FHIR DrillDocs

FHIR API

Chaining, includes and paging

Follow references inside a search, pull related resources into one response and walk large result sets.

Filter on a field of the referenced resource with .:

Text
Observation?subject:Patient.family=hammes
Observation?patient.identifier=https://fhirdrill.dev/mrn|DRILL-0001
Encounter?service-provider.name=Springfield

When a reference can point at more than one type, add the type, as in subject:Patient.

Reverse chaining with _has#

Find resources that are referenced by something matching a condition:

Text
# Patients who have a heart rate Observation above 120
Patient?_has:Observation:patient:code=http://loinc.org|8867-4&_has:Observation:patient:value-quantity=gt120

You read it as: Patients, that have an Observation, whose patient reference points at them, where …

_include and _revinclude#

Return related resources in the same Bundle so you don't need extra requests.

Text
# Observations plus the Patient each one is about
Observation?code=http://loinc.org|8867-4&_include=Observation:patient

# A Patient plus every Encounter that points at it
Patient?_id=1234&_revinclude=Encounter:patient

# Follow references more than one hop
MedicationRequest?patient=1234&_include=MedicationRequest:medication&_include:iterate=Medication:manufacturer

# Everything a type can include
Encounter?_id=55&_include=*

Included resources come back with search.mode = "include". The resources that matched the search have search.mode = "match".

Shell
curl -s "$FHIR/Encounter?patient=1234&_include=Encounter:practitioner&_count=5" \
  | jq '[.entry[] | {type: .resource.resourceType, mode: .search.mode}] | group_by(.type) | map({(.[0].type): length}) | add'

Paging#

Large results come back in pages. Always follow the next link. Don't build paging URLs yourself, because the format is specific to each server (HAPI uses _getpages).

Shell
url="$FHIR/Observation?patient=1234&_count=100"
while [ -n "$url" ]; do
  page=$(curl -s "$url")
  echo "$page" | jq -r '.entry[].resource.id'
  url=$(echo "$page" | jq -r '.link[] | select(.relation=="next") | .url // empty')
done

Paging links and the tunnel

Paging links use the address you called. A page fetched through fhir.fhirdrill.dev links to the next page on fhir.fhirdrill.dev, so every page needs your service token too.

Search the whole server#

Text
[base]?_type=Patient,Practitioner&name=smith
[base]?_lastUpdated=gt2026-11-25
FHIR Drill lab docs · synthetic data only · built 2026-11-26