Generating Synthetic Patient Data | by Akash Kaul | Towards Data Science

Using healthcare data for research can be tricky, and there can be many legal and financial hoops to jump through in order to use certain data. This is especially true when dealing with the information of specific patients. But, these hurdles can be avoided with synthetic data created using Synthea, an open-source patient generator. Synthea creates realistic data that can be used without restriction. Best of all, it’s extremely user-friendly.
Before you start creating your own patients, make sure you have the latest version of JDK (JDK 14). If you don’t already have it, you can follow this installation guide. Be sure you install JDK 14, and NOT JRE 14.
The next step is to install Synthea. If you are just looking to run Synthea without much flexibility and customizability, you can install the basic version using the link here. Alternatively, you can create a local copy of the Github repository if you want more freedom to play around with the code. I’ll walk through using the basic version, and I’ll leave exploring the more expansive version to you (follow these instructions).
Once Synthea is installed, open up your terminal and change to the directory where the file was downloaded. For me, that’s the “Downloads” folder.
cd /directory/with/downloaded/file
Once you’re in the directory, you can run Synthea with JUST ONE COMMAND! All you need to do is open the JAR file.
java -jar synthea-with-dependencies.jar
You should see a bunch of text pop up in the terminal.
Just like that, you’ve successfully created a synthetic patient; but, that’s just the surface of what Synthea has to offer.
There are several different parameters that you can use to customize the patients you create. For a full list of parameters, check out the Synthea wiki.
Let’s take a look at some useful ones.
-p size — Generate a population of the specified size (The size specifies the number of alive members of the population, so the total population size will likely be bigger)
-g gender— Generate a population of one gender (M for male, F for female)
-a ageRange — Generate a population within a range of ages (i.e. 30–40)
-m module — Generate a population using a specific ailment (i.e. Asthma, Dermatitis, Lupus, etc.) A full list of modules can be found here.
State City — Generate a population within a specific area (i.e. Minnesota, Texas Dallas, etc.) The city is optional. Only 1 state can be run at a time; if nothing is specified, the default state is Massachusetts.
--exporter.csv.export true — Exports the data as a CSV file. The default format is FHIR. The patient information is split up into multiple CSV files based on different data like “medications”, “encounters”, “providers”, and many others. You can also choose from lots of other output formats. The full list can be found here.
With these parameters, we can generate some pretty meaningful data. These parameters can all be combined, and the more parameters you use, the more specific the data you generate will be. Let’s look at a couple of examples.
java -jar synthea-with-dependencies.jar -p 500 -a 20–50 Minnesota
This generates a list of patients between the ages of 20 and 50 who live in Minnesota. The list will have 500 alive patients and some number of dead patients.
java -jar synthea-with-dependencies.jar -p 100 -g F -m Asthma --exporter.csv.export true
This generates a list of at least 100 female patients using only the asthma module and exports the data as a CSV file.
There are lots of ways that you can combine different parameters to create very different data sets. I encourage you to experiment, try different parameters, and see what you get. Or, if you’re feeling comfortable with the basic model, you can install the full repository and explore everything Synthea has to offer.
I hope you enjoyed this short introduction to Synthea, and I hope I showed you how easy-to-use and powerful this tool really is. Whether you’re working on a large-scale project, or you’re just experimenting on your laptop, the possibilities are truly endless.