Skip to main content

FHIR Core library

Project description

FHIR® Core

https://img.shields.io/pypi/v/fhir-core.svg Supported Python Versions https://img.shields.io/travis/com/nazrulworld/fhir-core.svg Windows Build https://codecov.io/gh/nazrulworld/fhir.resources/branch/master/graph/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg Downloads HL7® FHIR®

Powered by Pydantic V2. This library is developed for the support of the another libray fhir.resources but you are more than welcome to use it for your own purpose. It provides an abstract base class for any FHIR resource model and Primitive Datatypes along with factories to create FHIR resource model and other complex datatypes.

Installation

Just a simple pip install fhir-core. But if you want development version, just clone from https://github.com/nazrulworld/fhir-core and pip install -e .[dev].

Usages

Example: 1: This example creates an Organization class with some of its attributes (id, active, name, address):

>>> from typing import List
>>> from pydantic import Field
>>> from fhir_core.fhirabstractmodel import FHIRAbstractModel
>>> from fhir_core.types import IdType, BooleanType, StringType
>>> data = {
...     "id": "f001",
...     "active": True,
...     "name": "Acme Corporation",
...     "address": ["Road 10": "Acme corporation", "2390", "USA"}]
... }
>>> class Organization(FHIRAbstractModel):
...     __resource_type__ = "Organization"
...     id: IdType = Field(None, title="Id", alias="id", json_schema_extra={"element_property": True})
...     active: BooleanType = Field(None, title="Active", alias="active", json_schema_extra={"element_property": True})
...     name: StringType = Field(None, title="Name", alias="name", json_schema_extra={"element_property": True})
...     address: ListType[StringType] = Field(None, title="Address lines", alias="address", json_schema_extra={"element_property": True})
...
...     @classmethod
        def elements_sequence(cls):
            return ["id", "active", "name", "address"]
...
>>> org = Organization.model_validate(data)
>>> org.active is True
True
>>> org_json_str = org.model_dump_json()
>>> Organization.model_validate_json(org_json_str).model_dump() == org.model_dump()
True

Complex examples

  1. https://github.com/nazrulworld/fhir-core/blob/main/tests/fixtures/resources/extension.py

  2. https://github.com/nazrulworld/fhir-core/blob/main/tests/fixtures/resources/fhirtypes.py

  3. https://github.com/nazrulworld/fhir-core/blob/main/tests/fixtures/resources/codesystem.py

© Copyright HL7® logo, FHIR® logo and the flaming fire are registered trademarks owned by Health Level Seven International

History

0.1.1 (2024-10-09)

  • Version policy updated, now .bx suffix has been removed.

Fixes

  • Business logic for None type validation against FHIR Model validator as None value is acceptable! Instead, you should make Pydantic field optional.

0.1.0b9 (2024-10-02)

Fixes

0.1.0b8 (2024-08-04)

  • YAML dump & validate options are added into FHIRAbstractModel.

0.1.0b7 (2024-07-31)

  • typing hint added for the function ´´create_fhir_type´´ and ´´create_fhir_element_or_resource_type´´.

0.1.0b6 (2024-07-30)

  • Core configurations for types Id & String are coming from constraint module.

  • Default maximum char length Id is now 255.

0.1.0b5 (2024-07-28)

  • Fixes the function that is checking is_primitive, as missing bytes and bytesarray are added.

  • Encoding is handled for Base64Binary type.

0.1.0b4 (2024-07-28)

  • Fixes extension serialization.

0.1.0b3 (2024-07-28)

  • Fixes the function that is checking is_primitive.

  • Fixes validator for Resource & Element types.

0.1.0b2 (2024-07-27)

Bugfixes

  • Fixes pattern as string for some of primitives types. fx UriType.

  • Fixes model serializer.

0.1.0b1 (2024-07-26)

  • The first beta release! and this release is not stable enough to use in production.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fhir_core-0.1.1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

fhir_core-0.1.1-py2.py3-none-any.whl (21.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fhir_core-0.1.1.tar.gz.

File metadata

  • Download URL: fhir_core-0.1.1.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for fhir_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff563d0737b8f14efef0cd7200260aeb45de496cc8f4a0dc2c36e9d54b36bf87
MD5 ed9120fb208031accdf439bdaa11bd6c
BLAKE2b-256 a830dcf0b70a9acb7616b7213b174f7dbaa47d11e0d8b5814f93c68233121056

See more details on using hashes here.

File details

Details for the file fhir_core-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: fhir_core-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for fhir_core-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 15151cd910291acce3510234df17f1d80d72acaa4c31914c1d8c8f152f4fde32
MD5 da07d7d91af75700a75f0539f1fa9cc9
BLAKE2b-256 f92538461eacf97744f1b6bbec8618782aac40c50a8cbc56796326025ae1e758

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page