Illustrative HL7 V2 structure

We previously saw the scenario of Alex’ quidditch admission.

In the background, the IT systems may have interacted as illustrate in this sequence diagram.

sequenceDiagram
    participant FirstAid as First Aiders
    participant Ambulance as Ambulance System
    participant ED as JRH Emergency Dept
    participant XRay as JRH X-Ray Dept
    participant Fracture as JRH Fracture Clinic
    participant Outpatient as JRH Outpatient Clinic
    participant GP as GP System

    FirstAid->>Ambulance: Call 999 (Request Ambulance)
    note over Ambulance: Admission Phase 
    Ambulance->>ED: ADT^A01 (Admission to ED)
    ED->>GP: ADT^A01 (Notify GP of Admission)

    note over ED,XRay: Transfer Phase
    ED->>XRay: ADT^A02 (Transfer to X-Ray)
    XRay->>ED: OBX (X-Ray Result)
    ED->>Fracture: ADT^A02 (Transfer to Fracture Clinic)
    Fracture->>ED: OBX (Diagnosis Confirmed)

    note over Fracture,GP: Discharge Phase 
    Fracture->>Ambulance: ADT^A03 (Discharge Notification)
    Fracture->>GP: ADT^A03 (Notify GP of Discharge)

    note over Fracture,Outpatient: Follow-up Phase
    Fracture->>Outpatient: ADT^A08 (Schedule Follow-up)

HL7 V2 Message structure (generated by Copilot)

The messages are typically HL7 V2 messages. The anatomy of a V2 message is illustrated with this admission transaction.

flowchart LR
    subgraph Header["Header Information"]
        MSH["MSH (1..1) - Message Header"]
        EVN["EVN (1..1) - Event Type"]
    end

    subgraph PatientInfo["Patient Information"]
        PID["PID (1..1) - Patient Identification"]
        PD1["PD1 (0..1) - Patient Demographics"]
        NK1["NK1 (0..*) - Next of Kin"]
        AL1["AL1 (0..*) - Allergy Information"]
    end

    subgraph VisitInfo["Visit Information"]
        PV1["PV1 (1..1) - Patient Visit"]
        PV2["PV2 (0..1) - Additional Visit Info"]
    end

    subgraph ClinicalData["Clinical Data"]
        OBX["OBX (0..*) - Observation/Result"]
    end

    %% Connections
    Header --> PatientInfo
    PatientInfo --> VisitInfo
    VisitInfo --> ClinicalData

    %% Fields for MSH
    MSH --> MSH_F1["Sending App"]
    MSH --> MSH_F2["Sending Facility"]
    MSH --> MSH_F3["Receiving App"]
    MSH --> MSH_F4["Receiving Facility"]
    MSH --> MSH_F9["Message Type (ADT^A01)"]

    %% Fields for PID
    PID --> PID_F1["Patient ID"]
    PID --> PID_F2["Patient Name"]
    PID --> PID_F3["Date of Birth"]
    PID --> PID_F4["Sex"]

    %% Fields for PV1
    PV1 --> PV1_F1["Patient Class"]
    PV1 --> PV1_F2["Assigned Location"]
    PV1 --> PV1_F3["Attending Doctor"]

In HL7 v2 messages, these characters are special delimiters defined in the MSH segment (usually in MSH-2):

| (Pipe)Field Separator
Separates fields within a segment. Example: PID|1|12345|DOE^JOHN Here, PID is the segment name, and 1, 12345, DOE^JOHN are fields.

^ (Caret)Component Separator
Splits components within a field. Example: DOE^JOHN^A Means Last Name = DOE, First Name = JOHN, Middle Initial = A.

~ (Tilde)Repetition Separator
Indicates repeated values for the same field. Example: SMITH^JANE~SMITH^ROBERT Represents two next-of-kin entries in one NK1 field.

Sample messages (generated by Copilot)

Admission to Emergency Department (ADT^A01)

MSH|^~\&|AMB_SYS|SCAS|JRH_EPR|ED|20251127T101500Z||ADT^A01|MSG0001|P|2.6
EVN|A01|20251127T101500Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U|||12 COLLEGE LANE^OXFORD^OX1 2JD^UK||(01865)123456||ENG
NK1|1|SMITH^JAMIE|FRI|12 COLLEGE LANE^OXFORD^OX1 2JD^UK||(01865)654321
PV1|1|E|ED^ROOM_3^BED_2|U|AMB|20251127T101000Z||12345^DR^EMMA^J^^Consultant||||||||||||||||||||||||20251127T101500Z
OBX|1|TX|AMB_REPORT^Ambulance Report||Patient fell during quidditch match; suspected fracture lower arm|||N|||F

1a. GP Notification of Admission (ADT^A01)

MSH|^~\&|JRH_EPR|ED|GP_SYS|OXFORD_GP|20251127T101600Z||ADT^A01|MSG0001_GP|P|2.6
EVN|A01|20251127T101600Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U|||12 COLLEGE LANE^OXFORD^OX1 2JD^UK||(01865)123456||ENG
PV1|1|E|ED^ROOM_3^BED_2|U|AMB|20251127T101000Z||12345^DR^EMMA^J^^Consultant
OBX|1|TX|NOTIFY^Admission Notification||Patient admitted to JRH ED following sports injury|||N|||F

Transfer to X-Ray Department (ADT^A02)

MSH|^~\&|ED_SYS|JRH_ED|JRH_EPR|XRAY|20251127T103000Z||ADT^A02|MSG0002|P|2.6
EVN|A02|20251127T103000Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U
PV1|1|E|XRAY^ROOM_1|U|ED|20251127T103000Z||12345^DR^EMMA^J^^Consultant
OBX|1|TX|XRAY_REQ^X-Ray Request||Lower arm imaging requested|||N|||F

Transfer to Fracture Clinic (ADT^A02)

MSH|^~\&|ED_SYS|JRH_ED|JRH_EPR|FRACTURE_CLINIC|20251127T110000Z||ADT^A02|MSG0003|P|2.6
EVN|A02|20251127T110000Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U
PV1|1|E|FRACTURE_CLINIC^ROOM_2|U|ED|20251127T110000Z||12345^DR^EMMA^J^^Consultant
OBX|1|TX|XRAY_RESULT^X-Ray Result||Fracture confirmed in radius|||N|||F
OBX|2|TX|DIAGNOSIS^Provisional Diagnosis||Fractured lower arm|||N|||F

Discharge from Hospital (ADT^A03)

MSH|^~\&|FRACTURE_SYS|JRH_FRACTURE|JRH_EPR|DISCHARGE|20251127T130000Z||ADT^A03|MSG0004|P|2.6
EVN|A03|20251127T130000Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U
PV1|1|E|FRACTURE_CLINIC^ROOM_2|U|ED|20251127T110000Z||12345^DR^EMMA^J^^Consultant
OBX|1|TX|DISCHARGE_NOTE^Discharge Note||Arm placed in cast; follow-up scheduled|||N|||F

GP Notification of Discharge (ADT^A03)

MSH|^~\&|JRH_EPR|FRACTURE_CLINIC|GP_SYS|OXFORD_GP|20251127T130100Z||ADT^A03|MSG0004_GP|P|2.6
EVN|A03|20251127T130100Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U|||12 COLLEGE LANE^OXFORD^OX1 2JD^UK||(01865)123456||ENG
PV1|1|E|FRACTURE_CLINIC^ROOM_2|U|ED|20251127T110000Z||12345^DR^EMMA^J^^Consultant||||||||||||||||||||||||20251127T130000Z
DG1|1||S52.5^^ICD-10||Unspecified closed fracture of lower end of right radius|F
OBX|1|CWE|294063008^Diagnosis (SNOMED CT)^SNM|1|263199001^Fracture of distal end of radius (disorder)^SNM|||N|||F
OBX|2|TX|NOTIFY^Discharge Notification||Alex discharged from JRH Fracture Clinic; arm in cast; follow-up scheduled|||N|||F

Future Appointment (ADT^A08 – Update Info)

MSH|^~\&|FRACTURE_SYS|JRH_FRACTURE|JRH_EPR|OUTPATIENT|20251127T131500Z||ADT^A08|MSG0005|P|2.6
EVN|A08|20251127T131500Z
PID|1|987654321^^^NHS^UK||ALEX^^^^||20040315|U
PV1|1|O|OUTPATIENT^CLINIC_5|U|FRACTURE_CLINIC|20251231T090000Z||12345^DR^EMMA^J^^Consultant
OBX|1|TX|FOLLOWUP^Follow-up Appointment||Review fracture healing in 5 weeks|||N|||F