Summary

This article covers expression language when writing any normal dependency. 

Table of Contents


The Fountayn Expression Language is used when writing any normal dependency. Every dependency can be thought of as having a mathematical or logical expression that, no matter how complex, resolves either to true or false. If the expression resolves to false, a dependency alert will appear in the application.

Boolean Logic

Boolean logic is a complete system for logical operations. It is commonly associated with truth tables, which are tables used to determine the value of a logical function.

Boolean logic is used universally in anything having to do with electronics or computers, and in many other fields as well. Certainly it can be an intimidating subject, however, dependency expressions in our eClinical suite only scratch the surface of boolean logic, and as a result are not terribly complicated. Boolean logic forms the core of a dependency expression, and at a basic level is used to compare a value entered by the user to an expected value.

Truth Tables

A truth table is a table consisting of two or more logical variables containing all possible combinations of truth values, and then an output based on a particular logical function. Logical variables in a truth table are most commonly denoted as p, q, r, and s. Each one can be either true or false. Each row of a truth table will take the input values (true or false) for each variable, and then state the resulting value (true or false) for the logical function. Logical functions can be as simple as “p AND q”, or much more complex.

In the Fountayn clinical research platform, simple dependency expressions serve as the logical variables. For instance, you could think of the expression “this == 1″ as the variable “p” in a truth table, and “this == 3″ as the variable “q”. Therefore, a more complicated expression, such as “this == 1 AND this == 3″, would be the same as “p AND q” in the truth tables below. The reason this can be done is because “this == 1″ has two possible values, either true (the question is in fact 1), or false (the question is any number other than 1). In fact, any binary relation using the symbols ==, !=, <, >, <=, and >= will either be true or false.

Expression Language Syntax

The syntax used in eClinical dependency expressions consists of three common boolean operators: AND, OR, and NOT, as well as the binary relations ==, !=, <=, >=, <, and >. Parentheses are also used in more complicated expressions to denote order of operations.

The simplest expressions do not include any boolean operators at all, but rather just a single binary relation. The binary relations used in our expressions are used to compare one element to another. For example, “this == 1″ will return TRUE if the question is entered as 1, and FALSE if it is anything other than 1.

Dependency alerts will fire if the related expression evaluates to FALSE, and will not fire if it evaluates to TRUE. All expressions are independent of each other.

Dependency expressions become more complicated as more boolean operators are used. Several examples are listed below.

== and !=

The two binary relations == and != check that the data entered is either exactly the requirement, or anything but the requirement. For example, “this == ‘blue’” will be true if “blue” is entered, and false if anything else is entered.

ExpressionEntered DataEvaluation
this == 11true
this == 12false
this != ‘dog’cattrue
this != ‘dog’dotrue
this != ‘dog’dogfalse

<, >, <=, and >=

The binary relations <, >, <=, and >= check that the data entered is within a specific range. The difference between < and <= (and > and >=) is that <= includes the value itself as a valid entry, while < does not. In other words, for “this <= 1″, “1″ is acceptable, while for “this < 1″, “1″ is not acceptable. Integers, floats, and dates can all be checked using these relations.

ExpressionEntered DataEvaluation
this >= 22true
this >= 21false
this < 8.0328.032false
this <= 8.0328.032true
this <= @@todaytoday’s datetrue
this <= @@todaytomorrow’s datefalse
When using <, >, <=, and >= be sure not to put apostrophes around an integer or floating point number. Only use the apostrophes to designate a string or character. Doing so will cause the dependency to react unpredictably to certain values. Ex. do NOT use “this <= ’1′” instead use “this <= 1″.


AND

The AND operator requires that both the left and right side of the expression evaluate to true. If one or both of the sides are false, the entire expression will be false. If there are several AND’s relating more than 2 items, all of the items must be true in order for the entire expression to be true. If even just one item is false, the entire expression is false.

pqrp AND qp AND q AND r
TTTTT
TTFTF
TFTFF
TFFFF
FTTFF
FTFFF
FFTFF
FFFFF

OR

The OR operator requires that one or both of the left and right side of the expression evaluate to true. If both of the sides are false, the expression will be false. If there are several OR’s relating more than 2 items, any one (or more) of the items must be true in order for the entire expression to be true. Only if all three items are false, then the entire expression is false.

pqrp OR qp OR q OR r
TTTTT
TTFTT
TFTTT
TFFTT
FTTTT
FTFTT
FFTFT
FFFFF

NOT

The NOT operator effectively reverses the expression it is applied to. For instance, an AND expression is true when both elements are true, and false otherwise. Placing a NOT in front of expression would change it so that the expression is FALSE when both elements are true, and TRUE otherwise. The NOT operator can also be replaced by a “!” in our eClinical expressions.

The NOT operator can also be used to negate a single expression. For instance, “NOT (this == 1)” is an acceptable expression. However, an expression like this is almost always written as “this != 1″. The two are equivalent.

pqp AND qNOT ( p AND q )p OR qNOT ( p OR q )
TTTFTF
TFFTTF
FTFTTF
FFFTFT

Parentheses

Parentheses are used to denote order of operations in an expression that is dependent on more than two items. There is no limit to the number of parentheses used in an expression, although the number of open parentheses must equal the number of close parentheses. The items inside a parenthesis are evaluated to either TRUE or FALSE, and then that is compared to the values outside the parenthesis. If there is only one type of logical operator (AND, OR) used in an expression, the use of parentheses will not affect the evaluation of the expression. In other words, each item in the expression can be evaluated in any order.

pqr(p OR q) AND r(p AND q) OR rp OR (q AND r)
TTTTTT
TTFFTT
TFTTTT
TFFFFT
FTTTTT
FTFFFF
FFTFTF
FFFFFF

Examples

The following is a list of several example expressions, to give you an idea of how boolean logic is used in our eClinical dependencies.

questionTypeIdCheck If BlankExpressionAlert
initialsyesthis != ”An answer must be provided. Please verify.
signedConsentnothis == ‘yes’Question must be answered ‘Yes’ for patient to be included. Please verify.
meetAllCriterianothis == ‘no’ OR (this == ‘yes’ AND age == ‘yes’ AND birthControlMethod == ‘yes’)Question is answered ‘Yes’, yet at least one criteria above is not met. Please verify.
gendernothis == ‘female’ OR (this == ‘male’ AND pregnancyTest == ‘na’)‘Male’ has been selected, yet ‘NA’ is not chosen on ‘Pregnancy Test’. Please verify.
dateOfVitalsnoconsentDate <= this AND this <= @@currentDateThe date entered must occur on or after the Consent Date and cannot occur in the future. Please verify.
systolicBPno(80 <= this) AND (this <= 200)The value entered is outside the specified range (80-200). Please verify.
raceOtheryesrace CONTAINS ‘other’An answer is missing, however the response to ‘Race’ includes ‘Other’. Please verify.
raceOtherno!(race CONTAINS ‘other’)An answer has been provided, however the response to ‘Race’ does not include ‘Other’. Please verify.

 

initials
This dependency is one of the most common: the “check if blank” dependency. It is a contradiction in that “check if blank” is set to “yes”, but the expression states that the question must not be blank. This results in an “Answer must be provided” alert if the question is entered blank.

signedConsent
The “signedConsent” question must be answered “yes”, otherwise the alert listed will fire.

meetAllCriteria
This question must be answered “no”, or it must be answered “yes” while the age and birthControlMethod questions are also answered “yes”. Because of the OR operator, if the question is answered “no”, it does not matter how the other questions are answered. If it is answered “yes” and even one of the other questions is “no”, the alert will fire.

gender
If the question is answered “male”, then the pregnancyTest question must be answered “na”. If the question is answered “female”, then it does not matter how the pregnancyTest question is answered.

dateOfVitals
This date must occur between the consent date and current date, inclusive. This means that if it occurs directly on the consent date or today’s date, it is still valid. One day outside of the range will fire the alert.

systolicBP
The systolic blood pressure must be within 80 and 200, inclusive. 80 and 200 are acceptable values, while 79 and 201 are not.

raceOther
Whether or not an answer is expected on the raceOther question is dependent on the answer to the race question. In this example, the race question is set to allow multiple responses. Therefore, rather than check if the answer to race is equal to (exactly and only) ‘Other’, the ‘CONTAINS’ operator is used to determine if the response includes ‘Other’ (alone or in combination with other values). There is not a single operator for DOES NOT CONTAIN, so ‘!’ is used outside of the CONTAINS expression.


Need more help?

Please visit the Fountayn Contact Information page.