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.
pip install fhir-coreVerified import paths — ran on the pinned version, not inferred.
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.
Update your code to use `FHIRAbstractModel` as the base class. Review and adapt calls to `parse_obj` (now a classmethod), and prefer `model_dump()` or `model_dump_json()` from Pydantic V2 for serialization instead of `as_json` or `dict`.
Always verify the `pypi-slug` and `source_url` to confirm you are using the correct library. Use `pip install fhir-core` for this specific library.
Upgrade Pydantic to version 2 or greater (`pip install 'pydantic>=2'`). Review Pydantic V1 to V2 migration guides if you have existing Pydantic models.
Always ensure that the `fhir-core` version installed meets or exceeds the minimum requirement specified by your `fhir.resources` version. Check the release notes or `install_requires` of `fhir.resources` for compatibility.
Install the package using pip: `pip install fhir-core`
Ensure that all libraries in your environment are compatible with Pydantic V2. If you are using `fhir.resources`, make sure you have a version compatible with `fhir-core`'s Pydantic V2 dependency (e.g., `fhir.resources` version 8.0.0 or higher). If other dependencies require Pydantic V1, you might need to isolate environments or update those dependencies.
Inspect the error details provided by Pydantic (e.g., `pydantic.ValidationError.errors()`) to identify which specific fields have validation issues. Adjust the input data to match the expected FHIR structure, data types, and constraints defined by the `fhir-core` models.