Skip to content
IRI Logo
Solutions Products
  • Solutions
  • Products
  • Blog
  • BI
  • Big Data
  • DQ
  • ETL
  • IRI
    • IRI Business
    • IRI Workbench
  • Mask
  • MDM
    • Master Data Management
    • Metadata Management
  • Migrate
    • Data Migration
    • Sort Migration
  • Test Data
  • Transform
  • VLDB
  • VLOG
HL7 Logo

Unmasking the HL7 Data Standard

  • by Uli Bethke

In this series of articles, we will describe the semi-structured HL7 file format used in many healthcare industry data storage and processing settings, and show how you can rapidly transform and mask large volumes of HL7 XML messages without writing code.

This first article introduces the HL7 standard and explains how HL7 messages are structured with an example.  The next article will cover parsing and structuring this data with Flexter Data Liberator and seamlessly processing (transform, de-identify,  cleanse, report on, etc.) the results in the IRI Voracity platform. Note that for PHI data masking purposes, it is also possible to process HL7 and X12 messages in unstructured text or XML files using IRI DarkShield directly, without pre-parsing or other processing.

The HL7 Industry Data Standard

Health Level 7 (HL7) is the primary data standard for the healthcare industry worldwide. HL7 allows clinical systems to speak the same language when exchanging data as messages.

HL7 started in 1987 when an international group of experts created a first version of the standard. Volunteers founded the not-for-profit “Health Level Seven International” consortium and declared HL7 2.1 to be the first usable version of the standard in 1990.

The standard was widely adopted after the ANSI-compliant v2.3 was released. All minor releases of HL7 2.x are backward compatible, which made it hard to evolve the standard. As a result, HL7 v3 was released and exists alongside v2.x. However, adoption of v3 has been slow, and the vast majority of implementations are still based on version 2.x. HL7 is also ISO-compliant.

HL7 XML Encoding

HL7 messages can either be encoded in EDI or XML. At first, only EDI was used as a serialization mechanism. However, XML has various advantages over EDI. It is more widely adopted than EDI, and there are a lot of tools, such as Flexter Data Liberator, to efficiently process XML messages.

XML messages come with properly defined schema files called XSDs, which are widely used to implement industry data standards. Here is an excellent guide from the HL7 website on how to encode HL7 messages in XML. It also shows examples of how the messages differ from EDI.

HL7 XML Message Structure

HL7 Message Types

Before we process HL7 XML files with Flexter Data Liberator, let’s have a look at how HL7 messages are structured.

First, there are different message types, each representing a business process of the overall standard. The most popular message types are for patient administration and orders.

Each message type is represented by a code. For patient administration, this code is ADT, which stands for Admission, Discharge, and Transfer. Another popular message type is order entries. One of the message codes for orders is ORU.

If you want to learn more about the message types and their implementation, see the HL7 messaging standard specifications from the HL7 website. The v2.3.1 HL7 specification is over 1,000 pages and can be downloaded here (registration required).

HL7 Trigger Events

Each message type is split further into so-called trigger events. A trigger event correlates to an event in the real world; e.g., admission of a patient to a hospital or observation messages.

HL7 XML Sample Files

You can also download HL7 XML examples for ADT and ORU from the HL7 website.

The sample HL7 XML message below is of message type Observation Reporting (ORU), and corresponds to trigger event R01. What does this mean? ORU is an observation message used to transmit lab results. The R01 trigger event instructs the receiving system to create a new observation report.

XML samples

Segments

Each HL7 XML file is further split into segments. In our sample XML file, we have the segments for Patient (PID), Patient Observation Request (OBR), and Patient Observation (OBX).

Segments

 

Sequences

Each segment is further split into one or more mandatory or optional sequence numbers. Here is an example for PID:

Sequences

In the above PID element, we are dealing with PID sequence number 3. We can look up what sequence 3 stands for in the specification.

Figure 3-2

We now know from the lookup table that sequence 3 is the Patient Identifier List. Apart from the name of the element, the above table also tells us if a sequence is optional, backward compatible, or required (column OPT), plus other pieces of information, like the length of the field.

Data Types

What about XPN.1 (<CX.1>555-44-4444</CX.1>) then, which is the next element in the hierarchy?

XPN

This is a so-called data type. In HL7, there are simple and complex data types. An example of a simple data type is TS, which is a timestamp. An example of a complex data type is XPN, which stands for Extended Person Name. Codes for data types can be looked up in the specification.

XPN - extended person name

HL7V 2.3.1 page 2-60

Note: Instead of writing out the full name for each code, element names are abbreviated to keep the size of the XML files small for faster network transport and processing.

Parsing HL7 XML Files

Now that we have some background knowledge on the HL7 standard and understand how HL7 XML messages are structured, we can process them into a relational format.

The next article shows how the enterprise version of Flexter Data Liberator parses and structures the XML examples from the HL7 website mentioned in my introductory article on HL7, and how IRI Voracity seamlessly processes and protects the results in relational database tables.

The Formidable but Imperative Task of IoT Security
Process and Protect HL7 Data with Voracity
Flexter Data Liberator HL7 HL7 ADT HL7 data masking HL7 get started HL7 intro HL7 message masking HL7 ORU HL7 XML IRI Voracity PHI de-identificadtion X12 PHI xml XSD

Related articles

DarkShield PII Discovery & Masking…
Masking Flat Files in the…
Directory Data Class Search Wizard
Masking PII in a Relational…
IRI Data Class Map
Schema Data Class Search
Training NER Models in IRI…
Masking NoSQL DB PII in…
Masking RDB Data in the…
IRI DarkShield-NoSQL RPC API
Find & Mask File PII…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Big Data 66
  • Business Intelligence (BI) 77
  • Data Masking/Protection 163
  • Data Quality (DQ) 41
  • Data Transformation 94
  • ETL 122
  • IRI 229
    • IRI Business 86
    • IRI Workbench 162
  • MDM 37
    • Master Data Management 12
    • Metadata Management 25
  • Migration 65
    • Data Migration 60
    • Sort Migration 6
  • Test Data 102
  • VLDB 78
  • VLOG 40

Tracking

© 2025 Innovative Routines International (IRI), Inc., All Rights Reserved | Contact