Written by Technical Team | Last updated 27.11.2026 | 20 minute read
An HL7 v2 interface can successfully transmit thousands of messages without necessarily delivering the clinical outcomes expected of it. A patient administration system may receive a positive acknowledgement from an integration engine even though the receiving electronic patient record (EPR) has failed to process the corresponding admission. A laboratory information management system may retransmit a pathology result because an acknowledgement was lost, despite the result having already been recorded in the destination system.
Both scenarios arise from how acknowledgement workflows are designed, rather than from inherent limitations in the HL7 messaging standard.
HL7 acknowledgement messages provide a mechanism for communicating the outcome of message receipt, acceptance and application processing. Implementing them reliably requires an understanding of message persistence, transport protocols, transaction boundaries, asynchronous processing, retry behaviour and the responsibilities of each system participating in an integration.
For engineers working with NHS Trust integration engines, electronic patient records, clinical applications and distributed healthcare platforms, acknowledgement handling should form part of the underlying integration architecture rather than simply being configured as a response on a TCP listener.
An HL7 ACK is an acknowledgement message returned in response to an HL7 message. The term NACK, sometimes written as NAK, is commonly used to describe a negative acknowledgement. Within standard HL7 v2 messaging, however, a NACK is not generally a separate message type. Positive and negative outcomes are communicated through acknowledgement codes within an acknowledgement or other defined response message.
A typical HL7 v2.5.1 general acknowledgement looks like this:
MSH|^~\&|EPR|HOSPITAL|PAS|HOSPITAL|20261127103001||ACK^A01^ACK|ACK000456|P|2.5.1
MSA|AA|MSG000123
The MSH segment identifies the acknowledgement message, its originating application, its intended recipient and the applicable HL7 version. The MSA segment communicates the outcome of processing the original message.
Two fields are particularly relevant:
The acknowledgement itself has a separate message control identifier in its own MSH-10. Confusing these two identifiers is a relatively common implementation error when constructing custom acknowledgement messages or transforming responses between systems.
HL7 defines six principal acknowledgement codes across its original and enhanced acknowledgement modes.
| Code | Meaning |
|---|---|
| AA | Application Accept |
| AE | Application Error |
| AR | Application Reject |
| CA | Commit Accept |
| CE | Commit Error |
| CR | Commit Reject |
The AA, AE and AR codes are used for application-level acknowledgement outcomes. The CA, CE and CR codes are associated with accept-level acknowledgements in enhanced acknowledgement mode.
An AA indicates successful application processing according to the receiving interface’s defined responsibilities. An AE indicates that application processing encountered an error, whilst an AR indicates rejection. Rejection may occur because the receiving system does not support the specified message type, HL7 version or processing identifier, amongst other reasons.
The precise operational interpretation of these codes must be established in the interface specification. An application error does not automatically mean that retransmission will succeed, just as an application rejection does not necessarily indicate a permanent failure.
Consider an admission message containing a ward identifier that the receiving EPR cannot recognise. The receiver might return an AE because it cannot complete the admission workflow. Repeatedly transmitting the same message will achieve nothing until the ward mapping has been corrected. Conversely, an application error caused by a temporary database outage may be resolved through automated retransmission.
The acknowledgement code describes the outcome at a particular processing stage. The reason for that outcome determines how the sending system should respond.
Using ERR segments to communicate actionable failures
Negative acknowledgements should provide sufficient diagnostic information for the sending application or integration support team to identify the underlying failure.
In HL7 v2.5 and later versions, the ERR segment provides structured fields for communicating error locations, standard HL7 error codes, application-specific error codes, severity and diagnostic information.
For example:
MSH|^~\&|EPR|HOSPITAL|PAS|HOSPITAL|20261127103001||ACK^A01^ACK|ACK000457|P|2.5.1
MSA|AE|MSG000123
ERR||PV1^1^3^1|204^Unknown key identifier^HL70357|E|||Unknown ward identifier
This response indicates that the receiving application encountered an unknown identifier within the assigned patient location field, specifically the first component of PV1-3.
A sending application could use this information to classify the failure as a reference data problem, suspend automatic retries and route the message into an exception management workflow.
The structure of the ERR segment varies between HL7 versions. An interface processing HL7 v2.3 messages cannot assume that error information will appear in the same fields as an HL7 v2.5.1 interface. Integration engines supporting multiple versions should parse and construct error segments using the appropriate version-specific definitions.
Diagnostic information should also be constrained to what is necessary for troubleshooting. Copying entire clinical messages, patient demographics or sensitive clinical observations into acknowledgement error text creates unnecessary information governance and security risks, particularly when responses are subsequently recorded in operational logs.
HL7 v2 supports two acknowledgement models: original mode and enhanced mode. The choice affects when acknowledgements are generated, what they represent and how the sending application manages the lifecycle of an outbound message.
In original acknowledgement mode, the sending application transmits a message and receives a response representing the application-level outcome. Fields MSH-15 and MSH-16 are absent or empty, and the receiving system uses AA, AE or AR to communicate the result.
This approach remains common across NHS integrations, particularly where legacy patient administration systems, departmental applications and integration engines communicate over persistent TCP connections.
The principal architectural limitation is that the receiving application must complete whatever processing is required to generate its acknowledgement within the response window expected by the sender. If processing involves database transactions, external API calls or communication with additional clinical systems, acknowledgement latency can become unpredictable.
Enhanced acknowledgement mode separates message acceptance from application processing. The sending system specifies its acknowledgement requirements through two fields:
| Field | Purpose |
|---|---|
| MSH-15 | Accept acknowledgement type |
| MSH-16 | Application acknowledgement type |
Both fields support the following values:
| Value | Behaviour |
|---|---|
| AL | Always acknowledge |
| NE | Never acknowledge |
| ER | Acknowledge on error or rejection only |
| SU | Acknowledge on success only |
An interface configured with MSH-15 set to AL and MSH-16 set to AL requests acknowledgement at both processing stages.
The receiving system first determines whether it can accept responsibility for the message. If the message is successfully committed to durable storage, it returns a CA acknowledgement. Application processing can then continue independently of the original message exchange.
Once processing has completed, the receiving system initiates a separate exchange containing the application acknowledgement or the response defined for that particular message type. The original sender must therefore have a mechanism for receiving, correlating and processing these subsequent responses.
Consider an integration between a patient administration system and a hospital EPR. An admission message arrives at the receiving interface and is committed to a persistent inbound queue. The integration returns a CA, allowing the patient administration system to remove the message from its transmission queue. Several seconds later, the receiving application completes its processing and generates an AA.
If the admission cannot be processed because of an invalid consultant identifier, an application-level AE can be returned instead. The receiving system retains responsibility for managing the accepted message and its subsequent failure according to the agreed interface contract.
The architectural advantage is that message delivery and application processing no longer need to share the same synchronous execution path.
Enhanced acknowledgement mode is not universally supported, however. Some clinical systems only recognise AA, AE and AR, regardless of their advertised HL7 version. Others populate acknowledgement configuration fields without implementing the corresponding behaviour.
An engineer should establish actual acknowledgement capabilities through interface documentation and integration testing rather than assume that a vendor supports enhanced acknowledgement mode simply because it supports HL7 v2.5.1 or later.
The point at which a positive acknowledgement is generated determines which system owns responsibility for recovering the message following a failure.
An integration engine that returns an acknowledgement immediately after reading an inbound TCP payload, before persisting the message, introduces a potential data loss window. If the engine subsequently crashes, the sender may have already removed the message from its outbound queue, leaving neither system with a recoverable copy.
Acknowledgement generation should therefore be tied to an explicit persistence or application transaction boundary.
For an asynchronous inbound interface using accept acknowledgements, a suitable processing sequence would be:
The positive acknowledgement must not be transmitted until the storage operation has successfully completed. Writing a message to an in-memory queue, an uncommitted database transaction or a non-persistent message broker does not provide an equivalent level of recoverability.
Durability should also be considered in the context of infrastructure failover. A database configured with asynchronous replication may acknowledge a transaction before the corresponding data has reached its standby instance. If failover occurs during that interval, an acknowledged message could still be lost. Storage configuration, replication guarantees and recovery point objectives therefore influence the reliability of the HL7 acknowledgement workflow.
Early and late acknowledgements in integration engines
Integration platforms such as Rhapsody, Mirth Connect and InterSystems IRIS for Health provide different mechanisms for controlling when responses are returned to originating systems.
An acknowledgement may be generated by an inbound connector, after a transformation, following message persistence or after a destination response has been received. Each configuration establishes a different operational boundary.
Consider a pathology integration in which a laboratory information management system sends an ORU^R01 message to an integration engine. The engine transforms the result and distributes it to an EPR, a shared care record and a clinical data warehouse.
If the engine acknowledges receipt immediately after durable persistence, it assumes responsibility for delivering the result to all required destinations. Subsequent failures must be managed through its internal queues, retry mechanisms and operational exception workflows.
Alternatively, the engine could wait until the EPR returns an acknowledgement before responding to the laboratory system. This creates a synchronous dependency between the laboratory and EPR, potentially reducing throughput and exposing the originating system to downstream outages.
Waiting for acknowledgements from every destination introduces further complications. The EPR may accept a result whilst the data warehouse rejects it. Returning a negative acknowledgement to the laboratory could cause the entire result message to be retransmitted, even though one or more destinations have already processed it successfully.
A more manageable architecture maintains independent delivery states for each destination. The EPR delivery can remain complete whilst the data warehouse delivery is retried or investigated. There is no requirement to repeat a successful delivery simply because another destination has failed.
Where original acknowledgement mode is used, an integration engine returning AA after persistence must have an explicitly agreed role as the receiving application. It must not present successful queue insertion as confirmation that an unrelated downstream clinical application has completed processing.
When an engine transforms messages or generates new message control identifiers, it should also maintain a correlation record between the inbound message, each outbound message and the corresponding downstream acknowledgement. Without this relationship, tracing an unsuccessful clinical transaction across multiple systems becomes unnecessarily difficult.
Implementing acknowledgement state management
A single Boolean database field such as acknowledged = true is rarely sufficient for a complex healthcare integration.
Message processing state should distinguish between transmission, acceptance, application processing and failure. A practical implementation might maintain separate fields for the current transport state, acceptance acknowledgement code, application acknowledgement code, transmission attempts, processing attempts and timestamps.
An enhanced-mode sender receiving a CA should record successful acceptance without marking application processing as complete. If an application acknowledgement is required, the message should remain in an application-pending state until the relevant response arrives.
These state transitions should be persisted rather than held exclusively within the integration engine’s runtime memory. Following a restart, the engine must be able to determine which messages require retransmission, which have already been accepted and which are awaiting application-level responses.
Recording individual transmission attempts separately from the logical message also provides a useful audit trail. A message transmitted four times remains one clinical event, not four independent events.
Most traditional HL7 v2 interfaces transmit messages over TCP using the Minimal Lower Layer Protocol (MLLP). MLLP provides message framing by surrounding the HL7 payload with specific control characters.
A standard MLLP frame has the following structure:
0x0B + HL7 message payload + 0x1C + 0x0D
HL7 segments within the payload are themselves terminated by carriage returns. The final carriage return belonging to the HL7 payload should not be confused with the carriage return terminating the MLLP frame.
Both the original message and its HL7 acknowledgement are normally transmitted using this framing mechanism.
TCP provides ordered, reliable byte delivery whilst a connection remains operational. Its transport-level acknowledgements do not indicate that the receiving healthcare application has parsed, persisted or processed an HL7 message.
A successful socket write is similarly insufficient evidence of message acceptance.
Engineers implementing custom MLLP clients and servers must account for TCP stream behaviour. A single socket read may contain a partial HL7 message, multiple complete messages or the end of one message followed by the beginning of another.
The receiver should maintain a buffer and identify complete frames using the configured delimiters. Maximum frame sizes and frame completion timeouts should be enforced to prevent incomplete or malformed transmissions from consuming unbounded resources.
Acknowledgement parsing requires the same treatment. Reading once from a TCP socket immediately after transmitting a message does not guarantee that the complete acknowledgement has been received.
Standard MLLP framing should not be confused with transport variants such as MLLP Release 2, which introduces additional transport acknowledgement behaviour. An ASCII acknowledgement byte is not interchangeable with an HL7 acknowledgement message containing an MSA segment.
Managing ambiguous delivery outcomes
A particularly difficult failure occurs when the receiving application successfully processes a message but its acknowledgement never reaches the sender.
For example, an EPR receives an admission message, commits the admission to its database and generates an AA. The network connection fails before the sending integration engine receives the response.
From the sender’s perspective, the message has timed out. From the receiver’s perspective, processing has completed successfully.
The sender cannot determine from the timeout alone whether the message was never received, was received but not processed, or was processed successfully with a lost acknowledgement.
Increasing the acknowledgement timeout may reduce unnecessary retries caused by slow processing, but it cannot eliminate this ambiguity. The receiving application must be designed to tolerate retransmission.
Implementing idempotent HL7 message processing
Idempotency ensures that repeated processing attempts for the same logical message do not generate unintended duplicate clinical transactions.
The original message control identifier in MSH-10 provides a useful foundation for duplicate detection. Because identifiers may only be unique within the originating application’s namespace, using MSH-10 in isolation can cause unrelated messages to be incorrectly classified as duplicates.
A composite deduplication key might include the following fields:
Inbound interface identifier
MSH-3: Sending application
MSH-4: Sending facility
MSH-10: Message control ID
Including a trusted interface identifier helps distinguish systems that populate identical or inconsistent sending application fields. Hierarchical identifiers should be interpreted according to the agreed interface profile.
The receiving service can store this key alongside the message payload, processing state, payload fingerprint and previously generated acknowledgement.
When a duplicate arrives, the service retrieves the existing processing record. If the message has already completed successfully, the receiver can return an appropriate acknowledgement based on the stored outcome without repeating the clinical transaction.
A relational database implementation might enforce uniqueness using an index such as:
CREATE UNIQUE INDEX ux_hl7_message_identity
ON hl7_inbox (
interface_id,
sending_application,
sending_facility,
message_control_id
);
The uniqueness constraint prevents two concurrent processing threads from independently registering the same message. Application-level checks without a corresponding atomic storage mechanism can introduce race conditions, particularly when multiple integration engine instances are processing messages concurrently.
The stored payload fingerprint provides additional protection. If an incoming message uses an existing control identifier but contains different clinical content, it should be treated as a message identity conflict rather than automatically accepted as a duplicate. Such conflicts may indicate defective identifier generation, inappropriate replay behaviour or incorrect transformation logic.
Where the application updates clinical records within the same database, the clinical transaction and successful message processing state can be committed atomically. If the application crashes after committing the transaction but before transmitting the acknowledgement, the subsequent duplicate can be recognised and acknowledged without repeating the update.
Integrations involving external APIs or separate clinical databases require additional care. An inbound deduplication record alone cannot guarantee that a downstream operation has executed only once. The downstream system must support idempotency, enforce suitable business-level uniqueness constraints or provide a reliable reconciliation mechanism.
Transport-level deduplication also does not replace clinical transaction validation. Two messages with different control identifiers may represent the same underlying admission, prescription or pathology result. Business identifiers and event semantics remain necessary for detecting clinically equivalent transactions.
Configuring retry behaviour and message ordering
Retry policies should differentiate between communication failures, temporary processing errors and errors requiring intervention.
Connection failures and acknowledgement timeouts normally warrant automated retransmission. A negative acknowledgement containing an invalid patient identifier, unsupported message structure or unknown clinical code may require investigation before another delivery attempt.
The acknowledgement code, structured error information, destination system and interface-specific error mappings should collectively determine the retry strategy. Unrecognised errors should follow a controlled exception policy rather than trigger unlimited retransmissions.
A suitable retry policy for a temporary downstream outage might begin with a five-second delay and progressively increase to 30 seconds, two minutes and five minutes. Longer outages can be managed using capped exponential backoff with jitter, reducing the likelihood that multiple interfaces simultaneously overwhelm a recovering application.
These timings are illustrative rather than universal. An urgent clinical result interface may have substantially different delivery and escalation requirements from a nightly administrative data feed.
Message ordering must also be considered when introducing retries. An admission message that fails processing may be followed by a transfer and a discharge for the same patient encounter. If the integration engine processes the subsequent messages whilst the admission remains in a retry queue, the destination system may receive a sequence of events it cannot interpret correctly.
Preserving ordering within an appropriate clinical partition, such as an encounter identifier or patient identifier, can prevent related messages from overtaking one another without unnecessarily blocking unrelated patient transactions.
Where the optional HL7 sequence number protocol is supported, MSH-13 and MSA-4 can assist with detecting sequence discrepancies. This requires compatible implementations at both ends and does not remove the need for application-level ordering and recovery controls.
Retransmissions should generally preserve the original message control identifier and payload. A deliberately corrected message is a different operation and should follow the agreed interface rules for message identity, correction and replacement. Generating a new identifier on every transmission attempt defeats control-ID-based duplicate detection.
Acknowledgement handling should be tested under failure conditions rather than exclusively through successful message exchanges. A conventional integration test that sends an admission message and checks for an AA establishes very little about how the interface will behave following an unexpected restart, database failure or network interruption.
A comprehensive test suite should exercise malformed messages, unsupported HL7 versions, incorrect processing identifiers, invalid clinical reference data, duplicated messages, unexpected acknowledgement codes and incorrectly correlated responses.
Transport testing should deliberately fragment MLLP frames across multiple socket writes, terminate connections midway through a message and introduce delays between receipt and acknowledgement generation.
Fault injection is particularly useful for testing persistence boundaries. Terminating the receiving service immediately before database commit should result in the sender retaining responsibility for retransmission. Terminating the service after commit but before acknowledgement transmission should result in successful duplicate recognition when the sender retries.
Both scenarios need to be tested independently because they exercise different recovery paths.
Enhanced acknowledgement interfaces require additional tests for successful acceptance followed by application rejection, missing application acknowledgements, duplicated application responses and application acknowledgements arriving after a service restart.
Testing should inspect the resulting clinical application state as well as the acknowledgement messages. An interface that returns the correct acknowledgement whilst creating duplicate appointments or recording incomplete pathology results has not passed a meaningful end-to-end integration test.
Monitoring acknowledgement performance in production
Operational monitoring should extend beyond simple counts of positive and negative acknowledgements.
Acknowledgement latency provides a useful indication of interface health, particularly when analysed using percentile distributions rather than averages. A stable average response time can conceal occasional delays severe enough to cause retransmissions.
For example, a synchronous interface with one outstanding message per connection and an average acknowledgement latency of 100 milliseconds can theoretically process approximately ten messages per second, excluding other overheads. If acknowledgement latency increases to 500 milliseconds, throughput falls to approximately two messages per second.
An interface receiving five messages per second under those conditions accumulates a backlog of approximately 180 messages every minute.
Increasing connection concurrency may improve throughput, provided the receiving system can accommodate additional connections and the interface preserves necessary ordering guarantees. Reducing unnecessary synchronous processing is often a more effective solution.
Useful production metrics include:
Metrics should avoid patient identifiers and individual message control identifiers as monitoring labels. Apart from information governance concerns, using unique identifiers as metric dimensions creates excessive cardinality in monitoring platforms.
Individual transaction correlation belongs in appropriately secured structured logs and message audit records.
Diagnosing acknowledgement failures
Troubleshooting should begin by identifying which processing stage has failed.
If the sending system reports acknowledgement timeouts but the receiving integration engine shows no corresponding inbound messages, investigation should concentrate on network connectivity, listener availability, TLS configuration and MLLP framing.
If inbound messages are visible but acknowledgements are absent, the likely investigation moves towards parser failures, validation scripts, persistence operations, connector response configuration and blocked processing threads.
Where the receiver records successful acknowledgement transmission but the sender continues retrying, engineers should examine the acknowledgement payload itself. Incorrect MSA-2 values, incompatible HL7 versions, unexpected acknowledgement codes, incorrect segment terminators and malformed MLLP framing can all cause a sender to disregard an otherwise positive response.
A late acknowledgement can also arrive after the sender has abandoned the original transmission attempt. Persistent connections reused following timeouts require particular care. The sender must not mistake a delayed acknowledgement for the response to a subsequently transmitted message. Correlating responses through MSA-2, and resetting connections where required by the interface protocol, helps prevent this behaviour.
A rise in negative acknowledgements containing unknown key identifier errors following an EPR deployment may indicate that reference data mappings have changed. Increased acknowledgement latency following a database maintenance window may indicate storage contention or connection pool exhaustion. A sudden increase in duplicate detections without a corresponding increase in negative acknowledgements may indicate unstable connectivity or a mismatch between receiver processing times and sender timeout settings.
These patterns are considerably easier to identify when acknowledgement generation, transmission and receipt are recorded as separate events.
For multi-destination healthcare integrations, reconciliation should extend beyond the integration engine’s own message status. Source and destination systems should be compared using message correlation records, encounter identifiers, order identifiers or other suitable business keys. A successful interface delivery count cannot, on its own, establish that all expected clinical records have been created correctly.
The interface specification should ultimately define the acknowledgement boundary, supported codes, validation responsibilities, timeout settings, retry classifications, duplicate handling, ordering guarantees, persistence requirements and escalation procedures. These requirements should be treated as testable engineering contracts between participating systems.
A reliable HL7 acknowledgement workflow allows an engineer to establish where a message is stored, which system currently owns its recovery, whether the intended clinical transaction has completed and what will happen if the same message is received again. Those properties are far more valuable than an integration dashboard displaying an uninterrupted stream of positive acknowledgements.
Is your team looking for help with HL7 v2 messaging implementation? Click the button below.
Get in touch