Couchbase is a JSON database that has now become an alternative to the traditional RDBMS. It has achieved this, not only by providing the industry-leading Key-Value store and the same query and ACID translation capabilities that organizations have come to expect, but also the flexibility of natively stored its data in JSON format. In addition, Couchbase also includes distributed storage, multi-dimensional scalability, high availability, and cross datacenter replication(XDCR). All this in a single Couchbase Data Platform that extends to the Edge with the Couchbase Mobile.

Couchbase is also committed to extending its capabilities well beyond that are needed in traditional RDBMS applications. With Couchbase Cloud, where everything is fully managed and automated, providing a secure Database-as-a-Service (DBaaS) that simplifies FHIR database schema management by deploying, managing, and operating Couchbase Server across multi-cloud environments with just a few clicks. Couchbase Cloud is flexible, highly available, and provides a differentiated economical option for enterprises looking to reduce operational tasks while taking advantage of the most powerful NoSQL technology.

We are also doing this by collaborating with many of our customers across different industries to understand their business needs and how Couchbase can help with those challenges. These industries extend from Retail & E-Commerce, Travel & Hospitality, Financial Services, Energy & Utilities, and also High Tech and Gaming.

In this blog, I’d like to focus on how the Couchbase database can be used in the Healthcare industry. Specifically, the focus will be on the Fast Healthcare Interoperability Resources (FHIR) specification as defined by HL7 FHIR.   The reason for this blog is because of the level of interest from many of our customers who are currently planning or implementing their FHIR compliant applications using the Couchbase database.

Why is FHIR with Couchbase of interest to you?

  1. Organizations seek to develop FHIR applications, and/or looking into taking advantage of the many benefits of NoSQL database, such as distributed, high availability, XDCR, and multi-dimensional scalability.
  2. Architects or developers need to understand how Couchbase JSON database can greatly reduce the complexity of their applications, by relegating the complex FHIR Search  [https://www.hl7.org/fhir/searchparameter-registry.html] processing to the database server layer.
  3. Data analysts need to understand how to leverage your SQL knowledge to query FHIR data directly with Couchbase N1QL and Full-Text-Search.
  4. You are interested in finding out how Couchbase N1QL, a SQL for JSON, can provide an efficient way to query a relational data model, as defined by FHIR protocol, that is both JSON hierarchical and relational in nature.

What is FHIR?

FHIR® – Fast Healthcare Interoperability Resources – is a next-generation standards framework created by HL7. FHIR (pronounced “fire”) combines the best features for HL7 and leverages the latest web standards and applying a tight focus on implementability for information exchanges.

FHIR applications are based on the concept of “Resources”. These resources are assembled into specific healthcare applications, spanning from the administrative, clinical to patient care functions. FHIR is suitable for use in a wide variety of contexts – mobile phone apps, cloud communications, EHR-based data sharing, server communication for healthcare providers.

One of the key objectives of FHIR is to specify a standard in which different healthcare applications can adopt, thus allowing interoperability between different functional applications and ultimately drive down the cost of implementations.

Please refer to the FHIR overview website for further information.

The FHIR data model

At the heart of FHIR is the common definition of the different resource types that encompasses all the different aspects of healthcare. From the administrative function of Patient, Practitioner, CareTeam, Device, Organization, Location, Healthcare Service, to the Clinical, Diagnostic, Medications, as well as the Financial functions such as Insurance Coverage.

For the purpose of this article, I am using the sample synthetic data set available from Synthetic Mass that has been generated by Synthea, an open-source patient population simulation made available by The MITRE Corporation.

The data was made available as a resource bundle for each synthetic patient, which are then imported into an instance of Couchbase 6.5 database.

HL7 FHIR API Data Model for Healthcare in NoSQL JSON Database

A few notable points about the FHIR data model

  1. The model centers around the ‘patient’ object
  2. The object type is represented by the ‘resourceType’ field
  3. The JSON structure supports a richer set of health information that can be kept about the patient: health level, contact details, addresses, communications, etc.
  4. Each object has a uniquely identifiable ‘id’ field.
  5. The objects are referencing each other. Most are have references to the ‘patient’ object.

Why Couchbase is well suited for FHIR

As mentioned above, Couchbase stores its data natively in JSON, which is a readable document format. Applications can either use the Key-Value APIs, or leverage Couchbase N1QL Query Language to manipulate the documents. The advantage of storing the data in the JSON format, instead of as a column type as in many RDBMS, is the ease with which users can access the information therein. JSON document elements, such as field, array object, and hierarchical object can be accessed directly from the parent object without requiring additional syntax.

Here is an example of the Patient document as defined by the FHIR.

HL7 FHIR protocol patient admin document database

What it means for the FHIR application is that users with RDBMS experience who have a basic working knowledge of SQL can access the FHIR patient and the associated resources in the exact same way as with the traditional RDBMS. 

Couchbase N1QL to search FHIR data

Query patients by ID

Query patients by age group

  1. The patient’s age has to be calculated from taking the current date – DOB.
  2. The query uses the N1QL LET construct to define ‘age’ and bucket the age into ‘agegroup’.
  3. A standard ANSI GROUP BY and COUNT returns the number of patients by age group.

In addition, the ability to JOIN and UNNEST documents with Couchbase N1QL allows users to query related information of the patient.

Query patients and their current unresolved conditions 

  1. A patient can have multiple names, which are represented in the ‘name’ array. This query uses the ARRAY operator to filter out only the official ‘name’ array element.
  2. The query joins the ‘condition’  to the ‘patient’  object using part the ‘subject.reference’ field of the ‘condition’ object to the ‘patient.id’.
  3. Each ‘patient’ may have multiple conditions, hence the need to flatten (UNNEST) the ‘condition->code’ array.
  4. There could be multiple ‘clinical.status’ for the ‘condition’, but the query only needs to return the conditions that are not resolved
List of all patients who was at Beverley hospital on the week beginning of 2011-08-18

  1. The query examines the ‘encounter’ object to find out all the ‘patient’ treatment at this specific hospital.
  2. ARRAY operator is used to get the ‘patient’ official name.
List of patients with their insurance claim detail – services and cost

  1. The ‘claim’ object is JOINED to the ‘patient’ object to access the patient’s detail.
  2. The ‘claim’ object has nested array for ‘claim->item’.
  3. The ‘claim->item’ is associated to a ‘productOrService’ with an array coding that contain the description of the treatment.
  4. The cost is at the claim level.
Rank the Procedure count by Hospital

  1. The ‘procedure’ object is JOINED to the ‘encounter’ object to access the hospital where the procedure was administered.
  2. The N1QL Window RANK function is used to assign a value by the count of the procedure.
  3. Hash Join hint is used to improve the performance for the document JOIN.

Summary

Couchbase is well suited for FHIR implementation because of the approach it uses to store the data in JSON format. Its powerful N1QL query language allows developers with SQL experience to navigate the FHIR data model to perform all the CRUD operations that users would expect to see in a database.

With its ability to perform document JOIN to advanced processing of embedded array objects, the N1QL query language relegates all the processing needs to the Couchbase Query and Indexing Service, thus reducing the burden of the FHIR applications to having to perform all the object associations.

As with any new applications, there will always be a need to perform direct examinations of the underlying data, either by the application administrators or the data analysts who may have the need to perform searches beyond basic FHIR search capabilities.

In the next blog, I will examine what it takes to use REST for an FHIR API approach that can communicate with the Couchbase server to provide the basic FHIR search requirements.

Resources

  • Fast Healthcare Interoperability Resource
  • SyntheticMass: “Jason Walonoski, Mark Kramer, Joseph Nichols, Andre Quina, Chris Moesel, Dylan Hall, Carlton Duffett, Kudakwashe Dube, Thomas Gallagher, Scott McLachlan, Synthea: An approach, method, and software mechanism for generating synthetic patients and the synthetic electronic health care record, Journal of the American Medical Informatics Association, Volume 25, Issue 3, March 2018, Pages 230–238, https://doi.org/10.1093/jamia/ocx079″
  • N1QL Tutorial
  • FHIR Search Parameters

Author

Posted by Binh Le

Binh Le is a Principal Product Manager for Couchbase Query service. Prior to Couchbase, he worked at Oracle and led the product management team for Sales Clould Analytics and CRM OnDemand. Binh holds a Bachelor's Degree in Computer Science from the University of Brighton, UK.

Leave a reply