Python library for FHIR (Fast Healthcare Interoperability Resources) providing Pydantic-based models for all FHIR resource types. Supports FHIR R4, R4B, R5, STU3, and DSTU2. Built on Pydantic v2 for validation, serialization, and deserialization of FHIR JSON. Current version targets FHIR R5 by default with backwards-compatible imports for older FHIR versions.
Install & Compatibility
Where this runs
tested against v8.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
51MB installed
● package 51MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
The package uses a namespace package 'fhir.resources'. Each resource type is in its own module with a lowercase name.
from fhir.resources.patient import Patient
To use FHIR R4B resources, import from fhir.resources.R4B subpackage. Default top-level imports are R5.
from fhir.resources.R4B.patient import Patient
STU3 resources live under the fhir.resources.STU3 subpackage.
from fhir.resources.STU3.patient import Patient
Each FHIR resource is its own module. Import the class with the CamelCase name from the lowercase module.
from fhir.resources.bundle import Bundle
Create, validate, and serialize a FHIR Patient resource using Pydantic v2 methods.
from fhir.resources.patient import Patient
# Create from dict
patient_data = {
"resourceType": "Patient",
"id": "example",
"active": True,
"name": [
{
"use": "official",
"family": "Doe",
"given": ["John"]
}
],
"gender": "male",
"birthDate": "1990-01-01"
}
patient = Patient.model_validate(patient_data)
print(patient.name[0].family) # 'Doe'
# Serialize back to FHIR JSON
print(patient.model_dump_json(indent=2))
# Parse from JSON string
json_str = patient.model_dump_json()
patient2 = Patient.model_validate_json(json_str)
print(patient2.id) # 'example'
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.