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
- 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
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 14-inch, 2021 Macbook Pro with the M1 Pro. The benchmark performs the conversion for each template showing the min, max and mean times for the sample data used.
Python Version=3.12.1
Iterations=20
Sample=data/sample/ccda/Discharge_Summary.ccda
CCD max=0.042 min=0.013 avg=0.015
ConsultationNote max=0.015 min=0.013 avg=0.014
DischargeSummary max=0.020 min=0.014 avg=0.014
HistoryandPhysical max=0.015 min=0.013 avg=0.014
OperativeNote max=0.014 min=0.010 avg=0.010
ProcedureNote max=0.013 min=0.011 avg=0.012
ProgressNote max=0.013 min=0.012 avg=0.012
ReferralNote max=0.015 min=0.014 avg=0.014
TransferSummary max=0.016 min=0.014 avg=0.014
LabsandVitals max=0.009 min=0.008 avg=0.008
Pampi max=0.010 min=0.009 avg=0.009
Sample=data/sample/ccda/History_and_Physical.ccda
CCD max=0.053 min=0.018 avg=0.020
ConsultationNote max=0.021 min=0.018 avg=0.019
DischargeSummary max=0.018 min=0.016 avg=0.017
HistoryandPhysical max=0.020 min=0.018 avg=0.019
OperativeNote max=0.013 min=0.011 avg=0.012
ProcedureNote max=0.015 min=0.014 avg=0.014
ProgressNote max=0.017 min=0.015 avg=0.016
ReferralNote max=0.022 min=0.018 avg=0.019
TransferSummary max=0.021 min=0.019 avg=0.020
LabsandVitals max=0.012 min=0.010 avg=0.011
Pampi max=0.013 min=0.012 avg=0.012
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.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6f7514cf849b3ab143f1ad8a94fb9c1faa5320e71f7753ad1cfeca768313b31 |
|
MD5 | 7833ce2016803e7531f778d4bd9a6136 |
|
BLAKE2b-256 | 729b23ff8b7f53058ca9b1527e7ee92119690b595289f058de692b0fe7cb6129 |
Hashes for python_fhir_converter-0.0.20-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70728b2a3cf4421bec2b5972168facaf503e553b2242433bebda3a0b4e60fe82 |
|
MD5 | 7e7f5dc085ec1889f37c27329625f359 |
|
BLAKE2b-256 | 2314c442a6ca557a6f70fece46cb21be96ab3c00885979cc03944feec6060650 |