@cosyte/x12 0.0.3 → 0.0.5
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 +357 -3
- package/README.md +2 -2
- package/dist/index.cjs +365 -276
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +742 -230
- package/dist/index.d.ts +742 -230
- package/dist/index.mjs +357 -277
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -12,12 +12,35 @@ import { Buffer } from 'node:buffer';
|
|
|
12
12
|
* (see `test/warning-codes.snapshot.test.ts`). Phase 2+ extends, never
|
|
13
13
|
* renames.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* ## A warning message is built from this registry, never from the document
|
|
16
|
+
*
|
|
17
|
+
* This is the load-bearing PHI invariant of the library, and it is enforced
|
|
18
|
+
* structurally rather than by review: **no factory in this file takes a
|
|
19
|
+
* value parameter.** Every factory takes an {@link X12Position} plus, where
|
|
20
|
+
* one code covers more than one situation, a library-owned discriminant
|
|
21
|
+
* ({@link X12ControlNumberPair}, {@link X12UnexpectedSegmentContext},
|
|
22
|
+
* {@link X12BalanceInvariant}, {@link X12RequiredLoop}). `message` is a
|
|
23
|
+
* lookup into a frozen table, so it cannot interpolate anything a sender
|
|
24
|
+
* controls no matter what the input contains.
|
|
25
|
+
*
|
|
26
|
+
* That is a deliberate change of shape. Earlier versions shape-validated an
|
|
27
|
+
* echoed value against a spec grammar and substituted `(non-spec)` when it
|
|
28
|
+
* did not match. That held for the code-list slots and did NOT hold for the
|
|
29
|
+
* six envelope control numbers, whose grammar is "whatever the trading
|
|
30
|
+
* partner sent": a `X12_CONTROL_NUMBER_MISMATCH` echoed both sides verbatim
|
|
31
|
+
* and unbounded. A shape test is a filter somebody has to remember to
|
|
32
|
+
* apply; taking no value at all is a property of the type signature.
|
|
33
|
+
*
|
|
34
|
+
* The values themselves are never discarded. Every one of them is preserved
|
|
35
|
+
* verbatim on the model (`isa.elements`, `seg.raw`,
|
|
36
|
+
* `adjustment.reasonCode`, and so on), which is where a consumer that has
|
|
37
|
+
* decided it may handle PHI goes to read them. The diagnostic says *what*
|
|
38
|
+
* is wrong and *where*; the model says what the bytes were.
|
|
39
|
+
*
|
|
40
|
+
* `X12ParseError.snippet` on a **Tier-3 fatal** is the one deliberate
|
|
41
|
+
* exception in the library, and it is bounded to 64 characters. Warnings
|
|
42
|
+
* have no `snippet`, and a strict-mode escalation of a warning carries none
|
|
43
|
+
* either. See `KNOWN-LIMITATIONS.md`.
|
|
21
44
|
*/
|
|
22
45
|
|
|
23
46
|
/**
|
|
@@ -79,20 +102,163 @@ declare const WARNING_CODES: {
|
|
|
79
102
|
* ```
|
|
80
103
|
*/
|
|
81
104
|
type X12WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];
|
|
105
|
+
/**
|
|
106
|
+
* Which header/trailer control-number pair disagreed. A library-owned
|
|
107
|
+
* discriminant, NOT a value read out of the document: the useful part of
|
|
108
|
+
* the diagnostic is that the two disagree and where each one sits, never
|
|
109
|
+
* what either one says.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { controlNumberMismatch, CONTROL_NUMBER_PAIRS } from "@cosyte/x12";
|
|
114
|
+
* const w = controlNumberMismatch({ segmentIndex: 6 }, CONTROL_NUMBER_PAIRS.INTERCHANGE);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare const CONTROL_NUMBER_PAIRS: {
|
|
118
|
+
/** ISA-13 against IEA-02. */
|
|
119
|
+
readonly INTERCHANGE: "interchange";
|
|
120
|
+
/** GS-06 against GE-02. */
|
|
121
|
+
readonly GROUP: "group";
|
|
122
|
+
/** ST-02 against SE-02. */
|
|
123
|
+
readonly TRANSACTION: "transaction";
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* String-literal union over {@link CONTROL_NUMBER_PAIRS}.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* import type { X12ControlNumberPair } from "@cosyte/x12";
|
|
131
|
+
* const pair: X12ControlNumberPair = "group";
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
type X12ControlNumberPair = (typeof CONTROL_NUMBER_PAIRS)[keyof typeof CONTROL_NUMBER_PAIRS];
|
|
135
|
+
/**
|
|
136
|
+
* Which structural rule an out-of-place segment broke. A closed,
|
|
137
|
+
* library-owned set. The segment's own id is deliberately NOT part of it:
|
|
138
|
+
* a segment that is not where it belongs is exactly the case where its
|
|
139
|
+
* first element is arbitrary sender bytes rather than a spec name.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { unexpectedSegment, UNEXPECTED_SEGMENT_CONTEXTS } from "@cosyte/x12";
|
|
144
|
+
* const w = unexpectedSegment({ segmentIndex: 12 }, UNEXPECTED_SEGMENT_CONTEXTS.GE_WITHOUT_GS);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare const UNEXPECTED_SEGMENT_CONTEXTS: {
|
|
148
|
+
/** A `TA1` (envelope-level by spec) appeared inside an open functional group. */
|
|
149
|
+
readonly TA1_INSIDE_GROUP: "ta1-inside-group";
|
|
150
|
+
/** A `GE` appeared with no open `GS`. */
|
|
151
|
+
readonly GE_WITHOUT_GS: "ge-without-gs";
|
|
152
|
+
/** An `ST` appeared with no open functional group. */
|
|
153
|
+
readonly ST_WITHOUT_GS: "st-without-gs";
|
|
154
|
+
/** An `SE` appeared with no open transaction set. */
|
|
155
|
+
readonly SE_WITHOUT_ST: "se-without-st";
|
|
156
|
+
/** A body segment appeared outside any open transaction set. */
|
|
157
|
+
readonly BODY_OUTSIDE_TRANSACTION: "body-outside-transaction";
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* String-literal union over {@link UNEXPECTED_SEGMENT_CONTEXTS}.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* import type { X12UnexpectedSegmentContext } from "@cosyte/x12";
|
|
165
|
+
* const ctx: X12UnexpectedSegmentContext = "se-without-st";
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
type X12UnexpectedSegmentContext = (typeof UNEXPECTED_SEGMENT_CONTEXTS)[keyof typeof UNEXPECTED_SEGMENT_CONTEXTS];
|
|
169
|
+
/**
|
|
170
|
+
* Which 835 balance invariant failed. A library-owned discriminant naming
|
|
171
|
+
* the TR3 equation. The amounts on either side stay on the model as
|
|
172
|
+
* `X12Decimal` and are never rendered into the message: an EDI amount is a
|
|
173
|
+
* consumer-controlled element like any other, and a 300,000-digit "amount"
|
|
174
|
+
* would otherwise become a 300,000-byte diagnostic.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { remitBalanceMismatch, BALANCE_INVARIANTS } from "@cosyte/x12";
|
|
179
|
+
* const w = remitBalanceMismatch({ segmentIndex: 12 }, BALANCE_INVARIANTS.CLAIM);
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare const BALANCE_INVARIANTS: {
|
|
183
|
+
/** `CLP-04 + Σ(claim CAS + line CAS) == CLP-03`. */
|
|
184
|
+
readonly CLAIM: "claim";
|
|
185
|
+
/** `SVC-03 + Σ(line CAS) == SVC-02`. */
|
|
186
|
+
readonly SERVICE_LINE: "service-line";
|
|
187
|
+
/** `Σ(CLP-04) - Σ(PLB amounts) == BPR-02`. */
|
|
188
|
+
readonly REMIT_TOTAL: "remit-total";
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* String-literal union over {@link BALANCE_INVARIANTS}.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* import type { X12BalanceInvariant } from "@cosyte/x12";
|
|
196
|
+
* const which: X12BalanceInvariant = "service-line";
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
type X12BalanceInvariant = (typeof BALANCE_INVARIANTS)[keyof typeof BALANCE_INVARIANTS];
|
|
200
|
+
/**
|
|
201
|
+
* The TR3-required loops the parser reports as structurally absent. A
|
|
202
|
+
* closed set owned by the loop specs under `src/transactions/`, so both the
|
|
203
|
+
* loop id and its rationale are library constants rather than anything read
|
|
204
|
+
* out of the document.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* import { missingRequiredLoop, REQUIRED_LOOPS } from "@cosyte/x12";
|
|
209
|
+
* const w = missingRequiredLoop({ segmentIndex: 12 }, REQUIRED_LOOPS.PAYER_NAME_2010BB);
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare const REQUIRED_LOOPS: {
|
|
213
|
+
/** Loop 2000A, Billing Provider HL. */
|
|
214
|
+
readonly BILLING_PROVIDER_2000A: "2000A";
|
|
215
|
+
/** Loop 2000B, Subscriber HL. */
|
|
216
|
+
readonly SUBSCRIBER_2000B: "2000B";
|
|
217
|
+
/** Loop 2010BA, Subscriber Name. */
|
|
218
|
+
readonly SUBSCRIBER_NAME_2010BA: "2010BA";
|
|
219
|
+
/** Loop 2010BB, Payer Name. */
|
|
220
|
+
readonly PAYER_NAME_2010BB: "2010BB";
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* String-literal union over {@link REQUIRED_LOOPS}.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import type { X12RequiredLoop } from "@cosyte/x12";
|
|
228
|
+
* const loop: X12RequiredLoop = "2010BB";
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
type X12RequiredLoop = (typeof REQUIRED_LOOPS)[keyof typeof REQUIRED_LOOPS];
|
|
232
|
+
/**
|
|
233
|
+
* Every message string this library can put on a warning. Exported so a
|
|
234
|
+
* consumer, or a conformance gate, can assert set membership: if
|
|
235
|
+
* `ALL_WARNING_MESSAGES.has(w.message)` is ever false, something
|
|
236
|
+
* interpolated document bytes into a diagnostic.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* import { parseX12, ALL_WARNING_MESSAGES } from "@cosyte/x12";
|
|
241
|
+
* const ix = parseX12(raw);
|
|
242
|
+
* ix.warnings.every((w) => ALL_WARNING_MESSAGES.has(w.message)); // true, always
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare const ALL_WARNING_MESSAGES: ReadonlySet<string>;
|
|
82
246
|
/**
|
|
83
247
|
* Data shape for every Tier-2 warning emitted by the parser. Warnings are
|
|
84
248
|
* plain data (distinct from `X12ParseError`, which is a thrown `Error`
|
|
85
249
|
* subclass) so they can be safely accumulated on `X12Interchange.warnings`
|
|
86
250
|
* and passed to `onWarning` callbacks.
|
|
87
251
|
*
|
|
252
|
+
* `message` is always a member of {@link ALL_WARNING_MESSAGES}: it names
|
|
253
|
+
* the deviation, never the bytes that caused it. `position` says where to
|
|
254
|
+
* look and the bytes stay on the model. A warning has no `snippet`.
|
|
255
|
+
*
|
|
88
256
|
* @example
|
|
89
257
|
* ```ts
|
|
90
258
|
* import type { X12ParseWarning } from "@cosyte/x12";
|
|
91
|
-
* const w: X12ParseWarning
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* position: { segmentIndex: 0, interchangeIndex: 0, elementIndex: 12 },
|
|
95
|
-
* };
|
|
259
|
+
* declare const w: X12ParseWarning;
|
|
260
|
+
* w.code; // "X12_PRE_005010"
|
|
261
|
+
* w.position; // { segmentIndex: 0, interchangeIndex: 0, elementIndex: 12 }
|
|
96
262
|
* ```
|
|
97
263
|
*/
|
|
98
264
|
interface X12ParseWarning {
|
|
@@ -102,111 +268,101 @@ interface X12ParseWarning {
|
|
|
102
268
|
}
|
|
103
269
|
/**
|
|
104
270
|
* Build an `X12_CONTROL_NUMBER_MISMATCH` warning. Emitted when an
|
|
105
|
-
* envelope-trailer control number does not match its matching header
|
|
106
|
-
* ISA-13 ↔ IEA-02, GS-06 ↔ GE-02, or ST-02 ↔ SE-02.
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
271
|
+
* envelope-trailer control number does not match its matching header:
|
|
272
|
+
* ISA-13 ↔ IEA-02, GS-06 ↔ GE-02, or ST-02 ↔ SE-02.
|
|
273
|
+
*
|
|
274
|
+
* Neither side is echoed, not truncated and not hashed. A control number is
|
|
275
|
+
* free-form trading-partner text on five of the six slots (only ISA-13 is
|
|
276
|
+
* fixed-width), routinely carries a batch or patient-account identifier in
|
|
277
|
+
* the field, and is entirely sender-controlled. Read `isa.elements[13]`,
|
|
278
|
+
* `iea.elements[2]`, `gs.elements[6]`, `ge.elements[2]`, `st.elements[2]`
|
|
279
|
+
* and `se.elements[2]` off the model when you need the values.
|
|
110
280
|
*
|
|
111
281
|
* @example
|
|
112
282
|
* ```ts
|
|
113
|
-
* import { controlNumberMismatch } from "@cosyte/x12";
|
|
283
|
+
* import { controlNumberMismatch, CONTROL_NUMBER_PAIRS } from "@cosyte/x12";
|
|
114
284
|
* const w = controlNumberMismatch(
|
|
115
|
-
* { segmentIndex:
|
|
116
|
-
*
|
|
117
|
-
* "000000001",
|
|
118
|
-
* "000000002",
|
|
285
|
+
* { segmentIndex: 6, interchangeIndex: 0, elementIndex: 2 },
|
|
286
|
+
* CONTROL_NUMBER_PAIRS.INTERCHANGE,
|
|
119
287
|
* );
|
|
120
288
|
* ```
|
|
121
289
|
*/
|
|
122
|
-
declare function controlNumberMismatch(position: X12Position, pair:
|
|
290
|
+
declare function controlNumberMismatch(position: X12Position, pair: X12ControlNumberPair): X12ParseWarning;
|
|
123
291
|
/**
|
|
124
|
-
* Build an `X12_PRE_005010` warning. Emitted when ISA-12 declares
|
|
125
|
-
*
|
|
292
|
+
* Build an `X12_PRE_005010` warning. Emitted when ISA-12 declares any version
|
|
293
|
+
* other than `00501`, the HIPAA-mandated baseline. The code name reads as a
|
|
294
|
+
* "pre-005010" test and the guard is an inequality, so a LATER family
|
|
295
|
+
* (`00602`, `00700`) raises it too. The parser still
|
|
126
296
|
* accepts the input (Postel's Law: lenient on parse) but flags the
|
|
127
297
|
* mismatch so consumers know the input may diverge from 005010 semantics.
|
|
298
|
+
* The declared version stays on `isa.elements[12]`.
|
|
128
299
|
*
|
|
129
300
|
* @example
|
|
130
301
|
* ```ts
|
|
131
302
|
* import { pre005010 } from "@cosyte/x12";
|
|
132
|
-
* const w = pre005010({ segmentIndex: 0, interchangeIndex: 0, elementIndex: 12 }
|
|
303
|
+
* const w = pre005010({ segmentIndex: 0, interchangeIndex: 0, elementIndex: 12 });
|
|
133
304
|
* ```
|
|
134
305
|
*/
|
|
135
|
-
declare function pre005010(position: X12Position
|
|
306
|
+
declare function pre005010(position: X12Position): X12ParseWarning;
|
|
136
307
|
/**
|
|
137
308
|
* Build an `X12_GROUP_COUNT_MISMATCH` warning. Emitted when IEA-01 does not
|
|
138
309
|
* equal the actual number of GS..GE groups present in the interchange.
|
|
139
|
-
* Trading partners use this to detect transmission truncation
|
|
140
|
-
*
|
|
310
|
+
* Trading partners use this to detect transmission truncation. Both numbers
|
|
311
|
+
* stay on the model (`iea.elements[1]` and `ix.groups.length`) and neither
|
|
312
|
+
* is silently corrected.
|
|
141
313
|
*
|
|
142
314
|
* @example
|
|
143
315
|
* ```ts
|
|
144
316
|
* import { groupCountMismatch } from "@cosyte/x12";
|
|
145
|
-
* const w = groupCountMismatch(
|
|
146
|
-
* { segmentIndex: 5, interchangeIndex: 0, elementIndex: 1 },
|
|
147
|
-
* "2",
|
|
148
|
-
* 1,
|
|
149
|
-
* );
|
|
317
|
+
* const w = groupCountMismatch({ segmentIndex: 5, interchangeIndex: 0, elementIndex: 1 });
|
|
150
318
|
* ```
|
|
151
319
|
*/
|
|
152
|
-
declare function groupCountMismatch(position: X12Position
|
|
320
|
+
declare function groupCountMismatch(position: X12Position): X12ParseWarning;
|
|
153
321
|
/**
|
|
154
322
|
* Build an `X12_TRANSACTION_COUNT_MISMATCH` warning. Emitted when GE-01
|
|
155
323
|
* does not equal the actual number of ST..SE transaction sets present in
|
|
156
|
-
* the group.
|
|
157
|
-
*
|
|
324
|
+
* the group. Both numbers stay on the model (`ge.elements[1]` and
|
|
325
|
+
* `group.transactions.length`).
|
|
158
326
|
*
|
|
159
327
|
* @example
|
|
160
328
|
* ```ts
|
|
161
329
|
* import { transactionCountMismatch } from "@cosyte/x12";
|
|
162
|
-
* const w = transactionCountMismatch(
|
|
163
|
-
* { segmentIndex: 4, interchangeIndex: 0, groupIndex: 0, elementIndex: 1 },
|
|
164
|
-
* "3",
|
|
165
|
-
* 2,
|
|
166
|
-
* );
|
|
330
|
+
* const w = transactionCountMismatch({ segmentIndex: 4, groupIndex: 0, elementIndex: 1 });
|
|
167
331
|
* ```
|
|
168
332
|
*/
|
|
169
|
-
declare function transactionCountMismatch(position: X12Position
|
|
333
|
+
declare function transactionCountMismatch(position: X12Position): X12ParseWarning;
|
|
170
334
|
/**
|
|
171
335
|
* Build an `X12_SEGMENT_COUNT_MISMATCH` warning. Emitted by the spec-clean
|
|
172
336
|
* serializer when an SE-01 value does not equal the actual number of
|
|
173
|
-
* segments in the transaction set it closes (ST through SE inclusive).
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* Phase-8 serializer diagnostic.
|
|
337
|
+
* segments in the transaction set it closes (ST through SE inclusive).
|
|
338
|
+
* Corrected counts are emitted only on `serializeX12(ix, { specClean: true,
|
|
339
|
+
* recomputeCounts: true })`. The parser does not emit this code (it leaves
|
|
340
|
+
* SE-01 reconciliation to the emit half); it is a Phase-8 serializer
|
|
341
|
+
* diagnostic.
|
|
179
342
|
*
|
|
180
343
|
* @example
|
|
181
344
|
* ```ts
|
|
182
345
|
* import { segmentCountMismatch } from "@cosyte/x12";
|
|
183
|
-
* const w = segmentCountMismatch(
|
|
184
|
-
* { segmentIndex: 2, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0, elementIndex: 1 },
|
|
185
|
-
* "6",
|
|
186
|
-
* 7,
|
|
187
|
-
* );
|
|
346
|
+
* const w = segmentCountMismatch({ segmentIndex: 2, transactionIndex: 0, elementIndex: 1 });
|
|
188
347
|
* ```
|
|
189
348
|
*/
|
|
190
|
-
declare function segmentCountMismatch(position: X12Position
|
|
349
|
+
declare function segmentCountMismatch(position: X12Position): X12ParseWarning;
|
|
191
350
|
/**
|
|
192
351
|
* Build an `X12_TRAILING_GARBAGE` warning. Emitted when non-empty bytes
|
|
193
352
|
* appear after the IEA segment terminator and any optional CRLF. The bytes
|
|
194
353
|
* are preserved verbatim on {@link
|
|
195
|
-
* "./types.js".X12Interchange}.`trailingBytes` so consumers can inspect
|
|
196
|
-
* re-emit them. Common cause: a second interchange concatenated
|
|
197
|
-
* same file (multi-ISA
|
|
198
|
-
* decoded).
|
|
354
|
+
* "./types.js".X12Interchange}.`trailingBytes` so consumers can inspect,
|
|
355
|
+
* measure, or re-emit them. Common cause: a second interchange concatenated
|
|
356
|
+
* into the same file (multi-ISA, out of v1 scope; only the first
|
|
357
|
+
* interchange is decoded).
|
|
199
358
|
*
|
|
200
359
|
* @example
|
|
201
360
|
* ```ts
|
|
202
361
|
* import { trailingGarbage } from "@cosyte/x12";
|
|
203
|
-
* const w = trailingGarbage(
|
|
204
|
-
* { segmentIndex: 6, interchangeIndex: 0 },
|
|
205
|
-
* 42,
|
|
206
|
-
* );
|
|
362
|
+
* const w = trailingGarbage({ segmentIndex: 6, interchangeIndex: 0 });
|
|
207
363
|
* ```
|
|
208
364
|
*/
|
|
209
|
-
declare function trailingGarbage(position: X12Position
|
|
365
|
+
declare function trailingGarbage(position: X12Position): X12ParseWarning;
|
|
210
366
|
/**
|
|
211
367
|
* Build an `X12_MISSING_IEA` warning. Emitted when the input opened a
|
|
212
368
|
* valid ISA but EOF arrived before any IEA segment. The parser returns the
|
|
@@ -242,12 +398,7 @@ declare function missingGe(position: X12Position): X12ParseWarning;
|
|
|
242
398
|
* @example
|
|
243
399
|
* ```ts
|
|
244
400
|
* import { missingSe } from "@cosyte/x12";
|
|
245
|
-
* const w = missingSe({
|
|
246
|
-
* segmentIndex: 2,
|
|
247
|
-
* interchangeIndex: 0,
|
|
248
|
-
* groupIndex: 0,
|
|
249
|
-
* transactionIndex: 0,
|
|
250
|
-
* });
|
|
401
|
+
* const w = missingSe({ segmentIndex: 2, groupIndex: 0, transactionIndex: 0 });
|
|
251
402
|
* ```
|
|
252
403
|
*/
|
|
253
404
|
declare function missingSe(position: X12Position): X12ParseWarning;
|
|
@@ -268,249 +419,197 @@ declare function missingSe(position: X12Position): X12ParseWarning;
|
|
|
268
419
|
declare function danglingReleaseChar(position: X12Position): X12ParseWarning;
|
|
269
420
|
/**
|
|
270
421
|
* Build an `X12_UNEXPECTED_SEGMENT` warning. Emitted when a structurally
|
|
271
|
-
* meaningful
|
|
272
|
-
* its expected parent
|
|
273
|
-
* `
|
|
274
|
-
*
|
|
275
|
-
* it matches the X12 segment-id grammar - otherwise the literal
|
|
276
|
-
* `(non-spec)` is substituted to avoid echoing arbitrary bytes / PHI) and
|
|
277
|
-
* its global segment index so a consumer can locate the deviation.
|
|
422
|
+
* meaningful segment (`GE`, `SE`, `ST`, `TA1`, or a body segment) appears
|
|
423
|
+
* outside its expected parent. The parser preserves lenient-never-throw and
|
|
424
|
+
* continues; `context` names which structural rule broke and `position`
|
|
425
|
+
* locates the segment.
|
|
278
426
|
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
427
|
+
* The segment's own id is deliberately not a parameter. Note that a segment
|
|
428
|
+
* in one of these positions is NOT retained on the model at all (it has no
|
|
429
|
+
* open container to belong to), so `position.segmentIndex` against the input
|
|
430
|
+
* is the only way back to its bytes. For a segment that IS retained, the
|
|
431
|
+
* `X12Segment.id` a consumer reads is bounded to the X12 segment-id grammar
|
|
432
|
+
* (see {@link "./segment.js".decodeSegment}) while `seg.raw` and
|
|
433
|
+
* `seg.elements[0]` stay verbatim.
|
|
285
434
|
*
|
|
286
435
|
* @example
|
|
287
436
|
* ```ts
|
|
288
|
-
* import { unexpectedSegment } from "@cosyte/x12";
|
|
437
|
+
* import { unexpectedSegment, UNEXPECTED_SEGMENT_CONTEXTS } from "@cosyte/x12";
|
|
289
438
|
* const w = unexpectedSegment(
|
|
290
439
|
* { segmentIndex: 12, interchangeIndex: 0 },
|
|
291
|
-
*
|
|
292
|
-
* "no open functional group",
|
|
440
|
+
* UNEXPECTED_SEGMENT_CONTEXTS.GE_WITHOUT_GS,
|
|
293
441
|
* );
|
|
294
442
|
* ```
|
|
295
443
|
*/
|
|
296
|
-
declare function unexpectedSegment(position: X12Position,
|
|
444
|
+
declare function unexpectedSegment(position: X12Position, context: X12UnexpectedSegmentContext): X12ParseWarning;
|
|
297
445
|
/**
|
|
298
446
|
* Build an `X12_835_REMIT_BALANCE_MISMATCH` warning. Emitted by the 835
|
|
299
|
-
* helper when a balance invariant fails
|
|
300
|
-
*
|
|
301
|
-
*
|
|
447
|
+
* helper when a TR3 X221A1 §1.10.2 balance invariant fails. `invariant`
|
|
448
|
+
* names which equation broke; the spec'd, computed and delta amounts stay
|
|
449
|
+
* on the model as {@link "../decimal.js".X12Decimal} values and are never
|
|
450
|
+
* rendered into the message.
|
|
302
451
|
*
|
|
303
|
-
* The
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* echoes patient identifiers, member ids, names, account numbers, or any
|
|
307
|
-
* other PHI-shaped value - mirrors the H-PHI invariant from `@cosyte/hl7`.
|
|
308
|
-
* The parser ALWAYS surfaces this and NEVER silently rebalances.
|
|
452
|
+
* The parser ALWAYS surfaces this and NEVER silently rebalances. To report
|
|
453
|
+
* the numbers, recompute them from the model: `claim.totalChargeAmount`,
|
|
454
|
+
* `claim.totalPaymentAmount` and the CAS adjustments are all present.
|
|
309
455
|
*
|
|
310
456
|
* @example
|
|
311
457
|
* ```ts
|
|
312
|
-
* import { remitBalanceMismatch } from "@cosyte/x12";
|
|
458
|
+
* import { remitBalanceMismatch, BALANCE_INVARIANTS } from "@cosyte/x12";
|
|
313
459
|
* const w = remitBalanceMismatch(
|
|
314
|
-
* { segmentIndex: 12,
|
|
315
|
-
*
|
|
316
|
-
* "500.00",
|
|
317
|
-
* "499.99",
|
|
318
|
-
* "0.01",
|
|
460
|
+
* { segmentIndex: 12, groupIndex: 0, transactionIndex: 0 },
|
|
461
|
+
* BALANCE_INVARIANTS.CLAIM,
|
|
319
462
|
* );
|
|
320
463
|
* ```
|
|
321
464
|
*/
|
|
322
|
-
declare function remitBalanceMismatch(position: X12Position, invariant:
|
|
465
|
+
declare function remitBalanceMismatch(position: X12Position, invariant: X12BalanceInvariant): X12ParseWarning;
|
|
323
466
|
/**
|
|
324
467
|
* Build an `X12_UNKNOWN_CARC` warning. Emitted when a CAS adjustment
|
|
325
468
|
* carries a CARC code outside the bundled snapshot (see
|
|
326
|
-
* {@link "../code-lists/carc.js".CARC}). The verbatim code is
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* echoing in the message; a hostile non-conformant value collapses to
|
|
330
|
-
* the literal `(non-spec)` so the parser never echoes arbitrary bytes
|
|
331
|
-
* (H-PHI invariant).
|
|
469
|
+
* {@link "../code-lists/carc.js".CARC}). The verbatim code is preserved on
|
|
470
|
+
* the parsed adjustment (`adjustment.reasonCode`); only the description is
|
|
471
|
+
* missing.
|
|
332
472
|
*
|
|
333
473
|
* @example
|
|
334
474
|
* ```ts
|
|
335
475
|
* import { unknownCarc } from "@cosyte/x12";
|
|
336
|
-
* const w = unknownCarc(
|
|
337
|
-
* { segmentIndex: 14, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
338
|
-
* "9999",
|
|
339
|
-
* );
|
|
476
|
+
* const w = unknownCarc({ segmentIndex: 14, groupIndex: 0, transactionIndex: 0 });
|
|
340
477
|
* ```
|
|
341
478
|
*/
|
|
342
|
-
declare function unknownCarc(position: X12Position
|
|
479
|
+
declare function unknownCarc(position: X12Position): X12ParseWarning;
|
|
343
480
|
/**
|
|
344
481
|
* Build an `X12_UNKNOWN_RARC` warning. Companion to {@link unknownCarc}
|
|
345
|
-
* for RARC codes on `MIA` / `MOA` / `LQ` / `NTE`. Same
|
|
346
|
-
*
|
|
482
|
+
* for RARC codes on `MIA` / `MOA` / `LQ` / `NTE`. Same verbatim-preserve
|
|
483
|
+
* posture; the code lives on the parsed remark.
|
|
347
484
|
*
|
|
348
485
|
* @example
|
|
349
486
|
* ```ts
|
|
350
487
|
* import { unknownRarc } from "@cosyte/x12";
|
|
351
|
-
* const w = unknownRarc(
|
|
352
|
-
* { segmentIndex: 16, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
353
|
-
* "ZZZZZ",
|
|
354
|
-
* );
|
|
488
|
+
* const w = unknownRarc({ segmentIndex: 16, groupIndex: 0, transactionIndex: 0 });
|
|
355
489
|
* ```
|
|
356
490
|
*/
|
|
357
|
-
declare function unknownRarc(position: X12Position
|
|
491
|
+
declare function unknownRarc(position: X12Position): X12ParseWarning;
|
|
358
492
|
/**
|
|
359
|
-
* Build an `X12_HL_PARENT_MISMATCH` warning. Emitted
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* the
|
|
493
|
+
* Build an `X12_HL_PARENT_MISMATCH` warning. Emitted when an HL segment's
|
|
494
|
+
* HL-02 (parent id) does not match any earlier-emitted HL-01 in the same
|
|
495
|
+
* transaction. The walker NEVER silently re-numbers the hierarchy (HL
|
|
496
|
+
* parent-pointer integrity is the safety primitive of the 837), so the
|
|
497
|
+
* declared pointer stays verbatim on `hierarchy.parentHlId` and the warning
|
|
498
|
+
* reports only that the pointer is dangling, and where.
|
|
365
499
|
*
|
|
366
500
|
* @example
|
|
367
501
|
* ```ts
|
|
368
502
|
* import { hlParentMismatch } from "@cosyte/x12";
|
|
369
|
-
* const w = hlParentMismatch(
|
|
370
|
-
* { segmentIndex: 14, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
371
|
-
* "3",
|
|
372
|
-
* "9",
|
|
373
|
-
* );
|
|
503
|
+
* const w = hlParentMismatch({ segmentIndex: 14, groupIndex: 0, transactionIndex: 0 });
|
|
374
504
|
* ```
|
|
375
505
|
*/
|
|
376
|
-
declare function hlParentMismatch(position: X12Position
|
|
506
|
+
declare function hlParentMismatch(position: X12Position): X12ParseWarning;
|
|
377
507
|
/**
|
|
378
508
|
* Build an `X12_HL_PARENT_LEVEL_INVALID` warning. Emitted when an HL's
|
|
379
|
-
* level code (HL-03) is inconsistent with its declared parent's level
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
509
|
+
* level code (HL-03) is inconsistent with its declared parent's level code
|
|
510
|
+
* per the TR3 (e.g. a `22` Subscriber claiming a `22` Subscriber as its
|
|
511
|
+
* parent, where the parent must be `20` Information Source). Both level
|
|
512
|
+
* codes stay verbatim on the model.
|
|
383
513
|
*
|
|
384
514
|
* @example
|
|
385
515
|
* ```ts
|
|
386
516
|
* import { hlParentLevelInvalid } from "@cosyte/x12";
|
|
387
|
-
* const w = hlParentLevelInvalid(
|
|
388
|
-
* { segmentIndex: 14, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
389
|
-
* "3",
|
|
390
|
-
* "23",
|
|
391
|
-
* "2",
|
|
392
|
-
* "22",
|
|
393
|
-
* "20",
|
|
394
|
-
* );
|
|
517
|
+
* const w = hlParentLevelInvalid({ segmentIndex: 14, groupIndex: 0, transactionIndex: 0 });
|
|
395
518
|
* ```
|
|
396
519
|
*/
|
|
397
|
-
declare function hlParentLevelInvalid(position: X12Position
|
|
520
|
+
declare function hlParentLevelInvalid(position: X12Position): X12ParseWarning;
|
|
398
521
|
/**
|
|
399
|
-
* Build an `X12_UNKNOWN_HI_QUALIFIER` warning. Emitted by the 837
|
|
400
|
-
* when an HI composite's qualifier (first component) is outside the
|
|
522
|
+
* Build an `X12_UNKNOWN_HI_QUALIFIER` warning. Emitted by the 837 / 278
|
|
523
|
+
* helpers when an HI composite's qualifier (first component) is outside the
|
|
401
524
|
* bundled snapshot at {@link "../code-lists/hi-qualifiers.js".
|
|
402
|
-
* HI_QUALIFIERS}. The verbatim code
|
|
403
|
-
* diagnosis/procedure with `codeSystem: "unknown"` so consumers
|
|
404
|
-
* still react.
|
|
405
|
-
* invariant.
|
|
525
|
+
* HI_QUALIFIERS}. The verbatim qualifier and code are preserved on the
|
|
526
|
+
* parsed diagnosis / procedure with `codeSystem: "unknown"` so consumers
|
|
527
|
+
* can still react.
|
|
406
528
|
*
|
|
407
529
|
* @example
|
|
408
530
|
* ```ts
|
|
409
531
|
* import { unknownHiQualifier } from "@cosyte/x12";
|
|
410
|
-
* const w = unknownHiQualifier(
|
|
411
|
-
* { segmentIndex: 25, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
412
|
-
* "ZZZ",
|
|
413
|
-
* );
|
|
532
|
+
* const w = unknownHiQualifier({ segmentIndex: 25, groupIndex: 0, transactionIndex: 0 });
|
|
414
533
|
* ```
|
|
415
534
|
*/
|
|
416
|
-
declare function unknownHiQualifier(position: X12Position
|
|
535
|
+
declare function unknownHiQualifier(position: X12Position): X12ParseWarning;
|
|
417
536
|
/**
|
|
418
537
|
* Build an `X12_MISSING_REQUIRED_LOOP` warning. Emitted when a TR3-required
|
|
419
538
|
* loop is structurally absent (e.g. no Loop 2010BB Payer Name inside a
|
|
420
|
-
* Subscriber HL). The parser does not enforce situational rules
|
|
421
|
-
*
|
|
422
|
-
*
|
|
539
|
+
* Subscriber HL). The parser does not enforce situational rules: only loops
|
|
540
|
+
* marked `usage: "required"` in the loop spec fire this warning, so the
|
|
541
|
+
* loop id and its rationale are both library constants.
|
|
423
542
|
*
|
|
424
543
|
* @example
|
|
425
544
|
* ```ts
|
|
426
|
-
* import { missingRequiredLoop } from "@cosyte/x12";
|
|
545
|
+
* import { missingRequiredLoop, REQUIRED_LOOPS } from "@cosyte/x12";
|
|
427
546
|
* const w = missingRequiredLoop(
|
|
428
|
-
* { segmentIndex: 12,
|
|
429
|
-
*
|
|
430
|
-
* "Loop 2010BB Payer Name required when Loop 2000B (Subscriber HL) is present",
|
|
547
|
+
* { segmentIndex: 12, groupIndex: 0, transactionIndex: 0 },
|
|
548
|
+
* REQUIRED_LOOPS.PAYER_NAME_2010BB,
|
|
431
549
|
* );
|
|
432
550
|
* ```
|
|
433
551
|
*/
|
|
434
|
-
declare function missingRequiredLoop(position: X12Position,
|
|
552
|
+
declare function missingRequiredLoop(position: X12Position, loop: X12RequiredLoop): X12ParseWarning;
|
|
435
553
|
/**
|
|
436
554
|
* Build an `X12_837_UNKNOWN_VARIANT` warning. Emitted when the 837 helper
|
|
437
555
|
* cannot resolve the variant from ST-03's implementation-convention
|
|
438
556
|
* reference AND no SVx service-line segment is present to fall back on.
|
|
439
|
-
* The parsed submission still ships with `variant: "unknown"
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
557
|
+
* The parsed submission still ships with `variant: "unknown"` and the
|
|
558
|
+
* verbatim reference on `submission.implementationConventionReference`; the
|
|
559
|
+
* walker does its best on shared structure (envelope, HL, claim header) and
|
|
560
|
+
* skips variant-specific service-line decoding.
|
|
443
561
|
*
|
|
444
562
|
* @example
|
|
445
563
|
* ```ts
|
|
446
564
|
* import { unknown837Variant } from "@cosyte/x12";
|
|
447
|
-
* const w = unknown837Variant(
|
|
448
|
-
* { segmentIndex: 1, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
449
|
-
* "005010X999",
|
|
450
|
-
* );
|
|
565
|
+
* const w = unknown837Variant({ segmentIndex: 1, groupIndex: 0, transactionIndex: 0 });
|
|
451
566
|
* ```
|
|
452
567
|
*/
|
|
453
|
-
declare function unknown837Variant(position: X12Position
|
|
568
|
+
declare function unknown837Variant(position: X12Position): X12ParseWarning;
|
|
454
569
|
/**
|
|
455
570
|
* Build an `X12_UNKNOWN_CLAIM_STATUS_CATEGORY` warning. Emitted by the 277
|
|
456
571
|
* / 277CA helpers when an STC composite's Claim Status Category Code
|
|
457
|
-
* (CSCC, first component) is outside the bundled
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* the parsed status - only the description is missing. The code value is
|
|
461
|
-
* shape-validated against the CSCC grammar before echoing; a hostile
|
|
462
|
-
* non-conformant value collapses to the literal `(non-spec)` so the
|
|
463
|
-
* parser never echoes arbitrary bytes (H-PHI invariant).
|
|
572
|
+
* (CSCC, first component; X12 code source 507) is outside the bundled
|
|
573
|
+
* snapshot. The verbatim CSCC is preserved on the parsed status; only the
|
|
574
|
+
* description is missing.
|
|
464
575
|
*
|
|
465
576
|
* @example
|
|
466
577
|
* ```ts
|
|
467
578
|
* import { unknownClaimStatusCategory } from "@cosyte/x12";
|
|
468
|
-
* const w = unknownClaimStatusCategory(
|
|
469
|
-
* { segmentIndex: 18, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
470
|
-
* "Z9",
|
|
471
|
-
* );
|
|
579
|
+
* const w = unknownClaimStatusCategory({ segmentIndex: 18, transactionIndex: 0 });
|
|
472
580
|
* ```
|
|
473
581
|
*/
|
|
474
|
-
declare function unknownClaimStatusCategory(position: X12Position
|
|
582
|
+
declare function unknownClaimStatusCategory(position: X12Position): X12ParseWarning;
|
|
475
583
|
/**
|
|
476
584
|
* Build an `X12_UNKNOWN_CLAIM_STATUS` warning. Companion to
|
|
477
585
|
* {@link unknownClaimStatusCategory} for the Claim Status Code (CSC, the
|
|
478
586
|
* second component of an STC composite; X12 code source 508). Same
|
|
479
|
-
*
|
|
480
|
-
* `[A-Z0-9]{1,5}` value grammar (CSCs are short numeric tokens).
|
|
587
|
+
* verbatim-preserve posture.
|
|
481
588
|
*
|
|
482
589
|
* @example
|
|
483
590
|
* ```ts
|
|
484
591
|
* import { unknownClaimStatus } from "@cosyte/x12";
|
|
485
|
-
* const w = unknownClaimStatus(
|
|
486
|
-
* { segmentIndex: 18, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
487
|
-
* "99999",
|
|
488
|
-
* );
|
|
592
|
+
* const w = unknownClaimStatus({ segmentIndex: 18, transactionIndex: 0 });
|
|
489
593
|
* ```
|
|
490
594
|
*/
|
|
491
|
-
declare function unknownClaimStatus(position: X12Position
|
|
595
|
+
declare function unknownClaimStatus(position: X12Position): X12ParseWarning;
|
|
492
596
|
/**
|
|
493
597
|
* Build an `X12_834_UNKNOWN_MAINTENANCE_TYPE` warning. Emitted by the 834
|
|
494
598
|
* helper when a member-level `INS-03` (or a health-coverage `HD-01`)
|
|
495
599
|
* maintenance type code falls outside the bundled snapshot (see
|
|
496
600
|
* {@link "../code-lists/maintenance-type.js".MAINTENANCE_TYPE_CODES}).
|
|
497
|
-
* Maintenance type is the 834's safety-critical field
|
|
601
|
+
* Maintenance type is the 834's safety-critical field: an unknown action
|
|
498
602
|
* code must NEVER be silently coerced to add / change / terminate, so the
|
|
499
603
|
* verbatim code is preserved on the parsed enrollment and this warning
|
|
500
|
-
* flags the gap.
|
|
501
|
-
* before echoing; a hostile non-conformant value collapses to the literal
|
|
502
|
-
* `(non-spec)` (H-PHI invariant).
|
|
604
|
+
* flags the gap.
|
|
503
605
|
*
|
|
504
606
|
* @example
|
|
505
607
|
* ```ts
|
|
506
608
|
* import { unknownMaintenanceType } from "@cosyte/x12";
|
|
507
|
-
* const w = unknownMaintenanceType(
|
|
508
|
-
* { segmentIndex: 9, interchangeIndex: 0, groupIndex: 0, transactionIndex: 0 },
|
|
509
|
-
* "999",
|
|
510
|
-
* );
|
|
609
|
+
* const w = unknownMaintenanceType({ segmentIndex: 9, transactionIndex: 0 });
|
|
511
610
|
* ```
|
|
512
611
|
*/
|
|
513
|
-
declare function unknownMaintenanceType(position: X12Position
|
|
612
|
+
declare function unknownMaintenanceType(position: X12Position): X12ParseWarning;
|
|
514
613
|
|
|
515
614
|
/**
|
|
516
615
|
* Type definitions for the `@cosyte/x12` profile subsystem (Phase 9).
|
|
@@ -961,6 +1060,21 @@ interface X12Segment {
|
|
|
961
1060
|
readonly raw: string;
|
|
962
1061
|
readonly elements: readonly string[];
|
|
963
1062
|
}
|
|
1063
|
+
/**
|
|
1064
|
+
* The value {@link X12Segment.id} takes when the first element does not
|
|
1065
|
+
* match the X12 segment-id grammar. Not a valid segment id, so it can
|
|
1066
|
+
* never collide with a real one in a `seg.id === "NM1"` comparison.
|
|
1067
|
+
*
|
|
1068
|
+
* @example
|
|
1069
|
+
* ```ts
|
|
1070
|
+
* import { parseX12, NON_SPEC_SEGMENT_ID } from "@cosyte/x12";
|
|
1071
|
+
* const seg = parseX12(raw).groups[0]?.transactions[0]?.segments[1];
|
|
1072
|
+
* if (seg?.id === NON_SPEC_SEGMENT_ID) {
|
|
1073
|
+
* // the sender's "segment" name is not a spec segment id; its bytes are on seg.raw
|
|
1074
|
+
* }
|
|
1075
|
+
* ```
|
|
1076
|
+
*/
|
|
1077
|
+
declare const NON_SPEC_SEGMENT_ID = "(non-spec)";
|
|
964
1078
|
/**
|
|
965
1079
|
* Decode a raw segment string into an {@link X12Segment}. Splits on the
|
|
966
1080
|
* detected element separator (honouring the `?`-release-character escape),
|
|
@@ -1378,14 +1492,173 @@ interface X12FunctionalGroup {
|
|
|
1378
1492
|
readonly ge: GeSegment | undefined;
|
|
1379
1493
|
readonly transactions: readonly X12TransactionSet[];
|
|
1380
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Where an orphan sat in the STRUCTURE of the interchange, as opposed to
|
|
1497
|
+
* where it sat in the input byte stream. This is what lets `serializeX12`
|
|
1498
|
+
* put an orphan back without guessing.
|
|
1499
|
+
*
|
|
1500
|
+
* `X12OrphanSegment.segmentIndex` cannot do that job. It indexes the INPUT
|
|
1501
|
+
* stream, and the emit is not in input order: `ta1Segments` are hoisted ahead
|
|
1502
|
+
* of the groups, and a doubled terminator's zero-length segment occupies an
|
|
1503
|
+
* input index that is never emitted. Either one shifts the output's indices
|
|
1504
|
+
* away from the input's, so replaying by index splices the orphan into
|
|
1505
|
+
* whatever occupies that slot - measurably, into an 835's `ST..SE` body,
|
|
1506
|
+
* where a re-parse reports nothing. An anchor names a slot in the typed tree
|
|
1507
|
+
* instead, which survives both reorderings because it does not mention bytes.
|
|
1508
|
+
*
|
|
1509
|
+
* Three kinds, one per structural level:
|
|
1510
|
+
*
|
|
1511
|
+
* - **`"interchange"`** - between the ISA and the IEA but outside every
|
|
1512
|
+
* functional group. `groupIndex` is the number of groups that had already
|
|
1513
|
+
* closed, so the orphan is emitted immediately before `ix.groups[groupIndex]`
|
|
1514
|
+
* (or before the IEA when `groupIndex === ix.groups.length`).
|
|
1515
|
+
* - **`"group"`** - inside `ix.groups[groupIndex]` but outside every
|
|
1516
|
+
* transaction set in it. `transactionIndex` is the number of transactions
|
|
1517
|
+
* that had already closed, so the orphan is emitted immediately before that
|
|
1518
|
+
* group's `transactions[transactionIndex]` (or before its `GE` when
|
|
1519
|
+
* `transactionIndex === transactions.length`).
|
|
1520
|
+
* - **`"transaction"`** - inside an open `ST..SE`, which only a `TA1` can be,
|
|
1521
|
+
* since every other segment arriving there is body content. `segmentOffset`
|
|
1522
|
+
* is the number of `rawSegments` already collected, so the orphan is emitted
|
|
1523
|
+
* immediately before `rawSegments[segmentOffset]`. It is never `0` (the `ST`
|
|
1524
|
+
* is always `rawSegments[0]`) and never exceeds `rawSegments.length`. Such an
|
|
1525
|
+
* orphan is written back BETWEEN the `ST` and the `SE`, so `serializeX12`
|
|
1526
|
+
* counts it toward SE-01 in spec-clean mode even though it is not on
|
|
1527
|
+
* `tx.rawSegments` - it is a segment of that transaction set per X12.6.
|
|
1528
|
+
*
|
|
1529
|
+
* **An anchor is a POSITION, so reshaping the model invalidates it.** The
|
|
1530
|
+
* indices address `ix.groups`, that group's `transactions`, and that
|
|
1531
|
+
* transaction's `rawSegments` as they stand on the interchange you pass to
|
|
1532
|
+
* `serializeX12`. Filter or reorder any of those and an orphan's anchor may
|
|
1533
|
+
* still resolve while naming a different slot, and it will be emitted there
|
|
1534
|
+
* with no warning. An anchor that resolves to nothing is emitted at
|
|
1535
|
+
* interchange level before the IEA rather than dropped. Re-parse rather than
|
|
1536
|
+
* hand-edit if you need anchors to stay meaningful.
|
|
1537
|
+
*
|
|
1538
|
+
* @example
|
|
1539
|
+
* ```ts
|
|
1540
|
+
* import { parseX12 } from "@cosyte/x12";
|
|
1541
|
+
* const ix = parseX12(raw);
|
|
1542
|
+
* for (const o of ix.orphanSegments) {
|
|
1543
|
+
* if (o.anchor.kind === "group") console.warn(o.anchor.groupIndex);
|
|
1544
|
+
* }
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
type X12OrphanAnchor = {
|
|
1548
|
+
readonly kind: "interchange";
|
|
1549
|
+
/** How many functional groups had closed before this segment arrived. */
|
|
1550
|
+
readonly groupIndex: number;
|
|
1551
|
+
} | {
|
|
1552
|
+
readonly kind: "group";
|
|
1553
|
+
/** Index into `ix.groups` of the group that was open. */
|
|
1554
|
+
readonly groupIndex: number;
|
|
1555
|
+
/** How many transaction sets in that group had closed. */
|
|
1556
|
+
readonly transactionIndex: number;
|
|
1557
|
+
} | {
|
|
1558
|
+
readonly kind: "transaction";
|
|
1559
|
+
/** Index into `ix.groups` of the group that was open. */
|
|
1560
|
+
readonly groupIndex: number;
|
|
1561
|
+
/** Index into that group's `transactions` of the set that was open. */
|
|
1562
|
+
readonly transactionIndex: number;
|
|
1563
|
+
/** How many of that set's `rawSegments` had been collected. */
|
|
1564
|
+
readonly segmentOffset: number;
|
|
1565
|
+
};
|
|
1566
|
+
/**
|
|
1567
|
+
* String-literal union over the `kind` discriminant of {@link X12OrphanAnchor}.
|
|
1568
|
+
*
|
|
1569
|
+
* @example
|
|
1570
|
+
* ```ts
|
|
1571
|
+
* import type { X12OrphanAnchorKind } from "@cosyte/x12";
|
|
1572
|
+
* const kind: X12OrphanAnchorKind = "transaction";
|
|
1573
|
+
* ```
|
|
1574
|
+
*/
|
|
1575
|
+
type X12OrphanAnchorKind = X12OrphanAnchor["kind"];
|
|
1576
|
+
/**
|
|
1577
|
+
* A segment the envelope grammar has no place for, captured verbatim rather
|
|
1578
|
+
* than discarded. Every segment recorded here also raised exactly one
|
|
1579
|
+
* `X12_UNEXPECTED_SEGMENT` warning whose `position.segmentIndex` equals
|
|
1580
|
+
* {@link segmentIndex}, and `context` is that warning's library-owned
|
|
1581
|
+
* discriminant, so the two surfaces can be joined without string matching.
|
|
1582
|
+
*
|
|
1583
|
+
* These are structural anomalies, not a normal shape: a stray segment
|
|
1584
|
+
* between `GE` and `IEA`, a body segment between an `SE` and its group's
|
|
1585
|
+
* `GE`, a body segment between `GS` and the first `ST`, an `ST` with no open
|
|
1586
|
+
* group, an `SE` closing nothing, a `GE` closing nothing, or a `TA1` inside
|
|
1587
|
+
* an open functional group. The parser cannot place any of them in the typed
|
|
1588
|
+
* tree, but it no longer drops them either, so a segment that used to vanish
|
|
1589
|
+
* is now readable here.
|
|
1590
|
+
*
|
|
1591
|
+
* **Most of these sit outside every ST..SE transaction set, but the `TA1`
|
|
1592
|
+
* case does not.** `TA1` is envelope-level by spec, so a `TA1` anywhere
|
|
1593
|
+
* inside an open group is routed here even when it arrives BETWEEN an `ST`
|
|
1594
|
+
* and its `SE` - in which case it is lifted out of that transaction's
|
|
1595
|
+
* `segments` / `rawSegments` and appears only on this array. That is
|
|
1596
|
+
* long-standing behaviour (it predates this array; the segment simply used
|
|
1597
|
+
* to be discarded), and it is the one case where `ix.groups` is not the whole
|
|
1598
|
+
* typed model.
|
|
1599
|
+
*
|
|
1600
|
+
* **`serializeX12` re-emits these, at {@link anchor}**, so an orphan and its
|
|
1601
|
+
* `X12_UNEXPECTED_SEGMENT` warning both survive a round trip. Placement is by
|
|
1602
|
+
* the structural anchor and NEVER by {@link segmentIndex}: that index is an
|
|
1603
|
+
* index into the INPUT stream, and the emit is not in input order (it hoists
|
|
1604
|
+
* `ta1Segments` ahead of the groups and skips the zero-length segment a
|
|
1605
|
+
* doubled terminator produces), so replaying by index splices an orphan into
|
|
1606
|
+
* whatever occupies that slot - measurably, into an 835's `ST..SE` body,
|
|
1607
|
+
* where a re-parse reports nothing at all. Use {@link segmentIndex} to join
|
|
1608
|
+
* back to the warning, not to place the segment. See `KNOWN-LIMITATIONS.md`.
|
|
1609
|
+
*
|
|
1610
|
+
* Two things are NOT recorded here. A doubled segment terminator delimits a
|
|
1611
|
+
* zero-length segment carrying no elements, so there is nothing to retain.
|
|
1612
|
+
* A segment whose first element is empty (`*A*B~`) has no id for the
|
|
1613
|
+
* envelope walker to dispatch on and is skipped without a warning; that is
|
|
1614
|
+
* long-standing behaviour this array does not change.
|
|
1615
|
+
*
|
|
1616
|
+
* **This is document content, so treat it as PHI.** Unlike an
|
|
1617
|
+
* `X12ParseWarning`, whose `message` is a lookup into a frozen registry and
|
|
1618
|
+
* whose metadata is positional only, an orphan carries the sender's bytes
|
|
1619
|
+
* verbatim, exactly as `X12TransactionSet.rawSegments` and `isa.raw` do. A
|
|
1620
|
+
* segment outside a transaction is not required to be PHI-free, so do NOT
|
|
1621
|
+
* log this array wholesale when triaging; log `context` and `segmentIndex`,
|
|
1622
|
+
* which name the structural rule and the location without echoing content.
|
|
1623
|
+
*
|
|
1624
|
+
* @example
|
|
1625
|
+
* ```ts
|
|
1626
|
+
* import { parseX12 } from "@cosyte/x12";
|
|
1627
|
+
* const ix = parseX12(raw);
|
|
1628
|
+
* for (const o of ix.orphanSegments) {
|
|
1629
|
+
* console.warn(o.context, o.segmentIndex, o.segment.id);
|
|
1630
|
+
* }
|
|
1631
|
+
* ```
|
|
1632
|
+
*/
|
|
1633
|
+
interface X12OrphanSegment {
|
|
1634
|
+
/** The verbatim segment text, segment terminator stripped. */
|
|
1635
|
+
readonly raw: string;
|
|
1636
|
+
/** The decoded segment (id + 1-indexed elements), as for any body segment. */
|
|
1637
|
+
readonly segment: X12Segment;
|
|
1638
|
+
/**
|
|
1639
|
+
* Global segment index in the post-ISA stream (ISA itself is index 0) -
|
|
1640
|
+
* identical to the `position.segmentIndex` of the segment's
|
|
1641
|
+
* `X12_UNEXPECTED_SEGMENT` warning.
|
|
1642
|
+
*/
|
|
1643
|
+
readonly segmentIndex: number;
|
|
1644
|
+
/** Which structural rule the segment broke. */
|
|
1645
|
+
readonly context: X12UnexpectedSegmentContext;
|
|
1646
|
+
/**
|
|
1647
|
+
* Where the segment sat in the typed tree - the slot `serializeX12` puts it
|
|
1648
|
+
* back into. See {@link X12OrphanAnchor} for why a structural anchor and not
|
|
1649
|
+
* {@link segmentIndex} is what makes re-emission sound.
|
|
1650
|
+
*/
|
|
1651
|
+
readonly anchor: X12OrphanAnchor;
|
|
1652
|
+
}
|
|
1381
1653
|
/**
|
|
1382
1654
|
* The top-level X12 interchange returned by `parseX12`. `isa` carries the
|
|
1383
1655
|
* envelope header verbatim; `delimiters` is the four-class delimiter set
|
|
1384
1656
|
* detected from fixed positions inside `isa.raw`; `groups` is the ordered
|
|
1385
|
-
* GS..GE list; `
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1657
|
+
* GS..GE list; `orphanSegments` holds any segment that fell outside every
|
|
1658
|
+
* transaction set (empty for a well-formed interchange); `warnings`
|
|
1659
|
+
* accumulates every Tier-2 deviation observed during the parse (lenient
|
|
1660
|
+
* mode); `trailingBytes` (when present) is any non-empty content after IEA -
|
|
1661
|
+
* preserved verbatim so a consumer can inspect or re-emit it.
|
|
1389
1662
|
*
|
|
1390
1663
|
* @example
|
|
1391
1664
|
* ```ts
|
|
@@ -1400,6 +1673,14 @@ interface X12Interchange {
|
|
|
1400
1673
|
readonly delimiters: Delimiters;
|
|
1401
1674
|
readonly groups: readonly X12FunctionalGroup[];
|
|
1402
1675
|
readonly ta1Segments: readonly Ta1Segment[];
|
|
1676
|
+
/**
|
|
1677
|
+
* Segments the envelope grammar could not place, in input order - almost
|
|
1678
|
+
* always because they fell outside every ST..SE transaction set, plus the
|
|
1679
|
+
* `TA1`-inside-a-group case, which is lifted out of the transaction it
|
|
1680
|
+
* arrived in. Empty for a well-formed interchange. See
|
|
1681
|
+
* {@link X12OrphanSegment}.
|
|
1682
|
+
*/
|
|
1683
|
+
readonly orphanSegments: readonly X12OrphanSegment[];
|
|
1403
1684
|
readonly warnings: readonly X12ParseWarning[];
|
|
1404
1685
|
readonly trailingBytes?: string;
|
|
1405
1686
|
/**
|
|
@@ -1432,7 +1713,9 @@ interface X12Interchange {
|
|
|
1432
1713
|
* throw {@link X12ParseError}: `X12_EMPTY_INPUT`, `X12_NO_ISA_HEADER`,
|
|
1433
1714
|
* `X12_ISA_TOO_SHORT`, `X12_INVALID_DELIMITERS`. Opt into strict mode with
|
|
1434
1715
|
* `{ strict: true }` to escalate every Tier-2 warning into an
|
|
1435
|
-
* `X12ParseError` carrying the warning's code.
|
|
1716
|
+
* `X12ParseError` carrying the warning's code. A strict-mode escalation
|
|
1717
|
+
* carries an empty `snippet`: the warning it wraps is registry-built and
|
|
1718
|
+
* fully located by `position`, so there is nothing to redact.
|
|
1436
1719
|
*
|
|
1437
1720
|
* Phase 1 decodes the envelope (ISA / GS / ST / SE / GE / IEA) and
|
|
1438
1721
|
* detects the four delimiters from fixed ISA byte positions. Transaction-
|
|
@@ -1610,11 +1893,19 @@ type X12FatalCode = (typeof FATAL_CODES)[keyof typeof FATAL_CODES];
|
|
|
1610
1893
|
* snippet of the offending input so consumers can log actionable errors.
|
|
1611
1894
|
*
|
|
1612
1895
|
* @remarks
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
1896
|
+
* `snippet` is the library's ONE deliberate PHI exception, and it exists for
|
|
1897
|
+
* the four Tier-3 structural fatals only. Those are raised before the
|
|
1898
|
+
* envelope is readable and are undebuggable without a few bytes of context.
|
|
1899
|
+
* It may contain PHI/PII when parsing real interchanges (member IDs appear in
|
|
1900
|
+
* ISA-06/08 only as trading-partner IDs, not patient identity, but a real
|
|
1901
|
+
* claim / eligibility body elsewhere in the input can carry PHI). Redact at
|
|
1902
|
+
* the call site if required by your compliance posture; the library does not
|
|
1903
|
+
* redact snippets itself.
|
|
1904
|
+
*
|
|
1905
|
+
* A strict-mode escalation of a Tier-2 warning carries `snippet: ""`. That
|
|
1906
|
+
* error's `message` is the same frozen-registry entry the warning carried and
|
|
1907
|
+
* `position` locates it, so there is nothing to attach and nothing to
|
|
1908
|
+
* redact.
|
|
1618
1909
|
*
|
|
1619
1910
|
* @example
|
|
1620
1911
|
* ```ts
|
|
@@ -3931,8 +4222,12 @@ declare const REMIT_835_LOOP_1000B: LoopSpec;
|
|
|
3931
4222
|
* cash to the wrong dollar. These checks NEVER silently rebalance: a
|
|
3932
4223
|
* failed invariant emits an {@link
|
|
3933
4224
|
* "../../parser/warnings.js".WARNING_CODES.X12_835_REMIT_BALANCE_MISMATCH}
|
|
3934
|
-
*
|
|
3935
|
-
*
|
|
4225
|
+
* naming which TR3 equation broke, and the model still resolves with the
|
|
4226
|
+
* verbatim inbound amounts. The amounts themselves are NOT rendered into
|
|
4227
|
+
* the message: an EDI amount is a consumer-controlled element like any
|
|
4228
|
+
* other, and the spec'd / computed / delta trio used to be interpolated
|
|
4229
|
+
* unbounded. Recompute them from the model, which carries every one of
|
|
4230
|
+
* them as an `X12Decimal`.
|
|
3936
4231
|
*
|
|
3937
4232
|
* Three invariants per TR3 005010X221A1 §1.10.2 ("Balancing"):
|
|
3938
4233
|
*
|
|
@@ -3960,11 +4255,46 @@ declare const REMIT_835_LOOP_1000B: LoopSpec;
|
|
|
3960
4255
|
* > slice with a forward-pointer to this module so the contract stays
|
|
3961
4256
|
* > consistent.
|
|
3962
4257
|
*
|
|
3963
|
-
* **PHI discipline
|
|
3964
|
-
*
|
|
3965
|
-
*
|
|
3966
|
-
*
|
|
3967
|
-
*
|
|
4258
|
+
* **PHI discipline: the message names the equation and carries no value at
|
|
4259
|
+
* all**, not even an amount. An EDI amount is a consumer-controlled element
|
|
4260
|
+
* like any other: `CLP-03` is whatever the payer sent, so the spec'd /
|
|
4261
|
+
* computed / delta trio these messages used to interpolate was an unbounded
|
|
4262
|
+
* echo of sender bytes. Recompute the numbers from the model, which carries
|
|
4263
|
+
* every one of them as an `X12Decimal`.
|
|
4264
|
+
*
|
|
4265
|
+
* **Which claim, then?** Three different answers, one per invariant.
|
|
4266
|
+
*
|
|
4267
|
+
* - **Claim-level** ({@link checkClaimBalance}): `position.segmentIndex` is
|
|
4268
|
+
* the CLP segment's own 1-based index inside the transaction body, so
|
|
4269
|
+
* `tx.segments[position.segmentIndex]` is that exact CLP.
|
|
4270
|
+
* - **Service-line** ({@link checkServiceLineBalance}): that CLP index plus
|
|
4271
|
+
* the line's zero-based ordinal plus one, which is a **unique locator, not
|
|
4272
|
+
* a pointer at the SVC**. The segment sitting at that index is usually
|
|
4273
|
+
* something else in the claim's loop. Read it as "the claim whose CLP is at
|
|
4274
|
+
* `segmentIndex - (ordinal + 1)`, service line `ordinal`", or match against
|
|
4275
|
+
* `remit.claims` and `claim.serviceLines`, which carry the decoded model.
|
|
4276
|
+
* What the offset guarantees is non-collision across claims: a claim with
|
|
4277
|
+
* `n` service lines spans at least `n + 1` body segments, so the next CLP
|
|
4278
|
+
* always sits past the previous claim's last line position.
|
|
4279
|
+
* - **Remit-level** ({@link checkRemitTotalBalance}): `segmentIndex` is the
|
|
4280
|
+
* **BPR's** own 1-based body index, so `tx.segments[position.segmentIndex]`
|
|
4281
|
+
* is that exact BPR. The equation spans the whole transaction set, so no
|
|
4282
|
+
* single segment is uniquely "at fault" - but BPR-02 is the one element the
|
|
4283
|
+
* invariant compares against, and the BPR is the only segment a reader can
|
|
4284
|
+
* act on. `get835` was passing a literal `0` here, and `0` is not a neutral
|
|
4285
|
+
* sentinel: `tx.segments[0]` is the ST, so a consumer resolving the position
|
|
4286
|
+
* landed on the ST. The one remaining `0` is the transaction that carries no
|
|
4287
|
+
* BPR at all (malformed - TR3 005010X221A1 makes BPR mandatory - but
|
|
4288
|
+
* reachable, since the check still runs against an all-zero payment header).
|
|
4289
|
+
* Take the amounts from `remit.payment.totalActualPayment` and
|
|
4290
|
+
* `remit.claims`; the message names the equation and carries no value.
|
|
4291
|
+
*
|
|
4292
|
+
* **A caller that constructs the position itself gets whatever it passes.**
|
|
4293
|
+
* These three functions are exported, and they do not derive a position - they
|
|
4294
|
+
* forward one. `build835` exploits that: it hands in a synthetic position
|
|
4295
|
+
* because it has no parsed segment stream to index into, and it uses only
|
|
4296
|
+
* `.message`, which is a registry lookup keyed by the invariant and therefore
|
|
4297
|
+
* position-independent.
|
|
3968
4298
|
*/
|
|
3969
4299
|
|
|
3970
4300
|
/**
|
|
@@ -3978,7 +4308,8 @@ declare const REMIT_835_LOOP_1000B: LoopSpec;
|
|
|
3978
4308
|
* declare const claim: X12RemitClaim;
|
|
3979
4309
|
* const w = checkClaimBalance(claim, { segmentIndex: 12 });
|
|
3980
4310
|
* if (w !== undefined) {
|
|
3981
|
-
* // not balanced - w.message names
|
|
4311
|
+
* // not balanced - w.message names the TR3 equation; the amounts are on `claim`,
|
|
4312
|
+
* // and w.position.segmentIndex is the CLP's own index in the transaction body
|
|
3982
4313
|
* }
|
|
3983
4314
|
* ```
|
|
3984
4315
|
*/
|
|
@@ -11873,14 +12204,71 @@ interface BuildTA1Options {
|
|
|
11873
12204
|
* - **Byte-faithful (default).** Reconstructs the interchange purely from the
|
|
11874
12205
|
* verbatim `.raw` strings the parser preserved (ISA + terminator, then each
|
|
11875
12206
|
* GS / transaction segment / GE / IEA terminator-joined, then any
|
|
11876
|
-
* `trailingBytes`).
|
|
11877
|
-
*
|
|
11878
|
-
*
|
|
11879
|
-
*
|
|
11880
|
-
*
|
|
12207
|
+
* `trailingBytes`). "Byte-faithful" is a statement about SEGMENTS ON THE
|
|
12208
|
+
* MODEL, and the distinction matters to anyone diffing output against input.
|
|
12209
|
+
*
|
|
12210
|
+
* Every segment the parser recorded comes back verbatim, including element
|
|
12211
|
+
* padding, composite structure and `?`-release escapes, but it comes back in
|
|
12212
|
+
* the ORDER the model holds it, which is not always the input order. SIX
|
|
12213
|
+
* constructs are known not to survive, and line breaks are only the most
|
|
12214
|
+
* common:
|
|
12215
|
+
*
|
|
12216
|
+
* 1. **Line breaks between segments.** The parser absorbs any run of CR /
|
|
12217
|
+
* LF bytes between segments and the model has nowhere to record it, so a
|
|
12218
|
+
* pretty-printed or double-spaced source emits as its compact form.
|
|
12219
|
+
* Silent.
|
|
12220
|
+
* 2. **A doubled segment terminator** outside a transaction. It delimits a
|
|
12221
|
+
* zero-length segment carrying no elements, so there is nothing to
|
|
12222
|
+
* retain. Silent.
|
|
12223
|
+
* 3. **A missing final terminator**, which the emit supplies. Silent.
|
|
12224
|
+
* 4. **Post-IEA `trailingBytes`**, re-joined from segment slices rather than
|
|
12225
|
+
* preserved verbatim.
|
|
12226
|
+
* 5. **TA1 position.** A TA1 that appeared AFTER a functional group is
|
|
12227
|
+
* collected onto `ix.ta1Segments` and emitted immediately after the ISA,
|
|
12228
|
+
* so the emit reorders it. Silent, and unlike the others nothing is
|
|
12229
|
+
* dropped: the model and the warning stream both round-trip identically.
|
|
12230
|
+
* This is also the only construct that can move something ELSE - a
|
|
12231
|
+
* segment outside a transaction is placed correctly relative to the
|
|
12232
|
+
* groups but not relative to a TA1 that was hoisted past it. This library
|
|
12233
|
+
* takes no position here on where ASC X12 requires a TA1 to sit.
|
|
12234
|
+
* 6. **A segment whose first element is empty** (`*A*B~`), outside a
|
|
12235
|
+
* transaction. It has no id for the envelope walker to dispatch on, so it
|
|
12236
|
+
* is skipped: absent from the model, absent from the emit, and it does
|
|
12237
|
+
* not even raise `X12_UNEXPECTED_SEGMENT`. Silent, and the only case here
|
|
12238
|
+
* that loses a value with no diagnostic at all. Inside an open
|
|
12239
|
+
* transaction the same segment is kept and re-emitted normally.
|
|
12240
|
+
*
|
|
12241
|
+
* **A segment outside a transaction is no longer on that list.** It is
|
|
12242
|
+
* retained on `ix.orphanSegments` with a structural `anchor`, and this
|
|
12243
|
+
* function re-emits it at that anchor, so the segment, its value and its
|
|
12244
|
+
* `X12_UNEXPECTED_SEGMENT` warning all survive the round trip. See the
|
|
12245
|
+
* `orphans` block below for why placement is by anchor and never by
|
|
12246
|
+
* `segmentIndex`.
|
|
12247
|
+
*
|
|
12248
|
+
* So `serialize(parse(s)) === s` is still NOT guaranteed in general, and the
|
|
12249
|
+
* absence of line breaks is still not sufficient to make it hold: cases 2 to
|
|
12250
|
+
* 6 all break it on inputs that contain none. Five of the six (1, 2, 3, 5, 6)
|
|
12251
|
+
* produce no warning at all, so the warning stream is not a reliable signal
|
|
12252
|
+
* that a round trip will be byte-exact - only case 4 warns.
|
|
12253
|
+
*
|
|
12254
|
+
* What IS measured, across the 56 committed fixtures: all 56 emits are fixed
|
|
12255
|
+
* points (serializing again is a byte-level no-op), all 56 re-parse to an
|
|
12256
|
+
* identical model with an identical warning stream, the 14 fixtures carrying
|
|
12257
|
+
* no line breaks return byte-identical, and the 42 that are pretty-printed
|
|
12258
|
+
* differ from their source by line breaks and nothing else. Two caveats on
|
|
12259
|
+
* that corpus: it contains no instance of cases 2 to 6 and no orphan at all,
|
|
12260
|
+
* and 13 of the 14 byte-identical fixtures are `golden/*.edi`, which are
|
|
12261
|
+
* serializer output by construction, so `envelope/no-trailing-crlf.edi` is
|
|
12262
|
+
* the only independent witness. `test/serialize.test.ts` covers the corpus
|
|
12263
|
+
* sweep, the orphan round trip, and cases 1 to 6 separately.
|
|
11881
12264
|
*
|
|
11882
12265
|
* - **Spec-clean (`{ specClean: true }`).** Same byte-faithful structure, but
|
|
11883
|
-
* the serializer ALSO reconciles the envelope counts and control numbers
|
|
12266
|
+
* the serializer ALSO reconciles the envelope counts and control numbers.
|
|
12267
|
+
* Every count is taken from the bytes this function WRITES, which for SE-01
|
|
12268
|
+
* is `tx.rawSegments` PLUS any orphan re-emitted between the `ST` and the
|
|
12269
|
+
* `SE` - a lifted `TA1` is off the model's transaction but is still a
|
|
12270
|
+
* segment of that transaction set per X12.6, and counting the model alone
|
|
12271
|
+
* made `recomputeCounts` shrink a correct SE-01. The pairs reconciled are
|
|
11884
12272
|
* SE-01 (segment count) vs the actual ST..SE segment count, GE-01
|
|
11885
12273
|
* (transaction count) vs the actual ST count, IEA-01 (group count) vs the
|
|
11886
12274
|
* actual group count, plus the ISA-13↔IEA-02 / GS-06↔GE-02 / ST-02↔SE-02
|
|
@@ -11891,9 +12279,12 @@ interface BuildTA1Options {
|
|
|
11891
12279
|
* segments. Control numbers are identity, not derived, so they are NEVER
|
|
11892
12280
|
* rewritten - only flagged.
|
|
11893
12281
|
*
|
|
11894
|
-
*
|
|
11895
|
-
*
|
|
11896
|
-
*
|
|
12282
|
+
* Every warning it emits is built by the same value-free factories the parser
|
|
12283
|
+
* uses: `message` is a frozen-registry lookup and `position` locates the
|
|
12284
|
+
* control segment, so a declared count or control number can never reach a
|
|
12285
|
+
* diagnostic. Read the declared and actual values off the model
|
|
12286
|
+
* (`se.elements[1]` against `tx.rawSegments.length`, `ge.elements[1]` against
|
|
12287
|
+
* `group.transactions.length`, `iea.elements[1]` against `ix.groups.length`).
|
|
11897
12288
|
*/
|
|
11898
12289
|
|
|
11899
12290
|
/**
|
|
@@ -11943,7 +12334,10 @@ interface SerializeOptions {
|
|
|
11943
12334
|
* ```ts
|
|
11944
12335
|
* import { parseX12, serializeX12 } from "@cosyte/x12";
|
|
11945
12336
|
* const ix = parseX12(raw);
|
|
11946
|
-
*
|
|
12337
|
+
* // Segments on the model come back verbatim, orphans included. Anything the
|
|
12338
|
+
* // parser did not record (line breaks, a doubled terminator, ...) does not,
|
|
12339
|
+
* // so this is not guaranteed to equal `raw`. See the module header.
|
|
12340
|
+
* const bytes = serializeX12(ix);
|
|
11947
12341
|
* ```
|
|
11948
12342
|
*/
|
|
11949
12343
|
declare function serializeX12(interchange: X12Interchange, opts?: SerializeOptions): string;
|
|
@@ -12133,6 +12527,124 @@ interface InterchangeSpec {
|
|
|
12133
12527
|
*/
|
|
12134
12528
|
declare function buildInterchange(spec: InterchangeSpec): X12Interchange;
|
|
12135
12529
|
|
|
12530
|
+
/**
|
|
12531
|
+
* The single route a caller-supplied value takes into a `build*` refusal
|
|
12532
|
+
* message.
|
|
12533
|
+
*
|
|
12534
|
+
* ## Why this exists
|
|
12535
|
+
*
|
|
12536
|
+
* The parse side closed its equivalent hole first: no warning factory takes a
|
|
12537
|
+
* value parameter at all, and `message` is a lookup into the frozen
|
|
12538
|
+
* `ALL_WARNING_MESSAGES` table, so a *document's* bytes cannot reach a
|
|
12539
|
+
* diagnostic (`PHI-WARNING-MESSAGE-LEAK`). The builder side is the mirror
|
|
12540
|
+
* image with one material asymmetry, and the claim made here is deliberately
|
|
12541
|
+
* narrower because of it:
|
|
12542
|
+
*
|
|
12543
|
+
* > **A builder refusal echoes a value the CALLER passed in, which is usually
|
|
12544
|
+
* > but NOT ALWAYS their own.** They just handed it to the builder, so bounding
|
|
12545
|
+
* > it is **robustness and log hygiene, not redaction**. This module does not
|
|
12546
|
+
* > make a builder refusal PHI-safe, and nothing in this library claims it
|
|
12547
|
+
* > does. If a caller puts PHI in a control number, the refusal will show up
|
|
12548
|
+
* > to {@link BUILD_REFUSAL_VALUE_MAX_LENGTH} characters of it.
|
|
12549
|
+
*
|
|
12550
|
+
* **Do not state that dichotomy categorically, because the ack builders break
|
|
12551
|
+
* it.** `build999` renders the AK2-02 transaction-set control number and
|
|
12552
|
+
* `buildTA1` exists to echo an inbound ISA-13: TR3 005010X231A1 requires AK2-02
|
|
12553
|
+
* to be a verbatim copy of the acknowledged transaction set's ST-02, so on the
|
|
12554
|
+
* ack path a *document's* bytes reach the spec by the standard's own design,
|
|
12555
|
+
* and from there a refusal message. They are envelope control numbers rather
|
|
12556
|
+
* than clinical content, and they are bounded here like everything else - but
|
|
12557
|
+
* "the value is always the caller's own" is false, and this library should not
|
|
12558
|
+
* say it.
|
|
12559
|
+
*
|
|
12560
|
+
* What it does guarantee is that `Error.message` from a `build*` refusal has a
|
|
12561
|
+
* **fixed ceiling**. Before this, **twenty-three** refusal sites across ten builder
|
|
12562
|
+
* modules interpolated a caller value verbatim, so a 120,000-character control
|
|
12563
|
+
* number produced a 120,066-**character** `X12BuildError.message` - measured on
|
|
12564
|
+
* this tree, and the length grew without limit with the input. An unbounded
|
|
12565
|
+
* `Error.message` is a real operational hazard independent of PHI: it is what
|
|
12566
|
+
* gets serialized into a log line, a crash report, or a JSON error envelope.
|
|
12567
|
+
*
|
|
12568
|
+
* ## What is bounded and what is not
|
|
12569
|
+
*
|
|
12570
|
+
* - **Bounded:** the number of UTF-16 code units. The rendered fragment never
|
|
12571
|
+
* exceeds {@link BUILD_REFUSAL_VALUE_MAX_RENDERED}. **Code units, not bytes** -
|
|
12572
|
+
* an all-astral value renders 86 units but 152 UTF-8 bytes, and a CJK one
|
|
12573
|
+
* around 216. Every figure this package publishes says "characters" for that
|
|
12574
|
+
* reason. A slice at the bound can also split a surrogate pair, leaving a lone
|
|
12575
|
+
* surrogate that becomes U+FFFD once the message is UTF-8 encoded; the bound
|
|
12576
|
+
* holds regardless, and the fragment is diagnostic text, not data.
|
|
12577
|
+
* - **NOT escaped, and this is not an oversight.** The surviving characters are
|
|
12578
|
+
* whatever the caller supplied, including a segment terminator, a quote, or a
|
|
12579
|
+
* newline. A refusal message is therefore bounded but not guaranteed to be a
|
|
12580
|
+
* single log line. Escaping was considered and left out: it would expand the
|
|
12581
|
+
* rendered length by up to 6x per character for a hazard the caller creates
|
|
12582
|
+
* in their own data, and this slice makes the claim it can support and no
|
|
12583
|
+
* wider.
|
|
12584
|
+
*
|
|
12585
|
+
* @see `src/parser/errors.ts` for the parse-side `SNIPPET_MAX_INPUT` bound this
|
|
12586
|
+
* mirrors, which is the one deliberate place a *document's* bytes are copied.
|
|
12587
|
+
*/
|
|
12588
|
+
/**
|
|
12589
|
+
* How many characters of a caller-supplied value survive into a `build*`
|
|
12590
|
+
* refusal message. Set to mirror the parser's own `SNIPPET_MAX_INPUT` (63),
|
|
12591
|
+
* so the two bounded copies in this library agree rather than each picking a
|
|
12592
|
+
* number. Comfortably wider than every slot it guards: an ISA-13 / IEA-02
|
|
12593
|
+
* control number is 9, a TA1-05 note code 3, an ST-01 transaction set id 3, an
|
|
12594
|
+
* 834 maintenance type 2-3, an 837 service-line variant 1.
|
|
12595
|
+
*
|
|
12596
|
+
* @example
|
|
12597
|
+
* ```ts
|
|
12598
|
+
* import { BUILD_REFUSAL_VALUE_MAX_LENGTH } from "@cosyte/x12";
|
|
12599
|
+
* BUILD_REFUSAL_VALUE_MAX_LENGTH; // 63
|
|
12600
|
+
* ```
|
|
12601
|
+
*/
|
|
12602
|
+
declare const BUILD_REFUSAL_VALUE_MAX_LENGTH = 63;
|
|
12603
|
+
/**
|
|
12604
|
+
* Hard ceiling, in characters, on the fragment {@link renderCallerValue}
|
|
12605
|
+
* returns: {@link BUILD_REFUSAL_VALUE_MAX_LENGTH} surviving characters, two
|
|
12606
|
+
* quotes, one ellipsis, and the ` (N characters)` suffix at its widest.
|
|
12607
|
+
*
|
|
12608
|
+
* **This is the bound on the FRAGMENT, not on the message.** A refusal message
|
|
12609
|
+
* is this plus the site's own fixed template text, which differs per site, so
|
|
12610
|
+
* the message is bounded by a constant but not by *this* constant. Measured on
|
|
12611
|
+
* this tree: a 120,000-character control number gives an 86-character fragment
|
|
12612
|
+
* and a **150-character** `X12BuildError.message` from `buildInterchange`. Do
|
|
12613
|
+
* not quote the ceiling as though it were a message length - an earlier
|
|
12614
|
+
* revision of the docs did exactly that, reporting "now 90 bytes" for a message
|
|
12615
|
+
* that is 150. The suite asserts the fragment against this constant and each
|
|
12616
|
+
* message against its own site.
|
|
12617
|
+
*
|
|
12618
|
+
* @example
|
|
12619
|
+
* ```ts
|
|
12620
|
+
* import { BUILD_REFUSAL_VALUE_MAX_RENDERED } from "@cosyte/x12";
|
|
12621
|
+
* BUILD_REFUSAL_VALUE_MAX_RENDERED; // 90
|
|
12622
|
+
* ```
|
|
12623
|
+
*/
|
|
12624
|
+
declare const BUILD_REFUSAL_VALUE_MAX_RENDERED: number;
|
|
12625
|
+
/**
|
|
12626
|
+
* Render a caller-supplied value as a bounded, quoted fragment for a `build*`
|
|
12627
|
+
* refusal message. **This is the only sanctioned route a caller value takes
|
|
12628
|
+
* into a thrown message**, and `test/builder-refusal-bounds.test.ts` scans
|
|
12629
|
+
* `src/` for any other route - a twenty-fourth refusal site that interpolates a
|
|
12630
|
+
* value directly reds that test. That scan keys on `throw new *BuildError(` and
|
|
12631
|
+
* on template-literal holes, so it is a strong tripwire for the shape this
|
|
12632
|
+
* library uses rather than a proof over every shape one could write.
|
|
12633
|
+
*
|
|
12634
|
+
* Returns the value quoted when it fits, and otherwise the first
|
|
12635
|
+
* {@link BUILD_REFUSAL_VALUE_MAX_LENGTH} characters, an ellipsis, and the true
|
|
12636
|
+
* length - the length is the diagnostically useful part when the value is
|
|
12637
|
+
* over-long, since that is usually *why* the builder refused.
|
|
12638
|
+
*
|
|
12639
|
+
* @example
|
|
12640
|
+
* ```ts
|
|
12641
|
+
* import { renderCallerValue } from "@cosyte/x12";
|
|
12642
|
+
* renderCallerValue("000000001"); // '"000000001"'
|
|
12643
|
+
* renderCallerValue("9".repeat(120000)); // '"999…" (120000 characters)'
|
|
12644
|
+
* ```
|
|
12645
|
+
*/
|
|
12646
|
+
declare function renderCallerValue(value: string | number): string;
|
|
12647
|
+
|
|
12136
12648
|
/**
|
|
12137
12649
|
* Thrown errors emitted by the general-purpose interchange builder
|
|
12138
12650
|
* (`buildInterchange`). Distinct from `X12ParseError` (the parser stays
|
|
@@ -12479,4 +12991,4 @@ declare const profiles: {
|
|
|
12479
12991
|
*/
|
|
12480
12992
|
declare const VERSION: string;
|
|
12481
12993
|
|
|
12482
|
-
export { ACK_BUILD_ERROR_CODES, 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, type AckBuildErrorCode, type Build271AddressSpec, type Build271BenefitSpec, type Build271DateSpec, type Build271DependentSpec, type Build271EntitySpec, type Build271EnvelopeSpec, type Build271InformationReceiverSpec, type Build271InformationSourceSpec, type Build271MemberSpec, type Build271ReferenceSpec, type Build271ServiceTypeSpec, type Build271Spec, type Build271SubscriberSpec, type Build271TraceSpec, type Build277ClaimSpec, type Build277DateSpec, type Build277DependentSpec, type Build277EntitySpec, type Build277EnvelopeSpec, type Build277InformationReceiverSpec, type Build277InformationSourceSpec, type Build277MemberSpec, type Build277ProviderSpec, type Build277ReferenceSpec, type Build277ServiceLineSpec, type Build277Spec, type Build277StatusCodeSpec, type Build277StatusSpec, type Build277SubscriberSpec, type Build277TraceSpec, type Build278DateSpec, type Build278DecisionSpec, type Build278DependentSpec, type Build278DiagnosisSpec, type Build278EntitySpec, type Build278EnvelopeSpec, type Build278HeaderSpec, type Build278MemberSpec, type Build278ReferenceSpec, type Build278ReviewSpec, type Build278Spec, type Build278SubscriberSpec, type Build278TraceSpec, type Build820AddressSpec, type Build820AdjustmentSpec, type Build820DateSpec, type Build820EntitySpec, type Build820EnvelopeSpec, type Build820OpenItemSpec, type Build820PartySpec, type Build820PaymentSpec, type Build820PersonSpec, type Build820ReferenceSpec, type Build820RemittanceSpec, type Build820Spec, type Build820TraceSpec, type Build834AddressSpec, type Build834AmountSpec, type Build834CoordinationOfBenefitsSpec, type Build834CoverageSpec, type Build834DateSpec, type Build834EnvelopeSpec, type Build834HeaderSpec, type Build834MemberNameSpec, type Build834MemberSpec, type Build834PartySpec, type Build834ReferenceSpec, type Build834Spec, type Build835AddressSpec, type Build835AdjustmentSpec, type Build835AmountSpec, type Build835ClaimSpec, type Build835ContactSpec, type Build835EnvelopeSpec, type Build835PartySpec, type Build835PaymentSpec, type Build835PersonSpec, type Build835ProviderAdjustmentSpec, type Build835ProviderSpec, type Build835ReferenceSpec, type Build835RemarkSpec, type Build835ServiceLineSpec, type Build835Spec, type Build835TraceSpec, type Build837AddressSpec, type Build837AdjudicationSpec, type Build837AdjustmentSpec, type Build837AmountSpec, type Build837BillingProviderSpec, type Build837ClaimSpec, type Build837ContactSpec, type Build837DateSpec, type Build837DrugSpec, type Build837EntitySpec, type Build837EnvelopeSpec, type Build837HiCodeSpec, type Build837NoteSpec, type Build837OtherSubscriberSpec, type Build837PatientSpec, type Build837ReferenceSpec, type Build837ServiceLineBaseSpec, type Build837ServiceLineDentalSpec, type Build837ServiceLineInstitutionalSpec, type Build837ServiceLineProfessionalSpec, type Build837ServiceLineSpec, type Build837Spec, type Build837SubscriberInfoSpec, type Build837SubscriberSpec, type Build837ToothSpec, type Build999ElementErrorSpec, type Build999EnvelopeSpec, type Build999FunctionalGroupSpec, type Build999SegmentErrorSpec, type Build999Spec, type Build999TransactionResponseSpec, type BuildTA1Options, type BuildTA1Spec, 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, Claim837BuildError, type Claim837BuildErrorCode, type ClaimAdjustmentGroupCode, ClaimStatus277BuildError, type ClaimStatus277BuildErrorCode, type CodeListEntry, type CodeListMeta, type CodeListSnapshot, DELIMITER_POSITIONS, type DefineLoopSpecInput, type Delimiters, 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, type Eligibility271BuildErrorCode, Enrollment834BuildError, type Enrollment834BuildErrorCode, FATAL_CODES, type FunctionalGroupSpec, type GeSegment, type GsSegment, HI_QUALIFIERS, HL_LEVEL_CODES, IK3_SYNTAX_ERROR_CODES, IK4_SYNTAX_ERROR_CODES, ISA_MIN_LENGTH, type IeaSegment, type Ik304Code, type Ik403Code, type InterchangeSpec, type IsaSegment, type LoopMax, type LoopSegmentSpec, type LoopSpec, LoopSpecDefinitionError, type LoopUsage, MAINTENANCE_TYPE_CODES, NM1_QUALIFIERS, type OnWarningCallback, 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, type Premium820BuildErrorCode, 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, Remit835BuildError, type Remit835BuildErrorCode, 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, type SegmentSpec, type SerializeOptions, ServicesReview278BuildError, type ServicesReview278BuildErrorCode, TA1_ACK_CODES, TA1_NOTE_CODES, type Ta1AckCode, type Ta1NoteCode, type Ta1Segment, type TransactionSetSpec, VERSION, WARNING_CODES, type X12Ack999, type X12Ack999Ak1, type X12Ack999Ak2, type X12Ack999Ak9, type X12Ack999ElementNote, type X12Ack999Ik3, type X12Ack999Ik4, type X12Ack999Ik4Position, type X12Ack999Ik5, type X12Ack999SegmentNote, type X12Ack999TransactionResponse, type X12AckDispositionCode, type X12AckTA1, type X12AuthDate, type X12AuthDiagnosis, type X12AuthEntity, type X12AuthHeader, type X12AuthMember, type X12AuthReference, type X12AuthTrace, X12BuildError, type X12BuildErrorCode, type X12Claim, type X12Claim837Variant, type X12ClaimAddress, type X12ClaimAmount, type X12ClaimContact, type X12ClaimDate, type X12ClaimEntity, type X12ClaimHiCode, type X12ClaimMember, type X12ClaimNote, type X12ClaimReference, type X12ClaimStatus, type X12ClaimStatusResponse, type X12CoordinationOfBenefits, X12Decimal, type X12Eligibility, type X12EligibilityAddress, type X12EligibilityBenefit, type X12EligibilityDate, type X12EligibilityDependent, type X12EligibilityEntity, type X12EligibilityMember, type X12EligibilityReference, type X12EligibilityServiceType, type X12EligibilitySubscriber, type X12EligibilityTrace, type X12Enrollment, type X12EnrollmentAddress, type X12EnrollmentAmount, type X12EnrollmentDate, type X12EnrollmentHeader, type X12EnrollmentMember, type X12EnrollmentParty, type X12EnrollmentReference, type X12FatalCode, type X12FunctionalGroup, type X12HealthCoverage, type X12HiCategory, type X12HiCodeSystem, type X12HiQualifier, type X12HierarchicalLevel, type X12Hl, type X12Interchange, type X12LineAdjudication, type X12LineDrug, type X12OtherSubscriber, X12ParseError, type X12ParseOptions, type X12ParseWarning, type X12Position, type X12PremiumAddress, type X12PremiumAdjustment, type X12PremiumDate, type X12PremiumEntity, type X12PremiumOpenItem, type X12PremiumParty, type X12PremiumPaymentHeader, type X12PremiumPayments, type X12PremiumPerson, type X12PremiumReference, type X12PremiumRemittance, type X12PremiumTrace, type X12Profile, type X12ProfileDescription, type X12ProfileEffect, X12ProfileError, type X12ProfileQuirk, type X12ProfileSpec, type X12RemitAddress, type X12RemitAdjustment, type X12RemitAmount, type X12RemitClaim, type X12RemitContact, type X12RemitParty, type X12RemitPaymentHeader, type X12RemitPerson, type X12RemitProvider, type X12RemitProviderAdjustment, type X12RemitReference, type X12RemitRemark, type X12RemitServiceLine, type X12RemitTrace, type X12Remittance, type X12ReviewDecision, type X12Segment, type X12ServiceLineStatus, type X12ServiceReview, type X12ServicesReview, type X12StatusCode, type X12StatusDate, type X12StatusEntity, type X12StatusInfo, type X12StatusMember, type X12StatusReference, type X12StatusTrace, type X12SubscriberInfo, type X12ToothInformation, type X12TransactionSet, type X12WarningCode, type X12WarningPartition, type X12_837ServiceLine, type X12_837ServiceLineDental, type X12_837ServiceLineInstitutional, type X12_837ServiceLineProfessional, type X12_837Submission, 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, 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, remitBalanceMismatch, resolveHiQualifier, segmentCountMismatch, serializeX12, setDefaultProfile, trailingGarbage, transactionCountMismatch, unescapeRelease, unexpectedSegment, unknown837Variant, unknownCarc, unknownClaimStatus, unknownClaimStatusCategory, unknownHiQualifier, unknownMaintenanceType, unknownRarc };
|
|
12994
|
+
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, type AckBuildErrorCode, BALANCE_INVARIANTS, BUILD_REFUSAL_VALUE_MAX_LENGTH, BUILD_REFUSAL_VALUE_MAX_RENDERED, type Build271AddressSpec, type Build271BenefitSpec, type Build271DateSpec, type Build271DependentSpec, type Build271EntitySpec, type Build271EnvelopeSpec, type Build271InformationReceiverSpec, type Build271InformationSourceSpec, type Build271MemberSpec, type Build271ReferenceSpec, type Build271ServiceTypeSpec, type Build271Spec, type Build271SubscriberSpec, type Build271TraceSpec, type Build277ClaimSpec, type Build277DateSpec, type Build277DependentSpec, type Build277EntitySpec, type Build277EnvelopeSpec, type Build277InformationReceiverSpec, type Build277InformationSourceSpec, type Build277MemberSpec, type Build277ProviderSpec, type Build277ReferenceSpec, type Build277ServiceLineSpec, type Build277Spec, type Build277StatusCodeSpec, type Build277StatusSpec, type Build277SubscriberSpec, type Build277TraceSpec, type Build278DateSpec, type Build278DecisionSpec, type Build278DependentSpec, type Build278DiagnosisSpec, type Build278EntitySpec, type Build278EnvelopeSpec, type Build278HeaderSpec, type Build278MemberSpec, type Build278ReferenceSpec, type Build278ReviewSpec, type Build278Spec, type Build278SubscriberSpec, type Build278TraceSpec, type Build820AddressSpec, type Build820AdjustmentSpec, type Build820DateSpec, type Build820EntitySpec, type Build820EnvelopeSpec, type Build820OpenItemSpec, type Build820PartySpec, type Build820PaymentSpec, type Build820PersonSpec, type Build820ReferenceSpec, type Build820RemittanceSpec, type Build820Spec, type Build820TraceSpec, type Build834AddressSpec, type Build834AmountSpec, type Build834CoordinationOfBenefitsSpec, type Build834CoverageSpec, type Build834DateSpec, type Build834EnvelopeSpec, type Build834HeaderSpec, type Build834MemberNameSpec, type Build834MemberSpec, type Build834PartySpec, type Build834ReferenceSpec, type Build834Spec, type Build835AddressSpec, type Build835AdjustmentSpec, type Build835AmountSpec, type Build835ClaimSpec, type Build835ContactSpec, type Build835EnvelopeSpec, type Build835PartySpec, type Build835PaymentSpec, type Build835PersonSpec, type Build835ProviderAdjustmentSpec, type Build835ProviderSpec, type Build835ReferenceSpec, type Build835RemarkSpec, type Build835ServiceLineSpec, type Build835Spec, type Build835TraceSpec, type Build837AddressSpec, type Build837AdjudicationSpec, type Build837AdjustmentSpec, type Build837AmountSpec, type Build837BillingProviderSpec, type Build837ClaimSpec, type Build837ContactSpec, type Build837DateSpec, type Build837DrugSpec, type Build837EntitySpec, type Build837EnvelopeSpec, type Build837HiCodeSpec, type Build837NoteSpec, type Build837OtherSubscriberSpec, type Build837PatientSpec, type Build837ReferenceSpec, type Build837ServiceLineBaseSpec, type Build837ServiceLineDentalSpec, type Build837ServiceLineInstitutionalSpec, type Build837ServiceLineProfessionalSpec, type Build837ServiceLineSpec, type Build837Spec, type Build837SubscriberInfoSpec, type Build837SubscriberSpec, type Build837ToothSpec, type Build999ElementErrorSpec, type Build999EnvelopeSpec, type Build999FunctionalGroupSpec, type Build999SegmentErrorSpec, type Build999Spec, type Build999TransactionResponseSpec, type BuildTA1Options, type BuildTA1Spec, 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, type Claim837BuildErrorCode, type ClaimAdjustmentGroupCode, ClaimStatus277BuildError, type ClaimStatus277BuildErrorCode, type CodeListEntry, type CodeListMeta, type CodeListSnapshot, DELIMITER_POSITIONS, type DefineLoopSpecInput, type Delimiters, 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, type Eligibility271BuildErrorCode, Enrollment834BuildError, type Enrollment834BuildErrorCode, FATAL_CODES, type FunctionalGroupSpec, type GeSegment, type GsSegment, HI_QUALIFIERS, HL_LEVEL_CODES, IK3_SYNTAX_ERROR_CODES, IK4_SYNTAX_ERROR_CODES, ISA_MIN_LENGTH, type IeaSegment, type Ik304Code, type Ik403Code, type InterchangeSpec, type IsaSegment, type LoopMax, type LoopSegmentSpec, type LoopSpec, LoopSpecDefinitionError, type LoopUsage, MAINTENANCE_TYPE_CODES, NM1_QUALIFIERS, NON_SPEC_SEGMENT_ID, type OnWarningCallback, 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, type Premium820BuildErrorCode, 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, type Remit835BuildErrorCode, 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, type SegmentSpec, type SerializeOptions, ServicesReview278BuildError, type ServicesReview278BuildErrorCode, TA1_ACK_CODES, TA1_NOTE_CODES, type Ta1AckCode, type Ta1NoteCode, type Ta1Segment, type TransactionSetSpec, UNEXPECTED_SEGMENT_CONTEXTS, VERSION, WARNING_CODES, type X12Ack999, type X12Ack999Ak1, type X12Ack999Ak2, type X12Ack999Ak9, type X12Ack999ElementNote, type X12Ack999Ik3, type X12Ack999Ik4, type X12Ack999Ik4Position, type X12Ack999Ik5, type X12Ack999SegmentNote, type X12Ack999TransactionResponse, type X12AckDispositionCode, type X12AckTA1, type X12AuthDate, type X12AuthDiagnosis, type X12AuthEntity, type X12AuthHeader, type X12AuthMember, type X12AuthReference, type X12AuthTrace, type X12BalanceInvariant, X12BuildError, type X12BuildErrorCode, type X12Claim, type X12Claim837Variant, type X12ClaimAddress, type X12ClaimAmount, type X12ClaimContact, type X12ClaimDate, type X12ClaimEntity, type X12ClaimHiCode, type X12ClaimMember, type X12ClaimNote, type X12ClaimReference, type X12ClaimStatus, type X12ClaimStatusResponse, type X12ControlNumberPair, type X12CoordinationOfBenefits, X12Decimal, type X12Eligibility, type X12EligibilityAddress, type X12EligibilityBenefit, type X12EligibilityDate, type X12EligibilityDependent, type X12EligibilityEntity, type X12EligibilityMember, type X12EligibilityReference, type X12EligibilityServiceType, type X12EligibilitySubscriber, type X12EligibilityTrace, type X12Enrollment, type X12EnrollmentAddress, type X12EnrollmentAmount, type X12EnrollmentDate, type X12EnrollmentHeader, type X12EnrollmentMember, type X12EnrollmentParty, type X12EnrollmentReference, type X12FatalCode, type X12FunctionalGroup, type X12HealthCoverage, type X12HiCategory, type X12HiCodeSystem, type X12HiQualifier, type X12HierarchicalLevel, type X12Hl, type X12Interchange, type X12LineAdjudication, type X12LineDrug, type X12OrphanAnchor, type X12OrphanAnchorKind, type X12OrphanSegment, type X12OtherSubscriber, X12ParseError, type X12ParseOptions, type X12ParseWarning, type X12Position, type X12PremiumAddress, type X12PremiumAdjustment, type X12PremiumDate, type X12PremiumEntity, type X12PremiumOpenItem, type X12PremiumParty, type X12PremiumPaymentHeader, type X12PremiumPayments, type X12PremiumPerson, type X12PremiumReference, type X12PremiumRemittance, type X12PremiumTrace, type X12Profile, type X12ProfileDescription, type X12ProfileEffect, X12ProfileError, type X12ProfileQuirk, type X12ProfileSpec, type X12RemitAddress, type X12RemitAdjustment, type X12RemitAmount, type X12RemitClaim, type X12RemitContact, type X12RemitParty, type X12RemitPaymentHeader, type X12RemitPerson, type X12RemitProvider, type X12RemitProviderAdjustment, type X12RemitReference, type X12RemitRemark, type X12RemitServiceLine, type X12RemitTrace, type X12Remittance, type X12RequiredLoop, type X12ReviewDecision, type X12Segment, type X12ServiceLineStatus, type X12ServiceReview, type X12ServicesReview, type X12StatusCode, type X12StatusDate, type X12StatusEntity, type X12StatusInfo, type X12StatusMember, type X12StatusReference, type X12StatusTrace, type X12SubscriberInfo, type X12ToothInformation, type X12TransactionSet, type X12UnexpectedSegmentContext, type X12WarningCode, type X12WarningPartition, type X12_837ServiceLine, type X12_837ServiceLineDental, type X12_837ServiceLineInstitutional, type X12_837ServiceLineProfessional, type X12_837Submission, 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, 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, remitBalanceMismatch, renderCallerValue, resolveHiQualifier, segmentCountMismatch, serializeX12, setDefaultProfile, trailingGarbage, transactionCountMismatch, unescapeRelease, unexpectedSegment, unknown837Variant, unknownCarc, unknownClaimStatus, unknownClaimStatusCategory, unknownHiQualifier, unknownMaintenanceType, unknownRarc };
|