xLAB Interpretive Comments
xLab provides an extensive feature rich Script language designed to enable the user to create Interpretive Comments for virtually any logic and equation required. The ultimate goal of the Interpretive Comment it to output a User Defined comment(s) for a Result when specific conditions are met.
A given result can have one or more Interpretive Comment rules. Each "Rule" is evaluated separatly and, if the Conditional evaluates to 'True' the Action is output. This continues for each Rule for the particular result.
The Interpretive Comment Script consists of three parts,
Conditional,
Then,
Action:
- The Conditional - A Conditional statement that ultimately returns a 'True' or 'False'.
- The Then operator - The Key Word 'Then' which separates the Condition from the Action
- Action - in the case of Interpretive comments the actual comment line(s) you wish output if the Condition is true.
Conditional:
The conditional consists of either a Conditional if statement that reslolves to either a 'true' or 'false' or simply the Key Word 'true' sorrounded by single quotes. If the contitional is simply the word 'true' then the conditionaly always evaluates to 'true'
Then:
This is simply a Key Word separator used by xLab to separate the Conditional from the Action. It is always the work Then without quotes
Action:
The action is the actual comment you wish to output if the conditional evaluates to True. This may be any number of lines.
Examples:
Let's do a few examples to tie this all together;
Example 1 Associated with the calculated result Cardiac:

We start by entering the Result we wish to apply the Rules to (using the F3 look up) , int this case CRA, then selecting "Create New Rule"

Then we simply enter the
- Condition - In this case the Key Word 'True'
- Then - the Key Word Then
- The text we want output
Note that everything after the Then Key Word is treated as Text including spaces.
Prior to Clicking "Save Rule" we need to Validate the Rule by clicking on "Validate". We will see exactly what will be output on the Report.

Then we Click on "Save Rule"
Condition is always 'True' so the comment will aways be output when the patient as a Cardiac result.
Example 2 Associated with the Cocaine result
If we wish a comment to be output only when a specific condition exists, we would use the same approach but in place of the Key Word 'True' place a real conditional statement .
if(Result('Cocaine') == 'Positive', 'True', 'False')
Then
All Drugs of Abuse must be confirmed by an Confirmatory Lab.
Sample has been sent to xyz Lab for Confirmation, Report to follow
If the result of the Cocaine testing was Positive then output the comment
The xLab Scripting language is comprised of 'Functions', 'Operators', 'Keywords' and 'Conditionals'.. The tables below summarizes all of these items
Functions:
| Function | Description |
|---|---|
| Result('Code') | Returns the result value of the specified result 'Code' |
| Rflag('Code') | Returns the result reference range flag for the specified result 'Code' |
| Dflag('Code') | Returns the Delta Flaf for the specified Result 'Code' |
| DOB() | Returns Patient's Date Of Birth |
| Age('Units') | Returns the patient's age in the specified units ('H' = Hours, 'D' = days, 'M' = months, 'Y' = years) |
| Sex() | Returns the patient's sex (M,F,U) |
| Height('Units') | Returns the patients height in the specified units ('IN' inches, 'CM' centimeters) |
| Weight('Units') | Returns the patients weight in the specified units ('LBS' = pounds, 'KG' - Kilograms) |
| OrdDoc() | Returns the Sample Ordering Doctor Code |
| OrdLoc() | Returns the Sample Ordering Location Code |
| Fasting() | returns True if patient is fasting, else False |
| Sqrt(value) | Returns the Square Root of the value |
| Log10(value) | Returns the base 10 log of the value |
| Exp(value) | Returns e raised to the power of value |
| Log(value,base) | Returns the log of value in the specified base |
| Pow(value,power) | Returns value raised to power |
| Round(value,digits) | Rounds value to digits |
Operators:
| Operator | Meaning |
|---|---|
| =, == | Equals |
| !=, <> | Not Equal |
| < | Less Than |
| > | Greater Than |
| <= | Less than or Equal |
| >= | Greater Than or Equal |
| &&, and | And |
| ||, or | OR |
| ( | Left hand Parenthesizes (in the algebraic sense) |
| ) | Right Hand Parenthesis (in the algebraic sense) |
Arithmetic Operators listed in order of precedence:
| Operator | Description |
|---|---|
| () | Grouping operator |
| !, not | Logical negation |
| *,/ | Multiplicative operators |
| +,- | Additive operators |
| <,>,<=, >= | Relational operators |
| =,==,!=,<> | Equality operators |
| &&, and | Logical AND |
| ||,or | Logical OR |
Keywords: There are several Keywords used by the script language to help make writing the script easier;
| Keyword | Description |
|---|---|
| JRSF | Right Justify, space fill |
| JRZF | Right Justify zero fill |
| JR | Right Justify |
| LBS | Pounds |
| KG | Kilograms |
| IN | Inches |
| CM | Centimeters |
Conditional:
For Interpretive Comments, the basic format of the if statement is:
if (Condition, TrueValue, FalseValue)
The Condition is evaluated and if 'True' then the TrueValue is returned, if 'False' the FalseValue is returned. The power and complexity comes from what a Condition can be and what the TrueValue and FalseValue can be.
Condition: Any expression that evaluates to a True or False. Some examples of Conditions:
Result('CREAT') > 5 - Evaluates to True if the CREAT result is Greater Than 5
Result('CREAT") > 5 && Result('BUN') <= 15 - Evaluate to True if the CREAT result is Greater than 5 AND the BUN result is less than or equal to 15
Result('CREAT') > 5 || Result('BUN') != 15 - Evaluates to True if the CREAT result is Greater than 5 OR the BUN result is not equal to 15
TrueValue: This may be another Conditional or the word 'True' in single quotes. Nested Conditional's must ultimately resolved to a 'True' or 'False'. The following example is valid:
if( Sex()=='M', if( Age() > 10,'True','False'),if(Age() > 5,'True','False') )
If the patient's sex is Male the see if the patient age is greater than 10 and if so, return 'true', if not Return 'False'.
If the patient's sex is not Male then see if the patient age is greater than 5, if so return 'True', if not Return 'False'
AP-Visions is a leading provider of IT healthcare solutions to seamlessly manage, move, store, and report all your electronic laboratory data.