A function is an expression that returns a value. Arezzo functions can divided into the following categories:
Expression |
Description |
isknown(DataName) |
Condition is true if a value exists for the data name. For example: isknown(reg_date) or isknown(Screening:cover:DOB) |
It is advisable to use isknown with the logical operator not to avoid unexpected results concerning unknown data.
For example, the condition 'not q1 = 8' evaluates to true if q1 has a value that is not 8, but it also evaluates to true when q1 does not have a value as a result of not having been filled in.
If you use isknown as well as not you could create the condition 'isknown(q1) and not q1 = 8'
This evaluates to false when q1 has not been filled in, avoiding confusion.
Note that the condition 'isknown(q1) and not q1 = 8' is equivalent to 'q1 <> 8'
This is because <> is treated as a single operator, whereas "not q1 = 8" the "not" is applied after the "=" has been evaluated.
Expression |
Description |
if(Condition,Expression1,Expression2) |
Evaluates to Expression1 if Condition is true, or Expression2 if Condition is false, e.g. if(age<18,child,adult) |
case((Cond1,Expr1),(Cond2,Expr2),...) |
Conditional evaluation equivalent to nested 'if' expressions - evaluates to Expr1 if Cond1 is true, Expr2 if Cond2 is true, and so on, e.g. case((viral_load<500,low),(viral_load>10000,high),(viral_load between (500,10000),intermediate)) |
case((Cond1,Expr1),...,(else,ExprN)) |
Same as 'case' above - evaluates to expression1 if condition1 is true, and so on, otherwise expressionN, e.g. case((viral_load<500,low),(viral_load>10000,high),(viral_load between (500,10000),intermediate),(else,unknown)) |
These functions can only be used with text expressions.
Expression |
Description |
substring( Text, StartPos, NChars ) |
Returns NChars characters from the given Text string starting at position StartPos. The first character is at position 1. For example substring( SubjName, 1, 3 ) returns the first 3 characters of the value of SubjName. If StartPos is negative, the position is counted from the end of the string. For example substring( SubjName, -1, 1 ) returns the last character of the value of SubjName. |
len( Text ) |
Returns the length of the given text string, i.e. the number of characters in the string. |
Also see comparison operator like.
These functions can only be used with numeric expressions. Arezzo also includes the normal arithmetic operators.
Expression |
Description |
abs( Expr ) |
The absolute value of Expr. This is its positive numeric value, ignoring any minus sign. |
neg( Expr ) |
The negative value of Expr. This is its negative numeric value, ignoring any plus sign. |
sqrt( Expr ) |
The square root of Expr. |
log( Expr ) |
The base 10 logarithm of Expr. |
round( Expr, Places ) |
This rounds Expr to the specified number of decimal places. This is useful when displaying the results of calculations within text messages, for example 'The value ' & round( sqrt(Q1), 2 ) & ' is too high' You can use the round function to get the integer part of a real number by rounding to 0 decimal places. To ensure that the value is rounded down rather than up, you should subtract 0.5. |
Also see comparison operator between.
When creating a validation that checks decimal numbers, the arithmetic rounding process within the base operating system can cause incorrect results. We recommend not using the '=' operator in a comparison with a calculated value without specifying the number of decimal places to compare, as any minor rounding variation may cause this to return false.
For example,
“me:value – round( me:value – 0.5, 0 ) >= 0.7”
will evaluate incorrectly but
“me:value – round( me:value – 0.5, 0 ) oneof [ 0.7, 0.8, 0.9 ]”
will work as expected.
Alternatively, if you need to use an '=' comparison, you can use the Arezzo 'round' function to limit the number of significant digits to be compared.
For example,
“round(me:value – round( me:value – 0.5, 0 ),1) >= 0.7”
Also see Date and time functions.
There are buttons for all the Arezzo functions in the Expression Builder.