Versioning in FHIR using the _history parameter

Scenario: Your app need to show Status changes and when they occurred for a particular Encounter for a particular Patient. How can you get that information?

Assuming the FHIR server you’re accessing has implemented versioning such that a resource’s history is stored, you would use the “_history” query parameter.

Let’s say we have a patient called “Darren Sample”. We want to display the Status history for a recent Encounter Darren had at our hospital so we can see the progress of the Encounter as it happened.

The Encounter we select has an id of “7331557-Sample.” Our FHIR query would look like this:

/Encounter/7331599-Sample/_history

Here’s the live query showing sample data on HAPI: http://hapi.fhir.org/baseR4/Encounter/7331599-Sample/_history

We get back a bundle of type “history” with 5 different versions of the Encounter resource. The only difference between each version is the Status and the lastUpdated timestamp showing when the Status was changed. We can see the Encounter flow through a series of status changes that look like this:

“planned | arrived | triaged | in-progress | finished”

A little code might be required to polish the Status list and timestamps for display purposes, but as you can see, it’s easy to access versioned data once the FHIR API properly implements versioning.

Discussion

---

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