When a patient is admitted, the hospital information system sends the departmental systems a line of text that opens with MSH and continues with pipe-separated fields. It is a Health Level Seven Version 2 (HL7 v2) message, the format — first defined in 1987 — over which most internal hospital communication still travels today.

Context

The standard is twenty-five years old, with no operational successor in sight. Several versions live side by side in the field: 2.3 (1997) and 2.3.1 (1999) hold on in legacy installations; 2.4 (2000) and 2.5 (2003) are the most common baseline in Italian links; 2.5.1 and 2.6 (both 2007) show up in newer systems. The latest revision is 2.7, ANSI-approved in January 2011. The numbering moves on, but the old versions do not disappear: a hospital information system (HIS) installed ten years ago keeps emitting what it has always emitted, and the receiving end has to read it.

The scope is the clinical-administrative flow: patient demographics and movements, laboratory and radiology orders, results, scheduling, clinical documents. All of it passes between the HIS, the radiology information system (RIS), the laboratory information system (LIS) and the other departmental systems as v2 messages.

Anatomy of the message

HL7 v2 is a text format with hierarchical separators that the message declares for itself. Each message is a sequence of segments divided by carriage returns; each segment is a sequence of fields divided by the pipe |; fields break down into components divided by the caret ^, sub-components divided by the ampersand &, and repetitions divided by the tilde ~. The backslash \ is the escape character.

The first segment is always MSH (Message Header) and, at its characters 2-8, it declares the separators used in the rest of the message, along with sender, receiver, message type and control identifier. An admission (event A01) usually opens like this:

MSH|^~\&|HIS|OSP|RIS|RAD|201202201030||ADT^A01|MSG00001|P|2.5
EVN|A01|201202201030
PID|1||123456^^^OSP^MR||SMITH^JOHN||19501225|M
PV1|1|I|WARD1^101^1

The recurring ones are PID (patient identification), PV1 (visit/episode), OBR and OBX (observation request and result), ORC (common order), AL1 (allergies), DG1 (diagnosis), NK1 (next of kin). Each segment has a position and a structure fixed by the chapter of the standard that governs it.

Message types map clinical events. ADT covers admissions, discharges and transfers, with events such as A01 (admit), A03 (discharge), A08 (update). ORU^R01 carries results and reports. SIU handles scheduling. MDM handles textual clinical documents. Orders have a history that says a lot: the old generic ORM^O01 has been joined by domain-specific messages — OMG for general orders, OML for laboratory, OMP for pharmacy — a sign that the standard tried to narrow the ambiguity of a single catch-all type.

Transport

HL7 v2 mandates no transport protocol, but in the field the choice is almost always the Minimal Lower Layer Protocol (MLLP), the subject of a transport specification published by HL7 (Transport Specification: MLLP, Release 1). The mechanism is elementary. TCP delivers a continuous byte stream, so the message has to be framed for the receiver to tell where it starts and ends: MLLP prepends a start-block byte <VT> (0x0B) to the payload and closes it with <FS> (0x1C) followed by a carriage return (0x0D).

The frame imposes a constraint on character encoding: a multi-byte encoding that produces bytes equal to 0x0B or 0x1C breaks the framing. The application-level acknowledgement is an ACK message whose MSA-1 field holds AA (accepted), AE (application error) or AR (rejected). The connection lives on dedicated TCP ports inside the hospital network.

The real cost of integration

The cost of HL7 v2 integration does not lie in parsing the format — that was solved long ago. It lies in the distance between two implementations that claim the same version. The standard is permissive by choice: many fields are optional, many allow locally defined values, and the specification tolerates the elements it does not recognise rather than discarding the message. That tolerance is useful, because it does not stall clinical flows, but it pushes the burden of agreement downstream: two vendors can both conform to 2.5 and map the same datum into different positions, or use incompatible local code tables.

The field effect is that an ADT coming from a given HIS must be mapped and adapted to the format the receiver expects, even when both declare conformance to the same version. Integration, in practice, is translation work between dialects of the same standard, not plain routing.

Tools

Two mature open-source components cover the bulk of the work. Mirth Connect (Mirth Corporation) is a Java integration engine organised into channels: each channel reads messages from a source — MLLP listener, file, database, HTTP — filters and transforms them with JavaScript steps running on the Rhino engine, and routes them to multiple destinations. The 2.x series is the one in production today; the licence is the Mozilla Public License. HAPI (HL7 Application Programming Interface), born at University Health Network in Toronto, is the reference Java library for reading, validating and building v2 messages, distributed under the Apache License 2.0 and used as the parsing engine by several integration engines. Both cover versions from 2.1 onward: with these you build integration nodes without tying yourself to proprietary products.

The Italian picture

In Italy HL7 v2 is the common language of hospital integration: links between the HIS and departmental systems, exchanges between laboratories and requesters, the feeds for the regional Electronic Health Record programmes. HL7 Italia, an affiliate of HL7 International, coordinates standardisation locally, but the more elaborate Italian profiles concern the document layer — the Clinical Document Architecture (CDA) — rather than v2 messaging, which stays customised vendor by vendor.

Limits

The format’s limits are structural and well known: it is not self-describing, optionality is everywhere, error tolerance translates into variability between implementations, and there is no formal clinical semantics inside the message. On these limits the later HL7 efforts build — CDA for structured documents, and the work under way towards a resource-oriented model — but for the generation of systems in service today, real hospital integration keeps resting on lines of text that begin with MSH.


https://www.hl7.org/implement/standards/ansiapproved.cfm https://www.hl7.org/documentcenter/public/wg/inm/mllp_transport_specification.PDF https://www.hl7.eu/HL7v2x/v26/std26/hl7.html https://www.hl7italia.it/

Cover image: Diagram of an HL7 PID segment: a pipe-delimited line of text (“PID|||0815|1234567890|Doe^John…”) with yellow speech-bubble labels… — diagram by Dipl.-Inform. Oliver S. Lazar, public domain — https://commons.wikimedia.org/wiki/File:HL7_pid.png