Example 2: Using Rules in Loops

At the end of each repetition of the CLM loop in the data, we need to see if the claim total matches the total of the service lines. This example will show you how to do this.

  1. Go to the CLM02 and use SetVar to assign a variable S2300CLM02ClaimTotal: This variable holds the claim total.

  2. Go to the SV203 and use AddVar to total the service line amounts in a variable called S2400SV203ServiceAmt:

  3. Zero S2400SV203ServiceAmt on the CLM segment so that it will start over again for each repetition of the CLM loop:

  1. At the end of each repetition of the CLM loop in the data, see if the claim total matches the totaled service lines. To do this, we need to put a SetLoopPostInstanceExit early in the guideline, before the CLM loop. The usual place for these exits is on the ST segment.

    This example rule executes at the end of each repetition of the CLM loop (loop 2300) and compares the numeric values in the variables S2300CLM02ClaimTotal and S2400SV203ServiceAmt. If they are not the same, an error message displays.

For another example of rule usage in loops, see Balance.