Skip to content

Commit

Permalink
Update to FHIR 4.0.0 (#67)
Browse files Browse the repository at this point in the history
Updates Data models to R4 and closes #59.
  • Loading branch information
raheelsayeed authored and Culby committed May 8, 2019
1 parent 68a63dd commit 16540a4
Show file tree
Hide file tree
Showing 363 changed files with 32,847 additions and 15,982 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[bumpversion]
current_version = 3.2.0
current_version = 4.0.0
files = fhirclient/client.py

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ session_data
# IDE files
*.sublime-*

.DS_Store
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following wonderful people contributed directly or indirectly to this projec
- Josh Mandel <https://github.com/jmandel>
- Nikolai Schwertner <https://github.com/nschwertner>
- Pascal Pfiffner <https://github.com/p2>
- Raheel Sayeed <https://github.com/raheelsayeed>
- Trinadh Baranika <https://github.com/bktrinadh>

Please add yourself here alphabetically when you submit your first pull request.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "SMART on FHIR Python Client"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 3.2.0
PROJECT_NUMBER = 4.0.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The `develop` branch should be on recent freezes, and the `feature/latest-ci` br

Version | FHIR | &nbsp;
-----------|---------------|---------
**4.0.0** | `4.0.0` | (R4)
**3.0.0** | `3.0.0` | (STU-3)
**x.x** | `1.8.0` | (STU-3 Ballot, Jan 2017)
**x.x** | `1.6.0` | (STU-3 Ballot, Sep 2016)
Expand Down
2 changes: 1 addition & 1 deletion fhir-parser
2 changes: 1 addition & 1 deletion fhir-parser-resources/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from Default.settings import *

# Base URL for where to load specification data from
specification_url = 'http://hl7.org/fhir/STU3'
specification_url = 'http://hl7.org/fhir/R4'

# In which directory to find the templates. See below for settings that start with `tpl_`: these are the template names.
tpl_base = '../fhir-parser-resources'
Expand Down
2 changes: 1 addition & 1 deletion fhir-parser-resources/template-unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test{{ class.name }}{{ loop.index }}(self):
def impl{{ class.name }}{{ loop.index }}(self, inst):
{%- for onetest in tcase.tests %}
{%- if "str" == onetest.klass.name %}
self.assertEqual(inst.{{ onetest.path }}, "{{ onetest.value|replace('"', '\\"') }}")
self.assertEqual(inst.{{ onetest.path }}, "{{ onetest.value|replace('\\n', '\\\\n')|replace('"', '\\"') }}")
{%- else %}{% if "int" == onetest.klass.name or "float" == onetest.klass.name or "NSDecimalNumber" == onetest.klass.name %}
self.assertEqual(inst.{{ onetest.path }}, {{ onetest.value }})
{%- else %}{% if "bool" == onetest.klass.name %}
Expand Down
2 changes: 1 addition & 1 deletion fhirclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from server import FHIRServer, FHIRUnauthorizedException, FHIRNotFoundException

__version__ = '3.2.0'
__version__ = '4.0.0'
__author__ = 'SMART Platforms Team'
__license__ = 'APACHE2'
__copyright__ = "Copyright 2017 Boston Children's Hospital"
Expand Down
27 changes: 14 additions & 13 deletions fhirclient/fhirreference_tests.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ def testContainedResourceDetection(self):
self.assertEqual('Observation.subject', group.linkId)
question = group.item[0]
self.assertEqual('Observation.subject._type', question.linkId)
self.assertIsNotNone(question.options)
self.assertIsNotNone(question.answerOption)
with self.assertRaises(Exception):
question.options.resolved()

question.answerOption[0].valueReference.resolved()
reference = question.answerOption[0].valueReference
# 1st resolve, extracting from contained resources
contained = question.options.resolved(medication.Medication)
contained = reference.resolved(medication.Medication)
self.assertIsNone(contained, "Must not resolve on resource type mismatch")
contained = question.options.resolved(valueset.ValueSet)
contained = reference.resolved(valueset.ValueSet)
self.assertIsNotNone(contained, "Must resolve contained ValueSet")
self.assertEqual('ValueSet', contained.resource_type)
self.assertEqual('Type options for Observation.subject', contained.name)

# 2nd resolve, should pull from cache
contained = question.options.resolved(medication.Medication)
contained = reference.resolved(medication.Medication)
self.assertIsNone(contained, "Must not resolve on resource type mismatch")
contained = question.options.resolved(resource.Resource)
contained = reference.resolved(resource.Resource)
self.assertIsNotNone(contained, "Must resolve contained ValueSet even if requesting `Resource`")
contained = question.options.resolved(valueset.ValueSet)
contained = reference.resolved(valueset.ValueSet)
self.assertIsNotNone(contained, "Must resolve contained ValueSet")
self.assertEqual('ValueSet', contained.resource_type)

Expand All @@ -63,20 +63,21 @@ def testRelativeReference(self):
self.assertEqual('Observation.subject', group.linkId)
question = group.item[0]
self.assertEqual('Observation.subject._type', question.linkId)
self.assertIsNotNone(question.options)
self.assertIsNotNone(question.answerOption)
with self.assertRaises(Exception):
question.options.resolved()
question.answerOption[0].valueReference.resolved()
reference = question.answerOption[0].valueReference

# resolve relative resource
relative = question.options.resolved(valueset.ValueSet)
relative = reference.resolved(valueset.ValueSet)
self.assertIsNotNone(relative, "Must resolve relative ValueSet")
self.assertEqual('ValueSet', relative.resource_type)
self.assertEqual('Type options for Observation.subject', relative.name)

# 2nd resolve, should pull from cache
relative = question.options.resolved(medication.Medication)
relative = reference.resolved(medication.Medication)
self.assertIsNone(relative, "Must not resolve on resource type mismatch")
relative = question.options.resolved(resource.Resource)
relative = reference.resolved(resource.Resource)
self.assertIsNotNone(relative, "Must resolve relative ValueSet even if requesting `Resource`")

def testBundleReferences(self):
Expand Down
58 changes: 25 additions & 33 deletions fhirclient/models/account.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 3.0.0.11832 (http://hl7.org/fhir/StructureDefinition/Account) on 2017-03-22.
# 2017, SMART Health IT.
# Generated from FHIR 4.0.0-a53ec6ee1b (http://hl7.org/fhir/StructureDefinition/Account) on 2019-05-07.
# 2019, SMART Health IT.


from . import domainresource
Expand All @@ -25,14 +25,6 @@ def __init__(self, jsondict=None, strict=True):
:param bool strict: If True (the default), invalid variables will raise a TypeError
"""

self.active = None
""" Time window that transactions may be posted to this account.
Type `Period` (represented as `dict` in JSON). """

self.balance = None
""" How much is in account?.
Type `Money` (represented as `dict` in JSON). """

self.coverage = None
""" The party(s) that are responsible for covering the payment of this
account, and what order should they be applied to the account.
Expand All @@ -43,7 +35,7 @@ def __init__(self, jsondict=None, strict=True):
Type `str`. """

self.guarantor = None
""" Responsible for the account.
""" The parties ultimately responsible for balancing the Account.
List of `AccountGuarantor` items (represented as `dict` in JSON). """

self.identifier = None
Expand All @@ -55,20 +47,24 @@ def __init__(self, jsondict=None, strict=True):
Type `str`. """

self.owner = None
""" Who is responsible?.
Type `FHIRReference` referencing `Organization` (represented as `dict` in JSON). """
""" Entity managing the Account.
Type `FHIRReference` (represented as `dict` in JSON). """

self.period = None
self.partOf = None
""" Reference to a parent Account.
Type `FHIRReference` (represented as `dict` in JSON). """

self.servicePeriod = None
""" Transaction window.
Type `Period` (represented as `dict` in JSON). """

self.status = None
""" active | inactive | entered-in-error.
""" active | inactive | entered-in-error | on-hold | unknown.
Type `str`. """

self.subject = None
""" What is account tied to?.
Type `FHIRReference` referencing `Patient, Device, Practitioner, Location, HealthcareService, Organization` (represented as `dict` in JSON). """
""" The entity that caused the expenses.
List of `FHIRReference` items (represented as `dict` in JSON). """

self.type = None
""" E.g. patient, expense, depreciation.
Expand All @@ -79,17 +75,16 @@ def __init__(self, jsondict=None, strict=True):
def elementProperties(self):
js = super(Account, self).elementProperties()
js.extend([
("active", "active", period.Period, False, None, False),
("balance", "balance", money.Money, False, None, False),
("coverage", "coverage", AccountCoverage, True, None, False),
("description", "description", str, False, None, False),
("guarantor", "guarantor", AccountGuarantor, True, None, False),
("identifier", "identifier", identifier.Identifier, True, None, False),
("name", "name", str, False, None, False),
("owner", "owner", fhirreference.FHIRReference, False, None, False),
("period", "period", period.Period, False, None, False),
("status", "status", str, False, None, False),
("subject", "subject", fhirreference.FHIRReference, False, None, False),
("partOf", "partOf", fhirreference.FHIRReference, False, None, False),
("servicePeriod", "servicePeriod", period.Period, False, None, False),
("status", "status", str, False, None, True),
("subject", "subject", fhirreference.FHIRReference, True, None, False),
("type", "type", codeableconcept.CodeableConcept, False, None, False),
])
return js
Expand All @@ -113,9 +108,9 @@ def __init__(self, jsondict=None, strict=True):
"""

self.coverage = None
""" The party(s) that are responsible for covering the payment of this
account.
Type `FHIRReference` referencing `Coverage` (represented as `dict` in JSON). """
""" The party(s), such as insurances, that may contribute to the
payment of this account.
Type `FHIRReference` (represented as `dict` in JSON). """

self.priority = None
""" The priority of the coverage in the context of this account.
Expand All @@ -133,9 +128,10 @@ def elementProperties(self):


class AccountGuarantor(backboneelement.BackboneElement):
""" Responsible for the account.
""" The parties ultimately responsible for balancing the Account.
Parties financially responsible for the account.
The parties responsible for balancing the account if other payment options
fall short.
"""

resource_type = "AccountGuarantor"
Expand All @@ -154,10 +150,10 @@ def __init__(self, jsondict=None, strict=True):

self.party = None
""" Responsible entity.
Type `FHIRReference` referencing `Patient, RelatedPerson, Organization` (represented as `dict` in JSON). """
Type `FHIRReference` (represented as `dict` in JSON). """

self.period = None
""" Guarrantee account during.
""" Guarantee account during.
Type `Period` (represented as `dict` in JSON). """

super(AccountGuarantor, self).__init__(jsondict=jsondict, strict=strict)
Expand Down Expand Up @@ -185,10 +181,6 @@ def elementProperties(self):
from . import identifier
except ImportError:
identifier = sys.modules[__package__ + '.identifier']
try:
from . import money
except ImportError:
money = sys.modules[__package__ + '.money']
try:
from . import period
except ImportError:
Expand Down
70 changes: 30 additions & 40 deletions fhirclient/models/account_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Generated from FHIR 3.0.0.11832 on 2017-03-22.
# 2017, SMART Health IT.
# Generated from FHIR 4.0.0-a53ec6ee1b on 2019-05-07.
# 2019, SMART Health IT.


import os
Expand All @@ -22,7 +22,7 @@ def instantiate_from(self, filename):
return account.Account(js)

def testAccount1(self):
inst = self.instantiate_from("account-example-with-guarantor.json")
inst = self.instantiate_from("account-example.json")
self.assertIsNotNone(inst, "Must have instantiated a Account instance")
self.implAccount1(inst)

Expand All @@ -32,38 +32,29 @@ def testAccount1(self):
self.implAccount1(inst2)

def implAccount1(self, inst):
self.assertEqual(inst.active.end.date, FHIRDate("2016-06-30").date)
self.assertEqual(inst.active.end.as_json(), "2016-06-30")
self.assertEqual(inst.active.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.active.start.as_json(), "2016-01-01")
self.assertEqual(inst.balance.code, "USD")
self.assertEqual(inst.balance.system, "urn:iso:std:iso:4217")
self.assertEqual(inst.balance.unit, "USD")
self.assertEqual(inst.balance.value, -1200)
self.assertEqual(inst.coverage[0].priority, 1)
self.assertEqual(inst.coverage[1].priority, 2)
self.assertEqual(inst.description, "Hospital charges")
self.assertFalse(inst.guarantor[0].onHold)
self.assertEqual(inst.guarantor[0].period.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.guarantor[0].period.start.as_json(), "2016-01-01")
self.assertEqual(inst.id, "ewg")
self.assertEqual(inst.id, "example")
self.assertEqual(inst.identifier[0].system, "urn:oid:0.1.2.3.4.5.6.7")
self.assertEqual(inst.identifier[0].value, "654321")
self.assertEqual(inst.name, "Inpatient: Peter James Chalmers")
self.assertEqual(inst.period.end.date, FHIRDate("2016-06-30").date)
self.assertEqual(inst.period.end.as_json(), "2016-06-30")
self.assertEqual(inst.period.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.period.start.as_json(), "2016-01-01")
self.assertEqual(inst.meta.tag[0].code, "HTEST")
self.assertEqual(inst.meta.tag[0].display, "test health data")
self.assertEqual(inst.meta.tag[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActReason")
self.assertEqual(inst.name, "HACC Funded Billing for Peter James Chalmers")
self.assertEqual(inst.servicePeriod.end.date, FHIRDate("2016-06-30").date)
self.assertEqual(inst.servicePeriod.end.as_json(), "2016-06-30")
self.assertEqual(inst.servicePeriod.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.servicePeriod.start.as_json(), "2016-01-01")
self.assertEqual(inst.status, "active")
self.assertEqual(inst.text.div, "<div xmlns=\"http://www.w3.org/1999/xhtml\">Inpatient Admission for Peter James Chalmers Account</div>")
self.assertEqual(inst.text.div, "<div xmlns=\"http://www.w3.org/1999/xhtml\">HACC Funded Billing for Peter James Chalmers</div>")
self.assertEqual(inst.text.status, "generated")
self.assertEqual(inst.type.coding[0].code, "PBILLACCT")
self.assertEqual(inst.type.coding[0].display, "patient billing account")
self.assertEqual(inst.type.coding[0].system, "http://hl7.org/fhir/v3/ActCode")
self.assertEqual(inst.type.coding[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActCode")
self.assertEqual(inst.type.text, "patient")

def testAccount2(self):
inst = self.instantiate_from("account-example.json")
inst = self.instantiate_from("account-example-with-guarantor.json")
self.assertIsNotNone(inst, "Must have instantiated a Account instance")
self.implAccount2(inst)

Expand All @@ -73,29 +64,28 @@ def testAccount2(self):
self.implAccount2(inst2)

def implAccount2(self, inst):
self.assertEqual(inst.active.end.date, FHIRDate("2016-06-30").date)
self.assertEqual(inst.active.end.as_json(), "2016-06-30")
self.assertEqual(inst.active.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.active.start.as_json(), "2016-01-01")
self.assertEqual(inst.balance.code, "USD")
self.assertEqual(inst.balance.system, "urn:iso:std:iso:4217")
self.assertEqual(inst.balance.unit, "USD")
self.assertEqual(inst.balance.value, -1200)
self.assertEqual(inst.coverage[0].priority, 1)
self.assertEqual(inst.coverage[1].priority, 2)
self.assertEqual(inst.description, "Hospital charges")
self.assertEqual(inst.id, "example")
self.assertFalse(inst.guarantor[0].onHold)
self.assertEqual(inst.guarantor[0].period.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.guarantor[0].period.start.as_json(), "2016-01-01")
self.assertEqual(inst.id, "ewg")
self.assertEqual(inst.identifier[0].system, "urn:oid:0.1.2.3.4.5.6.7")
self.assertEqual(inst.identifier[0].value, "654321")
self.assertEqual(inst.name, "HACC Funded Billing for Peter James Chalmers")
self.assertEqual(inst.period.end.date, FHIRDate("2016-06-30").date)
self.assertEqual(inst.period.end.as_json(), "2016-06-30")
self.assertEqual(inst.period.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.period.start.as_json(), "2016-01-01")
self.assertEqual(inst.meta.tag[0].code, "HTEST")
self.assertEqual(inst.meta.tag[0].display, "test health data")
self.assertEqual(inst.meta.tag[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActReason")
self.assertEqual(inst.name, "Inpatient: Peter James Chalmers")
self.assertEqual(inst.servicePeriod.end.date, FHIRDate("2016-06-30").date)
self.assertEqual(inst.servicePeriod.end.as_json(), "2016-06-30")
self.assertEqual(inst.servicePeriod.start.date, FHIRDate("2016-01-01").date)
self.assertEqual(inst.servicePeriod.start.as_json(), "2016-01-01")
self.assertEqual(inst.status, "active")
self.assertEqual(inst.text.div, "<div xmlns=\"http://www.w3.org/1999/xhtml\">HACC Funded Billing for Peter James Chalmers</div>")
self.assertEqual(inst.text.div, "<div xmlns=\"http://www.w3.org/1999/xhtml\">Inpatient Admission for Peter James Chalmers Account</div>")
self.assertEqual(inst.text.status, "generated")
self.assertEqual(inst.type.coding[0].code, "PBILLACCT")
self.assertEqual(inst.type.coding[0].display, "patient billing account")
self.assertEqual(inst.type.coding[0].system, "http://hl7.org/fhir/v3/ActCode")
self.assertEqual(inst.type.coding[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActCode")
self.assertEqual(inst.type.text, "patient")

Loading

0 comments on commit 16540a4

Please sign in to comment.