How to filter patient records on a FHIR server

Sometimes, healthcare providers and developers require full access to patient medical histories and patient data for analytics and app integrations. In this guide, we explain how to run the $everything operation on a FHIR server to retrieve all patient records and filter them. We also provide useful, practical examples for better understanding.

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 and filter patient records 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 FHIR Patient compartment data with FHIR bulk API, $everything on Patient is a synchronous operation with batch-response resources in response.

How to run $everything on Patient

Before you run the FHIR $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 FHIR 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.

FAQ

Why do I need to filter patient records on a FHIR server?

Filtering patient records on a FHIR server can help you retrieve specific information about patients that you are interested in, and can improve the efficiency of your queries by reducing the amount of data you need to retrieve.

For example, you may only be interested in patients with a certain condition or patients within a certain age range. By filtering the patient records based on these criteria, you can quickly retrieve only the data that is relevant to your query, rather than having to manually search through all patient records on the server.

How do I filter patient records on a FHIR server?

To filter patient records on a FHIR server, you can use the FHIR search API. The search API allows you to specify a set of search parameters that define the criteria for the patient records you want to retrieve. These parameters can include things like patient demographics, conditions, medications, and more. The search API uses a query syntax that is based on the RESTful architectural style, and it returns results in a standard FHIR format. To read more about FHIR Search and how to work with it, refer to our article on Common Questions about FHIR Search from BAs and Developers.

Are there any limitations to filtering patient records on a FHIR server?

There are some limitations to filtering patient records on a FHIR server that you should be aware of such as:

  • FHIR servers may have limitations on the number of patient records that can be retrieved in a single query, so you may need to use paging or other techniques to retrieve large datasets.
  • Some FHIR servers may not support all of the search parameters that you need to filter patient records effectively, so you may need to use more complex queries or multiple queries to retrieve the data you need.

More article about FHIR Server

no-image
Kodjin FHIR Server Earns ONC Health IT Certification from Drummond Group

April 4, 2023

  • FHIR server
  • Kodjin Updates
no-image
Event-Driven Architecture for FHIR Servers: Benefits and Models

November 7, 2022

  • FHIR server
  • Kodjin Updates
no-image
How to Configure Notifications for an FHIR Server (Subscriptions)

October 25, 2022

  • Featured
  • FHIR
  • Kodjin Updates

Let`s chat

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

    Your form has been submitted successfully

    We will contact your shortly

    Kodjin White Paper

    Please leave your email to get Kodjin White Paper

      By downloading files from this site you agree to the Policy

      The Kodjin White Paper has been successfully sent to your email

      We have sent a copy to your email

      Back to website content