@cosyte/synth 0.0.8 → 0.1.0

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 (55) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +21 -12
  3. package/dist/astm/index.cjs +18 -6
  4. package/dist/astm/index.cjs.map +1 -1
  5. package/dist/astm/index.d.cts +2 -2
  6. package/dist/astm/index.d.ts +2 -2
  7. package/dist/astm/index.mjs +18 -6
  8. package/dist/astm/index.mjs.map +1 -1
  9. package/dist/ccda/index.cjs +23 -7
  10. package/dist/ccda/index.cjs.map +1 -1
  11. package/dist/ccda/index.d.cts +2 -2
  12. package/dist/ccda/index.d.ts +2 -2
  13. package/dist/ccda/index.mjs +23 -7
  14. package/dist/ccda/index.mjs.map +1 -1
  15. package/dist/deid/index.cjs +26 -8
  16. package/dist/deid/index.cjs.map +1 -1
  17. package/dist/deid/index.d.cts +2 -2
  18. package/dist/deid/index.d.ts +2 -2
  19. package/dist/deid/index.mjs +26 -8
  20. package/dist/deid/index.mjs.map +1 -1
  21. package/dist/fhir/index.cjs +174 -7
  22. package/dist/fhir/index.cjs.map +1 -1
  23. package/dist/fhir/index.d.cts +163 -2
  24. package/dist/fhir/index.d.ts +163 -2
  25. package/dist/fhir/index.mjs +171 -9
  26. package/dist/fhir/index.mjs.map +1 -1
  27. package/dist/hl7/index.cjs +18 -6
  28. package/dist/hl7/index.cjs.map +1 -1
  29. package/dist/hl7/index.d.cts +2 -2
  30. package/dist/hl7/index.d.ts +2 -2
  31. package/dist/hl7/index.mjs +18 -6
  32. package/dist/hl7/index.mjs.map +1 -1
  33. package/dist/index.cjs +37 -6
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +172 -38
  36. package/dist/index.d.ts +172 -38
  37. package/dist/index.mjs +36 -7
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/ncpdp/index.cjs +18 -6
  40. package/dist/ncpdp/index.cjs.map +1 -1
  41. package/dist/ncpdp/index.d.cts +1 -1
  42. package/dist/ncpdp/index.d.ts +1 -1
  43. package/dist/ncpdp/index.mjs +18 -6
  44. package/dist/ncpdp/index.mjs.map +1 -1
  45. package/dist/{providers-B9uVinAe.d.cts → providers-BQtPk3PN.d.cts} +18 -4
  46. package/dist/{providers-B9uVinAe.d.ts → providers-BQtPk3PN.d.ts} +18 -4
  47. package/dist/{quirk-HZdznAkM.d.ts → quirk-Bzx9g8KG.d.ts} +1 -1
  48. package/dist/{quirk-IaHp4z7N.d.cts → quirk-C_lZrspq.d.cts} +1 -1
  49. package/dist/x12/index.cjs +18 -6
  50. package/dist/x12/index.cjs.map +1 -1
  51. package/dist/x12/index.d.cts +1 -1
  52. package/dist/x12/index.d.ts +1 -1
  53. package/dist/x12/index.mjs +18 -6
  54. package/dist/x12/index.mjs.map +1 -1
  55. package/package.json +54 -30
@@ -1,7 +1,7 @@
1
- import { S as SyntheticName, a as SyntheticIdentifier, R as Rng, C as Corpus } from '../providers-B9uVinAe.cjs';
1
+ import { S as SyntheticName, a as SyntheticIdentifier, R as Rng, C as Corpus } from '../providers-BQtPk3PN.cjs';
2
2
  import { CcdaDocument, BuildCcdaPatient, BuildCode, BuildQuantity } from '@cosyte/ccda';
3
3
  import { C as CodeConcept, Q as QuantConcept } from '../example-codes-88f3_bQZ.cjs';
4
- import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-IaHp4z7N.cjs';
4
+ import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-C_lZrspq.cjs';
5
5
 
6
6
  /**
7
7
  * Synthetic **C-CDA document generation**: a spec-clean Continuity of Care Document
@@ -1,7 +1,7 @@
1
- import { S as SyntheticName, a as SyntheticIdentifier, R as Rng, C as Corpus } from '../providers-B9uVinAe.js';
1
+ import { S as SyntheticName, a as SyntheticIdentifier, R as Rng, C as Corpus } from '../providers-BQtPk3PN.js';
2
2
  import { CcdaDocument, BuildCcdaPatient, BuildCode, BuildQuantity } from '@cosyte/ccda';
3
3
  import { C as CodeConcept, Q as QuantConcept } from '../example-codes-88f3_bQZ.js';
4
- import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-HZdznAkM.js';
4
+ import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-Bzx9g8KG.js';
5
5
 
6
6
  /**
7
7
  * Synthetic **C-CDA document generation**: a spec-clean Continuity of Care Document
@@ -61,8 +61,7 @@ var SYNTH_FATAL_CODES = {
61
61
  * see `resolveKind`: a selector union is erased at run time, and a selector that falls through
62
62
  * either mislabels the fixture or hands the value to a peer builder that quotes it back.
63
63
  */
64
- SYNTH_UNSUPPORTED_KIND: "SYNTH_UNSUPPORTED_KIND"
65
- };
64
+ SYNTH_UNSUPPORTED_KIND: "SYNTH_UNSUPPORTED_KIND"};
66
65
  var SYNTH_FATAL_MESSAGES = Object.freeze({
67
66
  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.",
68
67
  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).",
@@ -73,7 +72,8 @@ var SYNTH_FATAL_MESSAGES = Object.freeze({
73
72
  SYNTH_INVALID_RANGE: "An integer range was requested with its maximum below its minimum.",
74
73
  SYNTH_EMPTY_POOL: "A value was drawn from an empty pool.",
75
74
  SYNTH_INVALID_PROFILE: "defineSynthProfile requires a non-empty string name.",
76
- SYNTH_UNSUPPORTED_KIND: "The requested kind, document type, corpus mix entry, variant or profile is not one this generator supports. The supported set is the exported union for that option."
75
+ SYNTH_UNSUPPORTED_KIND: "The requested kind, document type, corpus mix entry, variant or profile is not one this generator supports. The supported set is the exported union for that option.",
76
+ SYNTH_PROFILE_NOT_GENERATED: "The requested profile is published by the adopted implementation guide, and this build does not generate it. The coverage surface reports, per adopted profile, whether it is generated."
77
77
  });
78
78
  var SynthError = class extends Error {
79
79
  /** The stable fatal code. */
@@ -151,7 +151,7 @@ function makeCorpus(seed, artifacts, quirks = []) {
151
151
  var SYNTHETIC_ASSIGNING_AUTHORITY = Object.freeze({
152
152
  /** The human-readable assigning-authority namespace id (HL7 HD.1). */
153
153
  namespaceId: "COSYTE-SYNTH",
154
- /** The universal id, an OID under HL7's example arc `2.16.840.1.113883.19` (HD.2). */
154
+ /** The universal id, an OID this package chose under the root `2.16.840.1.113883.19` (HD.2). */
155
155
  universalId: "2.16.840.1.113883.19.999",
156
156
  /** The universal id type (HD.3). */
157
157
  universalIdType: "ISO"
@@ -170,6 +170,18 @@ var TEST_NET_V4_PREFIXES = Object.freeze([
170
170
  // TEST-NET-3
171
171
  ]);
172
172
  var DOC_V6_PREFIX = "2001:db8";
173
+ var ITIN_GROUP_RANGES = Object.freeze([
174
+ Object.freeze({ min: 50, max: 65 }),
175
+ Object.freeze({ min: 70, max: 88 }),
176
+ Object.freeze({ min: 90, max: 92 }),
177
+ Object.freeze({ min: 94, max: 99 })
178
+ ]);
179
+ var ITIN_EXCLUDED_GROUPS = Object.freeze([89, 93]);
180
+ var SSN_SYNTHETIC_GROUPS = Object.freeze(
181
+ Array.from({ length: 100 }, (_unused, group) => group).filter(
182
+ (group) => !ITIN_GROUP_RANGES.some((range) => group >= range.min && group <= range.max) && !ITIN_EXCLUDED_GROUPS.includes(group)
183
+ ).map((group) => String(group).padStart(2, "0"))
184
+ );
173
185
  var NPI_LUHN_PREFIX = "80840";
174
186
  function luhnMod10(digits) {
175
187
  let sum = 0;
@@ -278,10 +290,10 @@ var SYNTHETIC_CITY_NAMES = Object.freeze([
278
290
  // src/safe/providers.ts
279
291
  function ssn(rng, block = "never-issued") {
280
292
  if (block === "advertising") {
281
- return `987-65-432${String(rng.int(0, 9))}`;
293
+ return `987-00-432${String(rng.int(0, 9))}`;
282
294
  }
283
295
  const area = rng.int(900, 999);
284
- const group = rng.digits(2);
296
+ const group = rng.pick(SSN_SYNTHETIC_GROUPS);
285
297
  const serial = rng.digits(4);
286
298
  return `${String(area)}-${group}-${serial}`;
287
299
  }
@@ -450,7 +462,11 @@ var SYSTEM = Object.freeze({
450
462
  /** HL7 Terminology `allergyintolerance-clinical`, `AllergyIntolerance.clinicalStatus`. */
451
463
  ALLERGY_CLINICAL: "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical",
452
464
  /** HL7 Terminology `allergyintolerance-verification`, `AllergyIntolerance.verificationStatus`. */
453
- ALLERGY_VERIFICATION: "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification"
465
+ ALLERGY_VERIFICATION: "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification",
466
+ /** HL7 Terminology `provenance-participant-type`, `Provenance.agent.type` (`author`). */
467
+ PROVENANCE_PARTICIPANT_TYPE: "http://terminology.hl7.org/CodeSystem/provenance-participant-type",
468
+ /** US Core `us-core-provenance-participant-type`, `Provenance.agent.type` (`transmitter`). */
469
+ US_CORE_PROVENANCE_PARTICIPANT_TYPE: "http://hl7.org/fhir/us/core/CodeSystem/us-core-provenance-participant-type"
454
470
  });
455
471
 
456
472
  // src/fhir/example-codes.ts