Skip to content
Dylan Hall edited this page May 9, 2024 · 27 revisions

Synthea generates HL7 FHIR records using the HAPI FHIR library to generate a FHIR Bundle for each Patient. Currently, only JSON is supported.

Currently supported FHIR Resources:

  • AllergyIntolerance
  • Bundle
  • CarePlan
  • Claim
  • Condition
  • Coverage (R4 and STU3 only)
  • DiagnosticReport (for labs)
  • Encounter
  • ExplanationOfBenefit (R4 and STU3 only, Blue Button 2.0 Implementation Guide in STU3)
  • Goal
  • ImagingStudy
  • Immunization
  • MedicationRequest
  • MedicationAdministration
  • Observation
  • Organization
  • Patient
  • Practitioner
  • Procedure

Resources only supported with R4 and when US Core is enabled:

  • CareTeam
  • Device
  • DiagnosticReport (for clinical notes)
  • DocumentReference (for clinical notes)
  • Location
  • Medication
  • PractitionerRole
  • Provenance

Supported versions of US Core:

  • 6.1.0
  • 5.0.1 (R5)
  • 4.0.0 (R4)
  • 3.1.1 (R3)

Configuring FHIR

The exporting of FHIR can be configured using the src/main/resources/synthea.properties:

# default FHIR R4 configuration.
exporter.fhir.export = true
# transaction bundle 'true' produces transaction Bundles
# else if 'false' produces collection Bundles.
exporter.fhir.transaction_bundle = true
# if bulk_data 'true' ndjson bulk format is exported
# else if 'false' (default) normal FHIR bundles are exported
exporter.fhir.bulk_data = false
# Whether or not resources should conform to the US Core Implementation Guide
exporter.fhir.use_us_core_ig = false
# Which version of the US Core IG to conform to (See list of supported versions above)
exporter.fhir.us_core_version = 5.0.1
# Use Standard Health Record (SHR) extensions for STU3?
exporter.fhir.use_shr_extensions = false
# Exporting FHIR DSTU2
exporter.fhir_dstu2.export = false
# Exporting FHIR STU3
exporter.fhir_stu3.export = false
# Exporting Hospital Provider data in separate file.
exporter.hospital.fhir.export = true
exporter.hospital.fhir_stu3.export = false
exporter.hospital.fhir_dstu2.export = false
# Exporting Practitioner data in separate file.
exporter.practitioner.fhir.export = true
exporter.practitioner.fhir_stu3.export = false
exporter.practitioner.fhir_dstu2.export = false

Producing and Using FHIR

In the synthea.properties file, make sure that exporter.fhir.export, exporter.fhir.transaction_bundle, exporter.practitioner.fhir.export and exporter.hospital.fhir.export are all set to true.

Next, produce some synthetic data:

./run_synthea -p 100

By default, FHIR JSON data should now exist in the ./output/fhir sub-directory. If you have a FHIR server and client, you can POST those bundles to the FHIR server. See FHIR Transaction Bundles for additional details and the recommended order that bundles are POSTed.

For example:

curl http://hapi.fhir.org/baseR4 
  --data-binary "@/Users/example/synthea/output/fhir/Maryetta775_Rowe323_2cb7e4dd-9d8b-49cf-b1e4-9839be8bc754.json" 
  -H "Content-Type: application/fhir+json"

The FHIR server should return a transaction-response Bundle:

{
  "resourceType": "Bundle",
  "id": "ca4d459f-b078-4c04-a152-c7ce76a25179",
  "type": "transaction-response",
  "link": [
    {
      "relation": "self",
      "url": "http://hapi.fhir.org/baseR4"
    }
  ],
  "entry": [
    {
      "response": {
        "status": "201 Created",
        "location": "Patient/4147259/_history/1",
        "etag": "1",
        "lastModified": "2018-06-06T18:26:06.038+00:00"
      }
    },
    ...abridged...
  ]
}

Other Examples of Using Synthea FHIR Data

Clone this wiki locally