Description

This article will provide an example of using G-Rules for EDI. The instructions for completing each of the steps within this article can be found in the G-Rules section of the knowledge base.


In This Article


Story:

A tester needs to apply specific business logic for one or more Elements (i.e., Attributes) within the generated EDI Document/Transaction Set. This logic will ensure that the appropriate value is generated for each Element.


The G-Rules shown in this example are for an EDI 837P Document and are for the NM1-SubmitterName_1000A Segment.

The user must ensure that an Individuals Name is generated when the following conditions exist:

  • NM101_EntityIndentifierCode = 41
  • NM102_EntityTypeQualifier = 1


They must also ensure that an Organization Name is generated when the following conditions exist:

  • NM101_EntityIndentifierCode = 41
  • NM102_EntityTypeQualifier = 2

The tester will need to create two G-Rules:

  • Rule 1 – Defines the Conditions and Actions for generating the name of a person when certain conditions are met.
  • Rule 2 – Defines the Conditions and Actions for generating an organization name when certain conditions are met.


Step 1: Create a G-Rule Suite

Create a G-Rule Suite within the G-Rules Management Dashboard. G-Rules are added and managed within a G-Rule Suite.



Step 2: Add the first G-Rule to the G-Rule Suite

Next, add the first G-Rule to the G-Rule Suite. Once added, users may add Conditions and Actions to the G-Rule.



Pseudo Code for the first G-Rule

IF (NM1_SubmitterName_1000A.NM101__EntityIdentifierCode == ’41’ AND
NM1_SubmitterName_1000A.NM102__EntityTypeQualifier == ‘1’)
THEN
NM1_SubmitterName_1000A.NM103__SubmitterLastOrOrganizationName = ‘Taylor’
NM1_SubmitterName_1000A.NM104__SubmitterFirstName = ‘Hycel’


Step 2a: Add the First Condition

The first Condition is for the NM101_EntityIdentifierCode Element within the NM1_SubmitterName_1000A Segment:


IF (NM1_SubmitterName_1000A.NM101__EntityIdentifierCode == ’41’ AND


Below is the setup for the first Condition:


Step 2b: Add the Second Condition

The second Condition is for the NM102_EntityTypeQualifier Element within the NM1_SubmitterName_1000A Segment:

NM1_SubmitterName_1000A.NM102__EntityTypeQualifier == ‘1’)


Below is the setup for the second Condition:



Step 2c: Add First Action

The first Action is for the NM102_SubmitterLastOrOrganizationName Element within the NM1_SubmitterName_1000A Segment. When the conditions are met, the value for this Element will be “Taylor”.


THEN
NM1_SubmitterName_1000A.NM103__SubmitterLastOrOrganizationName = ‘Taylor’

Below is the setup for the first Action:


Note: For this example, a constant value will be generated for the NM103_SubmitterLastOrOrganizatonName Element. Alternatively, a user can reference the NameGen Generator within an Action to generate a different Last Name for each EDI Document/Transaction Set.


Step 2d: Add Second Action

The second Action defines the value generated for the NM104_SubmitterFirstName Element within the NM1_SubmitterName_1000A Segment. When the conditions are met, the value for this Element will be “Hycel”.


NM1_SubmitterName_1000A.NM104__SubmitterFirstName = ‘Hycel’


Below is the setup for the second Action:


Note: For this example, we are generating a single constant value for the NM104_SubmitterFristName Element; however, users can reference the NameGen Generator to generate a different First Name for each EDI Document/Transaction Set.


Step 3: Add the second G-Rule to the G-Rule Suite

Next, add the second G-Rule to the G-Rule Suite. Once added, a user will be able to start adding Conditions and Actions to the G-Rule.



Pseudo Code for second G-Rule


IF (NM1_SubmitterName_1000A.NM101__EntityIdentifierCode == ’41’ AND
NM1_SubmitterName_1000A.NM102__EntityTypeQualifier == ‘2’)
THEN
NM1_SubmitterName_1000A.NM103__SubmitterLastOrOrganizationName = ‘GenRocket’
NM1_SubmitterName_1000A.NM104__SubmitterFirstName = GEN_VALUE


Step 3a: Add first Condition

The first Condition for the second G-Rule is for the NM101_EntityIdentifierCode Element within the NM1_SubmitterName_1000A Segment:

IF (NM1_SubmitterName_1000A.NM101__EntityIdentifierCode == ’41’ AND

Below is the setup for the first Condition:

Step 3b: Add the Second Condition

The second Condition is for the NM102_EntityTypeQualifier Element within the NM1_SubmitterName_1000A Segment:

NM1_SubmitterName_1000A.NM102__EntityTypeQualifier == ‘2’)

Below is the setup for the second Condition:

Step 3c: Add First Action

The first Action defines the value generated for the NM103_SubmitterLastOrOrganizationName Element within the NM1_SubmitterName_1000A Segment. When the conditions are met, the value for this Element will be “GenRocket”.


THEN
NM1_SubmitterName_1000A.NM103__SubmitterLastOrOrganizationName = ‘GenRocket’

Below is the setup for the first Action for the second G-Rule:

Note: In this example, we will generate a single constant value for the NM103_SubmitterLastOrOrganizatonName Element. We could also reference a Generator, such as the ListGen Generator, to create a list of different Organization Names. In doing so, the referenced Generator would randomly generate an Organization Name from the list for each EDI Document/Transaction Set.


Step 3d: Add the Second Action

The second Action defines the value generated for the NM104_SubmitterFirstName Element within the NM1_SubmitterName_1000A Segment.


NM1_SubmitterName_1000A.NM104__SubmitterFirstName = ‘GEN_VALUE’

Below is the setup for the second Action:

Generator Configuration for referenced ConstantGen Generator:

Note: The second Action ensures an individual’s first name is not generated within the EDI Document/Transaction Set when the Submitter is an organization.


Step 4: Add the G-Rule Suite to a G-Case

After setting up the necessary G-Rules, users can add the G-Rule Suite to a G-Case. The G-Rules will be applied automatically when the G-Case is used to generate EDI data.