@cosyte/synth 0.1.3 → 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.
Files changed (57) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +28 -24
  3. package/dist/astm/index.cjs +109 -84
  4. package/dist/astm/index.cjs.map +1 -1
  5. package/dist/astm/index.d.cts +4 -3
  6. package/dist/astm/index.d.ts +4 -3
  7. package/dist/astm/index.mjs +109 -84
  8. package/dist/astm/index.mjs.map +1 -1
  9. package/dist/ccda/index.cjs +24 -2
  10. package/dist/ccda/index.cjs.map +1 -1
  11. package/dist/ccda/index.d.cts +5 -4
  12. package/dist/ccda/index.d.ts +5 -4
  13. package/dist/ccda/index.mjs +24 -2
  14. package/dist/ccda/index.mjs.map +1 -1
  15. package/dist/deid/index.cjs +98 -47
  16. package/dist/deid/index.cjs.map +1 -1
  17. package/dist/deid/index.d.cts +4 -3
  18. package/dist/deid/index.d.ts +4 -3
  19. package/dist/deid/index.mjs +98 -47
  20. package/dist/deid/index.mjs.map +1 -1
  21. package/dist/{example-codes-88f3_bQZ.d.cts → example-codes-4RnyF7bV.d.cts} +2 -1
  22. package/dist/{example-codes-88f3_bQZ.d.ts → example-codes-4RnyF7bV.d.ts} +2 -1
  23. package/dist/fhir/index.cjs +33 -2
  24. package/dist/fhir/index.cjs.map +1 -1
  25. package/dist/fhir/index.d.cts +4 -3
  26. package/dist/fhir/index.d.ts +4 -3
  27. package/dist/fhir/index.mjs +33 -2
  28. package/dist/fhir/index.mjs.map +1 -1
  29. package/dist/hl7/index.cjs +33 -3
  30. package/dist/hl7/index.cjs.map +1 -1
  31. package/dist/hl7/index.d.cts +4 -3
  32. package/dist/hl7/index.d.ts +4 -3
  33. package/dist/hl7/index.mjs +33 -3
  34. package/dist/hl7/index.mjs.map +1 -1
  35. package/dist/index.cjs +3 -3
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +13 -8
  38. package/dist/index.d.ts +13 -8
  39. package/dist/index.mjs +3 -3
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/ncpdp/index.cjs +57 -14
  42. package/dist/ncpdp/index.cjs.map +1 -1
  43. package/dist/ncpdp/index.d.cts +3 -2
  44. package/dist/ncpdp/index.d.ts +3 -2
  45. package/dist/ncpdp/index.mjs +57 -14
  46. package/dist/ncpdp/index.mjs.map +1 -1
  47. package/dist/{providers-DcPrqmp5.d.cts → providers-B48qUwHU.d.cts} +2 -1
  48. package/dist/{providers-DcPrqmp5.d.ts → providers-B48qUwHU.d.ts} +2 -1
  49. package/dist/{quirk-DmqYw3Vk.d.ts → quirk-BCSs1jPt.d.cts} +3 -2
  50. package/dist/{quirk-CilFUhwX.d.cts → quirk-BfObsiWV.d.ts} +3 -2
  51. package/dist/x12/index.cjs +82 -33
  52. package/dist/x12/index.cjs.map +1 -1
  53. package/dist/x12/index.d.cts +3 -2
  54. package/dist/x12/index.d.ts +3 -2
  55. package/dist/x12/index.mjs +82 -33
  56. package/dist/x12/index.mjs.map +1 -1
  57. package/package.json +29 -31
@@ -44,7 +44,32 @@ function sfc32Next(s) {
44
44
  }
45
45
 
46
46
  // src/codes.ts
47
- var SYNTH_FATAL_CODES = {
47
+ var SYNTH_FATAL_CODES = Object.freeze({
48
+ /**
49
+ * A format was requested that this build cannot generate through a real parser builder/serializer.
50
+ * Fatal, never a hand-written byte fallback.
51
+ *
52
+ * **No code path in this build raises it.** All six formats generate, so it is reserved for a
53
+ * future format that does not, and is kept because removing a published code is a breaking change.
54
+ * An unsupported *kind* within a format that does generate is `SYNTH_UNSUPPORTED_KIND`.
55
+ */
56
+ SYNTH_UNSUPPORTED_FORMAT: "SYNTH_UNSUPPORTED_FORMAT",
57
+ /**
58
+ * A vendor quirk was requested that the target format's profile system does not support. Fatal,
59
+ * never a silent no-op and never a fabricated quirk.
60
+ */
61
+ SYNTH_UNSUPPORTED_QUIRK: "SYNTH_UNSUPPORTED_QUIRK",
62
+ /**
63
+ * A quirk transform found no structural anchor to mutate, so the fixture would not carry the
64
+ * deviation it is labelled with. Fatal: a golden file that lies about its parser verdict is worse
65
+ * than no golden file.
66
+ */
67
+ SYNTH_QUIRK_ANCHOR_ABSENT: "SYNTH_QUIRK_ANCHOR_ABSENT",
68
+ /**
69
+ * A bare parse of a freshly-generated quirk artifact did not produce exactly the declared intended
70
+ * warning code(s). Fatal, never emit a mislabeled fixture.
71
+ */
72
+ SYNTH_INTENDED_WARNING_MISMATCH: "SYNTH_INTENDED_WARNING_MISMATCH",
48
73
  /** A concept's code-system URI has no OID mapping in the C-CDA example-code table. Fatal. */
49
74
  SYNTH_UNMAPPED_CODE_SYSTEM: "SYNTH_UNMAPPED_CODE_SYSTEM",
50
75
  /** A money value could not be read as an X12 decimal. Fatal: a generator never rounds to a float. */
@@ -53,13 +78,25 @@ var SYNTH_FATAL_CODES = {
53
78
  SYNTH_INVALID_RANGE: "SYNTH_INVALID_RANGE",
54
79
  /** A value was drawn from an empty pool. Fatal, never a fabricated substitute. */
55
80
  SYNTH_EMPTY_POOL: "SYNTH_EMPTY_POOL",
81
+ /** A `defineSynthProfile` spec was not usable (a missing or blank `name`). Fatal. */
82
+ SYNTH_INVALID_PROFILE: "SYNTH_INVALID_PROFILE",
56
83
  /**
57
84
  * A caller-supplied selector (a message kind, a document type, a corpus mix entry, a claim
58
85
  * variant, a Bundle type, a resource profile) is not in the closed set that governs it. Fatal:
59
86
  * see `resolveKind`: a selector union is erased at run time, and a selector that falls through
60
87
  * either mislabels the fixture or hands the value to a peer builder that quotes it back.
61
88
  */
62
- SYNTH_UNSUPPORTED_KIND: "SYNTH_UNSUPPORTED_KIND"};
89
+ SYNTH_UNSUPPORTED_KIND: "SYNTH_UNSUPPORTED_KIND",
90
+ /**
91
+ * A requested profile IS published by the adopted implementation guide, and this build does not
92
+ * generate it. Deliberately distinct from `SYNTH_UNSUPPORTED_KIND`, which says the name is not in
93
+ * the adopted set at all: "the guide does not publish this" and "we do not generate this yet" are
94
+ * different answers, and a caller building to a regulatory profile set has to be able to tell them
95
+ * apart without matching message text. Fatal, and raised **before** anything is generated: a
96
+ * mislabelled artifact is worse than no artifact.
97
+ */
98
+ SYNTH_PROFILE_NOT_GENERATED: "SYNTH_PROFILE_NOT_GENERATED"
99
+ });
63
100
  var SYNTH_FATAL_MESSAGES = Object.freeze({
64
101
  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.",
65
102
  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).",
@@ -550,6 +587,7 @@ function obxSegment(rng, setId) {
550
587
  const obs = rng.pick(EXAMPLE_LAB_OBSERVATIONS);
551
588
  const value = `${String(rng.int(1, 300))}.${String(rng.int(0, 9))}`;
552
589
  const observedAt = seededTimestamp(rng);
590
+ const units = obs.units ?? "";
553
591
  return [
554
592
  String(setId),
555
593
  // OBX-1 set id
@@ -561,7 +599,7 @@ function obxSegment(rng, setId) {
561
599
  // OBX-4 observation sub-id
562
600
  value,
563
601
  // OBX-5 observation value
564
- obs.units ?? "",
602
+ units,
565
603
  // OBX-6 units
566
604
  "",
567
605
  // OBX-7 reference range
@@ -1838,39 +1876,49 @@ function x12EnvelopeTiming(rng) {
1838
1876
  }
1839
1877
 
1840
1878
  // src/x12/example-codes.ts
1841
- var PROFESSIONAL_PROCEDURES = Object.freeze([
1842
- { code: "99213", label: "office/outpatient visit, established patient" },
1843
- { code: "99214", label: "office/outpatient visit, established patient, moderate" },
1844
- { code: "99203", label: "office/outpatient visit, new patient" },
1845
- { code: "85025", label: "complete blood count with differential" },
1846
- { code: "80053", label: "comprehensive metabolic panel" },
1847
- { code: "93000", label: "electrocardiogram, routine" }
1848
- ]);
1879
+ var PROFESSIONAL_PROCEDURES = Object.freeze(
1880
+ [
1881
+ { code: "99213", label: "office/outpatient visit, established patient" },
1882
+ { code: "99214", label: "office/outpatient visit, established patient, moderate" },
1883
+ { code: "99203", label: "office/outpatient visit, new patient" },
1884
+ { code: "85025", label: "complete blood count with differential" },
1885
+ { code: "80053", label: "comprehensive metabolic panel" },
1886
+ { code: "93000", label: "electrocardiogram, routine" }
1887
+ ].map((entry) => Object.freeze(entry))
1888
+ );
1849
1889
  var PROCEDURE_MODIFIERS = Object.freeze(["25", "59", "76", "GT"]);
1850
1890
  var PLACES_OF_SERVICE = Object.freeze(["11", "22", "21", "12", "49"]);
1851
- var DIAGNOSES = Object.freeze([
1852
- { code: "J20.9", label: "acute bronchitis, unspecified" },
1853
- { code: "E11.9", label: "type 2 diabetes mellitus without complications" },
1854
- { code: "I10", label: "essential (primary) hypertension" },
1855
- { code: "M54.5", label: "low back pain" },
1856
- { code: "R07.9", label: "chest pain, unspecified" },
1857
- { code: "Z00.00", label: "general adult medical exam without abnormal findings" }
1858
- ]);
1859
- var REVENUE_CODES = Object.freeze([
1860
- { code: "0120", label: "room & board, semi-private" },
1861
- { code: "0300", label: "laboratory, general" },
1862
- { code: "0450", label: "emergency room, general" },
1863
- { code: "0636", label: "drugs requiring detailed coding" }
1864
- ]);
1865
- var INSTITUTIONAL_PROCEDURES = Object.freeze([
1866
- { code: "99221", label: "initial hospital care, per day" },
1867
- { code: "99231", label: "subsequent hospital care, per day" }
1868
- ]);
1869
- var DENTAL_PROCEDURES = Object.freeze([
1870
- { code: "D2391", label: "resin-based composite, one surface, posterior" },
1871
- { code: "D1110", label: "prophylaxis, adult" },
1872
- { code: "D0120", label: "periodic oral evaluation" }
1873
- ]);
1891
+ var DIAGNOSES = Object.freeze(
1892
+ [
1893
+ { code: "J20.9", label: "acute bronchitis, unspecified" },
1894
+ { code: "E11.9", label: "type 2 diabetes mellitus without complications" },
1895
+ { code: "I10", label: "essential (primary) hypertension" },
1896
+ { code: "M54.5", label: "low back pain" },
1897
+ { code: "R07.9", label: "chest pain, unspecified" },
1898
+ { code: "Z00.00", label: "general adult medical exam without abnormal findings" }
1899
+ ].map((entry) => Object.freeze(entry))
1900
+ );
1901
+ var REVENUE_CODES = Object.freeze(
1902
+ [
1903
+ { code: "0120", label: "room & board, semi-private" },
1904
+ { code: "0300", label: "laboratory, general" },
1905
+ { code: "0450", label: "emergency room, general" },
1906
+ { code: "0636", label: "drugs requiring detailed coding" }
1907
+ ].map((entry) => Object.freeze(entry))
1908
+ );
1909
+ var INSTITUTIONAL_PROCEDURES = Object.freeze(
1910
+ [
1911
+ { code: "99221", label: "initial hospital care, per day" },
1912
+ { code: "99231", label: "subsequent hospital care, per day" }
1913
+ ].map((entry) => Object.freeze(entry))
1914
+ );
1915
+ var DENTAL_PROCEDURES = Object.freeze(
1916
+ [
1917
+ { code: "D2391", label: "resin-based composite, one surface, posterior" },
1918
+ { code: "D1110", label: "prophylaxis, adult" },
1919
+ { code: "D0120", label: "periodic oral evaluation" }
1920
+ ].map((entry) => Object.freeze(entry))
1921
+ );
1874
1922
  var TOOTH_CODES = Object.freeze(["14", "3", "19", "30"]);
1875
1923
  var TOOTH_SURFACES = Object.freeze(["M", "O", "D", "B", "L"]);
1876
1924
  var SERVICE_TYPE_CODES = Object.freeze(["30", "1", "35", "88", "98"]);
@@ -2302,18 +2350,20 @@ function ncpdpCardholder(rng) {
2302
2350
  }
2303
2351
 
2304
2352
  // src/ncpdp/example-codes.ts
2305
- var EXAMPLE_DRUGS = Object.freeze([
2306
- { description: "Amoxicillin 500 MG Oral Capsule", ndc: "00000010101", form: "EA" },
2307
- { description: "Lisinopril 10 MG Oral Tablet", ndc: "00000020202", form: "EA" },
2308
- { description: "Atorvastatin 20 MG Oral Tablet", ndc: "00000030303", form: "EA" },
2309
- { description: "Metformin 500 MG Oral Tablet", ndc: "00000040404", form: "EA" },
2310
- { description: "Amlodipine 5 MG Oral Tablet", ndc: "00000050505", form: "EA" },
2311
- { description: "Omeprazole 20 MG Delayed Release Capsule", ndc: "00000060606", form: "EA" },
2312
- { description: "Levothyroxine 50 MCG Oral Tablet", ndc: "00000070707", form: "EA" },
2313
- { description: "Azithromycin 250 MG Oral Tablet", ndc: "00000080808", form: "EA" },
2314
- { description: "Sertraline 50 MG Oral Tablet", ndc: "00000090909", form: "EA" },
2315
- { description: "Albuterol 90 MCG Metered Dose Inhaler", ndc: "00000101010", form: "EA" }
2316
- ]);
2353
+ var EXAMPLE_DRUGS = Object.freeze(
2354
+ [
2355
+ { description: "Amoxicillin 500 MG Oral Capsule", ndc: "00000010101", form: "EA" },
2356
+ { description: "Lisinopril 10 MG Oral Tablet", ndc: "00000020202", form: "EA" },
2357
+ { description: "Atorvastatin 20 MG Oral Tablet", ndc: "00000030303", form: "EA" },
2358
+ { description: "Metformin 500 MG Oral Tablet", ndc: "00000040404", form: "EA" },
2359
+ { description: "Amlodipine 5 MG Oral Tablet", ndc: "00000050505", form: "EA" },
2360
+ { description: "Omeprazole 20 MG Delayed Release Capsule", ndc: "00000060606", form: "EA" },
2361
+ { description: "Levothyroxine 50 MCG Oral Tablet", ndc: "00000070707", form: "EA" },
2362
+ { description: "Azithromycin 250 MG Oral Tablet", ndc: "00000080808", form: "EA" },
2363
+ { description: "Sertraline 50 MG Oral Tablet", ndc: "00000090909", form: "EA" },
2364
+ { description: "Albuterol 90 MCG Metered Dose Inhaler", ndc: "00000101010", form: "EA" }
2365
+ ].map((entry) => Object.freeze(entry))
2366
+ );
2317
2367
  var DAW_CODES = Object.freeze(["0", "1", "2"]);
2318
2368
  var SYNTHETIC_BIN = "999999";
2319
2369
  function digitsOnly(value) {
@@ -2664,7 +2714,8 @@ function recordTargetSentinels(xml) {
2664
2714
  seen.add(trimmed);
2665
2715
  out.push({ token: trimmed, locus, category: "names" });
2666
2716
  };
2667
- for (const m of scope.matchAll(/<given>([^<]+)<\/given>/g)) add(m[1] ?? "", "recordTarget/given");
2717
+ for (const m of scope.matchAll(/<given>([^<]+)<\/given>/g))
2718
+ add(m[1] ?? "", "recordTarget/given");
2668
2719
  for (const m of scope.matchAll(/<family>([^<]+)<\/family>/g))
2669
2720
  add(m[1] ?? "", "recordTarget/family");
2670
2721
  for (const m of scope.matchAll(/<id\b[^>]*\bextension="([^"]+)"/g))