Agnotic Technologies Logo
    Blog

    HL7 Acknowledgments (ACK/NAK): Original vs Enhanced Mode

    By GauravJanuary 30, 202610 mins read
    On this page

    What does an HL7 acknowledgment actually guarantee?

    The acknowledgment is the small message that makes HL7 v2 reliable — or reveals that it isn't. When a system sends an HL7 message, the receiver replies with an ACK saying 'got it, and here's whether I could process it.' Handle ACKs correctly and you get an interface that never silently loses data; handle them naively and you get one that reports success while messages fall on the floor. This guide covers acknowledgment modes, the MSA codes that carry the verdict, and why ACK handling is the difference between reliable and merely-working interfaces.

    Why acknowledgments exist

    HL7 v2 typically runs over a persistent connection where a sender pushes a message and waits for a reply before considering it delivered. That reply — the ACK — is the receiver's confirmation. Without it, the sender has no idea whether the message arrived, was rejected, or vanished. The ACK turns fire-and-forget into a reliable handshake, and treating it seriously is what keeps interfaces from silently dropping messages.

    The MSA segment: where the verdict lives

    An acknowledgment message carries an MSA (Message Acknowledgment) segment. MSA-1 holds the acknowledgment code, and MSA-2 echoes the original message's control ID so the sender can correlate the ACK to the message it acknowledges. That correlation matters: on a busy interface you must match each ACK to the specific message it answers, not just assume the last message was accepted.

    Acknowledgment codes: AA, AE, AR (and CA/CE/CR)

    • AA — Application Accept: the receiver processed the message successfully.
    • AE — Application Error: the message was received but couldn't be processed (e.g. a data problem). The sender should not treat this as success.
    • AR — Application Reject: the message was rejected outright (e.g. malformed, wrong type).
    • In enhanced mode the commit-level codes CA/CE/CR mirror these at the accept (commit) stage before application processing.

    Original vs enhanced acknowledgment mode

    HL7 defines two acknowledgment modes. In original mode, a single ACK covers both receipt and application processing — one reply says it was accepted and processed. In enhanced mode, acknowledgment is split into two levels: an accept (commit) acknowledgment that says 'I have safely received and stored this message and take responsibility for it,' and a later application acknowledgment that says whether business processing succeeded. Enhanced mode is more robust for reliable delivery because it separates 'I have custody of your message' from 'I successfully acted on it.'

    The failure mode people ship

    The classic bug: a sender fires messages and never checks the ACK, or checks only that some reply came back without inspecting MSA-1. The interface looks healthy — messages are going out, replies are coming in — while the receiver is returning AE on every one and processing nothing. Data loss is invisible until someone notices results aren't arriving. Always inspect the acknowledgment code, and treat AE/AR as failures that trigger retry or alerting, not as 'a reply was received, so we're fine.'

    Building reliable ACK handling

    • Wait for the ACK before considering a message delivered; time out and retry if none arrives.
    • Correlate the ACK to the original message via MSA-2 (the echoed control ID).
    • Branch on MSA-1: AA proceeds, AE/AR trigger retry, dead-lettering, or alerting depending on the error.
    • Prefer enhanced mode where the systems support it, to separate safe receipt from successful processing.
    • Make the receiver's side honest — don't return AA if you couldn't actually process the message.

    Why this small message is so important

    The ACK is the entire reliability contract of an HL7 v2 interface. A sender that respects it — waits, correlates, and reacts to AE/AR — cannot silently lose data, because every unacknowledged or rejected message is caught. A sender that ignores it has an interface that works in demos and drops messages in production. For something so small, the ACK carries the whole guarantee.

    Frequently Asked Questions

    Informally, an ACK with an accept code (AA/CA) is a positive acknowledgment, while a 'NAK' refers to a negative acknowledgment carrying an error or reject code (AE/AR or CE/CR) in the MSA segment. Both are ACK messages structurally; the MSA-1 code determines whether it's an accept or a rejection.

    Maintaining HL7 interfaces?

    We build and maintain production HL7 v2 interfaces — ADT/ORM/ORU feeds, interface-engine channels, and clean migrations from v2 to FHIR — for healthcare teams who need integrations that don't fall over at 2am.