Advanced FHIR features #1: Conditional Updates

Devs new to FHIR can be productive almost immediately.

This is not always a good thing. Early productivity can hide how much they don’t know.

This was me years ago.

To compensate for what I didn’t know, I made multiple calls to FHIR to get data I didn’t need. Then I wrote code to filter the results.

Let’s say you’re responsible for maintaining a list of Practitioners in a FHIR server.

A dev new to FHIR might make a GET request for that list, run some logic on the results in C# or Java, then send back a Bundle to update some Practitioners and create others.

It works, but it’s awkward.

This is where the “conditional update” or “conditional PUT” comes in — a moderately advanced FHIR feature that many devs never use.

You don’t need to GET the Practitioner first.

All you need to know is: “Can the Practitioner be uniquely identified by a FHIR query?”

Then you let the FHIR server do all the heavy lifting.

In the case of our dev updating Practitioner details, her conditional PUT request might look like this:

PUT /Practitoner/?identifier=http://hl7.org/fhir/sid/us-npi|789654789X

The FHIR server will look for a Practitioner with an Identifier of:
– system: http://hl7.org/fhir/sid/us-npi
– value: 789654789X

If it finds one, it will update the resource.

If it fails to find one, it will create a new Practitioner.

If it finds more than one, it will fail with a 412 error.

A single query. No code required.

Of course, not every FHIR server implements conditional updates.

Learn more: https://build.fhir.org/http.html#cond-update

Discussion

---

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