Is there an easy way to generate sample FHIR resources?

The only way I know to do this is to use a service provided by test.fhir.org. You call

http://test.fhir.org/r3/StructureDefinition/[resource]/$generate-template

e.g.

http://test.fhir.org/r3/StructureDefinition/Patient/$generate-template


Did some digging and here is what I've found.

If you do not need a lot of samples, the easiest way is to grab a zip file with resource examples from hl7 website http://hl7.org/fhir/downloads.html

IMHO the easiest way I've found to get more than a few samples is by using Synthea project. You can generate millions of records of synthetic realistic data https://github.com/synthetichealth/synthea

They even run a public server. Here is an example to get a bundle with 100 patients - very neat! https://syntheticmass.mitre.org/fhir/Patient?_offset=0&_count=100

You can also find examples of bulk FHIR API implementations - some of them have demo web sites you can use to download examples: https://github.com/smart-on-fhir/fhir-bulk-data-docs/blob/master/implementations.md

Another generator in Python from SMART on FHIR project (looks outdated): https://github.com/smart-on-fhir/sample-patients.


An easy way to generate example resources (in 2022) is to use FHIR Shorthand (FSH). Here's a copy of the example on FSH School from which you easily create the JSON.

Link: https://fshschool.org/FSHOnline/#/share/3LH920m

Instance: PatientExample
InstanceOf: Patient
Description: "Example of Patient"
* name.family = "Anyperson"
* name.given[0] = "John"
* name.given[1] = "B."
// The first element [0] can also be represented as [+] if it is not preceded by any hard index
* contact.telecom[+].system = #phone
* contact.telecom[=].value = "555-555-5555"
* contact.telecom[=].use = #home
* gender = #male
* birthDate = "1951-01-20"
* address.line = "123 Main St"
* address.city = "Anytown"
* address.postalCode = "12345"
* address.country = "US"

Have a try at https://fshschool.org/

A bonus is that you can reverse JSON into FSH as well. And, templating is easy enough use in FSH (though it's not built-in.). For a worked example see https://github.com/intrahealth/bulk-fsh

Tags:

Hl7 Fhir