Business Rules
TIBCO Foresight® Products
Business Rules
July 2015
Two-Second Advantage®
Important Information
SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED OR BUNDLED
TIBCO SOFTWARE IS SOLELY TO ENABLE THE FUNCTIONALITY (OR PROVIDE LIMITED ADD-ON FUNCTIONALITY) OF
THE LICENSED TIBCO SOFTWARE. THE EMBEDDED OR BUNDLED SOFTWARE IS NOT LICENSED TO BE USED OR
ACCESSED BY ANY OTHER TIBCO SOFTWARE OR FOR ANY OTHER PURPOSE.
USE OF TIBCO SOFTWARE AND THIS DOCUMENT IS SUBJECT TO THE TERMS AND CONDITIONS OF A LICENSE
AGREEMENT FOUND IN EITHER A SEPARATELY EXECUTED SOFTWARE LICENSE AGREEMENT, OR, IF THERE IS NO
SUCH SEPARATE AGREEMENT, THE CLICKWRAP END USER LICENSE AGREEMENT WHICH IS DISPLAYED DURING
DOWNLOAD OR INSTALLATION OF THE SOFTWARE (AND WHICH IS DUPLICATED IN THE LICENSE FILE) OR IF THERE
IS NO SUCH SOFTWARE LICENSE AGREEMENT OR CLICKWRAP END USER LICENSE AGREEMENT, THE LICENSE(S)
LOCATED IN THE “LICENSE” FILE(S) OF THE SOFTWARE. USE OF THIS DOCUMENT IS SUBJECT TO THOSE TERMS AND
CONDITIONS, AND YOUR USE HEREOF SHALL CONSTITUTE ACCEPTANCE OF AND AN AGREEMENT TO BE BOUND BY
THE SAME.
This document contains confidential information that is subject to U.S. and international copyright laws and treaties. No part of this document
may be reproduced in any form without the written authorization of TIBCO Software Inc.
TIBCO, Two-Second Advantage, TIBCO Foresight EDISIM, TIBCO Foresight HIPAA Validator Desktop, TIBCO Foresight ICD-10
Conversion Adapter, TIBCO Foresight Instream, and TIBCO Foresight Transaction Insight are either registered trademarks or trademarks of
TIBCO Software Inc. in the United States and/or other countries.
Enterprise Java Beans (EJB), Java Platform Enterprise Edition (Java EE), Java 2 Platform Enterprise Edition (J2EE), and all Java-based
trademarks and logos are trademarks or registered trademarks of Oracle Corporation in the U.S. and other countries.
All other product and company names and marks mentioned in this document are the property of their respective owners and are mentioned for
identification purposes only.
THIS SOFTWARE MAY BE AVAILABLE ON MULTIPLE OPERATING SYSTEMS. HOWEVER, NOT ALL OPERATING SYSTEM
PLATFORMS FOR A SPECIFIC SOFTWARE VERSION ARE RELEASED AT THE SAME TIME. SEE THE README FILE FOR
THE AVAILABILITY OF THIS SOFTWARE VERSION ON A SPECIFIC OPERATING SYSTEM PLATFORM.
THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT.
THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE
PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW
EDITIONS OF THIS DOCUMENT. TIBCO SOFTWARE INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE
PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS DOCUMENT AT ANY TIME.
THE CONTENTS OF THIS DOCUMENT MAY BE MODIFIED AND/OR QUALIFIED, DIRECTLY OR INDIRECTLY, BY OTHER
DOCUMENTATION WHICH ACCOMPANIES THIS SOFTWARE, INCLUDING BUT NOT LIMITED TO ANY RELEASE NOTES
AND "READ ME" FILES.
Copyright © 2010-2015 TIBCO Software Inc. ALL RIGHTS RESERVED.
General Contact Information
TIBCO Software Inc., Foresight Group
655 Metro Place South
Suite 900
Dublin OH 43017
Phone: (614) 791-1600
Fax: (614) 791-1609
Technical Support
E-mail: support@tibco.com
Web: https://support.tibco.com
(Note: Entry to this site requires a username and password. If you do not have one, you can request one. You must have a valid maintenance or
support contract to use this site.)
Contents
Introduction
1
Document Purpose ....................................................................................................... 1
Intended Audience ........................................................................................................ 1
What you need before using Business Rules............................................................... 2
Big Picture .................................................................................................................... 2
Viewing TIBCO Foresight-supplied HIPAA Rules ........................................................ 3
Using External Routines ............................................................................................... 4
*Call External Routine ............................................................................................ 4
Type the Rule ......................................................................................................... 5
Use the Parameters Grid ....................................................................................... 6
Registering new Business Rules .................................................................................. 8
Tutorials: Set up your own Rule
9
HIPAA business rule tutorial ......................................................................................... 9
Overview ................................................................................................................ 9
Create your own error message .......................................................................... 10
Set up a rule ......................................................................................................... 10
Copy the guideline from EDISIM to Instream ...................................................... 10
Test the rule ......................................................................................................... 11
Merge your business rule with a HIPAA guideline ............................................... 11
X12 business rule tutorial ........................................................................................... 12
Overview .............................................................................................................. 12
Set up a rule ......................................................................................................... 12
Test the rule ......................................................................................................... 13
Analyzer vs. other Validation Programs
14
Overview ..................................................................................................................... 14
Local Variables ........................................................................................................... 15
Condition and Rule Definition Dialog Box .................................................................. 16
External Routines ....................................................................................................... 17
Business Rules Reference
18
Overview ..................................................................................................................... 18
Reserved Variables .................................................................................................... 19
Current_Date........................................................................................................ 20
Current_Delim ...................................................................................................... 22
Current_Element .................................................................................................. 23
Current_ErrCount ................................................................................................. 24
Current_LoopCount ............................................................................................. 26
Current_LoopKey ................................................................................................. 26
Current_Row and Next_Row ............................................................................... 26
Current_Time ....................................................................................................... 27
GLOBAL_FILENAME ........................................................................................... 28
GLOBAL_FILEPATHNAME ................................................................................. 29
Using Reserved Variables in a Message ............................................................. 30
Business Rules
i
Contents
Literals ........................................................................................................................ 31
Escape Character for Double Quotes ........................................................................ 31
Copying Business Rules............................................................................................. 32
Printing Business Rules .............................................................................................. 33
Array Business Rules ................................................................................................. 34
Array Reserved Variables .................................................................................... 34
CheckVarFromArray ............................................................................................ 39
ClearArray ............................................................................................................ 40
CreateArray .......................................................................................................... 41
DumpArray ........................................................................................................... 42
GetArrayCurrentRowIndex ................................................................................... 42
GetArrayNextColumnIndex .................................................................................. 43
GetArrayNextRowIndex ....................................................................................... 44
GetARowFromArray ............................................................................................. 45
GetVarFromArray ................................................................................................. 47
SearchVarsInArray ............................................................................................... 48
SearchConditionsInArray ..................................................................................... 50
SetArrayFromVar ................................................................................................. 53
UpdateArrayFromDate ......................................................................................... 55
Correct Coding Initiatives (CCI) Business Rules ........................................................ 56
CCIInit .................................................................................................................. 57
CCICollect ............................................................................................................ 57
CCIAnalyze .......................................................................................................... 58
Code Lookup Business Rules .................................................................................... 59
FindCode .............................................................................................................. 59
FindCodeWithDate ............................................................................................... 61
FindUserCode ...................................................................................................... 63
FindUserCodeWithDate ....................................................................................... 63
ValidateZipState ................................................................................................... 64
Core3 (Phase III CORE) Business Rules ................................................................... 65
Custom Record Business Rules ................................................................................. 66
DefineCustomRec ................................................................................................ 68
OutputCustomRec ............................................................................................... 70
RemoveCustomRecord ........................................................................................ 71
Date and Time Business Rules .................................................................................. 72
CheckDateInRange .............................................................................................. 72
CompareDate ....................................................................................................... 74
DateCalc .............................................................................................................. 76
GetGMTDateTime ................................................................................................ 83
ValidateDateTimeUN and ValidateDateTimeX12 ................................................ 84
DBServer Business Rules .......................................................................................... 85
DBExecute ........................................................................................................... 85
DBQuery .............................................................................................................. 87
InvokeWebService ............................................................................................... 90
Exit Business Rules .................................................................................................... 93
ClearExits ............................................................................................................. 93
KeepOrder ............................................................................................................ 94
SetCompositePreExit ........................................................................................... 95
SetElementPostExit ............................................................................................. 96
SetLoopPostExit................................................................................................... 97
Business Rules
ii
Contents
SetLoopPostInstanceExit ..................................................................................... 99
SetSegmentPreExit ............................................................................................ 100
UserExitWithoutWait .......................................................................................... 102
UserExitWithWait ............................................................................................... 103
ICD Business Rules .................................................................................................. 106
List Business Rules .................................................................................................. 106
ClearList ............................................................................................................. 106
InList ................................................................................................................... 107
ListCheck ........................................................................................................... 108
ListContig ........................................................................................................... 110
ListCount ............................................................................................................ 112
ListGetVar .......................................................................................................... 113
ListInsert ............................................................................................................. 114
ListMinMax ......................................................................................................... 115
Lookahead Business Rules ...................................................................................... 118
Marking a Lookahead Range ............................................................................. 122
Creating Lookahead Business Rules ................................................................. 125
Looping Business Rules ........................................................................................... 129
ForEach .............................................................................................................. 130
Next .................................................................................................................... 131
ExitLoop ............................................................................................................. 131
Extended Looping Example ............................................................................... 132
ODBC Business Rules ............................................................................................. 133
Setting up your ODBC Connection String .......................................................... 134
DBOpen ............................................................................................................. 135
DBClose ............................................................................................................. 137
DBQuery ............................................................................................................ 138
DBExecute ......................................................................................................... 139
Run Business Rules ................................................................................................. 140
RunAlways ......................................................................................................... 140
RunNoData ........................................................................................................ 142
Substitute Business Rules ........................................................................................ 143
DeleteSegment .................................................................................................. 143
InsertSegment .................................................................................................... 144
MakeKey ............................................................................................................ 144
Substitute ........................................................................................................... 145
SubstituteFind .................................................................................................... 145
SubstituteReplace .............................................................................................. 146
Utilities Business Rules ............................................................................................ 147
AppendString ..................................................................................................... 147
BuildString .......................................................................................................... 149
ChangeCase ...................................................................................................... 151
ChangeElmAttribute ........................................................................................... 153
CheckFormat...................................................................................................... 155
CreateFSUID ...................................................................................................... 163
DisplayErrorByNumber ...................................................................................... 164
FindString ........................................................................................................... 166
GenerateFSUID ................................................................................................. 168
GetToken ........................................................................................................... 168
Identify................................................................................................................ 170
Business Rules
iii
Contents
IdentifierLookup.................................................................................................. 172
InsertIdentifier .................................................................................................... 173
Match ................................................................................................................. 173
MatchApplList..................................................................................................... 174
Normalize ........................................................................................................... 176
Numbers............................................................................................................. 181
OracleLookup and OracleLookupWithDate ....................................................... 182
OutputCTX ......................................................................................................... 184
ReplaceChars .................................................................................................... 185
ReplaceString..................................................................................................... 189
SetCheckCTT and SetCheckCTTCount ............................................................ 191
SetIdentifier ........................................................................................................ 192
SubString ........................................................................................................... 193
Trim .................................................................................................................... 194
TrimWhitespace ................................................................................................. 195
Variable Business Rules........................................................................................... 197
SetLocalVariable ................................................................................................ 197
SetVar ................................................................................................................ 198
AddVar ............................................................................................................... 199
Divide ................................................................................................................. 200
DumpVars .......................................................................................................... 201
Balance .............................................................................................................. 202
CompareString and CompareStringNoCase ..................................................... 204
CompareNstring ................................................................................................. 205
CompareNumeric ............................................................................................... 207
Clear ................................................................................................................... 208
ClearLocalVariable ............................................................................................. 209
FileTable Rules .................................................................................................. 210
GetInfo ............................................................................................................... 213
GetLength .......................................................................................................... 215
GetValueFromSegment ..................................................................................... 216
IsAlpha ............................................................................................................... 218
IsAlphaNum........................................................................................................ 219
IsNum ................................................................................................................. 220
SaveCurrentSegment ........................................................................................ 223
CheckCTT................................................................................................................. 224
FSVBExit.CheckDigit ................................................................................................ 226
X12 234-235 CheckDigit .................................................................................... 227
EDIFACT 3039-3055 CheckDigit ....................................................................... 228
Other CheckDigit Options .................................................................................. 229
User Defined Check Digit ................................................................................... 229
DateTime .................................................................................................................. 230
FSVBExit.DisplayMessage ....................................................................................... 231
ProductUtilities .......................................................................................................... 235
Appendix A: Variables
236
Local Variables ......................................................................................................... 236
When to use Local Variables ............................................................................. 236
Assigning a Local Variable ................................................................................. 236
BusinessRules.Variable ............................................................................................ 237
Business Rules
iv
Contents
When to use BusinessRules.Variable ................................................................ 237
Setting up BusinessRules.Variable .................................................................... 237
Good Variable Names .............................................................................................. 238
Global Variables ....................................................................................................... 239
TIBCO Foresight-Defined Variables ......................................................................... 239
Preprocessor Variables ............................................................................................ 242
Populating Variables with an External Variables File ............................................... 245
Initializing and Clearing Variables and Lists ............................................................. 246
Variable Maps ........................................................................................................... 248
Appendix B: Validator Error Messages
251
Viewing TIBCO Foresight-Supplied Error Messages ............................................... 251
Creating and Viewing your own Error Messages ..................................................... 251
Using your own Error Messages .............................................................................. 253
Troubleshooting Custom Error Messages ................................................................ 255
Appendix C: Code Tables
256
Setting up your own Code Tables ............................................................................ 256
Example A: External Code Table File ................................................................ 257
Extending existing HIPAA Code Tables ................................................................... 258
Appendix D: Complicated Rules
259
Simple Rules ............................................................................................................ 259
Complex Rules ......................................................................................................... 260
Example 1: Two Conditions create an Error Message ...................................... 260
Example 2: Using Rules in Loops ...................................................................... 262
Example 3: Adding and Comparing Numeric Values ......................................... 263
Appendix E: ODBC Examples
265
ODBC Tutorials and Demos ..................................................................................... 265
ODBC Example 1 ..................................................................................................... 266
Setting up a system DSN ................................................................................... 266
Looking at the Database .................................................................................... 267
Setting up the Error Message ............................................................................ 268
Creating the Rules ............................................................................................. 269
Testing the Rules ............................................................................................... 271
ODBC Example 2 ..................................................................................................... 272
Running the Demo in Desktop ........................................................................... 273
Running the Demo in Instream .......................................................................... 273
The Rules that made it Happen ......................................................................... 274
Appendix F: Guideline Merge
278
Overview ................................................................................................................... 278
Appendix G: Debug
279
EDISIM Validator Debug .......................................................................................... 279
Desktop and Instream Debug ................................................................................... 279
Appendix H: Troubleshooting Checklist
Business Rules
v
281
Contents
Appendix I: Processing Order
283
Appendix J: LookAhead and Array Extended Example
287
Array, Lookahead, and Web Services Demos ......................................................... 287
Summary of Rules – Top-Down ............................................................................... 288
Annotated Summary of Rules in Execution Order ................................................... 292
Appendix K: Building Business Rules
305
Overview ................................................................................................................... 305
Text Button ............................................................................................................... 305
Entry Examples ........................................................................................................ 306
Business Rules
vi
Contents
Introduction
Document Purpose
This document describes the external routines used to create business rules with TIBCO
Foresight® EDISIM®’s Standards Editor.
Business rule basics are in Fseditor.pdf in EDISIM’s Documentation directory.
Intended Audience
This document is intended for advanced users who are familiar with:

EDISIM Standards Editor.

The EDI guidelines for which rules are to be developed.

If the rules are to be used with EDISIM’s Analyzer, then familiarity with that product is
assumed.

If the rules are to be used with TIBCO Foresight® Instream® or TIBCO Foresight® HIPAA
Validator® Desktop, then familiarity with these products is assumed.
Before using this document, familiarize yourself with basics of business rules as described in the
Standards Editor manual, Fseditor.pdf.
You can open this manual from within Standards Editor by choosing Help | View the Manual.
Business Rules
1
Introduction
What you need before using Business Rules
You will need to install the following before using the business rules described in this document:

EDISIM

Instream or HIPAA Validator Desktop
Big Picture
You can create your own business rules and have Desktop, Instream, or EDISIM Analyzer enforce
them when it checks EDI files for compliance. These rules allow you to add additional checking
beyond that done by TIBCO Foresight-distributed guidelines.
Definitions
TIBCO Foresight guidelines
Guidelines that ship with EDISIM, Instream, and Desktop.
HIPAA
For those using TIBCO Foresight HIPAA validation products, these
guidelines in EDISIM contain types 1 and 2 edits. HIPAA-based
TIBCO Foresight guidelines in Validator include these same EDISIM
guidelines plus additional guidelines with types 1-6 edits. Refer to
ForesightHIPAAguidelinelist.pdf.
User guidelines
Guidelines that you create in EDISIM Standards Editor. They contain
your company's edits.
Production guideline Guidelines for Instream and Desktop that you create by merging a user
guideline with a TIBCO Foresight guideline. HIPAA-based Production
guidelines contain type 1-7 edits.
Major Steps for HIPAA validation users
To create a production guideline for Validator that includes both user and HIPAA rules:
1. Use EDISIM's Standards Editor to create a user guideline containing your own business rules.
2. Merge the user guideline containing your business rules with the corresponding TIBCO
Foresight types 1-6 guideline in Instream or Desktop. This creates a production guideline with
both user rules and HIPAA rules.
3. With Desktop or Instream, validate EDI data against the production guideline.
To create a guideline for Instream or Desktop that includes only user rules:
1. Use EDISIM's Standards Editor to create your own business rules in a user guideline.
2. Copy the user guideline's STD file from EDISIM’s User Files\Public Guidelines directory and
paste it into Instream or Desktop’s Database directory.
3. With Desktop or Instream, test your own rules by checking EDI data against the new guideline.
Business Rules
2
Introduction
Major Steps for EDISIM Analyzer users
1. Use EDISIM's Standards Editor to create a user guideline containing your own business rules.
2. With EDISIM Analyzer, check EDI data against the guideline. You will see diagnostic messages
created by the business rules.
Viewing TIBCO Foresight-supplied HIPAA Rules
Validator Only
TIBCO Foresight-supplied HIPAA business rules are not visible in Standards Editor, but you can
see them in Desktop’s Library. Click on the segment, composite, or element in Library’s top left
pane and look in the upper right corner.
For example:
1. Open Library with Start | Programs | Foresight | Desktop | Library.
2. Open the HIPAA guideline 4010837I.
3. Open loop 1000A and the PER segment at position 045 (Submitter EDI Contact Information)
and click on element 365 (Communication Number Qualifier) at PER05.
4. Scroll down in the upper right pane to see this business rule:
Business Rules
3
Introduction
Using External Routines
To create a rule that uses an external routine in Standards Editor, you have several options:

*Call External Routine ...........See page 4

Type the Rule ..........................See page 5

Use the Parameters Grid .......See page 6
*Call External Routine
1. Open the business rules box (right-click on the segment, composite, or element and choose
Business Rules).
2. Click New to bring up the Condition and Rule Definition dialog box. Set up the When to Run
the Rule area at the top of the box, if needed.
3. In the What Rule to Run area, select *Call External Routine in the drop box.
4. Click the down-arrow in the Server field and click the one of your choice. These are described in
detail in the rest of this document.
If it is not in the list, type it in in the Server line.
Business Rules
4
Introduction
5. Click the down-arrow in the Function field and click the one of your choice.
If the function is not there, type it in the Function line.
6. If the function requires parameters, type them in the Parameters field.
7. Click OK.
View the rule in the Business Rules dialog. If you need to change it, click Edit and make the
changes.
8. Click OK until you have exited all dialog boxes.
Type the Rule
1. Open the business rules box (right-click on the segment, composite, or element and choose
Business Rules).
2. Click New to bring up the Condition and Rule Definition dialog box. Set up the When to Run
the Rule area at the top of the box, if needed.
3. In the What Rule to Run area, select the rule from the drop list:
4. Click the Text button until you get an empty box where you can type the parameters:
Business Rules
5
Introduction
5. Referring to the parameters for the rule in Business Rules Reference, type the parameters, paying
particular attention to capitalization and parentheses:
6. Click OK until you have exited all dialog boxes.
Use the Parameters Grid
1. Open the business rules box (right-click on the segment, composite, or element and choose
Business Rules).
2. Click New to bring up the Condition and Rule Definition dialog box. Set up the When to Run
the Rule area at the top of the box, if needed.
3. In the What Rule to Run area, select the rule from the drop list:
4. Click the Text button until you get a parameters grid:
5. Click in the first Parameter Value line and read the Parameter Notes to the right.
Replace the contents of the line with the parameter value you want to use:
Business Rules
6
Introduction
6. Repeat for the other parameter values:
7. You cannot type in a line that has an fx to the right:
Instead, click the fx and then *All, or one of the categories:
Pick the sub-rule and click Select:
You will then have additional parameters in the grid for that sub-rule:
Business Rules
7
Introduction
The Parameter Names for a sub-rule are prefixed with > to indicate their depth:
8. When finished, click OK until you have exited all dialog boxes.
The Look-Ahead Rule checkboxes are explained in Lookahead Business Rules on page 118.
Registering new Business Rules
Two possibilities:

Until new rules are registered, select *Call External Routine at the top, and then type the Server
and Function in the fields provided.

Copy FSBRD.dat (if present) from Instream’s Bin directory into EDISIM’s Bin directory, or
request a copy from TIBCO Foresight Support. Then restart Standards Editor.
Business Rules
8
Introduction
Tutorials: Set up your own Rule
HIPAA business rule tutorial
Overview
This section shows you how to set up a rule that checks the transaction's date to be sure that it is
not in the future. Where it is in the future, you’d like an error message to be displayed:
Transaction date cannot be in the future.
Like most rules, this one has two parts:
A condition
An action
If the transaction date is in the future.
Then, issue an error message.
To create an example business rule, we'll take these steps:
1. Create your own error message .......................................................................page 10
2. Set up a rule .........................................................................................................page 10
3. Copy the guideline from EDISIM to Instream .............................................page 10
4. Test the rule.........................................................................................................page 11
5. Merge your business rule with a HIPAA guideline .......................................page 11
Business Rules
9
Tutorials: Set up your own Rule
Create your own error message
Use the instructions in Creating and Viewing your own Error Message on page 251 to create your
own error message number 32210 with this text:
Transaction date cannot be in the future.
Set up a rule
You will create a rule to:

See if the transaction date is in the future.

If so, issue error message 32210.
To create this rule, start an 837I guideline from 837AQ320 in Standards Editor and:
1. Click on the BHT-04.
2. Choose Edit | Advanced | Business Rules | New | Always.
3. In the What Rule to Run area, choose CompareDate from the drop box.
4. Fill out the bottom right as follows, using the same capitalization and spacing:
Where:
D8 Current_Element GT D8
Current_Date
See if the date in the current element is greater
than today's date.
If true, continue by executing the rest of the rule.
(BusinessRules.Utilities
DisplayErrorByNumber 32210)
Display the text of error number 32210.
5. Close the dialog boxes by clicking OK twice.
6. Save the guideline as RULESNEW.
Copy the guideline from EDISIM to Instream
You can test the rule using EDISIM Validator.
Instead, if you’d like, you can copy the RULESNEW.STD file in EDISIM’s User Files\Public
Guidelines directory and paste it in Desktop’s or Instream’s Database directory.
Business Rules
10
Tutorials: Set up your own Rule
Test the rule
When validating an EDI file against the RULESNEW guideline, your rule will be enforced.
To test this, validate 837I_4010_H_futureBHT04.txt or 837Idate.txt in the DemoData directory
of Instream or Desktop (Use the product that has your customized message 32210).
You should see the error message on the BHT segment, since the BHT-04 date is in the future.
Merge your business rule with a HIPAA guideline
HIPAA users:
Once you have verified that your business rule is operating correctly, you can merge it with the
corresponding HIPAA guideline, thus creating a guideline that will test both your rules and HIPAA
types 1-6 rules at the same time.
See Appendix F: Guideline Merge on page 278 for details.
Business Rules
11
Tutorials: Set up your own Rule
X12 business rule tutorial
Overview
You will create a rule for a 4010 850 transactions to:

See if Table 1’s REF-01 contains 06.

If not, issue this error message:
This REF-01 must contain a value of 06.
Set up a rule
To create this rule, start a 4010 850 guideline in Standards Editor and:
1
Click on the 050 REF-01.
2. Choose Edit | Advanced | Business Rules | New | Always.
3. In the What Rule to Run area, choose CompareString from the drop box.
4. Fill out the rule input area as follows, using the same capitalization and spacing:
Where:
Current_Element NE “06”
If the data in the current element is not 06, then
continue by executing the rest of the rule.
(BusinessRules.Utilities
DisplayErrorByNumber 0 0 “This REF-01
must contain a value of 06)
Display this message during analysis.
5. Close the dialog boxes by clicking OK twice.
6. Save the guideline as RULESNEW.
Business Rules
12
Tutorials: Set up your own Rule
Test the rule
When validating an EDI file against the RULESNEW guideline, your rule will be enforced.
To test this, open EDISIM’s Validator and check testpo1.txt in EDISIM’s Samples directory:
You should see the error message on the REF segment, since the REF-01 does not contain 06:
Business Rules
13
Tutorials: Set up your own Rule
Analyzer vs. other Validation
Programs
Overview
EDISIM Analyzer is a legacy product that supports validation of most, but not all of the
standards supported by Instream, Desktop, and EDISIM Validator. For example, Analyzer does
not validate HL7, XML, or Flat File data.
Analyzer does, however, support some standards that are not handled by the more recent
products such as GENCOD and ODETTE. (Refer to FileFormatsAtForesight.pdf for a
complete list.)
Due to these differences:

not all Business Rule functionality can be used with Analyzer. For example, reserved
variables cannot be used.

not all Business Rules can be used with Analyzer. For example, Array Business Rules cannot
be used.

Some Business Rules only apply to Analyzer. For example, the rule CheckCTT is Analyzeronly.
The following sections describe what business rules can be used with Analyzer.
Local Variables ............................................................................................................ page 15
Condition and Rule Definition Dialog Box............................................................ page 16
External Routines ....................................................................................................... page 17
Business Rules
14
Analyzer vs. other Validation Programs
Local Variables
Local variables are defined in the Local Variable area of the main business rules box. This
appears when you are on an element.
They work in business rules with all TIBCO Foresight validation programs:
See Local Variables on page 236 for details about where to use a local variable.
Business Rules
15
Analyzer vs. other Validation Programs
Condition and Rule Definition Dialog Box
Features of this box are available with all TIBCO Foresight validation programs.
Business Rules
16
Analyzer vs. other Validation Programs
External Routines
Most external routine business rules can be used with Analyzer.
The exceptions for Analyzer are as follows:
External Routines
Rule Type
Server Name
Exception(s)
Exits
BusinessRules.Exits
Not available:
UserExitWithWait
UserExitWithoutWait
Utilities
BusinessRules.Utilities
Note the following:
 CheckFormat does not look up the first three
digits of the SSN.
 DisplayErrorByNumber only supports explicit text.
 IdentifierLookup, OracleLookup,
OracleLookupWithDate, Substitute rules, and
SetIdentifier are ignored by Analyzer.
Variable
BusinessRules.Variable
Not available:
DumpVars
Business Rules
17
Analyzer vs. other Validation Programs
Business Rules Reference
Overview
EDISIM Validator, Desktop, and Instream support all business rules except where noted
otherwise in the Business Rules Reference section.
EDISIM Analyzer vs. other Validation Programs
EDISIM Analyzer is a legacy product that supports validation of many, but not all of the
standards supported by Instream, Desktop, and EDISIM Validator. For example, Analyzer does
not validate HL7, XML, or Flat File data.
Analyzer does, however, support some standards that are not handled by the more recent
products such as GENCOD and ODETTE. (Refer to FileFormatsAtForesight.pdf for a
complete list.)
Because of these differences:

Not all Business Rule functionality can be used with Analyzer. For example, reserved
variables cannot be used.

Not all Business Rules can be used with Analyzer. For example, Array Business Rules cannot
be used.

Some Business Rules only apply to Analyzer. For example, the rule CheckCTT is Analyzeronly.
Throughout this section, when Analyzer support is different it is noted as follows:
All validators except Analyzer
or
Analyzer Only
Business Rules
18
Business Rules Reference
Reserved Variables
Reserved variables are ones that do not have to be assigned in order for the system to determine
the value. They include
Current_Date ............................................................................................................ page 20
Current_Delim ......................................................................................................... page 22
Current_Element ..................................................................................................... page 23
Current_ErrCount ................................................................................................... page 24
Current_LoopCount................................................................................................ page 26
Current_LoopKey.................................................................................................... page 26
Current_Row and Next_Row ................................................................................ page 26
Current_Time ........................................................................................................... page 27
GLOBAL_FILENAME......................................................................................... page 28
GLOBAL_FILEPATHNAME............................................................................. page 29
Except where noted otherwise, these can be used in business rule parameters anywhere a variable
can be used.
Do not attempt use these reserved names for other purposes.
Business Rules
19
Business Rules Reference
Current_Date
All validators except Analyzer
Represents today’s date in your choice of formats.
Format
Current_Date_format
(case sensitive )
Where:
Current_Date_
Literal text.
format
Optional date format containing any combination of:
CC
YY
MM
DD
HH
mm
SS
separators
century
year
month
day
hour on 24-hour clock
minute (lower case mm)
(second)
(slash, hyphen, or colon)
If format is omitted, date will be in CCYYMMDD format.
In business rule:
Result if date is May 19, 2010
time is 1:45 PM)
Current_Date
20100519
Current_Date_CCYY
2010
Current_Date_YYMMDD
100519
Current_Date_ CCYY/MM/DD/HH/mm/SS
2010/05/19/13/45/00
Example 1
If the value in the current element (which is a date in format D8) is later than the current date,
then display error message 32210.
Business Rules
20
Business Rules Reference
Example 2
This uses the current date in an error message by surrounding it with %. The message must be
coded into the business rule rather than in the CustomerFSBRErrs.txt file.
Example 3
This is similar to Example 2, but combines the date and time:
If today is June 19, 2010 at 2:53 p.m., output will look like this:
Transaction was received at 201006191453
Business Rules
21
Business Rules Reference
Current_Delim
All validators except Analyzer
Returns the specified delimiter character.
If the character is a control character, then the corresponding number will be returned. For
example, if NewLine is the segment terminator, then Current_Delim will return '13'. If a
delimiter is not assigned a value, '-1' will be returned.
Format
Current_Delim(“delimiter”)
(case sensitive )
Where:
Current_Delim Literal text.
delimiter
One of these; include the surrounding parentheses and double quotes:
SEG
Segment terminator
ELM
Element delimiter
SUBELM
Subelement delimiter
REPELM
Repeating element delimiter
DEC
Decimal point character
ESC
Escape character
Example. This rule, which would typically be used in an EDIFACT message, sets variable
DPCHAR to a period or a comma, depending on the current decimal place character as specified
in the UNA Service String Advice segment.
This shows the decimal character that should be used:
The message shows that the decimal character is a period:
Business Rules
22
Business Rules Reference
Current_Element
All validators except Analyzer
Represents the value in the current element or field.
The rule should be applied to an item that directly holds data (EDI element, field, etc.) rather
than a segment, record, or other structure.
Format
(case sensitive )
Current_Element
Examples: This example places the value in the current element into variable
HI0102IndustryCode:
This example takes the first character of the value in the current element and places it in the
variable IDCode:
Business Rules
23
Business Rules Reference
Current_ErrCount
All validators except Analyzer
Represents the current total number of errors, up to the point where the variable is used, for the
specified severities or types.
Format
Current_ErrCount(criteria)
(case sensitive )
Where:
Current_ErrCount
Literal text.
(criteria)
Code defining the scope of the errors followed by the types or
severities. This must be within parentheses and immediately follow
ErrCount with no spaces.
Criteria
B
Optional
For Batch. Errors in this batch (the entire file), up to this point, are
counted.
If B is omitted, only errors in this transaction or message are
counted.
T
Optional
Types. This string of digits represents HIPAA type numbers.
If T is omitted, they are severity numbers.
T and B can be in any order, and either or both can be used or
omitted.
numbers
Business Rules
A string of digits specifying which types or severities should be
included in the counts. If preceded by a T, they are considered types
and can be 0-8. Otherwise, they are severities and can be 0-6. Please
see APF.pdf for details.
24
Business Rules Reference
Examples:
Current_ErrCount("34")
The total number of severity 3 and 4 errors in
the transaction up to this point.
Current_ErrCount("T34")
The total number of type 3 and 4 errors in the
transaction up to this point.
Current_ErrCount("B34")
The total number of severity 3 and 4 errors in
the batch up to this point.
Current_ErrCount("BT34")
The total number of type 3 and 4 errors in the
batch up to this point. (TB34 would also work).
Current_ErrCount("0123456")
The total number of all severity errors in the
transaction up to this point.
Current_ErrCount("B12")
The total number of Type 1 and 2 errors in the
batch up to this point.
Examples
This puts the count of the number of severity 3 and 4 errors encountered in the transaction set
into variable ERRCOUNTA.
This displays “Type 1 and 2 Errors Encountered!” if any Type 1 or 2 errors were encountered in
the batch before this point:
This displays the total number of type 1 and 2 errors in the batch up to this point: “12 Errors
Encountered!” Since %Current_ErrCount% does not have the criteria after it, the previous
criterion of TB12 is assumed.
Business Rules
25
Business Rules Reference
Current_LoopCount
All validators except Analyzer
Represents the current iteration of the current loop in GetInfo business rules (see page 210).
Current_LoopKey
All validators except Analyzer
Represents the loop ID and current iteration of the current loop in GetInfo business rules (see
page 210).
Current_Row and Next_Row
All validators except Analyzer
Represents the current or next array row index in some array business rules. Please see Array
Reserved Variables on page 34.
Business Rules
26
Business Rules Reference
Current_Time
All validators except Analyzer
Represents the current time in your choice of formats.
Format (case sensitive)
Current_Time_format
Where:
Current_Time
Literal text.
format
Optional time format containing any combination of:
HH
mm
SS
separators (slash, hyphen, or colon)
If format is omitted, time will be in HH:MM:SS format.
In business rule
Result if time is 1:45 PM
Current_Time
13:45:00
Current_Time_HHMM
1345
Current_Time_HHMMSS
134500
Current_Time_ MM/SS/HH
45/00/13
Example
Put the current time in HHMMSS format into variable POtime:
Business Rules
27
Business Rules Reference
GLOBAL_FILENAME
All validators except Analyzer
Represents the name of the file being validated. For example, this might contain the value
File.txt.
Format (case sensitive)
GLOBAL_FILENAME
Example
We store the first letter of the filename in a variable:
We put this on a certain PER segment. This displays a message if the segment is missing and the
filename starts with M.
Result in Desktop when the PER segment is missing and the filename starts with M:
Business Rules
28
Business Rules Reference
GLOBAL_FILEPATHNAME
All validators except Analyzer
Represents the path and name of the file being validated. For example, this might contain the
value c:\837P\File.txt.
Format (case sensitive)
GLOBAL_FILEPATHNAME
Example
We store the length of the path in a variable:
If it is longer than 120 characters, we issue a message:
Business Rules
29
Business Rules Reference
Using Reserved Variables in a Message
If you are hard-coding the message into the business rule, surround them with percent signs, like
this:
If the message is in CustomerFSBRErrs.txt:
Use # instead of % in the CustomerFSBRErrs.txt message:
32005 Order #Current_Element# received on #Current_Date# at #Current_Time#
Business Rules
30
Business Rules Reference
Literals
All validation programs
You can use literal values to insert specific values into rules. Literal values are normally
surrounded with double quotes.
Example: If the content of variable 2010BBNM108PayName equals the literal value PI and the
content of Current_Element does not equal the literal value AB123, then display error message
32212.
Escape Character for Double Quotes
To use a double quote within a parameter, and have it considered a literal, precede it with a \
slash.
Example
…
Incorrect:
Name EQ “John “Jack” Smith” (BusinessRules.Variable
Correct:
Name EQ “John \“Jack\” Smith” (BusinessRules.Variable
Business Rules
31
…
Business Rules Reference
Copying Business Rules
You can copy business rules and variable names between guidelines or within guidelines.
Copying a business rule
In Standards Editor:
1. Select the business rule in the main business rules box.
2. Use Ctrl-c or the Edit menu:
3. Go to the target business rules box and use Ctrl-v or the Edit menu to paste.
Business Rules
32
Business Rules Reference
Copying a variable
In Standards Editor:
1. In the main business rules box, select the entire variable name in the Local Variable text box.
2. Right-click on the text, and choose copy:
3. Go to the target location and use Ctrl-v or the Edit menu to paste. You can paste the variable
name into any location that uses the Windows clipboard (a word processor document,
spreadsheet, etc.).
Printing Business Rules
In Standards Editor, use File | Print | Print Rules to get a text report of all business rules.
Business Rules
33
Business Rules Reference
Array Business Rules
All validators except Analyzer
These rules set up and manipulate arrays, including those sent back by InvokeWebService rules.
For a complete example, please see Appendix J: LookAhead and Array Extended Example on
page 287.
Array rows and columns
Array business rules refer to cells in arrays by column and row. Example: cell 0,1 means column
0 and row 1. The top row in an array is row 0 and the first column is column 0.
Cell 0,1
row 0
row 1
row 2
column 0 column 1 column 2
Array Reserved Variables
Current_Row The current array row index (Set or Get array rules)
Next_Row
The next array row index (Set or Get array rules)
Last_Row
The last array row in the array (Get array rules only)
Set array rules like SetArrayFromVar and Get array rules like GetArrayCurrentRowIndex
maintain separate Current_Row and Next_Row pointers.
Row pointer for
“Set” array rules
Row pointer for
“Get” array rules
SetArrayFromVar
UpdateArrayFromDate
CheckVarFromArray
GetArrayCurrentRowIndex
GetArrayNextColumnIndex
GetArrayNextRowIndex
GetARowFromArray
GetVarFromArray
UpdateArrayFromDate
Business Rules
34
Business Rules Reference
Example 1
Filling the array:
1. SetArrayFromVar MyArray Current_Row 0 “A” - Puts A in 0,0:
A
2. SetArrayFromVar MyArray Current_Row 1 “B” - Puts B in 0,1:
A
B
3. SetArrayFromVar MyArray Next_Row 0 “C” - Puts C in 1,0:
A
B
C
4. SetArrayFromVar MyArray Current_Row 1 “D” - Puts D in 1,1:
A
B
C
D
5. SetArrayFromVar MyArray Next_Row 0 “E” - Puts E in 2,0:
A
B
C
D
E
Business Rules
35
Business Rules Reference
Getting values from array
6. GetVarFromArray MyArray Current_Row 0 MyVar - Gets A from 0,0 and puts it into MyVar
(Current_Row is pointing to the first row for this Get array rule - it is not related to the
Current_Row for Set array rules):
A
B
C
D
E
7. GetVarFromArray MyArray Current_Row 1 MyVar1 - Gets B from 0,1 and puts it into
MyVar1.
A
B
C
D
E
8. GetVarFromArray MyArray Next_Row 0 MyVar2 - Gets C from 1,0 and puts it into
MyVar2.
A
B
C
D
E
9. GetVarFromArray MyArray Last_Row 0 MyVar3 - Gets E from 1,0 and puts it into MyVar3.
This will always get from the last row in the array, regardless of previous Get array rules.
Last_Row is only used with Get array rules.
A
B
C
D
E
Business Rules
36
Business Rules Reference
Example 2
Assume we are loading provider names (NM103) and IDs (NM109) into an array called
ProvArray:
We want our array to contain a row for each billing provider:
first NM103 value
first NM109 value
second NM103 value
second NM109 value
third NM103 value
third NM109 value
etc.
We create the array on the ST segment:
Now, we load data into the array. We cannot hard-code a literal row number into our
SetArrayFromVar business rule because we would continually overwrite the first row. Instead,
we use Next_Row to automatically keep the row index incrementing.
This rule on the NM103 will load up the first column (Column 0), using the next row down each
time it executes:
Business Rules
37
Business Rules Reference
This rule on the NM109 will load up the second column (Column 1). Since we want this to be in
the same row as the previous rule on the NM103, we use Current_Row:
Business Rules
38
Business Rules Reference
CheckVarFromArray
Compare a value in a specific array cell to another value and perform an action if the two values
do not match.
Format of Parameters
arrayName rowIndex columnIndex ValueA (Actio n)
Where:
arrayName
Name of the array that contains the value to check. This can be a
variable or a literal in double quotes.
rowIndex
Array row index. This can be a variable or a literal in double quotes,
or one of the array reserved variables. Indexes start with 0. Please
read Array Reserved Variables on page 34 to see how current row is
determined for “Get” array rules.
columnIndex
Array column index. This can be a variable or a literal in double
quotes. Indexes start with 0.
valueA
The value to compare to the array value: a variable, literal in double
quotes, Current_Date, or Current_Element.
(Action)
The action to be executed if the result is false.
Examples
This rule checks the value in Array1BACK’s cell 0,4 (presumably returned from a web service
that checked a database). If the cell does not contain “1”, a message is displayed.
This does the same thing, except the row index is the number in variable SubNum:
Business Rules
39
Business Rules Reference
ClearArray
Remove data from all or part of an array.
Format of Parameter (three variations)
arrayName
arrayName rowIndex
arrayName rowIndex columnIndex
Where:
arrayName
Name of the array where data is to be cleared. This can be a variable
or a literal in double quotes.
rowIndex
Clear data only from this row. This can be a variable or a literal in
double quotes.
columnIndex
Clear data only from this column. This can be a variable or a literal
in double quotes.
Example 1. This clears all data from Array1:
Example 2. This clears all data from the row with index 2:
0
1
2
3
4
0
1
2
Business Rules
40
Business Rules Reference
Example 3. This clears data from the cell at row index 2 and column index 4:
0
1
2
3
4
0
1
2
CreateArray
Creates an array with the name of your choice. This rule typically goes on the ST segment, where
you can find it easily. However, it can go anywhere before it is used.
Format of Parameters
ArrayName
Where:
ArrayName
Name of the array you are creating. This can be a variable or a
literal in double quotes.
Examples
This rule creates an array named Array1.
This rule creates an array named whatever is in the variable Array1.
Business Rules
41
Business Rules Reference
DumpArray
Displays all values in an array.
Format of Parameters
ArrayName
Where:
ArrayName
Name of the array containing the data you want to see. This can be
a variable or a literal in double quotes.
Examples
This rule displays the contents of Array1:
In this example output, each row contains 5 values:
EMSG
9**FS Debug DLL Invoking InvokeWebService :
Row 0 = [2][9999][888888][aaaa][1]
EMSG
9**FS Debug DLL Invoking InvokeWebService :
Row 1 = [2][22222][NA][bbbbbb][1]
GetArrayCurrentRowIndex
Reports the index of the current row in the array.
As an alternative, use the Current_Row reserved variable.
Format of Parameters
arrayName indexVar
Where:
ArrayName
Name of the array containing the data you want to see. This can be
a variable or a literal in double quotes.
indexVar
A variable in which to return the current row’s index. The current
row is the last row that you inserted to. Please read Array Reserved
Variables on page 34 to see how current row is determined for
“Get” array rules.
See also the reserved variable Current_Row on page 34.
Business Rules
42
Business Rules Reference
GetArrayNextColumnIndex
Report the index of the column after the last column.
Format of Parameters
arrayName rowIndex indexVar
Where:
arrayName
Name of the array. This can be a variable or a literal in double
quotes.
rowIndex
The next column index of this row. This can be a variable or a
literal in double quotes, or one of the array reserved variables.
Indexes start with 0. Please read Array Reserved Variables on page
34 to see how current row is determined for “Get” array rules.
indexVar
A variable in which to return the index.
Example
AAA
55
BBB
123
XXX
432
Business Rules
NO
A5
43
Business Rules Reference
GetArrayNextRowIndex
Report the index of the row after the last row.
Format of Parameters
arrayName index
Where:
arrayName
Name of the array. This can be a variable or a literal in double
quotes.
indexVar
A variable in which to return the index. Please read Array Reserved
Variables on page 34 to see how the next row is determined for
“Get” array rules, and to read about the reserved variable
Next_Row.
Example
Business Rules
44
Business Rules Reference
GetARowFromArray
Populates one or more variables from a row in the array.
Format of Parameters
arrayName rowInd ex v arA varB v arC ..
Where:
arrayName
Name of the array. This can be a variable or a literal in double
quotes.
rowIndex
The row where the values are located. This can be a variable, a
literal in double quotes, or one of the array reserved variables.
Please read Array Reserved Variables on page 34 to see how to
specify a row for “Get” array rules.
varA
Variable to hold the contents of the first cell in the row. Use empty
double quotes to skip any cell.
varB
Variable to hold the contents of the second cell in the row.
var C
Continue with variable names until you have all the data that you
need from the row.
Examples
Assume that array WSout contains this:
row 1
1
SUB FNAME
SUB. DATEOFBIRTH
SUB GENDER
SUB LNAME
VALID DATE
1
PATRICK
19730203
M
WILSON
20010101
1
KATHERINE
19741125
F
WILSON
20010101
This business rule collects values from row 1:
With the array shown above:

Columns 0 and 1 would be skipped.

SubDOB would contain 19740203

SubGen would contain M

SubLnam would contain WILSON
Business Rules
45
Business Rules Reference
This rule is similar and collects values from the current row:
This rule is similar, and uses the row number stored in CurrentSearch_Row (from a
SearchVarsInArray or SearchConditionsInArray rule).
Business Rules
46
Business Rules Reference
GetVarFromArray
Populates a variable from a cell in an array.
Format of Parameters
arrayName rowIndex columnIndex v arName
Where:
arrayName
Name of the array that contains the value. This can be a variable or
a literal in double quotes.
rowIndex
The row where the cell is located. This can be a variable or a literal
in double quotes, or one of the array reserved variables. Indexes
start with 0. Please read Array Reserved Variables on page 34 to see
how current row is determined for “Get” array rules.
columnIndex
The column where the cell is located. This can be a variable or a
literal in double quotes.
varName
Variable that is to receive the value that was found in the array cell.
This can be a variable or a literal in double quotes.
Examples
These two rules show how you might check an array returned from InvokeWebService and then
use a value it contains. In this example, we are assuming that the web service returns a value of 1
if a certain value is not in a database.
This rule copies the value in Array1BACK’s row 0 column 4 into the variable NM109BACK:
This rule then checks this variable and displays a message if the value is 1.
Business Rules
47
Business Rules Reference
SearchVarsInArray
Search an array for a row that contains certain values, and perform an action if the search fails.
Results will be put in a variable CurrentSearch_Row. It will be set to the index of the row
where the values were found, or to -1 if there is no match.
Format of Parameters
arrayName valueA v alueB … (FailedAction)
Where:
arrayName
Name of the array to search. This can be a variable or a literal in
double quotes.
valueA valueB …
A list of values, each separated by a space. These can be any
combination of variables, literals in double quotes, Current_Date or
Current_Element. Please see the example below.
The list can contain one or more values. The first value will be
located in the first column of the array, the second value will be
located in the second column of the array, etc. To skip a column,
use empty double quotes. See the example below for details. All
values must be found in the same row for it to be considered a
match.
(Action)
The action to be executed no row contains all the values.
Example
Assume that we want to search an array for a subscriber with a certain date of birth, gender, and
last name. We have the array shown below (shading shows which columns are significant in this
particular search).
Assume that the list of values in the parameter is: "1" "" DMG02 Current_Element SLnam
The list maps to the columns like this:
matching row
Business Rules
"1"
""
DMG02
1
SUB FNAME
SUB. DATEOFBIRTH
SUB GENDER
SUB LNAME
VALID DATE
1
PATRICK
19740203
M
WILSON
20010101
1
KATHERINE
19741125
F
WILSON
20010101
1
RITA
19221120
F
O’NEILL
20010101
48
Current_Element
SLnam
Business Rules Reference
Assume:

DMG02
= 19741125

Current_Element
=F

SLnam
= WILSON
The array is searched like this:

All rows contain 1 in the first column, so all rows match so far.

The second column is skipped because of the empty "".

The third column contains one match to the contents of the variable DMG02 (19741125).
Only one row matches now.

In the fourth column of the row that still matches, the F matches the contents of
Current_Element.

In the fifth column of the row that still matches, WILSON matches the contents of SLnam.
Since we have a row that matches all values in the list, the Action in the business rule does
not execute.
The rule looks like this:
You can check CurrentSearch_Row for results. In this example, if the search succeeded, we
get the value from column two in the matched row and put the value into a variable SubDOB.
Business Rules
49
Business Rules Reference
SearchConditionsInArray
Search an array for a row that contains certain values, partial values, or combinations of values
and perform an action if the search fails.
Results will be put in a variable CurrentSearch_Row. It will be set to the index of the row
where the conditions were found, or to -1 if there is no match.
Format of Parameters
arrayNam #matches Criteria Criteria … (FailedAction)
Where:
arrayName
Name of the array to search. This can be a variable or a literal in
double quotes.
#matches
Number of columns that must match.
Criteria …
One or more sets of criteria, each separated by a space. Please see
matchCriteria format below. The first criteria applies to the first
column of the array, the second criteria applies to the second
column of the array, etc. To skip a column, use empty double
quotes. See the example below.
(FailedAction)
The action to be executed if no row matches the criteria.
Criteria
This can have several formats:

“”
Skip a column.

Literal in quotes.
Example: “SMITH”.

Variable.
Example: SubscrLName.

Comparison
The literal text COMP followed by a comparison of part or all of the
column contents with a value from the EDI. See below.
Comparison format:
COMP(EDIVar, EDIstart Arraystart, lengthToCompare, requirement )
Where:
COMP
Literal text indicating a comparison.
EDIvar
Value from EDI to compare.
EDIstart
Position in EDI value to start comparison.
Arraystart
Position in array value to start comparison.
lengthToCo mpare
Number of characters to compare.
requirement
M if values must match.
O if they do not have to match as long as the #matches is met.
Business Rules
50
Business Rules Reference
Example 1
Assume that we want to search an array for a subscriber who was born in November. If none are
found, we want to display the message “No subscribers in this transaction were born in
November.”
We are searching an array named Array1Back shown below (shading shows which column is
significant in this particular search; the underlined parts of the values are being compared to
“11”).
ANDREWS
ALAN
111222333
20010212
20040212
BROWN
BENITA
222333444
20010212
20080212
The business rule would be:
Where:
Array1Back
Name of array to search.
1
Number of matches required.
“”,””,””
The three sets of empty double quotes mean to skip the first three
columns in the array.
This brings us to the fourth column, where we have the comparison COMP("11",1,5,2,M)
COMP
Literal text meaning there is a comparison.
"11"
Literal value to compare to value in array.
1
Start comparing at position 1 in the value “11”.
5
Start comparing at position 5 in the array value
2
Compare 2 characters.
M
Must match.
BusinessRules.Utilities…
Action to take if no match is found.
In this example, the comparison will fail and the message will be displayed.
Example 2
Assume that we want to search the same array for a subscriber:

Whose last name starts with the letter in variable LnameStart

AND, whose birth month was November
If the array does not contain a row where both conditions match, we display a message.
Business Rules
51
Business Rules Reference
Where:
Array1Back
Name of array to search.
2
Number of matches required.
COMP(LnameStart,1,1,1,M)
In the first column, we start comparing the first position in variable
LnameStart, the first position in the array, one character , and they
must match.
“” “”
We skip the next two columns in the array.
COMP("11",1,5,2,M)This brings us to the fourth column, where we have the same
comparison that we did in Example 1.
In this example, the comparison will fail because no subscribers were born in November, and
both conditions are mandatory for success. The message will be displayed.
Example 3
Assume that we want to search the same array for a subscriber:

Whose last name starts with the letter in variable LnameStart

OR, whose birth month was November
If the array does not contain a row where at least one condition matches, we display a message.
The pertinent changes are underlined and in bold:
Array1Back 1 COMP(LnameStart,1,1,1,O) "" ""
COMP("11",1,5,2,O)(BusinessRules.Utilities DisplayErrorByNumber 0 0
"No subscribers had a last name starting with #LnameStart# in this
transaction and none were born in November")
The pertinent parts include;
The first 1
Means that only one match is needed: either the COMP in the first column or in
the fourth.
The first O
(Capital O for Optional) means that the first column’s comparison is not
required for success.
The second O
Means that the fourth column’s comparison is not required, either.
However, at least one of them is required due to the 1 immediately after the array name.
Business Rules
52
Business Rules Reference
Example 4
You can check CurrentSearch_Row for results. In this example, if the search succeeded, we get
the value from column two in the matched row and put the value into a variable IDnum.
SetArrayFromVar
Populates a cell in an array.
Format of Parameters
arrayName rowIndex columnIndex value
Where:
arrayName
Name of the array you are populating. This can be a variable or a
literal in double quotes.
rowIndex
The row where the cell is located. This can be a variable, a literal in
double quotes, or one of the array reserved variables. Please read
Array Reserved Variables on page 34 to see how to specify a row
for “Set” array rules.
columnIndex
The column where the cell is located. This can be a variable or a
literal in double quotes.
value
Source of value used to populate the cell. This can be a variable, a
“literal” in quotes, or a reserved variable like Current_Element.
Examples
This rule puts the value 0 into cell 0,5:
This rule puts the value in the variable SubNM109 into cell 0,5 in Array1:
Business Rules
53
Business Rules Reference
This rule puts the value in variable SubNM109 into an array named by the contents of a variable
called Array1Back. It will go in row 0. The column index is in variable SubNum.
Business Rules
54
Business Rules Reference
UpdateArrayFromDate
Compares two dates (one in the array) and updates the one in the array if the result is true.
Format of Parameters
arrayName rowIndex columnIndex operand dateV DateFormat
Where:
arrayName
Name of the array that contains the date. This can be a variable or a
literal in double quotes.
rowIndex
The array row where the date is located. This can be a variable, a
literal in double quotes, or one of the array reserved variables.
Please read Array Reserved Variables on page 34 to see how current
row is determined for “Set” array rules.
columnIndex
The array column where the date is located. This can be a variable
or a literal in double quotes.
operand
EQ, NE, GT, GE, LT, or LE.
dateV
Location of the date in the data: a variable, literal in double quotes,
Current_Date, or Current_Element.
DateFormat
D8
D6
(for YYYYMMDD)
(for YYMMDD)
The dates being compared must have the same format. This can be
a literal in quotes or a variable.
Example
If the date in the current element is less than the date in cell 0,2 of Array1, replace the array value
with the current element’s value. Format of both dates is YYYYMMDD.
Business Rules
55
Business Rules Reference
Correct Coding Initiatives (CCI) Business Rules
Instream and Desktop
HIPAA only
These rules enforce:

Correct Coding Initiatives (CCI) for Part B Medicare Carriers from the Centers for Medicare
and Medicaid Services (CMS).

National Correct Coding Initiative (NCCI) edits for Hospital Outpatient Prospective
Payment System (OPPS).
This initiative consists of a large number of CPT pairs, where the second CPT code:

Will not be paid if it occurs in the same claim and on the same service date as the first CPT
code.

Or, will not be paid if it occurs in the same claim and on the same service date unless a
modifier exists for the second code.
TIBCO Foresight has already added the rules for CCI checking in the PDSA837P and
B41A837P guidelines. You can turn on and off checking with a setting in the APF file (described
below).
You can add your own rules to your 837I guidelines to check for compliance to NCCI edits for
OPPS. TIBCO Foresight-supplied guidelines do not have these rules pre-built. See the sections
below on CCIInit, CCICollect, and CCIAnalyze.
Turning on CCI checking during validation
To validate with CCI or NCCI checking:

Use a guideline that has CCI or NCCI business rules set up.

Set CheckCCIEdits=1 in the APF file being used for validation.
The three CCI rules are:

CCIInit

CCICollect

CCIAnalyze
Business Rules
56
Business Rules Reference
CCIInit
Instream and Desktop
HIPAA only
Clears the collection of data to prepare for another claim.
CCI Part B Medicare: This rule is already attached to the CLM segment for PDSA837P and
B41A837P guidelines.
NCCI for Outpatient 837I: On the CLM segment of your own 837I guideline, use the O
parameter for NCCI for outpatient tables.
CCICollect
Instream and Desktop
HIPAA only
Collects information needed for the analysis. This rule goes on these segments that have data to
collect:
Segment
Collects …
2400 LX
Line count for use in error messages
2400 SV1, SV2, or SV3
Procedure codes and modifiers
2400 DTP for Service Date or
2300 DTP for Statement Dates
Date of service
Example
Business Rules
57
Business Rules Reference
CCIAnalyze
Instream and Desktop
HIPAA only
Analyze the data in the CCI and NCCI collection against the CCI and NCCI tables, and report
errors. The CCIAnalyze rule is usually set up on the ST segment to run at the end of each claim
loop.
This example rule runs at the end of any 2300 loop.
Only run the CCIAnalyze rule for NCCI checking if the CLM05-01 is an outpatient code.
CCI/NCCI error messages are in the range 31031 to 31070 and are listed in FSBRErrs.txt in the
Bin directory for Instream and Desktop.
Business Rules
58
Business Rules Reference
Code Lookup Business Rules
FindCode
Instream and Desktop
Issues an error message if the code is not valid. It looks up the code:

First, it checks code tables your company has set up (see Appendix C: Code Tables on page
256).

Then, for HIPAA guidelines, it checks for the presence of the code in the TIBCO Foresightdistributed external HIPAA code tables.
Format of Parameters
CodeTable
CodeValue
(ifNotFoundAction) (ifFoundActio n)
Where:
CodeTable
Name of the external code table.
CodeValue
Value to be checked. If omitted, the value in the current element is
assumed.
(ifNotFoundActio n)
Action to be taken if the value is not found in the table. The
parentheses must be included. To take no action, use
(BusinessRules.Utilities DoNothing)
(ifFoundActio n)
Optional. Action to be taken if the value is found in the table.
The parentheses must be included.
Examples
Business Rules
59
Business Rules Reference
Example parameters:
CPT4
CPT4 is the code table. Since CodeValue and ifNotFo undActio n
are omitted, this rule will use the code value in the current element
and issue a generic error message.
CPT4 A
A is a variable.
Since this has a CodeValue of A, see if the value in variable A is in
table CPT4. If the value is not found in table CPT4, issue a generic
error message.
CPT4 "A"
"A" is a literal.
Since this has a CodeValue of "A", check for the presence of code A
in table CPT4. If A is not found, issue a generic error message.
CPT4 Current_Element (BusinessRules.Utilities DisplayErrorByNumber 32201)
If the value in the current element is not found in table CPT4,
display the text in error number 32201.
We must include the second parameter, CodeValue, since we are
using the third parameter, (ifNotFoundActio n).
CPT4 Current_Element (BusinessRules.Utilities DoNothing)
(BusinessRules.Utilities DisplayErrorByNumber 32202)
If the value in the current element is not found in table CPT4, do
nothing.
If the value is found in table CPT4, display the text in error number
32202.
We must include all previous parameters, since we are using the last
parameter, (ifFoundActio n ).
Business Rules
60
Business Rules Reference
FindCodeWithDate
Instream and Desktop
Issues an error message if the code is not valid on a specific date. It looks up the code:

First, it checks code tables your company has set up (see Appendix C: Code Tables on page
256).

Then, for HIPAA guidelines, it checks for the presence of the code in the TIBCO Foresightdistributed external HIPAA code tables.
Format of Parameters
CodeTable CodeValue DateFormat DateToCheck (ifNotFoundAction) (ifFoundActio n)
Where:
CodeTable
Name of the external code table.
CodeValue
Value to be checked. It can be a literal in double quotes, a variable,
or Current_Element.
DateFormat
The format of the date, which must match the format of
DateToCheck. This can be a variable or a literal. If the date can be
in more than one format, assign a variable to the format element
and then call FindCodeWithDate.
DateToCheck
The date: a variable that has been assigned to a date element, a
literal in double quotes (such as "20030625"), or Current_Element
if it is a date.
(ifNotFoundActio n)
The action to be taken if the value is not effective on that
date. If omitted, a generic error message appears. The
parentheses must be included. To take no action, use
(BusinessRules.Utilities DoNothing)
(ifFoundActio n)
Optional. Action to be taken if the value is effective on that date.
The parentheses must be included.
Example 1. This rule checks to see if the facility code is valid for the transaction date. If not, it
displays error 32222.
Where:
FacilityCode
The table.
Current_Element Value of the element where the rule is attached.
D8
Business Rules
Date format for BHT04TransactionDate.
61
Business Rules Reference
BHT04TransactionDate
Variable assigned to the transaction date element.
(BusinessRules.Utilities DisplayErrorByNumber 32222)
Specifies that error message 32222 should be displayed if the
code is not valid for the transaction date.
Example 2. This rule on the statement date element checks to see if the date format is D8. If so,
it checks the facility code to see if it is valid on that date.
Where:
CompareString checks the element that has the BusinessRules.Variable S2300DTP02StmtDt
assigned to see if it contains D8.
If so, it executes the FindCodeWithDate function inside the outer parentheses:
FacilityCode
The table.
S2300CLM0501FacilityType
Variable assigned to the facility type element that is being checked.
D8
Date format.
Current_Element Value of the element where the rule is attached - the statement date.
(BusinessRules.Utilities DisplayErrorByNumber 32213)
Specifies that error 32213 should be displayed if the code is not
valid for the transaction date.
Business Rules
62
Business Rules Reference
FindUserCode
Instream and Desktop
Like FindCode (see page 59) but checks your own external code table only. It does not check
TIBCO Foresight’s table at all. See Appendix C: Code Tables on page 256.
FindUserCodeWithDate
Instream and Desktop
Like FindCodeWithDate (see page 61) but checks your own external code table only. It does not
check TIBCO Foresight’s table at all. See Appendix C: Code Tables on page 256.
Business Rules
63
Business Rules Reference
ValidateZipState
Instream and Desktop
HIPAA only
Checks the zip code and issues an error message if it is not valid for the state code.
If the zip code includes the four-digit extension (as in 43017-1111), only the first five digits will
be validated against the state code.
Format of Parameters
ZipCode StateCode ifNotMatchAction
Where:
ZipCode
Zip code element. It can be a variable or Current_Element.
StateCode
Current_Element, literal in double quotes, or a variable pointing
to the state element.
(ifNotMatchAction )
Optional. Action to be taken if the zip code is not valid in the state.
If omitted, the following message will be displayed: “ZipCode” is
not valid for the State “StateCode.”
Example. This rule is applied to the N403 to see if the zip code it contains is valid for the state
contained in the N402.
Set up variable 2010AAN402State.
here.
ValidateZipState rule goes here.
Where:
Current_Element Value of the zip code element where the rule is attached.
2010AAN402State Variable assigned to the state element.
(BusinessRules.Utilities DisplayErrorByNumber 32222)
Specifies that error 32222 should be displayed if the zip code is not
valid for the state.
Business Rules
64
Business Rules Reference
Core3 (Phase III CORE) Business Rules
Instream and Desktop
HIPAA only
The Phase III CORE 360 Uniform Use of Claim Adjustment Reason Codes and Remittance
Advice Remark Codes (835) Rule checks for certain valid combinations of Claim Adjustment
Group Codes (CAGC) with Claim Adjustment Reason Codes (CARC). This rule also checks for
valid combination of Claim Adjustment Reason Codes (CARC) with the Remittance Advise
Remark Codes (RARC).
In general:
 A CARC can be used only with certain CAGCs.

A CARC/CAGC pair may have a list of valid RARC(s), at least one of which must be used.
Turning on Phase III CORE checking during validation
To validate with Phase III CORE checking:

Use a guideline that has Core3 business rules set up. PDSA5010835.std and 5010-835.std
guidelines incorporate the Phase III CORE 360 Rule.

Set CheckCore3Edits=1 in the APF file being used for validation.
The Core3 rules are:

Core3CheckCARC

Core3CheckMissingRARCs

Core3Init

Core3TrackRARC
At this time, Core3 rules are for internal TIBCO Foresight use only.
Business Rules
65
Business Rules Reference
Custom Record Business Rules
Instream and Desktop
A custom record places the contents of actual data in the validation output stream. The name
and contents of the record are customizable. You might wish to display a patient ID number or
claim number in the output, for example.
You can set up custom records to be generated each time a message is placed in the output
stream, or on demand.
The layout of a custom record is:
Field
Notes
Record ID
1-4 alphanumeric characters. Avoid starting your Record ID with a Z, 00, S0, or
P0, or with any ID listed under Custom Record IDs to Avoid on page 67.
I n s t r e a m : Occupies positions 1-5, including a Z that is automatically added to
the beginning of the record.
D e s k t o p : Occupies positions 1-5. Includes a trailing colon. No Z added to
beginning.
I n s t r e a m o n l y . Automatically generated during validation: the number of the
segment line in the input file that caused the message to be generated.
Line #
Occupies positions 6-15.
Field 1Data
Contents of the specified BusinessRules.Variable name.
I n s t r e a m : Starts at position 16.
D e s k t o p : Starts at position 6.
Field n Data
Immediately after previous field
Desktop example custom record with two values:
CLM :2235057
Record ID
9012345918
First field's data
Second field's data
Instream example - same custom record
ZCLM
Record ID
482235057
9012345918
Line number
First field's data
Second field's data
Three functions let you create, output, and remove custom records that contain data of your
choosing:

DefineCustomRec

OutputCustomRec

RemoveCustomRec
Business Rules
66
Business Rules Reference
To set up a custom record:
1. Assign variables for the data that will be output. Use SetVar, AddVar, or other
BusinessRules.Variable (see page 237). You can assign these before or after defining the
record. Local variables will not work in custom records.
2. Define the record layout using DefineCustomRec (see page 68).
3. Output the record using OutputCustomRec (see page 70). This is not necessary for Automatic
records (see page 68).
Setting up variables for use by custom records
The example in the next two sections creates a record that contains the submitter number and
claim number, like this:
CLM :2235057
9012345918
ZCLM li n e nu mb er 2235057
9012345918
(Desktop)
(Instream)
We need to define BusinessRules.Variable for these two elements. To do this, we can use SetVar
to assign:

Variable 1000ANM109SubmitterNum to the submitter name.

Variable 2300CLM01ClaimNum to the claim number.
Custom Record IDs to Avoid
In general, avoid record names starting with X or Z unless you are using them with TIBCO
Foresight® Transaction Insight®.
Do not use these IDs for your own custom records.
BGNS
CLSP
CLSS
DPA1
DPA2
DPEL
DPNM
DPST
DPSV
DPTN
DSTC
DSVC
DTRN
Business Rules
GSSG
HCPN
HDDT
HLDP
HLIR
HLIS
HLRQ
HLSB
HLSP
HLSS
HLUM
IRNM
IRST
ISA1
ISNM
ISPN
ISST
MIA
P009
P010
P011
SREF
SSAA
S012
S020
SBA1
SBA2
SBEL
SBNM
SBST
SBSV
SBTN
SPAA
SPNM
SPST
SSTC
P012
P020
PRST
67
PTHD
RMRA
RMRB
RQAA
RQNM
RQST
S009
S010
S011
SSST
SSTN
SSVC
STRN
STST
TRSE
TS2
TS3
UMA1
UMA2
UMNM
UMST
XTID
XTIA
XD00-99
XF00-00
XM00-99
XN00-99
XS00-00
Business Rules Reference
DefineCustomRec
Instream and Desktop
Defines the layout of a custom record. This rule is normally attached to the ST
segment.
Format of Parameters
ID Flag VarI nfo
Where:
ID
An ID for the record: 1 to 4 alphanumeric characters. (Instream
output adds a Z to the beginning of the ID.)
Flag
M, D, or A.
M (Manual) Desktop and Instream. The record is output when
an OutputCustomRecord rule calls it. No accompanying detail
record is output.
D (Manual with Detail). Desktop and Instream. The custom
record is output when an OutputCustomRecord rule calls it. A
detail record is also output.
A (Automatic) Instream only. All automatic records output
whenever an error is encountered. No OutputCustomRecord
rule is needed. This might be useful if you want to show the
billing provider name, the claim number, etc., for each error. A
rule with a flag of A is ignored by Desktop.
VarInfo
Variables to be included in the output record. This is a list of
variable name and width pairs in the format variable/length. The
variable name and the length are separated by a slash. Commas
separate multiple variable/width pairs.
The variables have been set up with business rules like SetVar or
AddVar before being output. Undefined variables appear as blanks
in the record.
The length need not be the same as the length of the data in the
variable. It can be preceded with L to left-justify (the default) or R
to right-justify the data.
Example: VarOne/12,VarTwo/R5,VarThree/L10
This includes three variables: VarOne is left-justified in a field 12
characters wide, VarTwo is right-justified in a field 5 characters
wide, and VarThree is left-justified in a field 10 characters wide. The
L is actually not needed in the last pair, since it is the default.
Business Rules
68
Business Rules Reference
Example. This rule displays a record that contains the submitter number and claim number as
described on page 67.
Where:
CLM
ID of the custom record being defined.
M
Flag indicating Manual output (meaning the record is output when
called by a OutputCustomRec rule in either Desktop or Instream).
2300CLM01ClaimNum Variable containing data that is to be included in the record (in this
case, the claim number).
/
Separator between variable and its length.
20
Include the first 20 characters of the data from the variable.
,
Comma separates this variable/length pair from the next.
1000ANM109SubmitterNum/10
A second variable/length pair, this one showing the first 10 characters
of the contents of the Submitter NM109.
When output with OutputCustomRec, this message might look like:
CLM :2235057
9012345918
(Desktop)
or
ZCLM
482235057
9012345918
(Instream)
With Instream, a Z appears at the beginning of the record to flag it as a custom record. The line
number field is automatically added to the Instream record (in this example, eight spaces plus
48).
Fine-tuning the appearance of the custom record
You can add literal text to your message by setting up variables containing the literal text. Then
use these variables in the DefineCustomRec.
Business Rules
69
Business Rules Reference
OutputCustomRec
Instream and Desktop
Places custom records in the validation output.
Format of Parameters
ID ID ID …
Where:
ID
ID of the record: 1 to 4 alphanumeric characters. This ID was set up with a
DefineCustomRec rule. If the ID is omitted, all custom records are output.
Optional. Multiple record IDs can be included. Separate each with a space. The
custom records can include those defined with flags of M, A, or D.
Example. This rule displays the custom record CLM, defined in the example under
DefineCustomRec (see page 68). We can attach this rule to the CLM01, after the SetVar for the
variable used in the record definition.
With Instream, each OutputCustomRec command will first generate a DTL record, to identify
the location of the custom record in the data.
Business Rules
70
Business Rules Reference
RemoveCustomRecord
Instream and Desktop
Removes one or all custom record definitions and their outputs.
It is good practice to remove all custom records on the SE segment. This prevents the
definitions from remaining during further analyses for data in the same functional group.
You may also find this command useful for Instream. You can attach it to a location where you
no longer wish to see the automatic custom record.
Format of Parameters
ID ID ID …
Where:
ID
ID of the record: 1 to 4 alphanumeric characters. This record was set up with a
DefineCustomRec rule. If the ID is omitted, all custom records are removed.
Use a space to separate multiple record names.
Example. This rule removes the custom record CLM:
Business Rules
71
Business Rules Reference
Date and Time Business Rules
CheckDateInRange
All validation programs
Verifies whether a date falls within a range and takes an action if the test is true.
Format of Parameters
DateToCheckFormatCode DateToCheck Operand DateR angeFormatCode DateRange (IfTrueAction )
Where:
DateToCheckFormatCode The format of the date to check: a variable, literal in double
quotes, or Current_Element. Possible formats are:
D6
for YYMMDD
D8
for YYYYMMDD
DT
for YYMMDDHHMMSS
DateToCheck
The date that may or may not be in range. This can be a variable,
literal in double quotes, Current_Date, or
Current_Element.
Operand
InRange - Date is within the range, and is not the starting or
ending date of the range.
OutRange - Date is outside the range, and is not the starting or
ending date of the range.
InRangeEqual - Date is within the range or is the starting or
ending date of the range.
OutRangeEqual - Date is outside the range, or is the starting
or ending date of the range.
DateRangeFormatCode The format of the date range, always RD8 for YYYYMMDDYYYYMMDD format.
DateRange
A variable, literal in double quotes, or Current_Element.
(IfTrueAction)
Optional. The action to be executed if the result is true. If omitted,
a default message will be displayed.
Business Rules
72
Business Rules Reference
Example. This example checks that service line dates are within the range specified in the DTP
Statement Dates segment in the CLM loop. If not, it issues an error message.
To set this up, we need to put variables on the Statement Dates DTP02 and DTP03:
Use SetVar to assign variable
CLMStatementDateQual here.
Use SetVar to assign variable
CLMStatementDate here.
We will also need a variable on the Service Line Date DTP02, which offers a choice of two
codes.
CheckDateInRange rule
goes here.
We can then use these variables in a rule on the Service Line Date DTP03:
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
If it is possible that other date formats would appear in the data, then the rule would need to
become more complex, with CompareString used to check the formats of
CLMStatementDateQual and conditionally execute the rule above.
Business Rules
73
Business Rules Reference
CompareDate
All validation programs
Compares two dates based on the operand and performs an action if the result is true.
Format of Parameters
DateFormatCodeA DateVarA Operand DateFormatCodeB DateVarB (IfTrueAction)
Where:
DateFormatCodeA
D6
for YYMMDD
D8
for YYYYMMDD
DT
for YYYYMMDDHHMM
DateVarA
A variable, literal in double quotes, Current_Date, or
Current_Element.
Operand
EQ, NE, GT, GE, LT, or LE.
DateFormatCodeB
D6
for YYMMDD
D8
for YYYYMMDD
DT
for YYYYMMDDHHMM
DateVarB
A variable, literal in double quotes, Current_Date, or
Current_Element
(IfTrueAction)
Optional. The action to be executed if the result is true. If omitted,
a default message will be displayed.
Example. This example checks the service line date to see if it is in the future. If this is true, it
displays custom error message 32210, which might be "Service cannot have been performed in
the future."
Business Rules
74
Business Rules Reference
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
Rule goes here.
Business Rules
75
Business Rules Reference
DateCalc
All validation programs
DateCalc can be used in several ways:
Date Ranges:

Calculate how many days or months are in a date range and put the result in a variable.

Take action (such as displaying an error) based on the relationship between two dates.
Individual Dates:

Put the results of a calculation between two dates into a variable.

Display an error based on the calculation between two dates.
Example
Dates
Number
of days
Number of
months
20070922-20071021
21
1
20070922 and 20050922
730
24
Date Ranges: Calculate how many days or months are in an RD8 date range
DateCalc can calculate how many days or months are between the two dates in a date range. This
element would have a RD8 qualifier that contains a value like 20071028-20071204.
Format of Parameters
BYMONTH RD8 DateToCheck ResultVariable
Where:
BYMONTH
Literal. The difference between the two dates is to be calculated in
months. If omitted, the difference will be calculated in days.
RD8
Literal.
DateToCheck
The location of the date range: a variable, literal in double quotes,
Current_Date or Current_Element.
ResultVariable
A variable to hold the result of the calculation.
Business Rules
76
Business Rules Reference
Example 1 - number of days in a date range
This example calculates the number of days in the range contained in the current element and
places the result in variable NumOfServiceDays.
Another rule might then check the value in NumOfServiceDays and take some action:
Example 2 - number of months in a date range
This example is the same as the previous, but it calculates the number of months in the range
Example 3 - checking the qualifier first
Set a variable on the element Date Time Period Format Qualifier (in this example, we will use
DateFormat).
It then checks the variable to see if it contains RD8. If so, it calculates the number of days in the
range and places the result in variable NumOfServiceDays.
Business Rules
77
Business Rules Reference
Example 4: Creating a 6-month date range
This example creates a 6-month date range on the fly. The FutureDate variable will contain the
date 6 months from the Current_Date. It will be in D8 format. You can then use the FutureDate
to create a date range and check a date against that range.
Date Ranges: Take action based on the relationship between two RD8 dates
DateCalc can take action based on the relationship between a date range and another number.
Format of Parameters
BYMONTH RD8 DateToCheck Operand IntegerVar (action if true)
Where:
BYMONTH
The value is to be calculated in months. If omitted, the difference
will be calculated in days.
RD8
Literal.
DateToCheck
The location of the date range: a variable, literal in double quotes,
Current_Date or Current_Element.
Operand
Any of these: EQ, NE, GT, LT, GE, LE
IntegerVar
A variable containing an integer, or a literal in double quotes (such
as “5”).
(action if true)
Action to be taken if the calculation is true.
Example. This displays an error message if the number of days in the current date range is less
than the integer in the variable SV2Qty05.
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
Business Rules
78
Business Rules Reference
Individual Dates: Store the results of a calculation between dates in a variable
DateCalc can calculate how many days or months are between dates in two separate elements
and put the result in a variable.
Format of Parameters
BYMONTH DateFormat1 Date1 - DateFormat2 Date2 ResultVariable
or
BYMONTH DateFormat1 Date1 ± Integer ResultVariable
Where:
BYMONTH
The value is to be calculated in months. If omitted, the difference
will be calculated in days.
DateFormat1
The format of the first date:
If BYMONTH: D6, D8, or DT, or a variable containing one of
these values.
Date1
The location of the first date: a variable, literal in double quotes,
Current_Date or Current_Element.
-
A literal minus sign surrounded by spaces.
DateFormat2
The format of the second date: D6, D8, or DT, or a variable
containing one of these values.
Date2
The location of the second date: a variable, literal in double quotes,
Current_Date, or Current_Element.
ResultVariable
A variable to store the number of days between the two dates.
±
A plus sign or a minus sign surrounded by spaces.
Integer
A literal in double quotes or a variable containing an integer.
Example. This example calculates the number of days between the date in variable
BHT04StatementDate and the date in the current element. The result goes into variable
DelayInSubmitting.
Business Rules
79
Business Rules Reference
Individual Dates: Display an error based on the calculation between two dates
DateCalc can calculate how many days are between dates in two separate elements and put the
result in a variable.
Format of Parameters
BYMONTH DateFormat1 Date1 ± DateFormat2 Date2 Operand IntegerVar (actio n if true )
Where:
BYMONTH
The value is to be calculated in months. If omitted, the difference
will be calculated in days.
DateFormat1
The format of the first date: D6, D8, or DT, or a variable
containing one of these values.
Date1
The location of the first date: a variable, literal in double quotes,
Current_Date, or Current_Element.
±
A plus sign or a minus sign surrounded by spaces.
DateFormat2
The format of the second date: D6, D8, or DT, or a variable
containing one of these values.
Date2
The location of the second date: a variable, literal in double quotes,
Current_Date, or Current_Element.
Operand
Any of these: EQ, NE, GT, LT, GE, LE.
IntegerVar
A variable containing an integer, or a literal in double quotes (such
as “5”).
(action if true)
Action to be taken if the calculation is true.
Example. This example calculates the number of days between the date in variable
BHT04StatementDate and the date in the current element. If the result is more than 365, display
custom error message 32003.
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
Complete example
This set of rules in a HIPAA 837 will display an error if the transaction date and the date of
service are more than 4 months apart.
First, capture the transaction date on the BHT04:
Business Rules
80
Business Rules Reference
Go to the 2400 DTP03 for service date. In the first rule, capture the first 8 digits of the date:
In the second rule, capture the number of elapsed months:
In the third rule, display an error if the number of months is greater than 4:
Add or Subtract Hours and Adjust Date Accordingly
BYHOUR rules tell you how many days would have to be added or subtracted when you add or
subtract hours from a time. It also reports the new time.
For example, if the data contained a time of 1800 and you added 10 hours, it would report that
the time would be 0400, and one day would be added.
Format of Parameters
BYHOUR
DateFormat1
Date1
HourChange DateFormat2 Date2 DaysAdded
Where:
BYHOUR
Literal. Specifies that the difference between the two dates is to be
calculated in hours.
DateFormat1
The format of the time, one of these: TSDD, DT, TSD, TM or TS.
If unknown, use XX and validation will look at the value’s length to
pick one of these formats:
8
12
7
4
6
Date1
Business Rules
TSDD
DT
TSD
TM
TS
= HHMMSSDD
= CCYYMMDDHHMM
= HHMMSSD
= HHMM
= HHMMSS
The original time: a variable, literal in double quotes, Current_Time,
or Current_Element.
81
Business Rules Reference
HourChange
Hours to be added or subtracted - a variable or literal.
Examples:
8
-8
TimeChangeVar
DateFormat2
This should be the same as DateFormat1 .
Date2
A variable to contain the new date and time, after the hours have
been added to or subtracted from Date1.
DaysAdded
A variable containing the number of days that would need to be
added or subtracted to a date because of the time change.
Example. This example calculates the date when 9 hours is added to the time in the GS05. If
the new time runs into the next day, this information has to be captured in a variable in place of
the date in the GS04.
GS*BE*901234572000*908887732000*20100926*1615*3466*X*004010X095A1~
1.
Set a variable on the GS04 (a date):
This captures 20100926 in GS04Var.
2. Set up this rule on the GS05 (a time), which:

Adds 9 hours to the value in the GS05 and stores the result in variable NewGS05Var.

Determines that a time of 1615 + 9 hours = 2515. This means it is actually 0115 one
day later. The 1 is stored in DayAddedVar.
DateTime.DateCalc:BYHOUR TM Current_Element 9 TSDD NewGS05Var DaysAddedVar
3. Calculate the new date with this rule, also on the GS05:
DateTime.DateCalc:BYDAY D8 GS04Var DaysAddedVar D8 NewGS04Var
Business Rules
82
Business Rules Reference
Add Days to an existing Date
BYDAY rules add days to an existing date and put the result in a variable.
Format of Parameters
BYDAY DateFormat1 OriginalDate
DaysAdded
DateFormat2 NewDate
Where:
BYDAY
Literal. The difference between the two dates is to be calculated in
days.
DateFormat1
D6, D8, or DT.
OriginalDate
Input date. A literal in double quotes, a variable, Current_Element,
or Current_Date.
DaysAdded
A literal in double quotes or a variable containing the number of
days to add. If the value is negative, it will be subtracted from
OriginalDate.
DateFormat2
This should be the same as DateFormat1 .
NewDate
A variable to hold the new date.
Example. See the DateTime.DateCalc:BYDAY rule above.
GetGMTDateTime
Reports the current GMT date and time.
Format of Parameters
format
resultVar
Where:
format
resultVar
Business Rules
Format of the output, one of these:
Format
Output will look like:
RTS
DT
TSD
TSDD
MM-DD-CCYY
HH:MM:SS
CCYYMMDDHHMMSS
CCYYMMDDHHMM
HHMMSSD
HHMMSSDD
MM-DD-CCYY
HH:MM:SS
Variable to hold the current GMT date and time.
83
Business Rules Reference
Example: This rule puts the current GMT date and time in variable GMTvar, using format
CCYYMMDDHHMM. GMTvar might contain something like this: 201104012142
ValidateDateTimeUN and ValidateDateTimeX12
All validation programs
ValidateDateTimeX12
Place this rule on an X12 element 1251. It checks the date
and time in the current element to see if it follows the format
specified in the preceding element 1250. Be sure to
customize the code values for the qualifier in element 1250
ValidateDateTimeUN
Place this rule on an EDIFACT element 2380 to see if it
follows the format specified in the following element 2379.
Be sure to customize the code values for the qualifier in
element 2380.
Format of Parameters
<falseRule>
Where:
falseRule
(Optional) The rule to be executed if ValidateDateTimeX12 or
ValidateDateTimeUN check fails. This parameter must be another
rule to run. If omitted, a default message is displayed.
Example. This rule checks X12 element 1251.
Example. This rule checks EDIFACT element 2380. If the check fails, Error 32001 is displayed.
Business Rules
84
Business Rules Reference
DBServer Business Rules
Instream on UNIX
Important
Validating with these rules requires additional setup outside of
the guideline. Please see ISIserver.pdf for details.
These functions interact with Oracle or SQL Server databases from Instream that is running on
AIX:

The DBExecute function runs a stored procedure. See below.

The DBQuery function sends a query. See page 87.
The InvokeWebService function sends an array to a web service and receives one back.
DBExecute
Executes a stored procedure in an Oracle or SQL Server database.
Format of the Parameters
DBRef ReturnCode “Sto redProc params” {v ar1=1 {var2=2 …}} { (business rule )}
Where:
DBRef
Name of a database connection specified in the ISIserver.config’s
[ORACLE] or [SQL] sections (see ISIserver.pdf).
Example:
The DBRef is ORACLEDB in this business rule parameter:
ORACLEDB RetVal "check_NPI" NPIactive=1
It is also ORACLEDB in the ISIserver.config:
ORACLEDB=DATABASE{192.168.1.74:1521/or10};USER{ISUsr};PW
D{Q1W2E3}
ReturnCode
The name of a variable to contain the success of the DBExecute
rule. It will always contain 1. Therefore, please check the output
variables from the stored procedure to determine what action to
take.
If the rule failed, the DTL file will have more information like this:
EMSG
10SQL ERROR : [BRDatabase::DBExecute SQLExecDirect Failed. [-1]]
Business Rules
85
Business Rules Reference
StoredProc params
The stored procedure to execute followed by a space and its input
parameters, each separated by one space. You can include business
rule variables in the stored procedure’s name in the form %var%
where var is the name of a business rule variable. Before the
command is processed, var will be replaced with the contents of the
specified variable.
In the stored procedure, always put the output parameters first, like
this example:
CREATE PROCEDURE verifyXXXx
(@variableout varchar(50) out,
@variablein
varchar(50)
)
{var1=1 {v ar2=2 …}}
Variables to contain the values returned from the procedure. The
contents of these variables are automatically set to null strings
before the business rule executes the procedure. The “=1” means it
is the first parameter returned from the procedure, the “=2” means
it is the second parameter returned, etc.
{(business rule )}
Optional business rules to run at the end. See example 2 below.
This is especially useful in end of loop rules, which run in reverse
order.
Example 1: This rule executes a stored procedure called checkNPIproc in the database
referenced by SQLnpi in ISIserver.config. It sends the value in the current element as the proc’s
one input parameter. The only returned item is stored in variable InDB.
This rule then checks the procedure’s output parameter InDB and displays an error if it equals 1:
Example 2: This rule executes the checkNPIproc, checks the procedure’s InDB output value,
and displays a message if it doesn’t contain 1.
Business Rules
86
Business Rules Reference
DBQuery
Performs a SQL or Oracle query on a specified database.
Format of the Parameters
DBRef ReturnCode “SqlStatement” {var1=1 {var2=2 …}}
Where:
DBRef
Name of a database connection specified in the ISIserver.config’s
[ORACLE] or [SQL] sections.
ReturnCode
The name of a variable to contain the success of the database query.
It will contain one of these:
0 = database query failed (check database setup)
1 = database query succeeded
If the query failed, the DTL file will have an EMSG with more
information.
Note: This return code does not indicate success or failure of the
business rule. It indicates success/failure of the database query.
Success or failure of the business rule is indicated in {var1=1
{var2=2 …}}.
“SqlStatement”
SQL command to execute. The SQL command must return a
recordset. The SQL command can contain business rule variables in
the form %var% where var is the name of a business rule variable.
Before the SQL command is processed, variables in the SQL string
will be replaced with the contents of the specified variable.
{var1=1 {v ar2=2 …}}
Variables to contain the values returned from the query. The
contents of these variables are automatically set to null strings
before the business rule executes the query. The “=1” means it is
the first value returned from the procedure, the “=2” means it is the
second query returned, etc.
{(business rule )}
Business Rules
Optional business rules to run at the end. See example 3 below.
This is especially useful in end of loop rules, which run in reverse
order.
87
Business Rules Reference
Example 1
This rule queries a database to see if the current element is in table NPI in the database with
connection name SQLnpi.
This rule then uses the values in the returned variables NPI and Last:
DTL file results:
EMSG
Qian
10The database query for this provider returned
123456789 and
The Server-Thread log results in ISIserver’s fslog directory show success:
Example 2
This rule captures the value in the NM103 into this variable:
We then use this value in our DBQuery:
Business Rules
88
Business Rules Reference
Example 3
This example ends with a rule that checks the return code and displays an error message if the
query failed.
Business Rules
89
Business Rules Reference
InvokeWebService
HIPAA validation programs
In addition to a business rule developer, this requires:

A Java or web services developer to create a Java class.

Someone to install and configure TIBCO Foresight’s ISIserver.
Please see ISIserver.pdf for instructions on these steps.
For an extended example, see Appendix J: LookAhead and Array Extended Example on page
287.
TIBCO Foresight web services business rules give you a standardized way to send information
out to your own components. Instream acts as the client to your external web service.
You will need to create a Java class to serve as the client to your web service. At runtime, we will
call the class and invoke it according to the contract.
For instance, you might send a subscriber ID and the corresponding service line dates to a web
service. The web service might then execute a database lookup and return information about
whether the subscriber was covered on those dates. Another business rule could then check the
results and display an error message if they were not covered.
InvokeWebService is compliant with WS-I version 1.1 and tested in Java and .NET
environments. It sends an array to your web service and receives an array in return.
Overview
InvokeWebService sends a business rule array to TIBCO Foresight’s ISIserver program, which
passes it on to your own web service. It receives a response array that your guideline can use with
array business rules.
ISIserver.
config
Instream
ISIserver.
config
Array from
business rule
to web service
Invoke-Web
Service
business rule
ISIserver
Web service
client
Array from web
service to
business rule
Business Rules
90
Business Rules Reference
During validation
1. Before starting Instream or Desktop validation, start ISIserver.exe.
2. Instream or Desktop reaches an InvokeWebService business rule during validation.
3. This creates an instance of the Java class and sends an array of information to it.
4. The class can then perform any operations it requires to work with the data.
5. The web service returns another array to Instream or Desktop.
Format of Parameters
WSName inputArrayName outputArrayName (action)
Where:
WSName
Web service reference name; must match the name in
ISIserver.config’s[WEBSERVICES] section:
inputArray Name
Name of the array being sent to the web service. This must be a
literal in double quotes. It was defined and populated with Array
business rules (see page 33).
outputArrayName
Name of the array being returned from the web service. This must
be a literal in double quotes. It was defined with a CreateArray
business rule (see page 41).
actio n
Optional. The action to be executed if the call fails.
Business Rules
91
Business Rules Reference
Examples
These all invoke a web service called ChkSubSrv. They send an array called ArrayTOsrv and
receive back an array called ArrayFROMsrv. If the web service fails to start, a message displays.
Example 1. This is the simplest way to invoke a web service.
Example 2. This invokes the same web service only if there is no data on the current element.
Example 3. This invokes the same web service at the end of each instance of the 2000B loop.
Business Rules
92
Business Rules Reference
Exit Business Rules
An exit causes a rule to run every time a certain event occurs. Example: whenever a certain
element, composite, or segment is encountered, or whenever a certain loop ends.
If you have multiple Exit rules for a particular item, they run in reverse order. See Appendix I:
Processing Order on page 283.
Recommendation
When using these rules, place them on the ST segment, regardless of where they are to
run:
SetCompositePreExit
SetElementPostExit
SetLoopPostExit
SetLoopPostInstanceExit
SetSegmentPreExit
ClearExits
All validation programs
Clears all currently-set exits.
A typical use is to place this business rule on the ST segment to clear all exits that may be
lingering from previous transactions in the same file.
Business Rules
93
Business Rules Reference
KeepOrder
Desktop, EDISIM Validator, Instream
Causes element, segment, and group/loop exit rules to process in the same order as specified in
the Standards Editor Business Rules window.
Normally, SetCompositePreExit, SetElementPostExit, SetLoopPostExit,
SetLoopPostInstanceExit, and SetSegmentPreExit rules execute in reverse order.
KeepOrder is mainly needed within business rule loops.
Format of Parameters:
KeepOrder has no parameters.
Example 1. Normal execution order for exit rules:
List of exit rules at a one location:
Execution order
BusinessRules.Exits.SetSegmentPreExit UNT Rule #1
Rule #5
BusinessRules.Exits.SetSegmentPreExit UNT Rule #2
Rule #4
BusinessRules.Exits.SetSegmentPreExit UNT Rule #3
Rule #3
BusinessRules.Exits.SetSegmentPreExit UNT Rule #4
Rule #2
BusinessRules.Exits.SetSegmentPreExit UNT Rule #5
Rule #1
Example 2. Effect of KeepOrder rule on execution order for exit rules:
List of exit rules at a one location:
Execution order
BusinessRules.Exits.SetSegmentPreExit UNT Rule #1
Rule #2
BusinessRules.Exits.SetSegmentPreExit UNT Rule #2
Rule #1
BusinessRules.Exits. KeepOrder
Rule #3
BusinessRules.Exits.SetSegmentPreExit UNT Rule #3
Rule #4
BusinessRules.Exits.SetSegmentPreExit UNT Rule #4
Rule #5
BusinessRules.Exits.SetSegmentPreExit UNT Rule #5
Business Rules
94
Business Rules Reference
SetCompositePreExit
All validation programs
Calls a function before each occurrence of a specified composite is processed.
Format of Parameters
CompositeID ServerNam e
Functio nName FunctionParms
Where:
CompositeID
The 4-character composite ID where the function should run.
ServerName
The server that should run whenever Validator encounters a
composite with that ID.
FunctionName
The function within that server, if the function has parameters.
FunctionParms
The parameters for that function, if the function has parameters.
Example. This example displays a message whenever Validator encounters a composite with ID
C024:
Message 32217 is a custom message in file CustomerFSBRERRS.TXT.
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
Execution Order of Multiple SetCompositePreExit Rules
When validating a composite, the rules directly on the composite execute first, and then the
pertinent SetCompositePreExit rules execute. Unlike other business rules, these
SetCompositePreExit rules execute in the reverse order from how they are listed. See Appendix
I: Processing Order on page 283.
Business Rules
95
Business Rules Reference
SetElementPostExit
All validation programs
Calls a function after each occurrence of a specified element is processed. This rule slows down
validation significantly.
Format of Parameters
ElementID ServerName
FunctionName Functio nParms
Where:
ElementID
The element ID where the function should run.
ServerName
The server that should run whenever Validator encounters an
element with that ID.
FunctionName
The function within that server.
FunctionParms
The parameters for that function, if the function has parameters.
Example. This example displays a message 32214 (which might say, for example, "Presence of
SBR02 indicates a subscriber-as-patient scenario") whenever Validator encounters element 1069.
The rule is placed on the element itself so that it executes only when the SBR02 contains data.
Message 32214 is a custom message in file CustomerFSBRERRS.txt.
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
Execution order of multiple SetElementPostExitRules
Rules directly on the element execute before the SetElementPostExit rules.
Unlike other business rules, SetElementPostExit executes in reverse order from how they are
listed. See Appendix I: Processing Order on page 283.
Business Rules
96
Business Rules Reference
SetLoopPostExit
All validation programs
Calls a function after completion of all repetitions of the specified loop.
Place this business rule on the ST segment.
Format of Parameters
LoopID ServerName F unctio nName FunctionParms
Where:
LoopID
The loop ID where the function should run.
ServerName
The server that should run after Validator completes processing all
occurrences of the loop with that ID.
FunctionName
The function within that server.
FunctionParms
The parameters for that function, if the function has parameters.
Example. This example uses AddVar to total the quantities in CAS segments in each 837I claim
loop. The variable used for totaling is SLAdjustTot.
Put this SetLoopPostExit rule on the ST segment.
At the end of ALL repetitions of loop 2430 for this service line, it displays custom message
32215 ("Total adjustment amount for this claim is <value of SLAdjustTot >"). 2430 is the ID
for the Service Line Loop.
This is the error message in CustomerFSBRERRS.TXT:
32215 Total adjustment amount for the claim above is #SLAdjustTot#
If the rule is to be used with Analyzer, the DisplayErrorByNumber format is slightly different.
Business Rules
97
Business Rules Reference
In this example, the rules can be applied in these locations:
Up to 25 adjudication
loops per claim loop.
Place an AddVar rule on
all quantities in the CAS
segment to accumulate
total in a variable called
SLAdjustTot.
You will need to use SetVar to reset the variable SLAdjustTot to 0 at the top of the CLM loop to
zero the calculation for the next repetition of the loop.
Execution order of multiple SetLoopPostExit
After rules execute on all repetitions of a loop, the pertinent SetLoopPostExit rules execute.
Unlike other business rules, SetLoopPostExit rules, by default, execute in the reverse order from
how they are listed. See Appendix I: Processing Order on page 283.
Business Rules
98
Business Rules Reference
SetLoopPostInstanceExit
All validation programs
Calls a function after completion of each repetition of the specified loop.
Place this business rule on the ST segment.
This function is exactly like SetLoopPostExit (page 98) except that it executes the function at the
end of EACH REPETITION of the loop.
Format of Parameters
LoopID ServerName F unctio nName FunctionParms
Where:
LoopID
The ID of the loop where the function should run.
ServerName
The server that should run after Validator completes processing of
each repetition of the loop with that ID.
FunctionName
The function within that server.
FunctionParms
The parameters for that function, if any.
Example. This example displays a message at the end of each instance of loop 2300 (the claim
loop):
Message 32212 appears in file CustomerFSBRERRS.TXT and might say, for example:
End of CLM loop #CLMcount#
In Validator, this would display messages like these:
End of CLM loop 1
End of CLM loop 2
End of CLM loop 3
Business Rules
99
Business Rules Reference
CLMcount is a variable that counts the number of CLM segments. It was created by placing the
following AddVar rule on the CLM segment:
Create a SetLoopPostExit rule for the CLM loop that resets CLMcount to 0 at the end of all
repetitions of the CLM loop.
Execution Order of Multiple SetLoopPostInstanceExits
After rules execute on a repetition of a loop, all pertinent SetLoopPostInstanceExits rules
execute.
Unlike other business rules, SetLoopPostInstanceExits rules execute in the reverse order from
how they are listed. See Appendix I: Processing Order on page 283.
SetSegmentPreExit
All validation programs
Calls a function before each occurrence of a specified segment is processed.
Format of Parameters
SegmentID ServerName FunctionName FunctionParms
Where:
SegmentID
The 2 or 3-letter segment ID where the function should run.
ServerName
The server that should run whenever Validator encounters a
segment with that ID.
FunctionName
The function within that server.
FunctionParms
The parameters for that function, if the function has parameters.
Example. This example displays custom message 32213 ("Beginning of claim number nnn")
whenever Validator encounters a CLM segment.
The business rule on the ST segment is:
Business Rules
100
Business Rules Reference
Message 32213 is a custom message in file CustomerFSBRERRS.txt that includes the variable
assigned to the claim number:
32213 Beginning of claim number #S2300CLM01ClaimNum#
Execution Order of Multiple SetSegmentPreExit
All rules directly on the segment execute first.
Then, all pertinent SetSegmentPreExit rules for that segment execute. Unlike other business
rules, these execute in the reverse order from how they are listed. See Appendix I: Processing
Order on page 283.
Business Rules
101
Business Rules Reference
UserExitWithoutWait
Instream and Desktop
Starts an external program and immediately continues with validation. The outcome of the
external program’s activities has no effect on validation.
InStream
--------------------BusRule
-------------------------------
ProgramName Var1 var2 …
External
program
Program output
Format of Parameters
ExecutableName Var1 Var2 ...
Where:
ExecutableName
Name of executable to process.
Var
Optional. An input parameter to the executable being processed.
This can be a BusinessRules.Variable, a literal in double quotes, or
Current_Element. You can include any number of these, each
separated by a space.
Identifying the location of the program called by a user exit
Set the environment variable FSUSEREXITS.
You can do this system-wide or within the batch file that runs validation. Do not put quotes
around the path for FSUSEREXITS, even if it contains spaces, and don’t add a trailing slash:
SET FSUSEREXITS=C:\Foresight\InStream\DemoData\UserExits
"C:\Foresight\InStream\Bin\HVInStream.exe"
-i"C:\Foresight\InStream\DemoData\Two837i.txt"
-o"C:\Foresight\InStream\Output\Two837iNW_Results.txt" -gREISSUE
HIPAA example
This rule checks the BHT02 to see if it 18. If so, it runs an external program that logs the
submitter’s ID into a file.
A working demo of this example is installed with HIPAA Instream. Please see readme-UserExits.txt in
Instream’s DemoData\UserExits directory.
The rule we are trying to create is:
If the BHT02 = 18
Create a local variable on the BHT02
Then Run Reissue.bat
Run a UserExitWithoutWait and pass it the NM109
(submitter ID)
Business Rules
102
Business Rules Reference
To do this:
1. Create a local variable on the BHT02 (in this example, we will name it BHT02):
2. On the 1000A Submitter NM109-09, test the variable and create the rule to run the
UserExitWithoutWait. This rule runs Reissue.bat and passes it the contents of the current
element:
Reissue.bat might contain:
set InStreamRoot= C:\Foresight\InStream
echo %1 >> "%InStreamRoot%\Output\ReissueLog.txt"
UserExitWithWait
Instream and Desktop
Runs an external program and waits up to a specified number of seconds for a response, which it
puts into a specified list and then continues with validation.
InStream
--------------------BusRule
----------
---------------------
External Program

Input
ReturnList WaitTime
ProgramName Var1 Var2 …
outval1
%2
ReturnList
val1
val2
Stdout
%1

Variables
FS_UserExit_Status
FS_UserExit_RtnCode
 Business rule runs external program and passes it some

Program
output
outval2
.
.
.
.
.
.
values.
It specifies the name of a list to hold returned values from the external program. It also
specifies the number of seconds to wait before killing the external program.
 The external program runs and produces output that goes back to Instream via standard
output.
Business Rules
103
Business Rules Reference
 Instream puts the returning values into the list.
It also captures the program’s return code and a status into variables FS_UserExit_ RtnCode
and FS_UserExit_Status (see TIBCO Foresight-Defined
Variables on page 239).
Statuses can be:
200
201
202
203
204
User Exit business rule has been encountered
User Exit business rule has been called
The User Exit business rule has completed
The User Exit business rule timed out
The User Exit business rule failed
After the exit rule, you can use a CompareString business rule to check the contents of
FS_UserExit_Status and FS_UserExit_RtnCode and display a message, like this:
… where the error message (32004 in this example) would be something like this:
32004 UserExit to run Reissue2.bat return code is #FS_UserExit_RtnCode# and
status is #FS_UserExit_Status#
… and the output might be:
EMSG
6UserExit to run Reissue2.bat return code is 0 and status is 202
 Validation continues, presumably executing additional rules that make use of the list and two
variables.
Format of Parameters
ResultList WaitTimeI nSeconds ExecutableName Var1 Var2 ...
Where:
ResultList
BusinessRules.List containing values returned by the UserExit. This
list can contain duplicate values.
If the list exists, it is cleared before returned values are added.
If the list does not exit, it is created.
“WaitTimeInSeconds” Number of seconds before Instream should continue. This is an
integer in double quotes or a variable containing an integer.
If the external program does not send a return code to Instream
within the allotted seconds, it is killed and validation continues.
Examples:
“5”
WaitSeconds
ExecutableName
Business Rules
Name of executable to process.
104
Business Rules Reference
Var
Optional. An input parameter to the external program, which can
be a BusinessRule.Variable, a literal in double quotes, or
Current_Element. Use any number of these, each separated by a
space.
Please see Identifying the location of the program called by a user exit on page 102 for details
about how to set an environment variable that is necessary when using a User Exit.
Example
This example runs an external file called Reissue1.bat and passes it the contents of the current
element. Any value returned from Reissue1.bat goes in list Reissue1. If there is no response from
Reissue1.bat within 10 seconds, Reissue1.bat is killed and validation continues.
A working demo of this example is installed with Instream. Please see readme-UserExits.txt
in Instream’s DemoData\UserExits directory.
This rule is on the 837I 1000A NM1-09:
Each time the rule executes, it checks local variable BHT02 to see if it contains 18. If so, this rule
runs batch file Reissue1, which might contain, for example:
@if "%1%"=="123456789" @echo valid submitter
@if not "%1%"=="123456789" @echo invalid submitter
This example checks to see if the current element contains 123456789, the only provider who
can submit claims over 10000. It sends “valid submitter” or “invalid submitter” to list Reissue1.
In a subsequent rule, you might run a ListCheck on the list Reissue1 and display an error
message if it contains “invalid submitter.”
Business Rules
105
Business Rules Reference
ICD Business Rules
Using Instream validation and Dataswapper, you can convert and replace ICD-9 with ICD-10
codes and vice versa. You will need the TIBCO Foresight® ICD-10 Conversion Adapter, which
is a separate product.
Business rules for ICD conversion include:

ICDConvertOne

ICDConvert

ICDInsertToArrayWith Type
These are described in ICD_at_Foresight.pdf.
List Business Rules
This section describes how to accumulate lists of values from an EDI file and then act on them
in various ways.
ClearList
All validation programs
Removes one or all lists from the repository. You should clear a list specifically whenever you
want it cleared. Do not count on it being automatically cleared at the end of a transaction set,
group, or interchange.
The location of the ClearList is important. A typical place is on the first segment in a repeating
loop or on the first required element of a repeating segment.
Caution
It is hazardous to use ClearList without specifying which list is
being cleared. A ClearList without a list name results in clearing all
lists, including those in the HIPAA guideline with which you will
eventually merge your rules.
Format of Parameters
ListName
Where:
ListName
Business Rules
Optional but recommended. Name of the list to be removed. If
<ListName> is omitted, all lists are removed. See caution above.
106
Business Rules Reference
Example. This example removes list 2300CRCconditionInd.
InList
All validation programs
Adds a value to a list. Takes an action if the value is already in the list.
Format of Parameters
ListName ListValue if AlreadyInListAction
Where:
ListName
Name of the list. If the list does not exist, it is created.
ListValue
Optional. Value to be added to the list. This can be a variable, a
literal in double quotes, or Current_Element. If omitted,
Current_Element is assumed.
(ifAlreadyInListAction )
Optional. Action to be taken if ListValue is already in ListName.
If omitted, a default message displays if the value is already in the
list.
Example. This example checks Condition Indicator values to be sure that they are not
duplicated within the segment. As each Condition Indicator value is encountered in the EDI file,
a rule checks to see if it is in a list called 2300CRCconditionInd. If so, a custom error message is
issued. If not, it is added to the list.
Message 32216 is a custom message in file CustomerFSBRERRS.txt. The format of
DisplayErrorByNumber is different for rules used by Analyzer.
Business Rules
107
Business Rules Reference
ListCheck
All validation programs
Checks for the presence of a certain value in a list and takes action based in whether it is found
in the list.
Format of Parameters
ListName ListValue Operand (IfTrueAction)
Where:
ListName
Name of the list to be checked.
ListValue
The value that may or may not be in the list. This can be a variable,
literal value in double quotes, or Current_Element.
Operand
Either InList (indicating the value is in the list) or OutList
(indicating the value is not in the list). These are case-sensitive.
(IfTrueAction)
Optional. Action to be taken if the test is true: If the operand is
InList, this action will be taken only if the value is in the list. If the
operand is OutList, this action will be taken only if the value is not
in the list. If omitted, a general message is displayed.
Example
ListName:
ListValue:
Operand
(IfTrueAction)
2010AAPERQual
TE
OutList
(BusinessRules.Utilities DisplayErrorByNumber 32217)
This example issues a message if the data in the PER segment does not include a telephone
number. We used ListInsert to create a list containing the values in each Communication
Number Qualifier in the segment, and then use ListCheck to issue an error message if the list
does not contain the list value "TE".
Message 32217 is a custom message in file CustomerFSBRERRS.txt.
Business Rules
108
Business Rules Reference
The format of DisplayErrorByNumber is different for rules used by Analyzer.
ClearList of the 2010AAPERQual
list.
Use ListInsert to record values
of each Communication Number
Qualifier in 2010AAPERQual
list.
Use ListCheck to see if
2010AAPERQual contains "TE".
Business Rules
109
Business Rules Reference
ListContig
All validation programs except Analyzer
Check whether a list contains a contiguous block of dates or integers. Before using ListContig,
the list already has to be defined.
They do not have to be in any order, and representations of the same number are acceptable
unless you use both the D and U parameters. Here are some examples:
Contents of list
Contiguous?
1, 2, 3, 4, 5, 6, 7, 8
Yes
No
Reason
Empty lists are not considered contiguous
1, 2, 4, 5, 7, 8, 10, 55
No
2, 4, 6, 5, 3, 8, 7, 1
Yes
Order does not matter
1, 01, 2, 3, 4, 5, 6, 06, 7, 8
Yes
Representation of the same number are allowed in
non-date lists
20071231, 20080101
Yes, with “D”
option
See below for additional information on the D
parameter
No without “D”
option
20071230, 20080101
No
20071201-20071231,
20080101-20080131
Yes with “D”
option
01/01/2008-03/31/2008,
02/01/2008-04/15/2008,
04/15/2008, 04/16/200804/30/2008
Yes, with D
option but not
U option
The dates cover the contiguous period 01/01/2008
through 04/30/2008 and overlapping is OK
01/01/2008-03/31/2008,
02/01/2008-04/15/2008,
04/15/2008, 04/16/200804/30/2008
No, with D and
U option
The dates/ranges overlap:
Business Rules
Missing 20071231
01/01/2008-03/31/2008 overlaps 02/01/200804/15/2008
04/15/2008 is in the first two ranges
110
Business Rules Reference
Format of Parameters
ListName ResultVar (D) (U)
Where:
ListName
Name of the list to be checked.
ResultVar
Name of the variable where the result is to be stored. It will be 1 if
the list is contiguous, or 0 if not.
D
Optional. D causes ListContig to consider the values in the list as
dates, and also enables ListContig to recognize date ranges. Any
hours, minutes, or seconds, in the dates are ignored. Without the D
option, ListContig treats the values as integers. This parameter must
be a constant within double-quotes.
U
Optional. It requires the D option and must immediately follow the
D with no space, like this:
Mydatelist DateResults DU
U (which stands for Unique) checks to see if the dates and date
ranges are unique. Dates must be unique and contiguous to get a 1
in ResultVar.
This parameter must be a constant within double-quotes.
For example, if the list contains the following dates (in human
readable form, for easy consumption):
01/01/2008-03/31/2008
02/01/2008-04/15/2008
04/15/2008
04/16/2008-04/30/2008
ListContig without the U would pass, because the dates cover the
contiguous period 01/01/2008 through 04/30/2008.
ListContig with the U would fail because the list contains
overlapping dates/ranges: 01/01/2008-03/31/2008 overlaps
02/01/2008-04/15/2008 and 04/15/2008 is in the first two ranges.
Example. We have a list of Invoice Numbers called InvcList. We check to make sure that there
are no gaps in the invoices received:
Server
Function
Parameter
BusinessRules.Lists
ListContig
InvcList InvcContig
BusinessRules.Utilities
CompareNumeric
InvcContig EQ 0
(BusinessRules.Utilities.DisplayError ByNumber 0 0
“Missing at least one Invoice Number”)
Business Rules
111
Business Rules Reference
We first check list InvcList with the ListContig function to determine whether it contains a
contiguous list of numbers. The result goes into variable InvcContig, which will be either a 1 if
InvcList is contiguous, or 0 if it is not contiguous. We then check InvcContig for 0 and display
an error message if true.
ListCount
All validation programs
Reports the number of entries in a list. Before using ListCount, the list already has to be defined
and in use.
Format of Parameters
ListName ResultVar
Where:
ListName
Name of the list, which already exists.
ResultVar
Name of the variable that is to contain the count. If the variable
does not exist, it is created.
Example. This example is from loop 2010AA REF01 in a HIPAA 837I. The REF01 can occur
up to 8 times. We want to know how many were used, because we only allow 5 and we want to
make sure that the Qualifier 1B was the first occurrence.
Rule 1 on REF01: Add the contents of the REF01 to the list.
Rule 2 on REF01: Count the number of list entries and put them in variable ProvQualifier.
Rule 3 on REF01: Display an error message if the count exceeds 5.
Business Rules
112
Business Rules Reference
Rules 4 and 5 on REF01: Check the first entry in the list.
Put the first entry from the list into a variable.
Check the variable and issue a message if it is not 1B:
ListGetVar
All validation programs
Places entry n from a list into a variable.
Format of Parameters
ListName ListEntry ResultVar
Where:
ListName
Name of the list.
ListEntry
Position of the entry in the list – an integer in double quotes or a
variable that contains an integer.
ResultVar
A variable that is to contain the value from the list. If the variable
does not exist, it is created.
Example. This example takes the first value in the list Reissue1 and places it in a variable called
ReissueAnswer.
Business Rules
113
Business Rules Reference
ListInsert
All validation programs
Adds one or more values to a list. If the values are already in the list, they are not added again.
Format of Parameters
ListName ListValue <ListValue …>
Where:
ListName
Name of the list. If the list does not exist, it is created.
ListValue
Optional. Value to be added to the list. Variable, literal in double
quotes, or Current_Element. If omitted, Current_Element is
used.
To add multiple values, separate each with a space.
Important: The maximum total length of all values is 4000
characters. If you have more than that, do another ListInsert to the
same list.
Examples
This example inserts the value of the current element into list 2010BAN403Zip. Subsequent
repetitions of the loop would add more zip codes to the list.
This example inserts the value of the variable Subscr_ID, the value of the current element, and
the literal value 00000 into a list called Subscribers.
Business Rules
114
Business Rules Reference
ListMinMax
All validation products except Analyzer
Acquires this information about a list, which has been set up with other List rules:

Minimum and maximum values in the list.

Positions in the list of the minimum and maximum values.

Count of the number of objects in the list, or number of days spanned by the lists members.
Format of Parameters
ListName MinResultVar MaxResultVar <CountR esultVar MinPosResultVar
MaxPosResultVar <Options>>
Where:
ListName
Name of the list, which already exists.
MinResultVar
Variable where the list’s minimum value is to be stored.
MaxResultVar
Variable where the list’s maximum value is to be stored.
CountResultVar
Optional. Variable where the list’s object count is to be stored.
For date lists (see Options below), this is the number of days
spanned by the lists members.
For other lists, this is the number of members in the list.
MinPosResultVar
Optional. Variable that contains the name of the variable where the
position of the list’s minimum value is to be stored. Requires use of
CountResultVar .
MaxPosResultVar
Optional. Variable that contains the name of the variable where the
position of the list’s maximum value is to be stored. Requires use
of CountResultVar and MinPosResultVar .
Options
Optional. One of these:
“D” causes ListMinMax to consider the values in the list as dates,
and lets ListMinMax recognize date ranges. Any hours, minutes, or
seconds, in the dates are ignored. It will also change the way the
object count is determines (see CountResultVar above). Include
quotes around “D”.
“S” causes ListMinMax to treat ListName as a list of strings.
Without any option, the values are considered integers. Include
quotes around “S”.
If you use options, include CountResultVar , MinPosResultVar ,
and MaxPosResultVar to maintain positions.
Business Rules
115
Business Rules Reference
Example 1. List of integers.
With no Options (defaults to Integer):
Results:
VMin
VMax
VCount
VMinPos
VMaxPos
=1
= 10
=6
=1
=4
(members)
(first item in list)
(fourth item in list)
VMin
VMax
VCount
VMinPos
VMaxPos
=1
=9
=6
=1
=5
(with strings, 9 comes after 10)
(members)
(first item in list)
(fifth item in list)
With Options equal to S:
Results:
Business Rules
116
Business Rules Reference
Example 2. List of strings.
Assume that NameList = Greig, Beth, Cindy, Dorrie, Woody, Norman
ListMinMax NList VMin VMax VCount VMinPos VMaxPos
Results:
VMin
VMax
VCount
VMinPos
VMaxPos
PeriodList
= Beth
= Woody
=6
(members)
=2
(second item in list)
=5
(fifth item in list)
= 20071201, 20080101, 2007010120070331
Example 3. List of dates, including ranges with and without hyphens.
Assume that PeriodList = 20071201-20071208, 20080101, 2007010120070331
ListMinMax PeriodList VMin VMax VCount VMinPos VMaxPos “D”
Results:
VMin
VMax
VCount
VMinPos
VMaxPos
= 20070101
= 20080101
= 99
(Days)
=3
(third item in list)
=2
(second item in list)
ListMinMax PeriodList VMin VMax VCount VMinPos VMaxPos “S”
Results:
VMin
VMax
VCount
VMinPos
VMaxPos
= 2007010120070331
= 20080101
=3
(members)
=3
(third item in list)
=2
(second item in list)
ListMinMax PeriodList Placeholder1 Placeholder2 Placeholder3 VMinPos “S”
We don’t care about the min, max, and count but we need them in the parameters as
placeholders. We actually name them Placeholder1, etc., to clarify that we aren’t using them. We
omit the last parameter (the maximum value) since it is at the end and isn’t needed as a
placeholder.
Results:
Business Rules
Placeholder1
Placeholder2
Placeholder3
VMinPos
= 2007010120070331
= 20080101
= 3 (Members)
= 3 (Third item in list)
117
Business Rules Reference
Lookahead Business Rules
All validation programs except Analyzer
Lookahead is a way to pre-scan a defined section of the data, execute only Lookahead business
rules, and then return to the beginning of the range to start validation. The purpose is usually to
grab information that is farther down in the transaction.
The main steps for Lookahead are:
1. Mark the Lookahead range(s)
2. Create Lookahead business rules
3. Create one or more regular business rules to use the Lookahead information
Rules will execute in this order
1. Rules before the Lookahead range will execute as usual.
2. When the Lookahead range is reached, the lookahead rules will execute until the end of the
range.
3. Regular business rules will execute, starting at the top of the range and continuing as usual.
4. If a second Lookahead range is encountered, its lookahead rules will execute until the end of
that range.
5. Regular business rules will execute, starting at the top of the second range.
Example 1. Simple Lookahead scenario (range is enclosed in brackets)
ST
Rule A
Seg1
Rule B
Seg2
Seg3
LoopA – max repeat is 1
Lookahead
range
Seg4
Rule C – lookahead
Rule D
Seg5
Rule E – lookahead
Rule F
End LoopA
LoopB – max repeat is 1
Seg6
Rule G
Seg7
End LoopB
Seg 8
Rule H
Rules will execute in this order: A,B,C,E,D,F,G,H
Business Rules
118
Business Rules Reference
Example 2. Lookahead range is a repeating loop
ST
Rule A
Seg1
Rule B
Seg2
Seg3
LoopA – max repeat is 2
Lookahead
range
Seg4
Rule C – lookahead
Rule D
Seg5
Rule E – lookahead
Rule F
End LoopA
LoopB – max repeat is 1
Seg6
Rule G
Seg7
End LoopB
Seg 8
Rule H
Rules will execute in this order: A,B,C,E,D,F,C,E,D,F,G,H
Example 3. Nested loops in Lookahead range
ST
Rule A
Seg1
Rule B
Seg2
Seg3
LoopA – max repeat is 2
Seg4
Rule C – lookahead
Rule D
Seg5
Rule E – lookahead
Rule F
LoopB - max repeat is 2
Lookahead
range
Seg 6
Rule G – lookahead
Seg 7
Rule H
End LoopB
Seg 9
Rule I - lookahead
Seg 10
Rule J
End LoopA
Seg 11
Rule K
Rules will execute in this order:
A,B,C,E,G,G,I,D,F,H,H,J ,C,E,G,G,I,D,F,H,H,J,K
Business Rules
119
Business Rules Reference
Example 4. Two Lookahead ranges
ST
Rule A
Seg1
Rule B
Seg2
Seg3
LoopA – max repeat is 2
Lookahead
ranges
Seg4
Rule C – lookahead
Rule D
Seg5
Rule E – lookahead
Rule F
End LoopA
LoopB – max repeat is 2
Seg6
Rule G – lookahead
Seg7
Rule H
End LoopB
Seg 8
Rule I
Rules will execute in this order:
A,B,C,E,D,F,C,E,D,F,G,H,G,H,I
Example 5. End of loop rules
ST
Rule A – SetLoopPostInstanceExit lookahead rule
Rule B – SetLoopPostExit rule
Seg1
Rule C
Seg2
Seg3
LoopA – max repeat is 2
Lookahead
range
Seg4
Rule D – lookahead
Rule E
Seg5
Rule F – lookahead
Rule G
End loop
Seg 6
Rule H
Rules will execute in this order:
C,D,F,A,E,G,D,F,A,E,G,B,H
Business Rules
120
Business Rules Reference
Example 6. End of loop rules with nested loops and two Lookahead ranges
ST
Rule A – SetLoopPostInstanceExit lookahead rule
on Loop A (Ignored – outside of range)
Rule B – SetLoopPostInstanceExit lookahead rule
on Loop B
Seg1
Rule C
Seg2
Seg3
LoopA – max repeat is 2
LoopB is nested
within LoopA, but
new Lookahead
range starts here,
ending the one on
LoopA
Seg4
Rule D – lookahead
Rule E
Seg5
Rule F – lookahead
Rule G
LoopB - max repeat is 2
Seg 6
Rule H – lookahead
Seg 7
Rule I
End loop B
Seg 9
Rule J – lookahead (ignored – outside of range)
Seg 10
Rule K
End loopA
Seg 11
Rule L
Rules will execute in this order:
C,D,F,E,G,H,B,I,H,B,I,K, D,F,E,G,H,B,I,H,B,I,K,L
Typical example
See if a subscriber was covered on the claim service dates. If not, display an error message at the
subscriber ID location (which is earlier in the transaction than the dates).
The pertinent parts of validation:
1. After reaching the Lookahead start range on the 2000B, Instream scans through the range and
executes two Lookahead business rules on the service date. These capture the oldest and
newest service dates.
2. Instream then resumes normal validation at the 2000B. A rule captures the subscriber ID in
the NM109.
3. Also on the NM109, an InvokeWebService business rule checks the subscriber ID, oldest
service date, and newest service date against a database that records when this subscriber was
covered. It sends back a Y if they were covered and an N if not.
4. A rule then displays an error message on the NM109 if the returned value was N.
Business Rules
121
Business Rules Reference
Demo
Please see Appendix J: LookAhead and Array Extended Example on page 287 for a complete
example.
Marking a Lookahead Range
Things to know:

There can be more than one Lookahead ranges in a guideline.

When Instream detects the start of the Lookahead range, it goes into a mode where it scans
through the range and executes only the Lookahead rules. When the range ends, it then
returns to the start of the range and continues normal execution.

For speediest validation, make the range only as large as necessary.
Setting a Starting Point
1. Open the guideline in the EDISIM Standards Editor.
2. Decide where the Lookahead range starts.
The lookahead range starts on a loop header, or on the transaction line at the top of the
guideline. This must be on the parent loop of everything that is involved, including the
location of the Lookahead rule and the location where the data is found.
Business Rules
122
Business Rules Reference
Example
If they were not a subscriber on the Statement Dates, you want to display a message (earlier)
on the Subscriber Name NM1.
The starting point will be the 2000B loop, which is the parent loop of both the Subscriber
Name NM1 and the Statement Dates DPT.
(The starting point cannot be the 2010BA loop since it is not the parent to the 2300 loop –
even though it appears ahead of it in the guideline.)
3. Put a DSR mark at the top of the range.
Right click on the loop and select DSR/Unmark.
A red check now marks the range’s start:
Business Rules
123
Business Rules Reference
Ending a Lookahead Range
Lookahead ranges end in these ways:

The range started on a loop, and the loop ends.

Another Lookahead range starts. This automatically ends any previous range.

An ExitLookahead business rule is encountered.
Example
To stop Lookahead after it gets the value from the Statement Date DTP in the 2300 loop, add
this to the DTP03:
If the ending item might not be in the data, use one of these methods:
or
Business Rules
124
Business Rules Reference
Creating Lookahead Business Rules
Lookahead business rules are different than all other business rules in that they can actually
execute any other rule’s functions.
This example shows the Array server updating an array from the current location:
By simply checking the Look-Ahead Rule box, this same rule now executes when the Lookahead
range is first encountered.
This should be attached to an item in the Lookahead range (see page 122). You can type the
desired function into the Function field if it does not appear in the drop-down list.
The difference between these two rules is when they execute:

The first example executes when it is encountered during normal validation.

The Lookahead rule executes earlier. When validation encounters a Lookahead starting
point, it scans through the whole range to find and execute any Lookahead business rules. It
then returns to the range start and validates normally.
Business Rules
125
Business Rules Reference
Lookahead in Exit rules
Check the Lookahead box in the parameters area.
Correct:
Incorrect:
Lookahead example
Put the Lookahead start point on an 837I 2000B loop.
On the ST, create an array called Array1.
On the Subscriber NM109, add the subscriber identification code to the first cell in Array1.
Business Rules
126
Business Rules Reference
On the date element (2400 DTP03 Service Line Date), add the service line date to Array1 with a
Lookahead rule. If there are multiple service lines, this will store only the oldest date in cell 0,1. If
cell 0,1 is empty, the rule simply inserts the element’s date into it.
Likewise, put the most recent service line date into cell 0,2.
Now, back at the Subscriber NM109, use InvokeWebService to check the ID and dates against a
database. Assume that the web service has been preconfigured to send back a Y or N in cell 0,4
in an array called Array1BACK:.
Business Rules
127
Business Rules Reference
The final task is to display an error message if cell 0,4 does not contain Y:
Business rules for the NM109 must be in this order:
Business Rules
128
Business Rules Reference
Looping Business Rules
All validation programs except Analyzer
The Looping rules let you repeatedly execute a group of rules:

The ForEach function indicates the start of a loop.

The Next function identifies the end of a loop, with the rules between ForEach and Next
repeatedly executing. When all members of the list are processed, execution continues with
the function following the Next function.

ExitLoop causes the ForEach loop to immediately exit, with execution resuming with the
rule after the Next function.
Loops can be nested, but cannot span objects. For example, you can’t start a loop on one
element and end it on another.
If the list is empty, none of the looping rules execute.
Business Rules
129
Business Rules Reference
ForEach
All validation programs except Analyzer
Marks the top of a set of rules that execute once for each member of a list.
Format of Parameters
MemberVar IN ListName
Where:
MemberVar
Name of the variable to contain each member of the list.
IN
Literal text.
ListName
Name of the list to be processed.
Example
Let’s say we have a list of Supplier IDs called SuppList. These rules will display each of them:
Server
Function
Parameter
BusinessRules.Looping
ForEach
SID IN SuppList
BusinessRules.Utilities
DisplayErrorByNumber
0 0 “Supplier ID: %SID%”
BusinessRules.Looping
Next
One at a time, ForEach puts each member of SuppList into the SID variable, and then begin
executing rules until it hits the Next function. Note that we are using %SID% in the error
message to include the current contents of the SID variable (i.e., the current SuppList member)
into the error message. (See Preprocessor Variables on page 242).
The Next function causes ForEach to load the next SuppList member into SID and repeat
execution of the loop.
Once the last member of SuppList is processed, execution will continue with the function
following the Next function. If SuppList contains these members: A1001, B2002, Z99, then the
output would be:
Supplier ID: A1001
Supplier ID: B2002
Supplier ID: Z99
Business Rules
130
Business Rules Reference
Next
All validation programs except Analyzer
Marks the end of a ForEach loop. See ForEach on page 130 for further explanation.
Format of Parameters
Next has no parameters.
ExitLoop
All validation programs except Analyzer
Causes the ForEach loop to immediately exit, with execution resuming with the rule after the
Next function. See ForEach on page 130 for further explanation of the looping concept.
Format of Parameters
ExitLoop has no parameters.
Example
See Extended Looping Example on page 132.
Business Rules
131
Business Rules Reference
Extended Looping Example
We have a list of Supplier IDs called SuppList.
We have accumulated the total amount invoiced by Supplier ID into a variable array called
InvcTotals.
We want to make sure that each Supplier invoiced something greater than zero. If this is not the
case, we want to display an error message, just once (not one per supplier), saying that at least
one supplier didn’t have invoices.
Server
Function
Parameter
BusinessRules. Variable
SetVar
VLCount “0”
(Set up variable VLCount to contain a count of the
suppliers that do have an invoice total greater
than zero.)
BusinessRules. Looping
ForEach
SID IN SuppList
(Go through each entry in SuppList.)
BusinessRules. Variable
CompareNumeric
InvcTotals(SID) LE “0” (BusinessRules.Looping.
ExitLoop)
(If the InvcTotal entry is less than or equal to zero,
exit the loop with the ExitLoop command.
Execution continues with the ListCount rule after
the Next rule.)
BusinessRules. Variable
VLCount “1”
AddVar
(If the InvcTotal entry is greater than zero, we
increment the VLCount counter.)
BusinessRules. Looping
Next
(Repeat the loop for the next SuppList member.)
BusinessRules.
Lists
ListCount
SuppList VSuppListCount
(After the looping completes, we put the number
of members in SuppList into a variable called
VSuppListCount.)
BusinessRules. Variable
CompareNumeric
VLCount NE VSuppListCount
(BusinessRules.Utilities. DisplayErrorByNumber 0
0 “At least one Supplier had no Invoice Total”
(We then compare VSuppListCount against
VLCount; if all suppliers had invoice totals greater
than zero, they should match. If not, then we
display an error message.)
Business Rules
132
Business Rules Reference
ODBC Business Rules
Windows Instream and Desktop
You can validate data against your own databases using ODBC. The capabilities include:

Testing for the existence of a particular record in a database table.

Retrieval of one or more fields from a record in a database table.

Execution of a stored procedure in the database.
ODBC lookup or Customer Code Tables?
Use ODBC to access existing databases. If you are creating a new table just for Instream, then
set up a code table (see page 256) – which will give you faster lookup.
For example, if you already have a SQL ODBC-accessible database containing information about
500,000 health care policies that you wish to validate against, then an ODBC query makes sense.
The alternative would be to export data from this database into a text table and distribute that on
some schedule, a process that comes with its own coordination and distribution pitfalls.
ODBC rules are handled by the BusinessRules.ODBC server, and include:
This command …
Does this …
See page …
DBOpen
Opens a database.
135
DBClose
Closes one or more databases.
137
DBQuery
Executes an SQL query against an open database,
returning the number of records selected and, optionally,
values of fields from the first selected record.
138
DBExecute
Executes a database command.
139
See Appendix E on page 265 for two extended ODBC examples.
Business Rules
133
Business Rules Reference
Setting up your ODBC Connection String
If you use ODBC business rules, you need to supply your database connection string in the
DBOpen rule. You can put it in either or both of these places:

Within each DBOpen business rule
This method lets you globally change the connection string without having to edit a
guideline and change business rules. This can save you significant effort when changing
databases from test to production, for example.
Example business rule with connection string (detailed in the next sections):

In the $Dir.ini file for Instream and Desktop
Example business rule without connection string:
During validation, if Instream or Desktop find a connection string within a DBOpen business
rule, they will use it. If not, they look in $Dir.ini in their Bin directory for a connection string.
Putting connection strings in $Dir.ini
Use a text editor to edit $Dir.ini in the Bin directory of Instream or Desktop.
Add a Database section at end of the file, like this:
[Database]
DBRef="DRIVER={SQL Server};SERVER=(local);DATABASE=TI300;UID=sa;PWD=sa;"
DBRef1="DRIVER={SQL Server};SERVER=FCSUPP10;DATABASE=TI301;UID=sa;PWD=sa;"
You can have as many lines in this section as you need.
DBRef and DBRef1 are logical names of your choice and are used as the first parameter in the
DBOpen business rule. Notice that the example rules above use DBRef. According to the first $Dir.ini
database entry, this is the TI300 database.
Business Rules
134
Business Rules Reference
DBOpen
Windows Instream and Desktop
Opens an ODBC connection to a particular database.
Format of Parameters
DBRef ResultVar Connection
Where:
DBRef
Identifier you are giving to this ODBC connection. It is used in
subsequent ODBC business rules to tell Validator which database
to use. DBRef must be alphanumeric with no spaces.
ResultVar
Variable that is to be used to contain the results of the DBOpen
command. Result will be:
0 = Database opened successfully
-1 = Bad parameter or argument
-2 = Could not allocate ODBC environment handle
-3 = Could not allocate ODBC connection handle
-4 = Could not connect to database
-5 = Could not allocate ODBC statement handle
Connectio n
The connection string used to establish the connection to the
database. The connection string can be supplied in the $Dir.ini file
(see page 134) rather than here. If you use local in the connection
string, be sure that it will be correct on all machines where this
guideline will be used.
Example 1: SQL database.
Example 2: Access database.
Business Rules
135
Business Rules Reference
Example 3: Named Data Source (via Control Panel>Administrative Tools>Data Sources
(ODBC)).
or
Business Rules
136
Business Rules Reference
DBClose
Windows Instream and Desktop
Closes one or more ODBC connections.
Format of Parameters
DBRef {DBRef …}
or:
DBRef ALL
Where:
DBRef
The name of an ODBC connection to close. This name is the same
one that was specified with DBOpen. Specifying ALL will cause all
open ODBC connections to close.
Example
Business Rules
137
Business Rules Reference
DBQuery
Windows Instream and Desktop
Performs an SQL query on a specified database.
Format of the Parameters
DBRef ResultVar SQL {Var1=n1 {Var2=n2 …}}
Where:
DBRef
Name of an ODBC connection specified in the DBOpen
command.
ResultVar
Name of a variable that contains the results of the DBQuery
command. If a result is less than zero, it is an error code; otherwise,
the result is the number of records returned.
-1 = Bad Parameter or Argument
-2 = Database DBRef not opened, or had problem with open
-3 = Invalid Variable Assignment parameter
SQL
SQL command to execute. The SQL command must return a
recordset. The SQL command can contain business rule variables in
the form %var% where var is the name of a business rule variable.
Before the SQL command is processed, any variables in the SQL
string will be replaced with the contents of the specified variable.
Var=n
A variable and the column number from the returned record where
it is to get a value. The variable can then be used in other business
rules. If zero records are selected, Var is cleared. If the DBQuery
command returns an error, then Var remains unchanged.
Example 1
This example selects all records from the PatTable table in the PatientDB database whose SSN
field matches the contents of the variable 2000AN102.
It returns a recordset containing the following:

ID (Field #1)

Name (Field #2)

SSN (Field #3)
Variables returned include:

ResVar - The number of records found

SSNVar - The first record’s SSN (Field #3)

NameVar – The first record’s Name (Field #2)
Business Rules
138
Business Rules Reference
Example 2
This uses a stored procedure.
DBExecute
Windows Instream and Desktop
Executes an SQL command against an open ODBC database connection.
Format of Parameters
DBRef ResultVar Command
Where:
DBRef
Name of an ODBC connection to use. This name was specified
with DBOpen.
ResultVar
The name of a variable to contain the results of the query. If the
result is less than zero, it is an error code; otherwise, it is the
number of records returned:
-1 =
Bad parameter or Argument
-2 =
Database DBRef not opened, or had problem with open
These return codes show up in an EMSG in the DTL file.
ODBC error numbers (see APF.pdf):
31029
31025
31028
Command
31023
31026
31024
31027
The database command to execute. It can contain business rule
variables in the form %var% where var is the name of a business
rule variable. Before the command is processed, var will be replaced
with the contents of the specified variable.
Example
Business Rules
139
Business Rules Reference
Run Business Rules
RunAlways
Specifies that a business rule is to be run on an optional segment, regardless of whether the
segment is actually present in the data.
This only works on a segment, not an element.
Format of Parameters
BusinessR ule
Where:
BusinessR ule
Business rule to run, whether data is present or not.
Example
We want to see if the Principal Procedure Information segment is present. The HI segments can
come in any order and most are optional.
1. Set a variable on an element within the segment:
Business Rules
140
Business Rules Reference
2. Check the variable on an optional segment below the last HI:
The rule parameter is:
(BusinessRules.String CompareString PrinProcedurePresentVar EQ "NO"
(BusinessRules.Utilities DisplayErrorByNumber 0 0 "The data must contain a
Principal Procedure Information HI segment"))
3. Initialize the variable on the mandatory CLM segment, above the HI segments:
When the Principal Diagnosis Information HI segment is missing, the message appears:
Business Rules
141
Business Rules Reference
RunNoData
Instream and Desktop
Specifies a business rule to be run on this segment if and only if the segment is not present in the
EDI. This only works on a segment, not an element, and the segment cannot be within an
unused loop.
Warning. This business rule significantly slows down validation.
Format of Parameters
BusinessR ule
Where:
BusinessR ule
Business rule to run if no data is present.
Example. This example attached to the CUR segment displays a message if the segment is not
present.
Desktop Demo. The demo guideline NO_DATA has this rule on the CUR segment. Use it to
validate 837Idate.txt or 837I_4010_H_FutureDateBHT.txt in Desktop’s DemoData directory.
Since there is no CUR segment in the data, you will see the message “Currency is assumed to be
in US dollars.”
Instream Demo. Execute V_837I_4010_noData in Instream’s Scripts directory to see this rule
in action. Since there is no CUR segment in the data, the detail results file will see the message
“Currency is assumed to be in US dollars.”
Business Rules
142
Business Rules Reference
Substitute Business Rules
Instream
The Substitute, SubstituteFind, SubstituteReplace and MakeKey business rules let Instream users
replaces the value in the current element or sub-element with a new value.
They are used with the Instream’s Dataswapper program.
DeleteSegment
Instream
Details and examples are in the Dataswapper Business Rules section of Dataswapper.pdf.
Deletes the current segment from the EDI.
Format of Parameters
MetaData
Where:
MetaData
Business Rules
Optional. “Literal” or variable containing text for your own use. It
appears in the SBSTA record in the Dataswapper audit file.
143
Business Rules Reference
InsertSegment
Instream
Details and examples are in Dataswapper Business Rules section of Dataswapper.pdf.
Inserts a segment into the EDI above or below the current location.
Format of Parameters
SegmentID (Elements) M etaData
Where:
SegmentID
A “Literal” or variable containing the segment ID.
(Elements)
A series of FindKeys holding the values to replace. The series is
surrounded by parentheses. To include sub-elements, surround
them in a separate set of parentheses. See Example 2 below. The
FindKeys are set with SubstituteReplace rules, which can come
before or after the InsertSegment.
MetaData
Optional. “Literal” or variable containing text for your own use. It
appears in the SBSTA record in the Dataswapper audit file.
MakeKey
Instream
Details and examples are in Dataswapper Business Rules section of Dataswapper.pdf.
Creates unique key for SubstituteFind/SubstituteReplace pairs by incrementing a counter at the
end of a string of characters.
Format of Parameters
Prefix KeyVar
Where:
Prefix
“Literal” or variable holding the base part of the key. MakeKey will
automatically add an incrementing counter to this base.
KeyVar
Variable containing the key.
Business Rules
144
Business Rules Reference
Substitute
Instream
Details and examples are in Dataswapper Business Rules section of Dataswapper.pdf.
Replaces the value in the current element or sub-element with a new value.
Format of Parameters
ReplaceV alue MetaData
Where:
ReplaceValue
“Literal” or variable containing a value that is to replace the value in
the current value.
MetaData
Optional. For your own use. “Literal” or variable containing the
text of your choice that is to appear at the end of the SBST record
in the detail results file.
SubstituteFind
Instream
Details and examples are in Dataswapper Business Rules section of Dataswapper.pdf.
SubstituteFind identifies a value that is to be replaced. It specifies that the value in the current
element or subelement is to be replaced.
Format of Parameters
Key MetaData
Where:
Key
“Literal” or variable containing a key that will identify this element
as the one where the value is to be replaced.
MetaData
Optional. For your own use. “Literal” or variable containing the
text of your choice that is to appear at the end of the SBSTF record
in the detail results file.
Business Rules
145
Business Rules Reference
SubstituteReplace
Instream
Details and examples are in Dataswapper Business Rules section of Dataswapper.pdf.
SubstituteReplace identifies the value that will replace a value identified with a SubstituteFind
that has the same key.
Format of Parameters
Key ReplaceValue
Where:
Key
“Literal” value or a variable containing the same key as the one that
identifies the element to be replaced. This same key appears in the
SubstituteFind rule.
ReplaceValue
“Literal” or variable containing a value to replace the one in the
SubstituteFind element.
Business Rules
146
Business Rules Reference
Utilities Business Rules
AppendString
All validation programs
Appends one string or constant to the end of another.
Format of Parameters
DestStr SourceStr
Where:
DestStr
Variable to which another value should be appended. If DestStr
does not exist, it will be created.
SourceStr
The value to be appended to the end of DestStr. This can be a
variable, a literal in double quotes, Current_Element, or
Current_Date. If it does not exist as a variable, it will be treated
as a literal value.
Example. This example set of rules issues an error message if it finds that the same procedure
was given to the patient more than once in a given day.
This rule appends the date to the industry code. It is applied to the Industry Code and the Date
Time Period in the first composite in the HI segment shown below:
Similar AppendStrings are used in the other composites, but with different names for the
variables.
Business Rules
147
Business Rules Reference
SetVar for ProcDate2 goes here.
AppendString for ProcDate2 goes here.
CompareString rule that compares
ProcDate1 and ProcDate2 goes here also.
Use additional SetVars and
AppendStrings on the subelements in
these composites.
A rule could be applied to the second Date Time Period element that did a CompareString on
ProcDate1 and ProcDate2 and issued a custom error message if they matched:
The format of DisplayErrorByNumber is different for Analyzer.
Similar CompareString rules could be applied to the other Date Time Periods in the subsequent
composites.
Business Rules
148
Business Rules Reference
BuildString
All validation programs
Builds a string from a list of variables, constants, or reserved words.
Format of Parameters
DestStr Separator SourceStr1 SourceStr2 …
Where:
DestStr
Variable to contain the values from the SourceStrs. If this variable
exists, its contents will be overwritten. If it does not exist, it will be
created.
Separator
The character to be used to separate the values. This can be a
keyboard character, a space (surrounded by double quotes), or
nothing (two consecutive double quotes)
SourceStr
Separator
wanted
Separator in
business rule
one slash
/
ANDREWS/ALAN/A
space
““
ANDREWS ALAN A
no separator
““
ANDREWSALANA
space-slashspace
“/ “
Example output
ANDREWS / ALAN / A
The values to be combined into DestStr. These can be a
combination of variables, literals in double quotes,
Current_Element, or Current_Date. Ones that do not exist
as variables will be treated as literals.
Example
This rule places this information into a variable Subname:

The literal text “Name is “

The contents of variables SubLastName and SubFirstName

The contents of the current element.
Business Rules
149
Business Rules Reference
Each is separated with a slash.
Output might look like this: Name is /ANDREWS/ALAN/A
Business Rules
150
Business Rules Reference
ChangeCase
All validation programs
Converts all letters in a string to upper or lower case.
Format of Parameters
SourceString ResultVar CaseOptio n
Where:
SourceString
The string to be converted. This can be a literal in double quotes, a
system variable like Current_Element, or a variable.
ResultVar
The variable to contain the result.
CaseOption
An optional parameter that specifies whether to convert to upper or
lower case. This can be a variable name, or U or L surrounded by
optional double quotes:
U
(default) Convert all lowercase letters to their uppercase
equivalent
L
Convert all uppercase letters to their lowercase equivalent
Example 1
Assume that the current element contains Westerville Medical Clinic.
Either of these rules put WESTERVILLE MEDICAL CLINIC into variable SubmitterVar:
Or, using default behavior for Option:
Business Rules
151
Business Rules Reference
Example 2
Assume that:

Variable PatNameVar contains Fred Flintstone

Variable CaseVar contains U
This puts FRED FLINTSTONE
Business Rules
into PatNameCapsVar.
152
Business Rules Reference
ChangeElmAttribute
All validation programs
Changes the element’s type, minimum length, maximum length, or user attributes.
This rule executes before the length or user attribute is validated.
Format of Parameters
Attribute Value
Where:
Attribute
“UA”, “Type”, “Min”, or “Max”, or a variable containing one of
these.
Value
If Attribute is UA (for User Attributes), value can be one of these
or a variable containing one of these:
“O”
“N”
“MU”
“R”
“NR”
“D”
Used (Optional)
Not Used
Must be Used (Required)
Recommended (Advised)
Not Recommended
Dependent
If Attribute is Type, value can be one of these or a variable
containing one of these:
“AN”
“ID”
“N”
“R”
See DataTypes.pdf in EDISIM’s Documentation directory for
details.
If Attribute is Min or Max, value can be an integer in quotes or a
variable containing an integer.
Business Rules
153
Business Rules Reference
Examples:
This example checks the contents of local variable 2010AANM108. If it contains XX, then the
current element’s type is changed to R.
This example checks the value of 2010AANM108. If it contains 24, the maximum length of the
value in the element is 12:
This example uses two variables:

NewAttr contains Type.

NewAttrValue contains R.
Business Rules
154
Business Rules Reference
CheckFormat
All validators except Analyzer
For a rule that will work in Analyzer, see Other CheckDigit Options on page 229.
Checks the format of the value. Formats include:
Format of Parameters
CheckType Value
(IfFalseActio n)
(IfTrueActio n)
Where:
CheckType
One of these:
SocialSecurity
See below
NationalProviderID
See below
CHARSET(x)
Data must conform to the characters in the
specified character set. Sets available are
X12B, X12E, UNOA and UNOB.
See below.
EAN8
Data must be exactly 8 characters with no
leading zeros.
EAN13
Data must be exactly 13 characters long with
no leading zeros.
EAN14
Data must be exactly 14 characters long with
no leading zeros.
HIN
Data must be 9 characters long, with position
7 acting as a check digit for verifying the first
six positions.
Positions 8 and 9 are a suffix that acts as a
unique identifier.
Example:
9C8341600
(9C83416 is the base HIN, with 6 being the
check digit. 00 is the suffix identifier.)
MOD11
Calculates the Mod11 check digit for a value.
The format of this rule is slightly different than
other CheckFormat rules. Please see
Example 11 on page 161.
POA
Positions 1-3 must contain the literal string
POA
Position 4 must contain a Y
Starting at position 5 (up to 25 positions) any combination of N, U, W, 1, Y
The last position must contain X or Z.
Business Rules
155
Business Rules Reference
POAX
Like POA, but will allow:
-
a regular POA code
-
a POA code whose next-to-the-last
character is a Z or X, and whose last
character is a Y, N, U, W, or 1 (an
e-code). This is only used in the 4010
837I when the H103.01=BN.
SSCC
Data must conform to the Serial Shipping
Container Code - be exactly 18 digits.
UPC12
Data must be exactly 12 characters long and
can include leading zeros. The last digit is a
check-digit.
USER(min-maxZn)
Specify the minimum and maximum length
and the number of leading zeros included
within that length. The last digit is a check
digit. There is no space before the
parenthesis.
For details about the format within the
parentheses, see USER check digit and
examples 7 and 8 below.
USERNC(min-maxZ n)
Same as USER except the last digit is not a
check digit. There is no space before the
parenthesis.
See example 9 below.
ALL_BLANKS
Value is all blanks
ALL_?
? is a capital or lower case letter or a digit.
Examples:
ALL_0
(Value is all zeros)
ALL_9
(Value is all nines)
ALL_A
(Value is all capital A’s)
Value
The value being checked. This can be a variable, Current_Element,
or a literal in double quotes. If omitted, the value of
Current_Element is assumed.
(IfFalseAction)
Action to take if the format does not match. Required if you are
specifying an IfTrueAction. To do nothing if false, use this:
(BusinessRules.Utilities DoNothing)
(IfTrueAction)
Business Rules
Action to take if the format matches.
156
Business Rules Reference
SocialSecurity

Length can be 9 digits, plus optional dashes if it is X12-4010 data: nnnnnnnnn or nnn-nnnnnn. For X12-5010 and later, it cannot contain dashes.

Area code (first three digits) must not be 000 or 666. HIPAA validation products look up the
area code in the SSNArea table. Analyzer does not do this lookup.

Group (4th and 5th digits) must not be 00.

Serial (last four digits) cannot be 0000.

For HIPAA guidelines, the first five digits are automatically checked according to the SSA
guidelines.
NationalProviderID

Length is 9 digits followed by one numeric check digit.

The check digit uses the Luhn formula for the modulus 10 “double-add-double” check digit
and includes the prefix 80840, even though that is not included in the EDI value.

NationalProviderID
CHARSET
The CHARSET CheckFormat type code that allows you to verify that a value is comprised only of
characters in the specified character set.
The format is
CHARSET(x)
There should be no spaces between CHARSET and (x) or within the parentheses; spaces will
result in an error.
Where x is one of the following Character Set ID codes:
X12B = X12 Basic character set



Uppercase letters:
Decimal digits:
Punctuation Characters:
A-Z
0-9
! " & ' ( ) * + , - . / : ; ? = space
X12E = X12 Extended character set




Business Rules
Uppercase letters:
Lowercase letters:
Decimal digits:
Punctuation Characters:
A-Z
a-z
0-9
! " & ' ( ) * + , - . / : ; ? = space
% @ [ ] _ { } \ | < > ~ # $
157
Business Rules Reference
UNOA = EDIFACT UNOA character set



Uppercase letters:
Decimal digits:
Punctuation Characters:
A-Z
0-9
. , - ( ) / = space
UNOB = EDIFACT UNOB character set




Uppercase letters:
Lowercase letters:
Decimal digits:
Punctuation Characters:
A-Z
a-z
0-9
. , - ( ) / = space ' + : ? ! " % &
* ; < >
USER check digit
The USER check digit is a Modulo 10 calculation.
Consider this rule as an example of USER:
And consider this value in the data:
The last digit (5) is the check digit. Is it correct or not?
Here is how Foresight validators will calculate the check digit:
1. Add up the digits in the “odd” positions, starting FROM THE RIGHT with the digit just
BEFORE the check digit: 1234565
6+4+2=12
Multiply this sum by 3:
12*3=36
2. Add up the digits in the “even” positions: 1234565
5+3+1=9
3. Add the odd and even results:
36+9=45
4. The check digit is the number would you have to add to this to get to a multiple of 10. In our
example:
45+5=50
Our check digit should be 5, which makes the value 1234565 correct.
Business Rules
158
Business Rules Reference
CheckFormat examples
Example 1
This example displays default error message (31000 Comparison Failed!) if the current element’s
value does not match the format of a Social Security Number.
Example 2
This example displays custom error message 32001 (Social Security number format is wrong) if
the current element’s value does not match the format of a Social Security Number.
The format of DisplayErrorByNumber is different for Analyzer.
Example 3
This example displays custom error message 32001 (Social Security number format is wrong) if
variable 2010BAREF01 contains SY and the current element’s value does not match the format
of a Social Security Number.
Example 4
This example has the same result as the previous example, but the “if” part uses a local variable
(see page 236) instead of a SetVar variable.
Business Rules
159
Business Rules Reference
Example 5
This example displays custom error message 32005 if the current element contains all blanks.
Example 6
This example displays custom error message 32006 if the current element does not contain all
blanks, and custom error message 32005 if it does contain all blanks.
Example 7
This example displays a default error message if the current element does not contain exactly 10
digits including up to one leading zero. The last digit is a check digit.
Example 8
This example displays a default error message if the current element does not contain exactly 10
to 12 digits including up to one leading zero. The last digit is a check digit.
Example 9
This example displays a default error message if the current element does not contain exactly 2 to
8 digits. This can contain up to 6 leading zeros. The list digit is not a check digit.
Business Rules
160
Business Rules Reference
Example 10
This example verifies that the value (“Value to be Checked”) is comprised only of characters in
the X12B character set, then causes the FalseAction to be taken because the string contains
lower case letters not included in the X12B character set.
Example 11
This example uses MOD11 to calculate a value’s check digit, and then see if the data includes the
correct check digit in this HL7 ORU R01 Ambulance guideline:
We capture the ID number with this rule on the PID-03-01:
We capture its Check Digit from the data with this rule on the PID-03-02:
Business Rules
161
Business Rules Reference
If the value in the PID-03-03 is M11, that means we should use the Mod 11 algorithm. If so, we
calculate the check digit for the value in the PID-03-01:
If the check digit value in the PID-03-02 is different from the one calculated by CheckFormat,
we issue an error message.
Business Rules
162
Business Rules Reference
CreateFSUID
Instream
CreateFSUID creates a unique identifier (TIBCO Foresight Unique ID or FSUID) and places it
in a variable. The Identify (see page 170) or Match (see page 173) rules then use this variable to
output an IDENT record.
Warnings
It is extremely important that you never output the same FSUID twice. The safest way to ensure
this is to use a CreateFSUID rule before each Identify or Match rule.
Format of Parameters
FSUID CompressedID
Where:
FSUID
Variable to hold a unique 36-character TIBCO Foresight User ID
(FSUID).
CompressedFSUID
Optional variable to hold a 27-character version of the FSUID.
Example 1. This example, placed on the subscriber CLM segment, causes Instream to insert an
IDENT record each time a CLM segment is encountered.
First, create an FSUID in a variable called FSUniqueID:
Next, write the IDENT record using the FSUID value in the variable:
Each time a subscriber CLM is encountered in the EDI, the detail results file will contain an
IDENT record similar to this:
STRUS
31|2300|0|1|1159
SVALU
31|S009|464|CLM*2235057*460.00***25:B:1*N*A*N*I*P*OA*********1
IDENT
31|I|7ee91081-f49f-11de-a384-f131e23d4046|1|
DTL
31
2300 CLM1332C023
28 5 2
1
10618 3
4641 …
Example 2. These two rules put an IDENT record in the detail results file. This would be
suitable for marking the document level for generic X12 or EDIFACT documents that will be
sent to TI.
Business Rules
163
Business Rules Reference
DisplayErrorByNumber
All validation programs
In Analyzer, DisplayErrorByNumber only supports explicit text as shown in the example for
Analyzer.
Looks up the error number and then displays the corresponding error text. For more details
about error messages, see Appendix B on page 251.
Format of parameters for EDISIM Validator, Instream and Desktop
ErrorNumber Severity OverridingErrorMessage
Where:
ErrorNumber
Number of the error in FSBRErrs.txt or
CustomerFSBRERRS.TXT files (in the Bin directory). The number
can be from 32000 to 32999. Please see ErrorMessageNumbers.pdf
for a complete list of error number ranges.
Severity
Optional. Specifies the severity, one of these:
-1
0
1
2
3
4
5
6
for Un-Initialized
for Message
for Non-Critical
for Warning
for Error
for Fatal
for User1
for User2
Examples. This example displays message 32001. Because the severity is listed as 2, the message
displays as a warning.
Also see the example for ListCheck on page 108.
Business Rules
164
Business Rules Reference
Format of Parameters for any Foresight validation program
To display a message, use two zeros, separated by a space, and then the text:
Analyzer will display the text:
See also FSVBExit.DisplayMessage on page 230.
Business Rules
165
Business Rules Reference
FindString
All validation programs
Allows you to determine if String A can be found in String B, and if so, return its starting
position.
Format of Parameters
StringA StringB ResultVar (StartPos) (Opt)
Where:
StringA
The string (variable or constant) to search.
StringB
The substring (variable or constant) to search for.
If StringB is not found in StringA, then the result will be zero.
Otherwise, it will be the position in StringA that StringB starts (1based; i.e. the first character position is 1).
ResultVar
The variable to contain the result. Note that if either StringA or
StringB is an empty string, the value of -1 will be returned in
ResultVar.
(StartPos)
Optional. A variable or constant that tells FindString where to start
its search within StringA. If StartPos is omitted, then the search
begins in position 1 (i.e. the first character) of StringA. If StartPos
is less than 1 or greater than the length of StringA, then a zero will
be returned. If StartPos is not numeric, it will be ignored.
(Opt)
Optional. A variable or constant that modifies aspects of the
function. Currently, the only option supported is I, which means
Ignore Case.
Examples (Simple)
The following examples use these assumptions:

SetVar INVCONST “Office Box”

Current element = “Post office box 1234”
This example causes 0 to be put into VARPOPOS because the exact string wasn’t found.
Business Rules
166
Business Rules Reference
This example causes 6 to be put into VARPOPOS because, once we ignore the case of the
letters, the string is found.
Examples (Complex)
This more complex example shows how to find the second occurrence of a delimiter:
The following examples use this assumption:

Current element = “123-ER-456TT”
This rule causes 4 to be put into DELIMPOS1.
This AddVar rule increments DELIMPOS1 to 5.
This rule causes 7 to be put into DELIMPOS2.
Business Rules
167
Business Rules Reference
GenerateFSUID
Instream
NOTE
This rule has been deprecated. Please see FSUID_and_AppDocs.pdf for
alternatives.
GetToken
Instream, Desktop, and Analyzer
Finds a specific value in a series of delimited values and places it in another variable.
Format of Parameters
DestVar SourceVar I ndex Delimiter
Where:
DestVar
The variable that is to hold the extracted value.
SourceVar
A variable, literal in double quotes, or Current_Element that
holds the series of values before one of them is extracted.
Index
The position of the value that is to be extracted. This can be a literal
(no quotation marks), a variable, or Current_Element.
Delimiter
Optional. The delimiter that separates values in SourceVar . If
omitted, a space character is assumed.
Example. This example requires that the first NTE segment starts with the code MED and the
second repetition of the same NTE segment starts with the code NTR.
AddVar is used on the NTE segment as a counter. It increments by 1 with each NTE segment.
This segment can repeat up to 10 times, and has many code values available to the NTE01.
The AddVar NTE segment counter might look like this:
Business Rules
168
Business Rules Reference
And the GetToken on the NTE01ClaimNote might look like this:
The GetToken places MED in a variable called NTE01ClaimNote for the first instance of the
NTE segment (when CLMnote will equal 1).
It places NTR in a variable called NTE01ClaimNote for the second instance of the NTE
segment (when CLMnote will equal 2).
You could then put a CompareString on the NTE01ClaimNote, after the GetToken rule, to see
if CLMnote equals 1, and, if so, Current_Element should equal the contents of
NTE01ClaimNote - which will be MED.
Another rule could check to see if CLMnote equals 2. If true, then the contents of
Current_Element should equal NTR.
Business Rules
169
Business Rules Reference
Identify
This follows a CreateFSUID rule to generate an IDENT record in Instream’s detail file. Please
see InstreamValidationTechnicalManual.pdf for the layout of the IDENT record.
The rule never generates the same ID twice.
Activating the rule in your validation profile
To activate the business rule, edit your Instream validation profile (by default, $fsdeflt.apf in
Instream’s Bin directory), and set IDENT to 1:
IDENT=1
Where to place the rule
Place the rule on a mandatory or must use segment where you want the IDENT record to
appear. Be sure a previous CreateFSUID business rule has executed to load the variable(s)
needed. Precede each Identify rule with its own CreateFSUID record so that the number is never
repeated. Example. If you want each claim to have its own unique number, place the
CreateFSUID and Identify business rules on the CLM segment.
Format of Parameters
FSUID CompressedFSUI D SystemID
Where:
FSUID
Variable containing a unique 36-character TIBCO Foresight User
ID (FSUID) that was loaded by a CreateFSUID rule.
CompressedFSUID
Optional variable to hold a unique 27-character ID that was loaded
by a CreateFSUID rule. Required as a placeholder if you include a
SystemID. This value is not used by TIBCO Foresight programs.
SystemID
Variable or literal in double quotes identifying the system where
Instream resides. If omitted, the IDENT record will contain a 1 for
SystemID. Transaction Insight® expects this to be 1 for the initial
Instream validation. If it is not 1, be sure the value is defined under
Settings | External System Setting before attempting to import it
into TI.
Results: An IDENT record is placed in the validation detail results file:
IDENT
line_num |RuleID|FSUID|SystemID|CompressedFSUID
Example 1. This rule creates a 36-character FSUID in variable FSuniqueID and a 27-character
unique ID in variable ShortID.
Business Rules
170
Business Rules Reference
This Identify rule then creates an IDENT record that contains the FSUID that was created
above:
The record might look like this. Note the “I” after the line number, indicating that this was
created with an Identify rule rather than a Match rule.
SVALU
31|S009|464|CLM*2235057*460.00***25:B:1*N*A*N*I*P*OA*********1
IDENT
31|I|97c0a5aa-f4a0-11de-a384-f131e23d4046|1|
DTL
31
2300 CLM1332C023
28 5 2
1
10618 3…
Example 2. Instead of the Identify rule above, you could have used this one, which contains the
FSUID, the compressed FSUID and an ID for the external system.
The record might look like this:
SVALU
65|P009|108|CLM*2235057*680.00***25:B:1*Y*A*N*Y*P*OA*********2
IDENT
65|I|97c56a60-f4a0-11de-a384-f131e23d4046|2|IV2MKO7KK08TT8S4U4OU4FA086
Example 3. These two rules put an IDENT record in the detail results file. This would be
suitable for marking the document level for generic X12 or EDIFACT documents that will be
sent to TI.
Business Rules
171
Business Rules Reference
IdentifierLookup
Instream and Desktop
Checks a lookup file for the value in Current_Element and optionally for the value in a variable
assigned with SetIdentifier. If the lookup file contains the value(s), validation uses the profile
and/or guideline given in the lookup file.
Content-based trading partner automation is described in detail in InstreamTPAutomation.pdf.
Any SetIdentifier value used in this rule must have already been set before this rule executes.
Format of Parameters
LookupFile SetIDvariable Current_Element
Where:
LookupFile
Name of the lookup file, including file extension CSV.
SetIDvariable
A variable assigned with SetIdentifier. It holds one of the values
that determine whether the guideline and/or profile will be
changed.
Only include this parameter if two values are involved in the
lookup.
Current_Element
Literal text (typically); in complex scenarios, this can be another
SetIDvariable .
Example 1. This example uses two values. It checks lookup file MyCBpartnerAutomation.csv
for the values in variable PayeeN103 and Current_Element. If found, it validates using the
guideline and/or profile listed in the lookup file.
Example 2. This example uses one value. It checks lookup file MyCBpartnerAutomation.csv for
the value in Current_Element. If found, it validates using the guideline and/or profile listed in
the lookup file.
Business Rules
172
Business Rules Reference
InsertIdentifier
Instream
Flags an element used in the Java API callback, which is described in InstreamAPI.pdf.
Format of Parameters
Variable
Where:
Variable
A variable to hold this element’s value.
Example. This example saves the value in the current element in a variable called
T1055Ref0406:
Match
For internal TIBCO Foresight use.
Business Rules
173
Business Rules Reference
MatchApplList
All validators except Analyzer
Checks to see if a value is found in an Application Value List, and then take the appropriate
action.
Format of Parameters
Value ApplList (IfF alseAction) (IfTrueAction)
Where:
Value
Value to be searched for in the list. This can be a constant in
double quotes, a system variable (Current_Element, Current_Date,
etc.), or an external variable name.
ApplList
The name of the Application Value List to be searched for Value.
This list must already exist in the guideline. Note that
MatchApplList works with both explicit values and with regular
expression list members.
IfTrueAction
Specifies a rule to be run if Value is found in, or matches a regular
expression in, ApplList. Required if you are specifying an
IfFalseAction. To do nothing if false, use this:
(BusinessRules.Utilities DoNothing)
IfFalseAction
Optional. Specifies a rule to be run if Value is not found in
ApplList, or if ApplList does not exist.
Examples
The examples below assume these two lists:

TestList is an Application Value List that contains:
VAL1
VAL2
VAL3

MyPattList is an Application Value List that contains:
^REF[A-Z][0-9]$
^REF[A-Z][A-Z][0-9]$
^REF[A-Z][0-9][0-9]$
REFANY

and these two external variables:
ListToUse is an external variable that contains the string ‘TestList’
ValToCheck is an external variable that contains the string ‘REF01’
Business Rules
174
Business Rules Reference
Example 1
This example causes the TrueAction to be taken because ‘VAL1’ is found in list ‘TestList’.
Example 2
This example causes the FalseAction to be taken because ValToCheck contains the value
REF01, which is not in the application value list whose name is stored in ListToUse (i.e.
TestList).
Example 3
This example causes the TrueAction to be taken because ‘REFZ9’ matches one of the regular
expressions in list MyPattList.
Example 4
This example causes the the TrueAction to be taken because the value in variable ValToCheck
(REF01) matches one of the patterns in MyPattList.
Example 5
This example causes the FalseAction to be taken because list PattList2 does not exist.
Business Rules
175
Business Rules Reference
Normalize
Converts a string into a normalized form, which includes any or all of these:

Converting the entire string to upper or lower case

Removing extra spacing

Removing any non-alphanumeric characters, etc.

Removing any titles, such as ‘Mr.’, ‘Mrs.’, ‘Dr.’, etc.
This rule is handy for CAQH as well as other types of normalization as defined in the Phase II
CORE 258 rule.
Format of Parameters
SourceString ResultVar CommandString
Where:
SourceString
The string to be converted. This can be a literal in double quotes, a
system variable like Current_Element or Current_Date, or a
variable name.
ResultVar
The variable to contain the result.
CommandString
A string (variable or literal) containing one or more of the
normalization operations, each separated by a comma, as described
in CommandString Details below.
These will be performed on SourceString , in the order you specify,
so the results may differ if the options are in a different order.
Business Rules
176
Business Rules Reference
CommandString Details
This can be one of the following:
Option
Result
LC
Convert all upper case letters to lower case.
UC
Convert all lower case letters to upper case
TRIMlimits
Trim all leading and trailing spaces, and replacing any embedded sequences
of two or more spaces with a single space.
To limit the range of TRIM, append one or more of the following limits:
L
Remove leading spaces
T
Remove trailing spaces
M
Replace embedded sequences of two or more spaces in the middle
of the string with a single space
Examples
TRIM or TRIMLTM
Removes all leading and trailing spaces, and all
embedded sequences of two or more spaces.
TRIMLT
Removes all leading and trailing spaces.
The order of the suffix codes do not matter. TRIMLT is the same as
TRIMTL. Finally, TRIM with no suffix codes is the same as TRIMLTM.
RC:NonX12B
RC:NonX12E
Remove all characters not in the X12 basic character set. This character set
includes:
 Uppercase letters
A-Z
 Decimal digits
0-9
 Punctuation Characters
! " & ' ( ) * + , - . / : ;
? = space
Remove all characters not in the X12 extended character set. This character
set includes:
 Uppercase letters
A-Z
 Lowercase letters
a-z
 Decimal digits
0-9
 Punctuation Characters
:
! " & ' ( ) * + , - . /
;? = % @ [ ] _ { } \ | <
> ~ # $ space
Business Rules
177
Business Rules Reference
Option
Result
RC:NonUNOA
Remove all characters not in the EDIFACT UNOA character set. This
character set includes:
RC:NonUNOB
 Uppercase letters
A-Z
 Decimal digits
0-9
 Punctuation Characters
. , - ( ) / = space
Remove all characters not in the EDIFACT UNOB character set.
This character set includes:
 Uppercase letters
A-Z
 Lowercase letters
a-z
 Decimal digits
0-9
 Punctuation Characters
. , - ( ) / = ' + : ?
! " % & * space
RC:NonAN
Remove all characters that are not alphanumeric (not an uppercase or
lowercase letter or a digit)
RC:LoCC
Remove all control characters that have an ASCII value of 1 through
31
RC:HiCC
Remove all control characters that have an ASCII value of 128
through 255
RC:AllCC
Remove all control characters that have an ASCII value of 1 through
31 or 128 through 255
RC:List’ccc’
Remove all characters listed in ccc.
Example
This removes all colons, commas, and periods:
RC:List’:,.’
To remove a single quote character, use two consecutive single quotes
in the ‘ccc’ string.
Example
This removes all double quote and single quote characters:
RC:List’”’’’
RW:CAQH
Removes all occurrences of the following titles from the front and/or end
of SourceString, as specified in section 4.2.2 of the CAQH CORE
document:
JR SR I II III IV V RN MD MR MS DR MRS PHD REV
ESQ
Business Rules
178
Business Rules Reference
Option
Result
RW:List’w1 w2 … ’
Removes all occurrences of the words specified by w1, w2 ….
w1 w2 … is a list of words, with each word separated by a space. Letter case
is not significant.
Words will be removed if they are found at the beginning or end of
SourceString , and separated from the rest of the string by a space, comma,
or forward slash character. If any word is immediately followed by a period,
the period will also be removed.
To include a single quote character in a word, use two consecutive
single quotes in the ‘w1 w2 …’ string.
Examples
The character ‘·’ in these examples represents a space
Example 1
This puts ··CAT··FELINE!·· (with leading and trailing spaces remaining) into the variable
SpeciesVar because:

UC converts to upper case.

RC:NONX12B remove all characters not in the Basic X12 character set… in this case, the
curly brackets. The spaces and exclamation point remain.
Example 2
Assume that the current element contains Dr. Fred Schultz .
This puts FRED SHULTZ
into variable NormNamevar because:

UC converts to upper case.

RW:CAQH removes all CAQH titles.
Business Rules
179
Business Rules Reference
Example 3
This shows how the sequence of operations can affect the result.
Assume that variable VarDat contains This·is·a·Test!··
.
Normalize VarDat NormResult1var "UC,RC:NONX12B"
Normalize VarDat NormResult2var "RC:NONX12B,UC"
The first rule causes THIS·IS·A·TEST!·· to be put into variable NormResult1var
because:

UC converts to upper case.

RC:NONX12B removes all characters not in the Basic X12 character set.
However, the second rule causes T···T!·· to be put into variable NormResult2var
because:

RC:NONX12B remove all characters not in the Basic X12 character set.

UC converts to upper case.

Since lower case letters are not in the X12 Basic Character Set, they all get removed.
Example 4
Assume that the current element contains Rev. Raymond A. Ratchet, Esq, PhD
This causes
RAYMOND A RATCHET to be put into variable NormNameVar because:

UC converts to upper case.

RW:CAQH removes all CAQH titles like Rev, Esq, and PhD

RC:NONAN remove all non-alphanumeric characters like the punctuation
Example 5
This causes DR.NOSPACE to be put into DrNameVar because:

UC converts to upper case.

RW:CAQH removes all prefixes and suffixes in the CAQH title list. However, there is no
space, comma, or forward slash between the DR. and the rest of the string so it isn’t
removed.
Business Rules
180
Business Rules Reference
Numbers
Adds, subtracts, multiplies, and divides numbers and put the output into a variable. Maximum
precision is 8 decimal places.
Format of Parameters
VarA Operand VarB VarOut
Where:
VarA and VarB
A variable, Current_Element, or a literal surrounded with
double quotes. If Current_Element is used and is empty, processing
stops on the rule. If the variable does not represent a numeric, an
error message is issued.
Operand
+
*
/
VarOut
The variable to hold the result. If VarOut has not yet been
defined, it is created. If it exists, its contents are overwritten.
(plus)
(minus)
(multiply)
(divide)
Example. This example displays a message if the line item value exceeds $1,000,000 in a
purchase order.
On the PO102 (quantity), capture the quantity:
On the PO103 (unit price), multiply the unit price by the quantity:
Also on the PO103 (after the previous rule), display a message if the total is more than
$1,000,000:
Business Rules
181
Business Rules Reference
OracleLookup and OracleLookupWithDate
AIX Instream
These two business rules are available by request. Please contact TIBCO Foresight
Technical Support.
Performs a lookup from an Oracle database and executes a business rule if it is false.
OracleLookupWithDate
Use if the SQL statement or stored procedure includes a date
calculation.
OracleLookup
Use if the SQL statement or stored procedure does not include a
date calculation.
Format of Parameters
“SQLstatement” (I fFalseAction)
or
“StoredProcedure (procedure_name)" Parameter_for_Procedure (IfFalseAction)
Where:
SQLstatement
A SQL statement.
Business rule variables within the statement must be set already
with a SetVar or similar business rule.
Enclose business rule variables and Current_Element in single
quotes:
‘%ProviderIdNumber%’
‘%Current_Element%’
IfFalseAction
A business rule to execute if the SQL statement is false.
StoredProcedure
Literal text.
procedure_name
Name of the Oracle procedure.
Parameter_for_Procedure
One parameter to pass to the Oracle procedure.
Example 1. This example uses OracleLookup to check for a provider ID. It includes the SQL
statement. If it is not found by the lookup, then an error message is issued.
Business Rules
182
Business Rules Reference
Example 2. This example uses OracleLookupWithDate to check for a provider ID. If it is not
found by the lookup, then an error message is issued.
Example 3. This example uses an Oracle lookup to execute a stored procedure that does not
contain any date calculations.
Example 4. This example uses an Oracle lookup at the end of a loop if two conditions are true.
Business Rules
183
Business Rules Reference
OutputCTX
Instream
Creates a CTX record in the detail file. This record is used by Response Generator to create a
CTX segment in the 999.
During Instream validation, TIBCO Foresight 5010 837 guidelines generate CTX segments
under conditions specified in the HIPAA Implementation Guides.
Format of Parameters
CTXvar
Where:
CTXvar
Variable containing the contents of the CTX record. This is usually
created from a SaveCurrentSegment rule, a GetValueFromSegment
rule, and a BuildString rule.
Example. This rule creates a CTX record from the contents of the CTXOUTSTRING variable.
BusinessRules.Utilities.OutputCTX:CTXOUTSTRING
Rules required to create your own CTX record
A number of rules are required to create your own CTX record. Please see CTX.pdf for details.
Business Rules
184
Business Rules Reference
ReplaceChars
All validation programs
Performs any or all of these and stores the result in a variable:



Replaces characters that are not in the:

X12 basic character set

X12 extended character set

EDIFACT UNOA character set

EDIFACT UNOB character set
Replaces characters that are:

not alphanumeric

control characters
Replaces characters that you specify
Format of Parameters
SourceString ResultVar CharsToReplace ReplacementChar
Where:
SourceStr
The string to be changed. This can be a string constant in double
quotes, a variable, or a system variable like Current_Element or
Current_Date.
ResultVar
The variable to contain the result. This can be the same variable
name as specified in SourceString, if desired.
CharsToReplace
A string describing which characters to replace.
See CharstoReplace on page 186.
ReplacementChar
A string identifying the character that is to be used to replace all
matched characters in CharsToReplace .
This can be:
Business Rules
A single character
Replace each matched character with this
character. Examples: “X“ or “ “
NONE
Remove each matched character.
185
Business Rules Reference
CharstoReplace
This can be one of the following:
Option
Result
NonX12B
Replace all characters not in the X12 basic character set. This character set
includes:
NonX12E
NonUNOA
NonUNOB
 Uppercase letters
A-Z
 Decimal digits
0-9
 Punctuation Characters
! " & ' ( ) * + , - . / : ;
? = space
Replace all characters not in the X12 extended character set. This character set
includes:
 Uppercase letters
A-Z
 Lowercase letters
a-z
 Decimal digits
0-9
 Punctuation Characters
! " & ' ( ) * + , - . / :
;? = % @ [ ] _ { } \ | <
> ~ # $ space
Replace all characters not in the EDIFACT UNOA character set. This character
set includes:
 Uppercase letters
A-Z
 Decimal digits
0-9
 Punctuation Characters
. , - ( ) / = space
Replace all characters not in the EDIFACT UNOB character set. This
character set includes:
 Uppercase letters
A-Z
 Lowercase letters
a-z
 Decimal digits
0-9
 Punctuation Characters
. , - ( ) / = ' + : ?
! " % & * space
NonAN
Replace all characters that are not alphanumeric (not an uppercase or
lowercase letter or a digit)
LoCC
Replace all control characters that have an ASCII value of 1 through 31
HiCC
Replace all control characters that have an ASCII value of 128 through 255
AllCC
Replace all control characters that have an ASCII value of 1 through 31 or
128 through 255
Business Rules
186
Business Rules Reference
Option
Result
List’ccc’
Replace all characters listed in ccc.
Example
This removes all colons, commas, and periods:
List’:,.’
To remove a single quote character, use two consecutive single quotes in
the ‘ccc’ string.
Example
This removes all double quote and single quote characters: List’”’’’
Example 1
This example replaces all lowercase “c” characters with a capital C.
Assume that the current element contains col. John Crocker
SubmitterVar would then contain Col. John CroCker.
Example 2
This example replaces any characters that are not in the X12 basic character set with uppercase X
so that SpeciesVar contains TXXX XX X XXX .
Business Rules
187
Business Rules Reference
Example 3
Assume that the current element contains P. O. Box #1234 .
This example removes (not replaces) non-alphanumeric characters so that variable AddressVar
contains P O Box 1234 .
Example 4
Assume that:

Variable PatPhoneVar contains (614) 431-2345

Variable ReplCharsVar contains "List'() –'"
Note the space between ) and -‘

Variable ReplWithVar contains none
NewPatPhoneVar will contain 6144312345 .
Example 5
This causes KAVER Corporation#
Business Rules
to be put into variable CompanyNameVar.
188
Business Rules Reference
ReplaceString
All validation programs
Replaces one value with another and places the result in a variable.
Format of Parameters
SourceStr {ALL} OldString NewString {DestVar}
Where:
SourceStr
The location of the string to be changed. This can be a string
constant in double quotes, a variable, Current_Element, or
Current_Date.
If this parameter is not a variable, then DestVar is required.
OldString
The substring to be replaced. The first occurrence (or all
occurrences within SourceStr, if the ALL parameter is included
before this one) will be replaced with NewString. This parameter
can be a variable, Current_Element, Current_Date, or a
string constant in double quotes.
NewString
The substring to replace OldString in the SourceStr. This can be a
variable, Current_Element, Current_Date, or a string
constant in double quotes.
DestVar
Required to hold the result if SourceStr is not a variable. If
omitted, the result is stored back in the SourceStr variable.
Example 1. This example removes a single quote by replacing ‘ with nothing. It places the
result in the variable Patient_name. This removes quotes from values like O’Neill.
The parameters are:
Curr ent _El eme nt " ’" "" Pat ien t_n am e .
Value before:
Value after:
O’Neill
ONeill
Once the quote-less value is in Patient_name, you can use it in other business rules such as
ODBC rules.
Business Rules
189
Business Rules Reference
Example 2. This example removes all hyphens within Current_Element by replacing hyphens
with nothing. It places the result in the variable Phone_num.
The parameters are:
Curr ent _El eme nt A LL " -" "" Pho ne _n um
Value before:
Value after:
614-555-1212
6145551212
Example 3. This example replaces a single quote with a double quote.
The parameters are:
Pati ent Las tNa me " '" " "" Pat ien t_ na me
Value before:
Value after:
Business Rules
O’Neill
O”Neill
190
Business Rules Reference
SetCheckCTT and SetCheckCTTCount
Instream and Desktop, X12 only
For Analyzer checking, see CheckCTT on page 224.
SetCheckCTT checks the value in the CTT-01 (number of line items) and the CTT-02 (hash
total).
SetCheckCTTCount checks the CTT-02.
For best results, place the rule on the ST segment. It has to appear before anything that it counts.
See the explanation under CheckCTT on page 224.
Format of Parameters
These rules have no parameters
Examples:
Business Rules
191
Business Rules Reference
SetIdentifier
Instream and Desktop
Flags an element used in content-based trading partner automation, which is described in detail
in InstreamTPAutomation.pdf.
This rule goes with the IdentifierLookup rule and must precede it.
This rule is only needed if two elements are used with content-based trading partner automation.
Format of Parameters
SetIDvariable
Where:
SetIDvariable
A variable to hold this element’s value for use in an
IdentifierLookup rule for content-based trading partner automation.
Example. This example puts the value of the current element into variable PayeeN103 for use in
an IdentifierLookup rule:
Business Rules
192
Business Rules Reference
SubString
All validation programs
Extracts a portion of one string into another.
Format of Parameters
DestStr SourceStr StartIndex EndIndex
Where:
DestStr
The variable that is to hold the extracted portion of the SourceStr.
SourceStr
The variable that holds the characters to be extracted. This can be a
variable or Current_Element. If Current_Element is used
and is empty, processing of the rule stops.
StartI ndex
The position of the first character to be extracted from the
SourceStr. This can be a number or a variable containing a number.
If the StartIndex is less than 1, it is set to 1.
EndI ndex
The position of the last character to be extracted from the
SourceStr. This can be a number or a variable containing a number.
If the StartIndex is greater than the EndIndex, an error message
is displayed. If the EndIndex is greater than the length of
SourceStr, the EndIndex will be set to the number of characters in
SourceStr.
Example 1. This example extracts the first 8 characters of the value in the current element into a
variable called ShipDate that can be used in a subsequent rule.
Example 2. This example extracts the first characters of the value in the current element into a
variable called ShipDate that can be used in a subsequent rule. Since the EndIndex is not an
integer, it is treated as a variable and should contain an integer that will serve as the ending point
of the substring.
Business Rules
193
Business Rules Reference
Trim
All validation programs
Removes specified characters from the right or left of a value and places the result into a
variable.
Format of Parameters
TrimLocation Characters V alue ResultVar
Where:
TrimLocation
Where to trim: the literal LEFT, RIGHT, or BOTH.
Characters
One or more characters to trim, surrounded by double quotes.
If you supply one character, all of that character will be trimmed
from the location you chose. Example: “0” removes all leading or
trailing zeros.
If you supply multiple characters, all sets of them will be trimmed
from the location you chose. Example: “12” removes all leading or
trailing sets of 12.
Value
The value to be trimmed. This can be CURRENT_ELEMENT or
a variable.
ResultVar
A variable to hold the trimmed result.
Example. This rule is placed on the ISA08 to trim trailing spaces. It puts the trimmed result in
variable GLOBAL_ISA08.
This rule uses GLOBAL_ISA08 in a CodeLookup to see if the ISA08 is valid:
Business Rules
194
Business Rules Reference
TrimWhitespace
All validation programs
Removes leading and trailing whitespace characters (spaces and tabs) from a value and replaces
any sequences of two or more whitespace characters within the value with a single occurrence.
Format of Parameters
InputValue OutputVar Options
Where:
InputValue
The value to be trimmed. This can be a constant in double quotes,
an internal variable name (Current_Element,
Current_Date, etc.), or an external variable name.
OutputVar
An external variable name where the result is to be stored.
Option
The character string containing one or more of the following
characters (these options can be combined):
L Remove any leading whitespace characters
T Remove any trailing whitespace characters
M Replace any strings of two or more whitespace characters within
InputValue with a single space
If Options is not specified then LTM is assumed.
Examples
In the following examples, ‘·’ represents a space and ‘»’ represents a tab.
Example 1
This example causes the string ‘Test·Value’ to be stored into variable RESULTVAR. Because
no Option was specified, ‘LTM’ is assumed so leading and trailing whitespace characters are
removed and duplicate whitespace sequences within the string are replaced by a single space.
Business Rules
195
Business Rules Reference
Example 2
This example causes the string ‘Post·Office·Box·1234’ to be stored into variable
TRIMMEDADDR1. The ‘space tab space’ sequence is handled as a string of three whitespace
characters and is replaced by a single space. (ADDR1 = “»Post·»·Office··Box··1234»”)
Examples 3
This example causes the string ‘Post·»·Office··Box··1234’ to be stored into variable
TRIMMEDADDR1. Because Option LT was used, leading and trailing whitespace characters are
removed. (ADDR1 = “»Post·»·Office··Box··1234»”)
Business Rules
196
Business Rules Reference
Variable Business Rules
SetLocalVariable
All validation programs
Used to explicitly set the contents of a local variable.
Format of Parameters
LocalVariableName Value
Where:
LocalVariableName
The variable name in double quotes or an external variable name
containing the local variable name.
Value
The value to be stored in LocalVariableName in double quotes or
an external variable name containing the value.
Examples
This example causes the string ‘True’ to be stored into local variable UseListA
This example causes the string ‘SMITH’ to be stored into local variable LVar2 . (Where Current
element = “SMITH”)
This example looks up external variable LVARNAME and uses its contents as the name of the
local variable to set to “1”.
Business Rules
197
Business Rules Reference
SetVar
All validation programs
Sets a BusinessRules.Variable to the contents of the current element or to a passed value. See
Appendix A: Variables on page 236 for an overview of variables.
Format of Parameters
VarName VarValue
Where:
VarName
Name you are assigning to that variable. If the variable exists, the
current contents are overwritten with VarValue. The name can be
any length, with no special characters or spaces. It is case-sensitive.
VarValue
Optional. Value being assigned to that variable. This can be another
variable, Current_Element, a literal in double quotes, or
Current_Date if appropriate. If VarValue is omitted, the value in
Current_Element is assumed.
Example. This example assigns the variable name 2010AAN402State to the contents of the
current element.
The variable 2010AAN402State can then be used in the parameter for a rule like the one shown
below, which checks the zip code in the current element to see if it is valid for the state that is in
the variable 2010AAN402State.
Business Rules
198
Business Rules Reference
AddVar
All validation programs
Adds a value to the current value of a variable. This can keep a running total for use in other
rules. Maximum precision is 8 decimal places.
Format of Parameters
VarName Var Value
Where:
VarName
The variable to hold the accumulated values. If VarName has not
yet been defined, it is created.
VarValue
Optional. The amount being added to the variable. This can be a
variable, Current_Element, or a literal in double quotes. If
omitted, the value of Current_Element is assumed.
Example. This rule keeps a running total of the service line amounts in each repetition of the
SV2 and enclosing CLM loops. It is applied to each service line amount element.
For examples of how to use the results of an AddVar, see these examples:

CompareString on page 204

Example 2: Using Rules in Loops on page 262

Example 3: Adding and Comparing Numeric Values on page 263
Business Rules
199
Business Rules Reference
Divide
All validation programs
Divides one value by another and puts the result in a variable.
Format of Parameters
Dividend Divisor NumOfdec outVar
Where:
Dividend
The value to be divided. It can be a literal, variable, or
Current_Element.
Divisor
The value that the dividend is being divided by. If this is a literal,
enclose it in double quotes.
NumOfdec
Number of decimal places to use in the result. Do not put quotes
around this integer.
outVar
Variable to hold the result.
Example. This rule divides the value in the current element by 100 and puts the result in
variable DollarVar. The result has two decimal places.
Business Rules
200
Business Rules Reference
DumpVars
All validation programs except Analyzer
You must be set up for debugging before you can use DumpVars. See page 279.
Shows External Routine variables and their current values. It does not show local variables.
Place the rule on the segment or element where you would like Validator to display the variables
and values. During validation, you can view these messages or suppress them.
Format of Parameters
Variable Variable Variable …
Where:
Variable
A variable that is to have its current value displayed. Each additional
variable can be separated by a space.
If no variable is specified, all variables are displayed.
Specific array entries may not be dumped, though the entire array
can be. For example, ListTotals(“1”) is invalid, but
ListTotals is OK, and causes each member to be dumped.
To view the dumped variables, see page 279.
Example. This rule displays the current contents of two variables:
The output in EDISIM Validator:
Business Rules
201
Business Rules Reference
Balance
All validation programs
This will validate mathematical operations on variables.
Format of Parameters
VarA
Operand
VarB = VarC IfFalseAction
Where:
VarA
A variable, Current_Element, or a literal in double quotes. If
Current_Element is used and is empty, processing stops for the
rule.
Operand
One of these: - + * /
VarB
A variable, Current_Element, or a literal in double quotes. If
Current_Element is used and is empty, processing stops for the
rule.
=
Equal sign. Put one space before and one space after the equal sign.
VarC
A variable, Current_Element, or a literal in double quotes. If
Current_Element is used and is empty, processing stops for the
rule.
(IfFalseActio n)
Optional. Executed if the mathematical operation is FALSE. If
omitted, a generic message is displayed.
Example. This rule adds up adjustments and total paid amount to ensure that they equal
submitted charges for each repetition of the CLP loop in an 835. If not, an error message
displays.
Business Rules
202
Business Rules Reference
SetVar CASAdjustment to 0
AddVar variable CASAjustment goes on
each Monetary Amount in CAS
1. Use SetVar to set the variables shown above.
2. Use the same AddVar name CASAdjustment on the CAS03, CAS06, CAS09, CAS12, CAS15,
and CAS18. This sums all of the adjustments for a repetition of the loop.
3. On the CLP Segment (which begins the loop), set the CASAdjustment to 0. This starts the
calculation at zero for each repetition of the loop:
4. To balance at the end of each repetition of the loop, go to the ST segment and use
SetLoopPostInstanceExit and Balance functions:
This gives error message 32215 if the calculation is not true at the end of loop 2100, the CLP
loop.
Business Rules
203
Business Rules Reference
CompareString and CompareStringNoCase
All validation programs
Compares two values as strings based on the operand, and executes an action if the comparison
is true.
CompareString requires the value to match exactly in order to be true; CompareStringNoCase
does not consider capitalization when comparing the values.
Format of Parameters
VarA Operand VarB (IfTrueActio n)
Where:
VarA
A BusinessRules.Variable, Current_Element, or a literal
surrounded with double quotes. If Current_Element is used and
is empty, processing of the rule stops.
Operand
EQ, NE, GT, GE, LT, or LE.
VarB
A BusinessRules.Variable, Current_Element, Current_Date,
or a literal surrounded with double quotes. If Current_Element
is used and is empty, processing of the rule stops.
(IfTrueAction)
Optional. The action to be executed if the comparison is true. If
omitted, a generic message is displayed if the comparison is true.
Example. This example checks the PER segment and issues an error message if a telephone
number starts with 1. This involved these rules:

On the PER03 (the qualifier) - Use SetVar to set up variable PER03Submitter.

On the PER04 (the number itself):
Set up a rule that checks the qualifier to see if it is “TE” and, if so, places the first character of
the PER04 into a variable that we call TEFirstDigit.
Issue an error message if the variable contains a 1.
Message 32211 is a custom message in file CustomerFSBRERRS.txt.
Business Rules
204
Business Rules Reference
CompareNstring
Compares parts of two values as strings based on the operand, and executes an action if the
comparison is true.
CompareNstring requires the specified parts of the strings to match exactly, including their case,
in order to be true.
Format of Parameters
VarA Operand VarB (startVarA;startVarB;length;case) ( IfTrueAction)
Where:
VarA
String to compare. A BusinessRules.Variable, Current_Element,
or a literal surrounded with double quotes. If Current_Element
is used and is empty, processing of the rule stops.
Operand
EQ, NE, GT, GE, LT, or LE.
VarB
String to compare. A BusinessRules.Variable, Current_Element,
Current_Date, or a literal surrounded with double quotes. If
Current_Element is used and is empty, processing of the rule
stops.
startVarA
Position where comparison starts for VarA.
startVar
Position where comparison starts for VarB
length
Number of characters to compare.
case
Whether to consider the case when comparing:
(IfTrueAction)
0
(default) Comparison is case sensitive
1
Comparison ignores the case
Optional. The action to be executed if the comparison is true. If
omitted, a generic message is displayed if the comparison is true.
Example. This example compares 6 characters of the current element, starting with position 3,
to the first 6 characters of the variable RecName. The comparison is case-sensitive. If they do
not match, an error message is displayed.
Business Rules
205
Business Rules Reference
Assume:
Current_Element
= ABC123456789
RecName
= 999123
The underlined characters will be compared. Since they do not match, this error message will
display:
“Starting with the third character, this element must contain 999123”
Business Rules
206
Business Rules Reference
CompareNumeric
All validation programs
Compares two values as numeric and executes an action if the comparison is true.
Format of Parameters
VarA Operand VarB (IfTrueAction)
Where:
Var A
A variable, Current_Element, or a literal surrounded with
double quotes. If Current_Element is used and is empty,
processing stops on the rule. If the variable does not represent a
numeric, an error message is issued.
Operand
EQ, NE, GT, GE, LT, or LE.
VarB
A variable, Current_Element, or a literal surrounded with
double quotes. If Current_Element is used and is empty,
processing stops on the rule. If the variable does not represent a
numeric, an error message is issued.
(IfTrueAction)
Business rule to be taken if the comparison is true.
Extended Example. Assume your company does not make adjustments in excess of 10000.
You want to enforce this in a guideline based on 835-W120.
To accomplish this:
1. Assign an AddVar called PLBAdjustmentAmt to each Monetary Amount element in the PLB
segment in Table 3.
2. Create a CompareNumeric rule on the SE segment that would check the total in
PLBAdjustmentAmt to see if it exceeds 10000. If so, display an error message.
Message 32214 is a custom message in file CustomerFSBRERRS.txt.
Business Rules
207
Business Rules Reference
Clear
All validation programs
Clears the values from business rule variables. These are variables defined by a
BusinessRules.Variable function like SetVar or AddVar.
Variables automatically clear out with each ISA, regardless of the presence of CLEAR rules,
unless they are GLOBAL_variables.
The location of the Clear is important. A typical place is on the first segment in a repeating loop
or on the first required element of a repeating segment.
Caution
It is hazardous to use Clear without specifying which variables are
being cleared. A Clear without a variable name results in clearing all
variables, including those in the HIPAA guideline with which you
will eventually merge your rules.
A variable with a name that starts with GLOBAL_ will not be cleared unless it is specifically
named in the Clear rule.
See page 209 for information on clearing local variables (those set by clicking the Variable button
in the Business Rules dialog box).
Format of Parameters
"VarName" "VarName" "VarName " ...
Where:
"VarName"
Name of a variable, surrounded by double quotes. If omitted, all
variables are cleared except those starting with GLOBAL_.
"VarName"
Optional names of additional variables, surrounded by double
quotes and separated by spaces.
Example. This rule clears the BusinessRules.Variables HI0102IndustryCode and
CLAIMcount.
Business Rules
208
Business Rules Reference
ClearLocalVariable
All validation programs
Removes one or more local variables from the repository. The variable had been defined by
clicking the Variable button in the Business Rules dialog box as described on page 236.
Variables automatically clear out with each ISA, regardless of the presence of CLEAR rules,
unless they are GLOBAL_variables.
For information on clearing BusinessRules.Variable, see Clear on page 208.
Format of Parameters
"VarName" "VarName" "VarName" ...
Where:
"VarName"
Name of a local variable, surrounded by double quotes. You cannot
clear all local variables by omitting a variable name in this rule. You
must explicitly tell which ones are to be cleared.
"VarName"
Optional. Names of additional local variables, surrounded by
double quotes and separated by spaces.
Example. This rule clears two local variables.
Business Rules
209
Business Rules Reference
FileTable Rules
The FileTable rules let you check an external text file for a value. If it is found, a related value is
returned in a variable.
This set of rules clears the variables used by FileTableLookup rules, identifies the file containing
the tables as FileTable.txt, and looks up BROWN in the file:
The Table
The file must be in Instream’s Bin directory. It contains the table name preceded with ^ and then
one or more lines in this format:
key|value
The business rule inquires if the key is in the file. If so, value is returned in a variable. If not, the
variable is empty.
You can have one or more tables in this file.
Example
This table lets you inquire if SMITH is in the table. If so, the value 111222333 is returned in a
variable. Likewise, you could check for JONES or BROWN and get their related values.
FileTableClear
Clears the variable Retval, which is used in FileTableLookup.
Format of Parameters
None
Example. This rule clears variable Retval.
Business Rules
210
Business Rules Reference
FileTableLoad
Identifies the file that contains the table that you will be using for a lookup. This file must be in
Instream’s Bin directory.
Format of Parameters
“filename”
Where:
“filename”
File name and extension.
Example. This rule identifies FileTable.txt in Instream’s Bin directory.
FileTableLookup
Checks a table, in the file identified with FileTableLoad, for a value. If the value is in the table, a
related value is returned.
Format of Parameters
“tableName” key ReturnVar
Where:
“tableName”
Table name within the file.
Example
t a b l e N a m e is TableA in this file:
key
Business Rules
Value to search for in first column.
211
Business Rules Reference
ReturnVar
Variable in which to return the corresponding value in the second
column.
Example
If R e t u r n V a r is SubNumVar and k e y is Brown, then
SubNumVar will contain 333444555 after the rule executes.
Example. If TableA contains BROWN, the corresponding value is returned in variable
SubNumVar.
Business Rules
212
Business Rules Reference
GetInfo
Populates a variable with one of these:

The iteration of the current loop. This is a digit.

The loop ID, an underscore, and the iteration of the current loop. Example: 2000C_3

The value in an envelope element that is later in the segment than the business rule that uses
it.
Format of Parameters (3 variations):
Current_LoopCounter var
Current_LoopKey var
ENV(elementIndex ) var
Where:
Current_LoopCounter
Literal text that represents the iteration of the current loop. This
reserved word should only be used with GetInfo.
Current_LoopKey
Literal text that represents the loop ID, an underscore, and the
iteration of the current loop. This reserved word should only be
used with GetInfo.
Env
Literal text meaning the value is in the ISA or GS.
elementIndex
Element position within the current segment (the ISA or GS).
var
Variable to hold the loop count (for Current_LoopCounter or
Current_LoopKey) or the value in the envelope element (for ENV).
Example 1
This puts the loop count into a variable called CLMcount.
This puts the Loop ID and the iteration of the loop and into a variable called CLMkey.
By using a DumpVars and showing debug messages, we see a count like this in Desktop for each
iteration of the loop.
Business Rules
213
Business Rules Reference
Example 2
This puts the loop count in variable LoopNum2000B and executes at the end of each iteration of
the 2000B loop:
By using a DumpVars and showing debug messages, we see the count in Desktop. This data had
two 2000B loops and the first one had an error.
Example 3
This rule, written on the ISA06, grabs the value in the ISA08 and places it in a variable called
ISAReceiverID.
This rule, also on the ISA06, displays an error if the values in the ISA06 and ISA08 are the same.
Business Rules
214
Business Rules Reference
GetLength
All validation programs
Puts the length of a value into a variable.
Format of Parameters
TargetVar Source
Where:
TargetVar
A variable to hold the length.
Source
A BusinessRules.Variable, Current_Element, or a literal
surrounded with double quotes. The number of characters in this
value will be counted and the result placed in TargetVar.
Example. This rule counts the number of characters in SubscriberID and places the
resulting number in SubscriberIDlength.
Business Rules
215
Business Rules Reference
GetValueFromSegment
All validation programs
Gets a value from a variable that was saved with SaveCurrentSegment.
Format of Parameters:
SegVariable VarType Element Subelement OutVar
Where:
SegVariable
The variable containing a segment; created with a
SaveCurrentSegment rule.
VarType
Type of information, one of these literals:
Element
Subelement
OutVar
Business Rules
VALUE
OutVar will contain a value from the segment.
NAME
OutVar will contain a name for the elementsubelement ID. The actual name is your choice.
POS
OutVar will contain the segment’s location in the file,
where the first segment is 1, the second segment is 2,
etc.
The position of the element that you are getting.
Examples: CLM*2*200.00***13:A:1**B*W*Y***********2~
2
Refers to the value 200.00
5
Refers to the value 13:A:1 (a composite)
-1
No specific element; refers to the whole segment.
The location of the subelement within the element. Examples
(using CLM segment above, and assuming Element was 5):
1
Refers to the value 13
3
Refers to the value 1
-1
No specific subelement. Refers to the whole
composite. If the element is not a composite, always
use -1.
Variable that will contain the value, ID, or segment position
requested.
216
Business Rules Reference
Examples. Assume that a SaveCurrentSegment rule has saved the CLM segment in variable
CLM2300SEG. Use CLM*2235057*460.00***25:B:1*N*A*N*I*P*OA*********1~ as
an example.
Example 1. This rule saves the CLM’s position number to variable SEGPOS:
BusinessRules.Utilities.GetValueFromSegment:"CLM2300SEG" POS -1 -1 SEGPOS
Example 2. This rule saves the value in the CLM05 to variable CLM05. In this case, it is a
composite. Because the subelement parameter is -1, the whole value 25:B:1 is placed in
variable CLM05:
BusinessRules.Utilities.GetValueFromSegment:"CLM2300SEG" VALUE
5 -1 CLM05
Example 3. This rule gives the ID of the CLM05 the name CLM05NAME.
Notice that the subelement parameter is -1, so the name applies to the entire composite ID:
C023
BusinessRules.Utilities.GetValueFromSegment:"CLM2300SEG" NAME 5 -1 CLM05NAME
Example 4. This rule saves the CLM0501 (the first subelement in the CLM05) to variable
CLM0501. In our example, this will contain 25.
BusinessRules.Utilities.GetValueFromSegment:"CLM2300SEG" VALUE 5 1 CLM0501
Example 5. This rule shows how the variables above might be used by a BuildString rule. It
strings together literals and variables and places the result in variable CTXOUTSTRING:
BusinessRules.Utilities.BuildString:CTXOUTSTRING "" "CTX|CLM" "*" SEGPOS
"**" CLM05 "*" CLM05NAME ":" CLM0501
CTXOUTSTRING might contain something like this:
CTX|CLM*32**25:B:1*C023:25:C
Business Rules
217
Business Rules Reference
IsAlpha
All validation programs
Checks a value and takes action if it consists entirely of letters of the alphabet (A-Z and a-z only).
Format of Parameters
Value (IfTrueActio n) (I f FalseAction)
Where:
Value
The value being checked. This can be a variable,
Current_Element, or a literal in double quotes.
IfTrueAction
An action to be executed if the value contains all letters. Required if
you are specifying an IfFalseAction. To do nothing if false, use this:
(BusinessRules.Utilities DoNothing)
IfFalseAction
Optional. An action to be executed if the value contains something
other than letters.
Example. This rule checks to see if the current element is alphabetic. If so, it checks to
see that it conforms to the NationalProviderID format and displays a message if it does
not. If it is not alphanumeric, it displays error number 30110.
Business Rules
218
Business Rules Reference
IsAlphaNum
All validation programs
Checks a value and takes action if it consists entirely of numbers and/or letters of the alphabet
(0-9, A-Z, and a-z).
Format of Parameters
Value CaseOption (I fTrueAction) (IfFalseAction)
Where:
Value
The value being checked. This can be a constant in double quotes, a
system variable (Current_Element, Current_Date, etc.), or an
external variable name.
IfTrueAction
An action to be executed if the value passes the IsAlphaNum test.
Required if you are specifying an IfFalseAction. To do nothing if
false, use this:
(BusinessRules.Utilities DoNothing)
CaseOption
Optional. Further limits the check to allow just upper-case or lowercase letters:
U = Limit valid characters to numbers and uppercase letters
L = Limit valid characters to numbers and lowercase letters
IfFalseAction
Optional. An action to be executed if the value fails the
IsAlphaNum test.
Business Rules
219
Business Rules Reference
IsNum
All validation programs
Checks a value and takes action if:

It consists entirely of numbers

It has a specific number of decimal places

It has leading and/or trailing signs

You want to specify certain decimal requirements.
Format of Parameters
Value (DecPlaceArg ) (I fTrueActio n) (IfFalseActio n)
Where:
Value
The value being checked. This can be a variable,
Current_Element, or a literal in double quotes.
DecPlaceArg
Optional. Check for number of decimal places, leading and/or
trailing signs, and decimal place character requirements.
DecPlaceArg can be a constant in double quotes or a variable
containing an option string. It is made up of one or more of the
following sequences:
Dn(-n) – Check the for a an allowable number of decimal places.
S or T – Means the value must have a leading (S) or trailing (T) sign
for the edit to pass. Otherwise, the IfFalseAction will be taken.
If you include a comma or period, the decimal point character will
have to be that character.
See DecPlaceArg Examples below for additional information.
IfTrueAction
An action to be executed if the value contains all numbers.
Required if you are specifying an IfFalseAction. To do nothing if
false, use this:
(BusinessRules.Utilities DoNothing)
IfFalseAction
Business Rules
Optional. An action to be executed if the value contains something
other than numbers.
220
Business Rules Reference
Example. This rule checks to see if the current element is entirely numeric. If so, it
checks to see that it conforms to the NationalProviderID and displays error 32001 if it
does not.
The parameter is:
Current_Element (BusinessRules.Utilities CheckFormat
NationalProviderID Current_Element (BusinessRules.Utilities
DisplayErrorByNumber 32001) (BusinessRules.Utilities DoNothing))
DecPlaceArg Examples
This section provides examples of the variations of the DecPlaceArg parameter.

Dn(-n), checks Value for a an allowable number of decimal places.
Dn, where n is 0 – 9 requires that Value have exactly the specified number of decimal digits.
For example, D3 will pass 34.123, but not 34.12 or 55.
D n-n specifies a range and requires that Value have at least the minimum number of decimal
places, but no more than the maximum. For example, D2-4 will pass 123.4567 and 44.55, but
not 123.4 nor 44.987654.
A number with a decimal point character but no subsequent decimal digits, such as 1234., will
always fail.
Examples
IsNum “1234.56” “D2” (IfTrueAction) (IfFalseAction)
Causes the (TrueAction) to be taken because 1234.56 is a number, and has two
decimal places.
IsNum “1234.567” “D2” (IfTrueAction)(IfFalseAction)
Causes the (IfFalseAction) to be taken because, while 1234.567 is a number, it has
three, not two, decimal places.

S or T specifies requirement for sign characters ‘+’ and ‘-’.
Use S to require leading signs in the value (ex. +123, -5.6).
Use T to require trailing signs in the value (ex. 123-, 2.345+).
Use both S and T to require signs before or after the number (ex. +123, 123-). (Note that in
this case a value with both will fail.)
Business Rules
221
Business Rules Reference
Examples
IsNum “+1234.567” “D2-5S”(IfTrueAction)(IfFalseAction)
Causes the (IfTrueAction) to be taken because +1234.567 is a signed number.
IsNum “1234.567” “D2-5S” ”(IfTrueAction)(IfFalseAction)
Causes the (IfFalseAction) to be taken because 1234.567 does not have the
required leading sign character.

. (period) or , (comma) forces the decimal point character to be the specified one. For
example, D2-5, forces the decimal point character to be a comma and D2-5. forces the
decimal point character to be a period.
The default decimal point character is determined from the input file if provided (for example,
EDIFACT and its UNA segment). Otherwise, the default is a period.
Examples
IsNum “1234,567” “D2-5”(IfTrueAction)(IfFalseAction)
The action taken depends on the decimal point character in effect.
- For EDIFACT data, where the decimal point is specified by the UNA as a comma, the
(IfTrueAction) is taken.
- For X12 data, which assumes a period as the decimal point, the value is not recognized as a
number, and the (IfFalseAction) is taken.
IsNum “1234,567” “D2-5, ”(IfTrueAction)(IfFalseAction)
Causes the (IfTrueAction) to be taken because it forces the decimal point to be a
comma.
Business Rules
222
Business Rules Reference
SaveCurrentSegment
All validation programs
Saves the content of the current segment, minus the segment terminator, in a segment variable.
You can then use it with GetValueFromSegment rules.
Format of Parameters
SegVariable
Where:
SegVariable
Storage name for the segment. This can be used with
GetValueFromSegment rules but cannot be used as a typical
variable.
Example
This rule on the CLM segment saves the contents of the CLM segment to variable CLM2300SEG:
CLM2300SEG might contain something like this. The segment terminator is not included.
CLM*2235057*100.00***13::1*N*A*Y*A*B******P
Please see GetValueFromSegment on page 216 for details about how to get specific values out of
this variable.
Business Rules
223
Business Rules Reference
CheckCTT
Analyzer Only
(See SetCheckCTT and SetCheckCTTCount on page 191for Instream and Desktop validating)
Checks the value in the CTT-01 and, optionally, in the CTT-02 also.
For best results, place the rule on the ST segment. It has to appear before anything that it counts.
For Function Name, choose:
SetCheckCTTCount to check the CTT-01
SetCheckCTT
to check the CTT-01 and CTT-02
The number of line items (CTT-01) is usually the count of the first loop in Table 2, or the table
before the one containing the CTT. It is never an N1 loop.
The Hash total target is usually the first R-type field for amounts (such as element 330 or 782) on
or after the line item segment. All hash total targets are type R, as is CTT-02 (element 347). The
only hash total targets are elements 330, 782, 358, 380, 382, and 663.
CTT Checking
Set
CTT-01 NO. of ...
CTT-02 Hash Total of...
Element and Description
202
LX
205
MMC
500
HL
561
HL
PO102
330 (Quan. Ordered)
568
CS
AMT02 at 2-090
782 (Mon. Amt)
810
IT1
IT102
358 (Quan. Invoiced)
811
IT1
819
JIL
JIL03
782 (Mon. Amt)
828
DAD
Not Used
830
LIN
FST01
832
LIN
Not Used
840
PO1
PO102
330 (Quan. Ordered)
843
PO1
PO102
330 (Quan. Ordered)
844
CON
QTY02
380 (Quantity)
845
CON
QTY02
380 (Quantity)
846
LIN
QTY02
380 (Quantity)
847
HL
Not Used
Business Rules
224
380 (Quantity)
Business Rules Reference
CTT Checking
Set
CTT-01 NO. of ...
CTT-02 Hash Total of...
Element and Description
849
CON
QTY02
380 (Quantity)
850
PO1
PO102
330 (Quan. Ordered)
851
LS1
LS101
380 (Quantity)
852
LIN
Not Used
853
TD5
Not Used
855
PO1
PO102
330 (Quan. Ordered)
856
HL
SN102
382 (Units Shipped)
860
POC
POC03
330 (Quan. Ordered)
861
RCD
RCD02
663 (Quan. Units)
862
LIN
FST01
380 (Quantity)
865
POC
POC03
330 (Quan. Ordered)
866
DTM
QTY02
380 (Quantity)
867
LIN
QTY02
380 (Quantity)
869
HL
870
HL
PO102
330 (Quan. Ordered)
Example. This rule checks the CTT-01.
Business Rules
225
Business Rules Reference
FSVBExit.CheckDigit
Analyzer Only
For other validators, see CheckFormat on page 155.
Checks if data conforms to a length requirement, contains the correct number of leading zeros
and has a correct check digit as its final digit.
Check Digit algorithm
All TIBCO Foresight CheckDigit rules use UPC-A system:
1. Add together all the digits in odd-numbered positions and multiply that sum by 3.
2. Then add each digit in an even-numbered position to that sum.
3. The check digit will be whatever number you need to add to that end result sum to make it a
multiple of 10.
The rule looks like this:
Business Rules
226
Business Rules Reference
X12 234-235 CheckDigit
Analyzer Only
CheckDigit will check element 234’s last digit against the qualifier in element 235 if element 235
contains a code that has one of these character strings in its definition:
EAN
U.P.C.
The CheckDigit rule goes on element 234.
If element 235’s code has
EAN or U.P.C. in its
definition …
Then element 234’s
data will be checked by
the corresponding check
digit formula. Put the
CheckDigit rule here.
Analyzer will check the data in element 234 to see if it complies with the specified format of the
code value that was used.
Business Rules
227
Business Rules Reference
EDIFACT 3039-3055 CheckDigit
Analyzer Only
CheckDigit will check the last digit in the element 3039 if the data in element 3055 contains a
code that has one of these character strings in its definition:
EAN
UPC
The CheckDigit rule goes on element 3039.
CheckDigit rule goes here.
Element 3039’s data will be
checked by the check digit
formula …
…if element 3055’s code
has EAN or UPC in its
definition …
Analyzer will check the data in element 3039 to see if it complies with the specified format of the
code value that was used.
Business Rules
228
Business Rules Reference
Other CheckDigit Options
Analyzer Only
See also CheckFormat on page 155.
Besides the 234 - 235 and 3039 - 3055 pairs, CheckDigit server can check other numeric values
for a correct check digit, min/max length, and the correct number of leading zeros.
You can enter these as parameters when setting up the CheckDigit routine:
EAN8
Data must be exactly 8 characters with no leading zeros.
EAN13
Data must be exactly 13 characters long with no leading zeros.
EAN14
Data must be exactly 14 characters long with no leading zeros.
SSCC
Data must be exactly 18 characters long with up to one leading zero.
UPC12
Data must be exactly 12 characters long and can include leading zeros.
In each of these, the length includes the check digit.
Example: X12 Element 87 (MAN segment in 850)
If element 88 contains UP,
then the data for the current element must conform to UPC12
When Analyzer encounters this element 87, it will look at element 88 to see if it contains qualifier
UP. If so, it will verify that element 87 conforms to UPC12 (exactly 12 digits long with up to two
leading zeros) and has the correct check digit.
User Defined Check Digit
Analyzer Only
You can also check other numeric values, even if they have no qualifier. The data must match
the parameter format specified by the guideline or MIG developer in Standards Editor.
The generic format of min-max Zn can be used in place of the EDISIM-defined parameters,
where:
min
is the minimum length of the field
max
is the maximum length of the field (optional)
Zn
Zn is optional. Z is a literal and n is the number of leading zeros allowed. If
omitted, no leading zeros are allowed.
Business Rules
229
Business Rules Reference
Examples:
5Z0 or 5
Data must be at least 5 characters long with no leading zeros.
5-5Z0
Data must be at exactly 5 characters long with no leading zeros.
10-12Z2
Data must be between 10 and 12 characters long (inclusive) with up to two
leading zeros.
5-6 or 5-6Z0
Data must be between 5 and 6 characters long with no leading zeros.
EDIFACT element 7402 example
This is placed on element 7402 in a GIR segment in the ORDERS message:
When Analyzer encounters element 7402, it will verify that this element is exactly 10 digits long
with no leading zeros and has the correct check digit.
DateTime
Analyzer Only
For other validators, see Date and Time on page 72.
Checks date and time to see if it follows the specified format.
X12 element 1251
Place the rule on the element 1251 that you want to check.
Use function ValidateDateTimeX12. The rule will check to
see if it follows the format specified in element 1250.
EDIFACT element 2380
Place the rule on the element 2380 that you want to check..
Use function ValidateDateTimeUN. The rule will check to
see if it follows the format specified in element. 2379.
Be sure to customize the code values for the corresponding qualifier: X12 element 1250 or
EDIFACT element 2379.
Example. This rule checks X12 element 1251.
Business Rules
230
Business Rules Reference
FSVBExit.DisplayMessage
Analyzer Only
For other validators, see DisplayErrorByNumber on page 161.
Displays a customized diagnostic.

Display the diagnostic Code value must be 00 or 01 if a value is something else. See
example 1 below.

Display the diagnostic Vendor Num REF must precede Booking Num REF if this
condition is violated. See example 2 below.

Displays the message DUNS number must be 7825012250001 or 7825012250022 .
See example 3 below.
Steps include:
1. Define variables needed by the condition, if any.
2. In the Condition and Result Definitions box, set up the condition in the top and select Invoke
External Routine.
3. For Server Name, select FSVBExit.DisplayMessage.
4. For Function Name, select DisplayError.
5. For Parameters, type the diagnostic that is to display if Analyzer finds that the condition is
violated.
Example
This example displays “New PO1 loop” each time this segment appears in the data.
Business Rules
231
Business Rules Reference
Example: More descriptive diagnostics about code value violation
Our purchase order allows 2 code values for the BEG01: 00 and 01. Data that contains any other
value causes Analyzer to issue a diagnostic similar to “Code Value "03" not used for BEG01
(D.E. 353) at col. 5.”
This business rule will give an additional diagnostic: “Code value must be 00 or 01.”
Business Rules
232
Business Rules Reference
Example: Enforcing a particular order for REF segments
Let’s assume that we want two or more consecutive REF segments, and they have to be in the
same order as they appear in the guideline. Ordinarily, Analyzer would allow consecutive REF
segments to appear in any order in the data.
Edit the code values in each REF-01 to be unique.
Assign a local variable to the first REF. In our example we’ll use REF01first.
Create this business rule on the second REF:
If the REFs appear out of order, Analyzer displays the custom message:
Business Rules
233
Business Rules Reference
Example: Display the application value in an Analyzer diagnostic
Analyzer flags application value violations with a message like this:
Application Value "9012345918341" not found in value list "DUNS"
By using DisplayMessage, you can display an additional message that lists what values are
acceptable:
DUNS number must be 7825012250001 or 7825012250022
To set this up:
1. Attach the DUNS application value list to the element.
2. Place a variable on the element. In our example we’ll use 3100N104.
3. Place this rule on the element:
If Analyzer finds another value at that location, it will display the message that you specified.
Business Rules
234
Business Rules Reference
ProductUtilities
Analyzer Only
This rule checks segments with repeating pairs of element 235-234 (like the 850’s LIN segment
in recent vintage X12 versions) by:

Defining code(s), if any, that must be used in an element 235 in the segment.

Allowing the 235-234 pairs to appear in any order within the segment.

Prohibiting duplicate codes in element 235 within the segment.
Example
This rule on the LIN segment requires at least three 235 elements. They must contain B3, B5,
and B6.
When analyzing EDI data against this guideline, Analyzer will display diagnostic messages if
these conditions are not met: “Check235 Error(s) - Duplicate Codes: B5 Missing Codes: B6” or
similar.
Business Rules
235
Business Rules Reference
Appendix A: Variables
Before using any element other than the current element in a business rule, you will need to
assign it a "variable" name. There are two types of variables: local variables and
BusinessRules.Variable.
When do you use a local variable and when do you use a BusinessRules.Variable? That depends
on how you want to use it in a rule. See the next two sections for details.
Local Variables
When to use Local Variables
Assign a local variable if you will use it in the top of the Business Rules box. You must be on an
element.
Assigning a Local Variable
To assign a local variable:
1. Click on the element.
2. Select Edit | Advanced | Business Rules.
3. In the Local Variable area, type a variable name that conforms to the suggestions in Good
Variable Names on page 238.
Business Rules
236
Appendix A: Variables
4. Click OK to close the dialog boxes.
BusinessRules.Variable
When to use BusinessRules.Variable
Use BusinessRules.Variable when you want to assign a variable name that will be used in the
Parameter area of the Condition and Rule Definition dialog.
In this example, variable 1000APER04CommNum must be a BusinessRules.Variable because it
is used in the Parameters area of the rule:
This example compares the contents of variable 1000APER04CommNum to the current
element's value. If they are the same (true condition), then error number 32211 displays.
Setting up BusinessRules.Variable
Create BusinessRules.Variable with business rule functions like SetVar or AddVar.
To assign a BusinessRules.Variable:
1. Click on the element or segment.
2. Choose Edit | Advanced | Business Rules | New.
3. Click Always and select *Call External Routine from the drop box.
4. For Server Name, choose BusinessRules.Variable and then choose the Function Name
SetVar (see page 197) or AddVar (see page 199).
You can also assign variables with these functions under BusinessRules.Utilities:
AppendString (page 147), GetToken (page 168), or SubString (page 168).
Business Rules
237
Appendix A: Variables
5. Type the variable's name in the rule definition area, as in the following example. Follow the
naming suggestions in Good Variable Names on page 238.
Good Variable Names
TIBCO Foresight-supplied variable names indicate the location where the variable is assigned.
For example, to find 2 0 1 0 A B N M 1 0 8 I D Q u a l :
2010AB
= loop 2110AB
NM1
= segment
08
= element
IDQual
= short description
It is good practice for you to follow this convention and use the location of the element as part
of the name.
Variable names can be any length and should not contain special characters or spaces.
Example. If you are assigning a variable to the Statement Date DTP02 in loop 2300 of the
Subscriber HL loop of an 837:
Good name
Variable Name
Explanation
S2300DTP02StmtDt
S for Subscriber HL level.
2300 for loop 2300.
DTP02 for segment and element.
StmtDt for the Statement Date DTP.
Poor name
DTP02
Which DTP? There are many.
Example. If you are assigning a variable to the NM108 Identification Code Qualifier in loop
2010AB:
Good name
Variable Name
Explanation
2010ABNM108IDQual
2010AB for loop 2010AB.
NM108 for segment and element.
IDQual for the element name.
Poor name
IDQual
Which ID Qualifier? There are many.
If you follow these guidelines, a variable’s name will tell you where it is assigned.
Business Rules
238
Appendix A: Variables
Global Variables
To set up a variable that is cleared only by specifically naming it in a BusinessRules.Variable
Clear rule, assign a name that starts with GLOBAL_ (note the underscore).
Example. GLOBAL_2010ABNM108IDQual. The word GLOBAL and the underscore are
actually part of the name and should be included when using the name in a rule.
TIBCO Foresight-Defined Variables
Instream sets up these variable names when the guideline runs a UserExitWithWait business rule
(see page 103):
FS_UserExit_Status
FS_UserExit_RtnCode
Return status from external program, which can be:
200
Initial state at startup before attempt to call process
201
Called the process
202
Process completed within the time specified (Only
used for UserExitWithWait)
203
Process cancelled due to time limit (Only used for
UserExitWithWait)
204
Failed to locate Process
The return code from the external program.
The following variable is contained in the the base validation guidelines provided with TIBCO
Foresight products, however for it to be made active, a SetVar business rule is required in the
companion guideline.
FS_ICD9_ICD10_CutoverDate
This variable supports the ICD-9 to ICD-10 conversion
process cutover and is pre-set to the appropriate date.
To update this value without changing the associated
guidelines, override the variable by directing Instream to
call an external PreLoadedVariable file. See Procedure:
Changing the FS_ICD9_ICD10_CutoverDate Variable
on page 240.
Business Rules
239
Appendix A: Variables
Procedure: Changing the FS_ICD9_ICD10_CutoverDate Variable
Use the following steps to update the FS_ICD9_ICD10_CutoverDate variable.
1. Open your companion guideline using EDISIM Standards Editor. If you don’t have a companion
guideline, create a new one. In the examples in this procedure, our companion guideline is called
CUTOVERDATECHECKING.
2. On the ST segment of the companion guideline, add a SetVar business rule. We want to assign the
TIBCO Foresight-define variable FS_ICD9_ICD10_CutoverDate to a new variable name. Use
the variable name of your choice. In this example our new variable name is
MY_CUTOVERDATE.
When you are done, your business rule should look something like this:
Save your guideline.
Business Rules
240
Appendix A: Variables
3. Use GuideMerge to merge your companion guideline with the base guideline (which includes types
1-7 edits). Save your new guideline. Refer to GuideMerge.pdf for more information on merging.
4. Edit your external variables file to update the value for your new variable. If you don’t have an
external variables file, create one. (See Populating Variables with an External Variables File on
page 245.)
We want to use MY_CUTOVERDATE instead of the TIBCO Foresight-defined variable
FS_ICD9_ICD10_CutoverDate and we want MY_CUTOVERDATE to be set to 20141231. Save
the file.
5. Tell Instream where to find your external variables file by adding a PreloadedVariables line to
your $dir.ini file. Save the file.
The Preloaded Variables file will now be called during validation.
Business Rules
241
Appendix A: Variables
Preprocessor Variables
You can define and reference variable names on the fly by bracketing them by percent signs.
These “preprocessor variables” differ from regular variables in these ways:

For most rules, they are evaluated when the rule is executed.

For exits, they are evaluated when the rule in the exit is triggered, not when the exit itself is
encountered.

Their value can be another variable.

They can be used in any part of a business rule parameter.

They can be used to display a value in error messages for hard-coded rules but not in
CustomerFSBRerrs.txt rules.

They are surrounded by percent signs. Any time a variable bracketed by percent signs is seen
(ex. %TESTVAR%), it will be replaced by that variable’s contents.
For example, if we have a variable named “LocID” that contains a string corresponding to the
Location ID (say 540) then the statement
InsertList %LocID% ShipLOC
becomes
InsertList 540 ShipLOC
Example.
The % delimiters around PO1Count show that this is not the actual name, but a variable that
will point to the name. The contents might be another variable, which might contain another
variable and so on. At runtime, this chain is resolved as far as it goes.
These “indirect references” are resolved when the rule is run, not when it is encountered.
However, the following exits resolve the variable when the rule that they contain runs , not
when the exit itself is encountered:

SetCompositePreExit

SetElementPostExit

SetLoopPostExit

SetLoopPostInstanceExit

SetSegmentPreExit
Business Rules
242
Appendix A: Variables
Variable Delimiters
Used in CustomerFSBRerrs.txt message
Used in hard-coded message
Used in body of business rule
Variable contains
constant
Variable contains
another variable
#
See example 1
cannot be used in
external error file
%
%
See example 2
See example 3
unless noted, no
delimiters
%
See examples 5 and 6
See example 4
A number of examples are below. For two complex preprocessor variable examples involving
maps, see page 248.
Example 1. This example used a regular variable, not a preprocessor variable. OrderNum is a
variable containing a constant value.
32005
Order #OrderNum# received on #Current_Date#
Example 2. OrderNum is a variable containing a constant value. The error message is hardcoded into the business rule and contains two variables, which have to be surrounded by percent
signs.
Example 3. While this example appears this same as Example 2, in this case the variable
OrderNum contains a variable LastOrderNum which can contain a constant or another variable.
Business Rules
243
Appendix A: Variables
Example 4. OrderNum and MinNum are regular variables containing constants. They are not
surrounded by any special characters in the body of the rule except in DisplayErrorByNumber.
Example 5. This example creates a list name on the fly. The rule is inserting the contents of
LineItemAMT into the list (name to be determined by resolving the variable OrderID):
Assume:
OrderID
contains 20081025A10
LineItemAMT contains 72.50
The parameters above becomes:
20081025A10 72.50
( in s ert 72 .5 0 i nt o th e li st n amed 20 08 102 5A 10)
Example 6. Nested variables.
Assume:
ABC
DEF
GHI
contains %DEF%
contains %GHI%
contains JOHNSONJAKE
The parameters above becomes:
JOHNSONJAKE “1” (Add 1 to v ariable JOHNSONJAKE)
Business Rules
244
Appendix A: Variables
Populating Variables with an External Variables File
You can store variables and their values in an external file. This allows you to change the value
without changing the guideline.
This file can have the filename and location of your choice, as long as it can be accessed by
Instream.
To tell Instream where to find your variables file, add a PreloadedVariables line to $dir.ini in
Instream’s Bin directory:
Inside the variable file, each line contains:
variable,value
Example:
This file contains two variables. InternalPartner contains the value “KAVERCORP.”
If you use a business rule like this, the output for the element or field where this business rule
is located will contain “KAVERCORP.”
InternalPartner must be spelled and capitalized exactly the same in the external file and in the
business rule.
Save it with any filename and a location that is accessible to Instream. This file can contain
other data also.
For more information about dir.ini files, see Dir.ini_and_FSDir.pdf.
Business Rules
245
Appendix A: Variables
Initializing and Clearing Variables and Lists
Local variables, SetVar variables, and lists retain their current values until:

The value is changed with another rule.

The value is changed in another iteration of the loop that contains the rule.

The value is explicitly cleared.

The transaction set ends.
Variables in Loops
If a value is set on an element that will always occur, then the value will be overwritten with each
iteration of the loop.
If a value is set on an element that may or may not occur, then the value may persist through
multiple iterations of the loop. You may need to reset the value at the beginning or end of the
loop.
Consider this SetVar variable:
Mandatory loop;
can repeat
Mandatory loop;
cannot repeat
Optional element;
SetVar assigns
2010AAN404 here
Since N4-04 is optional, we want to provide for loop iterations where the N404 is not present.
There are many ways to handle this.
Business Rules
246
Appendix A: Variables
Example Method 1. Initialize
On the 2000A HL or the 2010AA NM1 segment, initialize the value:
Example Method 2. Clear at top of loop
On the 2000A HL or the 2010AA NM1 segment, clear the value:
Example Method 3. Clear at end of loop
On the ST, clear the variable at the exit of each 2000A or 2101AA loop:
Lists in Loops
The same principals apply to lists and to variables. You can reset the list with a
BusinessRules.List ClearList (see page 106) at the beginning of the loop or as a loop exit.
Business Rules
247
Appendix A: Variables
Variable Maps
Variables can be maps with alphanumeric indices. A map reference is a variable followed by an
alphanumeric index in parentheses, like these examples:
VendorTypeTotals(“InState”)
Refers to the “InState” slot of variable VendorTypeTotals.
StateTotals(“OH”)
Refers to the “OH” slot of variable StateTotals.
CategoryFlag(1)
Identical to CategoryFlag(“1”).
IDNeeded(“”)
Identical to IDNeeded (just a regular variable).
IDNeeded(MyVar)
Gets the index from the contents of variable MyVar.
CountryTotals(%MyVar%)
Gets the index from the contents of the variable contained in
MyVar. See Preprocessor Variables on page 242.
BuyerIndex(MyVar(BuyerCode))
First uses BuyerCode’s contents as index into MyVar array,
which it then uses as index into BuyerIndex array.
BusinessRules.Variable.Clear will clear the entire map, and BusinessRules.Variable.DumpVars
will display all map members, including their keys.
Maps are especially powerful when combined with preprocessor variables (see page 242).
Example 1
We display a message if the sales tax rate is incorrect for the state.
First, we create a map called StateTax containing sales tax rates for each state:
We set up a local variable on the State element:
Business Rules
248
Appendix A: Variables
Next, we go to the tax rate element and use the “Single” row at the top to see if the state is OH.
If so, we check the current element against our StateTax’s “OH” index. If they don’t match, we
display a message like “Tax rate is .055 for Ohio.”
We repeat this for each state:
Example 2
Like Example 1, this displays a message if the sales tax rate is incorrect for the state, but it uses
fewer rules.
First, we create the same map called StateTax containing sales tax rates for each state:
Business Rules
249
Appendix A: Variables
We set up a BusinessRule variable called StateCode on the State element:
Next, we go to the tax rate element and use the StateCode element as an index into our map. We
put the tax rate they should be using, considering their state, into a variable called StateTaxRate:
In a second rule on the same element, we check the current element against what it should be
(StateTaxRate). If it differs, we display a message that shows the correct state tax rate and the
state:
This rule will take care of any state in our map. We do not need separate rules for each state.
Business Rules
250
Appendix A: Variables
Appendix B: Validator Error
Messages
All validation programs
Viewing TIBCO Foresight-Supplied Error Messages
Please see ErrorMessageNumbers.pdf for a list of error message ranges, the files that contain them,
and what guidelines use them. These messages are used by the TIBCO Foresight-supplied business
rules.
Creating and Viewing your own Error Messages
To create your own custom error messages:
1. Look at the format of the error messages in FSBRErrs.txt in the Bin directory:
Each error message is on a separate line.
Each line starts with the number, then a Tab, then the text to be displayed during validation.
2. Use Notepad or another text editor to open the file CustomerFSBRERRS.TXT in the Bin
directory. Use this file when you want to create your own error messages.
Follow the format you saw in FSBRErrs.txt. The lowest error number you can use is 32000, which
already contains a dummy error message with text that you can change:
32000
Add your own error messages
Tab
Change the text for error 32000. Do not use any special characters such as exclamation marks.
3. To add another error message, add a line for error 32001 followed by a Tab and the error text.
You can use the following number ranges for custom error messages:
32000-32999
60000 to 60999
4. Save and close the file.
You now have your own error message and can use it in business rules.
Business Rules
Appendix B: Validator Error Messages  251
Variables in Error Messages
You can use a BusinessRules.Variable in error messages by surrounding the variable with:
#
(pound signs)
If the error message is in CustomerFSBRErrs.txt.
%
(percent signs) If the error message is hard-coded into the business rule.
This message displays variable S2300CLM01ClaimNum:
32222
Beginning of claim number #S2300CLM01ClaimNum#
The same message hard-coded into the business rule itself will look like this:
Either will display messages like these:
Beginning of claim number 2003051520001
Beginning of claim number 2003051520002
If variable S2300CLM01ClaimNum has no value, the message will display as one of these (depending
on whether it is empty due to a CLEAR or an empty element):
Beginning of claim number S2300CLM01ClaimNum
Beginning of claim number
Business Rules
Appendix B: Validator Error Messages  252
Using your own Error Messages
To use your own error messages in a rule:

Use BusinessRules.Utilities DisplayErrorByNumber ..................................................See page 161

Use Error Message Override ...........................................................................................See below
Error Message Override
At the bottom of the Condition and Rule Definition box, you can override the message that would
normally display if this rule is violated:
This is disabled for some data types.
To do this:
1. Choose any Result Type except Invoke External Routine.
2. If you selected Set Usage/Status, choose the Usage Setting. If the EDI data does not honor that
setting, the error message set up below will be displayed. When you close the business rules box, the
item’s user attribute will be D for dependent, indicating that the user attribute will be the one in the
business rule.
If you selected Select Internal Code Set, choose the set that should be used. If the value in the
EDI is not in that set, the error message set up below will be displayed. This is available for rules on
elements.
If you selected Select Application Value List, choose the value list that should be used. If the
value in the EDI is not in that list, the error message set up below will be displayed. This is available
for rules on elements.
3. Enter the number of your custom error message (32000 or higher) in the Message Number field at
the bottom.
4. To override the default severity (Error), select a severity.
5. To override the default type (type 4), select a type.
Example
This REF segment is marked as Must be Used:
If not present in the data, any TIBCO Foresight validator will issue a generic message:
Missing Segment REF (Transmission Type Identification) at 1-015, though
marked "Must Be Used"
Business Rules
Appendix B: Validator Error Messages  253
Instead, we want to display this message:
Missing REF segment at 1-015. Transaction set rejected.
To do this:
1. Add a business rule like this one to the REF segment:
If this is not true
in the data …
… display this
message
2. Put this message in CustomerFSBRERRS.TXT:
32003
Missing REF segment at 1-015. Transaction set rejected.
3. When validating with this guideline, your message will now look like this:
Business Rules
Appendix B: Validator Error Messages  254
Troubleshooting Custom Error Messages

If your error message displays as a blank line in Validator, check your customer errors file to be
sure you've separated the number and text with a Tab.

If the error message does not display at all, check its format in your customer errors file and
ensure that no special characters are included in the message text.

Be sure that you have closed all error messages files before validating a file.

Be sure $dir.ini points to the file and the line is not commented out:
[ErrMsgFile]
ERRMSGFILE1 = "@\bin\FSANERRS.TXT"
ERRMSGFILE2 = "@\bin\FSBRERRS.TXT"
ERRMSGFILE3 = "@\bin\CustomerFSBRERRS.TXT"

EDISIM Validator has a debug mode on the Options menu. Turn it on before validating:
Business Rules
Appendix B: Validator Error Messages  255
Appendix C: Code Tables
Instream and Desktop
Setting up your own Code Tables
To set up your own external code tables:
1. Create a text file containing your external code tables, as shown in Example A below.
You can copy SampleUserTable.txt to a new name and use it. Do not simply edit
SampleUserTable.txt itself, since this is overwritten with each update.
Codes should be unique within a table.
2. Go to Instream’s or Desktop’s Bin directory and edit $Dir.ini (Windows) or fsdir.ini (UNIX)
with a text editor such as Notepad.
Find the [UserTables] section and be sure that the UserTable line is not preceded by a colon
(which would comment out the line).
Change the path and filename to point to the location of the text file containing your external
code tables. Example:
[UserTables]
UserTable="C:\Foresight\Desktop\Bin\OurUserTable.TXT"
You can use these code tables with the FindUserCode function (see page 63) and
FindUserCodeWithDate function (see page 63).
It’s important to know that the validation supports only one entry per key within external tables.
If multiple entries for the same key are encountered in an external table, subsequent entries
overwrite the previous entries, causing unexpected errors.
Business Rules
Appendix C: Code Tables  256
Example A: External Code Table File
Example contents of file
File Format
A code table starts with ^tablename, where:
^
A caret.
tablename
Table's name, with no spaces or special characters. Suggestion:
HIPAA users can start your table names with USER to avoid using
the same name as a HIPAA table.
Code lines have this format: code|startdate|enddate|code descriptio n , where:
code
The actual code.
startdate
(optional) Date the code becomes effective. Use yyyymmdd format.
enddate
(optional) Date the code is no longer effective. Use yyyymmdd
format.
code descriptio n
The code's description.
|
All three vertical lines must be included, even if the code is always
effective and therefore has no start date and end date.
Business Rules
Appendix C: Code Tables  257
Extending existing HIPAA Code Tables
You can add to, modify, or delete codes in TIBCO Foresight-supplied HIPAA code tables, thus
allowing these codes. For details, see Extending Code Tables.pdf.
Business Rules
Appendix C: Code Tables  258
Appendix D: Complicated Rules
You may find situations in which you can either combine many tests and actions into one rule,
or you can make separate rules for each one.
Simple Rules
The typical format for a simple rule is:
Test ( action if true )
The following example is a simple rule. It has one test and one action if the test condition
evaluates to true.
What it does: This CompareString function checks to see if the value in variable
PER03Submitter contains the literal value TE. If so, it executes the action within the
parentheses: take the first character in the current element's value and stores it in a variable
TEFirstDigit.
You can add another simple rule to the same location. It might test the result of the rule above
and take another action if the test condition evaluates to true. The next example does this.
Business Rules
Appendix D: Complicated Rules  259
What it does: The CompareString function checks the contents of variable TEFirstDigit (just
created by the rule above) to see if it contains a 1. If so, it executes the action within the
parentheses. (The action issues error message 32211.)
Complex Rules
A typical format for a complex rule is:
test1 (test2 ( actio n if test1 AND test2 is true ))
The following example is a complex rule. It has a test plus an action if the test condition
evaluates to true. Within that action is another test with action to be performed if it is true.
Example 1: Two Conditions create an Error Message
This rule issues an error message if the NM108 is PI and the NM109 does not equal AB123.
1. Use SetVar to assign a variable to the NM108 and call it 2010BCNM108PayName. For
details about using SetVar, see page 237.
Business Rules
Appendix D: Complicated Rules  260
2. Create this rule on the NM109.
Parameter Text
Explanation
BusinessRules.Variable
CompareString
Call the CompareString function to see if the current
element contains a value of PI.
2010BCNM108PayName EQ "PI"
If true, continue by performing the action inside the
parentheses.
(BusinessRules.Variable
CompareString Current_Element NE
"AB123" (BusinessRules.Utilities
DisplayErrorByNumber 32212))
Call the CompareString function to see if the current
element does not contain AB123.
(BusinessRules.Utilities
DisplayErrorByNumber 32212))
Call the DisplayErrorByNumber function, to display
the text of error 32212.
Business Rules
If true, continue by performing the action inside the
inner parentheses.
Appendix D: Complicated Rules  261
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:
4. 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 good example of rule usage in loops, see Balance on page 202.
Business Rules
Appendix D: Complicated Rules  262
Example 3: Adding and Comparing Numeric Values
In the 835 Health Care Payment Advice, the CLP03 is the amount submitted for a claim, and
the CLP04 is the amount paid. If they are different, the differences must be specified in the
CAS. The amounts in the CAS03, 06, 09, 12, 15, and 18 must equal the difference between the
CLP03 and CLP04.
In other words:
CLP03 - CLP04 = (CAS03+CAS06+CAS09+CAS012+CAS015+CAS018)
A strategy:
1. Initialize CASTOT, CLP03, and CLP04 variables by setting them equal to 0 on the CLP
segment, which is mandatory:
2. On the CLP03, put its value into variable CLP03:
3. Add up amounts in CAS03, 06, 09, 12, 15, and 18 by putting this AddVar on each one:
Business Rules
Appendix D: Complicated Rules  263
4. On the CLP04, put its value into variable CLP04:
5. On the Patient Name NM1 (the next mandatory segment), see if
CLP03 - CLP04 = CASTOT; if not, display an error message:
Business Rules
Appendix D: Complicated Rules  264
Appendix E: ODBC Examples
Instream and Desktop
ODBC Tutorials and Demos
Please see page 106 for the format of each ODBC business rule.
This section includes two tutorials:

A simple example that looks up the provider ID in an Access database and issues a message
if it is not found. See ODBC Example 1 below.

An extensive example starts on page 272.
Desktop and HIPAA Instream ship with ODBC demos:
Desktop
Validate 837I-Demo3DB.txt or 837I_4010_H_Demo3DB.txt with guideline
ODBCEX1 and then ODBCEX2.
Instream
Go to Instream’s DemoData\ODBC directory and see the directions in
_readme_ODBC.txt.
Business Rules
Appendix E: ODBC Examples  265
ODBC Example 1
This example uses a sample Access database called FSDemo.mdb that has been installed in
Desktop’s DemoData directory and Instream’s DemoData\ODBC directory.
You will use EDISIM to create rules on an 837I Addenda that take the provider ID from the
EDI being validated and look it up in the database. If it is not in the database, your rule will
display an error message.
Database
FSDemo.mdb
DSN
FSODBCdemo
Database name in rules
MYFSdemo
Guideline containing rules
ODBCEX1
EDI file
837I_4010_H_ErrorEvenClms.txt
Setting up a system DSN
These directions can be used for Desktop or Instream.
On the PC where you will run Desktop or Instream, set up a system-wide Data Set Name
(DSN) called FSODBCdemo for the sample database:
1
Under Control Panel, choose Administrative Tools | Data Sources (ODBC).
2. Choose the System DSN tab and see if you have a listing for FSODBCdemo.
If so, your DSN is already set up and you can skip to Looking at the Database on page 267.
3. If it is not there, choose Add | Microsoft Access Driver (*.mdb) | Finish.
Business Rules
Appendix E: ODBC Examples  266
4. Fill out the fields as follows, and then click Select.
5. Navigate to Desktop’s DemoData directory or Instream’s DemoData\ODBC directory and
choose FSDemo.mdb. Click OK until you have closed out of all Control Panel dialog boxes.
(These files are exactly the same for Desktop and Instream; if you are using the demos for
both products, choose either one.)
The DSN name FSODBCdemo is like a nickname for the database file. If you move the
database, you need only change the path under Control Panel | Administrative Tools | Data
Sources (ODBC). No business rules will have to be changed.
It is possible to hard-code the database path in your business rules, but setting up a system DSN
as shown above is preferable. It enables you to move the database, and store the database in
different places on different validation machines, without editing business rules.
Looking at the Database
1. Open the Access database FSDemo.mdb in the Desktop’s DemoData directory or Instream’s
DemoData\ODBC directory. Look at the Master table.
This exercise checks the provider ID in an EDI file to see if it appears in column 2 of this
database. If not, an error message appears.
2. Close the database.
Business Rules
Appendix E: ODBC Examples  267
Setting up the Error Message
1
Back up your current CustomerFSBRERRS.TXT and $dir.ini files in Desktop’s or
Instream’s Bin directory.
2. Check $dir.ini to see that
ERRMSGFILE3 ="@\bin\CustomerFSBRERRS.TXT"
and that the line is not preceded with a colon (which would comment it out).
3. Edit CustomerFSBRERRS.TXT and add this error message all on one line (use a Tab after
the number):
35000 Database Lookup Error: The Pay-To Provider ID is not found in the
Master Table in FSDemo.MDB.
4. Save and close the file.
We will create a rule that uses this error message.
Business Rules
Appendix E: ODBC Examples  268
Creating the Rules
Note
To import a guideline that already has these rules created, open Standards Editor and choose
File | Import | Import Single SEF and open. Go to EDISIM’s AddlStds directory and
select ODBCEX1.sef.
Create rules that check the provider ID and issue a message if it is not found in FSDemo.mdb.
1
In Standards Editor, create a new guideline based on 837AQ320 and save it as ODBCEX1.
2. On the ST segment, create a business rule that opens FSDemo.mdb by using its DSN name
FSODBCdemo.
This rule names the database MYFSdemo and that is a name you will use for it in any rules
throughout the guideline.
3. The next rule compares the EDI data in 2010AA NM1-09:
NM1*85*2*JONES*****24*432021111~
… to the second column in the database’s Master table.
To set up this checking, see if the EDI value in 2010AA NM1-09 is in column 2 of the
database by adding this rule to 2010AA NM1-09:
Note the double quotes around the Select statement and the single quotes around
%Current_Element%.
This says to look in MYFSdemo, check the Master table, and find records where the EDI
value of the current element matches some value in the ID column of the database. Put the
number of matched database records in the variable FSDemoReturnCode.
4. The next rule, on the same element, issues message 35000 if the number of records matched
equals zero.
Business Rules
Appendix E: ODBC Examples  269
5. Finally, go to the SE segment and close the database:
6. Save the guideline.
Business Rules
Appendix E: ODBC Examples  270
Testing the Rules
Desktop
1
Find EDISIM’s User Files\Public Guidelines\ODBCEX1.std and copy it to Desktop’s
Database directory for testing.
2. From within Desktop, open 837I_4010_H_ErrorEvenClms.txt or Tutorial837IA.txt in
Desktop’s DemoData directory.
3. Choose ODBCEX1 for the guideline. After validation, look for the error message “Database
Lookup Error: T he Pay -T o Provider ID is no t found in the Master Table in
FSDemo.MDB.” This is our rule in action.
Instream
1
Find EDISIM’s User Files\Public Guidelines\ODBCEX1.STD and copy it to Instream’s
Database directory for testing.
2. Go to Instream’s DemoData\ODBC directory and check the paths in ODBC_EX1.bat. Save
and close the file.
3. Execute ODBC_EX1.bat.
4. After validation, look in Instream’s Output directory for results file
837I_4010_H_ErrorEvenClms_Results.txt. Search for “Database Lookup Error.” This is
our rule in action.
Business Rules
Appendix E: ODBC Examples  271
ODBC Example 2
In this example, the Bill-To and Pay-To provider numbers will be validated against the same
Access database table that was used in Example 1. Providers are first checked to see if they are
in the database table, and an error is displayed if they are not. The rules then check a ‘Status
Flag’ returned from the database to see if they are inactive. An error message is displayed if the
provider is inactive.
We assume FSDemo.mdb has a DSN name of FSODBCdemo. If not, please follow the steps
on page 266.
Database.......................................................................................................FSDemo.mdb
DSN ..............................................................................................................FSODBCdemo
Database name in rules ..............................................................................MYFSdemo
Return code variable ..................................................................................DBResultVar
Guideline containing rules ........................................................................ODBCEX2
The rules have already been placed in the guideline ODBCEX2, which is in Desktop’s Database
directory and Instream’s DemoData\ODBC directory.
Business Rules
Appendix E: ODBC Examples  272
Running the Demo in Desktop
1. Set up the custom error messages:
a. Back up CustomerFSBRERRS.TXT file in Desktop’s Bin directory.
b. Open Add-to-CustomerFSBRERRS.TXT in Desktop’s DemoData directory and copy
the contents to the end of your CustomerFSBRERRS.TXT.
c. Close both TXT files.
2. Validate data using the guideline:
a. Open Desktop.
b. Open 837I-Demo3DB.txt or 837I_4010_H_Demo3DB.txt in Desktop’s DemoData
directory.
c. Use guideline ODBCEX2.
d. Check Use for all occurrences of 004010X096A1.
3. When complete, view the ODBC messages by looking for messages that start with ‘ODBC
Message:’
This demo data file contains four claims:

The first provider’s number is OK.

The second provider is on file but not active.

The remaining two providers are not on file.
Running the Demo in Instream
Go to Instream’s DemoData\ODBC directory and follow the directions in
_readme_ODBC.txt.
Business Rules
Appendix E: ODBC Examples  273
The Rules that made it Happen
How did we accomplish this? Go to Standards Editor to see.
1. In Standards Editor, choose File | Import | Import Single SEF and open and import
ODBCEX2 from Desktop’s DemoData directory.
2. Look at the business rules described below.
ST segment
This business rule on the ST segment opens the database and nicknames it MYFSdemo within
the guideline.
To see it, right-click on the ST segment, chose Business Rules, click on the rule, and choose
Edit.
Where:
MYFSdemo
The name to be used for this database connection in subsequent
ODBC Business Rules in this guideline.
DBResultVar
A variable name to hold a return code. If this return code is not
zero, then an error occurred. See page 135.
FSODBCdemo
The DSN name for database FSDemo.mdb. This name was
previously assigned through control panel (see page 266).
Business Rules
Appendix E: ODBC Examples  274
2010AA NM1-08 Element
This business rule on the Billing Provider Name’s identification code qualifier stores the
contents of this element into variable BillProvIDQual:
2010AA NM1-09 Element
Rule #1
This business rule on the Billing Provider Name’s identification code stores the contents of this
element into variable BillProvID:
Rule #2
This rule executes a SELECT statement against the MYFSdemo database.
Before executing the statement, Desktop replaces the placeholders:
%BillProvIDQual%
with the contents of the BillProvIDQual variable (see the rule on the
NM1-08)
%Current_Element% with the contents of the current element (the provider’s ID).
Where:
Name and Status
Field names on the Master table from the
FSDemo.mdb file.
DBResultVar
Variable to contain the number of records that matched during the
SELECT. If this returns a negative number, it is an error code (see
page 138).
BillProvDBName=1
Assigns whatever is in Field #1 of the first record selected to
variable BillProvDBName. Field #1 in this SELECT example is the
Name field (SELECT Name, Status).
Business Rules
Appendix E: ODBC Examples  275
BillProvDBStatus=2
Assigns the contents of Field #2 (SELECT Name, Status) from the
first record selected to variable BillProvDBStatus.
If no records are found, then the two assignment variables are cleared.
Rule #3
This rule compares the contents of variable DBResultVar with the string ‘0’ (zero).
If equal, no records matched the ID and Qualifier of the provider, and error message 32501 is
displayed.
Where:
DBResultVar
Variable containing the number of records selected by DBQuery in
the previous rule.
32501
Error message in CustomerFSBRErrs.txt.
Rule #4
This rule compares the contents of variable BillProvDBStatus with the letter ‘I’. If equal, it
means that the first matching Provider record had a status of Inactive, and error message 32502
is displayed.
Where:
BillProvDBStatus
Variable containing the first selected record’s Status field from the
DBQuery in the Rule 2 above.
32502
Error message telling the user that the Provider is Inactive (from
CustomerFSBRErrs).
Business Rules
Appendix E: ODBC Examples  276
Rule #5
This rule compares the contents of variable with the letter ‘A’. If equal, the first matching
Provider record had a status of Active, and message 32503 is displayed.
Where:
BillProvDBStatus
The variable containing the first selected record’s Status field from
the DBQuery in the Rule 2 above.
32503
“Error” message telling the user that the Provider is OK (from
CustomerFSBRErrs).
SE Segment
This rule closes the database.
2010AB NM1 Rules
The guideline has another series of the same rules on the Pay-To Provider. The rules are the
same but the variable names are different. The data files 837I-Demo3DB.txt and
837I_4010_H_Demo3DB.txt do not have a Pay-to Provider, so no messages were generated by
Desktop.
Business Rules
Appendix E: ODBC Examples  277
Appendix F: Guideline Merge
(Windows Only) Instream, Desktop, and EDISIM
Overview
Guideline Merge lets you merge the changes that you have made to your guideline in EDISIM
Standards editor with:

TIBCO Foresight-supplied guidelines containing the full set of HIPAA rules

Another EDI or flat file guideline with the same structure.
This lets you have a “master” guideline and then separate guidelines with additional rules for
specific partners.
Please see GuideMerge.pdf for details.
Business Rules
Appendix F: Guideline Merge  278
Appendix G: Debug
EDISIM Validator Debug
Enable Options | Business Rule Script Debug Messages before validating.
This menu choice is a toggle. Your current setting will stick until you change it.
After validating, green debug messages show the steps Validator takes to enforce your business
rules.
To prevent some business rules from displaying debug messages, use a text editor to edit
BusinessRules.properties in EDISIM’s Bin directory. Set rules to 0 if you don’t want them to
show debug messages:
Desktop and Instream Debug
Important
Setting up debug reduces performance, even if the error messages are not being
displayed or output.
During validation, you can display debug messages like these:
To use debug:
1. Be sure that the file BusinessRule.properties is in the Bin directory. If not, contact TIBCO
Foresight Technical Support.
2. To see the debug messages:
In Desktop, choose Options | Validator Profile | Filter and select the checkbox for “User
#1” types.
In Instream (Windows only), go to the \Bin directory and open $fsdeflt.apf or the other APF
file that you are using. Change WT_User1=0 to WT_User1=1.
Business Rules
Appendix G: Debug  279
3. Validate a file and note the extra debugging messages.
4. To stop displaying the debug messages:
In Validator Desktop, clear the checkbox for “User #1” types.
In Validator Instream, open $fsdeflt.apf and change WT_User1=1 to WT_User1=0.
You can use DumpVars to display variables and their contents at a particular location. See
Divide on page 200 for details.
Business Rules
Appendix G: Debug  280
Appendix H: Troubleshooting
Checklist
If your rule does not fire at all:

Be sure the data should have triggered the rule.

Be sure you saved your guideline.

Close and re-open Validator.

Be sure that the rule is in the proper location.

Check spelling and capitalization of variables and other parts of business rules.

Be sure that literals are surrounded by quotes and variables aren’t.

Check parentheses.

Ensure that a space appears before and after each operator.

See if you need to clear a list or a variable in a repeating loop.

Turn on debug in Validator (Options | Business Rules Script Debug Messages) and
revalidate the file.

In Standards Editor, use Print | Print Rules | by Variable.

Add DumpVars rules.

Which validator are you using: EDISIM Validator, Desktop, Instream, or Analyzer? If you
have Desktop installed, the icon appears on the Standards Editor toolbar.
If the rule fires but you get a blank line:

Close your error messages file.

Check your customer errors file to see if one and only one rule with that number is there.

Be sure there is a tab between the number and the text.

Be sure you saved and closed the message file.

Check the path to the customer errors file in $dir.ini.

Which validator are you using: EDISIM Validator, Desktop, Instream, or Analyzer? If you
have Desktop installed, the icon appears on the Standards Editor toolbar.
Business Rules
Appendix H: Troubleshooting Checklist  281
Other things to check:

If you are validating with Instream or Desktop, be sure that the guideline and customer
errors file has been copied to its Database directory and its $Dir.ini updated accordingly.

Be sure that the business rule is added to all locations where it is needed. For instance, 837s
have claim loops at the subscriber and patient level. Be sure your rules are in both claim
loops.

When running rules in Analyzer, be sure that the business rules that you use are supported
by Analyzer.

See if you need to clear a list or a variable in a repeating loop. See page 239.
Business Rules
Appendix H: Troubleshooting Checklist  282
Appendix I: Processing Order
Demo
Please copy 837P_5010_ProcessingOrder.std from EDISIM’s Samples
directory or Instream’s DemoData directory to EDISIM’s User Files\Public
Guidelines directory and validate a 5010 837P.
1. As validation processes each segment:
It executes the business rules that are directly attached to it, in top-down order if there are
multiple rules.
It then executes the SetSegmentPreExits for that segment in bottom-up order.
2. It then looks at each element in the segment.
It executes any business rules directly attached to the first element in the segment, in topdown order if there are multiple rules.
It then executes SetElementPostExit rules for the first element in bottom-up order.
Likewise, it continues to the next element in the segment.
3. If the segment is the last one in a loop, the validator then processes any
SetLoopPostInstanceExit rules for that loop in bottom-up order.
At the end of all iterations of the loop, it processes the SetLoopPostExit rules for that loop in
bottom-up order.
4. For nested loops that end on the same segment (like 837 2300 and 2400 loops), the inner loop
is processed first.
The bottom-up rules include:
SetCompositePreExit
SetElementPostExit
SetLoopPostExit
SetLoopPostInstance Exit
SetSegmentPreExit
The BusinessRules.Exits KeepOrder rule causes them to execute in top-down order. See
KeepOrder on page 94 for details.
Please see KeepOrder on page 94 for a way to force top-down processing of loop Exit rules.
Business Rules
Appendix I: Processing Order  283
Rearranging Business Rules
You can use the Move Up and Move Down buttons in the business rules box to rearrange rules
so that they process in a different order:
Example 1. Processing Order of Rules
Business Rules
Appendix I: Processing Order  284
Assume these rules
ISA
rule 1
ISA05
rule 2
rule 3
ST
rule 4
rule 5
Exit instance for 2310A, rule 6
Exit instance for 2310A, rule 7
rule 8
Exit instance for 2310B, rule 9
Exit instance for 2310C, rule 10
BHT
rule 11
BHT01
rule 12
rule 13
SE
rule 14
Execution order
rule 1
rule 2
rule 3
rule 4
rule 5
rule 8
rule 11
rule 12
rule 13
rule 7
rule 6
rule 9
rule 10
rule 14
In this case, the two business rules (6 and 7) written for Loop 2310A will process from bottom
up.
Example 2. Two loops ending on same segment
Loop 2300 and its nested 2400 loop end on the same segment.
Business Rules
Appendix I: Processing Order  285
When two loops end on the same segment, the rules at the end of the loop execute in this order:
1. Rules placed directly on the segment.
2. Rules placed directly on the elements in the segment.
3. Exit rules for the inner loop (2400), in reverse order if there are more than one.
4. Exit rules for the outer loop (2300), in reverse order if there are more than one.
Assume these rules:
Execution order
ST
rule 1
rule 1
rule 2
rule 2
Exit instance for 2300, rule 3
rule 7
Exit instance for 2300, rule 4
rule 8
Exit instance for 2400, rule 5
rule 9
Exit instance for 2400, rule 6
rule 10
rule 7
rule 6
BHT
rule 8
rule 5
CAS
rule 9
rule 4
CAS19
rule 10
rule 3
SE
rule 11
rule 11
* Since the 2400 loop is inside the 2300 loop, it will execute before rules on the 2300.
Business Rules
Appendix I: Processing Order  286
Appendix J: LookAhead and
Array Extended Example
Array, Lookahead, and Web Services Demos
This demo is for experienced business rule developers.
This example is based on a 4010 837P guideline called WEBSRV1_837P (in Instream’s and
Desktop’s DemoData directories).
To see rules that are already in this guideline:

Import this file into EDISIM Standards Editor and look at the rules.

Copy the guideline to Desktop’s Database folder and then validate a 4010 837P with debug
turned on.
In this example, we simulate seeing if the subscribers and dependents were enrolled on the dates
provided in the data, and display messages if not. The tricky part is knowing the dates, which are
far down in the data, when you are validating the identification codes near the top of the data.
To do this, we capture names, ID’s and dates in an array on a first pass through the data. We
then send our demo array to a web service to check our “database” and send back an array that
tells us if they were covered on the dates provided.
We then use additional business rules to check the returned array and display error messages if
necessary.
Lookahead ranges are:


2000A (range ends at 2000B Lookahead start)
2000B through end of loop
Please see these pages for additional information:
Current_LoopCount....................................................................page 26
Current_LoopKey........................................................................page 26
Array Business Rules ...................................................................page 33
Lookahead .....................................................................................page 118
Business Rules
Appendix J: LookAhead and Array Extended Example  287
Summary of Rules – Top-Down
This set of rules is an example only. It will not actually run at your site since your web services will have
different names and perform different functions. These are the rules in the order in which they appear in
the sample guideline WEBSRV1_837P (in the DemoData directory).
The next section (page 292) shows the same rules in the order in which they will execute, along with
annotation.
Segment
Rules
ST
(Table 1 Transaction Set Header)
BusinessRules. Array. CreateArray: WSin
BusinessRules. Exits. SetLoopPostInstanceExit: 2000B BusinessRules.Lookahead ExitLookahead
BusinessRules. Exits. SetLoopPostInstanceExit: 2000B BusinessRules.Lookahead InvokeWebService
WEBSRV1 WSin "WSout" (BusinessRules.Utilities DisplayErrorByNumber 29001)
BusinessRules. Array. CreateArray: WSout
---------------------------------------- Start of first Lookahead range ----------------------------------------
HL
(2000A Billing/Pay-to Provider Hierarchical Level)
BusinessRules. Lookahead. ClearArray: WSin
BusinessRules. Lookahead. ClearArray: WSout
NM1
(2010AA Billing Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 0 "2"
NM109
(2010AA Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 1 Current_Element
BusinessRules. Array. CheckVarFromArray: WSout 0 4 "0" (BusinessRules.Utilities
DisplayErrorByNumber 32160)
REF02
(2010AA Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 2 Current_Element
NM1
(2010AB Pay-to Provider Name)
BusinessRules. Lookahead. RunNoData: (BusinessRules.DBServer InvokeWebService WEBSRV1 WSin
"WSout" (BusinessRules.Utilities DisplayErrorByNumber 29001))
BusinessRules. Lookahead. RunNoData: (BusinessRules.Array ExitLookahead)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 0 "2"
Business Rules
Appendix J: LookAhead and Array Extended Example  288
Segment
Rules
NM109
(2010AB Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 1 Current_Element
BusinessRules. Array. CheckVarFromArray: WSout 1 4 "0" (BusinessRules.Utilities
DisplayErrorByNumber 32161)
REF02
(2010AB Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 2 Current_Element
BusinessRules. Lookahead. InvokeWebService: WEBSRV1 WSin WSout (BusinessRules.Utilities
DisplayErrorByNumber 29001)
BusinessRules. Lookahead. ExitLookahead:
---------------------------------------- Start of second Lookahead range ----------------------------------------
HL
(2000B Subscriber Hierarchical Level)
BusinessRules. Lookahead. ClearArray: WSin
BusinessRules. Lookahead. ClearArray: WSout
NM103
(2010BA Name Last)
BusinessRules. Array. CheckVarFromArray: WSout 0 3 Current_Element (BusinessRules.Utilities
DisplayErrorByNumber 32152)
NM104
(2010BA Name First)
BusinessRules. Variable. SetVar: SubFirstName Current_Element
NM109
(2010BA Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 1 Current_Element
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 0 "1"
BusinessRules. Array. GetVarFromArray: WSout 0 1 "SubscriberID"
BusinessRules. Variable. CompareNString: SubscriberID "NE" Current_Element (1;1;3;)
(BusinessRules.Utilities DisplayErrorByNumber 32150)
BusinessRules. Variable. CompareNString: SubscriberID "NE" Current_Element (4;4;9;)
(BusinessRules.Utilities DisplayErrorByNumber 32151)
DMG02
(2010BA Date Time Period)
BusinessRules. Variable. SetVar: DMG02 Current_Element
DMG03
(2010BA Gender Code)
BusinessRules. Array. SearchVarsInArray: WSout "1" "" "" SubFirstName Current_Element DMG02
(BusinessRules.Utilities DisplayErrorByNumber 32153)
Business Rules
Appendix J: LookAhead and Array Extended Example  289
Segment
Rules
DTP03
(2300 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element "D8"
NM1
(2310B Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 0 "2"
NM109
(2310B Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 1 Current_Element
BusinessRules. Array. SearchVarsInArray: WSout "2" Current_Element "" "" "0" (BusinessRules.Utilities
DisplayErrorByNumber 32162)
REF02
(2310B Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 2 Current_Element
LX
(2400 Service Line)
BusinessRules. Lookahead. GetInfo: Current_LoopCounter 200B_2400LoopCounter
BusinessRules. Variable. GetInfo: Current_LoopCounter 200B_2400LoopCounter
DTP03
(2400 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
NM1
(2420A Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin Next_Row 0 "2"
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 1 200B_2400LoopCounter
NM109
(2420A Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 2 Current_Element
BusinessRules. Array. SearchVarsInArray: WSout "2" 200B_2400LoopCounter Current_Element "" "" "0"
(BusinessRules.Utilities DisplayErrorByNumber 32163)
REF02
(2420A Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 3 Current_Element
DTP03
(2430 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element "D8"
NM104
(2010CA Name First)
BusinessRules. Variable. SetVar: IndividualFirstName Current_Element
Business Rules
Appendix J: LookAhead and Array Extended Example  290
Segment
Rules
DMG02
(2010CA Date Time Period)
BusinessRules. Variable. SetVar: 2010CADMG02 Current_Element
DMG03
(2010CA Gender Code)
BusinessRules. Array. SearchVarsInArray: WSout "1" "" IndividualFirstName "" Current_Element
2010CADMG02 (BusinessRules.Utilities DisplayErrorByNumber 32153)
DTP03
(2300 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
NM1
(2310B Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 0 "2"
NM109
(2310B Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 1 Current_Element
BusinessRules. Array. SearchVarsInArray: WSout "2" Current_Element "" "" "0" (BusinessRules.Utilities
DisplayErrorByNumber 32162)
REF02
(2310B Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 2 Current_Element
LX
(2400 Service Line)
BusinessRules. Variable. GetInfo: Current_LoopCounter 200C_2400LoopCounter
BusinessRules. Lookahead. GetInfo: Current_LoopCounter 200C_2400LoopCounter
DTP03
(2400 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element "D8"
NM1
(2420A Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin Next_Row 0 "2"
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 1 200C_2400LoopCounter
NM109
(2420A Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 2 Current_Element
BusinessRules. Array. SearchVarsInArray: WSout "2" 200C_2400LoopCounter Current_Element “” “” “0”
(BusinessRules.Utilities DisplayErrorByNumber 32163)
REF02
(2420A Reference Number)
Business Rules
Appendix J: LookAhead and Array Extended Example  291
Segment
Rules
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 3 Current_Element
Annotated Summary of Rules in Execution Order
This set of rules is an example only. These are the same rules as in the previous section, but they are in
the order in which they will execute during validation.
Explanations are in Italic.
These rules are based on a 4010 837P called WEBSRV1_837P (in the DemoData directory).
Step
Segment Rules
------------------ Process rules before Lookahead range ------------------
ST
(Table 1 Transaction Set Header)
BusinessRules. Array. CreateArray: WSin
1
Create an array to serve as input to the web service.
BusinessRules. Array. CreateArray: WSout
2
Create an array to serve as output from the web service.
----------------------- Starting 2000A Lookahead range ----------------------Process Lookahead rules to end of range
HL
(2000A Billing/Pay-to Provider Hierarchical Level)
3
BusinessRules. Lookahead. ClearArray: WSin
4
BusinessRules. Lookahead. ClearArray: WSout
Empty both arrays.
NM1
5
(2010AA Billing Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 0 "2"
Load the literal value 2 into the first cell in array WSin (at index 0,0).
NM109
Business Rules
(2010AA Identification Code)
Appendix J: LookAhead and Array Extended Example  292
Step
Segment Rules
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 1 Current_Element
6
Load the contents of the NM109 into the second cell in the first row of WSin (index 0,1).
REF02
(2010AA Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 2 Current_Element
7
Put the value from this REF02 into WSin’s index 0,2.
NM1
8
(if no data)
(2010AB Pay-to Provider Name)
BusinessRules. Lookahead. RunNoData: (BusinessRules.DBServer InvokeWebService
WEBSRV1 WSin "WSout" (BusinessRules.Utilities DisplayErrorByNumber 29001))
Lookahead to invoke the web server WEBSRV1 if this NM1 has no data. Send it the WSin
array, receive WSout back.
9
BusinessRules. Lookahead. RunNoData: (BusinessRules.Array ExitLookahead)
(if no data)
Stop the Lookahead if this NM1 is not present in the data. This will skip Lookahead rules 8-12
below.
8
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 0 "2"
Lookahead to populate the WSin array’s 1,0 with the literal value 2.
Business Rules
Appendix J: LookAhead and Array Extended Example  293
Step
Segment Rules
NM109
(2010AB Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 1 Current_Element
9
Put the value of this NM109 in WSin 1,1.
REF02
(2010AB Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 2 Current_Element
10
Put the value of this REF02 into WSin’s 1,2:
BusinessRules. Lookahead. InvokeWebService: WEBSRV1 WSin WSout
(BusinessRules.Utilities DisplayErrorByNumber 29001)
11
Lookahead to again invoke the web server WEBSRV1. Send it the WSin array, receive WSout
back.
BusinessRules. Lookahead. ExitLookahead:
12
Stop the 2000A Lookahead.
NM109
13
(2010AA Identification Code)
BusinessRules. Array. CheckVarFromArray: WSout 0 4 "0" (BusinessRules.Utilities
DisplayErrorByNumber 32160)
We have completed the Lookahead rules for the first Lookahead range, which ends with the
start of the second Lookahead range at 2000B. We return to the top of the 2000A and start
doing its non-Lookahead rules.
Check array WSout, which has been returned from the web service. If it does not contain 0 in
index 0,4, display error 32160.
Business Rules
Appendix J: LookAhead and Array Extended Example  294
Step
Segment Rules
BusinessRules. Array. CheckVarFromArray: WSout 1 4 "0" (BusinessRules.Utilities
DisplayErrorByNumber 32161)
14
Check array WSout, which has been returned from the web service. If it does not contain 0 in
index 1,4, display error 32161.
----------------------- Starting 2000B Lookahead range ----------------------Automatically ends 2000A Lookahead range
Process Lookahead rules to end of 2000B range
HL
(2000B Subscriber Hierarchical Level)
15
BusinessRules. Lookahead. ClearArray: WSin
16
BusinessRules. Lookahead. ClearArray: WSout
Lookahead to clear both arrays at the beginning of the 2000B.
NM109
(2010BA Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 1 Current_Element
17
Put contents of this NM109 into WSin index 0,1:
BusinessRules. Lookahead. SetArrayFromVar: WSin 0 0 "1"
18
Put literal value 1 in first cell of WSin:
DTP03
19
(2300 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
"D8"
Puts the date from this DTP03 into WSin index 0,2.
Business Rules
Appendix J: LookAhead and Array Extended Example  295
Step
Segment Rules
NM1
(2310B Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 0 "2"
20
Put the literal value 2 into WSin 1,0.
NM109
(2310B Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 1 Current_Element
21
Put the value of this NM109 into WSin 1,1.
REF02
(2310B Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 2 Current_Element
22
Put the value of this REF02 into WSin 1,2.
LX
23
(2400 Service Line)
BusinessRules. Lookahead. GetInfo: Current_LoopCounter 200B_2400LoopCounter
Put the iteration of the 2400 loop into variable 200B_2400LoopCounter.
Business Rules
Appendix J: LookAhead and Array Extended Example  296
Step
Segment Rules
DTP03
(2400 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
24
Put the date from the current element into WSin 0,2 if it is earlier than the date that is currently
there.
NM1
(2420A Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin Next_Row 0 "2"
25
Put the literal value 2 into the first cell of the next row
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 1
200B_2400LoopCounter
26
Put the contents of the 2400 loop counter (see step 23) into the current row’s cell 1.
NM109
27
(2420A Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 2 Current_Element
Put the contents of this NM109 into the current row’s cell 2.
Business Rules
Appendix J: LookAhead and Array Extended Example  297
Step
Segment Rules
REF02
(2420A Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 3 Current_Element
28
Put the contents of this REF02 into the current row’s cell 3.
DTP03
(2430 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
"D8"
29
Put this date into WSin’s 0,2 if it is earlier than the current contents. Format is YYYYMMDD.
Start of Dependent 2300
DTP03
(2300 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
30
Put this date into WSin’s 0,2 if it is earlier than the current contents.
NM1
Business Rules
(2310B Rendering Provider Name)
Appendix J: LookAhead and Array Extended Example  298
Step
Segment Rules
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 0 "2"
31
Put 2 in this cell:
NM109
(2310B Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 1 Current_Element
32
Put the contents of this NM109 in this cell:
REF02
(2310B Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin 1 2 Current_Element
33
Put the contents of this REF02 in this cell:
LX
34
(2400 Service Line)
BusinessRules. Lookahead. GetInfo: Current_LoopCounter 200C_2400LoopCounter
Put the current loop count into the variable 200C_2400LoopCounter.
Business Rules
Appendix J: LookAhead and Array Extended Example  299
Step
Segment Rules
DTP03
(2400 Date Time Period)
BusinessRules. Lookahead. UpdateArrayFromDate: WSin 0 2 "LT" Current_Element
"D8"
35
Put this date in 0,2 if it is earlier than the one that is currently there.
NM1
36
(2420A Rendering Provider Name)
BusinessRules. Lookahead. SetArrayFromVar: WSin Next_Row 0 "2"
Put the literal value 2 in the next row’s first cell.
37
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 1
200C_2400LoopCounter
Put the value from the loop counter into the current row’s cell 1.
Business Rules
Appendix J: LookAhead and Array Extended Example  300
Step
Segment Rules
NM109
(2420A Identification Code)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 2 Current_Element
38
Put the value of this NM109 into the current row’s cell 2.
REF02
(2420A Reference Number)
BusinessRules. Lookahead. SetArrayFromVar: WSin Current_Row 3 Current_Element
39
Put the value of this REF02 into the current row’s cell 3.
----------------------- End of 2000B Lookahead range ----------------------Start 2000B end-of-loop Lookahead rules
ST
40
(Table 1 Transaction Set Header)
BusinessRules. Exits. SetLoopPostInstanceExit: 2000B BusinessRules.Lookahead
InvokeWebService WEBSRV1 WSin "WSout" (BusinessRules.Utilities
DisplayErrorByNumber 29001)
Send the WSin array to the WEBSRV1 web service, return information in the WSout array, and
display error 29001 if the web service is not available.
Exit rules execute in reverse order. The bottom one executes first.
41
BusinessRules. Exits. SetLoopPostInstanceExit: 2000B BusinessRules.Lookahead
ExitLookahead
End the Lookahead range after each 2000B loop.
Business Rules
Appendix J: LookAhead and Array Extended Example  301
Step
Segment Rules
----------------------- End of 2000B end-of-loop Lookahead rules ----------------------Starting 2000B non-Lookahead rules
NM103
(2010BA Name Last)
BusinessRules. Array. CheckVarFromArray: WSout 0 3 Current_Element
(BusinessRules.Utilities DisplayErrorByNumber 32152)
42
If 0,3 in the WSout array returned from the web service does not match the contents this
NM103, display error 32152.
NM104
(2010BA Name First)
BusinessRules. Variable. SetVar: SubFirstName Current_Element
43
Put the value from the current element into variable SubFirstName.
NM109
(2010BA Identification Code)
BusinessRules. Array. GetVarFromArray: WSout 0 1 "SubscriberID"
44
Put the value from the WSout array 0,1 into variable SubscriberID.
BusinessRules. Variable. CompareNString: SubscriberID "NE" Current_Element
(1;1;3;) (BusinessRules.Utilities DisplayErrorByNumber 32150)
45
If the contents of SubscriberID and the contents of this NM109 do not match, display error
32150.
BusinessRules. Variable. CompareNString: SubscriberID "NE" Current_Element
(4;4;9;) (BusinessRules.Utilities DisplayErrorByNumber 32151)
46
Compare 9 characters of SubscriberID and the value in the current element, starting at position
4 in each. If they do not match, display error 32151.
DMG02
47
(2010BA Date Time Period)
BusinessRules. Variable. SetVar: DMG02 Current_Element
Put contents of this DMG02 into variable DMG02.
Business Rules
Appendix J: LookAhead and Array Extended Example  302
Step
Segment Rules
DMG03
(2010BA Gender Code)
BusinessRules. Array. SearchVarsInArray: WSout "1" "" "" SubFirstName
Current_Element DMG02 (BusinessRules.Utilities DisplayErrorByNumber 32153)
48
Display error 32153 if array WSout does not contain a row that starts with these values:
NM109
(2310B Identification Code)
BusinessRules. Array. SearchVarsInArray: WSout "2" Current_Element "" "" "0"
(BusinessRules.Utilities DisplayErrorByNumber 32162)
49
Display error 32162 if array WSout does not contain a row that starts with these values:
LX
(2400 Service Line)
BusinessRules. Variable. GetInfo: Current_LoopCounter 200B_2400LoopCounter
50
Put the current loop count into variable 200B_2400LoopCounter.
NM109
(2420A Identification Code)
BusinessRules. Array. SearchVarsInArray: WSout "2" 200B_2400LoopCounter
Current_Element "" "" "0" (BusinessRules.Utilities DisplayErrorByNumber 32163)
51
Display error 32163 if array WSout does not contain a row that starts with these values:
NM104
(2010CA Name First)
BusinessRules. Variable. SetVar: IndividualFirstName Current_Element
52
Put the value from this NM104 into variable IndividualFirstName.
DMG02
(2010CA Date Time Period)
BusinessRules. Variable. SetVar: 2010CADMG02 Current_Element
53
Put the value in this DMG02 into variable 2010CADMG02.
DMG03
Business Rules
(2010CA Gender Code)
Appendix J: LookAhead and Array Extended Example  303
Step
Segment Rules
BusinessRules. Array. SearchVarsInArray: WSout "1" "" IndividualFirstName ""
Current_Element 2010CADMG02 (BusinessRules.Utilities DisplayErrorByNumber
32153)
54
Display error 32153 if array WSout does not contain a row that starts with these values:
NM109
(2310B Identification Code)
BusinessRules. Array. SearchVarsInArray: WSout "2" Current_Element "" "" "0"
(BusinessRules.Utilities DisplayErrorByNumber 32162)
55
Display error 32152 if array WSout does not contain a row that starts with these values:
LX
(2400 Service Line)
BusinessRules. Variable. GetInfo: Current_LoopCounter 200C_2400LoopCounter
56
Increment the loop counter.
NM109
57
(2420A Identification Code)
BusinessRules. Array. SearchVarsInArray: WSout "2" 200C_2400LoopCounter
Current_Element “” “” “0” (BusinessRules.Utilities DisplayErrorByNumber 32163)
Display error 32163 if array WSout does not contain a row that starts with these values:
Business Rules
Appendix J: LookAhead and Array Extended Example  304
Appendix K: Building Business
Rules
Overview
EDISIM Standards Editor provides two methods of entering text when building a business rule.
 Text Entry - in which rule text can be entered manually. Optionally, help text can be provided,
displaying the expected format of the selected rule.
 Prompted Entry - which provides a “fill-in-the-blank” style rule builder. This format also allows
the use of the Rule Selector to embed other rules within the rule being built.
Text Button
For new rules, the text entry method with help is displayed by default.
The Text button allows you to toggle between text entry and prompted entry methods.
Business Rules
Appendix K: Building Business Rules  305
Entry Examples
This section illustrates the various rule entry methods, each building the same business rule.
Our business rule checks the total number in a variable called “PLBAdjustmentAmt ”. IF the
number exceeds 10000, THEN error message 32214 displays.
Text Entry
Text Entry allows you to enter text with no prompting or reference cues for the format of the
rule. This method of rule entry is for experienced users who know the rule formats.
Text Entry with Help
Text Entry with help is the same as Text Entry but adds reference cues for the proper
formatting of the rule. Select each cue and overwrite with the desired parameter. This method
of entry is useful for intermediate-level users, who are familiar with rule building but haven’t
memorized the required parameters.
In this case:
<arrayName> is replaced with "Array1Back"
<rowIndex> is replaced with “0”
<columnIndex> is replaced with “5”
<resultVar> is replaced with “0”
Business Rules
Appendix K: Building Business Rules  306
Grid Entry Method
The grid allows you to build a rule in a fill-in-the-blank manner. The structure of the rule is
transferred to the input area and you are prompted to enter the parameters the rule requires to
run. Parameter notes are provided for reference. This format also allows the use of the Rule
Selector to embed other rules within the one being built.
This method is the default for rules selected from the Rule Selector Dialog and from the
common rules listed on the Select Rule drop box and is useful for all users, especially those
learning rule building.
Example: Prompted Entry Method
To enter a business rule using the prompted entry method:
1. Access the Condition and Rule Definition dialog.
2. Select the desired rule from the drop box. In this example, we will choose CompareNumeric.
If a grid doesn’t appear, click Text:
Parameter fields appear for the selected rule:
Business Rules
Appendix K: Building Business Rules  307
3. Click in the Parameter Value area for the first parameter. This causes the Parameter Notes
area on the right side to show helpful information:
4. Enter values for all parameters.
5. If the rule is an “If” test, requiring a sub-rule, use the small fx button on the right side of the
ThenRule entry box to access the Select Rule dialog.
In the Select Rule Dialog, click the rule you want to run when the “if” conditions are met for
our rule followed by Select. In our example, we Click *All:
… and then choose DisplayErrorByNumber:
Business Rules
Appendix K: Building Business Rules  308
6. This information is transferred to our rule and causes additional parameters to be displayed:
Finish filling out parameters.
7. We want this to be a Lookahead rule, so we check the box at the top:
Business Rules
Appendix K: Building Business Rules  309
8. Save the rule and look at the complete rule in the outer Business Rules box:
Business Rules
Appendix K: Building Business Rules  310
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising