4 types of GET Requests in FHIR

What can you expect from a GET request in FHIR?

Simple GET requests are not always simple. You can’t assume you’ll always get what you’re expecting.

Here are different types of GET requests that return different sets of results.

– Give me a specific resource by Id
Encounter/123456

Returns a single Encounter resource, or a 404 status if the resource is not found.

– Give me all Encounters that meet my search criteria
Encounter?status=in-progress

Returns a Bundle of type “searchset” containing Encounter resources. If no matching Encounters are found it returns an empty bundle. The HTTP status code is 200, as the search was successful despite finding no results.

– The search parameter I used was invalid
Encounter?INVALIDstatus=in-progress

Different FHIR servers behave in different ways. Some will return a single OperationOutcome resource detailing the problem along with a 400 status code. Others will return a bundle that contains results for the resource type you’re searching for as well as an OperationOutcome resource — and a 200 status code. Inconsistent and not ideal.

– Give me all Encounters, and also include any associated Patients and Conditions
/Encounter?_include=Encounter:patient&_revinclude=Condition:encounter

Returns a Bundle with a list of Encounters as well as any Patients referenced from that Encounter and any Conditions that refer back to that Encounter. There may or may not be a Patient and one or more Conditions for each Encounter.

In all cases where a Bundle is returned, OperationOutcome resources with information about the request may be included. These might tell you if any resources were omitted or if an error occurred during the request.

They’re easy to miss if you’re expecting a bundle of resources to be returned and you have code that extracts specific resource types from the bundle.

Don’t forget to always look for an OperationOutcome in all bundles you receive, and pay attention to what it says.

Discussion

---

Ways to Work With Me

Discover more from Darren Devitt

Subscribe now to keep reading and get access to the full archive.

Continue reading