Mock FHIR Servers
Using examples can help you to build an understanding of how the canonical models appear in real world scenarios.
See following list of test servers https://confluence.hl7.org/display/FHIR/Public+Test+Servers.
Get a list of resources, enter an invalid one, e.g.
curl https://hapi.fhir.org/baseR4B/invalid
Note: URLs are case sensitive, i.e. this will return an error
curl https://hapi.fhir.org/baseR4B/patient
While camel case is accepted
curl https://hapi.fhir.org/baseR4B/Patient
Emulating a Journey
For the Patient example above, use once of the fullUrl returned
curl -s https://hapi.fhir.org/baseR4B/Patient | grep fullUrl
curl -s https://hapi.fhir.org/baseR4B/Patient/593191 > 593191.json
Create/Update do not actually make any changes, but process successfully and return JSON.
curl -X POST https://hapi.fhir.org/baseR4B/Patient -H 'Content-Type: application/fhir+json' -d '@593191.json'
curl -X PUT https://hapi.fhir.org/baseR4B/Patient/593191 -H 'Content-Type: application/fhir+json' -d '@593191.json'
Seeding for local development server
To run a local development server docker run -p 8080:8080 hapiproject/hapi:latest
, and verify running
curl -s http://localhost:8080/fhir/Patient
An empty bundle should be returned
{
"resourceType": "Bundle",
"id": "cb628950-fcdb-4e85-8d8d-3ed4081ae316",
"meta": {
"lastUpdated": "2024-09-12T21:44:05.224+00:00"
},
"type": "searchset",
"total": 0,
"link": [ {
"relation": "self",
"url": "http://localhost:8080/fhir/Patient"
} ]
}
Each resource and reference provides a curl command to create in the local development HAPI FHIR server. To add the example to local development server
Reference Data
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/CodeSystem-assistance-needs-cs.json)" http://localhost:8080/fhir/CodeSystem
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/ValueSet-assistance-needs-vs.json)" http://localhost:8080/fhir/ValueSet
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/Questionnaire-AssistanceNeedsQuestionnaire.json)" http://localhost:8080/fhir/Questionnaire
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/Questionnaire-MedicationRequestQuestionnaire.json)" http://localhost:8080/fhir/Questionnaire
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/CapabilityStatement-PatientSummaryCapabilityStatement.json)" http://localhost:8080/fhir/CapabilityStatement
Entity Data
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/Patient-ZHI0020.json)" http://localhost:8080/fhir/Patient
patientRID=$(curl -s -X POST -H "Content-Type: application/fhir+json" -d "$(curl -s https://ig.opennz.org/Patient-ZHI0010.json)" http://localhost:8080/fhir/Patient | jq -r .id)
data=$(curl -s https://ig.opennz.org/Condition-NeedsAssistanceExample.json)
data=$(echo "$data" | sed "s/Patient\/rid/Patient\/$patientRID/g")
curl -s -X POST -H "Content-Type: application/fhir+json" -d "$data" http://localhost:8080/fhir/Condition
Verify
curl -s http://localhost:8080/fhir/Patient
There should now be two patients
{
"resourceType": "Bundle",
"id": "29ef5a54-fddb-4ff7-9781-da9dfe4978a0",
"meta": {
"lastUpdated": "2024-09-12T21:47:57.087+00:00"
},
"type": "searchset",
"total": 2,
...
curl -s http://localhost:8080/fhir/Patient/$patientRID
curl -s http://localhost:8080/fhir/Patient?identifier=ZHI0020
curl -s http://localhost:8080/fhir/Condition?subject.identifier=ZHI0010&category=717831006&code=371152001