How to filter patient records on a FHIR server

08.30.2022

In healthcare, there’s often a need to find all patient data for various uses, be it getting a full view of the patient’s medical history or using the data for analytics and app integrations. 

As such, the FHIR specification has the option to query everything associated with a specific patient. In order to do so, you need to run the $everything operation on a FHIR server that supports it.

In this article, we’ll teach you how to retrieve all records pertaining to an individual patient using $everything on Patient. We’ll showcase the examples using the Kodjin FHIR server. You can also test this function using our Postman collection.

What is $everything on Patient?

The operation $everything on Patient is synchronous and returns all the records related to one patient (Patient compartment). The intended uses for this operation are to provide patients with access to their entire records and for providers to perform bulk patient data downloads.

While there is also a possibility to retrieve Patient compartment data with bulk export, $everything on Patient is a synchronous operation with batch-response resources in response.

How to run $everything on Patient

Before you run the $everything operation, you need to make sure you have the resources associated with the patient available on the FHIR server (such as Patient, Observation, Encounter, etc.) If you would just like to test out the $everything command, we’ve compiled some example resources you can use. 

Now let’s take a look at how we can run $everything on Patient.

GET – Get Patient everything by ID

The example below shows how to retrieve data for a patient with an ID in the URL. This could be useful for the Blue Button app, for example. The user receives all Patient compartment information by Patient.id posted any time before the query.

Example: https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything

Example Request:

curl --location --request 
GET'https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything' \
--header 'content-type: application/json' \
--header 'prefer: respond-async' \
--data-raw ''

GET – Get Patient everything since [time/date]

In case you don’t need all of the EHR information but only the data posted since a specific time or date, you can run the $everything command with a _since filter. In the example below, we retrieved information posted from a specific date (2022-08-18 12:43:19) up to the present time. 

Example:

https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything?_since=2022-08-18T12:43:19.156Z

Example Request:

curl --location --request GET 'https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything?_since=2022-08-18T12:43:19.156Z' \
--header 'content-type: application/json' \
--header 'prefer: respond-async' \
--data-raw ''

GET – Get Observations for my Patient

We can have Patient/$everything filtered by one or more resources. For example, we need only Observation for the current Patient, and we are not interested in other resources, like MedicationRequests, etc. In this case, we could use the _type filter and ask only for the resources we are interested in.

Example: https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything?_type=Observation

Example Request:

curl --location --request GET 'https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything?_type=Observation' \
--header 'content-type: application/json' \
--header 'prefer: respond-async' \
--data-raw ''

GET – Get Observations for my Patient posted since [time/date]

All filters could be combined in the request, so we can ask for an exact resource made in an exact period of time (2022-08-18 12:43:19).

Example:

https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything?_type=Observation&_since=2022-08-18T12:43:19.156Z

Example Request:

curl --location --request GET 'https://kodjin-staging.edenlab.dev/fhir/Patient/aa74fca2-2c68-47a8-98b6-3857d3df75c4/$everything?_type=Observation&_since=2022-08-18T12:43:19.156Z' \
--header 'content-type: application/json' \
--header 'prefer: respond-async' \
--data-raw ''

GET – Get Patient everything

This example is for receiving all patients with all EHR information for them.

Example: 

https://kodjin-staging.edenlab.dev/fhir/Patient/$everything

Example Request:

curl --location --request GET 'https://kodjin-staging.edenlab.dev/fhir/Patient/$everything' \
--header 'content-type: application/json' \
--header 'prefer: respond-async' \
--data-raw ''

Summary

In this article, we’ve shown you how to retrieve all of an individual patient’s records and filter them by resource or time and date. We hope you find it useful. For further reading on how to perform various FHIR operations, refer to our other articles

The Kodjin team is open to cooperation and consultation. If you are looking for an expert team to implement your FHIR project, contact us to see how we can help.

Let’s chat

We would be glad to share more details about our enterprise-level solutions and other cases based on the FHIR standard








    Contact form

    We will share all details about our enterprise-level solutions and other cases based on the FHIR standard








      Thank you!

      KODJIN WHITEPAPER

      Please leave your email to get Kodjin White Paper.
      By downloading files from this site you agree to the Policy





        Thank you!

        Thank you!