A Python FHIR specification parser for model class generation.
The generate.py
script downloads the latest FHIR specification, parses the profiles and represents them in Python.
These representations are then used by Jinja templates to create classes in certain programming languages, mentioned below.
This script does its job for the most part, but it doesn't yet handle all FHIR pecularities and there's no guarantee the output is correct or complete.
The master
branch is currently on DSTU 1.
The develop
branch is currently on DSTU 2 and WiP.
- Copy the file
settings.py
from the respective subdirectory into the project's root directory, - Adjust settings, if necessary
- Execute
./generate.py
to run the script. This will use Python 3, issuepython generate.py
if you don't have Python 3 yet. Supply the-f
flag to force a re-download of the spec.
NOTE that the script currently overwrites existing files without asking and without regret.
This repo currently supports class generation in the following languages:
Swift, Apple's new programming language for OS X and iOS. Since the language is still under active development, the repo will be updated when a language change occurrs. The current supported "version" corresponds to what's accepted by Xcode 6.2. The Swift-FHIR repo contains the latest generated Swift classes.
Classes for Python are targeted towards Python 3 but will support the later 2.x versions – at least they should.
All resource classes will inherit from the FHIRResource
base class, which is a subclass of FHIRElement
.
Dates are expressed as FHIRDate
instances which can parse valid ISO dates.
[x] Generate Python classes
[x] Deserialize from JSON
[x] Implement reference resolver (for contained resources)
[ ] Implement reference resolver (for remote resources)
[ ] Serialize to JSON
[ ] Generate search parameter builder
[ ] Generate unit tests from JSON example files
isodate