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