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
message
string
position
counts
messageCount
number
patientCount
number
Returns
AstmAmbiguousStreamError
Overrides
Error.constructor
Properties
code
readonlycode:AmbiguousCode
The stable discriminant - see AMBIGUOUS_CODES.
messageCount
readonlymessageCount:number
How many H … L messages the stream carries.
patientCount
readonlypatientCount:number
How many P records the message in question carries.
position
readonlyposition:AstmPosition
Where the ambiguity became visible: the second header, or the second P. Value-free.