How do you get only the FHIR attributes that you need?

Let’s say you want to populate a screen.

The screen displays a list of Observations about a patient “Edgar Allan Poe”.

Most devs will build a query that returns all Observations that meet their criteria, then use only a few attributes in each resource.

This is overkill.

Not all FHIR resources are small. Ever tried running a query to get back 20 QuestionnaireResponse resources? That’ll run to 70,000 lines of JSON — if you’re lucky.

How about a list of Media or DocumentReference resources? Chances are each resource comes with 5 or 10 mbs of encoded data.

If you know what you want, it’s best to ask for what you want.

Back to our patient, “Edgar Allan Poe.” How do we get just the attributes we need to populate a screen with Edgar’s name and the results of the most recent Observations about him?

We use the _element parameter and we specify what we want.

The base query looks like this:


Add in the patient details:


Now lets add the elements we want:


This gives us the text of the Observation code (“High Density Lipoprotein Cholesterol”), the recorded value and date, as well as the Patient name.

We also get the resource’s Meta section, id and resourceType by default.

Everything else is left out.

This is the most efficient way to populate a display list from a FHIR query. No 70,000 lines of JSON, no 5 mb images you don’t need.

Here’s the query for real.



Sign up to “The Tuesday FHIR Sessions” and receive an email every Tuesday where I go deep on a single FHIR topic.