Skip to main content
Version: v0.0.2

Function: remitBalanceMismatch()

remitBalanceMismatch(position, invariant, spec, computed, delta): X12ParseWarning

Build an X12_835_REMIT_BALANCE_MISMATCH warning. Emitted by the 835 helper when a balance invariant fails - typically CLP-04 + CLP-05 + Σ(claim-level CAS amounts) !== CLP-03, or Σ(SVC paid) + Σ(line CAS) !== CLP-04, or Σ(claim CLP-04) + Σ(PLB adjustments) !== BPR-02.

The message carries the invariant label, the spec'd value, the computed value, and the side-by-side diff - all numeric strings (the outputs of "../decimal.js".X12Decimal toString()). It NEVER echoes patient identifiers, member ids, names, account numbers, or any other PHI-shaped value - mirrors the H-PHI invariant from @cosyte/hl7. The parser ALWAYS surfaces this and NEVER silently rebalances.

Parameters

position

X12Position

invariant

string

spec

string

computed

string

delta

string

Returns

X12ParseWarning

Example

import { remitBalanceMismatch } from "@cosyte/x12";
const w = remitBalanceMismatch(
{ segmentIndex: 12, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
"CLP-04 + CLP-05 + ΣCAS == CLP-03",
"500.00",
"499.99",
"0.01",
);