Function: rawAckUncorrelatable()
rawAckUncorrelatable(
payload):boolean
True iff a positive raw acknowledgement (AA/CA) cannot be safely correlated to
this payload, so buildRawAck (and the server's auto-ACK path) must downgrade
it to a non-positive AE/CE rather than tell the sender "I have it."
The rule this enforces: never answer AA for a message you could not correlate. A
positive ACK is a promise the sender may forget the message; if it names a control ID
the sender cannot match, or names one of several messages it never read, the sender
times out and resends, committing a duplicate clinical message (or worse, believes a
destroyed message was delivered). Three payload-shaped reasons make a positive ACK
uncorrelatable, all peer-reachable off the wire:
- No readable
MSH.readMshSegmentreturnsnull, e.g. aBOM/SP/TABbeforeMSH(which shares theMSH's segment line, soMSHheads no segment), or a bare fragment delivered after a mid-payloadVTdiscard (MLLP_TRAILING_BYTES). MSA-2 would be empty: an ACK that correlates to nothing. - Empty MSH-10. The
MSHis readable but carries no message control ID, so there is nothing to echo, againMSA|AA|with an empty MSA-2. - A batch or concatenated messages. An
FHS/BHS/BTS/FTSenvelope (§2.10.3) or a secondMSHin the same frame: a single MSA-2 can echo only ONE control ID, so a positive ACK naming the first silently drops the rest (see containsBatchOrExtraMessage). Batch ACK is its own feature; until it is designed, a batch must stay a loud non-positive answer.
This is a refusal, not a tolerance widening: it never makes an unreadable message
readable, never re-bases on a located MSH, never parses a batch. It only recognizes
the shapes for which a positive disposition would be a lie, so the builder can fall back
to AE. A negative requested code (AE/AR/CE/CR) is unaffected, it is
already non-positive, and echoing whatever control ID it can find is still useful.
Pure, byte-level, never throws.
Parameters
payload
Buffer
Returns
boolean
Example
import { rawAckUncorrelatable } from '@cosyte/mllp';
rawAckUncorrelatable(oneGoodMessage); // false → AA is safe
rawAckUncorrelatable(twoConcatenatedMsh); // true → downgrade AA to AE