Skip to main content
Version: 9.2.0

FHIRPath

Pathling leverages the FHIRPath language in order to abstract away some of the complexity of navigating and interacting with FHIR data structures.

Pathling implements the FHIRPath subset within the Sharable View Definition profile of the SQL on FHIR view definition, plus additional terminology and utility functions.

Supported language features

Path navigation

Pathling supports standard FHIRPath path navigation using dot notation:

Patient.name.given
Observation.code.coding.system

Array indexing is supported using bracket notation:

Patient.name[0].given

The $this special variable is supported for referring to the current context within expressions.

Literals

Pathling supports the following literal types:

TypeSyntaxExamples
Booleantrue, falseactive = true
StringSingle quotes with escapes'hello', 'it\'s'
IntegerWhole numbers123, -45
DecimalNumbers with decimal point3.14, -0.5
Date@ prefix, ISO 8601@2023-01-15
DateTime@ prefix, ISO 8601@2023-01-15T14:30:00
Time@T prefix@T14:30:00
QuantityNumber with unit10 'mg', 4 days

Operators

See Operators in the FHIRPath specification for detailed semantics.

Comparison operators

OperatorDescription
=Equality
!=Inequality
<Less than
<=Less than or equal to
>Greater than
>=Greater than or equal to

Boolean operators

OperatorDescription
andLogical AND
orLogical OR
xorExclusive OR
impliesLogical implication

Arithmetic operators

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division
modModulus

Unary + and - are also supported for numeric values.

String operators

OperatorDescription
&String concatenation

Collection operators

OperatorDescription
|Union of two collections
inTest if element is in collection
containsTest if collection contains element

Type operators

OperatorDescription
isType checking
asType casting

Standard functions

The following standard FHIRPath functions are implemented. See Functions in the FHIRPath specification for detailed semantics.

Existence functions

FunctionDescription
exists(criteria?)Returns true if the collection has any elements, optionally filtered by criteria
empty()Returns true if the collection is empty

Filtering and projection functions

FunctionDescription
where(criteria)Filter collection by criteria expression
ofType(type)Filter collection by type

Subsetting functions

FunctionDescription
first()Returns the first element of the collection

Boolean functions

FunctionDescription
not()Boolean negation

String functions

FunctionDescription
join(separator?)Join strings with optional separator

Type functions

FunctionDescription
is(type)Type checking (equivalent to is operator)
as(type)Type casting (equivalent to as operator)

Conversion functions

FunctionDescription
toBoolean()Convert to Boolean
toInteger()Convert to Integer
toDecimal()Convert to Decimal
toString()Convert to String
toDate()Convert to Date
toDateTime()Convert to DateTime
toTime()Convert to Time
toQuantity(unit?)Convert to Quantity with optional unit conversion using UCUM
FunctionDescription
convertsToBoolean()Check if convertible to Boolean
convertsToInteger()Check if convertible to Integer
convertsToDecimal()Check if convertible to Decimal
convertsToString()Check if convertible to String
convertsToDate()Check if convertible to Date
convertsToDateTime()Check if convertible to DateTime
convertsToTime()Check if convertible to Time
convertsToQuantity(unit?)Check if convertible to Quantity

Limitations

The following FHIRPath features are not currently supported:

  • Equivalence operators: ~ and !~
  • Lambda expressions
  • Aggregate functions: count(), sum(), avg(), min(), max()
  • Special variables: $index, $total
  • Quantity arithmetic: Math operations on Quantity types
  • DateTime arithmetic: DateTime math operations
  • Full resolve(): Traversal of resolved references

Additional functions

Pathling also supports additional functions beyond the standard FHIRPath specification:

  • FHIR-specific functions - Functions defined in the FHIR specification for use with FHIR data, including extension, resolve, memberOf, subsumes, and subsumedBy.
  • Extension functions - Functions unique to Pathling, including terminology functions like designation, display, property, and translate, plus the Coding literal data type.