Without using commercial tools, is there an easy way to generate sample FHIR resources?
I'm working an a project to store FHIR messages to Elasticsearch, and I need a tool to generate FHIR sample messages in real-time to ship over TCP/IP.
The core of HL7® FHIR® is a set of modular components called "Resources." These form the basic data exchange format and model of FHIR. As of FHIR Release 4, there are 145 Resources defined across health care domains and supporting services, a number that grows with every release.
FHIR supports 145 resource types, typically in XML, JSON, or RDF/Turtle. formats These are the logical, common contents of the resource mapped to formal definitions; e.g. RIM & other formats.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With