HL7 v2.x · ADT, ORM, ORU and more

HL7 Message Viewer

Open HL7 v2 messages to read every segment with its field names, check the header and counts, generate an ACK, and de-identify names, IDs, addresses, phones and dates. Message content never leaves this page.

HL7 input

Drop an HL7 file

.hl7, .txt, .msg up to 20.0 MB; MLLP framing and FHS/BHS batches are handled

Open a file, paste a message, or load an example. Patient data stays in this tab.

HL7 Message Viewer

Operator: Abdulla Al Fahad. How tools are built and checked

An HL7 v2 message is pipe-delimited text where PID-5 means the patient name only if you know the segment tables by heart. This viewer reads the encoding characters from the MSH segment, labels every field, and summarises the message: type, trigger event, sender, receiver, timestamp, control ID and patient. Beyond reading, it builds an ACK for the message and produces a de-identified copy for sharing or testing.

Key features

  • Field tables for MSH, EVN, PID, PD1, NK1, PV1, PV2, ORC, OBR, OBX, NTE, AL1, DG1, IN1, GT1, SCH, TXA and MRG with HL7 2.5.1 names
  • Repetitions, components and subcomponents shown separately, with escape sequences decoded
  • MLLP framing bytes and FHS/BHS batch wrappers stripped, with up to 50,000 messages per file
  • An ACK generator for AA, AE and AR, and de-identification of names, providers, IDs, addresses, phones, dates and free text, exported as HL7, JSON or CSV

How separators, escapes and repetitions are read

The field separator is the character right after MSH; MSH-2 lists the component, repetition, escape and subcomponent characters in that order. The escapes \F\, \S\, \T\, \R\ and \E\ become the field, component, subcomponent, repetition and escape characters, \Xhh\ becomes a byte and \.br\ a line break. Segment ends may be carriage returns, line feeds or both.

Messages that arrive from a TCP listener are often wrapped in MLLP: a 0x0B byte in front and 0x1C 0x0D behind. Those bytes are removed and the page says it did so. A batch file with FHS and BHS headers and BTS and FTS trailers is split into its messages.

How it works

De-identification works in three passes. First, a table of HL7 v2.5.1 field positions for the segments the page parses (PID, NK1, GT1, IN1, IN2, IN3, PV1, ROL, OBR, DG1 and others) says which fields hold a name, provider, identifier, address, phone, date or free text, including the social security fields GT1-19, NK1-37, IN2-2 and PID-19. Second, a sweep looks in every field that is not on the table for SSN-, phone- and email-shaped values. Third, with free text on, the text of NTE, text-typed OBX values and embedded documents (ED, RP) is removed, and segments the page has no table for, such as Z-segments, are emptied. Each distinct name, ID or address gets one pseudonym, so the same patient has the same replacement in every message of the file.

Dates are moved, not blanked. In per-patient mode each patient key is hashed to a shift of between 1 and 365 days earlier, so intervals inside one patient's record keep their length; a fixed mode shifts everything by the number of days you enter.

When this helps

  • An interface analyst receives a log of 3,000 ADT messages from a hospital's new registration system and needs to find the few with a wrong PV1-3 location. Each message is split into numbered fields, so the unit, room and bed components of PV1-3 can be read without counting pipes.
  • A vendor asks for a sample ORU to build their mapping. The analyst de-identifies it; the dictated comment naming the patient's sister, which sat in an OBX text value, is removed as free text, and the guarantor's social security number in GT1-19 is replaced by an ID.
  • A tester sends an AE acknowledgment with the text Bad value x back to the sender and checks that MSA-3 and ERR-8 both carry it.
  • A lab interface team opens a batch of 3 messages inside FHS and BHS headers and finds BTS-1 says 3, matching the count the viewer found.

Opening a file

  1. Paste messages or open a file; choose Load example for an ADT^A01 admit message.
  2. Read the summary, then open a segment to see its numbered fields and values.
  3. Read the issues list for missing MSH-9, MSH-10 or MSH-11 values and for OBX numbering gaps.
  4. On the ACK tab pick AA, AE or AR and enter an error text if needed.
  5. On the De-identify tab choose what to replace, check the counts, and download the copy.

Example

Load example (an invented ADT^A01 admit), de-identified with the default settings: the PID segment before

PID|1||MRN558201^^^MERCYGEN^MR||Brennan^Imara^N||19840607|F|||221 Linden Ave^^Dayton^OH^45402^US||(937)555-0142

The same segment afterwards, and the replacement counts for the whole message

PID|1||ID000001||Alder^Avery^||19840114|F|||1 Example Street^^Anytown^OH^00000^US||(555)555-0100|||M||ID000002|
2 names, 2 providers, 5 IDs, 2 addresses, 2 phones, 5 dates, 2 free text

Tips for best results

  • Turn on per-patient date shifting when you will compare two messages for the same person. A fixed shift is easier to reason about, but everyone in the file moves by the same number of days, so one known date reveals them all.
  • Search the result for the surname and the MRN before sending it out. The page replaces what its tables and sweep find; a name typed into a field it does not list will survive.
  • Leave free text switched on for anything leaving the organisation; it is the option that catches names in OBX results and Z-segments.

Limits

A name written into a field that is not on the field table survives, because the sweep only recognises SSN-, phone- and email-shaped values. Numeric OBX values are kept, coded values lose their display text when free text is on, and timestamps are shifted. Read the result before sharing it.

The birth date moves 145 days earlier in the example (19840607 becomes 19840114) and the message time moves with it. MSH sender and receiver names stay as they are, because they identify systems and not people; change them by hand if the facility is sensitive.

A shifted date can still land on a different weekday, which matters for scheduling data.

The viewer does not check a message against a profile or conformance statement, only its structure and counts.

Batch files over 50,000 messages are read only up to that limit.

Common errors and how to fix them

"Message 4: PID-7 "1984-06-07" is not a valid HL7 date and was left alone"
HL7 timestamps are digits (YYYYMMDD or longer), not ISO dates with dashes. The page cannot shift a value it cannot parse, so it stays unchanged: fix the source or edit that field before sharing the copy.
The ACK shows ERR-8 text with spaces where you typed | or ^
Those characters are separators in HL7 and would split the acknowledgment into extra fields, so they are replaced by spaces in the error text. Use a different word or punctuation.
"No MSH segment was found. An HL7 v2 message starts with MSH followed by the field separator"
The text does not start a message with MSH. Remove log prefixes such as timestamps in front of each line, or paste the raw payload.

What the ACK contains

The acknowledgment swaps sender and receiver, sets MSH-9 to ACK with the original trigger event, uses ACK- plus the incoming control ID as its own control ID, and echoes the incoming ID in MSA-2. For AE and AR it adds an ERR segment with code 207 and your text. Characters that would break the message, such as | and ^, are replaced by spaces in that text.

Frequently asked questions

Is the de-identified message safe to share?

It removes the identifiers its field tables and sweep cover, so it is a starting point rather than a certification. Search the output for the patient's surname, MRN and street, and follow your organisation's policy. It does not claim to meet the HIPAA Safe Harbor list.

Why is the sending facility replaced with FACILITY?

MSH-4 and MSH-6, and facility fields such as PD1-3 and IN1-4, can name the hospital or practice, which narrows down who the patient is. They are replaced when the ID option is on; turn it off if you need real routing values and share the file only inside your own network.

Why are two dates from the same patient moved by the same amount?

The shift comes from the patient's key, so birth date, admit date and discharge date keep the same gaps and a length of stay stays correct.

Does it handle HL7 v3 or FHIR?

No. Version 3 is XML and FHIR is JSON or XML; this page reads pipe-delimited v2.x only.