Skip to main content

FHIR Resources as Model Class

Project description

FHIR® Resources (R4) HL7® FHIR®

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


Just a simple pip install fhir.resources or easy_install fhir.resources is enough. But if you want development version, just clone from and python 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"
>>> org.as_json()['active'] is True

Example: 2: Construct resource object in python way:

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

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

Release and Version Policy

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.


All FHIR® Resources (python classes) are generated using fhir-parser.

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


4.0.0b1 (2019-01-13)

Version Info (R4)


3.0.1 (2019-01-13)

Version Info (STU3)


Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
fhir.resources-4.0.0b1-py2.py3-none-any.whl (685.3 kB) Copy SHA256 hash SHA256 Wheel py2.py3
fhir.resources-4.0.0b1.tar.gz (406.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page