Testing HL7 v2 MSH-2: What Encoding Characters Actually Needs to Handle
MSH-2 is four characters packed together right after the field separator, and each one quietly controls how every other segment in the message gets split apart — get one wrong and composite fields like patient name or address stop parsing correctly.
MSH-2 is the four-character field immediately after MSH-1 — by convention ^~\& — that defines the component, repetition, escape, and subcomponent separators used throughout the rest of the message.
What each character defines
Example
The four characters right after the first pipe — ^~\& — are MSH-2, setting the component, repetition, escape, and subcomponent delimiters. Synthetic message — not a real transmission.
Where this trips people up
A patient address or name that legitimately contains one of these delimiter characters — an ampersand in a business name, for instance — has to be escaped using the escape character defined here, and integrations that skip escaping on the way out, or fail to unescape on the way in, end up with corrupted or truncated free-text fields that only surface once real-world data with those characters shows up.