Skip to main content
Version: v0.0.4

Type Alias: BatchMessageEntry

BatchMessageEntry = { message: Hl7Message; ok: true; position: Hl7Position; raw: string; } | { error: Hl7ParseError; ok: false; position: Hl7Position; raw: string; }

One message extracted from a batch stream. Discriminated on ok: a successful parse carries the Hl7Message (whose own .warnings hold any per-message Tier-2 deviations); a message that hit one of the four Tier-3 fatal conditions carries the Hl7ParseError instead: isolated, so the rest of the batch still yields. raw is the message's verbatim source (re-parseable by parseHL7); position is the message's MSH (or, for pre-MSH stray content, its first) segment index in the stream.

Example

import { splitBatch } from "@cosyte/hl7";
for (const entry of splitBatch(raw).messages) {
if (entry.ok) handle(entry.message);
else quarantine(entry.raw, entry.error.code);
}