@cosyte/x12 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +238 -0
- package/KNOWN-LIMITATIONS.md +183 -27
- package/README.md +2 -2
- package/dist/index.cjs +179 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +326 -43
- package/dist/index.d.ts +326 -43
- package/dist/index.mjs +176 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -143,7 +143,11 @@ var WARNING_CODES = {
|
|
|
143
143
|
X12_837_SERVICE_LINE_NOT_DECODED: "X12_837_SERVICE_LINE_NOT_DECODED",
|
|
144
144
|
X12_837_SERVICE_LINE_DROPPED: "X12_837_SERVICE_LINE_DROPPED",
|
|
145
145
|
X12_837_SERVICE_SEGMENT_WITHOUT_LX: "X12_837_SERVICE_SEGMENT_WITHOUT_LX",
|
|
146
|
-
X12_837_ENTITY_SEGMENT_DISCARDED_AFTER_LX: "X12_837_ENTITY_SEGMENT_DISCARDED_AFTER_LX"
|
|
146
|
+
X12_837_ENTITY_SEGMENT_DISCARDED_AFTER_LX: "X12_837_ENTITY_SEGMENT_DISCARDED_AFTER_LX",
|
|
147
|
+
X12_837_PAY_TO_ADDRESS_REPEATED: "X12_837_PAY_TO_ADDRESS_REPEATED",
|
|
148
|
+
X12_835_BALANCE_NOT_EVALUABLE: "X12_835_BALANCE_NOT_EVALUABLE",
|
|
149
|
+
X12_AMOUNT_ROW_DROPPED: "X12_AMOUNT_ROW_DROPPED",
|
|
150
|
+
X12_STATED_AMOUNT_DISCARDED: "X12_STATED_AMOUNT_DISCARDED"
|
|
147
151
|
};
|
|
148
152
|
var CONTROL_NUMBER_PAIRS = {
|
|
149
153
|
/** ISA-13 against IEA-02. */
|
|
@@ -204,6 +208,9 @@ var WARNING_MESSAGES = {
|
|
|
204
208
|
X12_835_REMIT_BALANCE_MISMATCH_CLAIM: "835 balance invariant violated [CLP-04 + \u03A3(claim CAS + line CAS) == CLP-03]: the claim does not balance. Every amount is preserved verbatim on the model as an X12Decimal and is NEVER silently rebalanced.",
|
|
205
209
|
X12_835_REMIT_BALANCE_MISMATCH_SERVICE_LINE: "835 balance invariant violated [SVC-03 + \u03A3(line CAS) == SVC-02]: the service line does not balance. Every amount is preserved verbatim on the model as an X12Decimal and is NEVER silently rebalanced.",
|
|
206
210
|
X12_835_REMIT_BALANCE_MISMATCH_REMIT_TOTAL: "835 balance invariant violated [\u03A3(CLP-04) - \u03A3(PLB amounts) == BPR-02]: the remittance total does not balance. Every amount is preserved verbatim on the model as an X12Decimal and is NEVER silently rebalanced.",
|
|
211
|
+
X12_835_BALANCE_NOT_EVALUABLE_CLAIM: "835 balance invariant [CLP-04 + \u03A3(claim CAS + line CAS) == CLP-03] could not be evaluated: at least one term of it is `undefined` on the model, meaning this library decoded no value from that element. The equation is NOT reported as violated and NOT reported as satisfied, because an absent term has no value to compare - substituting 0 for it would be this library asserting a total the sender never sent. Which term is missing is read off the model, never from this message. Compare `X12_835_REMIT_BALANCE_MISMATCH`, which is raised only where every term decoded and the equation is genuinely out of balance.",
|
|
212
|
+
X12_835_BALANCE_NOT_EVALUABLE_SERVICE_LINE: "835 balance invariant [SVC-03 + \u03A3(line CAS) == SVC-02] could not be evaluated: at least one term of it is `undefined` on the model, meaning this library decoded no value from that element. The equation is NOT reported as violated and NOT reported as satisfied, because an absent term has no value to compare - substituting 0 for it would be this library asserting a total the sender never sent. Which term is missing is read off the model, never from this message. Compare `X12_835_REMIT_BALANCE_MISMATCH`, which is raised only where every term decoded and the equation is genuinely out of balance.",
|
|
213
|
+
X12_835_BALANCE_NOT_EVALUABLE_REMIT_TOTAL: "835 balance invariant [\u03A3(CLP-04) - \u03A3(PLB amounts) == BPR-02] could not be evaluated: at least one term of it is `undefined` on the model, meaning this library decoded no value from that element. The equation is NOT reported as violated and NOT reported as satisfied, because an absent term has no value to compare - substituting 0 for it would be this library asserting a total the sender never sent. Which term is missing is read off the model, never from this message. Compare `X12_835_REMIT_BALANCE_MISMATCH`, which is raised only where every term decoded and the equation is genuinely out of balance.",
|
|
207
214
|
X12_UNKNOWN_CARC: "Unknown CARC: the claim adjustment reason code is outside the bundled snapshot. The verbatim code is preserved on the adjustment; only its description is unavailable.",
|
|
208
215
|
X12_UNKNOWN_RARC: "Unknown RARC: the remittance advice remark code is outside the bundled snapshot. The verbatim code is preserved on the remark; only its description is unavailable.",
|
|
209
216
|
X12_HL_PARENT_MISMATCH: "HL-02 declares a parent id that no earlier HL in this transaction set emitted as its HL-01. The declared pointer is preserved verbatim and the hierarchy is NEVER silently re-numbered.",
|
|
@@ -218,10 +225,13 @@ var WARNING_MESSAGES = {
|
|
|
218
225
|
X12_UNKNOWN_CLAIM_STATUS: "Unknown claim status code (CSC): the STC composite's second component is outside the bundled snapshot. The verbatim code is preserved on the status; only its description is unavailable.",
|
|
219
226
|
X12_834_UNKNOWN_MAINTENANCE_TYPE: "Unknown 834 maintenance type: the INS-03/HD-01 code is outside the bundled snapshot. The verbatim code is preserved on the enrollment and the action is NEVER inferred.",
|
|
220
227
|
X12_UNPARSEABLE_DECIMAL: "Unparseable decimal: the element at `position.elementIndex` held bytes this library could not decode as a decimal, so NO value was decoded from it. Whatever occupies that slot on the model, including 0 and undefined, is a stand-in and is NOT a value the sender supplied. The verbatim bytes are preserved on the segment; read them there before acting on the amount, quantity or percent.",
|
|
221
|
-
X12_837_SERVICE_LINE_NOT_DECODED: "837 service line with no decoded service segment: the Loop 2400 line opened at `position.segmentIndex` is followed by no SV1 / SV2 / SV3 matching the variant this submission resolved to, so NOTHING carried by the service segment was read. The line's `charge` and `units`
|
|
228
|
+
X12_837_SERVICE_LINE_NOT_DECODED: "837 service line with no decoded service segment: the Loop 2400 line opened at `position.segmentIndex` is followed by no SV1 / SV2 / SV3 matching the variant this submission resolved to, so NOTHING carried by the service segment was read. The line's `charge` and `units` are `undefined`, which is what this library puts on a decimal slot it decoded no value into; its procedure code, modifiers, unit of measure and place of service are equally undecoded. Two common causes: the line carries no SVx at all, or it carries one for a different 837 variant than ST-03 (or the caller's `type` option) named. Which side is wrong is NOT decided here, because a caller-supplied `type` can disagree with a perfectly conformant document. The verbatim segments are preserved on the transaction set; read them there before acting on the charge or the quantity.",
|
|
222
229
|
X12_837_SERVICE_LINE_DROPPED: "837 service line dropped from the typed model: the LX at `position.segmentIndex` opened no Loop 2400, so no line appears on any claim's `serviceLines` for it and the SV1 / SV2 / SV3 that followed - its charge, units, procedure code and modifiers - was read into nothing. Compare `X12_837_SERVICE_LINE_NOT_DECODED`, where the line IS on the model and only its service segment went unread. Two causes: no Loop 2300 (CLM) is open at this LX, so there is no claim to attach a line to; or the submission's variant is not one of P / I / D, so no variant-specific line shape could be built. Read `submission.variant` and `submission.claims` to tell them apart; do NOT expect `X12_837_UNKNOWN_VARIANT` alongside this code, because a caller-supplied `type` outside P / I / D reaches the second cause without it. Nothing is fabricated to stand in for the missing line and no claim is synthesized. What becomes of a DTP / AMT / NTE / REF that follows the dropped LX depends on the route and this message does not say; see KNOWN-LIMITATIONS.md. The verbatim segments are preserved on the transaction set; read them there before concluding the claim had no service lines.",
|
|
223
230
|
X12_837_SERVICE_SEGMENT_WITHOUT_LX: "837 service segment with no Loop 2400 to read it into: no service line was open at the SV1 / SV2 / SV3 at `position.segmentIndex`, so NOTHING it carries - its charge, units, procedure code, modifiers, unit of measure and place of service - was read. Read that literally: an LX may well appear earlier in the transaction, and what this reports is that none of them had opened a Loop 2400 still current at this segment. No line appears on any claim's `serviceLines` for it and nothing is fabricated to stand in. Compare the two codes anchored at an LX: `X12_837_SERVICE_LINE_DROPPED`, where an LX IS present and opened no line, and `X12_837_SERVICE_LINE_NOT_DECODED`, where the line is on the model and only its service segment went unread. Neither of those can report the SAME service segment as this code, because both are raised at an LX and this one only where no Loop 2400 is open; a document with several claims can still carry all three. This says NOTHING about how the submission's variant resolved: absent a caller-supplied `type` option, and where ST-03 names no known implementation convention, the reader falls back to the first SV1 / SV2 / SV3 in the transaction, and a segment reported here is eligible for that fallback like any other, so a stray one can decide the variant every line is read against. Read `submission.variant`. The verbatim segments are preserved on the transaction set; read them there before concluding the claim had no service lines.",
|
|
224
|
-
X12_837_ENTITY_SEGMENT_DISCARDED_AFTER_LX: "837 entity segment read into nothing after a dropped LX: the N3 / N4 / PER / REF at `position.segmentIndex` arrived while no entity loop was open, because an earlier LX in this transaction opened no Loop 2400 (no CLM was open at it) and closed the entity loop that was current there. NOTHING this segment carries reached the model: no party's `address`, `contacts` or `references` was written from it, and no party, claim or line was synthesized to hold it. This is the code that names THAT loss; `X12_837_SERVICE_LINE_DROPPED` is raised at the LX itself and names the SERVICE LINE's loss, never an entity segment, so the two report different things about the same stretch of the document. Read the bound literally, because this code does NOT report every unattached entity segment: it reports one discarded after such an LX and only while nothing since has opened a new loop, so an N3 / N4 / PER / REF that reaches no party by any other route is still silent, and one arriving after a later NM1 is outside this code's scope, whether or not this reader surfaces that segment kind on that party. It reports that the segment reached NO party; it does not claim it would have reached one had the LX been absent, because this reader does not surface every one of these segment kinds on every party (a PER on a patient or a pay-to address, for one). Which party a segment following a stray LX belongs to is not derivable from the TR3s in either direction, so it is discarded rather than attributed: see KNOWN-LIMITATIONS.md. The verbatim segments are preserved on the transaction set; read them there before concluding a party had no address, no secondary identifier or no contact."
|
|
231
|
+
X12_837_ENTITY_SEGMENT_DISCARDED_AFTER_LX: "837 entity segment read into nothing after a dropped LX: the N3 / N4 / PER / REF at `position.segmentIndex` arrived while no entity loop was open, because an earlier LX in this transaction opened no Loop 2400 (no CLM was open at it) and closed the entity loop that was current there. NOTHING this segment carries reached the model: no party's `address`, `contacts` or `references` was written from it, and no party, claim or line was synthesized to hold it. This is the code that names THAT loss; `X12_837_SERVICE_LINE_DROPPED` is raised at the LX itself and names the SERVICE LINE's loss, never an entity segment, so the two report different things about the same stretch of the document. Read the bound literally, because this code does NOT report every unattached entity segment: it reports one discarded after such an LX and only while nothing since has opened a new loop, so an N3 / N4 / PER / REF that reaches no party by any other route is still silent, and one arriving after a later NM1 is outside this code's scope, whether or not this reader surfaces that segment kind on that party. It reports that the segment reached NO party; it does not claim it would have reached one had the LX been absent, because this reader does not surface every one of these segment kinds on every party (a PER on a patient or a pay-to address, for one). Which party a segment following a stray LX belongs to is not derivable from the TR3s in either direction, so it is discarded rather than attributed: see KNOWN-LIMITATIONS.md. The verbatim segments are preserved on the transaction set; read them there before concluding a party had no address, no secondary identifier or no contact.",
|
|
232
|
+
X12_837_PAY_TO_ADDRESS_REPEATED: "837 pay-to address named more than once in one Loop 2000A: the NM1*87 at `position.segmentIndex` is not the first in this Loop 2000A, and the TR3s allow Loop 2010AB at most once there. The model has ONE pay-to address slot, so it cannot carry both, and this code is the only thing that tells you the document named more than one. The reader NEVER merges them: an N3 or N4 after this segment can no longer add a street line to, or fill a blank in, the address an earlier NM1*87 named, which is what this library did through 0.0.12 - it returned a fused address no sender sent, silently. What the slot carries instead is the LAST occurrence that stated an address of its own; an occurrence that states none - one carrying no N3 or N4 at all, or only a valueless N3 or N4 whose elements are empty - does NOT replace one that did, so nothing an earlier occurrence stated is blanked either. Where no occurrence states an address, the slot holds what the FIRST N3 or N4 to arrive under any of them produced, which may be an address with no elements at all, and which is not necessarily the first occurrence's: an occurrence that carries no N3 or N4 writes nothing, so a later one's valueless N3 is the first write and takes a slot still empty. Read that as the corner it is, and never restate it as the first OCCURRENCE winning. Which occurrence the sender meant is NOT decided here and is not derivable from the TR3s, and the losing occurrence's address is NOT on the model in any form. Read the bound literally: this reports repetition within one Loop 2000A, which is where the pay-to route lives, and an NM1*87 arriving while a CLM is open never reaches that route. The verbatim segments are preserved on the transaction set; read them there before acting on where a payment is to be sent.",
|
|
233
|
+
X12_AMOUNT_ROW_DROPPED: "Amount row dropped from the typed model: the AMT or ADX at `position.segmentIndex` carried no decodable amount (AMT-02, ADX-01), so NO row was built for it and the rest of the segment went with it - its qualifier or adjustment reason code, and any reference qualifier and id. Nothing is fabricated to stand in: a row is not built around a zero this library did not read, which is why the loss is reported rather than papered over. Two routes reach it and this code does not say which: the amount element was ABSENT, or it was present and held bytes that do not decode as a decimal. On this segment only the second route also raises `X12_UNPARSEABLE_DECIMAL`, carrying the failing element in its own `position.elementIndex`, so whether one is present at this `position.segmentIndex` is what separates them - and that code is unchanged by this one, which is raised alongside it rather than in place of it. Read the bound literally: this reports a row whose AMOUNT was read and decoded no value, and it is NOT a general report that an amount segment reached no model. A segment a reader discards before reading its amount is not on this channel, and neither is one whose amount decoded and then found no claim, service line, coverage or remittance open to attach the row to. An 820 RMR is not on it either, for its own reason: that row is dropped on open-item IDENTITY, RMR-01 and RMR-02 both empty, before the amount is read at all, so an RMR that states an open item and no amount keeps its row with amountPaid undefined while one that states an amount and no open item is dropped whole. That second case is a separate loss, and so is an 837 AMT that decoded while a Loop 2430 adjudication was open; `X12_STATED_AMOUNT_DISCARDED` reports both, and this code reports neither. The two can never name the same segment, because this one requires an amount element that decoded no value and that one requires the opposite. The verbatim segments are preserved on the transaction set; read them there before concluding the document stated no such amount.",
|
|
234
|
+
X12_STATED_AMOUNT_DISCARDED: "Stated amount discarded: the RMR or AMT at `position.segmentIndex` populated its amount element and this reader built NO row for it, for a reason that is not a failure to decode that amount. What the sender wrote reaches no part of the typed model, so an empty list of open items or amounts is not evidence the sender stated none. Read that as the only claim made here: this code does NOT assert the amount is decodable, and on the RMR route below it is raised without the bytes ever being DECODED, so they may be unreadable, blank-but-present, or a lone component separator. Two routes reach it and this code does not say which. First, an 820 RMR whose RMR-01 and RMR-02 are BOTH empty while a remittance loop is open: the open item is refused on identity before RMR-04 or RMR-05 is read at all, so a stated payment amount, a stated amount due and the payment action code beside them go together. Second, an 837 AMT arriving while a Loop 2430 line adjudication is open: AMT-02 decoded, and the v1 adjudication model carries no amount row to put it on, so the row is skipped. Compare `X12_AMOUNT_ROW_DROPPED`, which reports the other situation on the same segments: there the amount element decoded no value, so there was no row to build at all. The two can never name the same segment. Read the bound literally, as a property of the READ: this reports a segment whose amount element the sender populated, arriving while the loop that would carry its row was open. It does NOT report an AMT or ADX that reaches a reader with no such loop open, which stays silent and is recorded in KNOWN-LIMITATIONS.md. And on the RMR route it says nothing about whether that amount WOULD have decoded, because the row is refused before the decode is attempted, so no `X12_UNPARSEABLE_DECIMAL` accompanies it even where the bytes are unreadable. Nothing is fabricated to stand in. The verbatim segments are preserved on the transaction set; read them there before concluding the document stated no such amount."
|
|
225
235
|
};
|
|
226
236
|
var ALL_WARNING_MESSAGES = new Set(
|
|
227
237
|
Object.values(WARNING_MESSAGES)
|
|
@@ -243,6 +253,11 @@ var BALANCE_INVARIANT_MESSAGES = {
|
|
|
243
253
|
[BALANCE_INVARIANTS.SERVICE_LINE]: WARNING_MESSAGES.X12_835_REMIT_BALANCE_MISMATCH_SERVICE_LINE,
|
|
244
254
|
[BALANCE_INVARIANTS.REMIT_TOTAL]: WARNING_MESSAGES.X12_835_REMIT_BALANCE_MISMATCH_REMIT_TOTAL
|
|
245
255
|
};
|
|
256
|
+
var BALANCE_NOT_EVALUABLE_MESSAGES = {
|
|
257
|
+
[BALANCE_INVARIANTS.CLAIM]: WARNING_MESSAGES.X12_835_BALANCE_NOT_EVALUABLE_CLAIM,
|
|
258
|
+
[BALANCE_INVARIANTS.SERVICE_LINE]: WARNING_MESSAGES.X12_835_BALANCE_NOT_EVALUABLE_SERVICE_LINE,
|
|
259
|
+
[BALANCE_INVARIANTS.REMIT_TOTAL]: WARNING_MESSAGES.X12_835_BALANCE_NOT_EVALUABLE_REMIT_TOTAL
|
|
260
|
+
};
|
|
246
261
|
var REQUIRED_LOOP_MESSAGES = {
|
|
247
262
|
[REQUIRED_LOOPS.BILLING_PROVIDER_2000A]: WARNING_MESSAGES.X12_MISSING_REQUIRED_LOOP_2000A,
|
|
248
263
|
[REQUIRED_LOOPS.SUBSCRIBER_2000B]: WARNING_MESSAGES.X12_MISSING_REQUIRED_LOOP_2000B,
|
|
@@ -333,6 +348,13 @@ function remitBalanceMismatch(position, invariant) {
|
|
|
333
348
|
position
|
|
334
349
|
};
|
|
335
350
|
}
|
|
351
|
+
function balanceNotEvaluable(position, invariant) {
|
|
352
|
+
return {
|
|
353
|
+
code: WARNING_CODES.X12_835_BALANCE_NOT_EVALUABLE,
|
|
354
|
+
message: BALANCE_NOT_EVALUABLE_MESSAGES[invariant],
|
|
355
|
+
position
|
|
356
|
+
};
|
|
357
|
+
}
|
|
336
358
|
function unknownCarc(position) {
|
|
337
359
|
return {
|
|
338
360
|
code: WARNING_CODES.X12_UNKNOWN_CARC,
|
|
@@ -410,6 +432,13 @@ function entitySegmentDiscardedAfterLx(position) {
|
|
|
410
432
|
position
|
|
411
433
|
};
|
|
412
434
|
}
|
|
435
|
+
function payToAddressRepeated(position) {
|
|
436
|
+
return {
|
|
437
|
+
code: WARNING_CODES.X12_837_PAY_TO_ADDRESS_REPEATED,
|
|
438
|
+
message: WARNING_MESSAGES.X12_837_PAY_TO_ADDRESS_REPEATED,
|
|
439
|
+
position
|
|
440
|
+
};
|
|
441
|
+
}
|
|
413
442
|
function unknownClaimStatusCategory(position) {
|
|
414
443
|
return {
|
|
415
444
|
code: WARNING_CODES.X12_UNKNOWN_CLAIM_STATUS_CATEGORY,
|
|
@@ -438,6 +467,20 @@ function unparseableDecimal(position) {
|
|
|
438
467
|
position
|
|
439
468
|
};
|
|
440
469
|
}
|
|
470
|
+
function amountRowDropped(position) {
|
|
471
|
+
return {
|
|
472
|
+
code: WARNING_CODES.X12_AMOUNT_ROW_DROPPED,
|
|
473
|
+
message: WARNING_MESSAGES.X12_AMOUNT_ROW_DROPPED,
|
|
474
|
+
position
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function statedAmountDiscarded(position) {
|
|
478
|
+
return {
|
|
479
|
+
code: WARNING_CODES.X12_STATED_AMOUNT_DISCARDED,
|
|
480
|
+
message: WARNING_MESSAGES.X12_STATED_AMOUNT_DISCARDED,
|
|
481
|
+
position
|
|
482
|
+
};
|
|
483
|
+
}
|
|
441
484
|
|
|
442
485
|
// src/parser/release.ts
|
|
443
486
|
var RELEASE_CHAR = "?";
|
|
@@ -1898,11 +1941,13 @@ function isProcedureQualifier(qualifier) {
|
|
|
1898
1941
|
// src/transactions/remit/balance.ts
|
|
1899
1942
|
function checkClaimBalance(claim, position) {
|
|
1900
1943
|
const claimCasSum = sumAmounts(claim.adjustments);
|
|
1901
|
-
const lineCasSum =
|
|
1902
|
-
(
|
|
1903
|
-
X12Decimal.ZERO
|
|
1944
|
+
const lineCasSum = sumOptional(
|
|
1945
|
+
claim.serviceLines.map((sl) => sumAmounts(sl.adjustments))
|
|
1904
1946
|
);
|
|
1905
|
-
const computed = claim.totalPaymentAmount
|
|
1947
|
+
const computed = sumOptional([claim.totalPaymentAmount, claimCasSum, lineCasSum]);
|
|
1948
|
+
if (computed === void 0 || claim.totalChargeAmount === void 0) {
|
|
1949
|
+
return balanceNotEvaluable(position, BALANCE_INVARIANTS.CLAIM);
|
|
1950
|
+
}
|
|
1906
1951
|
if (computed.equals(claim.totalChargeAmount)) return void 0;
|
|
1907
1952
|
return remitBalanceMismatch(position, BALANCE_INVARIANTS.CLAIM);
|
|
1908
1953
|
}
|
|
@@ -1912,35 +1957,37 @@ function checkServiceLineBalance(claim, position) {
|
|
|
1912
1957
|
const line = claim.serviceLines[i];
|
|
1913
1958
|
if (line === void 0) continue;
|
|
1914
1959
|
const lineCasSum = sumAmounts(line.adjustments);
|
|
1915
|
-
const
|
|
1960
|
+
const linePosition = { ...position, segmentIndex: position.segmentIndex + i + 1 };
|
|
1961
|
+
const computed = sumOptional([line.paymentAmount, lineCasSum]);
|
|
1962
|
+
if (computed === void 0 || line.chargeAmount === void 0) {
|
|
1963
|
+
out.push(balanceNotEvaluable(linePosition, BALANCE_INVARIANTS.SERVICE_LINE));
|
|
1964
|
+
continue;
|
|
1965
|
+
}
|
|
1916
1966
|
if (computed.equals(line.chargeAmount)) continue;
|
|
1917
|
-
out.push(
|
|
1918
|
-
remitBalanceMismatch(
|
|
1919
|
-
{ ...position, segmentIndex: position.segmentIndex + i + 1 },
|
|
1920
|
-
BALANCE_INVARIANTS.SERVICE_LINE
|
|
1921
|
-
)
|
|
1922
|
-
);
|
|
1967
|
+
out.push(remitBalanceMismatch(linePosition, BALANCE_INVARIANTS.SERVICE_LINE));
|
|
1923
1968
|
}
|
|
1924
1969
|
return out;
|
|
1925
1970
|
}
|
|
1926
1971
|
function checkRemitTotalBalance(bpr02, claims, providerAdjustments, position) {
|
|
1927
|
-
const claimSum = claims.
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
(acc, p) => acc.add(p.amount),
|
|
1933
|
-
X12Decimal.ZERO
|
|
1934
|
-
);
|
|
1972
|
+
const claimSum = sumOptional(claims.map((c) => c.totalPaymentAmount));
|
|
1973
|
+
const plbSum = sumOptional(providerAdjustments.map((p) => p.amount));
|
|
1974
|
+
if (bpr02 === void 0 || claimSum === void 0 || plbSum === void 0) {
|
|
1975
|
+
return balanceNotEvaluable(position, BALANCE_INVARIANTS.REMIT_TOTAL);
|
|
1976
|
+
}
|
|
1935
1977
|
const computed = claimSum.subtract(plbSum);
|
|
1936
1978
|
if (computed.equals(bpr02)) return void 0;
|
|
1937
1979
|
return remitBalanceMismatch(position, BALANCE_INVARIANTS.REMIT_TOTAL);
|
|
1938
1980
|
}
|
|
1939
1981
|
function sumAmounts(adjustments) {
|
|
1940
|
-
return adjustments.
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1982
|
+
return sumOptional(adjustments.map((a) => a.amount));
|
|
1983
|
+
}
|
|
1984
|
+
function sumOptional(terms) {
|
|
1985
|
+
let acc = X12Decimal.ZERO;
|
|
1986
|
+
for (const term of terms) {
|
|
1987
|
+
if (term === void 0) return void 0;
|
|
1988
|
+
acc = acc.add(term);
|
|
1989
|
+
}
|
|
1990
|
+
return acc;
|
|
1944
1991
|
}
|
|
1945
1992
|
|
|
1946
1993
|
// src/transactions/remit/get-835.ts
|
|
@@ -2106,7 +2153,10 @@ function get835(delimiters, tx) {
|
|
|
2106
2153
|
}
|
|
2107
2154
|
case "AMT": {
|
|
2108
2155
|
const amount = decodeAmt(seg, delimiters, sink);
|
|
2109
|
-
if (amount === void 0)
|
|
2156
|
+
if (amount === void 0) {
|
|
2157
|
+
warnings.push(amountRowDropped(position));
|
|
2158
|
+
break;
|
|
2159
|
+
}
|
|
2110
2160
|
if (currentServiceLine !== void 0) currentServiceLine.amounts.push(amount);
|
|
2111
2161
|
else if (currentClaim !== void 0) currentClaim.amounts.push(amount);
|
|
2112
2162
|
break;
|
|
@@ -2163,7 +2213,7 @@ function get835(delimiters, tx) {
|
|
|
2163
2213
|
function decodeBpr(seg, delimiters, sink) {
|
|
2164
2214
|
return Object.freeze({
|
|
2165
2215
|
transactionHandlingCode: elementValue(seg, 1, delimiters),
|
|
2166
|
-
totalActualPayment:
|
|
2216
|
+
totalActualPayment: elementDecimal(seg, 2, delimiters, sink),
|
|
2167
2217
|
creditDebitFlag: elementValue(seg, 3, delimiters),
|
|
2168
2218
|
method: elementValue(seg, 4, delimiters),
|
|
2169
2219
|
paymentFormatCode: elementOptional(seg, 5, delimiters),
|
|
@@ -2276,7 +2326,7 @@ function decodeCasAdjustments(seg, delimiters, warnings, position) {
|
|
|
2276
2326
|
groupCode,
|
|
2277
2327
|
reasonCode: code,
|
|
2278
2328
|
reasonDescription: entry?.description,
|
|
2279
|
-
amount
|
|
2329
|
+
amount,
|
|
2280
2330
|
quantity
|
|
2281
2331
|
})
|
|
2282
2332
|
);
|
|
@@ -2320,9 +2370,9 @@ function openClaim(seg, delimiters, clpSegmentIndex, sink) {
|
|
|
2320
2370
|
patientControlNumber: elementValue(seg, 1, delimiters),
|
|
2321
2371
|
claimStatusCode,
|
|
2322
2372
|
claimStatusDescription,
|
|
2323
|
-
totalChargeAmount:
|
|
2324
|
-
totalPaymentAmount:
|
|
2325
|
-
patientResponsibilityAmount:
|
|
2373
|
+
totalChargeAmount: elementDecimal(seg, 3, delimiters, sink),
|
|
2374
|
+
totalPaymentAmount: elementDecimal(seg, 4, delimiters, sink),
|
|
2375
|
+
patientResponsibilityAmount: elementDecimal(seg, 5, delimiters, sink),
|
|
2326
2376
|
claimFilingIndicatorCode: elementOptional(seg, 6, delimiters),
|
|
2327
2377
|
payerClaimControlNumber: elementOptional(seg, 7, delimiters),
|
|
2328
2378
|
facilityTypeCode,
|
|
@@ -2358,8 +2408,8 @@ function openServiceLine(seg, delimiters, sink) {
|
|
|
2358
2408
|
productServiceIdQualifier,
|
|
2359
2409
|
productServiceId,
|
|
2360
2410
|
modifiers,
|
|
2361
|
-
chargeAmount:
|
|
2362
|
-
paymentAmount:
|
|
2411
|
+
chargeAmount: elementDecimal(seg, 2, delimiters, sink),
|
|
2412
|
+
paymentAmount: elementDecimal(seg, 3, delimiters, sink),
|
|
2363
2413
|
revenueCode,
|
|
2364
2414
|
paidUnitsOfService,
|
|
2365
2415
|
originalUnitsOfService,
|
|
@@ -2404,7 +2454,7 @@ function decodePlb(seg, delimiters, sink) {
|
|
|
2404
2454
|
fiscalPeriodDate,
|
|
2405
2455
|
reasonCode: reasonCode ?? "",
|
|
2406
2456
|
subCode,
|
|
2407
|
-
amount
|
|
2457
|
+
amount
|
|
2408
2458
|
})
|
|
2409
2459
|
);
|
|
2410
2460
|
}
|
|
@@ -2419,7 +2469,7 @@ var EMPTY_ADDRESS = Object.freeze({
|
|
|
2419
2469
|
});
|
|
2420
2470
|
var EMPTY_HEADER = Object.freeze({
|
|
2421
2471
|
transactionHandlingCode: "",
|
|
2422
|
-
totalActualPayment:
|
|
2472
|
+
totalActualPayment: void 0,
|
|
2423
2473
|
creditDebitFlag: "",
|
|
2424
2474
|
method: "",
|
|
2425
2475
|
paymentFormatCode: void 0,
|
|
@@ -2839,12 +2889,24 @@ function enforceBalance(spec) {
|
|
|
2839
2889
|
for (const claim of claims) {
|
|
2840
2890
|
const claimWarn = checkClaimBalance(claim, position);
|
|
2841
2891
|
if (claimWarn !== void 0) {
|
|
2892
|
+
if (notEvaluable(claimWarn)) {
|
|
2893
|
+
throw new Remit835BuildError(
|
|
2894
|
+
REMIT_835_BUILD_ERROR_CODES.X12_835_BUILD_INVALID_SPEC,
|
|
2895
|
+
`build835 refuses a claim whose balance cannot be checked: ${claimWarn.message}`
|
|
2896
|
+
);
|
|
2897
|
+
}
|
|
2842
2898
|
throw new Remit835BuildError(
|
|
2843
2899
|
REMIT_835_BUILD_ERROR_CODES.X12_835_BUILD_BALANCE_MISMATCH,
|
|
2844
2900
|
`build835 refuses an out-of-balance claim: ${claimWarn.message}`
|
|
2845
2901
|
);
|
|
2846
2902
|
}
|
|
2847
2903
|
for (const lineWarn of checkServiceLineBalance(claim, position)) {
|
|
2904
|
+
if (notEvaluable(lineWarn)) {
|
|
2905
|
+
throw new Remit835BuildError(
|
|
2906
|
+
REMIT_835_BUILD_ERROR_CODES.X12_835_BUILD_INVALID_SPEC,
|
|
2907
|
+
`build835 refuses a service line whose balance cannot be checked: ${lineWarn.message}`
|
|
2908
|
+
);
|
|
2909
|
+
}
|
|
2848
2910
|
throw new Remit835BuildError(
|
|
2849
2911
|
REMIT_835_BUILD_ERROR_CODES.X12_835_BUILD_BALANCE_MISMATCH,
|
|
2850
2912
|
`build835 refuses an out-of-balance service line: ${lineWarn.message}`
|
|
@@ -2858,12 +2920,21 @@ function enforceBalance(spec) {
|
|
|
2858
2920
|
position
|
|
2859
2921
|
);
|
|
2860
2922
|
if (totalWarn !== void 0) {
|
|
2923
|
+
if (notEvaluable(totalWarn)) {
|
|
2924
|
+
throw new Remit835BuildError(
|
|
2925
|
+
REMIT_835_BUILD_ERROR_CODES.X12_835_BUILD_INVALID_SPEC,
|
|
2926
|
+
`build835 refuses a remit whose balance cannot be checked: ${totalWarn.message}`
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2861
2929
|
throw new Remit835BuildError(
|
|
2862
2930
|
REMIT_835_BUILD_ERROR_CODES.X12_835_BUILD_BALANCE_MISMATCH,
|
|
2863
2931
|
`build835 refuses an out-of-balance remit: ${totalWarn.message}`
|
|
2864
2932
|
);
|
|
2865
2933
|
}
|
|
2866
2934
|
}
|
|
2935
|
+
function notEvaluable(warn) {
|
|
2936
|
+
return warn.code === WARNING_CODES.X12_835_BALANCE_NOT_EVALUABLE;
|
|
2937
|
+
}
|
|
2867
2938
|
function materializeAdjustment(spec) {
|
|
2868
2939
|
return {
|
|
2869
2940
|
groupCode: spec.groupCode,
|
|
@@ -3237,6 +3308,17 @@ function wireLookup(entries) {
|
|
|
3237
3308
|
return Object.freeze(table);
|
|
3238
3309
|
}
|
|
3239
3310
|
|
|
3311
|
+
// src/transactions/claim/address-segments.ts
|
|
3312
|
+
function emitsStreetLines(address) {
|
|
3313
|
+
return address.lines.length > 0;
|
|
3314
|
+
}
|
|
3315
|
+
function emitsGeographicFields(address) {
|
|
3316
|
+
return address.city !== void 0 || address.state !== void 0 || address.postalCode !== void 0 || address.countryCode !== void 0;
|
|
3317
|
+
}
|
|
3318
|
+
function statesAnAddress(address) {
|
|
3319
|
+
return emitsStreetLines(address) || emitsGeographicFields(address);
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3240
3322
|
// src/transactions/claim/get-837.ts
|
|
3241
3323
|
var VARIANT_BY_ICR = wireLookup({
|
|
3242
3324
|
"005010X222A2": "P",
|
|
@@ -3297,6 +3379,8 @@ function get837Claims(delimiters, tx, opts) {
|
|
|
3297
3379
|
let receiver;
|
|
3298
3380
|
let billingProvider;
|
|
3299
3381
|
let payToAddress;
|
|
3382
|
+
let pendingPayToAddress;
|
|
3383
|
+
let payToAddressNamed = false;
|
|
3300
3384
|
let payToPlan;
|
|
3301
3385
|
let currentSubscriberMember;
|
|
3302
3386
|
let currentPayer;
|
|
@@ -3383,7 +3467,8 @@ function get837Claims(delimiters, tx, opts) {
|
|
|
3383
3467
|
currentPatientMember = { ...currentPatientMember, entity: next };
|
|
3384
3468
|
},
|
|
3385
3469
|
setPayToAddress: (next) => {
|
|
3386
|
-
|
|
3470
|
+
pendingPayToAddress = next;
|
|
3471
|
+
if (statesAnAddress(next) || payToAddress === void 0) payToAddress = next;
|
|
3387
3472
|
},
|
|
3388
3473
|
setOtherSubscriber: (next) => {
|
|
3389
3474
|
currentOtherSubscriber.otherSubscriber = next;
|
|
@@ -3398,7 +3483,10 @@ function get837Claims(delimiters, tx, opts) {
|
|
|
3398
3483
|
getCurrentSubscriber: () => currentSubscriberMember?.entity,
|
|
3399
3484
|
getCurrentPayer: () => currentPayer,
|
|
3400
3485
|
getCurrentPatient: () => currentPatientMember?.entity,
|
|
3401
|
-
|
|
3486
|
+
// Deliberately the CURRENT occurrence's accumulator, never the committed
|
|
3487
|
+
// slot: this is the getter both address arms build onto, and reading the
|
|
3488
|
+
// committed slot here is exactly what fused two `NM1*87`s.
|
|
3489
|
+
getCurrentPayToAddress: () => pendingPayToAddress,
|
|
3402
3490
|
getCurrentOtherSubscriber: () => currentOtherSubscriber?.otherSubscriber,
|
|
3403
3491
|
getCurrentOtherPayer: () => currentOtherSubscriber?.otherPayer
|
|
3404
3492
|
};
|
|
@@ -3420,6 +3508,8 @@ function get837Claims(delimiters, tx, opts) {
|
|
|
3420
3508
|
currentPatientHl = void 0;
|
|
3421
3509
|
billingProvider = void 0;
|
|
3422
3510
|
payToAddress = void 0;
|
|
3511
|
+
pendingPayToAddress = void 0;
|
|
3512
|
+
payToAddressNamed = false;
|
|
3423
3513
|
payToPlan = void 0;
|
|
3424
3514
|
context = { kind: "loop2000A" };
|
|
3425
3515
|
} else if (hl.levelCode === HL_LEVEL_CODES.SUBSCRIBER) {
|
|
@@ -3483,6 +3573,9 @@ function get837Claims(delimiters, tx, opts) {
|
|
|
3483
3573
|
billingProvider = entity;
|
|
3484
3574
|
activeEntity = { kind: "billingProvider" };
|
|
3485
3575
|
} else if (qualifier === NM1_QUALIFIERS.PAY_TO_ADDRESS && context.kind === "loop2000A") {
|
|
3576
|
+
if (payToAddressNamed) warnings.push(payToAddressRepeated(position));
|
|
3577
|
+
payToAddressNamed = true;
|
|
3578
|
+
pendingPayToAddress = void 0;
|
|
3486
3579
|
activeEntity = { kind: "payToAddress" };
|
|
3487
3580
|
} else if (qualifier === NM1_QUALIFIERS.PAY_TO_PLAN && context.kind === "loop2000A" && variant === "I") {
|
|
3488
3581
|
payToPlan = entity;
|
|
@@ -3616,8 +3709,14 @@ function get837Claims(delimiters, tx, opts) {
|
|
|
3616
3709
|
}
|
|
3617
3710
|
case "AMT": {
|
|
3618
3711
|
const amount = decodeAmt2(seg, delimiters, sink);
|
|
3619
|
-
if (amount === void 0)
|
|
3620
|
-
|
|
3712
|
+
if (amount === void 0) {
|
|
3713
|
+
warnings.push(amountRowDropped(position));
|
|
3714
|
+
break;
|
|
3715
|
+
}
|
|
3716
|
+
if (currentAdjudication !== void 0) {
|
|
3717
|
+
warnings.push(statedAmountDiscarded(position));
|
|
3718
|
+
break;
|
|
3719
|
+
}
|
|
3621
3720
|
if (currentServiceLine !== void 0) currentServiceLine.amounts.push(amount);
|
|
3622
3721
|
else if (currentClaim !== void 0) currentClaim.amounts.push(amount);
|
|
3623
3722
|
break;
|
|
@@ -3907,7 +4006,7 @@ function decodeCas(seg, delimiters, warnings, position) {
|
|
|
3907
4006
|
groupCode,
|
|
3908
4007
|
reasonCode: code,
|
|
3909
4008
|
reasonDescription: entry?.description,
|
|
3910
|
-
amount
|
|
4009
|
+
amount,
|
|
3911
4010
|
quantity
|
|
3912
4011
|
})
|
|
3913
4012
|
);
|
|
@@ -3953,7 +4052,7 @@ function openClaim2(seg, delimiters, ctx, sink) {
|
|
|
3953
4052
|
payer,
|
|
3954
4053
|
patient,
|
|
3955
4054
|
claimId: elementValue(seg, 1, delimiters),
|
|
3956
|
-
totalCharge:
|
|
4055
|
+
totalCharge: elementDecimal(seg, 2, delimiters, sink),
|
|
3957
4056
|
placeOfServiceCode: componentOptional(seg, 5, 1, delimiters),
|
|
3958
4057
|
facilityCodeQualifier: componentOptional(seg, 5, 2, delimiters),
|
|
3959
4058
|
claimFrequencyCode: componentOptional(seg, 5, 3, delimiters),
|
|
@@ -3979,8 +4078,8 @@ function openServiceLine2(seg, delimiters, variant, position) {
|
|
|
3979
4078
|
lineNumber,
|
|
3980
4079
|
position,
|
|
3981
4080
|
serviceSegmentDecoded: false,
|
|
3982
|
-
charge:
|
|
3983
|
-
units:
|
|
4081
|
+
charge: void 0,
|
|
4082
|
+
units: void 0,
|
|
3984
4083
|
unitOfMeasure: void 0,
|
|
3985
4084
|
placeOfServiceCode: void 0,
|
|
3986
4085
|
dates: [],
|
|
@@ -4041,9 +4140,9 @@ function decodeSv1(acc, seg, delimiters, sink) {
|
|
|
4041
4140
|
if (m !== void 0) mods.push(m);
|
|
4042
4141
|
}
|
|
4043
4142
|
acc.modifiers = mods;
|
|
4044
|
-
acc.charge =
|
|
4143
|
+
acc.charge = elementDecimal(seg, 2, delimiters, sink);
|
|
4045
4144
|
acc.unitOfMeasure = elementOptional(seg, 3, delimiters);
|
|
4046
|
-
acc.units =
|
|
4145
|
+
acc.units = elementDecimal(seg, 4, delimiters, sink);
|
|
4047
4146
|
acc.placeOfServiceCode = elementOptional(seg, 5, delimiters);
|
|
4048
4147
|
const pointers = [];
|
|
4049
4148
|
for (let p = 1; p <= 4; p += 1) {
|
|
@@ -4067,9 +4166,9 @@ function decodeSv2(acc, seg, delimiters, sink) {
|
|
|
4067
4166
|
if (m !== void 0) mods.push(m);
|
|
4068
4167
|
}
|
|
4069
4168
|
acc.modifiers = mods;
|
|
4070
|
-
acc.charge =
|
|
4169
|
+
acc.charge = elementDecimal(seg, 3, delimiters, sink);
|
|
4071
4170
|
acc.unitOfMeasure = elementOptional(seg, 4, delimiters);
|
|
4072
|
-
acc.units =
|
|
4171
|
+
acc.units = elementDecimal(seg, 5, delimiters, sink);
|
|
4073
4172
|
acc.serviceLineRate = elementDecimal(seg, 6, delimiters, sink);
|
|
4074
4173
|
acc.nonCoveredCharge = elementDecimal(seg, 7, delimiters, sink);
|
|
4075
4174
|
}
|
|
@@ -4084,7 +4183,7 @@ function decodeSv3(acc, seg, delimiters, sink) {
|
|
|
4084
4183
|
if (m !== void 0) mods.push(m);
|
|
4085
4184
|
}
|
|
4086
4185
|
acc.modifiers = mods;
|
|
4087
|
-
acc.charge =
|
|
4186
|
+
acc.charge = elementDecimal(seg, 2, delimiters, sink);
|
|
4088
4187
|
acc.placeOfServiceCode = elementOptional(seg, 3, delimiters);
|
|
4089
4188
|
const cavities = [];
|
|
4090
4189
|
for (let p = 1; p <= 5; p += 1) {
|
|
@@ -4093,12 +4192,12 @@ function decodeSv3(acc, seg, delimiters, sink) {
|
|
|
4093
4192
|
}
|
|
4094
4193
|
acc.oralCavityArea = cavities;
|
|
4095
4194
|
acc.prosthesisCrownInlayCode = elementOptional(seg, 5, delimiters);
|
|
4096
|
-
acc.units =
|
|
4195
|
+
acc.units = elementDecimal(seg, 6, delimiters, sink);
|
|
4097
4196
|
}
|
|
4098
4197
|
function openAdjudication(seg, delimiters, sink) {
|
|
4099
4198
|
return {
|
|
4100
4199
|
otherPayerId: elementValue(seg, 1, delimiters),
|
|
4101
|
-
amountPaid:
|
|
4200
|
+
amountPaid: elementDecimal(seg, 2, delimiters, sink),
|
|
4102
4201
|
procedureQualifier: componentOptional(seg, 3, 1, delimiters),
|
|
4103
4202
|
procedureCode: componentOptional(seg, 3, 2, delimiters),
|
|
4104
4203
|
paidUnits: elementDecimal(seg, 5, delimiters, sink),
|
|
@@ -4627,6 +4726,12 @@ function enforceClaim(variant, claim, locator) {
|
|
|
4627
4726
|
`build837${variant}: claim at ${locator} has a service line at index ${String(l)} with an empty ${line.variant === "I" ? "revenue" : "procedure"} code.`
|
|
4628
4727
|
);
|
|
4629
4728
|
}
|
|
4729
|
+
if (line.units === void 0) {
|
|
4730
|
+
throw new Claim837BuildError(
|
|
4731
|
+
CLAIM_837_BUILD_ERROR_CODES.X12_837_BUILD_INVALID_SPEC,
|
|
4732
|
+
`build837${variant}: claim at ${locator} has a service line at index ${String(l)} with no units. This builder will not emit a service unit count the caller did not supply; set units to an X12Decimal rather than leaving it undefined.`
|
|
4733
|
+
);
|
|
4734
|
+
}
|
|
4630
4735
|
}
|
|
4631
4736
|
}
|
|
4632
4737
|
function emitBillingProvider(variant, billing, body, ctx, counter) {
|
|
@@ -4741,7 +4846,7 @@ function emitOtherSubscriber(other, body, ctx) {
|
|
|
4741
4846
|
}
|
|
4742
4847
|
function emitServiceLine2(variant, line, lineNumber, body, ctx) {
|
|
4743
4848
|
body.push(ctx.seg(["LX", ctx.esc(line.lineNumber ?? String(lineNumber))]));
|
|
4744
|
-
const units =
|
|
4849
|
+
const units = decStr(line.units);
|
|
4745
4850
|
if (line.variant === "P") {
|
|
4746
4851
|
const proc = ctx.comp([line.procedureQualifier, line.procedureCode, ...line.modifiers ?? []]);
|
|
4747
4852
|
const pointers = ctx.comp(line.diagnosisPointers ?? []);
|
|
@@ -4893,10 +4998,10 @@ function emitEntity(entity, body, ctx) {
|
|
|
4893
4998
|
for (const ref of entity.references ?? []) body.push(emitRef2(ref, ctx));
|
|
4894
4999
|
}
|
|
4895
5000
|
function emitAddress(address, body, ctx) {
|
|
4896
|
-
if (address
|
|
5001
|
+
if (emitsStreetLines(address)) {
|
|
4897
5002
|
body.push(ctx.seg(["N3", ...address.lines.map(ctx.esc)]));
|
|
4898
5003
|
}
|
|
4899
|
-
if (address
|
|
5004
|
+
if (emitsGeographicFields(address)) {
|
|
4900
5005
|
body.push(
|
|
4901
5006
|
ctx.seg([
|
|
4902
5007
|
"N4",
|
|
@@ -6890,13 +6995,18 @@ function get820Payments(delimiters, tx) {
|
|
|
6890
6995
|
case "RMR": {
|
|
6891
6996
|
if (current === void 0) break;
|
|
6892
6997
|
const item = decodeRmr(seg, delimiters, sink);
|
|
6893
|
-
if (item !== void 0)
|
|
6998
|
+
if (item !== void 0) {
|
|
6999
|
+
current.openItems.push(item);
|
|
7000
|
+
break;
|
|
7001
|
+
}
|
|
7002
|
+
if (statesAnAmount(seg, delimiters)) warnings.push(statedAmountDiscarded(position));
|
|
6894
7003
|
break;
|
|
6895
7004
|
}
|
|
6896
7005
|
case "ADX": {
|
|
6897
7006
|
if (current === void 0) break;
|
|
6898
7007
|
const adjustment = decodeAdx(seg, delimiters, sink);
|
|
6899
|
-
if (adjustment
|
|
7008
|
+
if (adjustment === void 0) warnings.push(amountRowDropped(position));
|
|
7009
|
+
else current.adjustments.push(adjustment);
|
|
6900
7010
|
break;
|
|
6901
7011
|
}
|
|
6902
7012
|
case "REF": {
|
|
@@ -6950,7 +7060,7 @@ function freezeRemittance(acc) {
|
|
|
6950
7060
|
function decodeBpr2(seg, delimiters, sink) {
|
|
6951
7061
|
return Object.freeze({
|
|
6952
7062
|
transactionHandlingCode: elementValue(seg, 1, delimiters),
|
|
6953
|
-
totalPremiumAmount:
|
|
7063
|
+
totalPremiumAmount: elementDecimal(seg, 2, delimiters, sink),
|
|
6954
7064
|
creditDebitFlag: elementValue(seg, 3, delimiters),
|
|
6955
7065
|
method: elementValue(seg, 4, delimiters),
|
|
6956
7066
|
paymentFormatCode: elementOptional(seg, 5, delimiters),
|
|
@@ -7018,6 +7128,9 @@ function decodeNm13(seg, delimiters) {
|
|
|
7018
7128
|
idCode: elementOptional(seg, 9, delimiters)
|
|
7019
7129
|
});
|
|
7020
7130
|
}
|
|
7131
|
+
function statesAnAmount(seg, delimiters) {
|
|
7132
|
+
return elementValue(seg, 4, delimiters) !== "" || elementValue(seg, 5, delimiters) !== "";
|
|
7133
|
+
}
|
|
7021
7134
|
function decodeRmr(seg, delimiters, sink) {
|
|
7022
7135
|
const qualifier = elementValue(seg, 1, delimiters);
|
|
7023
7136
|
const referenceId = elementValue(seg, 2, delimiters);
|
|
@@ -7026,7 +7139,7 @@ function decodeRmr(seg, delimiters, sink) {
|
|
|
7026
7139
|
qualifier,
|
|
7027
7140
|
referenceId,
|
|
7028
7141
|
paymentActionCode: elementOptional(seg, 3, delimiters),
|
|
7029
|
-
amountPaid:
|
|
7142
|
+
amountPaid: elementDecimal(seg, 4, delimiters, sink),
|
|
7030
7143
|
amountDue: elementDecimal(seg, 5, delimiters, sink)
|
|
7031
7144
|
});
|
|
7032
7145
|
}
|
|
@@ -7049,7 +7162,7 @@ var EMPTY_ADDRESS3 = Object.freeze({
|
|
|
7049
7162
|
});
|
|
7050
7163
|
var EMPTY_HEADER2 = Object.freeze({
|
|
7051
7164
|
transactionHandlingCode: "",
|
|
7052
|
-
totalPremiumAmount:
|
|
7165
|
+
totalPremiumAmount: void 0,
|
|
7053
7166
|
creditDebitFlag: "",
|
|
7054
7167
|
method: "",
|
|
7055
7168
|
paymentFormatCode: void 0,
|
|
@@ -7608,7 +7721,8 @@ async function* get834Enrollments(delimiters, tx) {
|
|
|
7608
7721
|
if (currentCoverage === void 0) break;
|
|
7609
7722
|
const sink = { warnings: current.warnings, position };
|
|
7610
7723
|
const amount = decodeAmt3(seg, delimiters, sink);
|
|
7611
|
-
if (amount
|
|
7724
|
+
if (amount === void 0) current.warnings.push(amountRowDropped(position));
|
|
7725
|
+
else currentCoverage.amounts.push(amount);
|
|
7612
7726
|
break;
|
|
7613
7727
|
}
|
|
7614
7728
|
}
|
|
@@ -10190,8 +10304,8 @@ var profiles = Object.freeze({
|
|
|
10190
10304
|
});
|
|
10191
10305
|
|
|
10192
10306
|
// src/index.ts
|
|
10193
|
-
var VERSION = "0.0.
|
|
10307
|
+
var VERSION = "0.0.13";
|
|
10194
10308
|
|
|
10195
|
-
export { ACK_BUILD_ERROR_CODES, ALL_WARNING_MESSAGES, AUTH_278_BUILD_ERROR_CODES, AUTH_278_LOOP_2000A, AUTH_278_LOOP_2000B, AUTH_278_LOOP_2000C, AUTH_278_LOOP_2000D, AUTH_278_LOOP_2000E, AUTH_278_LOOP_2000F, AckBuildError, BALANCE_INVARIANTS, BUILD_REFUSAL_VALUE_MAX_LENGTH, BUILD_REFUSAL_VALUE_MAX_RENDERED, CARC, CLAIM_837D_LOOP_2000A, CLAIM_837D_LOOP_2300, CLAIM_837D_LOOP_2400, CLAIM_837I_LOOP_2000A, CLAIM_837I_LOOP_2300, CLAIM_837I_LOOP_2400, CLAIM_837P_LOOP_2000A, CLAIM_837P_LOOP_2300, CLAIM_837P_LOOP_2400, CLAIM_837P_LOOP_2410, CLAIM_837_BUILD_ERROR_CODES, CLAIM_837_LOOP_1000A, CLAIM_837_LOOP_1000B, CLAIM_837_LOOP_2010AA, CLAIM_837_LOOP_2010BA, CLAIM_837_LOOP_2010BB, CLAIM_837_LOOP_2010CA, CLAIM_837_LOOP_2430, CLAIM_ADJUSTMENT_GROUP_CODES, CLAIM_STATUS_277_BUILD_ERROR_CODES, CLAIM_STATUS_CATEGORY_CODES, CLAIM_STATUS_CODES, CLP_STATUS, CONTROL_NUMBER_PAIRS, Claim837BuildError, ClaimStatus277BuildError, DELIMITER_POSITIONS, ELIGIBILITY_271_BUILD_ERROR_CODES, ELIGIBILITY_271_LOOP_2000A, ELIGIBILITY_271_LOOP_2000B, ELIGIBILITY_271_LOOP_2000C, ELIGIBILITY_271_LOOP_2000D, ELIGIBILITY_271_LOOP_2100C, ELIGIBILITY_271_LOOP_2100D, ELIGIBILITY_271_LOOP_2110, ENROLLMENT_834_BUILD_ERROR_CODES, ENROLLMENT_834_LOOP_1000A, ENROLLMENT_834_LOOP_1000B, ENROLLMENT_834_LOOP_2000, ENROLLMENT_834_LOOP_2100A, ENROLLMENT_834_LOOP_2300, ENROLLMENT_834_LOOP_2320, Eligibility271BuildError, Enrollment834BuildError, FATAL_CODES, HI_QUALIFIERS, HL_LEVEL_CODES, IK3_SYNTAX_ERROR_CODES, IK4_SYNTAX_ERROR_CODES, ISA_MIN_LENGTH, LoopSpecDefinitionError, MAINTENANCE_TYPE_CODES, NM1_QUALIFIERS, NON_SPEC_SEGMENT_ID, PREMIUM_820_BUILD_ERROR_CODES, PREMIUM_820_LOOP_1000A, PREMIUM_820_LOOP_1000B, PREMIUM_820_LOOP_2000A, PREMIUM_820_LOOP_2100A, PREMIUM_820_LOOP_2300A, PREMIUM_820_LOOP_2310A, Premium820BuildError, RARC, RELEASE_CHAR, REMIT_835_BUILD_ERROR_CODES, REMIT_835_LOOP_1000A, REMIT_835_LOOP_1000B, REMIT_835_LOOP_2000, REMIT_835_LOOP_2100, REMIT_835_LOOP_2110, REQUIRED_LOOPS, Remit835BuildError, SERVICE_TYPE_CODES, STATUS_277_LOOP_2000A, STATUS_277_LOOP_2000B, STATUS_277_LOOP_2000C, STATUS_277_LOOP_2000D, STATUS_277_LOOP_2000E, STATUS_277_LOOP_2200, STATUS_277_LOOP_2220, ServicesReview278BuildError, TA1_ACK_CODES, TA1_NOTE_CODES, UNEXPECTED_SEGMENT_CONTEXTS, VERSION, WARNING_CODES, X12BuildError, X12Decimal, X12ParseError, X12ProfileError, X12_ACK_DISPOSITION_CODES, X12_BUILD_ERROR_CODES, build271, build277, build277CA, build278Request, build278Response, build820, build834, build835, build837D, build837I, build837P, build999, buildInterchange, buildTA1, checkClaimBalance, checkRemitTotalBalance, checkServiceLineBalance, collectElementValues, componentOptional, controlNumberMismatch, danglingReleaseChar, decodeSegment, defineLoopSpec, defineProfile, detectDelimiters, elementDecimal, elementDecimalOrZero, elementOptional, elementValue, entitySegmentDiscardedAfterLx, escapeRelease, get271Eligibility, get277CADisposition, get277Status, get278Request, get278Response, get820Payments, get834Enrollments, get834Header, get835, get837Claims, getAllSegmentValues, getDefaultProfile, getSegmentValue, groupCountMismatch, hlParentLevelInvalid, hlParentMismatch, isAcceptDisposition, isClaimAdjustmentGroupCode, isDiagnosisQualifier, isProcedureQualifier, lookupCarc, lookupClaimStatus, lookupClaimStatusCategory, lookupClpStatus, lookupMaintenanceType, lookupRarc, lookupServiceType, missingGe, missingIea, missingRequiredLoop, missingSe, parse999, parseTA1, parseX12, partitionWarnings, pre005010, profiles, readElementDecimal, remitBalanceMismatch, renderCallerValue, resolveHiQualifier, segmentCountMismatch, serializeX12, serviceLineDropped, serviceLineNotDecoded, serviceSegmentWithoutLx, setDefaultProfile, trailingGarbage, transactionCountMismatch, unescapeRelease, unexpectedSegment, unknown837Variant, unknownCarc, unknownClaimStatus, unknownClaimStatusCategory, unknownHiQualifier, unknownMaintenanceType, unknownRarc, unparseableDecimal };
|
|
10309
|
+
export { ACK_BUILD_ERROR_CODES, ALL_WARNING_MESSAGES, AUTH_278_BUILD_ERROR_CODES, AUTH_278_LOOP_2000A, AUTH_278_LOOP_2000B, AUTH_278_LOOP_2000C, AUTH_278_LOOP_2000D, AUTH_278_LOOP_2000E, AUTH_278_LOOP_2000F, AckBuildError, BALANCE_INVARIANTS, BUILD_REFUSAL_VALUE_MAX_LENGTH, BUILD_REFUSAL_VALUE_MAX_RENDERED, CARC, CLAIM_837D_LOOP_2000A, CLAIM_837D_LOOP_2300, CLAIM_837D_LOOP_2400, CLAIM_837I_LOOP_2000A, CLAIM_837I_LOOP_2300, CLAIM_837I_LOOP_2400, CLAIM_837P_LOOP_2000A, CLAIM_837P_LOOP_2300, CLAIM_837P_LOOP_2400, CLAIM_837P_LOOP_2410, CLAIM_837_BUILD_ERROR_CODES, CLAIM_837_LOOP_1000A, CLAIM_837_LOOP_1000B, CLAIM_837_LOOP_2010AA, CLAIM_837_LOOP_2010BA, CLAIM_837_LOOP_2010BB, CLAIM_837_LOOP_2010CA, CLAIM_837_LOOP_2430, CLAIM_ADJUSTMENT_GROUP_CODES, CLAIM_STATUS_277_BUILD_ERROR_CODES, CLAIM_STATUS_CATEGORY_CODES, CLAIM_STATUS_CODES, CLP_STATUS, CONTROL_NUMBER_PAIRS, Claim837BuildError, ClaimStatus277BuildError, DELIMITER_POSITIONS, ELIGIBILITY_271_BUILD_ERROR_CODES, ELIGIBILITY_271_LOOP_2000A, ELIGIBILITY_271_LOOP_2000B, ELIGIBILITY_271_LOOP_2000C, ELIGIBILITY_271_LOOP_2000D, ELIGIBILITY_271_LOOP_2100C, ELIGIBILITY_271_LOOP_2100D, ELIGIBILITY_271_LOOP_2110, ENROLLMENT_834_BUILD_ERROR_CODES, ENROLLMENT_834_LOOP_1000A, ENROLLMENT_834_LOOP_1000B, ENROLLMENT_834_LOOP_2000, ENROLLMENT_834_LOOP_2100A, ENROLLMENT_834_LOOP_2300, ENROLLMENT_834_LOOP_2320, Eligibility271BuildError, Enrollment834BuildError, FATAL_CODES, HI_QUALIFIERS, HL_LEVEL_CODES, IK3_SYNTAX_ERROR_CODES, IK4_SYNTAX_ERROR_CODES, ISA_MIN_LENGTH, LoopSpecDefinitionError, MAINTENANCE_TYPE_CODES, NM1_QUALIFIERS, NON_SPEC_SEGMENT_ID, PREMIUM_820_BUILD_ERROR_CODES, PREMIUM_820_LOOP_1000A, PREMIUM_820_LOOP_1000B, PREMIUM_820_LOOP_2000A, PREMIUM_820_LOOP_2100A, PREMIUM_820_LOOP_2300A, PREMIUM_820_LOOP_2310A, Premium820BuildError, RARC, RELEASE_CHAR, REMIT_835_BUILD_ERROR_CODES, REMIT_835_LOOP_1000A, REMIT_835_LOOP_1000B, REMIT_835_LOOP_2000, REMIT_835_LOOP_2100, REMIT_835_LOOP_2110, REQUIRED_LOOPS, Remit835BuildError, SERVICE_TYPE_CODES, STATUS_277_LOOP_2000A, STATUS_277_LOOP_2000B, STATUS_277_LOOP_2000C, STATUS_277_LOOP_2000D, STATUS_277_LOOP_2000E, STATUS_277_LOOP_2200, STATUS_277_LOOP_2220, ServicesReview278BuildError, TA1_ACK_CODES, TA1_NOTE_CODES, UNEXPECTED_SEGMENT_CONTEXTS, VERSION, WARNING_CODES, X12BuildError, X12Decimal, X12ParseError, X12ProfileError, X12_ACK_DISPOSITION_CODES, X12_BUILD_ERROR_CODES, amountRowDropped, balanceNotEvaluable, build271, build277, build277CA, build278Request, build278Response, build820, build834, build835, build837D, build837I, build837P, build999, buildInterchange, buildTA1, checkClaimBalance, checkRemitTotalBalance, checkServiceLineBalance, collectElementValues, componentOptional, controlNumberMismatch, danglingReleaseChar, decodeSegment, defineLoopSpec, defineProfile, detectDelimiters, elementDecimal, elementDecimalOrZero, elementOptional, elementValue, entitySegmentDiscardedAfterLx, escapeRelease, get271Eligibility, get277CADisposition, get277Status, get278Request, get278Response, get820Payments, get834Enrollments, get834Header, get835, get837Claims, getAllSegmentValues, getDefaultProfile, getSegmentValue, groupCountMismatch, hlParentLevelInvalid, hlParentMismatch, isAcceptDisposition, isClaimAdjustmentGroupCode, isDiagnosisQualifier, isProcedureQualifier, lookupCarc, lookupClaimStatus, lookupClaimStatusCategory, lookupClpStatus, lookupMaintenanceType, lookupRarc, lookupServiceType, missingGe, missingIea, missingRequiredLoop, missingSe, parse999, parseTA1, parseX12, partitionWarnings, payToAddressRepeated, pre005010, profiles, readElementDecimal, remitBalanceMismatch, renderCallerValue, resolveHiQualifier, segmentCountMismatch, serializeX12, serviceLineDropped, serviceLineNotDecoded, serviceSegmentWithoutLx, setDefaultProfile, statedAmountDiscarded, trailingGarbage, transactionCountMismatch, unescapeRelease, unexpectedSegment, unknown837Variant, unknownCarc, unknownClaimStatus, unknownClaimStatusCategory, unknownHiQualifier, unknownMaintenanceType, unknownRarc, unparseableDecimal };
|
|
10196
10310
|
//# sourceMappingURL=index.mjs.map
|
|
10197
10311
|
//# sourceMappingURL=index.mjs.map
|