A Python FHIR specification parser for model class generation.
The generate.py script downloads FHIR specification files, parses the profiles and represents them as FHIRClass
instances with FHIRClassProperty
properties (found in fhirclass.py).
Additionally, FHIRUnitTest
(in fhirunittest.py) instances get created that can generate unit tests from provided FHIR examples.
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. Unless you have a desire to understand how parsing works, you should be able to play with Lang/settings.py, Lang/mappings.py and Lang/templates* to achieve what you need.
The master
branch is currently on DSTU 2, May 2015 ballot.
The develop
branch is currently on DSTU 2 and WiP.
See [tags][releases] for other specific FHIR versions.
- Copy the file
settings.py
from the language's 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.
The Swift classes depend on two protocols to be implemented, defined in Swift/FHIRServer.swift
.
Implementations are provided by the Swift-FHIR library.
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
[x] Generate search parameter builder
[x] Generate unit tests from JSON example files
isodate