Searching a FHIR Server in a Browser¶
In this chapter you build search queries against the HAPI FHIR public sandbox in a browser. The goal is to develop a feel for the FHIR REST URL pattern and the shape of a searchset Bundle response before you start building channels. There is no QIE work in this chapter; the next one moves into QIE end-to-end.
Step 1: Browse the sandbox¶
Open the URL below in any browser:
The response is a JSON searchset Bundle whose entry array contains up to ten Patient resources. Pretty-printed, the top of the document looks like:
{
"resourceType": "Bundle",
"type": "searchset",
"total": 10,
"link": [ { "relation": "self", "url": "https://hapi.fhir.org/baseR4/Patient?_count=10" }, … ],
"entry": [
{
"fullUrl": "https://hapi.fhir.org/baseR4/Patient/12345",
"resource": {
"resourceType": "Patient",
"id": "12345",
"identifier": [ … ],
"name": [ { "family": "Doe", "given": [ "John" ] } ],
"birthDate": "1970-01-01",
…
}
},
…
]
}
Scroll through the entries and pick one. Note three values from the first Patient you find:
- The id at
resource.id(and visible infullUrl). - The first given name at
resource.name[0].given[0]. - The birthDate at
resource.birthDate.
You use these in the next step. The sandbox is shared, so any specific id may disappear later. Re-run the query and pick a new one if a step ever returns no results.
Step 2: Build search queries¶
Construct each of the following URLs in your browser using the values you noted above. Each query should return either the same Patient resource or a Bundle that includes it.
2a. Match by id¶
_id is the underscore-prefixed search parameter that matches the resource's server-assigned ID. The response is a Bundle with a single entry.
2b. Match by given name¶
Most servers do a case-insensitive starts-with match. Add :exact to force an exact match:
2c. Birthdate range¶
Return every Patient born before the date you noted:
The lt prefix is less than. Try ge, le, sa, eb to see how each one shifts the result set.
2d. Related resources¶
Pull every Observation for the patient (note that this navigates by reference rather than the patient compartment):
If the sandbox happens to have no Observations linked to your chosen Patient, pick a different id from Step 1.
2e. Compartment operation¶
This is a FHIR operation (note the $). It returns a Bundle of every resource the server has in that patient's compartment: Patient, Encounters, Observations, MedicationRequests, and so on. Not every server implements $everything; HAPI does.
What you can now do¶
You can compose FHIR REST URLs and read the shape of a searchset Bundle response by eye. From here, swap out the resource type and search parameters, such as /Observation?subject=Patient/..., /MedicationRequest?status=active&patient=..., and so on, to get a feel for what different servers return. The next chapter moves into QIE: it builds a channel that converts an inbound HL7 v2 message into a FHIR Patient resource and POSTs it to the same sandbox.