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 implementation of FHIR-Converter written in C#. This allows the data transformation to live and breath as any other python module in your favorite python based data pipeline framework
Key features:
- Fast: Speed is relative. Minimizes overhead outside the rendering engine. Can't take credit for the liquid 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. Use what's bundled or manage the environment your way
- Robust: Get
production-ready, tested code. Not all projects disclose what is and isn't covered
Limitations:
- Only CDA->FHIR is currently builtin. Additional work is needed to implement the filters, etc to support FHIR->FHIR and HL7v2->FHIR.
- Python-liquid requires a comma between parameters. 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
- Documentation: https://chaseastewart.github.io/fhir-converter/
- PyPi: https://pypi.org/project/python-fhir-converter/
- Source: https://github.com/chaseastewart/fhir-converter
- Issues: 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
---------------------------------------------------------------
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 / resue of templates a TemplateSystemLoader is provided that handles the template name conventions establised by FHIR-Converter. This allows user defined templates to reference existing templates without change. 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 11.164 3.721 ./scripts/benchmark.py:75(render_samples)
22 0.003 0.000 11.164 0.507 ./fhir-converter/fhir_converter/renderers.py:187(render_files_to_dir)
484 0.002 0.000 11.154 0.023 ./fhir-converter/fhir_converter/renderers.py:220(render_to_dir)
484 0.010 0.000 11.017 0.023 ./fhir-converter/fhir_converter/renderers.py:93(render_fhir)
484 0.003 0.000 10.876 0.022 ./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
Hashes for python_fhir_converter-0.0.19.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e655ac6ed7c1cc1be20771b408c43b0d668bb65efb94ed3661d0e9541f272813 |
|
MD5 | c9f9de511dc927d6ba827a704bd04333 |
|
BLAKE2b-256 | 90eb3667a3eeca690d61bc6569a92f039427e8489542e074c146d7c2e62b967e |
Hashes for python_fhir_converter-0.0.19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 617452281df5594f69f4a16846b7cfefb482265e609d56a3c2abb89ad6a1065b |
|
MD5 | 7ace420a73631c3956e41bef00e2a468 |
|
BLAKE2b-256 | a20200c83f601dd0fd147c43a705ab437af4e26b3441b30d9361113d569ed139 |