Link

Functions

FHIRPath supports the notion of functions, which all take a collection of values as input and produce another collection as output and may take parameters.

The following functions are currently supported:

The notation used to describe the type signature of each function is as follows:

[input type] -> [function name]([argument name]: [argument type], ...): [return type]

See also: Functions

resolve

Reference -> resolve(): collection<Resource>

The resolve function is used to traverse references between FHIR resources. Given a collection of References, this function will return a collection of the resources to which they refer.

Example:

AllergyIntolerance.patient.resolve().gender
Resolution of uri and canonical types (outside of Reference.reference is not currently supported.
Resolution of resources by identifier is not currently supported.

See also: Additional functions

reverseResolve

collection<Resource> -> reverseResolve(sourceReference: Reference): collection<Resource>

In FHIR, resource references are unidirectional, and often the source of the reference will be a resource type which is not the subject of the current path.

The reverseResolve function takes a collection of Resources as input, and a Reference as the argument. It returns a collection of all the parent resources of the source References that resolve to the input resource.

Example:

Patient.reverseResolve(Encounter.subject).reasonCode
The reverseResolve function is not within the FHIRPath specification, and is currently unique to the Pathling implementation.
Resolution of resources by identifier is not currently supported.

ofType

collection -> ofType(type: Resource): collection

Returns a collection that contains all items in the input collection that are of the given type. It is often necessary to use the ofType function in conjunction with the resolve function, to resolve references that are polymorphic.

Example:

Condition.subject.resolve().ofType(Patient).gender
Only resource types are currently supported by this function.

See also: ofType

count

collection -> count() : Integer

Returns the Integer count of the number of items in the input collection.

Example:

Patient.name.given.count()
The count function is an aggregate function, which means it can be used as the final path component in contexts that require this, e.g. aggregation expressions within the aggregate operation.

See also: count

first

collection -> first() : collection

Returns a collection containing only the first item in the input collection. This function will return an empty collection if the input collection has no items.

Example:

Patient.name.given.first()
The first function is an aggregate function, which means it can be used as the final path component in contexts that require this, e.g. aggregation expressions within the aggregate operation.

See also: first

empty

collection -> empty() : Boolean

Returns true if the input collection is empty, and false otherwise.

Example:

Patient.reverseResolve(Condition.subject).empty()

See also: empty

where

collection -> where(criteria: expression) : collection

Returns a collection containing only those elements in the input collection for which the criteria expression evaluates to true. Elements for which the expression evaluates to false or an empty collection will not be included in the result.

The $this keyword is used within the criteria expression to refer to the item from the input collection currently under evaluation.

Example:

Patient.reverseResolve(Condition.subject).where($this.recordedDate > @1960).severity

See also: where

memberOf

collection<Coding|CodeableConcept> -> memberOf() : collection<Boolean>

The memberOf function can be invoked on a collection of Coding or CodeableConcept values, returning a collection of Boolean values based on whether the concept is a member of the ValueSet with the specified url.

The memberOf function is a terminology function, which means that it requires a configured terminology service. See Configuration and deployment for details.

See also: Additional functions

subsumes

collection<Coding|CodeableConcept> -> subsumes(code: Coding|CodeableConcept) : collection<Boolean>

When invoked on a Coding-valued element and the given code is Coding-valued, returns true if the source code is equivalent to the given code, or if the source code subsumes the given code (i.e. the source code is an ancestor of the given code in a subsumption hierarchy), and false otherwise.

If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.

When the source or given elements are CodeableConcepts, returns true if any Coding in the source or given elements is equivalent to or subsumes the given code.

Example:

Patient.reverseResolve(Condition.subject).code.subsumes(http://snomed.info/sct|770581008)
The subsumes function is a terminology function, which means that it requires a configured terminology service. See Configuration and deployment for details.

See also: Additional functions

subsumedBy

collection<Coding|CodeableConcept> -> subsumedBy(code: Coding|CodeableConcept) : collection<Boolean>

When invoked on a Coding-valued element and the given code is Coding-valued, returns true if the source code is equivalent to the given code, or if the source code is subsumed by the given code (i.e. the given code is an ancestor of the source code in a subsumption hierarchy), and false otherwise.

If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.

When the source or given elements are CodeableConcepts, returns true if any Coding in the source or given elements is equivalent to or subsumed by the given code.

Example:

Patient.reverseResolve(Condition.subject).code.subsumedBy(http://snomed.info/sct|73211009)
The subsumedBy function is a terminology function, which means that it requires a configured terminology service. See Configuration and deployment for details.

See also: Additional functions

Next: Configuration and deployment