Skip to main content
Version: v0.0.2

Function: get837Claims()

get837Claims(delimiters, tx, opts?): X12_837Submission | undefined

Extract a typed X12_837Submission from an 837 transaction set. Pure function - no I/O, no global state. Returns undefined when the input transaction's ST-01 is not "837" (mis-routed call); every other deviation is recoverable and surfaces on submission.warnings.

Parameters

delimiters

Delimiters

tx

X12TransactionSet

opts?

type?

"P" | "I" | "D"

Returns

X12_837Submission | undefined

Example

import { parseX12, get837Claims } from "@cosyte/x12";
const ix = parseX12(raw);
for (const group of ix.groups) {
for (const tx of group.transactions) {
if (tx.st.elements[1] !== "837") continue;
const sub = get837Claims(ix.delimiters, tx);
sub?.variant; // "P" / "I" / "D" / "unknown"
for (const claim of sub?.claims ?? []) {
claim.totalCharge.toString();
claim.diagnoses[0]?.codeSystem; // "ICD-10-CM"
}
}
}