Skip to main content
Version: v0.0.2

Function: build835()

build835(spec): X12Interchange

build835 - assemble a 005010X221A1 835 around the supplied spec.

Refused via "./build-errors.js".Remit835BuildError:

  • No trace supplied, or a claim with no patient-control number, etc. → X12_835_BUILD_INVALID_SPEC.
  • Any §1.10.2 balance invariant violated (service-line SVC-02 == SVC-03 + Σ(line CAS), claim CLP-03 == CLP-04 + Σ(claim+line CAS), or top-of-remit BPR-02 == Σ(CLP-04) − Σ(PLB)) → X12_835_BUILD_BALANCE_MISMATCH.

Parameters

spec

Build835Spec

Returns

X12Interchange

Example

import { build835, X12Decimal } from "@cosyte/x12";
const ix = build835({
envelope: {
senderId: "MEDICARE", receiverId: "SUBMITTER",
interchangeDate: "260601", interchangeTime: "1200",
interchangeControlNumber: "000000001",
groupControlNumber: "1", transactionSetControlNumber: "0001",
},
payment: {
transactionHandlingCode: "I",
totalActualPayment: X12Decimal.fromString("450.00")!,
creditDebitFlag: "C", method: "ACH", paymentDate: "20260601",
},
traces: [{ traceTypeCode: "1", referenceId: "0012345", originatingCompanyId: "1512345678" }],
claims: [
{
patientControlNumber: "PT-ACCT-001", claimStatusCode: "1",
totalChargeAmount: X12Decimal.fromString("500.00")!,
totalPaymentAmount: X12Decimal.fromString("450.00")!,
patientResponsibilityAmount: X12Decimal.fromString("50.00")!,
adjustments: [{ groupCode: "PR", reasonCode: "1", amount: X12Decimal.fromString("50.00")! }],
},
],
});