Transformation utility to translate data formats into FHIR
Project description
Python FHIR converter, fastish, most nuts and bolts included, ready for production
Provides a python native version of FHIR-Converter written in C#.
The key features are:
- Fastish: Minimize overhead outside the rendering engine
- Move fast: Designed to be extensibile. Use the thin rendering API or leverage the builtin parts
- Easy: Designed to be easy to use, extend and deploy
- Robust: Get production-ready code
Limitations:
- Only CDA->FHIR is currently builtin. Additional work is needed to implement the filters, etc to support FHIR->FHIR and HL7v2->FHIR and back.
- Python-liquid requires a comma between parameters to filters. This does not appear to be a restriction with DotLiquid. As a result templates brought to this environment may need commas added.
Built on the back of:
Table of Contents
Install
Install Python FHIR Converter using Pipenv:
$ pipenv install -u python-fhir-converter
Or pip:
$ pip install python-fhir-converter
Links
- PyPi: https://pypi.org/project/python-fhir-converter/
- Source Code: https://github.com/chaseastewart/fhir-converter
- Issue Tracker: https://github.com/chaseastewart/fhir-converter/issues
Basic Usage
See examples for more indepth usage / usecases.
from fhir_converter.renderers import CcdaRenderer
with open("data/sample/ccda/ccd.ccda") as xml_in:
print(CcdaRenderer().render_fhir_string("CCD", xml_in))
Command line interface
The package comes with a CLI interface that can be invoked either by the script name
fhir_converter_cli or as python module python -m fhir_converter. The CLI allows you to transform a single file or an entire directory.
fhir_converter_cli --from-file ./data/sample/ccda/CCD.ccda --to-dir ./data/out --template-name CCD
---------------------------------------------------------------
RENDER SUCCESS
---------------------------------------------------------------
Total time: 0.14s
Finished at: 2024-01-11 10:49:44.182033
Final Memory: 32M
---------------------------------------------------------------
fhir-converter % fhir_converter_cli --template-dir ./data/templates/ccda --from-dir ./data/sample/ccda --to-dir ./data/out --template-name pampi
---------------------------------------------------------------
RENDER SUCCESS
---------------------------------------------------------------
Total time: 0.32s
Finished at: 2024-01-11 10:49:44.182033
Final Memory: 37M
---------------------------------------------------------------
Templates
Templates can be loaded from any python-liquid supported mechanism. To make packaging easier a ResourceLoader is provided. When a rendering environment is not provided, templates will be loaded from the module resources. To ease the creation of user defined templates a TemplateSystemLoader is provided that allows templates to be loaded from a primary and optionally default location. This allows user defined templates to reference templates in the default location. The example user defined templates reuse the default section / header templates.
Benchmark
You can run the benchmark from the root of the source tree. Test rig is a 16-inch, 2023 Macbook Pro with the M3 Pro not in low power mode. Python version is 3.12.1.
Ordered by: cumulative time
ncalls tottime percall cumtime percall filename:lineno(function)
3 0.000 0.000 12.273 4.091 ./scripts/benchmark.py:75(render_samples)
22 0.003 0.000 12.272 0.558 ./fhir-converter/fhir_converter/renderers.py:187(render_files_to_dir)
484 0.002 0.000 12.258 0.025 ./fhir-converter/fhir_converter/renderers.py:220(render_to_dir)
484 0.010 0.000 12.172 0.025 ./fhir-converter/fhir_converter/renderers.py:93(render_fhir)
484 0.003 0.000 12.004 0.025 ./fhir-converter/fhir_converter/renderers.py:117(render_to_fhir)
Related Projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_fhir_converter-0.0.18.tar.gz.
File metadata
- Download URL: python_fhir_converter-0.0.18.tar.gz
- Upload date:
- Size: 70.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5eeb3119299d9f9bc3776174b53049b2e3aca9535dec4f557ee122494f67633f
|
|
| MD5 |
b04fdf23168c92f5850908567ee689c4
|
|
| BLAKE2b-256 |
6e3da5718ac449130fef424958f34455fceffc246284394494fde464159ffe8d
|
File details
Details for the file python_fhir_converter-0.0.18-py3-none-any.whl.
File metadata
- Download URL: python_fhir_converter-0.0.18-py3-none-any.whl
- Upload date:
- Size: 349.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95c24214c24e99c2f094365c71b10f0f83fec471f4ae4ba97ee837ce6ebaac8a
|
|
| MD5 |
e90f3bbf1cc11ba4131f4d01cac51c33
|
|
| BLAKE2b-256 |
e87dca1791845e512fbc13c4c07d02785329ac39b10b596ede86f5414e9059ad
|