fhir-core is a Python library providing an abstract base class for FHIR resource models and Primitive Datatypes, along with factories to create FHIR resource models and other complex datatypes. It is powered by Pydantic V2, ensuring data validation and efficient serialization/deserialization. This library is primarily developed to support the 'fhir.resources' library but can be used independently. As of March 2026, the current version is 1.1.7, with frequent patch releases.
Install & Compatibility
Where this runs
tested against v1.1.8 · 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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.421s · 28MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 3.2s · import 0.386s · 28MB
26MB installed
● package 26MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from fhir_core.fhirabstractmodel import FHIRAbstractModel
from fhir_core.types import IdType
from fhir_core.types import BooleanType
from fhir_core.types import StringType
This example demonstrates how to define a simple FHIR 'Organization' model inheriting from `FHIRAbstractModel` and populate it with data. It showcases the use of `fhir_core.types` for primitive FHIR data types and Pydantic's `Field` for alias and validation.
from typing import List
from pydantic import Field
from fhir_core.fhirabstractmodel import FHIRAbstractModel
from fhir_core.types import IdType, BooleanType, StringType
class Organization(FHIRAbstractModel):
resourceType: StringType = Field('Organization', const=True)
id: IdType = Field(None, alias='id')
active: BooleanType = Field(None, alias='active')
name: StringType = Field(None, alias='name')
address: List[dict] = Field(None, alias='address') # Simplified for example
data = {
"id": "f001",
"active": True,
"name": "Acme Corporation",
"address": [
{
"use": "work",
"line": ["534 Erewhon St"],
"city": "PleasantVille",
"state": "Vic",
"postalCode": "3999",
"country": "ZZ"
}
]
}
organization_instance = Organization(**data)
print(organization_instance.json(indent=2))
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.