Skip to content

Acknowledgments

HL7v2's built-in mechanism for confirming receipt and reporting the results of validation and processing.

Every HL7v2 exchange involves two systems: the source, which sends a message, and the destination, which receives and processes it. For example, when a patient is admitted, the registration system (the source) sends an admission message to the laboratory system (the destination).

The acknowledgment, or ACK, is HL7v2's built-in mechanism for reporting the result of each exchange. The destination answers every message with an acknowledgment: a short HL7v2 message that confirms the message was received and reports the result of validating and processing it. In the admission example, the laboratory system returns the code AA when it has registered the patient, or an error code that identifies the problem, such as a missing required field, when it cannot.

Purpose

HL7v2 acknowledgments serve three purposes: they confirm that each message was delivered, they report the results of validating and processing it, and they provide an audit record of each exchange.

Delivery confirmation

Healthcare systems exchange messages over networks, and the source, the destination, or the network between them can fail at any time. A lost message has clinical consequences: a laboratory result that does not reach the patient's record, or an allergy that the pharmacy system does not receive. The source therefore needs confirmation that each message has arrived, and a rule for what to do when that confirmation is missing.

Distributed systems use one of two rules:

  • At-most-once delivery. The source sends each message once and never resends it. No message is duplicated, but a message lost in transit is not recovered.
  • At-least-once delivery. The source resends a message until the destination confirms that it has arrived. No message is lost, but a message can arrive more than once, so the destination must recognize a message it has already processed.

HL7v2 interfaces typically use at-least-once delivery, because a duplicate can be detected and discarded, while a lost message may go unnoticed.

The acknowledgment is the confirmation that at-least-once delivery depends on. It comes from the destination application, not from the network: a network connection confirms only that the bytes of a message arrived, while the acknowledgment confirms that the destination received the message and reports what it did with it. After sending a message, the source keeps a copy and waits for the acknowledgment. If the acknowledgment arrives, the message has been delivered, and the source can discard its copy and send the next message. If no acknowledgment arrives within a set time, the source treats the message as undelivered and sends it again. A negative acknowledgment (AE or AR) also confirms that the message arrived; whether resending can help depends on the error, as described under Acknowledgment codes.

This delivery protocol works only if the destination can distinguish a new message from a repeated one. For this purpose, every message carries a unique identifier, the control ID in MSH-10, which the source assigns once and reuses when it resends the message. The acknowledgment repeats the control ID in MSA-2, so the source can identify the message being confirmed. A destination that keeps track of control IDs can also recognize a repeated message: instead of processing it again, it sends the acknowledgment again, because a repeated message means the first acknowledgment did not reach the source. MSA segment describes both fields.

Validation

The destination validates each message against the standard and, where one applies, against the interface's profile, and reports the result in the acknowledgment. When a message fails validation or processing, the acknowledgment identifies each problem with its location, a standard error code, and a description, as described under ERR segment. Without this report, the source would not learn of the failure, and the two systems would hold different data without any error being raised.

Audit record

Each acknowledgment records that a specific message, identified by its control ID, was handled at a specific time with a specific outcome. Acknowledgment logs are used to confirm delivery, find processing delays, and reconcile the two systems after an outage.

Structure

An ACK consists of segments, like any other HL7v2 message. Its definition has changed slightly between versions, but its core consists of three segments:

  • MSH (Message Header): identifies the acknowledgment itself, including its source, its destination, and its creation time. Its sending and receiving application fields (MSH-3 and MSH-5) are the reverse of those in the original message.
  • MSA (Message Acknowledgment): the acknowledgment code and the control ID of the message being acknowledged.
  • ERR (Error): optional and repeating. Each ERR segment reports one problem, with the location of the error, a standard error code, and a severity.

In the following exchange, the source system sends an ADT^A01 message to the destination:

ADT A01 message
MSH|^~\&|SendingApp|SendingFacility|ReceivingApp|ReceivingFacility|20230630120000||ADT^A01^ADT_A01|MSG000003|P|2.8|
EVN|A01|20230630120000|||
PID|1||1234567890^^^MRN^MRN||Doe^John^M^^^||19700101|M|||123 Main St^Anytown^CA^12345||555-123-4567|||S|
PV1|1|I|^^^Hospital^Bed^100||||||||||||||||12345678|

The destination processes the message and generates an acknowledgment:

ACK message
MSH|^~\&|ReceivingApp|ReceivingFacility|SendingApp|SendingFacility|20230630120001||ACK^A01^ACK|ACK000003|P|2.8|
MSA|AA|MSG000003|

In the header, the message type is ACK, the trigger event is the original message's trigger event (A01), and the message structure is ACK for every acknowledgment regardless of event. The control ID in MSH-10 is the acknowledgment's own identifier; the original message's ID appears in MSA-2.

MSA segment

The MSA (Message Acknowledgment) segment is the central segment of an ACK. It carries the acknowledgment status and the reference to the original message.

MSA segment
MSA|AA|MSG000003|
FieldNameDescription
MSA-1Acknowledgment codeThe outcome, from table 0008. In this example, AA (application accept).
MSA-2Message control IDThe MSH-10 of the message being acknowledged, which the source uses to match the acknowledgment to the message it sent.
MSA-3Text messageFree text describing the outcome. Deprecated in 2.4 and withdrawn in 2.7 in favor of ERR segments, but still widely sent.

For the remaining fields, see the MSA segment reference.

ERR segment

When the code is not AA, the acknowledgment should identify each problem in an ERR segment.

ACK message with error segments
MSH|^~\&|ReceivingApp|ReceivingFacility|SendingApp|SendingFacility|20230630120001||ACK^A01^ACK|ACK000004|P|2.8|
MSA|AE|MSG000004|
ERR||PID^1^7|102^Data type error^HL70357|E||||Date of birth is not a valid date 
ERR||PV1^1^3|204^Unknown key identifier^HL70357|E||||Location WARD9 does not exist 

In this example, the MSA segment reports an application error (AE) for message MSG000004, and each ERR segment describes one problem in four fields:

  • Location (ERR-2): where the problem is. PID^1^7 is field 7 of the first PID segment.
  • Error code (ERR-3): what the problem is, as a code from HL7 table 0357 with its display text, such as 102^Data type error^HL70357.
  • Severity (ERR-4): whether the problem is an error, a warning, or information. Because warnings and information do not prevent processing, an acknowledgment with code AA can also carry ERR segments.
  • User message (ERR-8): a description for the people who read the acknowledgment log.

The error codes distinguish problems with the form of a message, such as a missing required field or a value of the wrong data type, from problems with its content or with the destination, such as an unsupported message type or an unknown patient. The available codes differ between versions of the standard; the tables reference lists them for each version.

Before version 2.5, the ERR segment had a single repeating field that combined the location and the code (ERR|PID^1^7^102). Acknowledgments from systems that implement earlier versions use that form.

Variation in practice

The error segments above are fully populated. Acknowledgments in production range from this form to a bare MSA|AE|…|Error with no ERR segment, so a source system must handle the acknowledgment format that each destination sends.

Acknowledgment codes

The acknowledgment code in MSA-1 reports the outcome of an exchange. Its first character identifies the kind of acknowledgment (A for application, C for commit), and its second character identifies the outcome. The codes in use depend on the acknowledgment mode, described under Modes: original mode uses only the application codes AA, AE, and AR, and enhanced mode adds the commit codes CA, CE, and CR.

CodeMeaningModeResponse by the source
AAApplication AcceptBothThe message was processed. No further action is required.
AEApplication ErrorBothThe message contained an error, for example a value that failed validation or a patient the destination does not know. The source corrects the message or the underlying data and resends it.
ARApplication RejectBothThe message was rejected because its message type, processing ID, or version is not supported, or because the destination could not process it for a reason unrelated to its content, such as an internal failure. In the first case, resending the same message produces the same result; in the second, the destination can usually accept the message later.
CACommit AcceptEnhanced onlyThe message was received and stored; processing follows.
CECommit ErrorEnhanced onlyThe message could not be accepted, for example because of a sequence-number error in MSH-13.
CRCommit RejectEnhanced onlyThe message was rejected because its message type, processing ID, or version is not supported.

The distinction between AE and AR is most significant for automated handling. An AE indicates a problem in the content of this message, so a corrected message can succeed. An AR indicates a problem outside the message content: either the interface does not support the message, which requires investigation, or the destination failed temporarily, in which case the same message can be resent later. An interface that handles the two codes in the same way either retries messages that cannot succeed or discards messages that a correction or a later resend would have delivered.

Modes

An acknowledgment mode determines when the destination replies to a message and what its reply confirms. HL7v2 defines two modes, and the choice between them is a trade-off between simplicity and throughput.

The source selects the mode for each message in two header fields, MSH-15 and MSH-16. When both fields are empty, the exchange uses original mode. When either field is populated, it uses enhanced mode, and the values specify which acknowledgments the source requests, as described under Enhanced mode.

Original mode

In original mode, the destination replies once, after it has completely processed the message, and the source waits for that reply before it sends the next message. The reply is definitive: an AA means that the work is done. The cost is that the source is held for as long as processing takes, so the destination's processing time limits how many messages the source can send.

The exchange has one round trip:

  1. The source sends the message and waits.
  2. The destination processes the message and returns AA if processing succeeded, AE if the message contained an error, or AR if processing failed for another reason, such as an internal failure.
  3. After the acknowledgment arrives, the source sends the next message.

Original mode is simple, and the acknowledgment reports the outcome of processing. Because the source sends one message at a time, messages are also processed in the order they were sent.

The limitation is that the source waits for processing to finish. A destination that takes a long time to process a message, for example because it must look up a patient in another system, holds the connection for that time, and no other message can be sent. To release the source sooner, many destinations, including most interface engines, return AA as soon as they have stored a message, before processing it. An AA from such a destination confirms receipt rather than processing. If the destination fails after acknowledging, the message is lost, because the source has no reason to resend it.

Enhanced mode

Enhanced mode was introduced to allow the source to continue sending messages without waiting for the destination to finish processing each one. In enhanced mode, the reply is split into two steps. The destination first sends a commit acknowledgment as soon as it has stored the message safely. The commit acknowledgment confirms that the destination has taken responsibility for the message, so the source can send the next one immediately. The destination then processes the message at its own pace and, if the source requested it, reports the outcome later in a separate application acknowledgment.

Separating receipt from processing is a common pattern in distributed systems. A web server can answer 202 Accepted to confirm that it has queued a request whose result it will report later. A message broker confirms a message once it has stored it, before any consumer has processed it. A mail server accepts a message once it has queued it, and delivers it afterwards. In each case, the sender can continue as soon as the receiver has taken responsibility for the work, so the time that processing takes no longer limits how fast messages can be sent.

The commit acknowledgment, which the standard also calls the accept acknowledgment (the name used by MSH-15), confirms that the destination has stored the message safely. The destination sends it immediately, before processing begins, with one of three codes:

CodeMeaning
CACommit accept. The message is stored, and the destination is now responsible for processing it. The source does not need to resend it.
CECommit error. The message could not be accepted, for example because of a sequence-number error. The source can resend it once the problem is resolved.
CRCommit reject. The message type, processing ID, or version is not supported. Resending the same message produces the same result.

The application acknowledgment reports the outcome of processing, with the codes AA, AE, or AR. The destination sends it as a separate message after processing, which can be minutes or hours later and on a different connection. The source matches it to the original message by the control ID in MSA-2, and it can return a commit acknowledgment for it in turn.

The following message requests a commit acknowledgment and no application acknowledgment, and the destination answers with CA:

Message requesting a commit acknowledgment
MSH|^~\&|SendingApp|SendingFacility|ReceivingApp|ReceivingFacility|20230630120000||ADT^A01^ADT_A01|MSG000005|P|2.8|||AL|NE|
Commit acknowledgment
MSH|^~\&|ReceivingApp|ReceivingFacility|SendingApp|SendingFacility|20230630120000||ACK^A01^ACK|ACK000005|P|2.8|
MSA|CA|MSG000005|

Summary

Acknowledgments are HL7v2's built-in mechanism for confirming receipt and reporting the results of validation and processing. They are the confirmation that at-least-once delivery depends on: the source resends a message until it is acknowledged, and the control ID lets the destination recognize a message it has already received.

The ACK message carries the outcome in MSA-1, the control ID of the original message in MSA-2, and the details of each problem in ERR segments. An AA confirms processing, an AE reports an error in the message content that a corrected message can resolve, and an AR reports a message that the destination does not support or could not process. In original mode, the destination sends one acknowledgment after processing; in enhanced mode, it sends a commit acknowledgment on receipt and an application acknowledgment after processing.

An acknowledgment states that the destination accepted the message, not that the message was correct. Whether the source and the destination apply the same definition of a valid message is the subject of conformance.

Further reading