======================================
FHIR® Resources (R5, R4B, STU3, DSTU2)
======================================
.. image:: https://img.shields.io/pypi/v/fhir.resources.svg
:target: https://pypi.python.org/pypi/fhir.resources
.. image:: https://img.shields.io/pypi/pyversions/fhir.resources.svg
:target: https://pypi.python.org/pypi/fhir.resources
:alt: Supported Python Versions
.. image:: https://img.shields.io/travis/com/nazrulworld/fhir.resources.svg
:target: https://app.travis-ci.com/github/nazrulworld/fhir.resources
.. image:: https://ci.appveyor.com/api/projects/status/0qu5vyue1jwxb4km?svg=true
:target: https://ci.appveyor.com/project/nazrulworld/fhir-resources
:alt: Windows Build
.. image:: https://codecov.io/gh/nazrulworld/fhir.resources/branch/master/graph/badge.svg
:target: https://codecov.io/gh/nazrulworld/fhir.resources
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
.. image:: https://static.pepy.tech/personalized-badge/fhir-resources?period=total&units=international_system&left_color=black&right_color=green&left_text=Downloads
:target: https://pepy.tech/project/fhir-resources
:alt: Downloads
.. image:: https://www.hl7.org/fhir/assets/images/fhir-logo-www.png
:target: https://www.hl7.org/implement/standards/product_brief.cfm?product_id=449
:alt: HL7® FHIR®
FHIR_ (Fast Healthcare Interoperability Resources) is a specification for exchanging healthcare information electronically.
It is designed to facilitate the exchange of data between different healthcare systems and applications, and is commonly used to build APIs (Application Programming Interfaces) for healthcare data.
It is based on modern web technologies, and is designed to be easy to use and implement.
It uses a modular approach, with a set of "resources" that represent different types of healthcare data (such as patients, observations, and diagnoses).
These resources can be combined and extended as needed to support a wide range of healthcare use cases.
This "fhir.resources" package is powered by pydantic_ so faster in performance and optionally ``orjson`` support has been included as a performance booster!
Obviously it is written in modern python and has data validation built-in.
It provides tools and classes for all of the `FHIR Resources <https://www.hl7.org/fhir/resourcelist.html>`_ defined in the FHIR specification,
and allows you to create and manipulate FHIR resources in Python. You can then use these resources to build FHIR-based APIs or to work with FHIR data in other ways.
* Easy to construct, easy to extended validation, easy to export.
* By inheriting behaviour from pydantic_, compatible with `ORM <https://en.wikipedia.org/wiki/Object-relational_mapping>`_.
* Full support of FHIR® Extensibility for Primitive Data Types are available.
* Previous release of FHIR® Resources are available.
* Free software: BSD license
**Experimental XML and YAML serialization and deserialization supports. See [Advanced Usages] section!**
FHIR® Version Info
------------------
FHIR® (Release R5, version 5.0.0) is available as default. Also previous versions are available as Python sub-package
(each release name string becomes sub-package name, i.e ``R4B`` ).
From ``fhir.resources`` version 7.0.0; there is no FHIR ``R4`` instead of ``R4B`` is available as sub-package.
**Available Previous Versions**:
* ``R4B`` (4.3.0)
* ``STU3`` (3.0.2)
* ``DSTU2`` (1.0.2) [see `issue#13 <https://github.com/nazrulworld/fhir.resources/issues/13>`_][don't have full tests coverage]
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 ``pip install -e .[dev]``.
Usages
------
**Example: 1**: This example creates a new Organization resource with some of its attributes (id, active, name, address)::
>>> from fhir.resources.organization import Organization
>>> from fhir.resources.address import Address
>>> data = {
... "id": "f001",
... "active": True,
... "name": "Acme Corporation",
... "address": [{"country": "Switzerland"}]
... }
>>> org = Organization(**data)
>>> org.resource_type == "Organization"
True
>>> isinstance(org.address[0], Address)
True
>>> org.address[0].country == "Switzerland"
True
>>> org.dict()['active'] is True
True
**Example: 2**: This example creates a new Organization resource from json string::
>>> from fhir.resources.organization import Organization
>>> from fhir.resources.address import Address
>>> json_str = '''{"resourceType": "Organization",
... "id": "f001",
... "active": True,
... "name": "Acme Corporation",
... "address": [{"country": "Switzerland"}]
... }'''
>>> org = Organization.parse_raw(json_str)
>>> isinstance(org.address[0], Address)
True
>>> org.address[0].country == "Switzerland"
True
>>> org.dict()['active'] is True
True
**Example: 3**: This example creates a new Patient resource from json object(py dict)::
>>> from fhir.resources.patient import Patient
>>> from fhir.resources.humanname import HumanName
>>> from datetime import date
>>> json_obj = {"resourceType": "Patient",
... "id": "p001",
... "active": True,
... "name": [
... {"text": "Adam Smith"}
... ],
... "birthDate": "1985-06-12"
... }
>>> pat = Patient.parse_obj(json_obj)
>>> isinstance(pat.name[0], HumanName)
True
>>> pat.birthDate == date(year=1985, month=6, day=12)
True
>>> pat.active is True
True
**Example: 4**: This example creates a new Patient resource from json file::
>>> from fhir.resources.patient import Patient
>>> import os
>>> import pathlib
>>> filename = pathlib.Path("foo/bar.json")
>>> pat = Patient.parse_file(filename)
>>> pat.resource_type == "Patient"
True
**Example: 5**: This example creates a new Organization resource in python way::
>>> from fhir.resources.organization import Organization
>>> from fhir.resources.address import Address
>>> json_obj = {"resourceType": "Organization",
... "id": "f001",
... "active": True,
... "name": "Acme Corporation",
... "address": [{"country": "Switzerland"}]
... }
>>> org = Organization.construct()
>>> org.id = "f001"
>>> org.active = True
>>> org.name = "Acme Corporation"
>>> org.address = list()
>>> address = Address.construct()
>>> address.country = "Switzerland"
>>> org.address.append(address)
>>> org.dict() == json_obj
True
.. note::
Please note that due to the way the validation works, you will run into issues if you are using ``construct()`` to create
resources that have more than one mandatory field. See `this comment in issue#56 <https://github.com/nazrulworld/fhir.resources/issues/56#issuecomment-784520234>`_ for details.
**Example: 4**: This example creates a new Organization resource using Resource Factory Function::
>>> from fhir.resources import construct_fhir_element
>>> json_dict = {"resourceType": "Organization",
... "id": "mmanu",
... "active": True,
... "name": "Acme Corporation",
... "address": [{"country": "Switzerland"}]
... }
>>> org = construct_fhir_element('Organization', json_dict)
>>> org.address[0].country == "Switzerland"
True
>>> org.dict()['active'] is True
True
**Example: 5**: Auto validation while providing wrong datatype::
>>> try:
... org = Organization({"id": "fmk", "address": ["i am wrong type"]})
... raise AssertionError("Code should not come here")
... except ValueError:
... pass
Advanced Usages
---------------
FHIR Comments (JSON)
~~~~~~~~~~~~~~~~~~~~
It is possible to add comments inside json like xml, but need to follow some convention, what is suggested by `Grahame Grieve <http://www.healthintersections.com.au/?p=2569>`_;
is implemented here.
Also it is possible to generate json string output without comments.
Examples::
>>> observation_str = b"""{
... "resourceType": "Observation",
... "id": "f001",
... "fhir_comments": [
... " a specimen identifier - e.g. assigned when the specimen was taken by the orderer/placer use the accession number for the filling lab ",
... " Placer ID "
... ],
... "text": {
... "fhir_comments": [
... " a specimen identifier - e.g. assigned when the specimen was taken by the orderer/placer use the accession number for the filling lab ",
... " Placer ID "
... ],
... "status": "generated",
... "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">.........</div>"
... },
... "identifier": [
... {
... "use": "official",
... "system": "http://www.bmc.nl/zorgportal/identifiers/observations",
... "value": "6323"
... }
... ],
... "status": "final",
... "_status": {
... "fhir_comments": [
... " EH: Note to balloters - lots of choices for whole blood I chose this. "
... ]
... },
... "code": {
... "coding": [
... {
... "system": "http://loinc.org",
... "code": "15074-8",
... "display": "Glucose [Moles/volume] in Blood"
... }
... ]
... },
... "subject": {
... "reference": "Patient/f001",
... "display": "P. van de Heuvel"
... },
... "effectivePeriod": {
... "start": "2013-04-02T09:30:10+01:00"
... },
... "issued": "2013-04-03T15:30:10+01:00",
... "performer": [
... {
... "reference": "Practitioner/f005",
... "display": "A. Langeveld"
... }
... ],
... "valueQuantity": {
... "value": 6.3,
... "unit": "mmol/l",
... "system": "http://unitsofmeasure.org",
... "code": "mmol/L"
... },
... "interpretation": [
... {
... "coding": [
... {
... "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
... "code": "H",
... "display": "High"
... }
... ]
... }
... ],
... "referenceRange": [
... {
... "low": {
... "value": 3.1,
... "unit": "mmol/l",
... "system": "http://unitsofmeasure.org",
... "code": "mmol/L"
... },
... "high": {
... "value": 6.2,
... "unit": "mmol/l",
... "system": "http://unitsofmeasure.org",
... "code": "mmol/L"
... }
... }
... ]
... }"""
>>> from fhir.resources.observation import Observation
>>> obj = Observation.parse_raw(observation_str)
>>> "fhir_comments" in obj.json()
>>> # Test comments filtering
>>> "fhir_comments" not in obj.json(exclude_comments=True)
Special Case: Missing data
~~~~~~~~~~~~~~~~~~~~~~~~~~
`In some cases <https://www.hl7.org/fhir/extensibility.html#Special-Case>`_, implementers might
find that they do not have appropriate data for an element with minimum cardinality = 1.
In this case, the element must be present, but unless the resource or a profile on it has made the
actual value of the primitive data type mandatory, it is possible to provide an extension that
explains why the primitive value is not present.
Example (required ``intent`` element is missing but still valid because of extension)::
>>> json_str = b"""{
... "resourceType": "MedicationRequest",
... "id": "1620518",
... "meta": {
... "versionId": "1",
... "lastUpdated": "2020-10-27T11:04:42.215+00:00",
... "source": "#z072VeAlQWM94jpc",
... "tag": [
... {
... "system": "http://www.alpha.alp/use-case",
... "code": "EX20"
... }
... ]
... },
... "status": "completed",
... "_intent": {
... "extension": [
... {
... "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason",
... "valueCode": "unknown"
... }
... ]
... },
... "medicationReference": {
... "reference": "Medication/1620516",
... "display": "Erythromycin 250 MG Oral Tablet"
... },
... "subject": {
... "reference": "Patient/1620472"
... },
... "encounter": {
... "reference": "Encounter/1620506",
... "display": "Follow up encounter"
... },
... "authoredOn": "2018-06-16",
... "requester": {
... "reference": "Practitioner/1620502",
... "display": "Dr. Harold Hippocrates"
... },
... "reasonReference": [
... {
... "reference": "Condition/1620514",
... "display": "Otitis Media"
... }
... ],
... "dosageInstruction": [
... {
... "text": "250 mg 4 times per day for 10 days",
... "timing": {
... "repeat": {
... "boundsDuration": {
... "value": 10,
... "unit": "day",
... "system": "http://unitsofmeasure.org",
... "code": "d"
... },
... "frequency": 4,
... "period": 1,
... "periodUnit": "d"
... }
... },
... "doseAndRate": [
... {
... "doseQuantity": {
... "value": 250,
... "unit": "mg",
... "system": "http://unitsofmeasure.org",
... "code": "mg"
... }
... }
... ]
... }
... ],
... "priorPrescription": {
... "reference": "MedicationRequest/1620517",
... "display": "Amoxicillin prescription"
... }
... }"""
>>> from fhir.resources.medicationrequest import MedicationRequest
>>> obj = MedicationRequest.parse_raw(json_str)
>>> "intent" not in obj.dict()
Custom Validators
~~~~~~~~~~~~~~~~~
``fhir.resources`` is providing the extensive API to create and attach custom validator into any model. See more `about root validator <https://pydantic-docs.helpmanual.io/usage/validators/#root-validators>`_
Some convention you have to follow though, while creating a root validator.
1. Number of arguments are fixed, as well as names are also. i.e ``(cls, values)``.
2. Should return ``values``, unless any exception need to be raised.
3. Validator should be attached only one time for individual Model. Update [from now, it's not possible to attach multiple time same name validator on same class]
Example 1: Validator for Patient::
from typing import Dict
from fhir.resources.patient import Patient
import datetime
def validate_birthdate(cls, values: Dict):
if not values:
return values
if "birthDate" not in values:
raise ValueError("Patient's ``birthDate`` is required.")
minimum_date = datetime.date(2002, 1, 1)
if values["birthDate"] > minimum_date:
raise ValueError("Minimum 18 years patient is allowed to use this system.")
return values
# we want this validator to execute after data evaluating by individual field validators.
Patient.add_root_validator(validate_gender, pre=False)
Example 2: Validator for Patient from Validator Class::
from typing import Dict
from fhir.resources.patient import Patient
import datetime
class MyValidator:
@classmethod
def validate_birthdate(cls, values: Dict):
if not values:
return values
if "birthDate" not in values:
raise ValueError("Patient's ``birthDate`` is required.")
minimum_date = datetime.date(2002, 1, 1)
if values["birthDate"] > minimum_date:
raise ValueError("Minimum 18 years patient is allowed to use this system.")
return values
# we want this validator to execute after data evaluating by individual field validators.
Patient.add_root_validator(MyValidator.validate_gender, pre=False)
**important notes** It is possible add root validator into any base class like ``DomainResource``.
In this case you have to make sure root validator is attached before any import of derived class, other
than validator will not trigger for successor class (if imported before) by nature.
ENUM Validator
~~~~~~~~~~~~~~
``fhir.resources`` is providing API for enum constraint for each field (where applicable), but it-self doesn't
enforce enum based validation! see `discussion here <https://github.com/nazrulworld/fhir.resources/issues/23>`_.
If you want to enforce enum constraint, you have to create a validator for that.
Example: Gender Enum::
from typing import Dict
from fhir.resources.patient import Patient
def validate_gender(cls, values: Dict):
if not values:
return values
enums = cls.__fields__["gender"].field_info.extra["enum_values"]
if "gender" in values and values["gender"] not in enums:
raise ValueError("write your message")
return values
Patient.add_root_validator(validate_gender, pre=True)
Reference Validator
~~~~~~~~~~~~~~~~~~~
``fhir.resources`` is also providing enum like list of permitted resource types through field property ``enum_reference_types``.
You can get that list by following above (Enum) approaches ``resource_types = cls.__fields__["managingOrganization"].field_info.extra["enum_reference_types"]``
Usages of orjson
~~~~~~~~~~~~~~~~
orjson_ is one of the fastest Python library for JSON and is more correct than the standard json library (according to their docs).
Good news is that ``fhir.resource`` has an extensive support for orjson_ and it's too easy to enable it automatically. What you need to do, just make orjson_ as your project dependency!
pydantic_ Field Type Support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All available fhir resources (types) can be use as pydantic_'s Field's value types. See issue#46 `Support for FastAPI pydantic response models <https://github.com/nazrulworld/fhir.resources/issues/46>`_.
The module ``fhirtypes.py`` contains all fhir resources related types and should trigger validator automatically.
``Resource.id aka fhirtypes.Id`` constraint extensibility
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are a lots of discussion here here i.) https://bit.ly/360HksL ii.) https://bit.ly/3o1fZgl about the length of ``Resource.Id``'s value.
Based on those discussions, we recommend that keep your ``Resource.Id`` size within 64 letters (for the seek of intercompatibility with third party system), but we are also providing freedom
about the length of Id, in respect with others opinion that 64 chr length is not sufficient. ``fhirtypes.Id.configure_constraints()``
is offering to customize as your own requirement.
Examples::
>>> from fhir.resources.fhirtypes import Id
>>> Id.configure_constraints(min_length=16, max_length=128)
Note: when you will change that behaviour, that would impact into your whole project.
XML Supports
~~~~~~~~~~~~
Along side with JSON string export, it is possible to export as XML string!
Before using this feature, make sure associated dependent library is installed. Use ``fhir.resources[xml]`` or ``fhir.resources[all]`` as
your project requirements.
**XML schema validator!**
It is possible to provide custom xmlparser, during load from file or string, meaning that you can validate
data against FHIR xml schema(and/or your custom schema).
Example-1 Export::
>>> from fhir.resources.patient import Patient
>>> data = {"active": True, "gender": "male", "birthDate": "2000-09-18", "name": [{"text": "Primal Kons"}]}
>>> patient_obj = Patient(**data)
>>> xml_str = patient_obj.xml(pretty_print=True)
>>> print(xml_str)
<?xml version='1.0' encoding='utf-8'?>
<Patient xmlns="http://hl7.org/fhir">
<active value="true"/>
<name>
<text value="Primal Kons"/>
</name>
<gender value="male"/>
<birthDate value="2000-09-18"/>
</Patient>
Example-2 Import from string::
>>> from fhir.resources.patient import Patient
>>> data = {"active": True, "gender": "male", "birthDate": "2000-09-18", "name": [{"text": "Primal Kons"}]}
>>> patient_obj = Patient(**data)
>>> xml_str = patient_obj.xml(pretty_print=True)
>>> print(xml_str)
>>> data = b"""<?xml version='1.0' encoding='utf-8'?>
... <Patient xmlns="http://hl7.org/fhir">
... <active value="true"/>
... <name>
... <text value="Primal Kons"/>
... </name>
... <gender value="male"/>
... <birthDate value="2000-09-18"/>
... </Patient>"""
>>> patient = Patient.parse_raw(data, content_type="text/xml")
>>> print(patient.json(indent=2))
{
"resourceType": "Patient",
"active": true,
"name": [
{
"text": "Primal Kons",
"family": "Kons",
"given": [
"Primal"
]
}
],
"gender": "male",
"birthDate": "2000-09-18"
}
>>> with xml parser
>>> import lxml
>>> schema = lxml.etree.XMLSchema(file=str(FHIR_XSD_DIR / "patient.xsd"))
>>> xmlparser = lxml.etree.XMLParser(schema=schema)
>>> patient2 = Patient.parse_raw(data, content_type="text/xml", xmlparser=xmlparser)
>>> patient2 == patient
True
Example-3 Import from file::
>>> patient3 = Patient.parse_file("Patient.xml")
>>> patient3 == patient and patient3 == patient2
True
**XML FAQ**
- Although generated XML is validated against ``FHIR/patient.xsd`` and ``FHIR/observation.xsd`` in tests, but we suggest you check output of your production data.
- Comment feature is included, but we recommend you check in your complex usages.
YAML Supports
~~~~~~~~~~~~~
Although there is no official support for YAML documented in FHIR specification, but as an experimental feature, we add this support.
Now it is possible export/import YAML strings.
Before using this feature, make sure associated dependent library is installed. Use ``fhir.resources[yaml]`` or ``fhir.resources[all]`` as
your project requirements.
Example-1 Export::
>>> from fhir.resources.patient import Patient
>>> data = {"active": True, "gender": "male", "birthDate": "2000-09-18", "name": [{"text": "Primal Kons", "family": "Kons", "given": ["Primal"]}]}
>>> patient_obj = Patient(**data)
>>> yml_str = patient_obj.yaml(indent=True)
>>> print(yml_str)
resourceType: Patient
active: true
name:
- text: Primal Kons
family: Kons
given:
- Primal
gender: male
birthDate: 2000-09-18
Example-2 Import from YAML string::
>>> from fhir.resources.patient import Patient
>>> data = b"""
... resourceType: Patient
... active: true
... name:
... - text: Primal Kons
... family: Kons
... given:
... - Primal
... gender: male
... birthDate: 2000-09-18
... """
>>> patient_obj = Patient.parse_raw(data, content_type="text/yaml")
>>> json_str = patient_obj.json(indent=True)
>>> print(json_str)
{
"resourceType": "Patient",
"active": true,
"name": [
{
"text": "Primal Kons",
"family": "Kons",
"given": [
"Primal"
]
}
],
"gender": "male",
"birthDate": "2000-09-18"
}
Example-3 Import from YAML file::
>>> from fhir.resources.patient import Patient
>>> patient_obj = Patient.parse_file("Patient.yml")
>>> json_str = patient_obj.json(indent=True)
>>> print(json_str)
{
"resourceType": "Patient",
"active": true,
"name": [
{
"text": "Primal Kons",
"family": "Kons",
"given": [
"Primal"
]
}
],
"gender": "male",
"birthDate": "2000-09-18"
}
**YAML FAQ**
- We are using https://pyyaml.org/ PyYAML library, for serialization/deserialization but if we find more faster library, we could use that. you are welcome to provide us your suggestion.
- YAML based comments is not supported yet, instead json comments syntax is used! Of course this comment feature is in our todo list.
Allow Empty String
~~~~~~~~~~~~~~~~~~
Although this is not good practice to allow empty string value against FHIR primitive data type ``String``. But
we in real life scenario, is it unavoidable sometimes.
Examples::
Place this code inside your __init__.py module or any place, just to make sure that this fragment of codes is runtime executed.
>>> from fhir.resources.fhirtypes import String
>>> String.configure_empty_str(allow=True)
FHIR release R4B over R4
------------------------
FHIR release R4B is coming with not that much changes over the release of R4. So we decided not to create separate sub-package for R4 like STU3, instead there just overlaps on existing R4. This also means that in future, when we will work on R5; there will be sub-package for R4B and no R4.
We suggest you to try make a plan to be upgraded to R4B. Here you could find related information dealing-strategy-R4-R4B_.
You could find full discussion here https://github.com/nazrulworld/fhir.resources/discussions/116
Migration (from ``6.X.X`` to ``7.0.X``)
---------------------------------------
First of all, you have to correct all imports path, if you wish to keep continue using FHIR release R4B or R4, as those resources
are moved under sub-package named ``R4B``. Then if you wish to use current ``R5`` release,
read carefully the following documents.
1. See the full changes history -> https://build.fhir.org/history.html
2. See complete lists of differences between R5 and R4B -> https://hl7.org/fhir/R5/diff.html
3. If you are planning to migrate direct from the release ``R4``,
then it is important to look at the differences between R4B and R4 here -> https://hl7.org/fhir/R4B/diff.html
Migration (from later than ``6.X.X``)
-------------------------------------
This migration guide states some underlying changes of ``API`` and replacement, those are commonly used from later than ``6.X.X`` version.
``fhir.resources.fhirelementfactory.FHIRElementFactory::instantiate``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Replacement:** ``fhir.resources.construct_fhir_element``
- First parameter value is same as previous, the Resource name.
- Second parameter is more flexible than previous! it is possible to provide not only json ``dict`` but also
json string or json file path.
- No third parameter, what was in previous version.
``fhir.resources.fhirabstractbase.FHIRAbstractBase::__init__``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Replacement:** ``fhir.resources.fhirabstractmodel.FHIRAbstractModel::parse_obj<classmethod>``
- First parameter value is same as previous, json dict.
- No second parameter, what was in previous version.
``fhir.resources.fhirabstractbase.FHIRAbstractBase::as_json``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Replacement:** ``fhir.resources.fhirabstractmodel.FHIRAbstractModel::dict``
- Output are almost same previous, but there has some difference in case of some date type, for example py date,
datetime, Decimal are in object representation.
- It is possible to use ``fhir.resources.fhirabstractmodel.FHIRAbstractModel::json`` as replacement, when
json string is required (so not need further, json dumps from dict)
Note:
All resources/classes are derived from ``fhir.resources.fhirabstractmodel.FHIRAbstractModel`` what was previously
from ``fhir.resources.fhirabstractbase.FHIRAbstractBase``.
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 <https://www.hl7.org/fhir/versions.html>`_, 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.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`fhir-parser`: https://github.com/nazrulworld/fhir-parser
.. _`pydantic`: https://pydantic-docs.helpmanual.io/
.. _`orjson`: https://pypi.org/project/orjson/
.. _`dealing-strategy-R4-R4B`: https://confluence.hl7.org/display/FHIR/Strategies+for+dealing+with+R4+and+R4B
.. _`FHIR`: https://www.hl7.org/implement/standards/product_brief.cfm
© Copyright HL7® logo, FHIR® logo and the flaming fire are registered trademarks
owned by `Health Level Seven International <https://www.hl7.org/legal/trademarks.cfm?ref=https://pypi.org/project/fhir-resources/>`_
.. role:: strike
:class: strike
.. role:: raw-html(raw)
:format: html
=======
History
=======
7.1.0 (2023-12-14)
------------------
Breaking
- Drop support for python 3.6.
- Drop support for pydantic v1.
Improvements
- `Issue 133 <https://github.com/nazrulworld/fhir.resources/issues/133>`_ Pydantic 2.0 migration plan. It's not fully migration though, instead of using of Pydantic V1 API.
- `Issue 144 <https://github.com/nazrulworld/fhir.resources/issues/144>`_ Parsing XML byte string MESH acknowledgment response.
7.0.2 (2023-07-03)
------------------
- `Issue 124 <https://github.com/nazrulworld/fhir.resources/issues/134>`_ on the wake of 2.x pydantic release, pydantic's max version restriction added.
7.0.1 (2023-05-29)
------------------
Fixes
- Issue #128 `pkg_resources.declare_namespace deprecation <https://github.com/nazrulworld/fhir.resources/issues/128>`_
- Issue #129 `urn not supported in Url <https://github.com/nazrulworld/fhir.resources/issues/129>`_
7.0.0 (2023-04-08)
------------------
New Feature
- Support for `FHIR version R5 <https://www.hl7.org/fhir/R5/resourcelist.html>`_ has been added under root package.
Breaking
- All root resources (FHIR version R4B) are moved under sub-package ``R4B``. Have a look at the migration guide.
6.5.0 (2023-01-01)
------------------
Breaking
- FHIR R4B release has been overlapped on current R4 as default release. See changes (Release R4B: May 28, 2022) http://hl7.org/fhir/R4B/history.html. More detail at http://hl7.org/fhir/R4B/diff.html
Improvements
- Issue #90 logging level downgraded from warning to debug.
- Primitive `URL` type is now accepting the relative path without prefix "/".
6.4.0 (2022-05-11)
------------------
Bugfixes
- Fix, primitive extension was not included if primitive field value is null. [nazrulworld]
- Issue `#101 ElementDefinition.id typing is incorrect <https://github.com/nazrulworld/fhir.resources/issues/101>`_
Improvements
- Issue `#97 <https://github.com/nazrulworld/fhir.resources/issues/97>`_ Now null value accepted as a member of String List.
- Primitive DataType `Ùrl`` is now accepting relative path.
Breaking
- ``Element.id`` & ``Resource.id`` don't have any extension. See https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Resource.2Eid.20and.20primitive.20extension.
6.2.2 (2022-04-02)
------------------
- Issue `#96 <https://github.com/nazrulworld/fhir.resources/issues/96>`_, fixes datetime's ISO format representation for YAML. [nazrulworld]
6.2.1 (2022-01-14)
------------------
- Issues `#89 <https://github.com/nazrulworld/fhir.resources/issues/89>`_ & `#90 <https://github.com/nazrulworld/fhir.resources/issues/90>`_ possible breaking for ``FHIRAbstractModel.dict`` (if pydnatic specific extra argument has been provided) is neutralized.[nazrulworld]
6.2.0 (2022-01-01)
------------------
Bugfixes
- Issue #88 fixes typo mistake. Resource name const was wrong. [nazrulworld]
6.2.0b3 (2021-06-26)
--------------------
New Feature
- String type class is now configurable, it is possible to allow empty str value.
Bugfixes
- Issue #75 Remove "tests" from installed package.
- Issue `#74 When are Falsy values evaluated as None? <https://github.com/nazrulworld/fhir.resources/issues/74>`_
- Fixes some issues for DSTU2 https://github.com/nazrulworld/fhir.resources/pull/71 & https://github.com/nazrulworld/fhir.resources/pull/70 [ItayGoren]
6.2.0b2 (2021-04-05)
--------------------
New Feature
- Parsing YAML file or string/bytes contents, now accept extra parameter ``loader`` class.
- Parsing from XML file or string/bytes contents are now supported. With possible to provide xmlparser for schema validation purpose.
Bugfixes
- Added correct fhir version name into Primitive Type Base class for ``STU3`` and ``DSTU2``.
6.2.0b1 (2021-03-31)
--------------------
New Feature
- `Issue #47 <https://github.com/nazrulworld/fhir.resources/issues/47>`_ add YAML support.
- `Issue #51 <https://github.com/nazrulworld/fhir.resources/issues/51>`_ Help on converting XML to FHIR format.
- `Issue #63 <https://github.com/nazrulworld/fhir.resources/issues/63>`_ Now JSON output key's sequence is matching with original FHIR specification.
Breaking
- ``FHIRAbstractModel.json()`` and ``FHIRAbstractModel.dict()`` parameters signatures are more FHIR specific and additional parameters are removed (pydantic specific).
Bugfixes
- Added missing ``element_property`` field attribute for class ``FHIRPrimitiveExtension``.
6.1.0 (2021-02-13)
------------------
- Breaking/Fixes: `PR#48 <https://github.com/nazrulworld/fhir.resources/pull/48>`_ ``Resource.id`` type has been replaced with ``fhirtypes.Id`` from ``fhirtypes.String`` (only for R4) [ItayGoren]
- Fixes: constraints regex for fhirtypes ``Id``, ``Code``, ``Integer``, ``Decimal``, ``UnsignedInt``, ``PositiveInt`` and so on. [nazrulworld]
6.0.0 (2020-12-17)
------------------
- Issue #21 Remaining resources are added. [iatechicken]
6.0.0b11 (2020-11-25)
---------------------
- Fixes: wrong ``ClaimResponseAddItemAdjudicationType`` resource type name into ``DTSU2``.
6.0.0b10 (2020-11-15)
---------------------
Improvements
- ``FHIRAbstractModel::add_root_validator`` is more improved and practical with proper validation, more now possible provide class method as root validator.
Bugfixes
- `Issue #41 <https://github.com/nazrulworld/fhir.resources/issues/41>`_ pydantic.errors.ConfigError: duplicate validator function.
6.0.0b9 (2020-11-05)
--------------------
Improvements
- Now supports of ``simplejson`` is available automatically (depends on importable) along side with ``orjson`` and default ``json`` library.
Order of json serializer available (orjson -> simplejson(as fallback) -> json(as default)).
Breaking
- ``orjson`` is not available by default, have to use extra_require ``orjson`` to available that.
6.0.0b8 (2020-11-02)
--------------------
- ``pydantic`` minimum version has been set to ``1.7.2``.
6.0.0b7 (2020-10-31)
--------------------
*If you face import error ``from pydantic.utils import ROOT_KEY``, please upgrade your pydnatic version to <1.7*
Fixes
- `Issue #39 <https://github.com/nazrulworld/fhir.resources/issues/39>`_ added compatibility with ``pydantic`` version between ``1.6.x`` and ``1.7.x`` [nazrulworld]
Improvements
- Issue #40 `Make fhir primitive element field optional if extension value is provided. <https://github.com/nazrulworld/fhir.resources/issues/40>`_
6.0.0b6 (2020-10-24)
--------------------
Improvements
- ``FHIRAbstractModel::json`` now takes additional parameter ``return_bytes``, indicates json string would be bytes. [nazrulworld]
- Issue#38 Add support for FHIR comments. As per suggestion of comments in json from `Grahame Grieve <http://www.healthintersections.com.au/?p=2569>`_, now ``fhir_comments`` is accepted. [nazrulworld]
- FHIR comments filter option is added in ``FHIRAbstractModel::json``, means it is possible to exclude any comments while generating json string by providing parameter ``exclude_comments`` value. [nazrulworld]
- More FHIR DSTU2 resources have been added. [Itay Goren]
6.0.0b5 (2020-10-04)
--------------------
Improvements
- ``visionprescription`` and ``supplyrequest`` resources added for DSTU2 [iatechicken]
Fixes
- Issue #28 `'construct_fhir_element' change the given dict <https://github.com/nazrulworld/fhir.resources/issues/28>`_
6.0.0b4 (2020-09-24)
--------------------
Improvements
- orjson_ supports have been available as default json ``dumps`` and ``loads`` for Model.
- ``FHIRAbstractModel::get_json_encoder`` class method now available, which return pydantic compatible json encoder callable, can be used with any json serializer.
- More DSTU2 FHIR Resources have added, https://github.com/nazrulworld/fhir.resources/issues/21. Thanks to [mmabey].
Fixes
- Fixes URL validation in the case where a primitive type is used as URL (which is allowed in StructureDefinition). [simonvadee]
- Fixes `Issue#19 <https://github.com/nazrulworld/fhir.resources/issues/19>`_ Getting validation errors that don't make sense.
6.0.0b3 (2020-08-07)
--------------------
- ``FHIRAbstractModel::get_resource_type`` class method now available, which returning name of the resource.
6.0.0b2 (2020-07-09)
--------------------
- ``FHIRAbstractModel::element_properties`` class method now available, which returning generator of ``ModelField``,
those are elements of the resource.
- Minor fixes on ``enum_values``.
6.0.0b1 (2020-07-05)
--------------------
Revolutionary evolution has been made, now fully rewritten with modern python, underlying APIs (almost all) have been changed.
Please have look at readme section, for howto.
Improvements
- Full support of FHIR `Extensibility <https://www.hl7.org/fhir/extensibility.html>`_ for `Primitive Data Types <https://www.hl7.org/fhir/datatypes.html#primitive>`_
Breaking
- Drop support for python 2.7.
5.1.0 (2020-04-11)
------------------
Improvements
- FHIR ``STU3`` release version upgraded from ``3.0.1`` to ``3.0.2``, Please find changes history here https://www.hl7.org/fhir/history.html.
- FHIR ``R4`` release version upgraded from ``4.0.0`` to ``4.0.1``, find changes history here https://www.hl7.org/fhir/history.html.
5.0.1 (2019-07-18)
------------------
Bugfixes:
- `Issue#5 <https://github.com/nazrulworld/fhir.resources/issues/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
- Isuue#1 `Add DSTU2 Support <https://github.com/nazrulworld/fhir.resources/issues/1>`_
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
.. _`Version Info (STU3)`: http://hl7.org/fhir/stu3/
.. _`Version Info (R4)`: http://hl7.org/fhir/R4/
Raw data
{
"_id": null,
"home_page": "https://github.com/nazrulworld/fhir.resources",
"name": "fhir.resources",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "fhir,resources,python,hl7,health IT,healthcare",
"author": "Md Nazrul Islam",
"author_email": "email2nazrul@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2f/cf/3ce9e45ec0b5bddade9d06dfafc91108d6841649ec70057bda785556c1d5/fhir.resources-7.1.0.tar.gz",
"platform": null,
"description": "======================================\nFHIR\u00ae Resources (R5, R4B, STU3, DSTU2)\n======================================\n\n.. image:: https://img.shields.io/pypi/v/fhir.resources.svg\n :target: https://pypi.python.org/pypi/fhir.resources\n\n.. image:: https://img.shields.io/pypi/pyversions/fhir.resources.svg\n :target: https://pypi.python.org/pypi/fhir.resources\n :alt: Supported Python Versions\n\n.. image:: https://img.shields.io/travis/com/nazrulworld/fhir.resources.svg\n :target: https://app.travis-ci.com/github/nazrulworld/fhir.resources\n\n.. image:: https://ci.appveyor.com/api/projects/status/0qu5vyue1jwxb4km?svg=true\n :target: https://ci.appveyor.com/project/nazrulworld/fhir-resources\n :alt: Windows Build\n\n.. image:: https://codecov.io/gh/nazrulworld/fhir.resources/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/nazrulworld/fhir.resources\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n\n.. image:: https://static.pepy.tech/personalized-badge/fhir-resources?period=total&units=international_system&left_color=black&right_color=green&left_text=Downloads\n :target: https://pepy.tech/project/fhir-resources\n :alt: Downloads\n\n.. image:: https://www.hl7.org/fhir/assets/images/fhir-logo-www.png\n :target: https://www.hl7.org/implement/standards/product_brief.cfm?product_id=449\n :alt: HL7\u00ae FHIR\u00ae\n\nFHIR_ (Fast Healthcare Interoperability Resources) is a specification for exchanging healthcare information electronically.\nIt is designed to facilitate the exchange of data between different healthcare systems and applications, and is commonly used to build APIs (Application Programming Interfaces) for healthcare data.\nIt is based on modern web technologies, and is designed to be easy to use and implement.\nIt uses a modular approach, with a set of \"resources\" that represent different types of healthcare data (such as patients, observations, and diagnoses).\nThese resources can be combined and extended as needed to support a wide range of healthcare use cases.\n\n\nThis \"fhir.resources\" package is powered by pydantic_ so faster in performance and optionally ``orjson`` support has been included as a performance booster!\nObviously it is written in modern python and has data validation built-in.\nIt provides tools and classes for all of the `FHIR Resources <https://www.hl7.org/fhir/resourcelist.html>`_ defined in the FHIR specification,\nand allows you to create and manipulate FHIR resources in Python. You can then use these resources to build FHIR-based APIs or to work with FHIR data in other ways.\n\n\n* Easy to construct, easy to extended validation, easy to export.\n* By inheriting behaviour from pydantic_, compatible with `ORM <https://en.wikipedia.org/wiki/Object-relational_mapping>`_.\n* Full support of FHIR\u00ae Extensibility for Primitive Data Types are available.\n* Previous release of FHIR\u00ae Resources are available.\n* Free software: BSD license\n\n**Experimental XML and YAML serialization and deserialization supports. See [Advanced Usages] section!**\n\nFHIR\u00ae Version Info\n------------------\n\nFHIR\u00ae (Release R5, version 5.0.0) is available as default. Also previous versions are available as Python sub-package\n(each release name string becomes sub-package name, i.e ``R4B`` ).\nFrom ``fhir.resources`` version 7.0.0; there is no FHIR ``R4`` instead of ``R4B`` is available as sub-package.\n\n**Available Previous Versions**:\n\n* ``R4B`` (4.3.0)\n* ``STU3`` (3.0.2)\n* ``DSTU2`` (1.0.2) [see `issue#13 <https://github.com/nazrulworld/fhir.resources/issues/13>`_][don't have full tests coverage]\n\n\nInstallation\n------------\n\nJust a simple ``pip install fhir.resources`` or ``easy_install fhir.resources`` is enough. But if you want development\nversion, just clone from https://github.com/nazrulworld/fhir.resources and ``pip install -e .[dev]``.\n\n\nUsages\n------\n\n**Example: 1**: This example creates a new Organization resource with some of its attributes (id, active, name, address)::\n\n >>> from fhir.resources.organization import Organization\n >>> from fhir.resources.address import Address\n >>> data = {\n ... \"id\": \"f001\",\n ... \"active\": True,\n ... \"name\": \"Acme Corporation\",\n ... \"address\": [{\"country\": \"Switzerland\"}]\n ... }\n >>> org = Organization(**data)\n >>> org.resource_type == \"Organization\"\n True\n >>> isinstance(org.address[0], Address)\n True\n >>> org.address[0].country == \"Switzerland\"\n True\n >>> org.dict()['active'] is True\n True\n\n**Example: 2**: This example creates a new Organization resource from json string::\n\n >>> from fhir.resources.organization import Organization\n >>> from fhir.resources.address import Address\n >>> json_str = '''{\"resourceType\": \"Organization\",\n ... \"id\": \"f001\",\n ... \"active\": True,\n ... \"name\": \"Acme Corporation\",\n ... \"address\": [{\"country\": \"Switzerland\"}]\n ... }'''\n >>> org = Organization.parse_raw(json_str)\n >>> isinstance(org.address[0], Address)\n True\n >>> org.address[0].country == \"Switzerland\"\n True\n >>> org.dict()['active'] is True\n True\n\n\n**Example: 3**: This example creates a new Patient resource from json object(py dict)::\n\n >>> from fhir.resources.patient import Patient\n >>> from fhir.resources.humanname import HumanName\n >>> from datetime import date\n >>> json_obj = {\"resourceType\": \"Patient\",\n ... \"id\": \"p001\",\n ... \"active\": True,\n ... \"name\": [\n ... {\"text\": \"Adam Smith\"}\n ... ],\n ... \"birthDate\": \"1985-06-12\"\n ... }\n >>> pat = Patient.parse_obj(json_obj)\n >>> isinstance(pat.name[0], HumanName)\n True\n >>> pat.birthDate == date(year=1985, month=6, day=12)\n True\n >>> pat.active is True\n True\n\n\n**Example: 4**: This example creates a new Patient resource from json file::\n\n >>> from fhir.resources.patient import Patient\n >>> import os\n >>> import pathlib\n >>> filename = pathlib.Path(\"foo/bar.json\")\n >>> pat = Patient.parse_file(filename)\n >>> pat.resource_type == \"Patient\"\n True\n\n\n**Example: 5**: This example creates a new Organization resource in python way::\n\n >>> from fhir.resources.organization import Organization\n >>> from fhir.resources.address import Address\n >>> json_obj = {\"resourceType\": \"Organization\",\n ... \"id\": \"f001\",\n ... \"active\": True,\n ... \"name\": \"Acme Corporation\",\n ... \"address\": [{\"country\": \"Switzerland\"}]\n ... }\n\n >>> org = Organization.construct()\n >>> org.id = \"f001\"\n >>> org.active = True\n >>> org.name = \"Acme Corporation\"\n >>> org.address = list()\n >>> address = Address.construct()\n >>> address.country = \"Switzerland\"\n >>> org.address.append(address)\n >>> org.dict() == json_obj\n True\n\n.. note::\n Please note that due to the way the validation works, you will run into issues if you are using ``construct()`` to create\n resources that have more than one mandatory field. See `this comment in issue#56 <https://github.com/nazrulworld/fhir.resources/issues/56#issuecomment-784520234>`_ for details.\n\n**Example: 4**: This example creates a new Organization resource using Resource Factory Function::\n\n >>> from fhir.resources import construct_fhir_element\n >>> json_dict = {\"resourceType\": \"Organization\",\n ... \"id\": \"mmanu\",\n ... \"active\": True,\n ... \"name\": \"Acme Corporation\",\n ... \"address\": [{\"country\": \"Switzerland\"}]\n ... }\n >>> org = construct_fhir_element('Organization', json_dict)\n >>> org.address[0].country == \"Switzerland\"\n True\n >>> org.dict()['active'] is True\n True\n\n\n**Example: 5**: Auto validation while providing wrong datatype::\n\n >>> try:\n ... org = Organization({\"id\": \"fmk\", \"address\": [\"i am wrong type\"]})\n ... raise AssertionError(\"Code should not come here\")\n ... except ValueError:\n ... pass\n\n\n\nAdvanced Usages\n---------------\n\nFHIR Comments (JSON)\n~~~~~~~~~~~~~~~~~~~~\n\nIt is possible to add comments inside json like xml, but need to follow some convention, what is suggested by `Grahame Grieve <http://www.healthintersections.com.au/?p=2569>`_;\nis implemented here.\n\nAlso it is possible to generate json string output without comments.\n\nExamples::\n\n >>> observation_str = b\"\"\"{\n ... \"resourceType\": \"Observation\",\n ... \"id\": \"f001\",\n ... \"fhir_comments\": [\n ... \" a specimen identifier - e.g. assigned when the specimen was taken by the orderer/placer use the accession number for the filling lab \",\n ... \" Placer ID \"\n ... ],\n ... \"text\": {\n ... \"fhir_comments\": [\n ... \" a specimen identifier - e.g. assigned when the specimen was taken by the orderer/placer use the accession number for the filling lab \",\n ... \" Placer ID \"\n ... ],\n ... \"status\": \"generated\",\n ... \"div\": \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">.........</div>\"\n ... },\n ... \"identifier\": [\n ... {\n ... \"use\": \"official\",\n ... \"system\": \"http://www.bmc.nl/zorgportal/identifiers/observations\",\n ... \"value\": \"6323\"\n ... }\n ... ],\n ... \"status\": \"final\",\n ... \"_status\": {\n ... \"fhir_comments\": [\n ... \" EH: Note to balloters - lots of choices for whole blood I chose this. \"\n ... ]\n ... },\n ... \"code\": {\n ... \"coding\": [\n ... {\n ... \"system\": \"http://loinc.org\",\n ... \"code\": \"15074-8\",\n ... \"display\": \"Glucose [Moles/volume] in Blood\"\n ... }\n ... ]\n ... },\n ... \"subject\": {\n ... \"reference\": \"Patient/f001\",\n ... \"display\": \"P. van de Heuvel\"\n ... },\n ... \"effectivePeriod\": {\n ... \"start\": \"2013-04-02T09:30:10+01:00\"\n ... },\n ... \"issued\": \"2013-04-03T15:30:10+01:00\",\n ... \"performer\": [\n ... {\n ... \"reference\": \"Practitioner/f005\",\n ... \"display\": \"A. Langeveld\"\n ... }\n ... ],\n ... \"valueQuantity\": {\n ... \"value\": 6.3,\n ... \"unit\": \"mmol/l\",\n ... \"system\": \"http://unitsofmeasure.org\",\n ... \"code\": \"mmol/L\"\n ... },\n ... \"interpretation\": [\n ... {\n ... \"coding\": [\n ... {\n ... \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation\",\n ... \"code\": \"H\",\n ... \"display\": \"High\"\n ... }\n ... ]\n ... }\n ... ],\n ... \"referenceRange\": [\n ... {\n ... \"low\": {\n ... \"value\": 3.1,\n ... \"unit\": \"mmol/l\",\n ... \"system\": \"http://unitsofmeasure.org\",\n ... \"code\": \"mmol/L\"\n ... },\n ... \"high\": {\n ... \"value\": 6.2,\n ... \"unit\": \"mmol/l\",\n ... \"system\": \"http://unitsofmeasure.org\",\n ... \"code\": \"mmol/L\"\n ... }\n ... }\n ... ]\n ... }\"\"\"\n >>> from fhir.resources.observation import Observation\n >>> obj = Observation.parse_raw(observation_str)\n >>> \"fhir_comments\" in obj.json()\n >>> # Test comments filtering\n >>> \"fhir_comments\" not in obj.json(exclude_comments=True)\n\n\nSpecial Case: Missing data\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n`In some cases <https://www.hl7.org/fhir/extensibility.html#Special-Case>`_, implementers might\nfind that they do not have appropriate data for an element with minimum cardinality = 1.\nIn this case, the element must be present, but unless the resource or a profile on it has made the\nactual value of the primitive data type mandatory, it is possible to provide an extension that\nexplains why the primitive value is not present.\nExample (required ``intent`` element is missing but still valid because of extension)::\n\n >>> json_str = b\"\"\"{\n ... \"resourceType\": \"MedicationRequest\",\n ... \"id\": \"1620518\",\n ... \"meta\": {\n ... \"versionId\": \"1\",\n ... \"lastUpdated\": \"2020-10-27T11:04:42.215+00:00\",\n ... \"source\": \"#z072VeAlQWM94jpc\",\n ... \"tag\": [\n ... {\n ... \"system\": \"http://www.alpha.alp/use-case\",\n ... \"code\": \"EX20\"\n ... }\n ... ]\n ... },\n ... \"status\": \"completed\",\n ... \"_intent\": {\n ... \"extension\": [\n ... {\n ... \"url\": \"http://hl7.org/fhir/StructureDefinition/data-absent-reason\",\n ... \"valueCode\": \"unknown\"\n ... }\n ... ]\n ... },\n ... \"medicationReference\": {\n ... \"reference\": \"Medication/1620516\",\n ... \"display\": \"Erythromycin 250 MG Oral Tablet\"\n ... },\n ... \"subject\": {\n ... \"reference\": \"Patient/1620472\"\n ... },\n ... \"encounter\": {\n ... \"reference\": \"Encounter/1620506\",\n ... \"display\": \"Follow up encounter\"\n ... },\n ... \"authoredOn\": \"2018-06-16\",\n ... \"requester\": {\n ... \"reference\": \"Practitioner/1620502\",\n ... \"display\": \"Dr. Harold Hippocrates\"\n ... },\n ... \"reasonReference\": [\n ... {\n ... \"reference\": \"Condition/1620514\",\n ... \"display\": \"Otitis Media\"\n ... }\n ... ],\n ... \"dosageInstruction\": [\n ... {\n ... \"text\": \"250 mg 4 times per day for 10 days\",\n ... \"timing\": {\n ... \"repeat\": {\n ... \"boundsDuration\": {\n ... \"value\": 10,\n ... \"unit\": \"day\",\n ... \"system\": \"http://unitsofmeasure.org\",\n ... \"code\": \"d\"\n ... },\n ... \"frequency\": 4,\n ... \"period\": 1,\n ... \"periodUnit\": \"d\"\n ... }\n ... },\n ... \"doseAndRate\": [\n ... {\n ... \"doseQuantity\": {\n ... \"value\": 250,\n ... \"unit\": \"mg\",\n ... \"system\": \"http://unitsofmeasure.org\",\n ... \"code\": \"mg\"\n ... }\n ... }\n ... ]\n ... }\n ... ],\n ... \"priorPrescription\": {\n ... \"reference\": \"MedicationRequest/1620517\",\n ... \"display\": \"Amoxicillin prescription\"\n ... }\n ... }\"\"\"\n >>> from fhir.resources.medicationrequest import MedicationRequest\n >>> obj = MedicationRequest.parse_raw(json_str)\n >>> \"intent\" not in obj.dict()\n\n\nCustom Validators\n~~~~~~~~~~~~~~~~~\n\n``fhir.resources`` is providing the extensive API to create and attach custom validator into any model. See more `about root validator <https://pydantic-docs.helpmanual.io/usage/validators/#root-validators>`_\nSome convention you have to follow though, while creating a root validator.\n\n1. Number of arguments are fixed, as well as names are also. i.e ``(cls, values)``.\n2. Should return ``values``, unless any exception need to be raised.\n3. Validator should be attached only one time for individual Model. Update [from now, it's not possible to attach multiple time same name validator on same class]\n\nExample 1: Validator for Patient::\n\n from typing import Dict\n from fhir.resources.patient import Patient\n\n import datetime\n\n def validate_birthdate(cls, values: Dict):\n if not values:\n return values\n if \"birthDate\" not in values:\n raise ValueError(\"Patient's ``birthDate`` is required.\")\n\n minimum_date = datetime.date(2002, 1, 1)\n if values[\"birthDate\"] > minimum_date:\n raise ValueError(\"Minimum 18 years patient is allowed to use this system.\")\n return values\n # we want this validator to execute after data evaluating by individual field validators.\n Patient.add_root_validator(validate_gender, pre=False)\n\n\nExample 2: Validator for Patient from Validator Class::\n\n from typing import Dict\n from fhir.resources.patient import Patient\n\n import datetime\n\n class MyValidator:\n @classmethod\n def validate_birthdate(cls, values: Dict):\n if not values:\n return values\n if \"birthDate\" not in values:\n raise ValueError(\"Patient's ``birthDate`` is required.\")\n\n minimum_date = datetime.date(2002, 1, 1)\n if values[\"birthDate\"] > minimum_date:\n raise ValueError(\"Minimum 18 years patient is allowed to use this system.\")\n return values\n # we want this validator to execute after data evaluating by individual field validators.\n Patient.add_root_validator(MyValidator.validate_gender, pre=False)\n\n\n**important notes** It is possible add root validator into any base class like ``DomainResource``.\nIn this case you have to make sure root validator is attached before any import of derived class, other\nthan validator will not trigger for successor class (if imported before) by nature.\n\nENUM Validator\n~~~~~~~~~~~~~~\n\n``fhir.resources`` is providing API for enum constraint for each field (where applicable), but it-self doesn't\nenforce enum based validation! see `discussion here <https://github.com/nazrulworld/fhir.resources/issues/23>`_.\nIf you want to enforce enum constraint, you have to create a validator for that.\n\nExample: Gender Enum::\n\n from typing import Dict\n from fhir.resources.patient import Patient\n\n def validate_gender(cls, values: Dict):\n if not values:\n return values\n enums = cls.__fields__[\"gender\"].field_info.extra[\"enum_values\"]\n if \"gender\" in values and values[\"gender\"] not in enums:\n raise ValueError(\"write your message\")\n return values\n\n Patient.add_root_validator(validate_gender, pre=True)\n\n\nReference Validator\n~~~~~~~~~~~~~~~~~~~\n\n``fhir.resources`` is also providing enum like list of permitted resource types through field property ``enum_reference_types``.\nYou can get that list by following above (Enum) approaches ``resource_types = cls.__fields__[\"managingOrganization\"].field_info.extra[\"enum_reference_types\"]``\n\n\nUsages of orjson\n~~~~~~~~~~~~~~~~\n\norjson_ is one of the fastest Python library for JSON and is more correct than the standard json library (according to their docs).\nGood news is that ``fhir.resource`` has an extensive support for orjson_ and it's too easy to enable it automatically. What you need to do, just make orjson_ as your project dependency!\n\n\npydantic_ Field Type Support\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAll available fhir resources (types) can be use as pydantic_'s Field's value types. See issue#46 `Support for FastAPI pydantic response models <https://github.com/nazrulworld/fhir.resources/issues/46>`_.\nThe module ``fhirtypes.py`` contains all fhir resources related types and should trigger validator automatically.\n\n\n``Resource.id aka fhirtypes.Id`` constraint extensibility\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nThere are a lots of discussion here here i.) https://bit.ly/360HksL ii.) https://bit.ly/3o1fZgl about the length of ``Resource.Id``'s value.\nBased on those discussions, we recommend that keep your ``Resource.Id`` size within 64 letters (for the seek of intercompatibility with third party system), but we are also providing freedom\nabout the length of Id, in respect with others opinion that 64 chr length is not sufficient. ``fhirtypes.Id.configure_constraints()``\nis offering to customize as your own requirement.\n\nExamples::\n >>> from fhir.resources.fhirtypes import Id\n >>> Id.configure_constraints(min_length=16, max_length=128)\n\nNote: when you will change that behaviour, that would impact into your whole project.\n\n\nXML Supports\n~~~~~~~~~~~~\n\nAlong side with JSON string export, it is possible to export as XML string!\nBefore using this feature, make sure associated dependent library is installed. Use ``fhir.resources[xml]`` or ``fhir.resources[all]`` as\nyour project requirements.\n\n**XML schema validator!**\nIt is possible to provide custom xmlparser, during load from file or string, meaning that you can validate\ndata against FHIR xml schema(and/or your custom schema).\n\nExample-1 Export::\n >>> from fhir.resources.patient import Patient\n >>> data = {\"active\": True, \"gender\": \"male\", \"birthDate\": \"2000-09-18\", \"name\": [{\"text\": \"Primal Kons\"}]}\n >>> patient_obj = Patient(**data)\n >>> xml_str = patient_obj.xml(pretty_print=True)\n >>> print(xml_str)\n <?xml version='1.0' encoding='utf-8'?>\n <Patient xmlns=\"http://hl7.org/fhir\">\n <active value=\"true\"/>\n <name>\n <text value=\"Primal Kons\"/>\n </name>\n <gender value=\"male\"/>\n <birthDate value=\"2000-09-18\"/>\n </Patient>\n\n\nExample-2 Import from string::\n >>> from fhir.resources.patient import Patient\n >>> data = {\"active\": True, \"gender\": \"male\", \"birthDate\": \"2000-09-18\", \"name\": [{\"text\": \"Primal Kons\"}]}\n >>> patient_obj = Patient(**data)\n >>> xml_str = patient_obj.xml(pretty_print=True)\n >>> print(xml_str)\n >>> data = b\"\"\"<?xml version='1.0' encoding='utf-8'?>\n ... <Patient xmlns=\"http://hl7.org/fhir\">\n ... <active value=\"true\"/>\n ... <name>\n ... <text value=\"Primal Kons\"/>\n ... </name>\n ... <gender value=\"male\"/>\n ... <birthDate value=\"2000-09-18\"/>\n ... </Patient>\"\"\"\n >>> patient = Patient.parse_raw(data, content_type=\"text/xml\")\n >>> print(patient.json(indent=2))\n {\n \"resourceType\": \"Patient\",\n \"active\": true,\n \"name\": [\n {\n \"text\": \"Primal Kons\",\n \"family\": \"Kons\",\n \"given\": [\n \"Primal\"\n ]\n }\n ],\n \"gender\": \"male\",\n \"birthDate\": \"2000-09-18\"\n }\n\n >>> with xml parser\n >>> import lxml\n >>> schema = lxml.etree.XMLSchema(file=str(FHIR_XSD_DIR / \"patient.xsd\"))\n >>> xmlparser = lxml.etree.XMLParser(schema=schema)\n >>> patient2 = Patient.parse_raw(data, content_type=\"text/xml\", xmlparser=xmlparser)\n >>> patient2 == patient\n True\n\nExample-3 Import from file::\n >>> patient3 = Patient.parse_file(\"Patient.xml\")\n >>> patient3 == patient and patient3 == patient2\n True\n\n\n**XML FAQ**\n\n - Although generated XML is validated against ``FHIR/patient.xsd`` and ``FHIR/observation.xsd`` in tests, but we suggest you check output of your production data.\n - Comment feature is included, but we recommend you check in your complex usages.\n\n\nYAML Supports\n~~~~~~~~~~~~~\nAlthough there is no official support for YAML documented in FHIR specification, but as an experimental feature, we add this support.\nNow it is possible export/import YAML strings.\nBefore using this feature, make sure associated dependent library is installed. Use ``fhir.resources[yaml]`` or ``fhir.resources[all]`` as\nyour project requirements.\n\nExample-1 Export::\n >>> from fhir.resources.patient import Patient\n >>> data = {\"active\": True, \"gender\": \"male\", \"birthDate\": \"2000-09-18\", \"name\": [{\"text\": \"Primal Kons\", \"family\": \"Kons\", \"given\": [\"Primal\"]}]}\n >>> patient_obj = Patient(**data)\n >>> yml_str = patient_obj.yaml(indent=True)\n >>> print(yml_str)\n resourceType: Patient\n active: true\n name:\n - text: Primal Kons\n family: Kons\n given:\n - Primal\n gender: male\n birthDate: 2000-09-18\n\n\nExample-2 Import from YAML string::\n >>> from fhir.resources.patient import Patient\n >>> data = b\"\"\"\n ... resourceType: Patient\n ... active: true\n ... name:\n ... - text: Primal Kons\n ... family: Kons\n ... given:\n ... - Primal\n ... gender: male\n ... birthDate: 2000-09-18\n ... \"\"\"\n >>> patient_obj = Patient.parse_raw(data, content_type=\"text/yaml\")\n >>> json_str = patient_obj.json(indent=True)\n >>> print(json_str)\n {\n \"resourceType\": \"Patient\",\n \"active\": true,\n \"name\": [\n {\n \"text\": \"Primal Kons\",\n \"family\": \"Kons\",\n \"given\": [\n \"Primal\"\n ]\n }\n ],\n \"gender\": \"male\",\n \"birthDate\": \"2000-09-18\"\n }\n\nExample-3 Import from YAML file::\n >>> from fhir.resources.patient import Patient\n >>> patient_obj = Patient.parse_file(\"Patient.yml\")\n >>> json_str = patient_obj.json(indent=True)\n >>> print(json_str)\n {\n \"resourceType\": \"Patient\",\n \"active\": true,\n \"name\": [\n {\n \"text\": \"Primal Kons\",\n \"family\": \"Kons\",\n \"given\": [\n \"Primal\"\n ]\n }\n ],\n \"gender\": \"male\",\n \"birthDate\": \"2000-09-18\"\n }\n\n\n**YAML FAQ**\n\n- We are using https://pyyaml.org/ PyYAML library, for serialization/deserialization but if we find more faster library, we could use that. you are welcome to provide us your suggestion.\n- YAML based comments is not supported yet, instead json comments syntax is used! Of course this comment feature is in our todo list.\n\n\nAllow Empty String\n~~~~~~~~~~~~~~~~~~\n\nAlthough this is not good practice to allow empty string value against FHIR primitive data type ``String``. But\nwe in real life scenario, is it unavoidable sometimes.\n\nExamples::\n Place this code inside your __init__.py module or any place, just to make sure that this fragment of codes is runtime executed.\n\n >>> from fhir.resources.fhirtypes import String\n >>> String.configure_empty_str(allow=True)\n\n\n\nFHIR release R4B over R4\n------------------------\n\nFHIR release R4B is coming with not that much changes over the release of R4. So we decided not to create separate sub-package for R4 like STU3, instead there just overlaps on existing R4. This also means that in future, when we will work on R5; there will be sub-package for R4B and no R4.\nWe suggest you to try make a plan to be upgraded to R4B. Here you could find related information dealing-strategy-R4-R4B_.\n\nYou could find full discussion here https://github.com/nazrulworld/fhir.resources/discussions/116\n\nMigration (from ``6.X.X`` to ``7.0.X``)\n---------------------------------------\n\nFirst of all, you have to correct all imports path, if you wish to keep continue using FHIR release R4B or R4, as those resources\nare moved under sub-package named ``R4B``. Then if you wish to use current ``R5`` release,\nread carefully the following documents.\n\n1. See the full changes history -> https://build.fhir.org/history.html\n2. See complete lists of differences between R5 and R4B -> https://hl7.org/fhir/R5/diff.html\n3. If you are planning to migrate direct from the release ``R4``,\n then it is important to look at the differences between R4B and R4 here -> https://hl7.org/fhir/R4B/diff.html\n\n\nMigration (from later than ``6.X.X``)\n-------------------------------------\n\nThis migration guide states some underlying changes of ``API`` and replacement, those are commonly used from later than ``6.X.X`` version.\n\n\n``fhir.resources.fhirelementfactory.FHIRElementFactory::instantiate``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n**Replacement:** ``fhir.resources.construct_fhir_element``\n\n- First parameter value is same as previous, the Resource name.\n\n- Second parameter is more flexible than previous! it is possible to provide not only json ``dict`` but also\n json string or json file path.\n\n- No third parameter, what was in previous version.\n\n\n``fhir.resources.fhirabstractbase.FHIRAbstractBase::__init__``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n**Replacement:** ``fhir.resources.fhirabstractmodel.FHIRAbstractModel::parse_obj<classmethod>``\n\n- First parameter value is same as previous, json dict.\n\n- No second parameter, what was in previous version.\n\n\n``fhir.resources.fhirabstractbase.FHIRAbstractBase::as_json``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n**Replacement:** ``fhir.resources.fhirabstractmodel.FHIRAbstractModel::dict``\n\n- Output are almost same previous, but there has some difference in case of some date type, for example py date,\n datetime, Decimal are in object representation.\n\n- It is possible to use ``fhir.resources.fhirabstractmodel.FHIRAbstractModel::json`` as replacement, when\n json string is required (so not need further, json dumps from dict)\n\n\nNote:\n\nAll resources/classes are derived from ``fhir.resources.fhirabstractmodel.FHIRAbstractModel`` what was previously\nfrom ``fhir.resources.fhirabstractbase.FHIRAbstractBase``.\n\n\nRelease and Version Policy\n--------------------------\n\nStarting from version ``5.0.0`` we are following our own release policy and we although follow Semantic Versioning scheme like FHIR\u00ae version.\nUnlike previous statement (bellow), releasing now is not dependent on FHIR\u00ae.\n\n\n**removed statement**\n\n This package is following `FHIR\u00ae release and versioning policy <https://www.hl7.org/fhir/versions.html>`_, for example say, FHIR releases next version 4.0.1,\n we also release same version here.\n\n\nCredits\n-------\n\nAll FHIR\u00ae Resources (python classes) are generated using fhir-parser_ which is forked from https://github.com/smart-on-fhir/fhir-parser.git.\n\n\nThis package skeleton was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _`fhir-parser`: https://github.com/nazrulworld/fhir-parser\n.. _`pydantic`: https://pydantic-docs.helpmanual.io/\n.. _`orjson`: https://pypi.org/project/orjson/\n.. _`dealing-strategy-R4-R4B`: https://confluence.hl7.org/display/FHIR/Strategies+for+dealing+with+R4+and+R4B\n.. _`FHIR`: https://www.hl7.org/implement/standards/product_brief.cfm\n\n\u00a9 Copyright HL7\u00ae logo, FHIR\u00ae logo and the flaming fire are registered trademarks\nowned by `Health Level Seven International <https://www.hl7.org/legal/trademarks.cfm?ref=https://pypi.org/project/fhir-resources/>`_\n\n.. role:: strike\n :class: strike\n.. role:: raw-html(raw)\n :format: html\n\n\n=======\nHistory\n=======\n\n7.1.0 (2023-12-14)\n------------------\n\nBreaking\n\n- Drop support for python 3.6.\n- Drop support for pydantic v1.\n\nImprovements\n\n- `Issue 133 <https://github.com/nazrulworld/fhir.resources/issues/133>`_ Pydantic 2.0 migration plan. It's not fully migration though, instead of using of Pydantic V1 API.\n- `Issue 144 <https://github.com/nazrulworld/fhir.resources/issues/144>`_ Parsing XML byte string MESH acknowledgment response.\n\n\n7.0.2 (2023-07-03)\n------------------\n\n- `Issue 124 <https://github.com/nazrulworld/fhir.resources/issues/134>`_ on the wake of 2.x pydantic release, pydantic's max version restriction added.\n\n\n7.0.1 (2023-05-29)\n------------------\n\nFixes\n\n- Issue #128 `pkg_resources.declare_namespace deprecation <https://github.com/nazrulworld/fhir.resources/issues/128>`_\n\n- Issue #129 `urn not supported in Url <https://github.com/nazrulworld/fhir.resources/issues/129>`_\n\n7.0.0 (2023-04-08)\n------------------\n\nNew Feature\n\n- Support for `FHIR version R5 <https://www.hl7.org/fhir/R5/resourcelist.html>`_ has been added under root package.\n\n\nBreaking\n\n- All root resources (FHIR version R4B) are moved under sub-package ``R4B``. Have a look at the migration guide.\n\n\n6.5.0 (2023-01-01)\n------------------\n\nBreaking\n\n- FHIR R4B release has been overlapped on current R4 as default release. See changes (Release R4B: May 28, 2022) http://hl7.org/fhir/R4B/history.html. More detail at http://hl7.org/fhir/R4B/diff.html\n\nImprovements\n\n- Issue #90 logging level downgraded from warning to debug.\n- Primitive `URL` type is now accepting the relative path without prefix \"/\".\n\n\n6.4.0 (2022-05-11)\n------------------\n\nBugfixes\n\n- Fix, primitive extension was not included if primitive field value is null. [nazrulworld]\n- Issue `#101 ElementDefinition.id typing is incorrect <https://github.com/nazrulworld/fhir.resources/issues/101>`_\n\nImprovements\n\n- Issue `#97 <https://github.com/nazrulworld/fhir.resources/issues/97>`_ Now null value accepted as a member of String List.\n- Primitive DataType `\u00d9rl`` is now accepting relative path.\n\nBreaking\n\n- ``Element.id`` & ``Resource.id`` don't have any extension. See https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Resource.2Eid.20and.20primitive.20extension.\n\n6.2.2 (2022-04-02)\n------------------\n\n- Issue `#96 <https://github.com/nazrulworld/fhir.resources/issues/96>`_, fixes datetime's ISO format representation for YAML. [nazrulworld]\n\n\n6.2.1 (2022-01-14)\n------------------\n\n- Issues `#89 <https://github.com/nazrulworld/fhir.resources/issues/89>`_ & `#90 <https://github.com/nazrulworld/fhir.resources/issues/90>`_ possible breaking for ``FHIRAbstractModel.dict`` (if pydnatic specific extra argument has been provided) is neutralized.[nazrulworld]\n\n\n6.2.0 (2022-01-01)\n------------------\n\nBugfixes\n\n- Issue #88 fixes typo mistake. Resource name const was wrong. [nazrulworld]\n\n\n6.2.0b3 (2021-06-26)\n--------------------\n\nNew Feature\n\n- String type class is now configurable, it is possible to allow empty str value.\n\nBugfixes\n\n- Issue #75 Remove \"tests\" from installed package.\n- Issue `#74 When are Falsy values evaluated as None? <https://github.com/nazrulworld/fhir.resources/issues/74>`_\n\n- Fixes some issues for DSTU2 https://github.com/nazrulworld/fhir.resources/pull/71 & https://github.com/nazrulworld/fhir.resources/pull/70 [ItayGoren]\n\n\n6.2.0b2 (2021-04-05)\n--------------------\n\nNew Feature\n\n- Parsing YAML file or string/bytes contents, now accept extra parameter ``loader`` class.\n- Parsing from XML file or string/bytes contents are now supported. With possible to provide xmlparser for schema validation purpose.\n\nBugfixes\n\n- Added correct fhir version name into Primitive Type Base class for ``STU3`` and ``DSTU2``.\n\n\n6.2.0b1 (2021-03-31)\n--------------------\n\nNew Feature\n\n- `Issue #47 <https://github.com/nazrulworld/fhir.resources/issues/47>`_ add YAML support.\n- `Issue #51 <https://github.com/nazrulworld/fhir.resources/issues/51>`_ Help on converting XML to FHIR format.\n- `Issue #63 <https://github.com/nazrulworld/fhir.resources/issues/63>`_ Now JSON output key's sequence is matching with original FHIR specification.\n\nBreaking\n\n- ``FHIRAbstractModel.json()`` and ``FHIRAbstractModel.dict()`` parameters signatures are more FHIR specific and additional parameters are removed (pydantic specific).\n\n\nBugfixes\n\n- Added missing ``element_property`` field attribute for class ``FHIRPrimitiveExtension``.\n\n6.1.0 (2021-02-13)\n------------------\n\n- Breaking/Fixes: `PR#48 <https://github.com/nazrulworld/fhir.resources/pull/48>`_ ``Resource.id`` type has been replaced with ``fhirtypes.Id`` from ``fhirtypes.String`` (only for R4) [ItayGoren]\n\n- Fixes: constraints regex for fhirtypes ``Id``, ``Code``, ``Integer``, ``Decimal``, ``UnsignedInt``, ``PositiveInt`` and so on. [nazrulworld]\n\n\n6.0.0 (2020-12-17)\n------------------\n\n- Issue #21 Remaining resources are added. [iatechicken]\n\n\n6.0.0b11 (2020-11-25)\n---------------------\n\n- Fixes: wrong ``ClaimResponseAddItemAdjudicationType`` resource type name into ``DTSU2``.\n\n\n6.0.0b10 (2020-11-15)\n---------------------\n\nImprovements\n\n- ``FHIRAbstractModel::add_root_validator`` is more improved and practical with proper validation, more now possible provide class method as root validator.\n\n\nBugfixes\n\n- `Issue #41 <https://github.com/nazrulworld/fhir.resources/issues/41>`_ pydantic.errors.ConfigError: duplicate validator function.\n\n6.0.0b9 (2020-11-05)\n--------------------\n\nImprovements\n\n- Now supports of ``simplejson`` is available automatically (depends on importable) along side with ``orjson`` and default ``json`` library.\n Order of json serializer available (orjson -> simplejson(as fallback) -> json(as default)).\n\nBreaking\n\n- ``orjson`` is not available by default, have to use extra_require ``orjson`` to available that.\n\n\n6.0.0b8 (2020-11-02)\n--------------------\n\n- ``pydantic`` minimum version has been set to ``1.7.2``.\n\n\n6.0.0b7 (2020-10-31)\n--------------------\n\n*If you face import error ``from pydantic.utils import ROOT_KEY``, please upgrade your pydnatic version to <1.7*\n\nFixes\n\n- `Issue #39 <https://github.com/nazrulworld/fhir.resources/issues/39>`_ added compatibility with ``pydantic`` version between ``1.6.x`` and ``1.7.x`` [nazrulworld]\n\nImprovements\n\n- Issue #40 `Make fhir primitive element field optional if extension value is provided. <https://github.com/nazrulworld/fhir.resources/issues/40>`_\n\n6.0.0b6 (2020-10-24)\n--------------------\n\nImprovements\n\n- ``FHIRAbstractModel::json`` now takes additional parameter ``return_bytes``, indicates json string would be bytes. [nazrulworld]\n\n- Issue#38 Add support for FHIR comments. As per suggestion of comments in json from `Grahame Grieve <http://www.healthintersections.com.au/?p=2569>`_, now ``fhir_comments`` is accepted. [nazrulworld]\n\n- FHIR comments filter option is added in ``FHIRAbstractModel::json``, means it is possible to exclude any comments while generating json string by providing parameter ``exclude_comments`` value. [nazrulworld]\n\n- More FHIR DSTU2 resources have been added. [Itay Goren]\n\n6.0.0b5 (2020-10-04)\n--------------------\n\nImprovements\n\n- ``visionprescription`` and ``supplyrequest`` resources added for DSTU2 [iatechicken]\n\nFixes\n\n- Issue #28 `'construct_fhir_element' change the given dict <https://github.com/nazrulworld/fhir.resources/issues/28>`_\n\n\n6.0.0b4 (2020-09-24)\n--------------------\n\nImprovements\n\n- orjson_ supports have been available as default json ``dumps`` and ``loads`` for Model.\n\n- ``FHIRAbstractModel::get_json_encoder`` class method now available, which return pydantic compatible json encoder callable, can be used with any json serializer.\n\n- More DSTU2 FHIR Resources have added, https://github.com/nazrulworld/fhir.resources/issues/21. Thanks to [mmabey].\n\nFixes\n\n- Fixes URL validation in the case where a primitive type is used as URL (which is allowed in StructureDefinition). [simonvadee]\n\n- Fixes `Issue#19 <https://github.com/nazrulworld/fhir.resources/issues/19>`_ Getting validation errors that don't make sense.\n\n\n6.0.0b3 (2020-08-07)\n--------------------\n\n- ``FHIRAbstractModel::get_resource_type`` class method now available, which returning name of the resource.\n\n\n6.0.0b2 (2020-07-09)\n--------------------\n\n- ``FHIRAbstractModel::element_properties`` class method now available, which returning generator of ``ModelField``,\n those are elements of the resource.\n\n- Minor fixes on ``enum_values``.\n\n6.0.0b1 (2020-07-05)\n--------------------\n\nRevolutionary evolution has been made, now fully rewritten with modern python, underlying APIs (almost all) have been changed.\nPlease have look at readme section, for howto.\n\nImprovements\n\n- Full support of FHIR `Extensibility <https://www.hl7.org/fhir/extensibility.html>`_ for `Primitive Data Types <https://www.hl7.org/fhir/datatypes.html#primitive>`_\n\nBreaking\n\n- Drop support for python 2.7.\n\n\n\n5.1.0 (2020-04-11)\n------------------\n\nImprovements\n\n- FHIR ``STU3`` release version upgraded from ``3.0.1`` to ``3.0.2``, Please find changes history here https://www.hl7.org/fhir/history.html.\n\n- FHIR ``R4`` release version upgraded from ``4.0.0`` to ``4.0.1``, find changes history here https://www.hl7.org/fhir/history.html.\n\n\n5.0.1 (2019-07-18)\n------------------\n\nBugfixes:\n\n- `Issue#5 <https://github.com/nazrulworld/fhir.resources/issues/5>`_ confusing error message \"name 'self' is not defined\" [nazrulworld]\n\n\n5.0.0 (2019-06-08)\n------------------\n\n- Nothing but release stable version.\n\n\n5.0.0b3 (2019-05-14)\n--------------------\n\nNew features\n\n- Isuue#1 `Add DSTU2 Support <https://github.com/nazrulworld/fhir.resources/issues/1>`_\n\n\n5.0.0b2 (2019-05-13)\n--------------------\n\nBreaking or Improvments\n\n- ``elementProperties``: element now has extra property ``type_name``. Now format like ``(name, json_name, type, type_name, is_list, \"of_many\", not_optional)``\n The ``type_name`` refers original type name (code) from FHIR Structure Definition and it would be very helpful while\n making fhir search, fhirpath navigator.\n\n\n\n5.0.0b1 (2019-01-19)\n--------------------\n\nNew features\n\n- Implemented own build policy, now previous version of FHIR\u00ae resources are available as python sub-package.\n\nBuild info\n\n- Default version is ``R4`` (see version info at `4.0.0b1 (2019-01-13)` section)\n\n- ``STU3`` (see version info at `3.0.1 (2019-01-13)` section)\n\n\n4.0.0 (2019-01-14)\n------------------\n\n- see version info at ``4.0.0b1`` section.\n\n\n4.0.0b1 (2019-01-13)\n--------------------\n\n`Version Info (R4)`_ ::\n\n [FHIR]\n FhirVersion=4.0.0-a53ec6ee1b\n version=4.0.0\n buildId=a53ec6ee1b\n date=20181227223754\n\n\n\n3.0.1 (2019-01-13)\n------------------\n\n`Version Info (STU3)`_ ::\n\n [FHIR]\n FhirVersion=3.0.1.11917\n version=3.0.1\n revision=11917\n date=20170419074443\n\n\n.. _`Version Info (STU3)`: http://hl7.org/fhir/stu3/\n.. _`Version Info (R4)`: http://hl7.org/fhir/R4/\n",
"bugtrack_url": null,
"license": "BSD license",
"summary": "FHIR Resources as Model Class",
"version": "7.1.0",
"project_urls": {
"CI: Travis": "https://travis-ci.org/github/nazrulworld/fhir.resources",
"Coverage: codecov": "https://codecov.io/gh/nazrulworld/fhir.resources",
"GitHub: issues": "https://github.com/nazrulworld/fhir.resources/issues",
"GitHub: repo": "https://github.com/nazrulworld/fhir.resources",
"Homepage": "https://github.com/nazrulworld/fhir.resources"
},
"split_keywords": [
"fhir",
"resources",
"python",
"hl7",
"health it",
"healthcare"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "155800b50d32c9669acfeaac2c60989a9b49e7bde79c1a8d31801be61ee558e1",
"md5": "e4521a199568bceb1213579fc9cb3981",
"sha256": "4d37c3aadb3afbabad28ca7701b87323680468a13f6a6426bb6c282d4efd5c62"
},
"downloads": -1,
"filename": "fhir.resources-7.1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "e4521a199568bceb1213579fc9cb3981",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.7",
"size": 3121497,
"upload_time": "2023-12-14T12:28:23",
"upload_time_iso_8601": "2023-12-14T12:28:23.565944Z",
"url": "https://files.pythonhosted.org/packages/15/58/00b50d32c9669acfeaac2c60989a9b49e7bde79c1a8d31801be61ee558e1/fhir.resources-7.1.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2fcf3ce9e45ec0b5bddade9d06dfafc91108d6841649ec70057bda785556c1d5",
"md5": "99759ef0d62ecdae4e31fbf831f38abd",
"sha256": "fae2d43c03dacf85a9f9fbce3b62148f3166fe297471cd43b74d91abbf69f818"
},
"downloads": -1,
"filename": "fhir.resources-7.1.0.tar.gz",
"has_sig": false,
"md5_digest": "99759ef0d62ecdae4e31fbf831f38abd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 1916569,
"upload_time": "2023-12-14T12:28:27",
"upload_time_iso_8601": "2023-12-14T12:28:27.907341Z",
"url": "https://files.pythonhosted.org/packages/2f/cf/3ce9e45ec0b5bddade9d06dfafc91108d6841649ec70057bda785556c1d5/fhir.resources-7.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-14 12:28:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nazrulworld",
"github_project": "fhir.resources",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"appveyor": true,
"tox": true,
"lcname": "fhir.resources"
}