@cosyte/synth 0.0.1
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 +414 -0
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/dist/astm/index.cjs +847 -0
- package/dist/astm/index.cjs.map +1 -0
- package/dist/astm/index.d.cts +418 -0
- package/dist/astm/index.d.ts +418 -0
- package/dist/astm/index.mjs +828 -0
- package/dist/astm/index.mjs.map +1 -0
- package/dist/ccda/index.cjs +1103 -0
- package/dist/ccda/index.cjs.map +1 -0
- package/dist/ccda/index.d.cts +380 -0
- package/dist/ccda/index.d.ts +380 -0
- package/dist/ccda/index.mjs +1077 -0
- package/dist/ccda/index.mjs.map +1 -0
- package/dist/deid/index.cjs +2809 -0
- package/dist/deid/index.cjs.map +1 -0
- package/dist/deid/index.d.cts +464 -0
- package/dist/deid/index.d.ts +464 -0
- package/dist/deid/index.mjs +2793 -0
- package/dist/deid/index.mjs.map +1 -0
- package/dist/example-codes-DeXcnCSK.d.cts +105 -0
- package/dist/example-codes-DeXcnCSK.d.ts +105 -0
- package/dist/fhir/index.cjs +1429 -0
- package/dist/fhir/index.cjs.map +1 -0
- package/dist/fhir/index.d.cts +772 -0
- package/dist/fhir/index.d.ts +772 -0
- package/dist/fhir/index.mjs +1384 -0
- package/dist/fhir/index.mjs.map +1 -0
- package/dist/hl7/index.cjs +1012 -0
- package/dist/hl7/index.cjs.map +1 -0
- package/dist/hl7/index.d.cts +548 -0
- package/dist/hl7/index.d.ts +548 -0
- package/dist/hl7/index.mjs +990 -0
- package/dist/hl7/index.mjs.map +1 -0
- package/dist/index.cjs +535 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +407 -0
- package/dist/index.d.ts +407 -0
- package/dist/index.mjs +488 -0
- package/dist/index.mjs.map +1 -0
- package/dist/ncpdp/index.cjs +714 -0
- package/dist/ncpdp/index.cjs.map +1 -0
- package/dist/ncpdp/index.d.cts +432 -0
- package/dist/ncpdp/index.d.ts +432 -0
- package/dist/ncpdp/index.mjs +695 -0
- package/dist/ncpdp/index.mjs.map +1 -0
- package/dist/providers-OLz3zAc-.d.cts +343 -0
- package/dist/providers-OLz3zAc-.d.ts +343 -0
- package/dist/quirk-DmkgoZdh.d.cts +239 -0
- package/dist/quirk-JLyO1Ncj.d.ts +239 -0
- package/dist/x12/index.cjs +920 -0
- package/dist/x12/index.cjs.map +1 -0
- package/dist/x12/index.d.cts +484 -0
- package/dist/x12/index.d.ts +484 -0
- package/dist/x12/index.mjs +892 -0
- package/dist/x12/index.mjs.map +1 -0
- package/package.json +210 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import { b as SyntheticAddress, S as SyntheticName, R as Rng, C as Corpus } from '../providers-OLz3zAc-.cjs';
|
|
2
|
+
import { X12Interchange, X12Decimal } from '@cosyte/x12';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Spec-clean HIPAA 005010 **837** claim generation — Professional (`build837P`, TR3 005010X222A2),
|
|
6
|
+
* Institutional (`build837I`, X223A3), and Dental (`build837D`, X224A2) — built through
|
|
7
|
+
* `@cosyte/x12`'s domain builders so the ISA/GS/ST…SE/GE/IEA envelope, the computed HL spine, and
|
|
8
|
+
* every segment are the parser's own conservative emit. Every subscriber, patient,
|
|
9
|
+
* provider, and payer identifier is drawn from the synthetic-safety providers via {@link ./identity};
|
|
10
|
+
* every generated 837 round-trips through `@cosyte/x12` with zero warnings.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The 837 variant to generate. */
|
|
16
|
+
type Claim837Variant = "P" | "I" | "D";
|
|
17
|
+
/** Options for {@link generate837}. */
|
|
18
|
+
interface Generate837Options {
|
|
19
|
+
/** The seed (deterministic — same seed yields a byte-identical interchange). */
|
|
20
|
+
readonly seed: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate a spec-clean 005010 837 claim of the given `variant`, built through `@cosyte/x12`'s
|
|
24
|
+
* `build837P` / `build837I` / `build837D`. Every identity value is synthetic-by-construction; the returned
|
|
25
|
+
* interchange round-trips through `@cosyte/x12` with zero warnings.
|
|
26
|
+
*
|
|
27
|
+
* @param variant - `"P"` professional, `"I"` institutional, or `"D"` dental.
|
|
28
|
+
* @param options - The seed. See {@link Generate837Options}.
|
|
29
|
+
* @returns A frozen `X12Interchange` (feed it to {@link ./round-trip.roundTrip} to verify).
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { generate837, roundTrip } from "@cosyte/synth/x12";
|
|
33
|
+
* const { specClean } = roundTrip(generate837("P", { seed: 42 }));
|
|
34
|
+
* // specClean === true
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare function generate837(variant: Claim837Variant, options: Generate837Options): X12Interchange;
|
|
38
|
+
/**
|
|
39
|
+
* Generate a spec-clean 837**P** (Professional) claim.
|
|
40
|
+
*
|
|
41
|
+
* @param options - The seed.
|
|
42
|
+
* @returns A frozen `X12Interchange`.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { generate837P } from "@cosyte/synth/x12";
|
|
46
|
+
* const ix = generate837P({ seed: 1 });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function generate837P(options: Generate837Options): X12Interchange;
|
|
50
|
+
/**
|
|
51
|
+
* Generate a spec-clean 837**I** (Institutional) claim.
|
|
52
|
+
*
|
|
53
|
+
* @param options - The seed.
|
|
54
|
+
* @returns A frozen `X12Interchange`.
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { generate837I } from "@cosyte/synth/x12";
|
|
58
|
+
* const ix = generate837I({ seed: 1 });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function generate837I(options: Generate837Options): X12Interchange;
|
|
62
|
+
/**
|
|
63
|
+
* Generate a spec-clean 837**D** (Dental) claim.
|
|
64
|
+
*
|
|
65
|
+
* @param options - The seed.
|
|
66
|
+
* @returns A frozen `X12Interchange`.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { generate837D } from "@cosyte/synth/x12";
|
|
70
|
+
* const ix = generate837D({ seed: 1 });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function generate837D(options: Generate837Options): X12Interchange;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Spec-clean HIPAA 005010X221A1 **835** Health Care Claim Payment/Advice (ERA) generation, built
|
|
77
|
+
* through `@cosyte/x12`'s `build835`. The 835 is **balance-checked by construction**:
|
|
78
|
+
* `build835` REFUSES an out-of-balance remit, so `synth` computes amounts that satisfy the three X12
|
|
79
|
+
* balance identities — line (`charge = payment + Σ CAS`), claim (`totalCharge = totalPayment +
|
|
80
|
+
* patientResponsibility`), and remit (`BPR-02 = Σ CLP-04 − Σ PLB`) — before handing them to the
|
|
81
|
+
* builder. Patient, payer, and payee identity is drawn from the synthetic-safety providers
|
|
82
|
+
* ({@link ./identity}); every generated 835 round-trips through `@cosyte/x12` with zero warnings.
|
|
83
|
+
*
|
|
84
|
+
* @module
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/** Options for {@link generate835}. */
|
|
88
|
+
interface Generate835Options {
|
|
89
|
+
/** The seed (deterministic — same seed yields a byte-identical interchange). */
|
|
90
|
+
readonly seed: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate a spec-clean 005010X221A1 835 remittance, built through `@cosyte/x12`'s `build835`. A single
|
|
94
|
+
* balanced claim with one service line: `charge = payment + patientResponsibility`, and the remit
|
|
95
|
+
* total equals the claim payment (no provider-level adjustments). Every identity value is
|
|
96
|
+
* synthetic-by-construction; the returned interchange round-trips with zero warnings.
|
|
97
|
+
*
|
|
98
|
+
* @param options - The seed. See {@link Generate835Options}.
|
|
99
|
+
* @returns A frozen `X12Interchange` (feed it to {@link ./round-trip.roundTrip} to verify).
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* import { generate835, roundTrip } from "@cosyte/synth/x12";
|
|
103
|
+
* const { specClean } = roundTrip(generate835({ seed: 7 }));
|
|
104
|
+
* // specClean === true
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function generate835(options: Generate835Options): X12Interchange;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Spec-clean HIPAA 005010X279A1 **271** Health Care Eligibility Benefit Response generation, built
|
|
111
|
+
* through `@cosyte/x12`'s `build271`. The 271 carries subscriber identity (name,
|
|
112
|
+
* member id, DOB, address) plus benefit information across the 20→21→22 HL hierarchy; every identity
|
|
113
|
+
* value is drawn from the synthetic-safety providers ({@link ./identity}). Every generated 271
|
|
114
|
+
* round-trips through `@cosyte/x12` with zero warnings.
|
|
115
|
+
*
|
|
116
|
+
* **Note (coverage tracks the builder):** `@cosyte/x12` ships a **271** builder but no
|
|
117
|
+
* **270** (request) builder — the 270 is only *read* (as the echoed trace on the 271). Per the
|
|
118
|
+
* through-the-builder discipline (never hand-write bytes around a missing builder), `synth` generates
|
|
119
|
+
* the 271 and **defers 270** until `@cosyte/x12` grows a `build270` (noted in the README + CHANGELOG).
|
|
120
|
+
*
|
|
121
|
+
* @module
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
/** Options for {@link generate271}. */
|
|
125
|
+
interface Generate271Options {
|
|
126
|
+
/** The seed (deterministic — same seed yields a byte-identical interchange). */
|
|
127
|
+
readonly seed: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Generate a spec-clean 005010X279A1 271 eligibility response, built through `@cosyte/x12`'s
|
|
131
|
+
* `build271`: one information source (payer) → one information receiver (provider) → one subscriber
|
|
132
|
+
* with an active-coverage benefit. Every identity value is synthetic-by-construction; the
|
|
133
|
+
* returned interchange round-trips with zero warnings.
|
|
134
|
+
*
|
|
135
|
+
* @param options - The seed. See {@link Generate271Options}.
|
|
136
|
+
* @returns A frozen `X12Interchange` (feed it to {@link ./round-trip.roundTrip} to verify).
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { generate271, roundTrip } from "@cosyte/synth/x12";
|
|
140
|
+
* const { specClean } = roundTrip(generate271({ seed: 3 }));
|
|
141
|
+
* // specClean === true
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare function generate271(options: Generate271Options): X12Interchange;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The **round-trip-through-the-parser harness** for X12 — the headline gate for the synthetic-fixture
|
|
148
|
+
* generator. A generated interchange is "spec-clean" only if `@cosyte/x12` — not
|
|
149
|
+
* `@cosyte/synth`'s own opinion — reads it back cleanly. This harness serializes a built interchange,
|
|
150
|
+
* parses it straight back through `parseX12`, and reports what the parser found, so a false
|
|
151
|
+
* "spec-clean" claim cannot hide.
|
|
152
|
+
*
|
|
153
|
+
* `@cosyte/x12`'s domain builders (`build837P`, `build835`, `build271`) are round-trip-by-construction
|
|
154
|
+
* (each maps its typed model to segments and computes the ISA/GS/ST…SE/GE/IEA envelope + counts), but
|
|
155
|
+
* this harness re-verifies that **independently**, against the parser, because the parser is the judge.
|
|
156
|
+
*
|
|
157
|
+
* @module
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
/** The verdict of one round-trip through `@cosyte/x12`. */
|
|
161
|
+
interface RoundTripResult {
|
|
162
|
+
/** The serialized X12 EDI (the builder/serializer's own conservative emit). */
|
|
163
|
+
readonly content: string;
|
|
164
|
+
/** The warning codes the parser emitted on re-parse. Empty ⇒ spec-clean. */
|
|
165
|
+
readonly warnings: readonly string[];
|
|
166
|
+
/** Whether re-serializing the re-parsed interchange is byte-identical to `content`. */
|
|
167
|
+
readonly byteStable: boolean;
|
|
168
|
+
/** `true` iff the artifact is spec-clean: zero warnings **and** byte-stable. */
|
|
169
|
+
readonly specClean: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Round-trip a built `@cosyte/x12` `X12Interchange` through serialize → parse → serialize and report
|
|
173
|
+
* the verdict. A spec-clean interchange re-parses with **zero warnings** and re-serializes
|
|
174
|
+
* byte-identically.
|
|
175
|
+
*
|
|
176
|
+
* @param interchange - The interchange to check (typically from a `generate837P` / `generate835` /
|
|
177
|
+
* `generate271`).
|
|
178
|
+
* @returns The {@link RoundTripResult}.
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* import { generate837P, roundTrip } from "@cosyte/synth/x12";
|
|
182
|
+
* const { specClean, warnings } = roundTrip(generate837P({ seed: 1 }));
|
|
183
|
+
* // specClean === true, warnings.length === 0
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function roundTrip(interchange: X12Interchange): RoundTripResult;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Shared money helpers for the X12 generators. X12 amounts are {@link "@cosyte/x12".X12Decimal}, never
|
|
190
|
+
* a float (float arithmetic destroys cents), so every generated charge / payment / adjustment is
|
|
191
|
+
* constructed through {@link dec} — a single, tested conversion point rather than a per-generator
|
|
192
|
+
* duplicate.
|
|
193
|
+
*
|
|
194
|
+
* @module
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A non-null `X12Decimal` from a decimal string. Throws on an unparseable string — the generators only
|
|
199
|
+
* ever pass literals or `${n}.00` strings, so the throw is a defensive guard, never a runtime path.
|
|
200
|
+
*
|
|
201
|
+
* @param value - A decimal string, e.g. `"150.00"`.
|
|
202
|
+
* @returns The parsed {@link "@cosyte/x12".X12Decimal}.
|
|
203
|
+
* @throws If `value` is not a valid X12 decimal.
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* import { dec } from "@cosyte/synth/x12";
|
|
207
|
+
* dec("150.00"); // X12Decimal
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
declare function dec(value: string): X12Decimal;
|
|
211
|
+
/**
|
|
212
|
+
* A whole-dollar `${n}.00` money string.
|
|
213
|
+
*
|
|
214
|
+
* @param n - The whole-dollar amount.
|
|
215
|
+
* @returns The `${n}.00` string.
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { money } from "@cosyte/synth/x12";
|
|
219
|
+
* money(150); // "150.00"
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare function money(n: number): string;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Synthetic identity for X12 healthcare transactions — every subscriber, patient, provider, and payer
|
|
226
|
+
* identifier `synth` puts into an 837 / 835 / 271 is minted here, and **only** from the
|
|
227
|
+
* synthetic-safety providers. X12 is uniquely identity-dense: a claim carries subscriber
|
|
228
|
+
* *and* patient names, member ids, provider NPIs, a provider tax id, dates of birth, and addresses —
|
|
229
|
+
* across two HL loops. The synthetic-by-construction invariant is therefore attacked hardest here, so
|
|
230
|
+
* every locus below has a construction-level guarantee, not a heuristic:
|
|
231
|
+
*
|
|
232
|
+
* - **member id** — minted under the synthetic assigning authority (no reserved range exists; the
|
|
233
|
+
* *namespace* is the guarantee).
|
|
234
|
+
* - **NPI** — a deliberately **invalid Luhn** check digit, so it can never be a NPPES-issued NPI
|
|
235
|
+
* ({@link ../safe/reserved.isSyntheticNpi}).
|
|
236
|
+
* - **provider tax id** — emitted as an SSN (REF*SY) in the SSA **never-issued** 900-range, so it can
|
|
237
|
+
* never be a real, issuable SSN (900–999 is never assigned as an SSN — the universal synthetic-safe
|
|
238
|
+
* SSN convention).
|
|
239
|
+
* - **name** — the shipped clearly-fake pool; **DOB / dates** — the seeded generator (no real event
|
|
240
|
+
* implied); **address** — synthetic street + reserved ZIP.
|
|
241
|
+
*
|
|
242
|
+
* @module
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
/** A synthetic person (subscriber / patient / rendering provider) — all fields from `../safe`. */
|
|
246
|
+
interface X12Person {
|
|
247
|
+
/** Name from the shipped fake-name pool. */
|
|
248
|
+
readonly person: SyntheticName;
|
|
249
|
+
/** Member/cardholder id, synthetic-AA scoped (all-digit under a synthetic namespace). */
|
|
250
|
+
readonly memberId: string;
|
|
251
|
+
/** Date of birth `CCYYMMDD` from the seeded generator. */
|
|
252
|
+
readonly dob: string;
|
|
253
|
+
/** Administrative sex (X12 DMG-03 `M`/`F`). */
|
|
254
|
+
readonly sex: "M" | "F";
|
|
255
|
+
/** Synthetic postal address (reserved non-real ZIP). */
|
|
256
|
+
readonly address: SyntheticAddress;
|
|
257
|
+
}
|
|
258
|
+
/** A synthetic billing organization — org name + invalid-Luhn NPI + never-issued-SSN tax id. */
|
|
259
|
+
interface X12Organization {
|
|
260
|
+
/** A clearly-fictional organization name. */
|
|
261
|
+
readonly name: string;
|
|
262
|
+
/** A 10-digit NPI with a deliberately-invalid Luhn check digit (never a real NPI). */
|
|
263
|
+
readonly npi: string;
|
|
264
|
+
/** The provider tax id as a never-issued (900-range) SSN — emitted at REF*SY. */
|
|
265
|
+
readonly taxIdSsn: string;
|
|
266
|
+
/** Synthetic postal address. */
|
|
267
|
+
readonly address: SyntheticAddress;
|
|
268
|
+
}
|
|
269
|
+
/** A synthetic payer — name + a synthetic payer id (PI). */
|
|
270
|
+
interface X12Payer {
|
|
271
|
+
/** A clearly-fictional payer name. */
|
|
272
|
+
readonly name: string;
|
|
273
|
+
/** The payer identifier (NM1*PR*...*PI), synthetic. */
|
|
274
|
+
readonly payerId: string;
|
|
275
|
+
}
|
|
276
|
+
/** The submitter / receiver trading-partner identity for the interchange envelope. */
|
|
277
|
+
interface X12TradingPartners {
|
|
278
|
+
/** ISA-06 / submitter id. */
|
|
279
|
+
readonly senderId: string;
|
|
280
|
+
/** ISA-08 / receiver id. */
|
|
281
|
+
readonly receiverId: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Mint a synthetic person. Fixed draw order (name → member id → DOB → sex → address) so the same seed
|
|
285
|
+
* yields the same person.
|
|
286
|
+
*
|
|
287
|
+
* @param rng - The seeded generator.
|
|
288
|
+
* @returns A synthetic {@link X12Person}.
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* import { createRng } from "@cosyte/synth";
|
|
292
|
+
* import { x12Person } from "@cosyte/synth/x12";
|
|
293
|
+
* const { person, memberId } = x12Person(createRng(1));
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
declare function x12Person(rng: Rng): X12Person;
|
|
297
|
+
/**
|
|
298
|
+
* Mint a synthetic billing organization — org name, an invalid-Luhn NPI, a never-issued-SSN tax id,
|
|
299
|
+
* and an address.
|
|
300
|
+
*
|
|
301
|
+
* @param rng - The seeded generator.
|
|
302
|
+
* @returns A synthetic {@link X12Organization}.
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* import { createRng } from "@cosyte/synth";
|
|
306
|
+
* import { x12Organization } from "@cosyte/synth/x12";
|
|
307
|
+
* const org = x12Organization(createRng(1)); // org.npi is invalid-Luhn; org.taxIdSsn is 900-range
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare function x12Organization(rng: Rng): X12Organization;
|
|
311
|
+
/**
|
|
312
|
+
* Mint a synthetic rendering/service provider **person** — a person name plus an invalid-Luhn NPI.
|
|
313
|
+
*
|
|
314
|
+
* @param rng - The seeded generator.
|
|
315
|
+
* @returns The provider name and NPI.
|
|
316
|
+
* @example
|
|
317
|
+
* ```ts
|
|
318
|
+
* import { createRng } from "@cosyte/synth";
|
|
319
|
+
* import { x12ProviderPerson } from "@cosyte/synth/x12";
|
|
320
|
+
* const rendering = x12ProviderPerson(createRng(1));
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
declare function x12ProviderPerson(rng: Rng): {
|
|
324
|
+
readonly person: SyntheticName;
|
|
325
|
+
readonly npi: string;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Mint a synthetic payer — a fictional name and a synthetic payer id.
|
|
329
|
+
*
|
|
330
|
+
* @param rng - The seeded generator.
|
|
331
|
+
* @returns A synthetic {@link X12Payer}.
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* import { createRng } from "@cosyte/synth";
|
|
335
|
+
* import { x12Payer } from "@cosyte/synth/x12";
|
|
336
|
+
* const payer = x12Payer(createRng(1));
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
declare function x12Payer(rng: Rng): X12Payer;
|
|
340
|
+
/**
|
|
341
|
+
* Mint synthetic submitter/receiver trading-partner ids for the interchange envelope. These are not
|
|
342
|
+
* PHI, but are kept clearly synthetic for consistency.
|
|
343
|
+
*
|
|
344
|
+
* @param rng - The seeded generator.
|
|
345
|
+
* @returns Synthetic {@link X12TradingPartners}.
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* import { createRng } from "@cosyte/synth";
|
|
349
|
+
* import { x12TradingPartners } from "@cosyte/synth/x12";
|
|
350
|
+
* const { senderId, receiverId } = x12TradingPartners(createRng(1));
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
declare function x12TradingPartners(rng: Rng): X12TradingPartners;
|
|
354
|
+
/** A seeded interchange/group/transaction envelope timing + control-number bundle. */
|
|
355
|
+
interface X12EnvelopeTiming {
|
|
356
|
+
/** ISA-09 interchange date `YYMMDD`. */
|
|
357
|
+
readonly interchangeDate: string;
|
|
358
|
+
/** ISA-10 interchange time `HHMM`. */
|
|
359
|
+
readonly interchangeTime: string;
|
|
360
|
+
/** ISA-13 interchange control number (9 digits). */
|
|
361
|
+
readonly interchangeControlNumber: string;
|
|
362
|
+
/** GS-06 group control number. */
|
|
363
|
+
readonly groupControlNumber: string;
|
|
364
|
+
/** ST-02 transaction set control number (4+ digits). */
|
|
365
|
+
readonly transactionSetControlNumber: string;
|
|
366
|
+
/** A `CCYYMMDD` transaction/service base date (recent, seeded). */
|
|
367
|
+
readonly serviceDate: string;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Mint a seeded envelope timing + control-number bundle. The service/transaction date is drawn in a
|
|
371
|
+
* recent plausible window (2024–2026) so a generated transaction reads like a current one; every value
|
|
372
|
+
* is seeded, so the interchange is byte-reproducible.
|
|
373
|
+
*
|
|
374
|
+
* @param rng - The seeded generator.
|
|
375
|
+
* @returns A synthetic {@link X12EnvelopeTiming}.
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* import { createRng } from "@cosyte/synth";
|
|
379
|
+
* import { x12EnvelopeTiming } from "@cosyte/synth/x12";
|
|
380
|
+
* const timing = x12EnvelopeTiming(createRng(1));
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
declare function x12EnvelopeTiming(rng: Rng): X12EnvelopeTiming;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* License-clean example code pools for X12 generation. `synth` ships only a tiny curated
|
|
387
|
+
* set of **spec-example codes** — the same codes that appear in the WPC 005010 TR3 implementation-guide
|
|
388
|
+
* examples and the `@cosyte/x12` builder test fixtures — never a bundled CPT/ICD/NDC table. They are
|
|
389
|
+
* used purely to give a generated claim a structurally-valid code element; a consumer who needs a real
|
|
390
|
+
* code set supplies their own (matching `@cosyte/terminology`'s content-free stance).
|
|
391
|
+
*
|
|
392
|
+
* Every code here is a *structural placeholder*: a `synth` claim may pair a diagnosis and a procedure
|
|
393
|
+
* that make no clinical sense, and that is correct — `synth` exercises the *parser*, not clinical
|
|
394
|
+
* coherence.
|
|
395
|
+
*
|
|
396
|
+
* @module
|
|
397
|
+
*/
|
|
398
|
+
/** A code drawn from a pool, with the X12 qualifier that names its code system. */
|
|
399
|
+
interface X12ExampleCode {
|
|
400
|
+
/** The code value (the element or composite component). */
|
|
401
|
+
readonly code: string;
|
|
402
|
+
/** A short human label — documentation only, never emitted. */
|
|
403
|
+
readonly label: string;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* HCPCS/CPT professional procedure codes (SV1-01-2, qualifier `HC`) — office-visit / lab E&M codes
|
|
407
|
+
* from the 837P TR3 examples. Structural placeholders only.
|
|
408
|
+
*/
|
|
409
|
+
declare const PROFESSIONAL_PROCEDURES: readonly X12ExampleCode[];
|
|
410
|
+
/** Professional procedure modifiers (SV1-01-3..6). */
|
|
411
|
+
declare const PROCEDURE_MODIFIERS: readonly string[];
|
|
412
|
+
/** Place-of-service codes (CLM-05-1 / SV1-05). */
|
|
413
|
+
declare const PLACES_OF_SERVICE: readonly string[];
|
|
414
|
+
/**
|
|
415
|
+
* ICD-10-CM diagnosis codes (HI qualifier `ABK` principal / `ABF` secondary) — codes from the TR3
|
|
416
|
+
* examples. Structural placeholders only.
|
|
417
|
+
*/
|
|
418
|
+
declare const DIAGNOSES: readonly X12ExampleCode[];
|
|
419
|
+
/** NUBC revenue codes (837I SV2-01) — spec-example codes. */
|
|
420
|
+
declare const REVENUE_CODES: readonly X12ExampleCode[];
|
|
421
|
+
/** Institutional procedure codes paired with revenue lines (837I SV2-02-2, qualifier `HC`). */
|
|
422
|
+
declare const INSTITUTIONAL_PROCEDURES: readonly X12ExampleCode[];
|
|
423
|
+
/** CDT dental procedure codes (837D SV3-01-2, qualifier `AD`) — spec-example codes. */
|
|
424
|
+
declare const DENTAL_PROCEDURES: readonly X12ExampleCode[];
|
|
425
|
+
/** ADA tooth codes (837D TOO-02, qualifier `JP`) + surfaces (TOO-03). */
|
|
426
|
+
declare const TOOTH_CODES: readonly string[];
|
|
427
|
+
/** Tooth surface codes (TOO-03). */
|
|
428
|
+
declare const TOOTH_SURFACES: readonly string[];
|
|
429
|
+
/**
|
|
430
|
+
* Claim adjustment reason codes (CARC — CAS-02) paired with a group code. CARC is a public WPC code
|
|
431
|
+
* list; these are the handful used in the 835 TR3 examples. Structural placeholders only.
|
|
432
|
+
*/
|
|
433
|
+
declare const CARC_CODES: readonly string[];
|
|
434
|
+
/** Service type codes (271 EB-03) — the public X12 code list 1365, spec-example subset. */
|
|
435
|
+
declare const SERVICE_TYPE_CODES: readonly string[];
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* `@cosyte/synth/x12` — the X12 EDI generation surface, exposed as its own subpath so importing the
|
|
439
|
+
* package root does **not** pull `@cosyte/x12`. This is the **lazy, per-format** boundary: a consumer
|
|
440
|
+
* who only needs X12 fixtures imports `@cosyte/synth/x12`; one who needs only the core primitives
|
|
441
|
+
* never loads a parser.
|
|
442
|
+
* `@cosyte/x12` is an **optional peer dependency** — present only for this subpath.
|
|
443
|
+
*
|
|
444
|
+
* This subpath ships spec-clean HIPAA 005010 generation via `@cosyte/x12`'s domain
|
|
445
|
+
* builders: **837P/I/D** claims (`generate837P`/`generate837I`/`generate837D`), the **835** remittance
|
|
446
|
+
* (`generate835`), and the **271** eligibility response (`generate271`) — each built through the
|
|
447
|
+
* parser's own builder so the ISA/GS/ST…SE/GE/IEA envelope and every segment are spec-clean by
|
|
448
|
+
* construction, each round-tripping through `@cosyte/x12` with zero warnings, and each drawing every
|
|
449
|
+
* subscriber/patient/provider identifier from the synthetic-safety providers.
|
|
450
|
+
*
|
|
451
|
+
* **Deferred (coverage tracks the builder):** the **270** request (`@cosyte/x12` ships no
|
|
452
|
+
* `build270`) and **quirk mode**.
|
|
453
|
+
*
|
|
454
|
+
* @module
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
/** Every X12 transaction kind {@link x12Corpus} generates — the label used as the corpus `kind`. */
|
|
458
|
+
type X12CorpusKind = "837P" | "837I" | "837D" | "835" | "271";
|
|
459
|
+
/** Options for {@link x12Corpus}. */
|
|
460
|
+
interface X12CorpusOptions {
|
|
461
|
+
/** The seed for the whole corpus (deterministic). */
|
|
462
|
+
readonly seed: number;
|
|
463
|
+
/** How many transactions to generate. Defaults to the length of the mix. */
|
|
464
|
+
readonly count?: number;
|
|
465
|
+
/** The transaction kinds to cycle through. Defaults to one of each. */
|
|
466
|
+
readonly mix?: readonly X12CorpusKind[];
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Build a reproducible {@link Corpus} of spec-clean X12 transactions. Each transaction is generated from
|
|
470
|
+
* a distinct sub-seed derived from the corpus seed (so the set is deterministic) and round-tripped
|
|
471
|
+
* through `@cosyte/x12`; the per-artifact `warnings` record the parser's verdict (empty ⇒ spec-clean).
|
|
472
|
+
*
|
|
473
|
+
* @param options - Seed, count, and the transaction mix. See {@link X12CorpusOptions}.
|
|
474
|
+
* @returns A deep-frozen {@link Corpus}.
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* import { x12Corpus } from "@cosyte/synth/x12";
|
|
478
|
+
* const corpus = x12Corpus({ seed: 42 });
|
|
479
|
+
* corpus.artifacts.every((a) => a.warnings.length === 0); // true — spec-clean
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
declare function x12Corpus(options: X12CorpusOptions): Corpus;
|
|
483
|
+
|
|
484
|
+
export { CARC_CODES, type Claim837Variant, DENTAL_PROCEDURES, DIAGNOSES, type Generate271Options, type Generate835Options, type Generate837Options, INSTITUTIONAL_PROCEDURES, PLACES_OF_SERVICE, PROCEDURE_MODIFIERS, PROFESSIONAL_PROCEDURES, REVENUE_CODES, type RoundTripResult, SERVICE_TYPE_CODES, TOOTH_CODES, TOOTH_SURFACES, type X12CorpusKind, type X12CorpusOptions, type X12EnvelopeTiming, type X12ExampleCode, type X12Organization, type X12Payer, type X12Person, type X12TradingPartners, dec, generate271, generate835, generate837, generate837D, generate837I, generate837P, money, roundTrip, x12Corpus, x12EnvelopeTiming, x12Organization, x12Payer, x12Person, x12ProviderPerson, x12TradingPartners };
|