Skip to content
Dylan Hall edited this page Aug 4, 2022 · 15 revisions

⚠️⚠️ WARNING: Here be dragons. This feature is a very rough work in progress. Features that you expect may be missing, and features that do exist may be broken. Proceed with caution. ⚠️⚠️

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

Approach

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.

Usage

In Synthea

./run_synthea -fm mapping_file [-ig ig_folder]

Standalone

The Flexporter can also run standalone to post-process FHIR Bundles.

./run_flexporter -fm mapping_file -s source_fhir [-ig ig_folder]

https://github.com/synthetichealth/synthea/blob/flexporter/src/main/java/RunFlexporter.java

Mapping File

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

https://github.com/synthetichealth/synthea/blob/flexporter/src/main/java/org/mitre/synthea/export/flexporter/Actions.java

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)

Apply Profiles

Key name: "profiles"

Set Values

Create Resource

Keep Resources

Delete Resources

Value Functions

Value Transforms

https://github.com/synthetichealth/synthea/blob/flexporter/src/main/java/org/mitre/synthea/export/flexporter/ValueTransforms.java

Examples

Technical Notes

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

Clone this wiki locally