Get started
Quickstart: your first ten minutes
Read the server's capabilities, find a patient, create your own and see it come back in a search.
You need curl and jq
The examples pipe JSON through jq. Install it once with sudo apt install jq (Debian, including the lab box) or winget install jqlang.jq (Windows).
These examples use the LAN address so they work from any terminal without logging in. To call the server from outside, swap in https://fhir.fhirdrill.dev/fhir and add a service token; see Call the API from outside.
Set a base URL#
export FHIR=http://192.168.1.181:8080/fhirOn Windows PowerShell, run $FHIR = "http://192.168.1.181:8080/fhir" and use curl.exe instead of curl.
Ask the server what it supports#
Every FHIR server publishes a CapabilityStatement at /metadata. It lists the FHIR version, the resource types and the search parameters it supports.
curl -s "$FHIR/metadata" | jq '{fhirVersion, software, resources: [.rest[0].resource[].type] | length}'{
"fhirVersion": "4.0.1",
"software": { "name": "HAPI FHIR Server", "version": "8.12.0" },
"resources": 146
}Count and find patients#
curl -s "$FHIR/Patient?_summary=count" | jq .total
curl -s "$FHIR/Patient?family=Hammes&_elements=name,birthDate" | jq '.entry[].resource'_summary=count returns only the total. _elements trims each resource to just the fields you ask for.
Create a patient#
curl -s -X POST "$FHIR/Patient" \
-H "Content-Type: application/fhir+json" \
-d '{
"resourceType": "Patient",
"identifier": [{ "system": "https://fhirdrill.dev/mrn", "value": "DRILL-0001" }],
"name": [{ "family": "Drill", "given": ["Quick", "Start"] }],
"gender": "other",
"birthDate": "1990-01-01"
}' -i | grep -iE "^(HTTP|location|etag)"HTTP/1.1 201 Created
Location: http://192.168.1.181:8080/fhir/Patient/1234/_history/1
ETag: W/"1"The server assigned the id (1234 here) and version 1. Keep the id for the next steps.
Read it back and search for it#
curl -s "$FHIR/Patient/1234" | jq '.name'
curl -s "$FHIR/Patient?identifier=https://fhirdrill.dev/mrn|DRILL-0001" | jq '.total'Searching by system|value is how real systems find patients, so get used to it now.
Clean up#
curl -s -X DELETE "$FHIR/Patient/1234" -o /dev/null -w "%{http_code}\n"Where next
Work through Create, read, update, delete and Searching, then try Drill 1.