Skip to main content
Version: v0.0.2

Function: build820()

build820(spec): X12Interchange

build820 - assemble a 005010X218 820 around the supplied spec.

Refused via "./build-errors.js".Premium820BuildError with code X12_820_BUILD_INVALID_SPEC:

  • no TRN trace, or no remittance loop;
  • a remittance with neither an entity nor an individual (nothing opens its loop), or with no openItems;
  • an open item with empty qualifier AND empty referenceId (the read side drops it);
  • an over-long (> 9 char) interchange control number.

Parameters

spec

Build820Spec

Returns

X12Interchange

Example

import { build820, X12Decimal } from "@cosyte/x12";
const ix = build820({
envelope: {
senderId: "EMPLOYERCO", receiverId: "MEDPAY",
interchangeDate: "260601", interchangeTime: "1200",
interchangeControlNumber: "000000001",
groupControlNumber: "1", transactionSetControlNumber: "0001",
},
payment: {
transactionHandlingCode: "I",
totalPremiumAmount: X12Decimal.fromString("250.00")!,
creditDebitFlag: "C", method: "ACH", paymentDate: "20260601",
},
traces: [{ traceTypeCode: "1", referenceId: "PREM-202606" }],
remittances: [{
individual: { entityIdentifierCode: "IL", lastName: "DOE", idQualifier: "34", idCode: "MBR0001" },
openItems: [{ qualifier: "AZ", referenceId: "POL-0001", amountPaid: X12Decimal.fromString("250.00")! }],
}],
});