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

  • 16 November 2021

    Create Production-Ready, Automated Deliverables Using a Build Pipeline for Games – Part 1

  • 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

  • 25 January 2022

    Scalable Microservices Architecture with .NET Made Easy – a Tutorial

  • 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

Challenges for Adopting AI Systems in Software Development
 

AI | Mario Rugeles | 01 June 2023

Challenges for Adopting AI Systems in Software Development

Will AI transform even the most creative professions?
 

AI | Špela Poklukar | 07 March 2023

Will AI transform even the most creative professions?

Generative AI: Technology of Tomorrow, Today
 

Artificial intelligence | Boris Cergol | 14 February 2023

Generative AI: Technology of Tomorrow, Today

The Joy and Challenge of Being a Video Game Tester
 

Testing | Gabriela Elena Miroiu | 25 January 2023

The Joy and Challenge of Being a Video Game Tester

Can Software Really Be Green?
 

Software Engineering | Eoin Woods | 14 November 2022

Can Software Really Be Green?

Is Data Mesh Going to Replace Centralised Repositories?
 

Insights Through Data | Adriana Calomfirescu | 26 July 2022

Is Data Mesh Going to Replace Centralised Repositories?

A Spatial Analysis of the Covid-19 Infection and Its Determinants
 

Insights Through Data | Stefana Belbe | 09 June 2022

A Spatial Analysis of the Covid-19 Infection and Its Determinants

An R&D Project on AI in 3D Asset Creation for Games
 

AI | Radu Orghidan | 17 May 2022

An R&D Project on AI in 3D Asset Creation for Games

Using Two Cloud Vendors Side by Side – a Survey of Cost and Effort
 

Architecture | Radu Vunvulea | 07 February 2022

Using Two Cloud Vendors Side by Side – a Survey of Cost and Effort

 

Archive

  • 01 June 2023

    Challenges for Adopting AI Systems in Software Development

  • 07 March 2023

    Will AI transform even the most creative professions?

  • 14 February 2023

    Generative AI: Technology of Tomorrow, Today

  • 25 January 2023

    The Joy and Challenge of Being a Video Game Tester

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?