-
Notifications
You must be signed in to change notification settings - Fork 651
Flexporter
The Synthea Flexible Exporter a.k.a. "Flexporter" is a utility designed to make it easy to add new fields, values, and resource types to Synthea-generated FHIR, without having to modify the Synthea engine. Primary users of this feature are expected to be Implementation Guide authors and users, electronic clinical quality measure developers and testers, and anyone who needs just a slight tweak to the data exported by Synthea.
As of 2022-07-28, this feature is only available on the flexporter
branch: https://github.com/synthetichealth/synthea/tree/flexporter
The basic idea of the Flexporter is that users will define a series of transformations to apply to Synthea data. A predefined set of transformations, such as "set field X to value Y" or "create a new resource" is intended to cover the majority of use cases while still remaining easy to use.
./run_synthea -fm mapping_file [-ig ig_folder]
The Flexporter can also run standalone to post-process FHIR Bundles.
./run_flexporter -fm mapping_file -s source_fhir [-ig ig_folder]
The format of the mapping file is as follows:
---
# name is just a friendly name for this mapping
name: Flexporter Mapping
# applicability determines whether this mapping applies to a given file.
# for now the assumption is 1 file = 1 synthea patient bundle.
# NOT YET IMPLEMENTED
# Eventually this should be a FHIRPath which should return a "truthy" value if the mapping applies
applicability: true
# actions is a list of Action objects. see below for details
actions:
- name: Apply Profiles
Actions are driven by a key property name on the object. (technical note: this is because the YML library doesn't support discriminators like GSON does for JSON, think like how state types get mapped into a different class by type)
Key name: "profiles"
At the core of the flexporter is the CustomFHIRPathResourceGeneratorR4 class - this is based on a community contribution within HAPI which we've added some additional functionality to. It does some magic using HAPI's internal reflection (on top of Java reflection), so it can be a bear to wrap your head around. Debugging and stepping through examples makes it easier. https://github.com/synthetichealth/synthea/blob/flexporter/src/main/java/org/mitre/synthea/export/flexporter/CustomFHIRPathResourceGeneratorR4.java