Skip to main content

FHIR Resources as Model Class

Project description

FHIR® Resources (R4, STU3, DSTU2)

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

All FHIR Resources are available as python class with built-in initial validation, exporter as json value.

  • Provides Resource Factory class (see example 4) to create resource object in more convenient way.

  • Previous version of FHIR® Resources are available.

  • Fully support for fhirclient as models.

  • Free software: BSD license

FHIR® Version Info

FHIR® (Release R4, version 4.0.1) is available as default. Also previous versions are available as Python sub-package (each release name string becomes sub-package name, i.e STU3 ).

Available Previous Versions:

  • STU3 (3.0.2)

  • DSTU2 (1.0.2)

Installation

Just a simple pip install fhir.resources or easy_install fhir.resources is enough. But if you want development version, just clone from https://github.com/nazrulworld/fhir.resources and python setup.py install.

Example: 1: Resource object created from json string:

>>> from fhir.resources.organization import Organization
>>> from fhir.resources.address import Address
>>> json_dict = {"resourceType": "Organization",
...     "id": "mmanu",
...     "active": True,
...     "name": "Acme Corporation",
...     "address": [{"country": "Swizterland"}]
... }
>>> org = Organization(json_dict)
>>> isinstance(org.address[0], Address)
>>> True
>>> org.address[0].country == "Swizterland"
True
>>> org.as_json()['active'] is True
True

Example: 2: Construct resource object in python way:

>>> org = Organization()
>>> org.id = "mmanu"
>>> org.active = True
>>> org.name = "Acme Corporation"
>>> org.address = list()
>>> address = Address()
>>> address.country = "Swizterland"
>>> org.address.append(address)
>>> org.as_json() == json_dict
True

Example: 3: Auto validation while providing wrong datatype:

>>> from fhir.resources.fhirabstractbase import FHIRValidationError
>>> try:
...     org = Organization({"id": "fmk", "address": ["i am wrong type"]})
...     raise AssertionError("Code should not come here")
... except FHIRValidationError:
...     pass

Example: 4: Using Resource Factory:

This package provides a convenient factory to create FHIR® resource, you never need to import manually each resource class.

>>> from fhir.resources.fhirelementfactory import FHIRElementFactory
>>> json_dict = {"resourceType": "Organization",
...     "id": "mmanu",
...     "active": True,
...     "name": "Acme Corporation",
...     "address": [{"country": "Swizterland"}]
... }
>>> org = FHIRElementFactory.instantiate('Organization', json_dict)
>>> org.address[0].country == "Swizterland"
True
>>> org.as_json()['active'] is True
True

Release and Version Policy

Starting from version 5.0.0 we are following our own release policy and we although follow Semantic Versioning scheme like FHIR® version. Unlike previous statement (bellow), releasing now is not dependent on FHIR®.

removed statement

This package is following FHIR® release and versioning policy, for example say, FHIR releases next version 4.0.1, we also release same version here.

Credits

All FHIR® Resources (python classes) are generated using fhir-parser which is forked from https://github.com/smart-on-fhir/fhir-parser.git.

This package skeleton was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

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

History

5.1.1 (2020-06-26)

Improvements

  • Strict flag support to FHIRElementFactory classes [mmabey]

Bugfixes

  • Fixed cyclical import that starts in BackboneElement (DSTU2) [mmabey]

5.1.0 (2020-04-11)

Improvements

5.0.1 (2019-07-18)

Bugfixes:

  • Issue#5 confusing error message “name ‘self’ is not defined” [nazrulworld]

5.0.0 (2019-06-08)

  • Nothing but release stable version.

5.0.0b3 (2019-05-14)

New features

5.0.0b2 (2019-05-13)

Breaking or Improvments

  • elementProperties: element now has extra property type_name. Now format like (name, json_name, type, type_name, is_list, "of_many", not_optional) The type_name refers original type name (code) from FHIR Structure Definition and it would be very helpful while making fhir search, fhirpath navigator.

5.0.0b1 (2019-01-19)

New features

  • Implemented own build policy, now previous version of FHIR® resources are available as python sub-package.

Build info

  • Default version is R4 (see version info at 4.0.0b1 (2019-01-13) section)

  • STU3 (see version info at 3.0.1 (2019-01-13) section)

4.0.0 (2019-01-14)

  • see version info at 4.0.0b1 section.

4.0.0b1 (2019-01-13)

Version Info (R4)

[FHIR]
FhirVersion=4.0.0-a53ec6ee1b
version=4.0.0
buildId=a53ec6ee1b
date=20181227223754

3.0.1 (2019-01-13)

Version Info (STU3)

[FHIR]
FhirVersion=3.0.1.11917
version=3.0.1
revision=11917
date=20170419074443

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.resources-5.1.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhir.resources-5.1.1-py2.py3-none-any.whl (1.8 MB view details)

Uploaded Python 2Python 3

File details

Details for the file fhir.resources-5.1.1.tar.gz.

File metadata

  • Download URL: fhir.resources-5.1.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for fhir.resources-5.1.1.tar.gz
Algorithm Hash digest
SHA256 8db64438325f238ae3abf43793ee10339e7107724b392441bdae3d963d82d0d5
MD5 8f9669e1aed012925827c3dde260d354
BLAKE2b-256 64f260abece9cd90fab361349fe44d47c024da1eac2de61f6af73823aa1f7b55

See more details on using hashes here.

File details

Details for the file fhir.resources-5.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: fhir.resources-5.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for fhir.resources-5.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1863c9d124551db3666d79cabbb39ee16205ad22f1008e0bfc50b9a481639bb6
MD5 0d72bcf65ac6a2a4b6f77e87892d68b7
BLAKE2b-256 ef99fb3000fbf7d8816c224a382b75ea85a40213f3fc97d4f212b19f7bb65315

See more details on using hashes here.

Supported by

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