Skip to main content
Version: v0.0.3

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:

  1. No readable MSH. readMshSegment returns null, e.g. a BOM/SP/TAB before MSH (which shares the MSH's segment line, so MSH heads no segment), or a bare fragment delivered after a mid-payload VT discard (MLLP_TRAILING_BYTES). MSA-2 would be empty: an ACK that correlates to nothing.
  2. Empty MSH-10. The MSH is readable but carries no message control ID, so there is nothing to echo, again MSA|AA| with an empty MSA-2.
  3. A batch or concatenated messages. An FHS/BHS/BTS/FTS envelope (§2.10.3) or a second MSH in 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