Registry / analytics / fhirpathpy

fhirpathpy

JSON →
library2.2.0pypypi✓ verified 88d ago

A Python implementation of the FHIRPath specification (FHIR R4), version 2.2.0, released Feb 2024. Follows minor version bumps when the upstream FHIRPath spec changes; patch releases fix bugs. Fully typed, supports evaluating expressions against FHIR resources represented as dicts or Pydantic models.

pip install fhirpathpy
INSTALL
IMPORT
SIG · FHIRPATHPY
F
fhirpathpy
analyticspythonv2.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

evaluate
✓ from fhirpathpy import evaluate
✗ from fhirpath import evaluate
Old package name `fhirpath` was deprecated; new import is `fhirpathpy`

Evaluates a FHIRPath expression against a FHIR resource (dict) and returns a list of values.

from fhirpathpy import evaluate resource = { "resourceType": "Patient", "name": [{"family": "Doe", "given": ["John"]}], "birthDate": "1970-01-01" } # Evaluate FHIRPath expression result = evaluate(resource, "Patient.name.family") print(result) # Output: ['Doe']
Debug
Known issues
breakingIn version 2.0+, the `evaluate` function returns a list of matching nodes (each a dict with `value`, `path`, etc.) instead of raw values. Use the `result` fixture to get the 'value' field if you need the scalar.
fix
Extract values with `[match['value'] for match in result]` or use the `value` property.
affects: >=2.0.0
breakingThe `fhirpathpy.parse` function was removed in v2.0. Use `evaluate` directly.
fix
Replace `parse(fhirpath_expr).evaluate(resource)` with `evaluate(resource, expr)`.
affects: >=2.0.0
deprecatedThe `fhirpathpy` package no longer supports Python 3.9 and earlier (requires >=3.10).
fix
Upgrade Python to 3.10 or later, or pin to fhirpathpy<2.2.0 if you must stay on older Python.
affects: >=2.2.0
gotchaThe library does not support custom functions or extensions to the FHIRPath spec. If you need extensions, you must pre/post-process.
fix
Wrap the query with additional Python logic before/after evaluate() to inject custom behavior.
affects: all
Errors
Common errors & fixes
AttributeError: module 'fhirpath' has no attribute 'evaluate'
Importing the wrong package name (fhirpath instead of fhirpathpy).
fix
Install `pip install fhirpathpy` and import as `from fhirpathpy import evaluate`.
fhirpathpy.exceptions.EvaluationException: Unknown function: myCustomFunc
Trying to call a custom function not defined in the FHIRPath spec or in fhirpathpy's built-ins.
fix
Remove custom functions or implement them as Python helpers before/after evaluate().
TypeError: Object of type Patient is not JSON serializable
Passing a Pydantic model object directly instead of a dict.
fix
Use `.model_dump()` (Pydantic v2) or `.dict()` (Pydantic v1) to convert to dict before calling evaluate().
Upgrade
Version history
2.2.0latest on PyPI · released Apr 16, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
fhirpathpy — pip install fhirpathpy · libregistry