{"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":"python","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,"search_vec":"'1.1.7':70 '2026':65 'abstract':13 'along':23 'base':14 'class':15 'complex':33 'core':2,6 'creat':27 'current':67 'data':42,80 'data-model':79 'datatyp':22,34 'develop':51 'effici':45 'ensur':41 'factori':25 'fhir':1,5,17,28,75 'fhir-cor':4 'fhir.resources':55 'frequent':72 'health':83 'health-it':82 'healthcar':76 'hl7':77 'independ':61 'librari':3,10,48,56 'march':64 'model':19,30,81 'patch':73 'power':37 'primarili':50 'primit':21 'provid':11 'pydant':39,78 'python':9 'releas':74 'resourc':18,29 'serialization/deserialization':46 'support':53 'use':60 'v2':40 'valid':43 'version':68","created_at":"2026-04-14T01:24:36.892432+00:00","updated_at":"2026-04-16T15:00:29.204506+00:00","problems":[{"fix":"Install the package using pip: `pip install fhir-core`","cause":"The `fhir-core` package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'fhir_core'"},{"fix":"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.","cause":"This error typically occurs when `fhir-core` (or a library depending on it like `fhir.resources`) is used with an incompatible version of Pydantic, specifically when Pydantic v1 code attempts to run in a Pydantic v2 environment due to breaking changes in Pydantic's API. `fhir-core` is powered by Pydantic V2.","error":"ImportError: cannot import name 'ROOT_VALIDATOR_CONFIG_KEY' from 'pydantic.class_validators'"},{"fix":"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.","cause":"This error occurs when data provided to construct a FHIR resource model (which is built using Pydantic V2 by `fhir-core`) does not conform to the FHIR specification or the Pydantic model's defined schema. This could be due to missing required fields, incorrect data types, or invalid values for specific fields.","error":"pydantic.ValidationError"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.10","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/nazrulworld/fhir-core","docs":null,"changelog":null,"pypi":"https://pypi.org/project/fhir-core/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}