How do you look up recent Encounters for Patients with the surname Smith?

In FHIR we do this by building a query of chained search parameters from Encounter to Patient. What does this look like?

A patient, “Oliver James Smith,” calls up his clinic and asks about an appointment he had last week. The receptionist looks up his name in the system but nothing comes back.

She tries again, this time searching under recent appointments for the surname “Smith” and comes back with a single result for “Oliver J Smith”.

The appointment was for the correct day and the patient’s date of birth matches. She answers Oliver James’s questions.

If this were SQL, the query would look something like this:

select * from Patient, Encounter
where = Encounter.subject.resource and = 'smith'
order by Encounter.meta.lastUpdated desc

In FHIR we build a query that goes from Encounter to Patient via the Encounter’s subject resource reference. It looks like this:


In plain English this says: give me all the Encounters and associated Patients where the Encounter subject (the Patient) has the name “smith”, and sort the results in descending order by recently updated.

Here’s the query for real:

If you come from an SQL background, FHIR queries can appear verbose and difficult to understand. Break them down parameter by parameter, and the complexity disappears.

More about chained parameters:



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