← ReferenceStandards
What is FHIRPath?
FHIRPathis a path-based expression language for navigating and extracting data from FHIR resources. It is similar in concept to XPath for XML or JSONPath for JSON, but purpose-built for FHIR's type system and polymorphic elements.
FHIRPath appears in profiles (as invariant constraints), search parameters, FHIR mapping rules, questionnaires, and CQL clinical logic.
FHIRPath expressions
| Expression | Result |
|---|---|
| Patient.name | All HumanName elements |
| Patient.name.family | All family name strings |
| Patient.name.where(use = 'official') | Only the official name |
| Patient.identifier.count() | Number of identifiers |
| Observation.value.ofType(Quantity).value | Numeric value when value[x] is Quantity |
| Patient.birthDate.exists() | true if birthDate is present |
| Patient.name.family.hasValue() | true if family name has a non-empty value |
Invariants in profiles
Profiles use FHIRPath to define invariants — constraints that cannot be expressed as simple cardinality rules. For example:
// At least one identifier must have system + value Patient.identifier.where(system.exists() and value.exists()).count() >= 1 // If telecom exists, it must have a value Patient.telecom.all(value.exists())
The dom-6 warning from HAPI ("A resource should have narrative") is a FHIRPath invariant defined on DomainResource: text.'div'.exists().
Where FHIRPath is used
- Profile invariants: element constraints that go beyond cardinality
- Search parameters: defines which element a search param extracts
- Questionnaires: conditional display logic (enableWhen expressions)
- FHIR Mapping Language: source/target path expressions
- CQL: Clinical Quality Language builds on FHIRPath for measure logic