How do we do that in FHIR?
The FHIR query we need to build uses what’s called ‘reverse chaining’. This is where you search for a target resource (Patient) referenced from another resource (Immunization).
We also add some search parameters to run against Immunization.
Reverse chaining is the area of FHIR search that causes the most problems for new developers. It looks unintuitive — almost backwards.
But once you get the hang of the syntax, it’s easy enough to use.
The CVX code for the flu vaccine is 140.
The query has three parts:
First, give me Patients.
Second, give me only Patients referenced from the ‘patient’ element of the Immunization resource, where the vaccine-code is the flu vaccine.
Finally, of those patients, only give me ones where the flu vaccine was administered after June 8th, 2023.
Here’s a working query using some data I added yesterday to the HAPI server:
It should return a single patient, Becky Sharp.
Again, the syntax surrounding the _has search modifier above looks wrong and causes a lot of scratched heads amongst new developers. But it’s here to stay.
More about reverse chaining: https://build.fhir.org/search.html#has
Sign up to “The Tuesday FHIR Sessions” and receive an email every Tuesday where I go deep on a single FHIR topic.