On this page ⌄
Kotlin FHIRPath
A FHIRPath expression engine for Kotlin Multiplatform that evaluates expressions over the Kotlin FHIR data model.
What it is
Kotlin FHIRPath runs FHIRPath expressions against FHIR resources in Kotlin. It works on the resource classes from Kotlin FHIR, for FHIR R4, R4B, and R5. It runs on Android, iOS, the JVM, and the web.
FHIRPath is the expression language that FHIR uses for search parameters, invariants, and questionnaire logic. Within the KMP FHIR SDK, Kotlin FHIR Engine uses this library to index resources for search, and Kotlin FHIR Data Capture uses it for questionnaire behavior. You can also use it on its own.
What you get
- A small API. Create an engine with
FhirPathEngine.forR4()and callevaluateExpression(). - The FHIRPath specification v3.0.0 (STU3) and the FHIR-specific additions from FHIR R5. The library is tested against the official FHIR test cases.
- Quantities with units.
Quantityvalues use UCUM, so2.1 'kg' = 2100 'g'istrue. - Two error modes. By default, a property that does not exist gives an empty result. In strict mode, it throws an exception.
Artifacts
| Artifact | Contents |
|---|---|
fhir-path-r4, fhir-path-r4b, fhir-path-r5 | The engine for one FHIR version. Each one includes the matching Kotlin FHIR model. |
fhir-path | All three FHIR versions |
fhir-path-core | Shared internals. The artifacts above depend on it. You do not add it yourself. |
What it is not
- It does not call other services. There is no reference lookup, so
resolve()is not available. There is no terminology server, somemberOf()andsubsumes()are not available. - It does not check expressions before running them. Mistakes show up when you evaluate, as an empty result or an exception.
- It does not guess time zones. Comparing a date-time that has a time zone offset with one that has none gives an empty result.
How this documentation is organized
| Page | Use it to |
|---|---|
| Get started | Add the library and evaluate your first expression |
| How evaluation works | Understand result types, empty results, dates, and quantities |
| Evaluate expressions | Pass variables, read results, and evaluate search parameters |
| Debug expressions | Find out why an expression returns the wrong result |
| Conformance | Check which functions and operators are supported |
| Troubleshooting | Look up an error message and its fix |
Next step
Get started adds the library and evaluates an expression.