Clinical Quality Language Specification, published by Clinical Decision Support WG. This guide is not an authorized publication; it is the continuous build for version 1.5.3 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/cql/ and changes regularly. See the Directory of published versions
Page standards status: Normative | Maturity Level: N |
This appendix provides detailed mappings for each FHIRPath function in terms of the ELM output produced.
In addition to the function mappings below, the $index accessor can be used within the FHIRPath iteration functions (i.e. FHIRPath functions that take an expression as an argument) to access the 0-based index of the current iteration.
X.aggregate(<iteration>, <init>) === Aggregate(<iteration>, <init>)
In addition, the $total accumulator can be used within the iteration and init expressions to access the current value of the accumulator.
X.abs() === Abs(X)
X.all(<condition>) === AllTrue(X $this let a: <condition> where a return a)
X.allFalse() === AllTrue(X A return not A)
X.allTrue() === AllTrue(X)
X.anyFalse() === AnyTrue(X A return not A)
X.anyTrue() === AnyTrue(X)
X.as(T) === X as T
Note that the type argument T is expected to be a literal string and must resolve to the name of a type.
X.ceiling() === Ceiling(X)
.children(X) === Children(X)
X.combine(Y) === Flatten(\{ X, Y })
X.conformsTo(Y) === FHIRSupport.ConformsTo(Y)
Note that this mapping relies on an external library, FHIRSupport to provide conformance validation checking.
X.contains(Y) === PositionOf(Y, X) >= 0
X.convertsToBoolean() === ConvertsToBoolean(X)
X.convertsToDate() === ConvertsToDate(X)
X.convertsToDateTime() === ConvertsToDateTime(X)
X.convertsToDecimal() === ConvertsToDecimal(X)
X.convertsToInteger() === ConvertsToInteger(X)
X.convertsToQuantity() === ConvertsToQuantity(X)
X.convertsToTime() === ConvertsToTime(X)
X.count() === Count(X)
.descendants(X) === Descendants(X)
X.distinct() === distinct X
X.empty() === not exists X
X.endsWith(Y) === EndsWith(X, Y)
X.exclude(Y) === X except Y
X.exists() === exists X
X.exists(<condition>) === exists (X $this where <condition>)
X.exp() === Exp(X)
X.first() === First(X)
X.floor() === Floor(X)
X.hasValue() === X is not null
iif(X, Y) === if X then Y else null
iif(X, Y, Z) === if X then Y else Z
X.indexOf(Y) === PositionOf(Y, X) // Note carefully the order of arguments here, it’s the opposite of IndexOf
X.intersect(Y) === X intersect Y
X.is(T) === X is T
Note that the argument T is expected to be a literal string and must resolve to the name of a type.
X.isDistinct() === Count(X) = Count(distinct X)
X.last() === Last(X)
X.lastIndexOf(Y) === LastPositionOf(Y, X) // Note carefully the order of arguments here, it’s the opposite of lastIndexOf.
X.length() === Length(X)
X.ln() === Ln(X)
X.log(B) === Log(X, B)
X.lower() === Lower(X)
X.matches(Y) === Matches(X, Y)
X.memberOf(Y) === InValueSet(X, Y) // where Y is required to be a ValueSetRef
X.ofType(T) === X $this where $this is T return $this as T
Note that the argument T is required to be a literal string, and is interpreted as the name of a type. For non-named-types, type specifier syntax applies.
X.not() === not X
now() === Now()
X.power(Y) === Power(X, Y)
X.repeat(<element>) === Repeat(X, <element>)
The type of X.repeat(
X.select(<element>).select(<element>)
X.replace(Y, Z) === Replace(X, Y, Z)
X.replaceMatches(Y, Z) === ReplaceMatches(X, Y, Z)
X.round() === Round(X)
X.round(Y) === Round(X, Y)
If the result type of
X.select(<element>) === X $this let a: <element> where a is not null return a
If the result type of
X.select(<element>) === Flatten(X $this let a: <element> where a is not null return a)
X.single() === singleton from X
X.skip(Y) === Slice(X, Y, null)
X.sqrt() === Power(X, 0.5)
X.startsWith(Y) === StartsWith(X, Y)
X.subsetOf(Y) === X included in Y
X.substring(Y) === SubString(X, Y)
X.substring(Y, Z) === SubString(X, Y, Z)
X.subsumes(Y) === Subsumes(X, Y)
X.subsumedBy(Y) === SubsumedBy(X, Y)
X.supersetOf(Y) === X includes Y
X.tail() === Slice(X, 1, null)
X.take(Y) === Slice(X, 0, Coalesce(Y, 0))
timeOfDay() === TimeOfDay()
X.toBoolean() === ToBoolean(X)
X.toChars() === ToChars(X)
X.toDate() === ToDate(X)
X.toDateTime() === ToDateTime(X)
today() === Today()
X.toDecimal() === ToDecimal(X)
X.toInteger() === ToInteger(X)
X.toQuantity() === ToQuantity(X)
X.toString() === ToString(X)
X.toTime() === ToTime(X)
X.trace(Y) === Message(X, true, Y, 'Trace', ToString(X)))
X.truncate() === Truncate(X)
X.union(Y) === X union Y
X | Y === X union Y
X.upper() === Upper(X)
X.where(<condition>) === X $this where <condition>