Package: python-fhir-converter
Python FHIR converter, fastish, most nuts and bolts included, ready for productionProvides a python implementation ofFHIR-Converterwritten inC#. This allows the data transformation to live and breath as any other python module in your favorite python based data pipeline frameworkWhats supported:CDA->FHIR R4STU3->FHIR R4Key features:Fast.Speed is relative. Minimizes overhead outside the rendering engineDesigned to be extensibile.Use the thin rendering API or leverage the builtin partsDesigned to be easy to use, extend and deploy.Use what's bundled or manage the environment your wayMultiple enhancement / bug correctionsincluded with the packaged CDA->R4 templates.Limitations:Additional workis needed to support JSON->FHIR, HL7v2->FHIR and FHIR->HL7v2.Comma between parameters. Python-liquidrequiresa comma between parameters. Templates brought to this environment may need commas added.Variable names when passing variables to a snippet. Python-liquidrequiresthe identifier / variable name. Templates brought to this environment may need changes. SeeResource.liquidas an example of a template that has been updated.C# date format stringsare supported to an extent to mimimize the impact of migrating templates. Seefiltersfor more information.Built on the back of:FHIR-Converterpython-liquidTable of ContentsInstallLinksBasic UsageCommand line interfaceTemplatesBenchmarkRelated ProjectsInstallInstall Python FHIR Converter usingPipenv:$pipenvinstall-upython-fhir-converterOrpip:$pipinstallpython-fhir-converterLinksDocumentation:https://chaseastewart.github.io/fhir-converter/PyPi:https://pypi.org/project/python-fhir-converter/Source:https://github.com/chaseastewart/fhir-converterIssues:https://github.com/chaseastewart/fhir-converter/issuesBasic UsageSeeexamplesfor more indepth usage / usecases.fromfhir_converter.renderersimportCcdaRendererwithopen("data/sample/ccda/ccd.ccda")asxml_in:print(CcdaRenderer().render_fhir_string("CCD",xml_in))Command line interfaceThe package comes with a CLI interface that can be invoked either by the script namefhir_converter_clior as python modulepython -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-nameCCD
---------------------------------------------------------------
RENDERSUCCESS
---------------------------------------------------------------
Totaltime:0.14s
Finishedat:2024-01-1110:49:44.182033
FinalMemory:32M
---------------------------------------------------------------TemplatesTemplates can be loaded from any python-liquid supported mechanism. To make packaging easier aResourceLoaderis provided. When a rendering environment is not provided, templates will be loaded from the moduleresources. To ease the creation / reuse of templates aTemplateSystemLoaderis provided that handles the template name conventions establised byFHIR-Converter. This allows user defined templates to reference existing templates without change. The example user definedtemplatesreuse the default section / header templates.BenchmarkYou can run thebenchmarkfrom 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.012Related ProjectsFHIR-Converterpython-liquidpyjson5xmltodict