Skip to main content
Version: v0.0.2

Interface: Build820Spec

The full input to "./build-820.js".build820: the envelope, the payment header, ≥ 1 trace, optional receiver / remitter parties, and ≥ 1 remittance loop. A well-formed spec round-trips through get820Payments field-for-field; a structurally impossible one is REFUSED with a "./build-errors.js".Premium820BuildError.

Example

import { build820, X12Decimal, type Build820Spec } from "@cosyte/x12";
const spec: Build820Spec = {
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" }],
remitter: { entityIdentifierCode: "PR", name: "EMPLOYER CO" },
receiver: { entityIdentifierCode: "PE", name: "MEDPAY INSURANCE" },
remittances: [
{
individual: { entityIdentifierCode: "IL", lastName: "DOE", idQualifier: "34", idCode: "MBR0001" },
openItems: [{ qualifier: "AZ", referenceId: "POL-0001", amountPaid: X12Decimal.fromString("250.00")! }],
},
],
};
const ix = build820(spec);

Properties

envelope

readonly envelope: Build820EnvelopeSpec

Interchange / group / transaction identity.


payment

readonly payment: Build820PaymentSpec

BPR payment header.


receiver?

readonly optional receiver?: Build820PartySpec

Loop 1000A premium receiver (N1*PE).


remittances

readonly remittances: readonly Build820RemittanceSpec[]

Loop 2000 remittance detail (≥ 1 required).


remitter?

readonly optional remitter?: Build820PartySpec

Loop 1000B premium payer / remitter (N1PR / N1RM).


traces

readonly traces: readonly Build820TraceSpec[]

TRN traces (≥ 1 required).