How to Generate Synthetic Healthcare Data Using Synthea: A Hands On Tutorial

Healthcare generates huge amounts of data every day, from patient visits and lab results to diagnoses, medications, and medical imaging.

For developers and data engineers building healthcare applications, access to realistic patient data is essential. Whether you are building a healthcare analytics pipeline, testing an Electronic Health Record (EHR) system, or experimenting with machine learning, you need data that reflects how healthcare systems actually work.

But there is a challenge: real patient data is sensitive, highly regulated, and often difficult to access. So how can we develop and test healthcare applications without exposing real patient information? One solution is to generate synthetic healthcare data.

In this tutorial, you will learn how to use Synthea, an open-source synthetic patient generator, to create realistic patient records. We’ll generate a population of approximately 100 patients, explore the resulting healthcare datasets using Python, and reconstruct a patient’s clinical history.

By the end, you will have your own synthetic healthcare dataset that you can use for learning, testing, and prototyping.

I have also included a companion Jupyter notebook that you can use to explore the generated data with Python, visualize clinical events, and understand a synthetic patient’s healthcare journey.

1. What Is Synthetic Healthcare Data?

Synthetic healthcare data is artificially generated information designed to resemble real healthcare records without representing actual patients.

For example, a synthetic patient might have:

  • Demographic information such as age and gender
  • A history of primary care visits
  • Diagnosed medical conditions
  • Lab test results
  • Prescribed medications
  • Procedures and hospital visits

These records are generated using simulation models and predefined rules and not copied from real patient histories.

Synthetic Data vs. De-identified Data

It’s important to understand the difference between these two types of data.

De-identified data starts with real patient records and removes or transforms identifying information, such as names, addresses, and other personal identifiers.

Synthetic data, on the other hand, is generated artificially. It doesn’t directly represent an actual patient’s medical history.

Synthetic data offers another way to create development and testing datasets without relying on actual patient records. But synthetic data isn’t automatically statistically representative, clinically accurate, or free from bias.

Why Is Synthetic Healthcare Data Useful?

Developers and researchers can use synthetic data in a variety of ways. It lets them develop and test healthcare applications, build data ingestion and transformation pipelines, and experiment with healthcare data models.

They can also use it to test interoperability between healthcare systems, prototype analytics and machine learning workflows, and learn more about certain healthcare concepts and data relationships.

For this tutorial, we’ll focus on generating structured healthcare data and understanding how the records relate to one another.

2. What Is Synthea?

Synthea is an open-source synthetic patient population simulator developed by MITRE.

Instead of generating random rows of patient information, Synthea simulates patient lifecycles. It models healthcare events over time, including medical conditions, clinical encounters, medications, procedures, and laboratory observations.

For example, a simulated patient might develop a medical condition, visit a healthcare provider, undergo testing, and receive medication. These events become part of that patient’s longitudinal health record.

Synthea uses configurable clinical modules and population characteristics to generate these histories.

What Data Can Synthea Generate?

Synthea can generate many types of data, including:

Healthcare dataDescription
PatientsDemographics and patient identifiers
EncountersHospital visits, outpatient consultations, and emergency visits
ConditionsDiagnoses and clinical findings
ObservationsLaboratory results, vital signs, and clinical measurements
MedicationsMedication prescriptions and history
ProceduresClinical procedures and interventions
AllergiesRecorded allergies
ImmunizationsVaccination records
Imaging studiesMedical imaging study metadata
ClaimsHealthcare billing and insurance data

Synthea supports several export formats, including CSV (which is useful for data analysis, SQL databases, and data engineering), HL7 FHIR (a standard for exchanging healthcare information between systems, commonly represented as JSON resources), and C-CDA (an XML-based format for exchanging clinical documents).

We’ll use CSV in this tutorial because it’s easy to explore with Python and can be imported into relational databases.

3. Prerequisites

Before getting started, you’ll need:

  • Java Development Kit (JDK) 17 or newer
  • Git
  • A terminal or command-line environment
  • Python 3, for the exploration section
  • Basic familiarity with CSV files and Python

Synthea recommends supported long-term-support Java versions, such as Java 17 or 25.

I’ll demonstrate the commands using macOS, but the same general workflow works on Linux and Windows.

Check Your Java Installation

Open Terminal and run:

java -version

This command prints the installed Java version. Confirm that it reports Java 17 or newer before moving on to installing Synthea.