@cosyte/synth 0.0.7 → 0.0.8
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 +135 -17
- package/README.md +47 -45
- package/dist/astm/index.cjs +7 -7
- package/dist/astm/index.cjs.map +1 -1
- package/dist/astm/index.d.cts +47 -47
- package/dist/astm/index.d.ts +47 -47
- package/dist/astm/index.mjs +7 -7
- package/dist/astm/index.mjs.map +1 -1
- package/dist/ccda/index.cjs +15 -15
- package/dist/ccda/index.cjs.map +1 -1
- package/dist/ccda/index.d.cts +31 -31
- package/dist/ccda/index.d.ts +31 -31
- package/dist/ccda/index.mjs +15 -15
- package/dist/ccda/index.mjs.map +1 -1
- package/dist/deid/index.cjs +15 -15
- package/dist/deid/index.cjs.map +1 -1
- package/dist/deid/index.d.cts +37 -37
- package/dist/deid/index.d.ts +37 -37
- package/dist/deid/index.mjs +15 -15
- package/dist/deid/index.mjs.map +1 -1
- package/dist/{example-codes-DeXcnCSK.d.cts → example-codes-88f3_bQZ.d.cts} +8 -8
- package/dist/{example-codes-DeXcnCSK.d.ts → example-codes-88f3_bQZ.d.ts} +8 -8
- package/dist/fhir/index.cjs +12 -12
- package/dist/fhir/index.cjs.map +1 -1
- package/dist/fhir/index.d.cts +46 -46
- package/dist/fhir/index.d.ts +46 -46
- package/dist/fhir/index.mjs +12 -12
- package/dist/fhir/index.mjs.map +1 -1
- package/dist/hl7/index.cjs +6 -6
- package/dist/hl7/index.cjs.map +1 -1
- package/dist/hl7/index.d.cts +45 -45
- package/dist/hl7/index.d.ts +45 -45
- package/dist/hl7/index.mjs +6 -6
- package/dist/hl7/index.mjs.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -49
- package/dist/index.d.ts +49 -49
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/dist/ncpdp/index.cjs +3 -3
- package/dist/ncpdp/index.cjs.map +1 -1
- package/dist/ncpdp/index.d.cts +42 -42
- package/dist/ncpdp/index.d.ts +42 -42
- package/dist/ncpdp/index.mjs +3 -3
- package/dist/ncpdp/index.mjs.map +1 -1
- package/dist/{providers-OLz3zAc-.d.cts → providers-B9uVinAe.d.cts} +24 -24
- package/dist/{providers-OLz3zAc-.d.ts → providers-B9uVinAe.d.ts} +24 -24
- package/dist/{quirk-C9t9CkPS.d.ts → quirk-HZdznAkM.d.ts} +23 -23
- package/dist/{quirk-DYMDojVw.d.cts → quirk-IaHp4z7N.d.cts} +23 -23
- package/dist/x12/index.cjs +6 -6
- package/dist/x12/index.cjs.map +1 -1
- package/dist/x12/index.d.cts +44 -44
- package/dist/x12/index.d.ts +44 -44
- package/dist/x12/index.mjs +6 -6
- package/dist/x12/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/x12/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { b as SyntheticAddress, S as SyntheticName, R as Rng, C as Corpus } from '../providers-
|
|
1
|
+
import { b as SyntheticAddress, S as SyntheticName, R as Rng, C as Corpus } from '../providers-B9uVinAe.cjs';
|
|
2
2
|
import { X12Interchange, X12Decimal } from '@cosyte/x12';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Spec-clean HIPAA 005010 **837** claim generation
|
|
6
|
-
* Institutional (`build837I`, X223A3), and Dental (`build837D`, X224A2)
|
|
5
|
+
* Spec-clean HIPAA 005010 **837** claim generation: Professional (`build837P`, TR3 005010X222A2),
|
|
6
|
+
* Institutional (`build837I`, X223A3), and Dental (`build837D`, X224A2), built through
|
|
7
7
|
* `@cosyte/x12`'s domain builders so the ISA/GS/ST…SE/GE/IEA envelope, the computed HL spine, and
|
|
8
8
|
* every segment are the parser's own conservative emit. Every subscriber, patient,
|
|
9
9
|
* provider, and payer identifier is drawn from the synthetic-safety providers via {@link ./identity};
|
|
@@ -16,7 +16,7 @@ import { X12Interchange, X12Decimal } from '@cosyte/x12';
|
|
|
16
16
|
type Claim837Variant = "P" | "I" | "D";
|
|
17
17
|
/** Options for {@link generate837}. */
|
|
18
18
|
interface Generate837Options {
|
|
19
|
-
/** The seed (deterministic
|
|
19
|
+
/** The seed (deterministic: same seed yields a byte-identical interchange). */
|
|
20
20
|
readonly seed: number;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -76,8 +76,8 @@ declare function generate837D(options: Generate837Options): X12Interchange;
|
|
|
76
76
|
* Spec-clean HIPAA 005010X221A1 **835** Health Care Claim Payment/Advice (ERA) generation, built
|
|
77
77
|
* through `@cosyte/x12`'s `build835`. The 835 is **balance-checked by construction**:
|
|
78
78
|
* `build835` REFUSES an out-of-balance remit, so `synth` computes amounts that satisfy the three X12
|
|
79
|
-
* balance identities
|
|
80
|
-
* patientResponsibility`), and remit (`BPR-02 = Σ CLP-04 − Σ PLB`)
|
|
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
81
|
* builder. Patient, payer, and payee identity is drawn from the synthetic-safety providers
|
|
82
82
|
* ({@link ./identity}); every generated 835 round-trips through `@cosyte/x12` with zero warnings.
|
|
83
83
|
*
|
|
@@ -86,7 +86,7 @@ declare function generate837D(options: Generate837Options): X12Interchange;
|
|
|
86
86
|
|
|
87
87
|
/** Options for {@link generate835}. */
|
|
88
88
|
interface Generate835Options {
|
|
89
|
-
/** The seed (deterministic
|
|
89
|
+
/** The seed (deterministic: same seed yields a byte-identical interchange). */
|
|
90
90
|
readonly seed: number;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -114,7 +114,7 @@ declare function generate835(options: Generate835Options): X12Interchange;
|
|
|
114
114
|
* round-trips through `@cosyte/x12` with zero warnings.
|
|
115
115
|
*
|
|
116
116
|
* **Note (coverage tracks the builder):** `@cosyte/x12` ships a **271** builder but no
|
|
117
|
-
* **270** (request) builder
|
|
117
|
+
* **270** (request) builder, the 270 is only *read* (as the echoed trace on the 271). Per the
|
|
118
118
|
* through-the-builder discipline (never hand-write bytes around a missing builder), `synth` generates
|
|
119
119
|
* the 271 and **defers 270** until `@cosyte/x12` grows a `build270` (noted in the README + CHANGELOG).
|
|
120
120
|
*
|
|
@@ -123,7 +123,7 @@ declare function generate835(options: Generate835Options): X12Interchange;
|
|
|
123
123
|
|
|
124
124
|
/** Options for {@link generate271}. */
|
|
125
125
|
interface Generate271Options {
|
|
126
|
-
/** The seed (deterministic
|
|
126
|
+
/** The seed (deterministic: same seed yields a byte-identical interchange). */
|
|
127
127
|
readonly seed: number;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
@@ -144,9 +144,9 @@ interface Generate271Options {
|
|
|
144
144
|
declare function generate271(options: Generate271Options): X12Interchange;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* The **round-trip-through-the-parser harness** for X12
|
|
148
|
-
* generator. A generated interchange is "spec-clean" only if `@cosyte/x12
|
|
149
|
-
* `@cosyte/synth`'s own opinion
|
|
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
150
|
* parses it straight back through `parseX12`, and reports what the parser found, so a false
|
|
151
151
|
* "spec-clean" claim cannot hide.
|
|
152
152
|
*
|
|
@@ -188,14 +188,14 @@ declare function roundTrip(interchange: X12Interchange): RoundTripResult;
|
|
|
188
188
|
/**
|
|
189
189
|
* Shared money helpers for the X12 generators. X12 amounts are {@link "@cosyte/x12".X12Decimal}, never
|
|
190
190
|
* a float (float arithmetic destroys cents), so every generated charge / payment / adjustment is
|
|
191
|
-
* constructed through {@link dec}
|
|
191
|
+
* constructed through {@link dec}: a single, tested conversion point rather than a per-generator
|
|
192
192
|
* duplicate.
|
|
193
193
|
*
|
|
194
194
|
* @module
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
|
-
* A non-null `X12Decimal` from a decimal string. Throws on an unparseable string
|
|
198
|
+
* A non-null `X12Decimal` from a decimal string. Throws on an unparseable string: the generators only
|
|
199
199
|
* ever pass literals or `${n}.00` strings, so the throw is a defensive guard, never a runtime path.
|
|
200
200
|
*
|
|
201
201
|
* @param value - A decimal string, e.g. `"150.00"`.
|
|
@@ -223,27 +223,27 @@ declare function dec(value: string): X12Decimal;
|
|
|
223
223
|
declare function money(n: number): string;
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
* Synthetic identity for X12 healthcare transactions
|
|
226
|
+
* Synthetic identity for X12 healthcare transactions: every subscriber, patient, provider, and payer
|
|
227
227
|
* identifier `synth` puts into an 837 / 835 / 271 is minted here, and **only** from the
|
|
228
228
|
* synthetic-safety providers. X12 is uniquely identity-dense: a claim carries subscriber
|
|
229
|
-
* *and* patient names, member ids, provider NPIs, a provider tax id, dates of birth, and addresses
|
|
229
|
+
* *and* patient names, member ids, provider NPIs, a provider tax id, dates of birth, and addresses,
|
|
230
230
|
* across two HL loops. The synthetic-by-construction invariant is therefore attacked hardest here, so
|
|
231
231
|
* every locus below has a construction-level guarantee, not a heuristic:
|
|
232
232
|
*
|
|
233
|
-
* - **member id
|
|
233
|
+
* - **member id**: minted under the synthetic assigning authority (no reserved range exists; the
|
|
234
234
|
* *namespace* is the guarantee).
|
|
235
|
-
* - **NPI
|
|
235
|
+
* - **NPI**: a deliberately **invalid Luhn** check digit, so it can never be a NPPES-issued NPI
|
|
236
236
|
* ({@link ../safe/reserved.isSyntheticNpi}).
|
|
237
|
-
* - **provider tax id
|
|
238
|
-
* never be a real, issuable SSN (900–999 is never assigned as an SSN
|
|
237
|
+
* - **provider tax id**: emitted as an SSN (REF*SY) in the SSA **never-issued** 900-range, so it can
|
|
238
|
+
* never be a real, issuable SSN (900–999 is never assigned as an SSN, the universal synthetic-safe
|
|
239
239
|
* SSN convention).
|
|
240
|
-
* - **name
|
|
241
|
-
* implied); **address
|
|
240
|
+
* - **name**: the shipped clearly-fake pool; **DOB / dates**: the seeded generator (no real event
|
|
241
|
+
* implied); **address**: synthetic street + reserved ZIP.
|
|
242
242
|
*
|
|
243
243
|
* @module
|
|
244
244
|
*/
|
|
245
245
|
|
|
246
|
-
/** A synthetic person (subscriber / patient / rendering provider)
|
|
246
|
+
/** A synthetic person (subscriber / patient / rendering provider): all fields from `../safe`. */
|
|
247
247
|
interface X12Person {
|
|
248
248
|
/** Name from the shipped fake-name pool. */
|
|
249
249
|
readonly person: SyntheticName;
|
|
@@ -256,18 +256,18 @@ interface X12Person {
|
|
|
256
256
|
/** Synthetic postal address (reserved non-real ZIP). */
|
|
257
257
|
readonly address: SyntheticAddress;
|
|
258
258
|
}
|
|
259
|
-
/** A synthetic billing organization
|
|
259
|
+
/** A synthetic billing organization: org name + invalid-Luhn NPI + never-issued-SSN tax id. */
|
|
260
260
|
interface X12Organization {
|
|
261
261
|
/** A clearly-fictional organization name. */
|
|
262
262
|
readonly name: string;
|
|
263
263
|
/** A 10-digit NPI with a deliberately-invalid Luhn check digit (never a real NPI). */
|
|
264
264
|
readonly npi: string;
|
|
265
|
-
/** The provider tax id as a never-issued (900-range) SSN
|
|
265
|
+
/** The provider tax id as a never-issued (900-range) SSN, emitted at REF*SY. */
|
|
266
266
|
readonly taxIdSsn: string;
|
|
267
267
|
/** Synthetic postal address. */
|
|
268
268
|
readonly address: SyntheticAddress;
|
|
269
269
|
}
|
|
270
|
-
/** A synthetic payer
|
|
270
|
+
/** A synthetic payer: name + a synthetic payer id (PI). */
|
|
271
271
|
interface X12Payer {
|
|
272
272
|
/** A clearly-fictional payer name. */
|
|
273
273
|
readonly name: string;
|
|
@@ -296,7 +296,7 @@ interface X12TradingPartners {
|
|
|
296
296
|
*/
|
|
297
297
|
declare function x12Person(rng: Rng): X12Person;
|
|
298
298
|
/**
|
|
299
|
-
* Mint a synthetic billing organization
|
|
299
|
+
* Mint a synthetic billing organization: org name, an invalid-Luhn NPI, a never-issued-SSN tax id,
|
|
300
300
|
* and an address.
|
|
301
301
|
*
|
|
302
302
|
* @param rng - The seeded generator.
|
|
@@ -310,7 +310,7 @@ declare function x12Person(rng: Rng): X12Person;
|
|
|
310
310
|
*/
|
|
311
311
|
declare function x12Organization(rng: Rng): X12Organization;
|
|
312
312
|
/**
|
|
313
|
-
* Mint a synthetic rendering/service provider **person
|
|
313
|
+
* Mint a synthetic rendering/service provider **person**: a person name plus an invalid-Luhn NPI.
|
|
314
314
|
*
|
|
315
315
|
* @param rng - The seeded generator.
|
|
316
316
|
* @returns The provider name and NPI.
|
|
@@ -326,7 +326,7 @@ declare function x12ProviderPerson(rng: Rng): {
|
|
|
326
326
|
readonly npi: string;
|
|
327
327
|
};
|
|
328
328
|
/**
|
|
329
|
-
* Mint a synthetic payer
|
|
329
|
+
* Mint a synthetic payer: a fictional name and a synthetic payer id.
|
|
330
330
|
*
|
|
331
331
|
* @param rng - The seeded generator.
|
|
332
332
|
* @returns A synthetic {@link X12Payer}.
|
|
@@ -385,13 +385,13 @@ declare function x12EnvelopeTiming(rng: Rng): X12EnvelopeTiming;
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* License-clean example code pools for X12 generation. `synth` ships only a tiny curated
|
|
388
|
-
* set of **spec-example codes
|
|
389
|
-
* examples and the `@cosyte/x12` builder test fixtures
|
|
388
|
+
* set of **spec-example codes**: the same codes that appear in the WPC 005010 TR3 implementation-guide
|
|
389
|
+
* examples and the `@cosyte/x12` builder test fixtures, never a bundled CPT/ICD/NDC table. They are
|
|
390
390
|
* used purely to give a generated claim a structurally-valid code element; a consumer who needs a real
|
|
391
391
|
* code set supplies their own (matching `@cosyte/terminology`'s content-free stance).
|
|
392
392
|
*
|
|
393
393
|
* Every code here is a *structural placeholder*: a `synth` claim may pair a diagnosis and a procedure
|
|
394
|
-
* that make no clinical sense, and that is correct
|
|
394
|
+
* that make no clinical sense, and that is correct, `synth` exercises the *parser*, not clinical
|
|
395
395
|
* coherence.
|
|
396
396
|
*
|
|
397
397
|
* @module
|
|
@@ -400,11 +400,11 @@ declare function x12EnvelopeTiming(rng: Rng): X12EnvelopeTiming;
|
|
|
400
400
|
interface X12ExampleCode {
|
|
401
401
|
/** The code value (the element or composite component). */
|
|
402
402
|
readonly code: string;
|
|
403
|
-
/** A short human label
|
|
403
|
+
/** A short human label, documentation only, never emitted. */
|
|
404
404
|
readonly label: string;
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
|
-
* HCPCS/CPT professional procedure codes (SV1-01-2, qualifier `HC`)
|
|
407
|
+
* HCPCS/CPT professional procedure codes (SV1-01-2, qualifier `HC`): office-visit / lab E&M codes
|
|
408
408
|
* from the 837P TR3 examples. Structural placeholders only.
|
|
409
409
|
*/
|
|
410
410
|
declare const PROFESSIONAL_PROCEDURES: readonly X12ExampleCode[];
|
|
@@ -413,38 +413,38 @@ declare const PROCEDURE_MODIFIERS: readonly string[];
|
|
|
413
413
|
/** Place-of-service codes (CLM-05-1 / SV1-05). */
|
|
414
414
|
declare const PLACES_OF_SERVICE: readonly string[];
|
|
415
415
|
/**
|
|
416
|
-
* ICD-10-CM diagnosis codes (HI qualifier `ABK` principal / `ABF` secondary)
|
|
416
|
+
* ICD-10-CM diagnosis codes (HI qualifier `ABK` principal / `ABF` secondary): codes from the TR3
|
|
417
417
|
* examples. Structural placeholders only.
|
|
418
418
|
*/
|
|
419
419
|
declare const DIAGNOSES: readonly X12ExampleCode[];
|
|
420
|
-
/** NUBC revenue codes (837I SV2-01)
|
|
420
|
+
/** NUBC revenue codes (837I SV2-01): spec-example codes. */
|
|
421
421
|
declare const REVENUE_CODES: readonly X12ExampleCode[];
|
|
422
422
|
/** Institutional procedure codes paired with revenue lines (837I SV2-02-2, qualifier `HC`). */
|
|
423
423
|
declare const INSTITUTIONAL_PROCEDURES: readonly X12ExampleCode[];
|
|
424
|
-
/** CDT dental procedure codes (837D SV3-01-2, qualifier `AD`)
|
|
424
|
+
/** CDT dental procedure codes (837D SV3-01-2, qualifier `AD`): spec-example codes. */
|
|
425
425
|
declare const DENTAL_PROCEDURES: readonly X12ExampleCode[];
|
|
426
426
|
/** ADA tooth codes (837D TOO-02, qualifier `JP`) + surfaces (TOO-03). */
|
|
427
427
|
declare const TOOTH_CODES: readonly string[];
|
|
428
428
|
/** Tooth surface codes (TOO-03). */
|
|
429
429
|
declare const TOOTH_SURFACES: readonly string[];
|
|
430
430
|
/**
|
|
431
|
-
* Claim adjustment reason codes (CARC
|
|
431
|
+
* Claim adjustment reason codes (CARC: CAS-02) paired with a group code. CARC is a public WPC code
|
|
432
432
|
* list; these are the handful used in the 835 TR3 examples. Structural placeholders only.
|
|
433
433
|
*/
|
|
434
434
|
declare const CARC_CODES: readonly string[];
|
|
435
|
-
/** Service type codes (271 EB-03)
|
|
435
|
+
/** Service type codes (271 EB-03): the public X12 code list 1365, spec-example subset. */
|
|
436
436
|
declare const SERVICE_TYPE_CODES: readonly string[];
|
|
437
437
|
|
|
438
438
|
/**
|
|
439
|
-
* `@cosyte/synth/x12
|
|
439
|
+
* `@cosyte/synth/x12`: the X12 EDI generation surface, exposed as its own subpath so importing the
|
|
440
440
|
* package root does **not** pull `@cosyte/x12`. This is the **lazy, per-format** boundary: a consumer
|
|
441
441
|
* who only needs X12 fixtures imports `@cosyte/synth/x12`; one who needs only the core primitives
|
|
442
442
|
* never loads a parser.
|
|
443
|
-
* `@cosyte/x12` is an **optional peer dependency
|
|
443
|
+
* `@cosyte/x12` is an **optional peer dependency**, present only for this subpath.
|
|
444
444
|
*
|
|
445
445
|
* This subpath ships spec-clean HIPAA 005010 generation via `@cosyte/x12`'s domain
|
|
446
446
|
* builders: **837P/I/D** claims (`generate837P`/`generate837I`/`generate837D`), the **835** remittance
|
|
447
|
-
* (`generate835`), and the **271** eligibility response (`generate271`)
|
|
447
|
+
* (`generate835`), and the **271** eligibility response (`generate271`), each built through the
|
|
448
448
|
* parser's own builder so the ISA/GS/ST…SE/GE/IEA envelope and every segment are spec-clean by
|
|
449
449
|
* construction, each round-tripping through `@cosyte/x12` with zero warnings, and each drawing every
|
|
450
450
|
* subscriber/patient/provider identifier from the synthetic-safety providers.
|
|
@@ -455,7 +455,7 @@ declare const SERVICE_TYPE_CODES: readonly string[];
|
|
|
455
455
|
* @module
|
|
456
456
|
*/
|
|
457
457
|
|
|
458
|
-
/** Every X12 transaction kind {@link x12Corpus} generates
|
|
458
|
+
/** Every X12 transaction kind {@link x12Corpus} generates: the label used as the corpus `kind`. */
|
|
459
459
|
type X12CorpusKind = "837P" | "837I" | "837D" | "835" | "271";
|
|
460
460
|
/** Options for {@link x12Corpus}. */
|
|
461
461
|
interface X12CorpusOptions {
|
|
@@ -477,7 +477,7 @@ interface X12CorpusOptions {
|
|
|
477
477
|
* ```ts
|
|
478
478
|
* import { x12Corpus } from "@cosyte/synth/x12";
|
|
479
479
|
* const corpus = x12Corpus({ seed: 42 });
|
|
480
|
-
* corpus.artifacts.every((a) => a.warnings.length === 0); // true
|
|
480
|
+
* corpus.artifacts.every((a) => a.warnings.length === 0); // true, spec-clean
|
|
481
481
|
* ```
|
|
482
482
|
*/
|
|
483
483
|
declare function x12Corpus(options: X12CorpusOptions): Corpus;
|
package/dist/x12/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { b as SyntheticAddress, S as SyntheticName, R as Rng, C as Corpus } from '../providers-
|
|
1
|
+
import { b as SyntheticAddress, S as SyntheticName, R as Rng, C as Corpus } from '../providers-B9uVinAe.js';
|
|
2
2
|
import { X12Interchange, X12Decimal } from '@cosyte/x12';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Spec-clean HIPAA 005010 **837** claim generation
|
|
6
|
-
* Institutional (`build837I`, X223A3), and Dental (`build837D`, X224A2)
|
|
5
|
+
* Spec-clean HIPAA 005010 **837** claim generation: Professional (`build837P`, TR3 005010X222A2),
|
|
6
|
+
* Institutional (`build837I`, X223A3), and Dental (`build837D`, X224A2), built through
|
|
7
7
|
* `@cosyte/x12`'s domain builders so the ISA/GS/ST…SE/GE/IEA envelope, the computed HL spine, and
|
|
8
8
|
* every segment are the parser's own conservative emit. Every subscriber, patient,
|
|
9
9
|
* provider, and payer identifier is drawn from the synthetic-safety providers via {@link ./identity};
|
|
@@ -16,7 +16,7 @@ import { X12Interchange, X12Decimal } from '@cosyte/x12';
|
|
|
16
16
|
type Claim837Variant = "P" | "I" | "D";
|
|
17
17
|
/** Options for {@link generate837}. */
|
|
18
18
|
interface Generate837Options {
|
|
19
|
-
/** The seed (deterministic
|
|
19
|
+
/** The seed (deterministic: same seed yields a byte-identical interchange). */
|
|
20
20
|
readonly seed: number;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -76,8 +76,8 @@ declare function generate837D(options: Generate837Options): X12Interchange;
|
|
|
76
76
|
* Spec-clean HIPAA 005010X221A1 **835** Health Care Claim Payment/Advice (ERA) generation, built
|
|
77
77
|
* through `@cosyte/x12`'s `build835`. The 835 is **balance-checked by construction**:
|
|
78
78
|
* `build835` REFUSES an out-of-balance remit, so `synth` computes amounts that satisfy the three X12
|
|
79
|
-
* balance identities
|
|
80
|
-
* patientResponsibility`), and remit (`BPR-02 = Σ CLP-04 − Σ PLB`)
|
|
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
81
|
* builder. Patient, payer, and payee identity is drawn from the synthetic-safety providers
|
|
82
82
|
* ({@link ./identity}); every generated 835 round-trips through `@cosyte/x12` with zero warnings.
|
|
83
83
|
*
|
|
@@ -86,7 +86,7 @@ declare function generate837D(options: Generate837Options): X12Interchange;
|
|
|
86
86
|
|
|
87
87
|
/** Options for {@link generate835}. */
|
|
88
88
|
interface Generate835Options {
|
|
89
|
-
/** The seed (deterministic
|
|
89
|
+
/** The seed (deterministic: same seed yields a byte-identical interchange). */
|
|
90
90
|
readonly seed: number;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -114,7 +114,7 @@ declare function generate835(options: Generate835Options): X12Interchange;
|
|
|
114
114
|
* round-trips through `@cosyte/x12` with zero warnings.
|
|
115
115
|
*
|
|
116
116
|
* **Note (coverage tracks the builder):** `@cosyte/x12` ships a **271** builder but no
|
|
117
|
-
* **270** (request) builder
|
|
117
|
+
* **270** (request) builder, the 270 is only *read* (as the echoed trace on the 271). Per the
|
|
118
118
|
* through-the-builder discipline (never hand-write bytes around a missing builder), `synth` generates
|
|
119
119
|
* the 271 and **defers 270** until `@cosyte/x12` grows a `build270` (noted in the README + CHANGELOG).
|
|
120
120
|
*
|
|
@@ -123,7 +123,7 @@ declare function generate835(options: Generate835Options): X12Interchange;
|
|
|
123
123
|
|
|
124
124
|
/** Options for {@link generate271}. */
|
|
125
125
|
interface Generate271Options {
|
|
126
|
-
/** The seed (deterministic
|
|
126
|
+
/** The seed (deterministic: same seed yields a byte-identical interchange). */
|
|
127
127
|
readonly seed: number;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
@@ -144,9 +144,9 @@ interface Generate271Options {
|
|
|
144
144
|
declare function generate271(options: Generate271Options): X12Interchange;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* The **round-trip-through-the-parser harness** for X12
|
|
148
|
-
* generator. A generated interchange is "spec-clean" only if `@cosyte/x12
|
|
149
|
-
* `@cosyte/synth`'s own opinion
|
|
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
150
|
* parses it straight back through `parseX12`, and reports what the parser found, so a false
|
|
151
151
|
* "spec-clean" claim cannot hide.
|
|
152
152
|
*
|
|
@@ -188,14 +188,14 @@ declare function roundTrip(interchange: X12Interchange): RoundTripResult;
|
|
|
188
188
|
/**
|
|
189
189
|
* Shared money helpers for the X12 generators. X12 amounts are {@link "@cosyte/x12".X12Decimal}, never
|
|
190
190
|
* a float (float arithmetic destroys cents), so every generated charge / payment / adjustment is
|
|
191
|
-
* constructed through {@link dec}
|
|
191
|
+
* constructed through {@link dec}: a single, tested conversion point rather than a per-generator
|
|
192
192
|
* duplicate.
|
|
193
193
|
*
|
|
194
194
|
* @module
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
|
-
* A non-null `X12Decimal` from a decimal string. Throws on an unparseable string
|
|
198
|
+
* A non-null `X12Decimal` from a decimal string. Throws on an unparseable string: the generators only
|
|
199
199
|
* ever pass literals or `${n}.00` strings, so the throw is a defensive guard, never a runtime path.
|
|
200
200
|
*
|
|
201
201
|
* @param value - A decimal string, e.g. `"150.00"`.
|
|
@@ -223,27 +223,27 @@ declare function dec(value: string): X12Decimal;
|
|
|
223
223
|
declare function money(n: number): string;
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
* Synthetic identity for X12 healthcare transactions
|
|
226
|
+
* Synthetic identity for X12 healthcare transactions: every subscriber, patient, provider, and payer
|
|
227
227
|
* identifier `synth` puts into an 837 / 835 / 271 is minted here, and **only** from the
|
|
228
228
|
* synthetic-safety providers. X12 is uniquely identity-dense: a claim carries subscriber
|
|
229
|
-
* *and* patient names, member ids, provider NPIs, a provider tax id, dates of birth, and addresses
|
|
229
|
+
* *and* patient names, member ids, provider NPIs, a provider tax id, dates of birth, and addresses,
|
|
230
230
|
* across two HL loops. The synthetic-by-construction invariant is therefore attacked hardest here, so
|
|
231
231
|
* every locus below has a construction-level guarantee, not a heuristic:
|
|
232
232
|
*
|
|
233
|
-
* - **member id
|
|
233
|
+
* - **member id**: minted under the synthetic assigning authority (no reserved range exists; the
|
|
234
234
|
* *namespace* is the guarantee).
|
|
235
|
-
* - **NPI
|
|
235
|
+
* - **NPI**: a deliberately **invalid Luhn** check digit, so it can never be a NPPES-issued NPI
|
|
236
236
|
* ({@link ../safe/reserved.isSyntheticNpi}).
|
|
237
|
-
* - **provider tax id
|
|
238
|
-
* never be a real, issuable SSN (900–999 is never assigned as an SSN
|
|
237
|
+
* - **provider tax id**: emitted as an SSN (REF*SY) in the SSA **never-issued** 900-range, so it can
|
|
238
|
+
* never be a real, issuable SSN (900–999 is never assigned as an SSN, the universal synthetic-safe
|
|
239
239
|
* SSN convention).
|
|
240
|
-
* - **name
|
|
241
|
-
* implied); **address
|
|
240
|
+
* - **name**: the shipped clearly-fake pool; **DOB / dates**: the seeded generator (no real event
|
|
241
|
+
* implied); **address**: synthetic street + reserved ZIP.
|
|
242
242
|
*
|
|
243
243
|
* @module
|
|
244
244
|
*/
|
|
245
245
|
|
|
246
|
-
/** A synthetic person (subscriber / patient / rendering provider)
|
|
246
|
+
/** A synthetic person (subscriber / patient / rendering provider): all fields from `../safe`. */
|
|
247
247
|
interface X12Person {
|
|
248
248
|
/** Name from the shipped fake-name pool. */
|
|
249
249
|
readonly person: SyntheticName;
|
|
@@ -256,18 +256,18 @@ interface X12Person {
|
|
|
256
256
|
/** Synthetic postal address (reserved non-real ZIP). */
|
|
257
257
|
readonly address: SyntheticAddress;
|
|
258
258
|
}
|
|
259
|
-
/** A synthetic billing organization
|
|
259
|
+
/** A synthetic billing organization: org name + invalid-Luhn NPI + never-issued-SSN tax id. */
|
|
260
260
|
interface X12Organization {
|
|
261
261
|
/** A clearly-fictional organization name. */
|
|
262
262
|
readonly name: string;
|
|
263
263
|
/** A 10-digit NPI with a deliberately-invalid Luhn check digit (never a real NPI). */
|
|
264
264
|
readonly npi: string;
|
|
265
|
-
/** The provider tax id as a never-issued (900-range) SSN
|
|
265
|
+
/** The provider tax id as a never-issued (900-range) SSN, emitted at REF*SY. */
|
|
266
266
|
readonly taxIdSsn: string;
|
|
267
267
|
/** Synthetic postal address. */
|
|
268
268
|
readonly address: SyntheticAddress;
|
|
269
269
|
}
|
|
270
|
-
/** A synthetic payer
|
|
270
|
+
/** A synthetic payer: name + a synthetic payer id (PI). */
|
|
271
271
|
interface X12Payer {
|
|
272
272
|
/** A clearly-fictional payer name. */
|
|
273
273
|
readonly name: string;
|
|
@@ -296,7 +296,7 @@ interface X12TradingPartners {
|
|
|
296
296
|
*/
|
|
297
297
|
declare function x12Person(rng: Rng): X12Person;
|
|
298
298
|
/**
|
|
299
|
-
* Mint a synthetic billing organization
|
|
299
|
+
* Mint a synthetic billing organization: org name, an invalid-Luhn NPI, a never-issued-SSN tax id,
|
|
300
300
|
* and an address.
|
|
301
301
|
*
|
|
302
302
|
* @param rng - The seeded generator.
|
|
@@ -310,7 +310,7 @@ declare function x12Person(rng: Rng): X12Person;
|
|
|
310
310
|
*/
|
|
311
311
|
declare function x12Organization(rng: Rng): X12Organization;
|
|
312
312
|
/**
|
|
313
|
-
* Mint a synthetic rendering/service provider **person
|
|
313
|
+
* Mint a synthetic rendering/service provider **person**: a person name plus an invalid-Luhn NPI.
|
|
314
314
|
*
|
|
315
315
|
* @param rng - The seeded generator.
|
|
316
316
|
* @returns The provider name and NPI.
|
|
@@ -326,7 +326,7 @@ declare function x12ProviderPerson(rng: Rng): {
|
|
|
326
326
|
readonly npi: string;
|
|
327
327
|
};
|
|
328
328
|
/**
|
|
329
|
-
* Mint a synthetic payer
|
|
329
|
+
* Mint a synthetic payer: a fictional name and a synthetic payer id.
|
|
330
330
|
*
|
|
331
331
|
* @param rng - The seeded generator.
|
|
332
332
|
* @returns A synthetic {@link X12Payer}.
|
|
@@ -385,13 +385,13 @@ declare function x12EnvelopeTiming(rng: Rng): X12EnvelopeTiming;
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* License-clean example code pools for X12 generation. `synth` ships only a tiny curated
|
|
388
|
-
* set of **spec-example codes
|
|
389
|
-
* examples and the `@cosyte/x12` builder test fixtures
|
|
388
|
+
* set of **spec-example codes**: the same codes that appear in the WPC 005010 TR3 implementation-guide
|
|
389
|
+
* examples and the `@cosyte/x12` builder test fixtures, never a bundled CPT/ICD/NDC table. They are
|
|
390
390
|
* used purely to give a generated claim a structurally-valid code element; a consumer who needs a real
|
|
391
391
|
* code set supplies their own (matching `@cosyte/terminology`'s content-free stance).
|
|
392
392
|
*
|
|
393
393
|
* Every code here is a *structural placeholder*: a `synth` claim may pair a diagnosis and a procedure
|
|
394
|
-
* that make no clinical sense, and that is correct
|
|
394
|
+
* that make no clinical sense, and that is correct, `synth` exercises the *parser*, not clinical
|
|
395
395
|
* coherence.
|
|
396
396
|
*
|
|
397
397
|
* @module
|
|
@@ -400,11 +400,11 @@ declare function x12EnvelopeTiming(rng: Rng): X12EnvelopeTiming;
|
|
|
400
400
|
interface X12ExampleCode {
|
|
401
401
|
/** The code value (the element or composite component). */
|
|
402
402
|
readonly code: string;
|
|
403
|
-
/** A short human label
|
|
403
|
+
/** A short human label, documentation only, never emitted. */
|
|
404
404
|
readonly label: string;
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
|
-
* HCPCS/CPT professional procedure codes (SV1-01-2, qualifier `HC`)
|
|
407
|
+
* HCPCS/CPT professional procedure codes (SV1-01-2, qualifier `HC`): office-visit / lab E&M codes
|
|
408
408
|
* from the 837P TR3 examples. Structural placeholders only.
|
|
409
409
|
*/
|
|
410
410
|
declare const PROFESSIONAL_PROCEDURES: readonly X12ExampleCode[];
|
|
@@ -413,38 +413,38 @@ declare const PROCEDURE_MODIFIERS: readonly string[];
|
|
|
413
413
|
/** Place-of-service codes (CLM-05-1 / SV1-05). */
|
|
414
414
|
declare const PLACES_OF_SERVICE: readonly string[];
|
|
415
415
|
/**
|
|
416
|
-
* ICD-10-CM diagnosis codes (HI qualifier `ABK` principal / `ABF` secondary)
|
|
416
|
+
* ICD-10-CM diagnosis codes (HI qualifier `ABK` principal / `ABF` secondary): codes from the TR3
|
|
417
417
|
* examples. Structural placeholders only.
|
|
418
418
|
*/
|
|
419
419
|
declare const DIAGNOSES: readonly X12ExampleCode[];
|
|
420
|
-
/** NUBC revenue codes (837I SV2-01)
|
|
420
|
+
/** NUBC revenue codes (837I SV2-01): spec-example codes. */
|
|
421
421
|
declare const REVENUE_CODES: readonly X12ExampleCode[];
|
|
422
422
|
/** Institutional procedure codes paired with revenue lines (837I SV2-02-2, qualifier `HC`). */
|
|
423
423
|
declare const INSTITUTIONAL_PROCEDURES: readonly X12ExampleCode[];
|
|
424
|
-
/** CDT dental procedure codes (837D SV3-01-2, qualifier `AD`)
|
|
424
|
+
/** CDT dental procedure codes (837D SV3-01-2, qualifier `AD`): spec-example codes. */
|
|
425
425
|
declare const DENTAL_PROCEDURES: readonly X12ExampleCode[];
|
|
426
426
|
/** ADA tooth codes (837D TOO-02, qualifier `JP`) + surfaces (TOO-03). */
|
|
427
427
|
declare const TOOTH_CODES: readonly string[];
|
|
428
428
|
/** Tooth surface codes (TOO-03). */
|
|
429
429
|
declare const TOOTH_SURFACES: readonly string[];
|
|
430
430
|
/**
|
|
431
|
-
* Claim adjustment reason codes (CARC
|
|
431
|
+
* Claim adjustment reason codes (CARC: CAS-02) paired with a group code. CARC is a public WPC code
|
|
432
432
|
* list; these are the handful used in the 835 TR3 examples. Structural placeholders only.
|
|
433
433
|
*/
|
|
434
434
|
declare const CARC_CODES: readonly string[];
|
|
435
|
-
/** Service type codes (271 EB-03)
|
|
435
|
+
/** Service type codes (271 EB-03): the public X12 code list 1365, spec-example subset. */
|
|
436
436
|
declare const SERVICE_TYPE_CODES: readonly string[];
|
|
437
437
|
|
|
438
438
|
/**
|
|
439
|
-
* `@cosyte/synth/x12
|
|
439
|
+
* `@cosyte/synth/x12`: the X12 EDI generation surface, exposed as its own subpath so importing the
|
|
440
440
|
* package root does **not** pull `@cosyte/x12`. This is the **lazy, per-format** boundary: a consumer
|
|
441
441
|
* who only needs X12 fixtures imports `@cosyte/synth/x12`; one who needs only the core primitives
|
|
442
442
|
* never loads a parser.
|
|
443
|
-
* `@cosyte/x12` is an **optional peer dependency
|
|
443
|
+
* `@cosyte/x12` is an **optional peer dependency**, present only for this subpath.
|
|
444
444
|
*
|
|
445
445
|
* This subpath ships spec-clean HIPAA 005010 generation via `@cosyte/x12`'s domain
|
|
446
446
|
* builders: **837P/I/D** claims (`generate837P`/`generate837I`/`generate837D`), the **835** remittance
|
|
447
|
-
* (`generate835`), and the **271** eligibility response (`generate271`)
|
|
447
|
+
* (`generate835`), and the **271** eligibility response (`generate271`), each built through the
|
|
448
448
|
* parser's own builder so the ISA/GS/ST…SE/GE/IEA envelope and every segment are spec-clean by
|
|
449
449
|
* construction, each round-tripping through `@cosyte/x12` with zero warnings, and each drawing every
|
|
450
450
|
* subscriber/patient/provider identifier from the synthetic-safety providers.
|
|
@@ -455,7 +455,7 @@ declare const SERVICE_TYPE_CODES: readonly string[];
|
|
|
455
455
|
* @module
|
|
456
456
|
*/
|
|
457
457
|
|
|
458
|
-
/** Every X12 transaction kind {@link x12Corpus} generates
|
|
458
|
+
/** Every X12 transaction kind {@link x12Corpus} generates: the label used as the corpus `kind`. */
|
|
459
459
|
type X12CorpusKind = "837P" | "837I" | "837D" | "835" | "271";
|
|
460
460
|
/** Options for {@link x12Corpus}. */
|
|
461
461
|
interface X12CorpusOptions {
|
|
@@ -477,7 +477,7 @@ interface X12CorpusOptions {
|
|
|
477
477
|
* ```ts
|
|
478
478
|
* import { x12Corpus } from "@cosyte/synth/x12";
|
|
479
479
|
* const corpus = x12Corpus({ seed: 42 });
|
|
480
|
-
* corpus.artifacts.every((a) => a.warnings.length === 0); // true
|
|
480
|
+
* corpus.artifacts.every((a) => a.warnings.length === 0); // true, spec-clean
|
|
481
481
|
* ```
|
|
482
482
|
*/
|
|
483
483
|
declare function x12Corpus(options: X12CorpusOptions): Corpus;
|
package/dist/x12/index.mjs
CHANGED
|
@@ -31,15 +31,15 @@ function sfc32Next(s) {
|
|
|
31
31
|
|
|
32
32
|
// src/codes.ts
|
|
33
33
|
var SYNTH_FATAL_CODES = {
|
|
34
|
-
/** A money value could not be read as an X12 decimal. Fatal
|
|
34
|
+
/** A money value could not be read as an X12 decimal. Fatal: a generator never rounds to a float. */
|
|
35
35
|
SYNTH_INVALID_DECIMAL: "SYNTH_INVALID_DECIMAL",
|
|
36
36
|
/** An integer range was requested with its maximum below its minimum. Fatal. */
|
|
37
37
|
SYNTH_INVALID_RANGE: "SYNTH_INVALID_RANGE",
|
|
38
|
-
/** A value was drawn from an empty pool. Fatal
|
|
38
|
+
/** A value was drawn from an empty pool. Fatal, never a fabricated substitute. */
|
|
39
39
|
SYNTH_EMPTY_POOL: "SYNTH_EMPTY_POOL",
|
|
40
40
|
/**
|
|
41
41
|
* A caller-supplied selector (a message kind, a document type, a corpus mix entry, a claim
|
|
42
|
-
* variant, a Bundle type, a resource profile) is not in the closed set that governs it. Fatal
|
|
42
|
+
* variant, a Bundle type, a resource profile) is not in the closed set that governs it. Fatal:
|
|
43
43
|
* see `resolveKind`: a selector union is erased at run time, and a selector that falls through
|
|
44
44
|
* either mislabels the fixture or hands the value to a peer builder that quotes it back.
|
|
45
45
|
*/
|
|
@@ -141,7 +141,7 @@ function money(n) {
|
|
|
141
141
|
var SYNTHETIC_ASSIGNING_AUTHORITY = Object.freeze({
|
|
142
142
|
/** The human-readable assigning-authority namespace id (HL7 HD.1). */
|
|
143
143
|
namespaceId: "COSYTE-SYNTH",
|
|
144
|
-
/** The universal id
|
|
144
|
+
/** The universal id, an OID under HL7's example arc `2.16.840.1.113883.19` (HD.2). */
|
|
145
145
|
universalId: "2.16.840.1.113883.19.999",
|
|
146
146
|
/** The universal id type (HD.3). */
|
|
147
147
|
universalIdType: "ISO"
|
|
@@ -651,7 +651,7 @@ function specOf(rng, variant) {
|
|
|
651
651
|
claims: [
|
|
652
652
|
{
|
|
653
653
|
...claim,
|
|
654
|
-
// Rendering provider (Loop 2310B, NM1 fields round-trip)
|
|
654
|
+
// Rendering provider (Loop 2310B, NM1 fields round-trip), a person with an invalid-Luhn NPI.
|
|
655
655
|
providers: [
|
|
656
656
|
{
|
|
657
657
|
entityIdentifierCode: "82",
|
|
@@ -678,7 +678,7 @@ function specOf(rng, variant) {
|
|
|
678
678
|
state: org.address.state,
|
|
679
679
|
postalCode: org.address.zip
|
|
680
680
|
},
|
|
681
|
-
// Provider tax id as a never-issued (900-range) SSN at REF*SY
|
|
681
|
+
// Provider tax id as a never-issued (900-range) SSN at REF*SY, provably synthetic (roadmap §4.1).
|
|
682
682
|
references: [{ qualifier: "SY", value: org.taxIdSsn }]
|
|
683
683
|
},
|
|
684
684
|
subscribers: [subscriber]
|