Skip directly to search

Skip directly to content

 

EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 3

 
 

Software Engineering | Matjaz Bravc |
24 August 2021

Welcome to the final post of this blog series where I show you how to create simple custom EHR to HL7 FHIR* integration using the latest Microsoft tech stack. In the first article, I introduced the HL7 FHIR standard and the .NET 5 framework. In the second post, I shared how you can integrate Patients into your solution. In this third part, I will describe how to integrate Patient Observations (blood tests).

HL7 FHIR OBSERVATIONS

As the HL7 documentation describes, Observations are a central element in healthcare, used to support diagnosis, monitor progress, determine baselines and patterns, and even capture demographic characteristics. Most observations are simple name/value pair assertions with some metadata, but some observations group other observations together logically or can even be multi-component observations. The DiagnosticReport resource provides a clinical or workflow context for a set of observations. The Observation resource is referenced by DiagnosticReport to represent laboratory, imaging, and other clinical and diagnostic data to form a complete report.

Uses for the Observation resource include:

  • Vital signs such as body weight, blood pressure, and temperature
  • Laboratory data like blood glucose or an estimated GFR
  • Imaging results like bone density or foetal measurements
  • Clinical findings such as abdominal tenderness
  • Device measurements such as EKG data or pulse oximetry data
  • Clinical assessment tools such as APGAR or a Glasgow Coma Score
  • Personal characteristics such as eye colour
  • Social history like tobacco use, family support, or cognitive status
  • Core characteristics like pregnancy status or a death assertion

But first, some explanation...

CBC TESTS

This demo focuses on several blood observations which are part of a complete blood count (CBC). CBC is a group of tests that evaluate the cells that circulate in the blood, including red blood cells (RBCs, or erythrocytes), white blood cells (WBCs, or leukocytes), and platelets (PLTs, or thrombocytes). The CBC can evaluate your overall health and detect a variety of diseases and conditions, such as infections, anaemia, and leukaemia. Blood cells are produced and mature primarily in the bone marrow and, under normal circumstances, are released into the bloodstream as needed.

A CBC is typically performed using an automated instrument that measures various parameters, including cell count and the physical features of some of the cells. A standard CBC includes:

Red blood cell tests:

• Red blood cell count – the actual number of red blood cells in your blood sample.
Haemoglobin – the total amount of the oxygen-carrying protein in the blood, which generally reflects the number of red blood cells in the blood.
Haematocrit – the percentage of your total blood volume that consists of red blood cells.

White blood cell tests:

White blood cell count – the total number of white blood cells in your blood sample.
White blood cell differential – may be included as part of the CBC or may be done in follow-up if the WBC count is high or low.

For Observations, like the results of such CBC tests, there are several endpoints available. Using Swagger UI “allows anyone – be it your development team or your end consumers – to visualize and interact with the API’s resources without having any of the implementation logic in place. It’s automatically generated from your OpenAPI Specification, with the visual documentation making it easy for back end implementation and client side consumption.”
 

 People looking at medical scan on computer screen

ADD A RED BLOOD CELL (RBC) OBSERVATION

Let’s go through the typical data flow and create a new red blood cell observation. For this purpose, I will use the api/Observation/AddRedBloodCellCountObservation/1845361/4.9 endpoint and send the following Patient ID (1845361) and value (4.9) in a request. The result is a new observation:

 People looking at medical scan on computer screen

DIG INTO THE CODE

Let’s look at the details. After the model validation in ObservationController, we call ObservationService with the AddRedBloodCellCountObservationAsync method.

 People looking at medical scan on computer screen

In the first step, the AddRedBloodCellCountObservationAsync method creates a new instance of the RedBloodCellCount model and then passes it to the private CreateObservation method, which returns a new instance of the FHIR Observation model.

 People looking at medical scan on computer screen

OBSERVATIONBASE MODEL

 People looking at medical scan on computer screen

REDBLOODCELLCOUNT MODEL

 People looking at medical scan on computer screen

OBSERVATIONDTO MODEL

People looking at medical scan on computer screen

As the result, ObservationController returns an ObservationDto model. For this purpose, we have to convert the FHIR Observation model into an ObservationDto model which includes only important information.

 People looking at medical scan on computer screen

I hope this introduction and guide on how to integrate patients and patient observations using the HL7 FHIR standard and .NET 5 have sparked your interest and will help you create healthcare software solutions.

Find example source code for this series on Endava’s GitHub.

PREREQUISITES

Visual Studio 2019 16.8.1 or higher
.NET 5.x

TAGS, TECHNOLOGIES AND SOURCES

Swagger – interactive API documentation
API-Docs – friendly API documentation
Serilog – flexible, structured logger
FluentValidation – a popular .NET library for building strongly-typed validation rules
Firely .NET SDK – the official HL7 FHIR SDK in .NET

ADDITIONAL RESOURCES

Extra documentation for FhirClient
HL7 FHIR Restful API specification
Firely.NET SDK FHIR Community
List of FHIR test servers

* HL7® and FHIR® are the registered trademarks of Health Level Seven International.

Matjaz Bravc

Senior Developer

Matjaz is a Senior Software Engineer with more than 15 years of experience in designing and developing scalable applications in an Agile manner. His experience ranges across various fields and technologies (mostly Microsoft stack), and he is an expert .NET developer with strong backend C# development experience. His expertise also includes mission-critical distributed systems with a strong focus on object-oriented programming, microservice architecture, data warehouse design, and test-driven development. Matjaz likes to spend his free time away from the computer, with hobbies such as scuba diving, canoeing, standup paddling, and mountain biking.

 

Related Articles

  • 24 August 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 3

  • 20 July 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 2

  • 29 June 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 1

  • 02 December 2020

    8 Tips for Sharing Technical Knowledge – Part 2

  • 12 November 2020

    8 Tips for Sharing Technical Knowledge – Part 1

 

From This Author

  • 20 July 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 2

  • 29 June 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 1

Most Popular Articles

11 Things I wish I knew before working with Terraform – part 2
 

Architecture | Julian Alarcon | 23 July 2019

11 Things I wish I knew before working with Terraform – part 2

11 Things I wish I knew before working with Terraform – part 1
 

Architecture | Julian Alarcon | 25 June 2019

11 Things I wish I knew before working with Terraform – part 1

AWS Serverless with Terraform – Best Practices
 

Architecture | Vlad Cenan | 10 December 2019

AWS Serverless with Terraform – Best Practices

Endava at NASA’s 2020 Space Apps Challenge
 

Insights Through Data | Gabriel Preda | 27 May 2021

Endava at NASA’s 2020 Space Apps Challenge

EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 1
 

Software Engineering | Matjaz Bravc | 29 June 2021

EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 1

EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 2
 

Software Engineering | Matjaz Bravc | 20 July 2021

EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 2

Elasticsearch and Apache Lucene: Fundamentals Behind the Relevance Score
 

Insights Through Data | Alveiro Garcia | 08 June 2021

Elasticsearch and Apache Lucene: Fundamentals Behind the Relevance Score

Following the Patterns – The Rise of Neo4j and Graph Databases
 

Insights Through Data | Calin Constantinov | 27 January 2021

Following the Patterns – The Rise of Neo4j and Graph Databases

Distributed Agile – Closing the Gap Between the Product Owner and the Team
 

Agile | Thomas Behrens | 11 February 2019

Distributed Agile – Closing the Gap Between the Product Owner and the Team

 

Archive

  • 24 August 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 3

  • 20 July 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 2

  • 29 June 2021

    EHR to HL7 FHIR Integration: The Software Developer’s Guide – Part 1

  • 08 June 2021

    Elasticsearch and Apache Lucene: Fundamentals Behind the Relevance Score

  • 27 May 2021

    Endava at NASA’s 2020 Space Apps Challenge

  • 27 January 2021

    Following the Patterns – The Rise of Neo4j and Graph Databases

  • 12 January 2021

    Data is Everything

  • 05 January 2021

    Closing-the-gap-between-the-product-owner-and-the-team-part-3

We are listening

How would you rate your experience with Endava so far?

We would appreciate talking to you about your feedback. Could you share with us your contact details?