Skip to content

Export Formats

Roberto Cruz edited this page May 15, 2026 · 2 revisions

Export Formats

Synthea can export synthetic patient data in three formats: FHIR R4, CSV, and JSON. Each is controlled independently in synthea.properties.

FHIR R4 (default)

FHIR R4 is enabled by default. Each patient is exported as a transaction Bundle containing all their clinical resources.

Enable

exporter.fhir.export = true

Output structure

output/fhir/
├── hospitalInformation<timestamp>.json     # Organization / Location resources
├── practitionerInformation<timestamp>.json # Practitioner resources
├── Ada_Howell_<uuid>.json                  # One Bundle per patient
└── ...

Bundle contents

Each patient bundle includes:

Resource Description
Patient Demographics, identifiers, address
Encounter All clinical visits
Condition Active and historical diagnoses
MedicationRequest Prescriptions
Observation Labs, vitals, social history
Procedure Surgical and clinical procedures
Immunization Vaccination history
AllergyIntolerance Known allergies
CarePlan Active care plans
DiagnosticReport Lab and imaging reports
ImagingStudy Radiology studies
Claim Insurance claims
ExplanationOfBenefit EOB records
Coverage Insurance coverage periods
Organization Providers and payers
Practitioner Clinicians

POST to a FHIR server

exporter.fhir.server_url = https://fhir.example.com/r4
exporter.fhir.transaction_bundle = true

Python: load a bundle

import json
from pathlib import Path

bundle_path = Path("output/fhir/Jane_Doe_abc123.json")
bundle = json.loads(bundle_path.read_text())

for entry in bundle["entry"]:
    rt = entry["resource"]["resourceType"]
    print(rt)

CSV

CSV export produces one table per resource type — useful for database ingestion and analytics.

Enable

exporter.csv.export = true

Tables generated

File Contents
patients.csv One row per patient
encounters.csv All encounters
conditions.csv All diagnoses
medications.csv All medication orders
observations.csv Labs and vitals
procedures.csv All procedures
immunizations.csv Vaccines
allergies.csv Allergy records
careplans.csv Care plan entries
claims.csv Insurance claims
claims_transactions.csv Line items
payers.csv Payer / insurance info
providers.csv Provider info
organizations.csv Facility info
devices.csv Medical device records

Load into pandas

import pandas as pd

patients = pd.read_csv("output/csv/patients.csv")
conditions = pd.read_csv("output/csv/conditions.csv")

diabetic = conditions[conditions["DESCRIPTION"].str.contains("diabetes", case=False)]
diabetic_ids = diabetic["PATIENT"].unique()

diabetic_patients = patients[patients["Id"].isin(diabetic_ids)]
print(diabetic_patients[["FIRST", "LAST", "BIRTHDATE", "GENDER"]].head())

JSON (raw)

Raw JSON export writes the internal Synthea patient object, before FHIR mapping. Useful for debugging modules or building custom exporters.

Enable

exporter.json.export = true

Output: output/json/<PatientName>_<uuid>.json


Controlling Output

# Where files are written
exporter.baseDirectory = ./output/

# Use UUID filenames (avoids special characters in patient names)
exporter.use_uuid_filenames = false

# Append to existing CSV files (false = overwrite each run)
exporter.append_mode = false

# Skip living patients (emit deceased only)
exporter.only_living = false

Enabling All Three Formats

uv run synthea -p 100 -c <(cat <<EOF
exporter.fhir.export = true
exporter.csv.export = true
exporter.json.export = true
exporter.baseDirectory = ./output/
EOF
)

Clone this wiki locally