FHIR DrillDocs

Data

Load data into HAPI

Post Synthea bundles as transactions, in the right order, and check what arrived.

Synthea bundles are transaction Bundles, so each one goes in with a single POST to the base URL.

Load the shared organisations and practitioners first#

Shell
cd ~/fhir-lab/synthea/output/fhir
FHIR=http://localhost:8080/fhir
for f in hospitalInformation*.json practitionerInformation*.json; do
  curl -s -X POST "$FHIR" -H "Content-Type: application/fhir+json" --data-binary @"$f" \
    -o /dev/null -w "$f %{http_code}\n"
done

Patient bundles refer to these with conditional references like Organization?identifier=.... Those only resolve if the organisations and practitioners already exist.

Load the patients#

Shell
for f in $(ls *.json | grep -v -e hospitalInformation -e practitionerInformation); do
  code=$(curl -s -X POST "$FHIR" -H "Content-Type: application/fhir+json" --data-binary @"$f" -o /tmp/resp.json -w "%{http_code}")
  echo "$code $f"
  [ "$code" = 200 ] || jq '.issue[]?.diagnostics' /tmp/resp.json
done

A big patient can take 10–30 seconds. The whole population of 61 takes a few minutes.

Check what arrived#

Shell
for t in Patient Encounter Observation Condition MedicationRequest Immunization Procedure; do
  printf "%-18s %s\n" $t "$(curl -s "$FHIR/$t?_summary=count" | jq .total)"
done

Loading twice

Synthea's patient entries are plain POSTs, so loading the same bundle twice makes duplicates of every encounter and observation. Either reset first, or treat the duplicates as data-quality practice.

Load one resource or a folder of NDJSON#

Shell
# one resource
curl -s -X POST "$FHIR/Patient" -H "Content-Type: application/fhir+json" --data-binary @patient.json

# NDJSON (one resource per line, as bulk export produces)
while read -r line; do
  t=$(echo "$line" | jq -r .resourceType); id=$(echo "$line" | jq -r .id)
  echo "$line" | curl -s -X PUT "$FHIR/$t/$id" -H "Content-Type: application/fhir+json" --data-binary @- -o /dev/null
done < Patient.ndjson
FHIR Drill lab docs · synthetic data only · built 2026-11-26