Skip to main content
Version: v0.0.4

Class: AstmAmbiguousStreamError

Thrown by a flat extractor when the stream it was handed does not determine a single answer - either because it carries several messages, or because its one message carries several patients.

The throw is the fix. A caller who gets this error is strictly better off than one who silently received another patient's results, and the remedy is mechanical: walk messages and read each message's own records.

PHI: carries a stable code, a position, and two counts. Never a field value, never a patient identifier.

Example

import { parseAstmRecords, messages, results, AstmAmbiguousStreamError } from "@cosyte/astm";
const msg = parseAstmRecords(raw);
try {
results(msg);
} catch (err) {
if (err instanceof AstmAmbiguousStreamError) {
for (const m of messages(msg)) m.results.length;
}
}

Extends

  • Error

Constructors

Constructor

new AstmAmbiguousStreamError(code, message, position, counts): AstmAmbiguousStreamError

Internal

Parameters

code

AmbiguousCode

message

string

position

AstmPosition

counts
messageCount

number

patientCount

number

Returns

AstmAmbiguousStreamError

Overrides

Error.constructor

Properties

code

readonly code: AmbiguousCode

The stable discriminant - see AMBIGUOUS_CODES.


messageCount

readonly messageCount: number

How many HL messages the stream carries.


patientCount

readonly patientCount: number

How many P records the message in question carries.


position

readonly position: AstmPosition

Where the ambiguity became visible: the second header, or the second P. Value-free.