Stream: python
Topic: Logical Models in Python
Eric Haas (Apr 19 2018 at 19:17):
Can one generate a python model for a FHIR logical model ( based on a SD) - is that documented somewhere.?
Eric Haas (May 10 2018 at 17:31):
ping re this?
Pascal Pfiffner (May 10 2018 at 22:41):
I think it will work if you add your StructureDefinition
to the downloads folder with the appropriate name, but you have to generate all classes since the parser depends on knowing base elements and resources.
Eric Haas (May 11 2018 at 23:58):
how to insert your own models into fhirclient.
use fhir-parser to create python classes (models)
follow instruction in readme
notes:
- I ran in python3.4 (python3.6 did not work)
- I changed the source directory in specification_url = 'http://hl7.org/fhir/STU3/' for STU3
- download the spec into the downloads
folder using the command python3 generate.py -fl
- inject my SDs into the bundle file downloads/profiles-resources.json
and your folders should end up looking like this...
.
├── fhir-parser
│ ├── Default
│ ├── LICENSE.txt
│ ├── README.md
│ ├── Sample
│ ├── __pycache__
│ ├── downloads
│ ├── fhirclass.py
│ ├── fhirloader.py
│ ├── fhirrenderer.py
│ ├── fhirspec.py
│ ├── fhirunittest.py
│ ├── generate.py
│ ├── logger.py
│ ├── mappings.py
│ ├── requirements.txt
│ └── settings.py
└── models (this is created by generate.py)
├── account.py
...
└── visionprescription_tests.py
now you can copy your model file(s) from the models
folder and add it to the fhirclient folder (or just replace the whole folder) after you pip install that in your environment :
For example, in [path to environment]/venv36/lib/python3.6/site-packages/fhirclient/models
Geoff Low (May 13 2018 at 08:37):
What was the error with 3.6?
Eric Haas (May 13 2018 at 23:47):
Probably an environment issue on my machine, I didn't investigate.
Eric Haas (May 21 2018 at 16:03):
working on 3.6.2 too. fixed my environment and my atom editor.
Last updated: Apr 12 2022 at 19:14 UTC