Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaneously support R4, STU3 and DSTU2 #81

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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 = 4.0.0
current_version = 5.0.0
files = fhirclient/client.py

25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI
on: [push, pull_request]
jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: [ '2.7', '3.6', '3.7', 'pypy3' ]
steps:
- name: Checkout
uses: actions/checkout@v1
with:
submodules: true
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run Python ${{ matrix.python }} tests
run: |
pip install -r fhir-parser/requirements.txt
pip install requests isodate flake8
./test_models.sh

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "fhir-parser"]
path = fhir-parser
url = https://github.com/smart-on-fhir/fhir-parser.git
[submodule "fhir-parser-DSTU2"]
path = fhir-parser-DSTU2
url = https://github.com/smart-on-fhir/fhir-parser.git
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Contributors

The following wonderful people contributed directly or indirectly to this project:

- Andrew Wason <https://github.com/rectalogic>
- Erik Wiffin <https://github.com/erikwiffin>
- Josh Mandel <https://github.com/jmandel>
- Nikolai Schwertner <https://github.com/nschwertner>
Expand Down
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 = 4.0.0
PROJECT_NUMBER = 5.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
13 changes: 7 additions & 6 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;
-----------|---------------|---------
**5.0.0** | | (DSTU 2, STU-3, R4)
**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)
Expand Down Expand Up @@ -50,7 +51,7 @@ settings = {
}
smart = client.FHIRClient(settings=settings)

import fhirclient.models.patient as p
import fhirclient.R4.models.patient as p
patient = p.Patient.read('hca-pat-1', smart.server)
patient.birthDate.isostring
# '1963-06-12'
Expand Down Expand Up @@ -81,7 +82,7 @@ You can work with the `FHIRServer` class directly, without using `FHIRClient`, b

```python
smart = server.FHIRServer(None, 'https://fhir-open-api-dstu2.smarthealthit.org')
import fhirclient.models.patient as p
import fhirclient.models.R4.patient as p
patient = p.Patient.read('hca-pat-1', smart)
patient.name[0].given
# ['Christy']
Expand All @@ -93,7 +94,7 @@ You can also search for resources matching a particular set of criteria:

```python
smart = client.FHIRClient(settings=settings)
import fhirclient.models.procedure as p
import fhirclient.models.R4.procedure as p
search = p.Procedure.where(struct={'subject': 'hca-pat-1', 'status': 'completed'})
procedures = search.perform_resources(smart.server)
for procedure in procedures:
Expand All @@ -112,8 +113,8 @@ Starting with version 1.0.5, data model validity are enforced to a certain degre
#### Initialize Data Model

```python
import fhirclient.models.patient as p
import fhirclient.models.humanname as hn
import fhirclient.models.R4.patient as p
import fhirclient.models.R4.humanname as hn
patient = p.Patient({'id': 'patient-1'})
patient.id
# prints `patient-1`
Expand All @@ -138,7 +139,7 @@ patient.as_json()

```python
import json
import fhirclient.models.patient as p
import fhirclient.models.R4.patient as p
with open('path/to/patient.json', 'r') as h:
pjs = json.load(h)
patient = p.Patient(pjs)
Expand Down
1 change: 1 addition & 0 deletions fhir-parser-DSTU2
Submodule fhir-parser-DSTU2 added at 8f179b
19 changes: 19 additions & 0 deletions fhir-parser-resources/settings-DSTU2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# These are settings for the FHIR class generator

from Python.settings import *

# classes/resources
write_resources = True
tpl_resource_target_ptrn = '../fhirclient/models/DSTU2/{}.py' # where to write the generated class files to, with one placeholder for the class name
resource_base_target = '../fhirclient/models/DSTU2/' # resource target directory, likely the same as `tpl_resource_target_ptrn` without the filename pattern

# factory methods
write_factory = True
tpl_factory_target = '../fhirclient/models/DSTU2/fhirelementfactory.py'

# unit tests
write_unittests = True
tpl_unittest_target_ptrn = '../fhirclient/models/DSTU2/{}_tests.py'

# jinja2 doesn't support '..', generate_models.sh copies this file here
tpl_unittest_source = 'env/template-unittest.py'
8 changes: 4 additions & 4 deletions fhir-parser-resources/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
from Default.settings import *

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

# 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'

# classes/resources
write_resources = True
tpl_resource_target = '../fhirclient/models' # target directory to write the generated class files to
tpl_resource_target = '../fhirclient/models/{FHIR_VERSION}' # target directory to write the generated class files to
tpl_codesystems_source = None # the template to use as source when writing enums for CodeSystems; can be `None`

# factory methods
write_factory = True
tpl_factory_target = '../fhirclient/models/fhirelementfactory.py' # where to write the generated factory to
tpl_factory_target = '../fhirclient/models/{FHIR_VERSION}/fhirelementfactory.py' # where to write the generated factory to

# unit tests
write_unittests = True
tpl_unittest_target = '../fhirclient/models' # target directory to write the generated unit test files to
tpl_unittest_target = '../fhirclient/models/{FHIR_VERSION}' # target directory to write the generated unit test files to


# all these files should be copied to dirname(`tpl_resource_target_ptrn`): tuples of (path/to/file, module, array-of-class-names)
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 @@ -4,7 +4,7 @@
# Generated from FHIR {{ info.version }} on {{ info.date }}.
# {{ info.year }}, SMART Health IT.


from __future__ import unicode_literals
import os
import io
import unittest
Expand Down
5 changes: 0 additions & 5 deletions fhirclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
import sys
import os.path
abspath = os.path.abspath(os.path.dirname(__file__))
if abspath not in sys.path:
sys.path.insert(0, abspath)
Loading