{"id":5225,"library":"fhir-core","title":"FHIR Core Library","description":"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.","status":"active","version":"1.1.7","language":"en","source_language":"en","source_url":"https://github.com/nazrulworld/fhir-core","tags":["fhir","healthcare","hl7","pydantic","data-modeling","health-it"],"install":[{"cmd":"pip install fhir-core","lang":"bash","label":"Install stable version"},{"cmd":"git clone https://github.com/nazrulworld/fhir-core.git && cd fhir-core && pip install -e .[dev]","lang":"bash","label":"Install development version"}],"dependencies":[{"reason":"The library leverages Pydantic V2 for data validation, serialization, and deserialization.","package":"pydantic>=2","optional":false},{"reason":"This library is developed to support fhir.resources, which provides generated Python classes for all FHIR Resources.","package":"fhir.resources","optional":true}],"imports":[{"symbol":"FHIRAbstractModel","correct":"from fhir_core.fhirabstractmodel import FHIRAbstractModel"},{"symbol":"IdType","correct":"from fhir_core.types import IdType"},{"symbol":"BooleanType","correct":"from fhir_core.types import BooleanType"},{"symbol":"StringType","correct":"from fhir_core.types import StringType"}],"quickstart":{"code":"from typing import List\nfrom pydantic import Field\nfrom fhir_core.fhirabstractmodel import FHIRAbstractModel\nfrom fhir_core.types import IdType, BooleanType, StringType\n\nclass Organization(FHIRAbstractModel):\n    resourceType: StringType = Field('Organization', const=True)\n    id: IdType = Field(None, alias='id')\n    active: BooleanType = Field(None, alias='active')\n    name: StringType = Field(None, alias='name')\n    address: List[dict] = Field(None, alias='address') # Simplified for example\n\ndata = {\n    \"id\": \"f001\",\n    \"active\": True,\n    \"name\": \"Acme Corporation\",\n    \"address\": [\n        {\n            \"use\": \"work\",\n            \"line\": [\"534 Erewhon St\"],\n            \"city\": \"PleasantVille\",\n            \"state\": \"Vic\",\n            \"postalCode\": \"3999\",\n            \"country\": \"ZZ\"\n        }\n    ]\n}\n\norganization_instance = Organization(**data)\n\nprint(organization_instance.json(indent=2))","lang":"python","description":"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."},"warnings":[{"fix":"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`.","message":"Between fhir-core 0.x and 1.x (and consequently fhir.resources <8.0.0 and >=8.0.0), there were significant breaking changes in the base model class and its methods. `FHIRAbstractBase` was replaced by `FHIRAbstractModel`. Methods like `__init__`, `parse_obj`, `as_json`, and `dict` had their signatures or behavior altered.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"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.","message":"fhir-core is developed by 'nazrulworld'. Be aware that other Python libraries with similar names exist (e.g., `google-fhir-core`, `fhir-py`, `fhirclient`), which serve different purposes or are maintained by different entities. Ensure you are importing from `fhir_core` (with an underscore).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade Pydantic to version 2 or greater (`pip install 'pydantic>=2'`). Review Pydantic V1 to V2 migration guides if you have existing Pydantic models.","message":"fhir-core relies on Pydantic V2. If your project uses Pydantic V1, there will be incompatibilities. Ensure your environment is set up with Pydantic V2 or later.","severity":"breaking","affected_versions":"All versions"},{"fix":"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.","message":"The `fhir.resources` library, which `fhir-core` supports, has minimum version requirements for `fhir-core`. For instance, `fhir.resources` 8.0.0 requires `fhir-core` 1.0.0, and `fhir.resources` 8.2.0 requires `fhir-core` 1.1.5. Incompatible versions between the two libraries can lead to runtime errors.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}