Data Properties for Expressions

Expressions are used in the following data properties:

Property

Where Used

Description

Conditions

Section

Entry

Cluster

Element

Result of the expression is cast to xs:boolean

The Condition is evaluated continuously as the containing Composition is edited by the user. If the Condition evaluates to true then the component is in-scope, if the Condition evaluates to false then the component is out-of-scope.

Any out-of-scope component has its visibility set to false, is hidden from the user, does not get used in other calculations and is removed from the Composition before it is committed to the patient record.

Pre-conditions

Section

Entry

Result of the expression is cast to xs:boolean

These pre-conditions are evaluated once, when the Composition is loaded; any out-of-scope component is removed from the Composition before any user interaction begins.

EvaluationContext

Section

Entry

Conditions used to constrain the Compositions in the record from which default values for any Elements in the component are calculated when the Composition is loaded.

Constraints

Element

Result of the expression is cast to xs:boolean

An expression that is evaluated as the user enters the value of Data for the Element; if the Constraints evaluates to false then the value entered by the user is removed (replaced by an empty value)

DefaultValue

Element

Result of the expression is cast to the DataType of the Element

An expression that is evaluated when the Composition is loaded; result is set as the initial value of the Element Data. Note that the evaluation is also determined by the InitialValue property of the containing Entry, which must be set to either Default or Pre-filled. For Default, the default value is set as the result of the expression or is left empty if no default expression is specified. For Pre-filled entries, any default values are calculated only if there is no existing Entry of that type recorded for the patient.

CalculatedValue

Element

Result of the expression is cast to the DataType of the Element

The CalculatedValue is evaluated continuously as the containing Composition is edited by the user.

The result of the CalculatedValue expression sets the Data value of Elements that are of type calculatedValue

For Elements of type enumeratedCalculatedValue, the result of the expression should be a sequence of values (a, b,c, etc) that then constrains the Data values for the Element that can be selected by the user.

The expression language used by cityEHR is XPath, with some additional built-in functions and the ability to reference the data value of Elements using the convention:

EntryId/ElementId

where ElementId is the identifier of an Element contained in the Entry with identifier EntryId. Expressions use the XPath expression language (version 2) as defined by the W3C standard at:

https://www.w3.org/TR/xquery-operators/

In the context of cityEHR expressions the data value of an Element is represented as EntryId/ElementId, so for example in the expression

ScanDate/Date – Demographics/DateOfBirth

ScanDate/Date is the value of the Element with the identity Date in the Entry with the identity ScanDate and

Demographics/DateOfBirth is the value of the Element with identity DateOfBirth in the Entry with the identity Demographics

The result of the expression is cast to the data type defined by the DataType of the Element (when used in Default Value or CalculatedValue) or as xs:boolean (for Conditions, Pr-conditions and Constraints)

Expressions can also use extension functions that are specific to cityEHR, as shown in the following table. Here elementRef represents the pair EntryId/ElementId

Function

Description

cityEHR:getValues(elementRef)

Returns a sequence of values for the elementRef – this is all values that have been recorded in the longitudinal record.

cityEHR:getValues(elementRef, conditions)

Where the conditions parameter is supplied this is an Xpath expression used to filter the value returned and is evaluated relative to the return sequence. So for example the conditions [. lt 60] would filter the sequence to values less than 60.

cityEHR:distinctValues(elementRef)

cityEHR:distinctValues(elementRef, conditions)

As getValues, but returns the sequence of distinct values found. So the sequence does not contain any repeats of the same value.

cityEHR:lookup(directoryElement, keyValue)

Looks up the keyValue in the directory specified by the directoryElement parameter.

The keyValue is an Xpath expression that can be a string literal (must be quoted) or an elementRef

cityEHR:instance(instanceId, path)

Returns the result of the path in the XForms instance specified by the instanceId parameter. This function requires knowledge of the cityEHR code in order to specify the instanceId.

cityEHR:getAttribute(elementRef, attributeId)

Returns the value of the XML attribute named by the attributeId parameter on the element specified as the elementRef

Examples of expressions from the default Feature Demo application are shown in the table below.

Type

Example Expression

Calculated Value

0

Calculated Value

'today'

Calculated Value

'P7D

Calculated Value

Current-date()

Calculated Value

ClinicDetails/ClinicCode

Calculated Value

ScanDate/Date – Demographics/DateOfBirth

Calculated Value

round-half-to-even(10000*BMI/WeightInKg div (BMI/HeightInCm * BMI/HeightInCm),2)

Calculated Value

if (BMI/CalculatedBMI lt 18.5) then 'Underweight' else if (BMI/CalculatedBMI ge 18.5 and BMI/CalculatedBMI lt 25) then 'Healthy' else if (BMI/CalculatedBMI ge 25 and BMI/CalculatedBMI lt 30) then 'Overweight' else 'Obese'

Calculated Value

max(BMI/HeightInCm)

Calculated Value

round-half-to-even(avg(BMI/HeightInCm))

Calculated Value

normalize-space(concat(Demographics/Title, ' ', Demographics/Forename, ' ', Demographics/Surname))

Calculated Value

count(cityEHR:getValues(Fracture/FractureDate,Fracture/ CurrentFracture='Yes'))

Calculated Value

cityEHR:instance(patient-instance,cdaheader/id)

Calculated Value

cityEHR:lookup(DrugInformationDirectory,MedicationInformation/DrugName)

Constraint

.gt0and.le100