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
Whats supported:
- CDA->FHIR R4
- STU3->FHIR R4
Key features:
- Fast. Speed is relative. Minimizes overhead outside the rendering engine
- Designed to be extensibile. Use the thin rendering API or leverage the builtin parts
- Designed to be easy to use, extend and deploy. Use what's bundled or manage the environment your way
- Multiple enhancement / bug corrections included with the packaged CDA->R4 templates.
Limitations:
- Additional work is needed to support JSON->FHIR, HL7v2->FHIR and FHIR->HL7v2.
- Comma between parameters. Python-liquid requires a comma between parameters. Templates brought to this environment may need commas added.
- Variable names when passing variables to a snippet. Python-liquid requires the identifier / variable name. Templates brought to this environment may need changes. See Resource.liquid as an example of a template that has been updated.
- C# date format strings are supported to an extent to mimimize the impact of migrating templates. See filters for more information.
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. When a rendering environment is not provided, templates will be loaded from the module templates. To ease the creation / reuse 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
Metadata
Release files for python-fhir-converter 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_fhir_converter-0.3.0.tar.gz | 114.2 kB | Without provenance | Details for python_fhir_converter-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_fhir_converter-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for python_fhir_converter-0.3.0-py3-none-any.whl |
Total release size: 594.1 kB
Release files / python_fhir_converter-0.3.0.tar.gz
| Download URL | python_fhir_converter-0.3.0.tar.gz |
|---|---|
| Size | 114.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f313802904b8ffcc691d7bb77fd14f3b80e781dad3e7cd0ead901f0804477ea
|
|
BLAKE2b-256 checksum How to use checksums |
d6f8f3ae1379ed1d15a91a04d37b9322f3ca3b879663bb5e65830a9bd3724e58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.1 Darwin/23.5.0
|
Release files / python_fhir_converter-0.3.0-py3-none-any.whl
| Download URL | python_fhir_converter-0.3.0-py3-none-any.whl |
|---|---|
| Size | 479.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
677824f3aaa8e017d39aa451820062bb9d6867465627347cc864e67906889b62
|
|
BLAKE2b-256 checksum How to use checksums |
a950072a40993bf25869d3c924b3a6e99d09427124fd14d0736ae047c0a6956f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.1 Darwin/23.5.0
|
Security for python-fhir-converter 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.