xLab provides an extensive feature rich Calculated Results language designed to enable the user to create a Calculated Result for virtually any logic and equation required. The ultimate goal of a Calculated Result is to produce a Value that is the "result"
For example; Bun Creat Ration is simply BUN divided by Creatine. The Value of the Bun result is divided by the the value of the Creatine result and the resulting value is the Bun Creatine Ratio result. Expressed in xLab script the expression is simply:
Result('BUN') / Result('CREAT')
I.E. The "result of bun" divided by the "result of creatine".
In xLab, like in regular math, an order of precedence
The xLab Scripting language is comprised of 'Functions', 'Operators', 'Keywords' and 'Conditionals'.. The tables below summarizes all of these items
| Function | Description |
|---|---|
| Result('Code') | Returns the result value of the specified result 'Code' |
| Rflag('Code') | Returns the result flag for the specified result 'Code' |
| 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 |
| Operator | Meaning |
|---|---|
| =, == | Equals |
| !=, <> | Not Equal |
| < | Less Than |
| > | Greater Than |
| <= | Less than or Equal |
| >= | Greater Than or Equal |
| &&, and | And |
| ||, or | OR |
| ( | Left hand Parenthesize (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 |
Perhaps the most powerful (and most difficult to understand) is the xLab Conditional statement. The basic format of this 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, FalseValue: The values returns when the condition evaluates to True (TrueValue) or False (FalseValue). Either can be any valid expression for example:
28.8 - a number
Result('CREAT') - the creatine result
Result('CREAT') * 2.255 - The creatine result times 2.255
'This is a result' - a literal text
If (Result('CREAT')>3.5,'Big','Small') - Another if statement
if (Fasting()='True','Yes','No') would produce the word "Yes" if the patient is Fasting and "No" if the patient is not fasting.
if (age('Y') > 10,true,false) - If the patients age was greater than 10 years, this would return a 'True', else a 'False'
A More complex example is GFR calculation (Take a breath, we will explain):
186*(Result('CREA')^-1.154)*(age('Y')^-0.203)*
(if(Sex() = 'F', .742, 1 )) *
(if(Race() == 'AA' , 1.210, 1 ))Stated in English, the above equation; Multiply 196 times the result of the CREAT raised to the -1.154 power. Take this and multiply times the patients age in years raised to the -0.203 power. Take this and IF the sex is Female, multiply by .742 else multiply by 1. Take this and IF the Race is 'AA' (African American) multiply by 1.210, else multiply by 1.
Conditional statements can also be 'Nested' For example:
if( if(Sqrt(4)=2,'true','false') = 'true' , 'Is True', 'Is False' ) - Inner parenthesize are always evaluated first so in this equation, if the Square Root of 4 is equal to 2 (which it is) the inner IF returns a 'true'. The outer If compares (=) the result of the inner IF to 'true" and is so, returns the text 'Is True'.
AP-Visions is a leading provider of IT healthcare solutions to seamlessly manage, move, store, and report all your electronic laboratory data.