@cosyte/synth 0.1.4 → 0.1.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d13238: The exported example-code pools and the fatal-code registry are now frozen all the way down. `EXAMPLE_ASTM_TESTS` (`@cosyte/synth/astm`), `EXAMPLE_DRUGS` (`@cosyte/synth/ncpdp`) and the X12 pools `PROFESSIONAL_PROCEDURES`, `INSTITUTIONAL_PROCEDURES`, `DENTAL_PROCEDURES`, `REVENUE_CODES` and `DIAGNOSES` (`@cosyte/synth/x12`) froze the array but left each entry writable, so a JavaScript caller could rewrite an entry and change what every later call with the same seed generated. `SYNTH_FATAL_CODES` was not frozen at all, so a caller could change the code a later `SynthError` carried. Each entry and the registry are now frozen, as the other pools already were, and a write to one throws in strict mode.
8
+
9
+ No generated value, export, warning code or seed mapping changes.
10
+
11
+ - cbae766: Doc comments only. `luhnMod10` is exported from `@cosyte/synth`, so it is public: its doc comment no longer marks it internal, and it now carries an example like any other export. The comment on the fatal-code module that ships in the type declarations now says in plain words how a parser handles bad input.
12
+
13
+ No generated value, export, warning code or seed mapping changes.
14
+
3
15
  ## 0.1.4
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -62,8 +62,9 @@ Node.js 22 or later, tested on 22, 24, and 26.
62
62
  `@cosyte/hl7`, `@cosyte/fhir`, `@cosyte/ccda`, `@cosyte/x12`, `@cosyte/ncpdp`, `@cosyte/astm`, and
63
63
  `@cosyte/deid` are **optional peer dependencies**, each needed only for its subpath (`@cosyte/synth/hl7`,
64
64
  `@cosyte/synth/fhir`, `@cosyte/synth/ccda`, `@cosyte/synth/x12`, `@cosyte/synth/ncpdp`,
65
- `@cosyte/synth/astm`, and `@cosyte/synth/deid`: the last needs `@cosyte/deid` **plus** the parsers for
66
- the formats it pairs): install only the packages whose fixtures you generate. The package core has
65
+ `@cosyte/synth/astm`, and `@cosyte/synth/deid`: the last loads `@cosyte/deid` **plus** the five
66
+ parsers it pairs, `@cosyte/hl7`, `@cosyte/fhir`, `@cosyte/ccda`, `@cosyte/x12`, and `@cosyte/ncpdp`,
67
+ as soon as it is imported): install only the packages whose fixtures you generate. The package core has
67
68
  **zero third-party runtime dependencies**.
68
69
 
69
70
  ## Usage
@@ -367,21 +368,24 @@ isSyntheticNpi(safe.npi(rng)); // true, always a deliberately-invalid-Luhn NPI (
367
368
 
368
369
  The full reference is on [docs.cosyte.com/synth](https://docs.cosyte.com/synth):
369
370
 
370
- - [Installation](https://docs.cosyte.com/synth/installation) and the [quickstart](https://docs.cosyte.com/synth/quickstart).
371
- - Core concepts: [the archetype](https://docs.cosyte.com/synth/concepts-archetype) and the [limitations](https://docs.cosyte.com/synth/limitations).
372
- - Guides: [the overview](https://docs.cosyte.com/synth/guides-overview), [FHIR R4 and US Core](https://docs.cosyte.com/synth/guides-fhir),
371
+ - [Installation](https://docs.cosyte.com/synth/installation), the [quickstart](https://docs.cosyte.com/synth/quickstart), and
372
+ a tutorial: [test your HL7 handling with generated fixtures](https://docs.cosyte.com/synth/test-hl7-handling-with-fixtures).
373
+ - How-to guides: [HL7 v2](https://docs.cosyte.com/synth/guides-hl7), [FHIR R4 and US Core](https://docs.cosyte.com/synth/guides-fhir),
373
374
  [C-CDA](https://docs.cosyte.com/synth/guides-ccda), [X12](https://docs.cosyte.com/synth/guides-x12), [NCPDP](https://docs.cosyte.com/synth/guides-ncpdp),
374
- [ASTM](https://docs.cosyte.com/synth/guides-astm), [vendor quirks](https://docs.cosyte.com/synth/guides-quirks), and
375
- [the `@cosyte/deid` pairing loop](https://docs.cosyte.com/synth/guides-deid).
376
- - [Troubleshooting](https://docs.cosyte.com/synth/troubleshooting).
375
+ [ASTM](https://docs.cosyte.com/synth/guides-astm), [vendor quirks](https://docs.cosyte.com/synth/guides-quirks),
376
+ [the `@cosyte/deid` pairing loop](https://docs.cosyte.com/synth/guides-deid), [synthetic values](https://docs.cosyte.com/synth/draw-synthetic-values),
377
+ and [pinning a golden fixture](https://docs.cosyte.com/synth/guides-overview).
378
+ - Explanation: [how it works](https://docs.cosyte.com/synth/concepts-archetype) and [what it does and does not do](https://docs.cosyte.com/synth/limitations).
379
+ - Reference: [fatal codes](https://docs.cosyte.com/synth/fatal-codes), the [quirk catalog](https://docs.cosyte.com/synth/quirk-catalog), and the API reference.
380
+ - [Troubleshooting](https://docs.cosyte.com/synth/troubleshooting), [testing and quality](https://docs.cosyte.com/synth/testing-and-quality), and [performance](https://docs.cosyte.com/synth/performance).
377
381
  - [`CHANGELOG.md`](https://github.com/cosyte/synth/blob/main/CHANGELOG.md): every release.
378
382
 
379
383
  ## Support
380
384
 
381
385
  Questions, bug reports, and requests for a format or a quirk go in
382
386
  [GitHub issues](https://github.com/cosyte/synth/issues). Every fixture this package makes is
383
- synthetic: never attach a real patient's data to an issue. For help with an integration test suite,
384
- see our [integration services](https://cosyte.com/integration-services).
387
+ synthetic: never attach a real patient's data to an issue. Need an integration built and tested, or
388
+ hosted and run for you? See our [integration services](https://cosyte.com/integration-services).
385
389
 
386
390
  ## Security
387
391
 
@@ -32,7 +32,16 @@ function sfc32Next(s) {
32
32
  }
33
33
 
34
34
  // src/codes.ts
35
- var SYNTH_FATAL_CODES = {
35
+ var SYNTH_FATAL_CODES = Object.freeze({
36
+ /**
37
+ * A format was requested that this build cannot generate through a real parser builder/serializer.
38
+ * Fatal, never a hand-written byte fallback.
39
+ *
40
+ * **No code path in this build raises it.** All six formats generate, so it is reserved for a
41
+ * future format that does not, and is kept because removing a published code is a breaking change.
42
+ * An unsupported *kind* within a format that does generate is `SYNTH_UNSUPPORTED_KIND`.
43
+ */
44
+ SYNTH_UNSUPPORTED_FORMAT: "SYNTH_UNSUPPORTED_FORMAT",
36
45
  /**
37
46
  * A vendor quirk was requested that the target format's profile system does not support. Fatal,
38
47
  * never a silent no-op and never a fabricated quirk.
@@ -49,6 +58,10 @@ var SYNTH_FATAL_CODES = {
49
58
  * warning code(s). Fatal, never emit a mislabeled fixture.
50
59
  */
51
60
  SYNTH_INTENDED_WARNING_MISMATCH: "SYNTH_INTENDED_WARNING_MISMATCH",
61
+ /** A concept's code-system URI has no OID mapping in the C-CDA example-code table. Fatal. */
62
+ SYNTH_UNMAPPED_CODE_SYSTEM: "SYNTH_UNMAPPED_CODE_SYSTEM",
63
+ /** A money value could not be read as an X12 decimal. Fatal: a generator never rounds to a float. */
64
+ SYNTH_INVALID_DECIMAL: "SYNTH_INVALID_DECIMAL",
52
65
  /** An integer range was requested with its maximum below its minimum. Fatal. */
53
66
  SYNTH_INVALID_RANGE: "SYNTH_INVALID_RANGE",
54
67
  /** A value was drawn from an empty pool. Fatal, never a fabricated substitute. */
@@ -61,7 +74,17 @@ var SYNTH_FATAL_CODES = {
61
74
  * see `resolveKind`: a selector union is erased at run time, and a selector that falls through
62
75
  * either mislabels the fixture or hands the value to a peer builder that quotes it back.
63
76
  */
64
- SYNTH_UNSUPPORTED_KIND: "SYNTH_UNSUPPORTED_KIND"};
77
+ SYNTH_UNSUPPORTED_KIND: "SYNTH_UNSUPPORTED_KIND",
78
+ /**
79
+ * A requested profile IS published by the adopted implementation guide, and this build does not
80
+ * generate it. Deliberately distinct from `SYNTH_UNSUPPORTED_KIND`, which says the name is not in
81
+ * the adopted set at all: "the guide does not publish this" and "we do not generate this yet" are
82
+ * different answers, and a caller building to a regulatory profile set has to be able to tell them
83
+ * apart without matching message text. Fatal, and raised **before** anything is generated: a
84
+ * mislabelled artifact is worse than no artifact.
85
+ */
86
+ SYNTH_PROFILE_NOT_GENERATED: "SYNTH_PROFILE_NOT_GENERATED"
87
+ });
65
88
  var SYNTH_FATAL_MESSAGES = Object.freeze({
66
89
  SYNTH_UNSUPPORTED_FORMAT: "The requested format is not generable by this build. A generator has no byte fallback: it builds through a parser's own serializer or it refuses.",
67
90
  SYNTH_UNSUPPORTED_QUIRK: "The requested vendor quirk is not in the target format's quirk registry. Compare the request against that format's exported registry (HL7_QUIRKS, CCDA_QUIRKS, ASTM_QUIRKS).",
@@ -472,88 +495,90 @@ function astmHeaderIdentity(rng) {
472
495
  }
473
496
 
474
497
  // src/astm/example-codes.ts
475
- var EXAMPLE_ASTM_TESTS = Object.freeze([
476
- {
477
- localCode: "GLU",
478
- loinc: "2345-7",
479
- name: "Glucose",
480
- units: "mg/dL",
481
- referenceRange: "70-110",
482
- valueLow: 55,
483
- valueHigh: 260,
484
- decimals: 0
485
- },
486
- {
487
- localCode: "K",
488
- loinc: "2823-3",
489
- name: "Potassium",
490
- units: "mmol/L",
491
- referenceRange: "3.5-5.1",
492
- valueLow: 28,
493
- valueHigh: 62,
494
- decimals: 1
495
- },
496
- {
497
- localCode: "NA",
498
- loinc: "2951-2",
499
- name: "Sodium",
500
- units: "mmol/L",
501
- referenceRange: "136-145",
502
- valueLow: 125,
503
- valueHigh: 155,
504
- decimals: 0
505
- },
506
- {
507
- localCode: "CREA",
508
- loinc: "2160-0",
509
- name: "Creatinine",
510
- units: "mg/dL",
511
- referenceRange: "0.6-1.3",
512
- valueLow: 4,
513
- valueHigh: 32,
514
- decimals: 1
515
- },
516
- {
517
- localCode: "HGB",
518
- loinc: "718-7",
519
- name: "Hemoglobin",
520
- units: "g/dL",
521
- referenceRange: "12.0-17.5",
522
- valueLow: 80,
523
- valueHigh: 190,
524
- decimals: 1
525
- },
526
- {
527
- localCode: "WBC",
528
- loinc: "6690-2",
529
- name: "Leukocytes",
530
- units: "10*3/uL",
531
- referenceRange: "4.5-11.0",
532
- valueLow: 30,
533
- valueHigh: 150,
534
- decimals: 1
535
- },
536
- {
537
- localCode: "TSH",
538
- loinc: "3016-3",
539
- name: "Thyrotropin",
540
- units: "mIU/L",
541
- referenceRange: "0.40-4.50",
542
- valueLow: 2,
543
- valueHigh: 90,
544
- decimals: 2
545
- },
546
- {
547
- localCode: "ALT",
548
- loinc: "1742-6",
549
- name: "Alanine aminotransferase",
550
- units: "U/L",
551
- referenceRange: "7-56",
552
- valueLow: 5,
553
- valueHigh: 120,
554
- decimals: 0
555
- }
556
- ]);
498
+ var EXAMPLE_ASTM_TESTS = Object.freeze(
499
+ [
500
+ {
501
+ localCode: "GLU",
502
+ loinc: "2345-7",
503
+ name: "Glucose",
504
+ units: "mg/dL",
505
+ referenceRange: "70-110",
506
+ valueLow: 55,
507
+ valueHigh: 260,
508
+ decimals: 0
509
+ },
510
+ {
511
+ localCode: "K",
512
+ loinc: "2823-3",
513
+ name: "Potassium",
514
+ units: "mmol/L",
515
+ referenceRange: "3.5-5.1",
516
+ valueLow: 28,
517
+ valueHigh: 62,
518
+ decimals: 1
519
+ },
520
+ {
521
+ localCode: "NA",
522
+ loinc: "2951-2",
523
+ name: "Sodium",
524
+ units: "mmol/L",
525
+ referenceRange: "136-145",
526
+ valueLow: 125,
527
+ valueHigh: 155,
528
+ decimals: 0
529
+ },
530
+ {
531
+ localCode: "CREA",
532
+ loinc: "2160-0",
533
+ name: "Creatinine",
534
+ units: "mg/dL",
535
+ referenceRange: "0.6-1.3",
536
+ valueLow: 4,
537
+ valueHigh: 32,
538
+ decimals: 1
539
+ },
540
+ {
541
+ localCode: "HGB",
542
+ loinc: "718-7",
543
+ name: "Hemoglobin",
544
+ units: "g/dL",
545
+ referenceRange: "12.0-17.5",
546
+ valueLow: 80,
547
+ valueHigh: 190,
548
+ decimals: 1
549
+ },
550
+ {
551
+ localCode: "WBC",
552
+ loinc: "6690-2",
553
+ name: "Leukocytes",
554
+ units: "10*3/uL",
555
+ referenceRange: "4.5-11.0",
556
+ valueLow: 30,
557
+ valueHigh: 150,
558
+ decimals: 1
559
+ },
560
+ {
561
+ localCode: "TSH",
562
+ loinc: "3016-3",
563
+ name: "Thyrotropin",
564
+ units: "mIU/L",
565
+ referenceRange: "0.40-4.50",
566
+ valueLow: 2,
567
+ valueHigh: 90,
568
+ decimals: 2
569
+ },
570
+ {
571
+ localCode: "ALT",
572
+ loinc: "1742-6",
573
+ name: "Alanine aminotransferase",
574
+ units: "U/L",
575
+ referenceRange: "7-56",
576
+ valueLow: 5,
577
+ valueHigh: 120,
578
+ decimals: 0
579
+ }
580
+ ].map((entry) => Object.freeze(entry))
581
+ );
557
582
  var ASTM_ABNORMAL_FLAGS = Object.freeze(["N", "L", "H", "A"]);
558
583
  var ASTM_RESULT_STATUSES = Object.freeze(["F", "P", "C"]);
559
584
  var ASTM_COMMENT_TEXT = Object.freeze([