Skip to main content
Version: v0.0.3

Function: batchCountMismatch()

batchCountMismatch(position, unit, declared, actual): Hl7ParseWarning

Build a BATCH_COUNT_MISMATCH warning. Emitted by splitBatch(): attached to the returned BatchSplitResult.warnings, never to Hl7Message.warnings: when a declared envelope count does not equal the count actually split out: a BTS-1 batch message count that differs from the messages found in that batch, or an FTS-1 file batch count that differs from the batches found in the file (HL7 v2 Ch. 2 §2.10.3; BTS-1 / FTS-1 per the BTS / FTS segment definitions in §2.15). The splitter never drops the tail to make the numbers agree: the mismatch is surfaced and every message is still returned; the caller decides whether to reject.

The message carries only the declared-vs-actual integers and the unit (message for BTS-1, batch for FTS-1): NEVER a field value, facility identifier, or any other content, so no PHI is exposed. position references the trailer segment (BTS/FTS) that declared the count.

Parameters

position

Hl7Position

unit

"message" | "batch"

declared

number

actual

number

Returns

Hl7ParseWarning

Example

import { batchCountMismatch } from "@cosyte/hl7";
const w = batchCountMismatch({ segmentIndex: 4 }, "message", 3, 2);