The expression element appears in RuleDef Element. It is an expression that evaluates to a result when it is run. For example the expression below might evaluate to true or false depending on the value of ITEM_OID.
<Expression> ITEM_OID eq 50</Expression> |
OpenClinica defines a specific language for creating these expressions. This language supports Logical, Arithmetic, and Conditional operators. We will list those in tables below. Alongside operators OpenClinica supports the user of Integers, Strings and OpenClinica variables in order to do the evaluation.
The expression above is using ITEM_OID, which is an OpenClinica variable and 50, which is a number, with the operator being an equal. OpenClinica out of the box supports the following operators
The Equality and Relational Operators | ||
eq | Equal to | Variables used with this operator could be of any type |
ne | Not Equal to | Variables used with this operator could be of any type |
ct | Contains | Variables used with this operator could be of any type |
gt | Greater Than | Variables used with this operator should be of a number type |
gte | Greater Than or Equal to | Variables used with this operator should be of a number type |
lt | Less Than | Variables used with this operator should be of a number type |
lte | Less Than or Equal to | Variables used with this operator should be of a number type |
Some example expressions using the above operators
- ITEM_OID eq YELLOW
- ITEM_OID lt (-15)
- ITEM_OID gt 5
- 5 gte ITEM_OID
- YELLOW ne GREEN
- ITEM_OID ct “2014”
The Conditional Operators | ||
and | and | Variables used with this operator should be of a boolean type |
or | or | Variables used with this operator should be of a boolean type |
Some example expression using the above operators
- ITEM_OID eq YELLOW and ITEM_OID_2 gt 5
- (ITEM_OID eq YELLOW) and (ITEM_OID_2 gt 5)
- (YELLOW neq GREEN ) or (ITEM_OID_2 gt 5)
The Arithmetic Operators | ||
+ | Addition | Variables used with this operator should be of a number type |
– | Subtraction | Variables used with this operator should be of a number type |
* | Multiplication | Variables used with this operator should be of a number type |
/ | Division | Variables used with this operator should be of a number type |
Some example expression using the above operators
- ITEM_OID + 35 eq 50
- ITEM_OID 10 eq 34 AND ITEM_OID_2 gt 45
- ((ITEM_OID 10) eq 34) AND (ITEM_OID_2 gt 45)
Statements can be used in these expressions. Now OpenClinica utilizes what is known as contextual statements, meaning as in the examples above you can put
ITEM_OID and OpenClinica will automatically complete the statement so to make it legal. Lets use an example
<Target Context=”OC_RULES_V1″>SED_OID[ALL].CRF_OID.GROUP_OID.ITEM_OID</Target> <Expression> ITEM_OID eq 50</Expression> |
What will actually happen here when this expression is being evaluated is that ITEM_OID will be substituted by
SED_OID[ordinal].CRF_OID.GROUP_OID.ITEM_OID |
In order to support cross form edit checks we actually include a complete statement. One side not regarding that is we cannot use ALL in the expressions.
Dates within Rules
Rules supports the following operators to be used with dates
The Equality and Relational Operators | ||
eq | Equal to | ITEM_OID eq 2008-12-12 |
ne | Not Equal to | ITEM_OID ne 2008-12-12 |
gt | Greater Than | ITEM_OID gt 2008-12-12 |
gte | Greater Than or Equal to | ITEM_OID gte 2008-12-12 |
lt | Less Than | ITEM_OID lt 2008-12-12 |
lte | Less Than or Equal to | ITEM_OID lte 2008-12-12 |
The format of the date included in an expression should be yyyy-MM-dd .
Example: January 01, 2010 should be written as : 2010-01-01
You can also use _CURRENT_DATE to compare values against the current server date. For example, with a NotificationAction, to notify Participants of a Form that must be completed on the next day, you could use an expression such as:
<Expression>SE_OID.STARTDATE eq (_CURRENT_DATE +1) and SE_OID.STATUS ne “complete”</Expression>
This would send a notification one day in advance of the expected form completion date as long as the form was not already completed by the Participant.