Using FHIRPath - Smile CDR Documentation
Using FHIRPath LMA
Realtime Export uses FHIRPath as its evaluation engine, which is likely to be unfamiliar to many people. While the official documentation is excellent, this page will serve as a set of examples that can be used in Realtime Export
For all of the following examples, we will be applying the FHIRPath expressions to this example Patient.
{
"resourceType":"Patient",
"id":"123",
"meta":{
"versionId":"1",
"lastUpdated":"2020-09-15T18:38:07.182+00:00"
},
"identifier":[\
{\
"system": "http://example.org/mrn",\
"value": "123"\
},\
{\
"system": "http://example.org/person-id",\
"value": "456"\
}\
],
"gender":"male",
"name":[\
{\
"family":"Scott",\
"given":[\
"Michael",\
"Gary"\
]\
},\
{\
"family":"Levinson",\
"given":[\
"Astrid"\
]\
}\
],
"address":[\
{\
"use":"home",\
"line":[\
"#4 Privet Drive",\
"Under the staircase"\
],\
"city":"Little Whinging",\
"district":"Surrey",\
"postalCode":"ABC 123"\
}\
]
}
Copy
Basics
The first thing to know is that all FHIRPath expressions always return collections of elements. For example, this expression:
Patient.name.given
Copy
Will return
["Michael", "Gary", "Astrid"]
Copy
This makes intuitive sense, as there are 3 given name elements. However, even if there were a single element, it would return it wrapped in a collection like this:
["Michael"]
Copy
For Realtime Export, the FHIRPath expressions must resolve to a single element. Refer to Collection Subsetting below for methods to mitigate this limitation.
Collection Subsetting LMA
first() method
Patient.name.given.first()
> ["Michael"]
Copy
last() method
Patient.name.given.last()
> ["Astrid"]
Copy
Index slicing
Patient.name.given[0]
> ["Michael"]
Copy
Patient.name.given[1]
> ["Gary"]
Copy
There are more methods which can handle subsetting, which are documented here.
Self-referral LMA
Occasionally you will need to refer to the full content of a previous given FHIRPath expression. For occasions like this, you can use the $this expression, which will cause the element to evaluate to itself. Consider the following snippet, which has a child transformer on each line of an address.
{
"childTables": [\
{\
"fhirPath": "line",\
"tableName": "rte_patient_address_line",\
"childTransformer": {\
"columns": [\
{\
"columnName": "line",\
"fhirPath": "$this",\
"columnType": "STRING"\
}\
]\
}\
}\
]
}
Copy
Conditionals LMA
In FHIR, often times you will be faced with a high cardinality element, but what do you do when you need a specific element in the collection,
which you cannot safely index by its position in the list? In this case, FHIRPath supports use of the .where() function, which allows you to conditionally select from a collection:
Patient.identifier.where(system='http://example.org/mrn').value > ["123"]
Copy
Realtime Export Rules Definition
Using FHIRPath
Realtime Export
Realtime Export Overview Bootstrapping RTE Data Realtime Export Rules Definition Using FHIRPath Delta Lake Export --EAP-- Bulk Batch Replication --EAP--