#100DaysOfCode - Day 99: HL7 Fundamentals

#100DaysOfCode - Day 99: HL7 Fundamentals

3 mins

As one of my days of final “Days of Code” (although I’m coding every day at work in C# and Javascript), I wanted to write about my process of learning HL7 healthcare interoperability standards, particularly their earlier standards (before FHIR).

I’ve spent the last 12 weeks taking a course called on the fundamentals of HL7.org, which includes a dive in of the open healthcare interfaces’ first standards, including HL7v2, HL7 CDA, and HL7v3. It also briefly spoke about the organization’s newest, and most versatile standard called FHIR, but I’ll save that post for another time.

So, I wanted to summarize the standards a bit:

HL7v2

From the three older standards, HL7v2 is the most common standard being used alongside FHIR for interoperability in healthcare. It’s been around since the early 2000’s (2004 I believe), and it’s really just a documented way to share information, using it’s own format. The format, in text, consists of “object” type entities on each line, and each line (formally a “message”) is pipe (“|”) delimited to include different “segments”. These segments can then be separated even further, via the up caret (“^”) delimiter.

Here’s an example of an HL7 message sending a base64 encoded PDF report for a Patient encounter:

MSH|^~\&|||<YOUR APP>|<DESTINATION EHR>|<MESSAGE DATE/TIME>||MDM^T02|<CONTROL ID>|T|2.3
PID|||<MRN>^^^^<ID TYPE>||<LAST NAME>^<FIRST NAME>^<MIDDLE>||<DOB>|<LEGAL SEX>|||||||||||
PV1|1||||||||||||||||||<VISIT ID (CSN)> TXA||<DOCUMENT TYPE>||<ACTIVITY DATE/TIME>|<OPTIONAL:ACTIVITY PROVIDER ID>^<LAST>^<FIRST>^<MIDDLE>^^^^^<ID TYPE>|||||||^^<DOCUMENT ID>||<OPTIONAL:ORDER ID>|<OPTIONAL:ACCESSION NUMBER>||AU||AV
OBX|1|ED||1|^^PDF^Base64^<base 64 encoded document>|||||||||||

Walking through each line:

  1. MSH: the header of the entire packet. Includes some information about the type of data we’re sending. In this case, an MDM (see later in the first line) is a standard type of ADT packet to send in healthcare.
  2. PID: a patient identifier with some basic patient demographics
  3. PV1: a patient visit identifier (encounter, basically)
  4. OBX: an observation / result object, used to encapsulate text or encoded files.

If you’re interested in learning more about HL7v2, check out the PDF here

HL7 CDA

HL7 Clinical Document Architecture (CDA) was a push extending beyond v2 and v3. It was HL7’s push for creating their own standard word documents, in a way, so that everything would follow a particular format and be able to lead to more actionable insights and quick exchange across facilities. It’s still used widely in healthcare, but it’s more commonly used for document exchange within hospital networks (with lots of active communication), so it’s more known by the analysts working within big hospital networks, such as Mayo Clinic.

For CDA, we went through creating an example ClinicalDocument, which you can find in my training resources submission documented here

If you’re interested in learning more about CDA, check out the PDF here

HL7v3 (RIM)

The HL7 Reference Information Model (RIM) was introduced as an (admittedly somewhat failed) attempt to encode everything in healthcare, and how it related to other things. It was, in a way, healthcare trying to make every action, object, and thing related - in the object-oriented sense that programming is.

Healthcare is a notoriously complex field, so naturally, the many many options of having different ways to map things together wasn’t a great fit, and this standard hasn’t been very well adopted. It’s admittedly hard to follow in many ways, and regardless of how much experience I have in this subject, I don’t think I’ll ever fully be comfortable with v3 HL7.

If you’re interested in learning more about v3’s Reference Information Model, check out the PDF here


For more resources on HL7 formats, including FHIR, visit my training documents all gathered together at https://github.com/mochsner/hl7-training !

Happy healthcare interoperability!

Marc

Written on November 22, 2021