@cosyte/synth 0.0.9 → 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 +73 -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 +1 @@
1
- {"version":3,"sources":["../../src/rng/splitmix32.ts","../../src/rng/sfc32.ts","../../src/codes.ts","../../src/rng/rng.ts","../../src/safe/reserved.ts","../../src/safe/names-pool.ts","../../src/safe/providers.ts","../../src/safe/index.ts","../../src/fhir/us-core.ts","../../src/fhir/builder.ts","../../src/fhir/example-codes.ts","../../src/select.ts","../../src/fhir/patient.ts","../../src/fhir/condition.ts","../../src/fhir/observation.ts","../../src/fhir/medication-request.ts","../../src/fhir/encounter.ts","../../src/fhir/immunization.ts","../../src/fhir/allergy-intolerance.ts","../../src/fhir/procedure.ts","../../src/fhir/diagnostic-report.ts","../../src/corpus.ts","../../src/fhir/composition.ts","../../src/fhir/round-trip.ts","../../src/fhir/bundle.ts"],"names":["name","address","phone","email","complex","list"],"mappings":";;;;;AA0BO,SAAS,WAAW,IAAA,EAA4B;AACrD,EAAA,IAAI,IAAI,IAAA,GAAO,CAAA;AACf,EAAA,OAAO,SAAS,IAAA,GAAe;AAC7B,IAAA,CAAA,GAAK,IAAI,UAAA,GAAc,CAAA;AACvB,IAAA,IAAI,CAAA,GAAI,IAAK,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AA,EAAM,CAAA;AAAA,IAC1C,KAAK,QAAA;AACH,MAAA,OAAO,cAAA,CAAe,EAAE,IAAA,EAAM,CAAA;AAAA,IAChC,KAAK,gBAAA;AACH,MAAA,OAAO,cAAA,CAAe,EAAE,IAAA,EAAM,IAAA,EAAM,YAAY,CAAA;AAAA;AAEtD;AA4BO,SAAS,WAAW,OAAA,EAAoC;AAC7D,EAAA,MAAM,EAAE,IAAA,EAAM,KAAA,GAAQ,CAAA,EAAE,GAAI,OAAA;AAC5B,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,SAAA,EAAW,OAAA,CAAQ,KAAK,WAAW,CAAA;AAC5D,EAAA,MAAM,UAAA,GAAa,UAAU,IAAI,CAAA;AACjC,EAAA,MAAM,SAAA,GAAY,MAAM,IAAA,CAAK,EAAE,QAAQ,KAAA,EAAM,EAAG,CAAC,OAAA,EAAS,CAAA,KAAM;AAC9D,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,CAAA,GAAI,KAAA,CAAM,MAAM,CAAA,IAAK,eAAA;AACxC,IAAA,MAAM,KAAK,SAAA,CAAU,YAAA,CAAa,MAAM,UAAA,CAAW,UAAA,EAAY,CAAC,CAAA;AAMhE,IAAA,OAAO,EAAE,QAAQ,MAAA,EAAiB,IAAA,EAAM,SAAS,EAAA,CAAG,OAAA,EAAS,QAAA,EAAU,EAAA,CAAG,MAAA,EAAO;AAAA,EACnF,CAAC,CAAA;AACD,EAAA,OAAO,UAAA,CAAW,MAAM,SAAS,CAAA;AACnC","file":"index.mjs","sourcesContent":["/**\n * `splitmix32`: a tiny, well-studied 32-bit mixing PRNG used **only** to expand a single integer\n * seed into the four 32-bit state words that seed {@link ../rng/sfc32.sfc32}. It is not the corpus\n * generator itself (that is `sfc32`); it exists so that a one-number seed deterministically produces a\n * well-distributed 128-bit `sfc32` state, avoiding the poor low-bit behavior of naive\n * `state = seed`-style initialization.\n *\n * Zero-dependency, `Math.random`-free (lint-enforced): the whole point of the library is that a seed,\n * and only the seed, determines the output, on any machine, any run.\n *\n * @module\n */\n\n/**\n * A stateful `splitmix32` step function. Each call advances the internal 32-bit state and returns the\n * next unsigned 32-bit integer. Deterministic for a given seed.\n *\n * @param seed - The 32-bit seed. Coerced to a 32-bit integer via `| 0`.\n * @returns A nullary function returning the next `uint32` in the stream.\n * @example\n * ```ts\n * import { splitmix32 } from \"@cosyte/synth\";\n * const next = splitmix32(12345);\n * const a = next(); // deterministic uint32\n * ```\n */\nexport function splitmix32(seed: number): () => number {\n let a = seed | 0;\n return function next(): number {\n a = (a + 0x9e3779b9) | 0;\n let t = a ^ (a >>> 16);\n t = Math.imul(t, 0x21f0aaad);\n t = t ^ (t >>> 15);\n t = Math.imul(t, 0x735a2d97);\n t = t ^ (t >>> 15);\n return t >>> 0;\n };\n}\n","/**\n * `sfc32` (Small Fast Counter, 32-bit, 128-bit state): the deterministic, non-cryptographic PRNG that\n * drives every value `@cosyte/synth` generates. Chosen over `mulberry32` (whose author flags that it\n * skips ~1/3 of 32-bit outputs) and over a CSPRNG (`node:crypto`, which is **not seedable** and would\n * defeat reproducibility). A synthetic-fixture generator has **no secrets**: statistical quality plus\n * byte-for-byte reproducibility is exactly the right trade.\n *\n * The state is four 32-bit words. This module exposes the raw step function; {@link ../rng/rng.Rng}\n * wraps it with a seed-expansion ({@link ./splitmix32.splitmix32}) and the ergonomic draw helpers.\n *\n * @module\n */\n\n/**\n * The mutable four-word `sfc32` state. Threaded explicitly (never global) by {@link ../rng/rng.Rng}.\n */\nexport interface Sfc32State {\n /** State word `a`. */\n a: number;\n /** State word `b`. */\n b: number;\n /** State word `c`. */\n c: number;\n /** Counter word `d`. */\n d: number;\n}\n\n/**\n * Advance an {@link Sfc32State} in place by one step and return the next unsigned 32-bit integer.\n *\n * This is the canonical `sfc32` step. The state object is mutated (the counter `d` increments and the\n * mixing words rotate); callers that need reproducible independence hold their own state and never\n * share it: {@link ../rng/rng.Rng} creates a fresh state per seed so two runs from the same seed are\n * identical.\n *\n * @param s - The state to advance. Mutated in place.\n * @returns The next `uint32` in the stream.\n * @example\n * ```ts\n * import { sfc32Next, type Sfc32State } from \"@cosyte/synth\";\n * const s: Sfc32State = { a: 1, b: 2, c: 3, d: 4 };\n * const x = sfc32Next(s); // uint32\n * ```\n */\nexport function sfc32Next(s: Sfc32State): number {\n s.a |= 0;\n s.b |= 0;\n s.c |= 0;\n s.d |= 0;\n const t = (((s.a + s.b) | 0) + s.d) | 0;\n s.d = (s.d + 1) | 0;\n s.a = s.b ^ (s.b >>> 9);\n s.b = (s.c + (s.c << 3)) | 0;\n s.c = (s.c << 21) | (s.c >>> 11);\n s.c = (s.c + t) | 0;\n return t >>> 0;\n}\n","/**\n * Stable diagnostic codes for `@cosyte/synth` and the {@link SynthError} they travel on.\n *\n * Unlike a parser (which recovers from bad *input* into Tier-2 warnings), a **generator** has no input\n * to tolerate: its reflex is *synthetic-by-construction* and *fail-closed on impossibility*. So the\n * codes here are **fatal**: a caller asked for something the library cannot honor spec-clean, and the\n * only safe answer is to throw, never to silently fabricate a value or a byte workaround. Codes are `key ===\n * value` and part of the public contract:\n * renaming one is a breaking change.\n *\n * @module\n */\n\n/**\n * The stable **fatal** code registry. Additions-only thereafter.\n *\n * @example\n * ```ts\n * import { SYNTH_FATAL_CODES, SynthError } from \"@cosyte/synth\";\n * try {\n * // ...generate...\n * } catch (err) {\n * if (err instanceof SynthError && err.code === SYNTH_FATAL_CODES.SYNTH_UNSUPPORTED_FORMAT) {\n * // handle an unsupported format request\n * }\n * }\n * ```\n */\nexport const SYNTH_FATAL_CODES = {\n /**\n * A format was requested that this build cannot generate through a real parser builder/serializer.\n * Fatal, never a hand-written byte fallback.\n *\n * **No code path in this build raises it.** All six formats generate, so it is reserved for a\n * future format that does not, and is kept because removing a published code is a breaking change.\n * An unsupported *kind* within a format that does generate is `SYNTH_UNSUPPORTED_KIND`.\n */\n SYNTH_UNSUPPORTED_FORMAT: \"SYNTH_UNSUPPORTED_FORMAT\",\n /**\n * A vendor quirk was requested that the target format's profile system does not support. Fatal,\n * never a silent no-op and never a fabricated quirk.\n */\n SYNTH_UNSUPPORTED_QUIRK: \"SYNTH_UNSUPPORTED_QUIRK\",\n /**\n * A quirk transform found no structural anchor to mutate, so the fixture would not carry the\n * deviation it is labelled with. Fatal: a golden file that lies about its parser verdict is worse\n * than no golden file.\n */\n SYNTH_QUIRK_ANCHOR_ABSENT: \"SYNTH_QUIRK_ANCHOR_ABSENT\",\n /**\n * A bare parse of a freshly-generated quirk artifact did not produce exactly the declared intended\n * warning code(s). Fatal, never emit a mislabeled fixture.\n */\n SYNTH_INTENDED_WARNING_MISMATCH: \"SYNTH_INTENDED_WARNING_MISMATCH\",\n /** A concept's code-system URI has no OID mapping in the C-CDA example-code table. Fatal. */\n SYNTH_UNMAPPED_CODE_SYSTEM: \"SYNTH_UNMAPPED_CODE_SYSTEM\",\n /** A money value could not be read as an X12 decimal. Fatal: a generator never rounds to a float. */\n SYNTH_INVALID_DECIMAL: \"SYNTH_INVALID_DECIMAL\",\n /** An integer range was requested with its maximum below its minimum. Fatal. */\n SYNTH_INVALID_RANGE: \"SYNTH_INVALID_RANGE\",\n /** A value was drawn from an empty pool. Fatal, never a fabricated substitute. */\n SYNTH_EMPTY_POOL: \"SYNTH_EMPTY_POOL\",\n /** A `defineSynthProfile` spec was not usable (a missing or blank `name`). Fatal. */\n SYNTH_INVALID_PROFILE: \"SYNTH_INVALID_PROFILE\",\n /**\n * A caller-supplied selector (a message kind, a document type, a corpus mix entry, a claim\n * variant, a Bundle type, a resource profile) is not in the closed set that governs it. Fatal:\n * see `resolveKind`: a selector union is erased at run time, and a selector that falls through\n * either mislabels the fixture or hands the value to a peer builder that quotes it back.\n */\n SYNTH_UNSUPPORTED_KIND: \"SYNTH_UNSUPPORTED_KIND\",\n} as const;\n\n/**\n * A value from {@link SYNTH_FATAL_CODES}: the type carried by a thrown {@link SynthError}.\n */\nexport type SynthFatalCode = (typeof SYNTH_FATAL_CODES)[keyof typeof SYNTH_FATAL_CODES];\n\n/**\n * The **frozen message registry**: the only place a {@link SynthError} message can come from.\n *\n * A message here is a fixed string. It never quotes the request that produced it, and there is no\n * parameter through which it could: {@link SynthError} takes a code and nothing else. That is the\n * whole mechanism, and it is deliberately a mechanism rather than a habit. Every one of these\n * messages used to be assembled by interpolating the caller's value into a template, and the reason\n * that was safe was not the design: it was that the caller happened to be passing a quirk name.\n *\n * The trade is real and is accepted: a fatal no longer tells you *which* value it rejected. It tells\n * you which rule refused, on `err.code`, and the stack frame tells you where. The caller already\n * holds the value it passed.\n *\n * @example\n * ```ts\n * import { SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES } from \"@cosyte/synth\";\n * SYNTH_FATAL_MESSAGES[SYNTH_FATAL_CODES.SYNTH_EMPTY_POOL]; // => \"A value was drawn from an empty pool.\"\n * ```\n */\nexport const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>> = Object.freeze({\n SYNTH_UNSUPPORTED_FORMAT:\n \"The requested format is not generable by this build. A generator has no byte fallback: it \" +\n \"builds through a parser's own serializer or it refuses.\",\n SYNTH_UNSUPPORTED_QUIRK:\n \"The requested vendor quirk is not in the target format's quirk registry. Compare the request \" +\n \"against that format's exported registry (HL7_QUIRKS, CCDA_QUIRKS, ASTM_QUIRKS).\",\n SYNTH_QUIRK_ANCHOR_ABSENT:\n \"The quirk transform found no structural anchor to mutate, so the fixture would not carry the \" +\n \"deviation it is labelled with. Refusing to emit a mislabeled fixture.\",\n SYNTH_INTENDED_WARNING_MISMATCH:\n \"A bare parse of the generated quirk artifact did not produce exactly the declared intended \" +\n \"warning code(s). Refusing to emit a mislabeled fixture.\",\n SYNTH_UNMAPPED_CODE_SYSTEM:\n \"The concept's code-system URI has no OID mapping in the C-CDA example-code table.\",\n SYNTH_INVALID_DECIMAL: \"The value could not be read as an X12 decimal.\",\n SYNTH_INVALID_RANGE: \"An integer range was requested with its maximum below its minimum.\",\n SYNTH_EMPTY_POOL: \"A value was drawn from an empty pool.\",\n SYNTH_INVALID_PROFILE: \"defineSynthProfile requires a non-empty string name.\",\n SYNTH_UNSUPPORTED_KIND:\n \"The requested kind, document type, corpus mix entry, variant or profile is not one this \" +\n \"generator supports. The supported set is the exported union for that option.\",\n});\n\n/**\n * The typed error every fatal `@cosyte/synth` condition throws. Carries a stable\n * {@link SynthFatalCode} so callers branch on `err.code` without matching message text.\n *\n * It takes **no value parameter**. The message is whatever {@link SYNTH_FATAL_MESSAGES} holds for the\n * code, so no caller-supplied string can reach a diagnostic surface by any route, not `message`, not\n * `stack`, not a field on the thrown object.\n *\n * @example\n * ```ts\n * import { SynthError, SYNTH_FATAL_CODES } from \"@cosyte/synth\";\n * throw new SynthError(SYNTH_FATAL_CODES.SYNTH_UNSUPPORTED_FORMAT);\n * ```\n */\nexport class SynthError extends Error {\n /** The stable fatal code. */\n public readonly code: SynthFatalCode;\n\n /**\n * @param code - The stable {@link SynthFatalCode}. The message comes from the frozen registry.\n */\n public constructor(code: SynthFatalCode) {\n super(SYNTH_FATAL_MESSAGES[code]);\n this.name = \"SynthError\";\n this.code = code;\n }\n}\n","/**\n * `Rng`: the seeded, deterministic random source every `@cosyte/synth` provider draws from.\n *\n * **The reproducibility contract.** A seed, and only the seed, determines the output.\n * `createRng(seed)` expands the integer seed through {@link ./splitmix32.splitmix32} into the four\n * `sfc32` state words, then every draw advances that state via {@link ./sfc32.sfc32Next}. Two `Rng`s\n * created from the same seed emit the **identical** sequence on any machine, any run: the property\n * the parsers', `transform`'s, and `deid`'s regression suites depend on.\n *\n * **Explicit, never global.** An `Rng` is a value you thread through a build; there is no ambient\n * shared generator and **`Math.random` is lint-banned** in `src/` (it is not seedable: its seed is\n * engine-chosen and cannot be reset, so a corpus built on it is not reproducible). Because each\n * generation creates a fresh `Rng` from its seed, generations are independent and parallel-safe.\n *\n * The `Rng` object is stateful by nature (a PRNG advances). Immutability in this library lives where it\n * is testable and matters: the generated **artifacts and the `Corpus` are deep-frozen** (see\n * `../corpus.ts`). Determinism, not object-immutability, is the `Rng`'s guarantee.\n *\n * @module\n */\n\nimport { splitmix32 } from \"./splitmix32.js\";\nimport { sfc32Next, type Sfc32State } from \"./sfc32.js\";\nimport { SYNTH_FATAL_CODES, SynthError } from \"../codes.js\";\n\n/**\n * A seeded, deterministic random source. Created via {@link createRng}; passed explicitly to every\n * provider. All draw methods advance the internal state deterministically.\n */\nexport interface Rng {\n /** The integer seed this generator was created from (part of the `Corpus` manifest). */\n readonly seed: number;\n /** The next unsigned 32-bit integer. */\n nextUint32(): number;\n /** The next float in `[0, 1)`. */\n float(): number;\n /**\n * A uniformly-distributed integer in the inclusive range `[min, max]`.\n *\n * @param min - Inclusive lower bound (integer).\n * @param max - Inclusive upper bound (integer, `>= min`).\n */\n int(min: number, max: number): number;\n /** `true` with probability `p` (default `0.5`). */\n bool(p?: number): boolean;\n /**\n * Pick one element from a non-empty array.\n *\n * @param items - A non-empty readonly array.\n */\n pick<T>(items: readonly T[]): T;\n /**\n * A string of `n` decimal digits (`0`–`9`), each drawn uniformly.\n *\n * @param n - The number of digits (`>= 0`).\n */\n digits(n: number): string;\n}\n\n/**\n * The concrete {@link Rng}. Holds the mutable `sfc32` state; every method advances it deterministically.\n */\nclass Sfc32Rng implements Rng {\n public readonly seed: number;\n readonly #state: Sfc32State;\n\n public constructor(seed: number) {\n this.seed = seed | 0;\n // Expand the single seed into four well-distributed state words. Seeding sfc32 directly from the\n // raw seed gives poor low-bit behavior; splitmix32 is the standard fix (bryc / roadmap §5).\n const mix = splitmix32(this.seed);\n this.#state = { a: mix(), b: mix(), c: mix(), d: mix() };\n // A short warm-up so nearby seeds diverge immediately.\n for (let i = 0; i < 8; i += 1) sfc32Next(this.#state);\n }\n\n public nextUint32(): number {\n return sfc32Next(this.#state);\n }\n\n public float(): number {\n return this.nextUint32() / 0x1_0000_0000;\n }\n\n public int(min: number, max: number): number {\n if (max < min) throw new SynthError(SYNTH_FATAL_CODES.SYNTH_INVALID_RANGE);\n const span = max - min + 1;\n return min + Math.floor(this.float() * span);\n }\n\n public bool(p = 0.5): boolean {\n return this.float() < p;\n }\n\n public pick<T>(items: readonly T[]): T {\n if (items.length === 0) throw new SynthError(SYNTH_FATAL_CODES.SYNTH_EMPTY_POOL);\n // `int(0, length-1)` is always in-bounds on a non-empty array, so this access cannot be a hole;\n // the cast discharges `noUncheckedIndexedAccess`'s `T | undefined` without a runtime re-check.\n return items[this.int(0, items.length - 1)] as T;\n }\n\n public digits(n: number): string {\n let out = \"\";\n for (let i = 0; i < n; i += 1) out += String(this.int(0, 9));\n return out;\n }\n}\n\n/**\n * Create a seeded, deterministic {@link Rng}. The same `seed` yields the same sequence everywhere.\n *\n * @param seed - The integer seed. Coerced to a 32-bit integer.\n * @returns A fresh, independent {@link Rng}.\n * @example\n * ```ts\n * import { createRng } from \"@cosyte/synth\";\n * const rng = createRng(12345);\n * rng.int(1, 6); // deterministic for seed 12345\n * ```\n */\nexport function createRng(seed: number): Rng {\n return new Sfc32Rng(seed);\n}\n","/**\n * The reserved / never-collide identifier facts that make a `@cosyte/synth` value **provably\n * synthetic**: the ground truth behind the synthetic-safety invariant.\n *\n * These are **facts**, not copyrighted prose: authoritative ranges published by SSA, NANPA, and the\n * IETF that are guaranteed never to denote a real person or a real routable resource. Every provider\n * draws only from these; the predicates here are the executable half of the CI synthetic-safety gate:\n * they let a test assert that no emitted value falls **outside** a reserved source.\n *\n * Sources:\n * - **SSN**, SSA never issues area numbers `000`, `666`, or `900–999`; the `987-65-4320…4329` block\n * is SSA's explicitly-reserved advertising range. (ssa.gov)\n * - **Phone**, NANP reserves `555-0100…555-0199` as the fictional/non-working line range. (nanpa.com)\n * - **Email/domain**, RFC 2606 / RFC 6761 reserved: `example.com`/`.net`/`.org` and the `.example`,\n * `.test`, `.invalid`, `.localhost` TLDs.\n * - **IP**, RFC 5737 IPv4 TEST-NET-1/2/3 (`192.0.2.0/24`, `198.51.100.0/24`, `203.0.113.0/24`) and\n * RFC 3849 IPv6 documentation prefix `2001:db8::/32`.\n * - **NPI**, a real National Provider Identifier is a 10-digit number whose last digit is a Luhn\n * check digit computed over the `80840` prefix + the 9-digit base (CMS NPI check-digit rule, ISO\n * 7812). A number whose check digit is **wrong** therefore cannot be a NPPES-issued NPI. `synth`\n * emits NPIs with a deliberately-invalid check digit, so no generated NPI can collide with a real\n * provider.\n *\n * @module\n */\n\n/**\n * The synthetic **assigning authority** `@cosyte/synth` mints MRNs / account / member identifiers\n * under. There is **no** reserved MRN range (an MRN is unique only within its assigning-authority /\n * OID namespace), so, as a documented design decision, every synthetic identifier\n * is scoped to a namespace that clearly cannot be a real facility's: a `SYNTH`-labelled authority whose\n * OID lives under HL7's designated **example** root `2.16.840.1.113883.19`. A value under this AA can\n * never collide with a real record because the *namespace itself* is synthetic.\n */\nexport const SYNTHETIC_ASSIGNING_AUTHORITY = Object.freeze({\n /** The human-readable assigning-authority namespace id (HL7 HD.1). */\n namespaceId: \"COSYTE-SYNTH\",\n /** The universal id, an OID under HL7's example arc `2.16.840.1.113883.19` (HD.2). */\n universalId: \"2.16.840.1.113883.19.999\",\n /** The universal id type (HD.3). */\n universalIdType: \"ISO\",\n});\n\n/** RFC 2606 / 6761 reserved email domains `@cosyte/synth` draws from. */\nexport const RESERVED_EMAIL_DOMAINS: readonly string[] = Object.freeze([\n \"example.com\",\n \"example.org\",\n \"example.net\",\n]);\n\n/** RFC 5737 IPv4 documentation (TEST-NET) `/24` network prefixes. */\nexport const TEST_NET_V4_PREFIXES: readonly string[] = Object.freeze([\n \"192.0.2\", // TEST-NET-1\n \"198.51.100\", // TEST-NET-2\n \"203.0.113\", // TEST-NET-3\n]);\n\n/** RFC 3849 IPv6 documentation prefix. */\nexport const DOC_V6_PREFIX = \"2001:db8\";\n\n/**\n * The `80840` prefix prepended to a 10-digit NPI before the Luhn check (the CMS NPI check-digit\n * rule: `80840` is the ISO 7812 issuer identifier for the US health-application namespace). A real\n * NPI satisfies `luhn(\"80840\" + npi) ≡ 0 (mod 10)`.\n */\nexport const NPI_LUHN_PREFIX = \"80840\";\n\n/**\n * The Luhn sum (mod 10) of a numeric string, doubling every second digit from the right. Used to\n * verify (or deliberately break) an NPI check digit.\n *\n * @param digits - A string of decimal digits.\n * @returns The Luhn sum modulo 10 (0 ⇒ the string passes the Luhn check).\n * @internal\n */\nexport function luhnMod10(digits: string): number {\n let sum = 0;\n // Standard Luhn: the RIGHTMOST digit is never doubled; doubling starts one position in and\n // alternates. For a full payload+check string this makes a Luhn-valid string sum to 0 (mod 10);\n // for a payload with a `0` placeholder in the check position it yields the complement of the\n // correct check digit.\n let double = false;\n for (let i = digits.length - 1; i >= 0; i -= 1) {\n let d = digits.charCodeAt(i) - 48;\n if (d < 0 || d > 9) continue;\n if (double) {\n d *= 2;\n if (d > 9) d -= 9;\n }\n sum += d;\n double = !double;\n }\n return sum % 10;\n}\n\n/**\n * The correct NPI check digit for a 9-digit base: the value that makes `80840` + base + check pass\n * the Luhn check.\n *\n * @param base9 - The 9-digit NPI base (positions 1–9).\n * @returns The check digit (`0`–`9`) a real NPI would carry for this base.\n * @example\n * ```ts\n * import { npiCheckDigit } from \"@cosyte/synth\";\n * npiCheckDigit(\"123456789\"); // 3, so 1234567893 is a Luhn-valid NPI shape\n * ```\n */\nexport function npiCheckDigit(base9: string): number {\n // Luhn over \"80840\" + base9 with a trailing 0 check placeholder; the check digit closes the sum.\n const partial = luhnMod10(`${NPI_LUHN_PREFIX}${base9}0`);\n return (10 - partial) % 10;\n}\n\n/**\n * The DEA-registration prefix letters `@cosyte/synth` draws a synthetic DEA number's first character\n * from. A real DEA number is `<registrant-type><last-name-initial>` + 7 digits; the first letter is the\n * registrant type (A/B/F/G/M/P/R/X are the widely-published values; the second letter is the\n * registrant's last-name initial). These letters are a **fact** about the number's shape, not\n * copyrighted prose: they only shape the value; the synthetic guarantee is the deliberately-**invalid\n * checksum** (see {@link dea} / {@link isSyntheticDea}).\n */\nexport const DEA_REGISTRANT_TYPES: readonly string[] = Object.freeze([\n \"A\",\n \"B\",\n \"F\",\n \"G\",\n \"M\",\n \"P\",\n \"R\",\n \"X\",\n]);\n\n/**\n * The correct DEA check digit for a 7-digit numeric base. The published DEA checksum is\n * `(d1 + d3 + d5) + 2·(d2 + d4 + d6)`, whose **units digit** is the 7th (check) digit. A real DEA\n * number satisfies this; a number whose 7th digit differs cannot be a validly-issued DEA registration.\n *\n * @param base6 - The first 6 digits of the DEA number (positions 1–6).\n * @returns The check digit (`0`–`9`) a real DEA number would carry for this base.\n * @example\n * ```ts\n * import { deaCheckDigit } from \"@cosyte/synth\";\n * deaCheckDigit(\"123456\"); // the units digit of (1+3+5) + 2·(2+4+6)\n * ```\n */\nexport function deaCheckDigit(base6: string): number {\n let odd = 0;\n let even = 0;\n for (let i = 0; i < 6; i += 1) {\n const digit = base6.charCodeAt(i) - 48;\n if (i % 2 === 0) odd += digit;\n else even += digit;\n }\n return (odd + 2 * even) % 10;\n}\n\n/**\n * Whether a DEA number (`XX` + 7 digits, case-insensitive) is **provably synthetic**: its check digit\n * (the 7th digit) does **not** match the published DEA checksum, so it cannot be a validly-issued DEA\n * registration. A checksum-valid DEA number (which *could* denote a real prescriber) returns `false`; a\n * value that is not the DEA shape returns `false`.\n *\n * @param value - The candidate DEA number (with or without incidental separators).\n * @returns `true` when the DEA number's checksum is wrong (never a real DEA registration).\n * @example\n * ```ts\n * import { isSyntheticDea } from \"@cosyte/synth\";\n * isSyntheticDea(\"AF1234561\"); // depends on the base: true when the 7th digit is wrong\n * ```\n */\nexport function isSyntheticDea(value: string): boolean {\n const compact = value.replace(/[\\s-]/g, \"\").toUpperCase();\n if (!/^[A-Z]{2}\\d{7}$/.test(compact)) return false;\n const digits = compact.slice(2);\n const check = digits.charCodeAt(6) - 48;\n return deaCheckDigit(digits.slice(0, 6)) !== check;\n}\n\n/**\n * Whether a 10-digit NPI is **provably synthetic**, i.e. its check digit is invalid, so it cannot be\n * a NPPES-issued NPI. A Luhn-valid 10-digit NPI (which *could* denote a real registered provider)\n * returns `false`; a non-10-digit value returns `false` (not an NPI shape).\n *\n * @param value - The candidate NPI (digits only, or with incidental separators).\n * @returns `true` when the NPI's check digit is wrong (never a real NPI).\n * @example\n * ```ts\n * import { isSyntheticNpi } from \"@cosyte/synth\";\n * isSyntheticNpi(\"1234567894\"); // true: invalid check digit (valid would be 1234567893)\n * isSyntheticNpi(\"1234567893\"); // false: Luhn-valid, could be a real NPI\n * ```\n */\nexport function isSyntheticNpi(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n if (digits.length !== 10) return false;\n return luhnMod10(`${NPI_LUHN_PREFIX}${digits}`) !== 0;\n}\n\n/**\n * Whether a `ddd-dd-dddd` (or `ddddddddd`) SSN string is drawn from an SSA never-issued / reserved\n * space: area `000`, `666`, or `900–999`. A real, issuable SSN returns `false`.\n *\n * @param value - The candidate SSN (dashes optional).\n * @returns `true` when the SSN is provably synthetic.\n * @example\n * ```ts\n * import { isSyntheticSsn } from \"@cosyte/synth\";\n * isSyntheticSsn(\"900-12-3456\"); // true (never issued)\n * isSyntheticSsn(\"123456789\"); // false (issuable area 123)\n * ```\n */\nexport function isSyntheticSsn(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n if (digits.length !== 9) return false;\n const area = Number(digits.slice(0, 3));\n return area === 0 || area === 666 || area >= 900;\n}\n\n/**\n * Whether a phone string contains the NANP `555-0100…555-0199` reserved fictional line range.\n *\n * @param value - The candidate phone (any formatting).\n * @returns `true` when the number is in the reserved fictional block.\n * @example\n * ```ts\n * import { isSyntheticPhone } from \"@cosyte/synth\";\n * isSyntheticPhone(\"(202) 555-0142\"); // true\n * ```\n */\nexport function isSyntheticPhone(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n // The reserved guarantee is the 7-digit tail: exchange 555 + line 01NN.\n const tail = digits.slice(-7);\n return /^555 ?01\\d\\d$/.test(tail) || /^55501\\d\\d$/.test(tail);\n}\n\n/**\n * Whether an email's domain is an RFC 2606 / 6761 reserved / test domain.\n *\n * @param value - The candidate email address.\n * @returns `true` when the domain is reserved (never real).\n * @example\n * ```ts\n * import { isSyntheticEmail } from \"@cosyte/synth\";\n * isSyntheticEmail(\"faux.testerson@example.com\"); // true\n * ```\n */\nexport function isSyntheticEmail(value: string): boolean {\n const at = value.lastIndexOf(\"@\");\n if (at < 0) return false;\n const domain = value.slice(at + 1).toLowerCase();\n if (RESERVED_EMAIL_DOMAINS.includes(domain)) return true;\n return /\\.(example|test|invalid|localhost)$/.test(domain);\n}\n\n/**\n * Whether an IP string is in an RFC 5737 (IPv4 TEST-NET) or RFC 3849 (IPv6 documentation) reserved\n * block. A real routable address returns `false`.\n *\n * @param value - The candidate IPv4 or IPv6 address.\n * @returns `true` when the address is a reserved documentation address.\n * @example\n * ```ts\n * import { isSyntheticIp } from \"@cosyte/synth\";\n * isSyntheticIp(\"192.0.2.44\"); // true (TEST-NET-1)\n * isSyntheticIp(\"8.8.8.8\"); // false (real)\n * ```\n */\nexport function isSyntheticIp(value: string): boolean {\n if (value.toLowerCase().startsWith(`${DOC_V6_PREFIX}:`)) return true;\n return TEST_NET_V4_PREFIXES.some((prefix) => value.startsWith(`${prefix}.`));\n}\n","/**\n * The shipped **clearly-fake name pool**: `@cosyte/synth`'s own license-clean synthetic data.\n *\n * Deliberately **not** a `faker`-style realistic-name corpus (which could match a real person at a real\n * address: the exact hazard the synthetic-safety invariant forbids). Every token is\n * an obviously-invented, fixture-flavoured word: a reader can tell at a glance it names no one. The pool\n * is small on purpose: structural coverage, not demographic realism, is the goal.\n *\n * `# synthetic: true`\n *\n * @module\n */\n\n/** Obviously-synthetic given names. None is a plausible real person's name. */\nexport const SYNTHETIC_GIVEN_NAMES: readonly string[] = Object.freeze([\n \"Testina\",\n \"Fixtura\",\n \"Synthos\",\n \"Placeholda\",\n \"Sampleton\",\n \"Prototius\",\n \"Stubbina\",\n \"Exampla\",\n \"Quilliam\",\n \"Fabrica\",\n \"Simula\",\n \"Testry\",\n \"Seedwin\",\n \"Corpora\",\n \"Reprodo\",\n \"Mocktavia\",\n \"Dummett\",\n \"Voidwin\",\n \"Deteria\",\n \"Randomir\",\n]);\n\n/** Obviously-synthetic family names. None is a plausible real surname at a real address. */\nexport const SYNTHETIC_FAMILY_NAMES: readonly string[] = Object.freeze([\n \"Testerson\",\n \"Fauxman\",\n \"Placeholt\",\n \"Mockridge\",\n \"Fixtingham\",\n \"Synthwell\",\n \"Dummerton\",\n \"Examplewood\",\n \"Fabricant\",\n \"Simulacre\",\n \"Nonesuch\",\n \"Seedman\",\n \"Corpusworth\",\n \"Reprodus\",\n \"Voidmark\",\n \"Deterwood\",\n \"Randomson\",\n \"Quillfeather\",\n \"Notreal\",\n \"Genfield\",\n]);\n\n/** Obviously-synthetic street names for structured address fields. */\nexport const SYNTHETIC_STREET_NAMES: readonly string[] = Object.freeze([\n \"Fixture Lane\",\n \"Sample Street\",\n \"Placeholder Avenue\",\n \"Synthetic Way\",\n \"Example Boulevard\",\n \"Testing Terrace\",\n \"Mock Road\",\n \"Prototype Court\",\n]);\n\n/**\n * Obviously-synthetic city names. Combined only ever with a synthetic street + a fake name (the\n * *combination* is what identifies, and the combination is always synthetic).\n */\nexport const SYNTHETIC_CITY_NAMES: readonly string[] = Object.freeze([\n \"Faketon\",\n \"Synthville\",\n \"Exampleburg\",\n \"Testford\",\n \"Mockhaven\",\n \"Fixtureton\",\n]);\n","/**\n * The synthetic-safety provider layer: every identifier, contact point, name, and date\n * `@cosyte/synth` emits is minted here, and **only** from a guaranteed-non-colliding source. There is no code\n * path that returns a value not drawn from a reserved range or the\n * shipped fake-name pool. This is the inverse of a parser's liberality: the generator is *closed-world*\n * on its data sources, so no output *can* be real or plausibly-real PHI.\n *\n * All providers are pure functions of an explicit {@link ../rng/rng.Rng}, same seed, same values.\n *\n * @module\n */\n\nimport type { Rng } from \"../rng/rng.js\";\n\nimport {\n RESERVED_EMAIL_DOMAINS,\n TEST_NET_V4_PREFIXES,\n DOC_V6_PREFIX,\n SYNTHETIC_ASSIGNING_AUTHORITY,\n npiCheckDigit,\n deaCheckDigit,\n DEA_REGISTRANT_TYPES,\n} from \"./reserved.js\";\nimport {\n SYNTHETIC_GIVEN_NAMES,\n SYNTHETIC_FAMILY_NAMES,\n SYNTHETIC_STREET_NAMES,\n SYNTHETIC_CITY_NAMES,\n} from \"./names-pool.js\";\n\n/** A synthetic person name drawn from the shipped fake-name pool. */\nexport interface SyntheticName {\n /** A clearly-fake given name. */\n readonly given: string;\n /** A clearly-fake family name. */\n readonly family: string;\n}\n\n/** A synthetic postal address: synthetic street + city, a fixed non-real ZIP. */\nexport interface SyntheticAddress {\n /** A clearly-fake street line. */\n readonly street: string;\n /** A clearly-fake city. */\n readonly city: string;\n /** A US state abbreviation (structural only; never combined with a real street + name + DOB). */\n readonly state: string;\n /** A reserved non-real ZIP (`00000`). */\n readonly zip: string;\n}\n\n/** A synthetic identifier scoped to the synthetic assigning authority. */\nexport interface SyntheticIdentifier {\n /** The identifier value (digits): unique only within the synthetic namespace. */\n readonly value: string;\n /** HL7 identifier type code (`MR` = medical record, `AN` = account, `MB` = member). */\n readonly typeCode: \"MR\" | \"AN\" | \"MB\";\n /** The synthetic assigning-authority namespace id. */\n readonly assigningAuthority: string;\n /** The synthetic assigning-authority OID (HL7 example arc). */\n readonly assigningAuthorityOid: string;\n}\n\n/** Which SSN reserved space to draw from. */\nexport type SsnBlock = \"never-issued\" | \"advertising\";\n\n/**\n * A **synthetic SSN**: dashed `AAA-GG-SSSS`. Default draws the SSA never-issued area space\n * (`900–999`); `block: \"advertising\"` draws SSA's reserved advertising block (`987-65-4320…4329`).\n * A value from this function can never be a real SSN.\n *\n * @param rng - The seeded generator.\n * @param block - Which reserved space to draw from. Defaults to `\"never-issued\"`.\n * @returns A dashed synthetic SSN string.\n * @example\n * ```ts\n * import { createRng, ssn } from \"@cosyte/synth\";\n * ssn(createRng(1)); // e.g. a 900-area, never-issued SSN\n * ```\n */\nexport function ssn(rng: Rng, block: SsnBlock = \"never-issued\"): string {\n if (block === \"advertising\") {\n // SSA's explicitly-reserved advertising block: last digit 0..9 within -4320..-4329.\n return `987-65-432${String(rng.int(0, 9))}`;\n }\n const area = rng.int(900, 999); // SSA never issues 900-999.\n const group = rng.digits(2);\n const serial = rng.digits(4);\n return `${String(area)}-${group}-${serial}`;\n}\n\n/**\n * A **synthetic phone** in the NANP reserved fictional block: `(AAA) 555-01NN`. The reserved\n * guarantee is the `555-01NN` tail (exchange 555, line 0100–0199); the area code is any NANP-valid\n * `NXX`. Can never be a working number.\n *\n * @param rng - The seeded generator.\n * @returns A formatted synthetic phone string.\n * @example\n * ```ts\n * import { createRng, phone } from \"@cosyte/synth\";\n * phone(createRng(1)); // e.g. \"(2XX) 555-01NN\"\n * ```\n */\nexport function phone(rng: Rng): string {\n const area = `${String(rng.int(2, 9))}${rng.digits(2)}`; // NXX area code.\n const line = `01${rng.digits(2)}`; // reserved 0100-0199.\n return `(${area}) 555-${line}`;\n}\n\n/**\n * A **synthetic name** drawn from the shipped clearly-fake pool.\n *\n * @param rng - The seeded generator.\n * @returns A {@link SyntheticName}.\n * @example\n * ```ts\n * import { createRng, name } from \"@cosyte/synth\";\n * const { given, family } = name(createRng(1));\n * ```\n */\nexport function name(rng: Rng): SyntheticName {\n return { given: rng.pick(SYNTHETIC_GIVEN_NAMES), family: rng.pick(SYNTHETIC_FAMILY_NAMES) };\n}\n\n/**\n * A **synthetic email** at an RFC 2606 / 6761 reserved domain: `<slug>@example.com`.\n *\n * @param rng - The seeded generator.\n * @param person - Optional name to derive the local-part slug from; otherwise a random slug is used.\n * @returns A synthetic email address.\n * @example\n * ```ts\n * import { createRng, email, name } from \"@cosyte/synth\";\n * email(createRng(1), name(createRng(1))); // \"<given>.<family>@example.com\"\n * ```\n */\nexport function email(rng: Rng, person?: SyntheticName): string {\n const domain = rng.pick(RESERVED_EMAIL_DOMAINS);\n const slug = person ? `${person.given}.${person.family}`.toLowerCase() : `synth${rng.digits(6)}`;\n return `${slug}@${domain}`;\n}\n\n/**\n * A **synthetic IPv4** in an RFC 5737 TEST-NET block, never routable.\n *\n * @param rng - The seeded generator.\n * @returns A TEST-NET IPv4 address string.\n * @example\n * ```ts\n * import { createRng, ipv4 } from \"@cosyte/synth\";\n * ipv4(createRng(1)); // e.g. \"192.0.2.NN\"\n * ```\n */\nexport function ipv4(rng: Rng): string {\n return `${rng.pick(TEST_NET_V4_PREFIXES)}.${String(rng.int(1, 254))}`;\n}\n\n/**\n * A **synthetic IPv6** in the RFC 3849 documentation prefix `2001:db8::/32`, never routable.\n *\n * @param rng - The seeded generator.\n * @returns A documentation-prefix IPv6 address string.\n * @example\n * ```ts\n * import { createRng, ipv6 } from \"@cosyte/synth\";\n * ipv6(createRng(1)); // e.g. \"2001:db8::NNNN\"\n * ```\n */\nexport function ipv6(rng: Rng): string {\n const tail = rng.nextUint32().toString(16).padStart(4, \"0\").slice(-4);\n return `${DOC_V6_PREFIX}::${tail}`;\n}\n\n/**\n * A **deterministic UUIDv4-shaped** surrogate key from the seeded generator. Because it is seeded (not\n * from `node:crypto`, which is not reproducible), the cryptographic non-collision argument is weaker,\n * acceptable because the identifier namespace is synthetic anyway, and noted honestly.\n *\n * @param rng - The seeded generator.\n * @returns A canonical `8-4-4-4-12` lowercase-hex UUID string with version `4` and RFC 4122 variant.\n * @example\n * ```ts\n * import { createRng, uuid } from \"@cosyte/synth\";\n * uuid(createRng(1)); // \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\"\n * ```\n */\nexport function uuid(rng: Rng): string {\n const bytes = new Uint8Array(16);\n for (let i = 0; i < 16; i += 1) bytes[i] = rng.int(0, 255);\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40; // version 4\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80; // variant 10xx\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(6, 8).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10, 16).join(\"\")}`;\n}\n\n/**\n * A **synthetic NPI**: a 10-digit National Provider Identifier with a **deliberately-invalid Luhn\n * check digit**, so it can never be a NPPES-issued NPI (a real NPI must satisfy the `80840`-prefixed\n * Luhn check). The 9-digit base is drawn from the seeded generator; the check digit is\n * set to `(correct + 1) mod 10`, guaranteeing the full value fails validation.\n *\n * @param rng - The seeded generator.\n * @returns A 10-digit NPI-shaped string that is provably not a real NPI.\n * @example\n * ```ts\n * import { createRng, npi, isSyntheticNpi } from \"@cosyte/synth\";\n * isSyntheticNpi(npi(createRng(1))); // true: invalid check digit by construction\n * ```\n */\nexport function npi(rng: Rng): string {\n const base9 = rng.digits(9);\n const wrongCheck = (npiCheckDigit(base9) + 1) % 10;\n return `${base9}${String(wrongCheck)}`;\n}\n\n/**\n * A **synthetic DEA number**: `<registrant-type><initial>` + 7 digits with a **deliberately-invalid\n * checksum**, so it can never be a validly-issued DEA registration (a real DEA number's 7th digit\n * satisfies the published DEA checksum). The first letter is a registrant-type letter, the\n * second is derived from `person` (its family initial) when supplied so the number reads plausibly; the\n * 6-digit base is seeded and the check digit is set to `(correct + 1) mod 10`, guaranteeing the value\n * fails validation. NCPDP carries prescriber DEA, and this is the identity locus a refuter attacks\n * hardest, so, like {@link npi}, non-collision is a construction-level guarantee, not a heuristic.\n *\n * @param rng - The seeded generator.\n * @param person - Optional name whose family initial becomes the DEA's second letter.\n * @returns A DEA-shaped string that is provably not a real DEA registration.\n * @example\n * ```ts\n * import { createRng, dea, isSyntheticDea } from \"@cosyte/synth\";\n * isSyntheticDea(dea(createRng(1))); // true: invalid checksum by construction\n * ```\n */\nexport function dea(rng: Rng, person?: SyntheticName): string {\n const type = rng.pick(DEA_REGISTRANT_TYPES);\n const initialSource = person?.family ?? rng.pick(SYNTHETIC_FAMILY_NAMES);\n const initial = initialSource.slice(0, 1).toUpperCase();\n const base6 = rng.digits(6);\n const wrongCheck = (deaCheckDigit(base6) + 1) % 10;\n return `${type}${initial}${base6}${String(wrongCheck)}`;\n}\n\n/**\n * A **synthetic identifier** (MRN / account / member id) scoped to the synthetic assigning authority.\n * There is no reserved MRN range, so non-collision is guaranteed by the *namespace*, not the value: the\n * identifier lives under a `SYNTH` authority no real facility uses.\n *\n * @param rng - The seeded generator.\n * @param typeCode - The HL7 identifier type: `MR` (default), `AN`, or `MB`.\n * @returns A {@link SyntheticIdentifier}.\n * @example\n * ```ts\n * import { createRng, identifier } from \"@cosyte/synth\";\n * identifier(createRng(1), \"MR\"); // { value, typeCode: \"MR\", assigningAuthority: \"COSYTE-SYNTH\", ... }\n * ```\n */\nexport function identifier(\n rng: Rng,\n typeCode: SyntheticIdentifier[\"typeCode\"] = \"MR\",\n): SyntheticIdentifier {\n return {\n value: rng.digits(8),\n typeCode,\n assigningAuthority: SYNTHETIC_ASSIGNING_AUTHORITY.namespaceId,\n assigningAuthorityOid: SYNTHETIC_ASSIGNING_AUTHORITY.universalId,\n };\n}\n\n/**\n * A **synthetic address**: a fake street + city, a reserved non-real ZIP (`00000`). A real state\n * abbreviation may appear (structural only) but is never combined with a real street + name + DOB.\n *\n * @param rng - The seeded generator.\n * @returns A {@link SyntheticAddress}.\n * @example\n * ```ts\n * import { createRng, address } from \"@cosyte/synth\";\n * address(createRng(1)); // { street, city, state, zip: \"00000\" }\n * ```\n */\nexport function address(rng: Rng): SyntheticAddress {\n const number = rng.int(1, 9999);\n return {\n street: `${String(number)} ${rng.pick(SYNTHETIC_STREET_NAMES)}`,\n city: rng.pick(SYNTHETIC_CITY_NAMES),\n state: rng.pick(US_STATES),\n zip: \"00000\",\n };\n}\n\n/**\n * A **synthetic date** in HL7 `YYYYMMDD` form, drawn uniformly within an inclusive year range. Comes\n * from the seeded generator (never wall-clock), so it is reproducible and implies no real event.\n *\n * @param rng - The seeded generator.\n * @param minYear - Inclusive lower year bound (default `1930`).\n * @param maxYear - Inclusive upper year bound (default `2010`).\n * @returns An `YYYYMMDD` date string (always a valid calendar day).\n * @example\n * ```ts\n * import { createRng, dateYmd } from \"@cosyte/synth\";\n * dateYmd(createRng(1), 1970, 2000); // \"YYYYMMDD\"\n * ```\n */\nexport function dateYmd(rng: Rng, minYear = 1930, maxYear = 2010): string {\n const year = rng.int(minYear, maxYear);\n const month = rng.int(1, 12);\n const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();\n const day = rng.int(1, daysInMonth);\n return `${String(year).padStart(4, \"0\")}${String(month).padStart(2, \"0\")}${String(day).padStart(2, \"0\")}`;\n}\n\n/** US state abbreviations: structural only (see {@link address}). */\nconst US_STATES: readonly string[] = Object.freeze([\n \"AL\",\n \"AK\",\n \"AZ\",\n \"AR\",\n \"CA\",\n \"CO\",\n \"CT\",\n \"DE\",\n \"FL\",\n \"GA\",\n \"HI\",\n \"ID\",\n \"IL\",\n \"IN\",\n \"IA\",\n \"KS\",\n \"KY\",\n \"LA\",\n \"ME\",\n \"MD\",\n \"MA\",\n \"MI\",\n \"MN\",\n \"MS\",\n \"MO\",\n \"MT\",\n \"NE\",\n \"NV\",\n \"NH\",\n \"NJ\",\n \"NM\",\n \"NY\",\n \"NC\",\n \"ND\",\n \"OH\",\n \"OK\",\n \"OR\",\n \"PA\",\n \"RI\",\n \"SC\",\n \"SD\",\n \"TN\",\n \"TX\",\n \"UT\",\n \"VT\",\n \"VA\",\n \"WA\",\n \"WV\",\n \"WI\",\n \"WY\",\n]);\n","/**\n * The `safe` namespace: the single entry point for every synthetic-by-construction value provider.\n *\n * Grouped under one object so a consumer reads `safe.ssn(rng)` / `safe.phone(rng)` and it is\n * self-evident that the value is drawn from a guaranteed-non-colliding synthetic source.\n * The individual functions and the reserved-range predicates are also exported by name from the\n * package root for direct import.\n *\n * @module\n */\n\nimport {\n ssn,\n phone,\n name,\n email,\n ipv4,\n ipv6,\n uuid,\n identifier,\n address,\n dateYmd,\n npi,\n dea,\n} from \"./providers.js\";\n\nexport * from \"./providers.js\";\nexport * from \"./reserved.js\";\nexport * from \"./names-pool.js\";\n\n/**\n * The synthetic-safety provider namespace. Every function draws only from a reserved range or the\n * shipped fake-name pool, no value it returns can be real or plausibly-real PHI.\n *\n * @example\n * ```ts\n * import { createRng, safe } from \"@cosyte/synth\";\n * const rng = createRng(42);\n * safe.ssn(rng); // never-issued SSN\n * safe.phone(rng); // reserved 555-01NN number\n * ```\n */\nexport const safe = Object.freeze({\n ssn,\n phone,\n name,\n email,\n ipv4,\n ipv6,\n uuid,\n identifier,\n address,\n dateYmd,\n npi,\n dea,\n});\n","/**\n * US Core + base-FHIR **canonical URLs and code-system identifiers**: the facts `@cosyte/synth` needs\n * to emit US-Core-conformant resources, and nothing more.\n *\n * **Content-free, exactly like `@cosyte/fhir`.** These are *identifiers*: canonical URLs and code\n * `system` URIs, not the copyrighted terminology tables or the profile `StructureDefinition` content\n * they name. `@cosyte/synth` bundles **no** US Core IG: a consumer who wants to *validate* generated\n * output against US Core supplies the `StructureDefinition`s themselves (BYO), exactly as\n * `@cosyte/fhir.validateResource({ profiles })` requires. What is encoded here is only which canonical\n * URL a resource's `meta.profile` claims and which `system` a coding carries: public facts.\n *\n * The URLs target **US Core 6.1.0** (the USCDI v3 / ONC HTI-1 §170.315(g)(10) anchor, FHIR R4 4.0.1),\n * grounded firsthand against the published IG (`hl7.org/fhir/us/core/STU6.1`): the same version the\n * test corpus validates against.\n *\n * @module\n */\n\n/** The canonical `meta.profile` URLs for the US Core 6.1.0 profiles `@cosyte/synth` generates. */\nexport const US_CORE_PROFILE = Object.freeze({\n /** US Core Patient. */\n PATIENT: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient\",\n /** US Core Condition (Problems and Health Concerns). */\n CONDITION:\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-problems-health-concerns\",\n /** US Core Laboratory Result Observation. */\n OBSERVATION_LAB: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab\",\n /** US Core Vital Signs (derived from the base FHIR vital-signs profile). */\n VITAL_SIGNS: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-vital-signs\",\n /** US Core MedicationRequest. */\n MEDICATION_REQUEST: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-medicationrequest\",\n /** US Core Encounter. */\n ENCOUNTER: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter\",\n /** US Core DiagnosticReport Profile for Laboratory Results Reporting. */\n DIAGNOSTIC_REPORT_LAB:\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-lab\",\n /** US Core Immunization. */\n IMMUNIZATION: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-immunization\",\n /** US Core AllergyIntolerance. */\n ALLERGY_INTOLERANCE: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-allergyintolerance\",\n /** US Core Procedure. */\n PROCEDURE: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-procedure\",\n} as const);\n\n/** The US Core `us-core-race` extension URL (a Patient must-support extension). */\nexport const US_CORE_RACE_EXTENSION =\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race\";\n/** The US Core `us-core-ethnicity` extension URL (a Patient must-support extension). */\nexport const US_CORE_ETHNICITY_EXTENSION =\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity\";\n/** The US Core `us-core-birthsex` extension URL (a Patient must-support extension). */\nexport const US_CORE_BIRTHSEX_EXTENSION =\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex\";\n\n/**\n * The code-system `system` URIs the generators reference. Public identity URIs (HL7-published),\n * never the code-system *content*, no SNOMED/LOINC/RxNorm table is bundled.\n */\nexport const SYSTEM = Object.freeze({\n /** FHIR `administrative-gender` (`Patient.gender`). */\n ADMINISTRATIVE_GENDER: \"http://hl7.org/fhir/administrative-gender\",\n /** HL7 Terminology `observation-category`. */\n OBSERVATION_CATEGORY: \"http://terminology.hl7.org/CodeSystem/observation-category\",\n /** HL7 Terminology `condition-category`. */\n CONDITION_CATEGORY: \"http://terminology.hl7.org/CodeSystem/condition-category\",\n /** HL7 Terminology `condition-clinical`. */\n CONDITION_CLINICAL: \"http://terminology.hl7.org/CodeSystem/condition-clinical\",\n /** HL7 Terminology `condition-ver-status`. */\n CONDITION_VER_STATUS: \"http://terminology.hl7.org/CodeSystem/condition-ver-status\",\n /** HL7 v2 `0203` identifier-type (`Identifier.type.coding.code` = `MR`). */\n IDENTIFIER_TYPE: \"http://terminology.hl7.org/CodeSystem/v2-0203\",\n /** OMB race & ethnicity category system (US Core race/ethnicity `ombCategory`). */\n OMB_RACE_ETHNICITY: \"urn:oid:2.16.840.1.113883.6.238\",\n /** LOINC, `Observation.code` (lab + vital-signs). */\n LOINC: \"http://loinc.org\",\n /** SNOMED CT, `Condition.code`. */\n SNOMED: \"http://snomed.info/sct\",\n /** RxNorm, `MedicationRequest.medicationCodeableConcept` + an allergen substance. */\n RXNORM: \"http://www.nlm.nih.gov/research/umls/rxnorm\",\n /** UCUM, `Quantity.system` for units of measure. */\n UCUM: \"http://unitsofmeasure.org\",\n /** CVX (CDC vaccine administered), `Immunization.vaccineCode`. */\n CVX: \"http://hl7.org/fhir/sid/cvx\",\n /** HL7 v3 `ActCode`, `Encounter.class`. */\n V3_ACT_CODE: \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",\n /** HL7 v2 `0074` diagnostic-service-section, `DiagnosticReport.category` (`LAB`). */\n DIAGNOSTIC_SERVICE_SECTION: \"http://terminology.hl7.org/CodeSystem/v2-0074\",\n /** HL7 Terminology `allergyintolerance-clinical`, `AllergyIntolerance.clinicalStatus`. */\n ALLERGY_CLINICAL: \"http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\",\n /** HL7 Terminology `allergyintolerance-verification`, `AllergyIntolerance.verificationStatus`. */\n ALLERGY_VERIFICATION: \"http://terminology.hl7.org/CodeSystem/allergyintolerance-verification\",\n} as const);\n\n/** A US Core profile canonical URL. */\nexport type UsCoreProfileUrl = (typeof US_CORE_PROFILE)[keyof typeof US_CORE_PROFILE];\n","/**\n * Shared FHIR model-construction helpers: the small vocabulary every resource generator uses\n * to build **through `@cosyte/fhir`'s own model constructors** (`complex` / `list` / `primitive` /\n * `decimal`). A generated resource is a `FhirComplex` tree assembled here and serialized by\n * `@cosyte/fhir`'s conservative writer, so it is **spec-clean by construction**: the same mechanism\n * that makes the parser's emit side spec-clean. Nothing here hand-writes JSON\n * bytes.\n *\n * Identity fields (`name`, `identifier`, `birthDate`, `telecom`, `address`) are minted from the\n * synthetic-safety providers in `../safe`, so no value a resource carries can be real or plausibly-real\n * PHI. The `fhirPatientIdentity` bundle draws them in a **fixed order** for the\n * reproducibility contract.\n *\n * @module\n */\n\nimport { complex, decimal, list, primitive } from \"@cosyte/fhir\";\nimport type { FhirComplex, FhirNode } from \"@cosyte/fhir\";\n\nimport type { Rng } from \"../rng/rng.js\";\nimport {\n safe,\n type SyntheticName,\n type SyntheticAddress,\n type SyntheticIdentifier,\n} from \"../safe/index.js\";\n\nimport { SYSTEM } from \"./us-core.js\";\n\n/** A named FHIR property (`{ name, value }`): the shape `complex` consumes. */\nexport type Prop = { readonly name: string; readonly value: FhirNode };\n\n/**\n * Build a named FHIR property.\n *\n * @param name - The property name.\n * @param value - The property's node value.\n * @returns A {@link Prop}.\n * @example\n * ```ts\n * import { prop, str } from \"@cosyte/synth/fhir\";\n * prop(\"gender\", str(\"female\"));\n * ```\n */\nexport function prop(name: string, value: FhirNode): Prop {\n return { name, value };\n}\n\n/**\n * A `string`/`code`/`uri`/`date` primitive leaf.\n *\n * @param value - The lexical string value.\n * @returns A primitive `FhirNode`.\n * @example\n * ```ts\n * import { str } from \"@cosyte/synth/fhir\";\n * str(\"final\");\n * ```\n */\nexport function str(value: string): FhirNode {\n return primitive(value);\n}\n\n/**\n * A `decimal` primitive leaf, precision-preserving via `@cosyte/fhir`'s string-backed `FhirDecimal`.\n *\n * @param raw - The exact decimal lexical form (never routed through a JS `number`).\n * @returns A primitive `FhirNode`.\n * @example\n * ```ts\n * import { dec } from \"@cosyte/synth/fhir\";\n * dec(\"6.3\");\n * ```\n */\nexport function dec(raw: string): FhirNode {\n return primitive(decimal(raw));\n}\n\n/**\n * A `boolean` primitive leaf.\n *\n * @param value - The boolean value.\n * @returns A primitive `FhirNode`.\n * @example\n * ```ts\n * import { bool } from \"@cosyte/synth/fhir\";\n * bool(true);\n * ```\n */\nexport function bool(value: boolean): FhirNode {\n return primitive(value);\n}\n\n/**\n * A single `Coding` element (`system` + `code` + `display`).\n *\n * @param concept - The coding's `system`, `code`, and `display`.\n * @returns A `Coding` `FhirComplex`.\n * @example\n * ```ts\n * import { coding } from \"@cosyte/synth/fhir\";\n * coding({ system: \"http://loinc.org\", code: \"2345-7\", display: \"Glucose\" });\n * ```\n */\nexport function coding(concept: { system: string; code: string; display: string }): FhirComplex {\n return complex([\n prop(\"system\", str(concept.system)),\n prop(\"code\", str(concept.code)),\n prop(\"display\", str(concept.display)),\n ]);\n}\n\n/**\n * A `CodeableConcept` wrapping a single `Coding`.\n *\n * @param concept - The coding's `system`, `code`, and `display`.\n * @returns A `CodeableConcept` `FhirComplex`.\n * @example\n * ```ts\n * import { codeableConcept } from \"@cosyte/synth/fhir\";\n * codeableConcept({ system: \"http://snomed.info/sct\", code: \"59621000\", display: \"Essential hypertension\" });\n * ```\n */\nexport function codeableConcept(concept: {\n system: string;\n code: string;\n display: string;\n}): FhirComplex {\n return complex([prop(\"coding\", list([coding(concept)]))]);\n}\n\n/**\n * A literal `Reference` element (`{ reference: \"<Type>/<id>\" }` or a `urn:uuid:` fullUrl).\n *\n * @param ref - The reference string.\n * @returns A `Reference` `FhirComplex`.\n * @example\n * ```ts\n * import { reference } from \"@cosyte/synth/fhir\";\n * reference(\"Patient/syn-patient-1\");\n * ```\n */\nexport function reference(ref: string): FhirComplex {\n return complex([prop(\"reference\", str(ref))]);\n}\n\n/**\n * A generated `Narrative` (`text`) with `status: \"generated\"` and an XHTML `div` carrying only\n * synthetic text, satisfies the base `dom-6` best-practice constraint so a generated resource is\n * robust as well as valid. The `div` is XHTML-namespaced and carries no markup beyond a paragraph, so\n * it round-trips byte-for-byte through `@cosyte/fhir`'s codec.\n *\n * @param text - The plain synthetic summary text (no PHI: it is composed from synthetic values).\n * @returns A `Narrative` `FhirComplex`.\n * @example\n * ```ts\n * import { narrative } from \"@cosyte/synth/fhir\";\n * narrative(\"Synthetic patient summary.\");\n * ```\n */\nexport function narrative(text: string): FhirComplex {\n const escaped = text.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n return complex([\n prop(\"status\", str(\"generated\")),\n prop(\"div\", str(`<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>${escaped}</p></div>`)),\n ]);\n}\n\n/**\n * A `meta.profile` element pinning the resource to one or more canonical profile URLs (US Core\n * conformance is claimed via `meta.profile`). No version is pinned, so validating against any supplied\n * version of the named profile never raises a version-mismatch.\n *\n * @param profiles - The canonical profile URLs to claim.\n * @returns A `meta` `FhirComplex`.\n * @example\n * ```ts\n * import { meta, US_CORE_PROFILE } from \"@cosyte/synth/fhir\";\n * meta([US_CORE_PROFILE.PATIENT]);\n * ```\n */\nexport function meta(profiles: readonly string[]): FhirComplex {\n return complex([prop(\"profile\", list(profiles.map((p) => str(p))))]);\n}\n\n/** A synthetic FHIR patient identity: every field drawn from `../safe`. */\nexport interface FhirPatientIdentity {\n /** A synthetic resource `id` (a seeded UUID), never a real record key. */\n readonly id: string;\n /** Name from the shipped fake-name pool. */\n readonly person: SyntheticName;\n /** Medical-record identifier scoped to the synthetic assigning authority. */\n readonly mrn: SyntheticIdentifier;\n /** Date of birth as a FHIR `date` (`YYYY-MM-DD`) from the seeded generator. */\n readonly birthDate: string;\n /** FHIR administrative-gender code. */\n readonly gender: \"male\" | \"female\";\n /** Synthetic postal address (reserved non-real ZIP). */\n readonly address: SyntheticAddress;\n /** Reserved `555-01xx` phone number. */\n readonly phone: string;\n /** Synthetic email at a reserved (`example.*`) domain. */\n readonly email: string;\n}\n\n/**\n * Reformat a `YYYYMMDD` synthetic date (from `safe.dateYmd`) as a FHIR `date` (`YYYY-MM-DD`).\n *\n * @param ymd - The `YYYYMMDD` date string.\n * @returns The `YYYY-MM-DD` FHIR date string.\n * @example\n * ```ts\n * import { toFhirDate } from \"@cosyte/synth/fhir\";\n * toFhirDate(\"19700131\"); // \"1970-01-31\"\n * ```\n */\nexport function toFhirDate(ymd: string): string {\n return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;\n}\n\n/**\n * Mint a complete synthetic {@link FhirPatientIdentity}. Every value comes from a synthetic-safety\n * provider, no code path here can return a real or plausibly-real identifier. The draw\n * order is fixed (id → name → MRN → DOB → gender → address → phone → email) so the same seed yields the\n * same identity.\n *\n * @param rng - The seeded generator.\n * @returns A synthetic {@link FhirPatientIdentity}.\n * @example\n * ```ts\n * import { createRng } from \"@cosyte/synth\";\n * // const id = fhirPatientIdentity(createRng(1)); // id.person, id.mrn, …\n * ```\n */\nexport function fhirPatientIdentity(rng: Rng): FhirPatientIdentity {\n const id = safe.uuid(rng);\n const person = safe.name(rng);\n const mrn = safe.identifier(rng, \"MR\");\n const birthDate = toFhirDate(safe.dateYmd(rng, 1930, 2010));\n const gender = rng.pick([\"male\", \"female\"] as const);\n const address = safe.address(rng);\n const phone = safe.phone(rng);\n const email = safe.email(rng, person);\n return { id, person, mrn, birthDate, gender, address, phone, email };\n}\n\n/**\n * The US Core Patient `identifier` element for a synthetic MRN: `type` (`MR`), the synthetic\n * assigning-authority OID as `system`, and the synthetic value. Satisfies US Core Patient's required\n * `identifier.system` + `identifier.value`.\n *\n * @param mrn - The synthetic identifier from `safe.identifier`.\n * @returns An `Identifier` `FhirComplex`.\n * @example\n * ```ts\n * import { createRng, safe } from \"@cosyte/synth\";\n * import { mrnIdentifier } from \"@cosyte/synth/fhir\";\n * mrnIdentifier(safe.identifier(createRng(1), \"MR\"));\n * ```\n */\nexport function mrnIdentifier(mrn: SyntheticIdentifier): FhirComplex {\n return complex([\n prop(\n \"type\",\n complex([\n prop(\n \"coding\",\n list([\n coding({\n system: SYSTEM.IDENTIFIER_TYPE,\n code: \"MR\",\n display: \"Medical Record Number\",\n }),\n ]),\n ),\n ]),\n ),\n prop(\"system\", str(`urn:oid:${mrn.assigningAuthorityOid}`)),\n prop(\"value\", str(mrn.value)),\n ]);\n}\n","/**\n * A tiny, curated, **license-clean** pool of example codes for filling coded fields in generated FHIR\n * resources (`Observation.code`, `Condition.code`, `MedicationRequest.medication[x]`, and the OMB\n * race/ethnicity categories). These are **public code facts**: codes drawn from the published FHIR R4\n * and US Core specification examples, not copyrighted terminology tables: `@cosyte/synth` bundles\n * **no** SNOMED/LOINC/RxNorm content. The pool exists only so a\n * generated resource is *structurally* realistic; a consumer who needs their own codes supplies them.\n *\n * Nothing here is PHI: codes and their display text are not patient identifiers. The synthetic-safety\n * invariant governs identity fields (name/DOB/identifier/telecom/address), which come from `../safe`.\n *\n * @module\n */\n\n/** A coded concept: a `system` URI, a `code`, and its human-readable `display`. */\nexport interface CodeConcept {\n /** The code-system URI (`Coding.system`). */\n readonly system: string;\n /** The code value (`Coding.code`). */\n readonly code: string;\n /** The human-readable display text (`Coding.display`). */\n readonly display: string;\n}\n\n/**\n * A quantitative observation concept: a LOINC code plus the UCUM unit and a plausible synthetic value\n * range the seeded generator draws within. The range implies **no** real measurement: it only keeps a\n * generated result inside a structurally-sane band.\n */\nexport interface QuantConcept extends CodeConcept {\n /** The UCUM unit code (`Quantity.code` and, as text, `Quantity.unit`). */\n readonly unit: string;\n /** Inclusive lower bound of the synthetic value (in `unit`). */\n readonly low: number;\n /** Inclusive upper bound of the synthetic value (in `unit`). */\n readonly high: number;\n /** Decimal places to render (keeps the emitted `decimal` lexical form stable and realistic). */\n readonly decimals: number;\n}\n\nimport { SYSTEM } from \"./us-core.js\";\n\n/**\n * LOINC laboratory-result example codes (for a US Core Laboratory Result `Observation`). Public LOINC\n * identifiers used purely as illustrative structural fillers, with UCUM units and synthetic value bands.\n */\nexport const EXAMPLE_LAB_OBSERVATIONS: readonly QuantConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"2345-7\",\n display: \"Glucose [Mass/volume] in Serum or Plasma\",\n unit: \"mg/dL\",\n low: 70,\n high: 140,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"718-7\",\n display: \"Hemoglobin [Mass/volume] in Blood\",\n unit: \"g/dL\",\n low: 12,\n high: 17,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"2951-2\",\n display: \"Sodium [Moles/volume] in Serum or Plasma\",\n unit: \"mmol/L\",\n low: 135,\n high: 145,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"2823-3\",\n display: \"Potassium [Moles/volume] in Serum or Plasma\",\n unit: \"mmol/L\",\n low: 4,\n high: 5,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"4548-4\",\n display: \"Hemoglobin A1c/Hemoglobin.total in Blood\",\n unit: \"%\",\n low: 4,\n high: 9,\n decimals: 1,\n }),\n]);\n\n/**\n * LOINC vital-sign example codes (for a US Core Vital Signs `Observation`). Public LOINC identifiers\n * with their required UCUM units and synthetic value bands. Simple single-value vitals only:\n * multi-component vitals (e.g. blood-pressure panel `85354-9`) are not generated.\n */\nexport const EXAMPLE_VITAL_SIGNS: readonly QuantConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"8867-4\",\n display: \"Heart rate\",\n unit: \"/min\",\n low: 55,\n high: 100,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"9279-1\",\n display: \"Respiratory rate\",\n unit: \"/min\",\n low: 12,\n high: 20,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"8310-5\",\n display: \"Body temperature\",\n unit: \"Cel\",\n low: 36,\n high: 38,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"29463-7\",\n display: \"Body weight\",\n unit: \"kg\",\n low: 50,\n high: 100,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"8302-2\",\n display: \"Body height\",\n unit: \"cm\",\n low: 150,\n high: 190,\n decimals: 0,\n }),\n]);\n\n/**\n * SNOMED CT problem/condition example codes (for a US Core `Condition.code`). Public SNOMED identifiers\n * used as structural fillers; `@cosyte/synth` bundles no SNOMED content.\n */\nexport const EXAMPLE_CONDITIONS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.SNOMED, code: \"59621000\", display: \"Essential hypertension\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"44054006\", display: \"Type 2 diabetes mellitus\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"195967001\", display: \"Asthma\" }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"13645005\",\n display: \"Chronic obstructive lung disease\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"38341003\", display: \"Hypertensive disorder\" }),\n]);\n\n/**\n * RxNorm medication example codes (for a US Core `MedicationRequest.medicationCodeableConcept`). Public\n * RxNorm identifiers used as structural fillers; `@cosyte/synth` bundles no RxNorm content.\n */\nexport const EXAMPLE_MEDICATIONS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"1049221\",\n display: \"Acetaminophen 325 MG Oral Tablet\",\n }),\n Object.freeze({ system: SYSTEM.RXNORM, code: \"197361\", display: \"Amlodipine 5 MG Oral Tablet\" }),\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"860975\",\n display: \"24 HR Metformin hydrochloride 500 MG Extended Release Oral Tablet\",\n }),\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"308136\",\n display: \"Amoxicillin 250 MG Oral Capsule\",\n }),\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"617314\",\n display: \"Atorvastatin 40 MG Oral Tablet\",\n }),\n]);\n\n/**\n * OMB race categories (US Core `us-core-race` `ombCategory`): the five OMB categories, public code\n * facts from the CDC Race &amp; Ethnicity code system (`urn:oid:2.16.840.1.113883.6.238`).\n */\nexport const EXAMPLE_RACE_CATEGORIES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.OMB_RACE_ETHNICITY, code: \"2106-3\", display: \"White\" }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2054-5\",\n display: \"Black or African American\",\n }),\n Object.freeze({ system: SYSTEM.OMB_RACE_ETHNICITY, code: \"2028-9\", display: \"Asian\" }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"1002-5\",\n display: \"American Indian or Alaska Native\",\n }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2076-8\",\n display: \"Native Hawaiian or Other Pacific Islander\",\n }),\n]);\n\n/**\n * OMB ethnicity categories (US Core `us-core-ethnicity` `ombCategory`): the two OMB categories, public\n * code facts from the CDC Race &amp; Ethnicity code system.\n */\nexport const EXAMPLE_ETHNICITY_CATEGORIES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2135-2\",\n display: \"Hispanic or Latino\",\n }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2186-5\",\n display: \"Not Hispanic or Latino\",\n }),\n]);\n\n/**\n * CVX vaccine-administered example codes (for a US Core `Immunization.vaccineCode`). Public CDC CVX\n * identifiers used as structural fillers; `@cosyte/synth` bundles no CVX content.\n */\nexport const EXAMPLE_VACCINES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.CVX,\n code: \"140\",\n display: \"Influenza, seasonal, injectable, preservative free\",\n }),\n Object.freeze({ system: SYSTEM.CVX, code: \"03\", display: \"MMR\" }),\n Object.freeze({ system: SYSTEM.CVX, code: \"20\", display: \"DTaP\" }),\n Object.freeze({ system: SYSTEM.CVX, code: \"133\", display: \"Pneumococcal conjugate PCV 13\" }),\n Object.freeze({\n system: SYSTEM.CVX,\n code: \"208\",\n display: \"COVID-19, mRNA, LNP-S, PF, 30 mcg/0.3 mL dose\",\n }),\n]);\n\n/**\n * Allergen-substance example codes (for a US Core `AllergyIntolerance.code`). Public RxNorm / SNOMED CT\n * identifiers used as structural fillers; no terminology content is bundled.\n */\nexport const EXAMPLE_ALLERGENS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.RXNORM, code: \"7980\", display: \"Penicillin G\" }),\n Object.freeze({ system: SYSTEM.RXNORM, code: \"2670\", display: \"Codeine\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"762952008\", display: \"Peanut (substance)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"227493005\", display: \"Cashew nuts (substance)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"3718001\", display: \"Cow's milk (substance)\" }),\n]);\n\n/**\n * Allergy-reaction manifestation example codes (for `AllergyIntolerance.reaction.manifestation`).\n * Public SNOMED CT clinical-finding identifiers used as structural fillers.\n */\nexport const EXAMPLE_ALLERGY_MANIFESTATIONS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.SNOMED, code: \"247472004\", display: \"Wheal (finding)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"126485001\", display: \"Urticaria (disorder)\" }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"271807003\",\n display: \"Eruption of skin (disorder)\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"267036007\", display: \"Dyspnea (finding)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"422587007\", display: \"Nausea (finding)\" }),\n]);\n\n/**\n * SNOMED CT procedure example codes (for a US Core `Procedure.code`). Public SNOMED identifiers used as\n * structural fillers, **not** CPT (which is never bundled).\n */\nexport const EXAMPLE_PROCEDURES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"80146002\",\n display: \"Excision of appendix (procedure)\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"73761001\", display: \"Colonoscopy (procedure)\" }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"5880005\",\n display: \"Physical examination procedure (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"108252007\",\n display: \"Laboratory procedure (procedure)\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"71651007\", display: \"Mammography (procedure)\" }),\n]);\n\n/**\n * LOINC diagnostic-report example codes (for a US Core Laboratory `DiagnosticReport.code`). Public LOINC\n * panel identifiers used as structural fillers.\n */\nexport const EXAMPLE_DIAGNOSTIC_REPORTS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24323-8\",\n display: \"Comprehensive metabolic 2000 panel - Serum or Plasma\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"58410-2\",\n display: \"CBC panel - Blood by Automated count\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24357-6\",\n display: \"Urinalysis complete panel - Urine\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24331-1\",\n display: \"Lipid 1996 panel - Serum or Plasma\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24321-2\",\n display: \"Basic metabolic 1998 panel - Serum or Plasma\",\n }),\n]);\n\n/**\n * SNOMED CT encounter-type example codes (for a US Core `Encounter.type`). Public SNOMED identifiers\n * used as structural fillers.\n */\nexport const EXAMPLE_ENCOUNTER_TYPES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"308335008\",\n display: \"Patient encounter procedure (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"185349003\",\n display: \"Encounter for check up (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"185347001\",\n display: \"Encounter for problem (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"390906007\",\n display: \"Follow-up encounter (procedure)\",\n }),\n]);\n\n/**\n * HL7 v3 `ActCode` encounter-class example codes (for `Encounter.class`, a single `Coding`). Public\n * ActCode identifiers used as structural fillers.\n */\nexport const EXAMPLE_ENCOUNTER_CLASSES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.V3_ACT_CODE, code: \"AMB\", display: \"ambulatory\" }),\n Object.freeze({ system: SYSTEM.V3_ACT_CODE, code: \"EMER\", display: \"emergency\" }),\n Object.freeze({ system: SYSTEM.V3_ACT_CODE, code: \"IMP\", display: \"inpatient encounter\" }),\n]);\n","/**\n * The **selector chokepoint**. A generator's options are almost all *selectors*: a message kind, a\n * document type, a corpus mix, a claim variant, a Bundle type, a profile. Each is typed as a closed\n * union, and every one of those unions is **erased at run time**, so a JavaScript caller (or a\n * `as never` in someone's test) reaches the branch with any string at all.\n *\n * Three things went wrong when that was left unchecked, and they are all the same bug:\n *\n * 1. **The value reached a diagnostic.** An unrecognised `documentType` travelled into\n * `@cosyte/ccda`'s `buildCcda`, which is entitled to quote it back in its own `TypeError` and\n * does. This package then has a caller-supplied string on an `err.message` and an `err.stack`,\n * through its own public entry point, having taken no care of it.\n * 2. **The value reached the model.** A corpus mix entry becomes an `Artifact.kind` and a\n * `manifest.counts` key, which is precisely the structural-identifier position a downstream\n * package interpolates to describe a location.\n * 3. **The fixture was silently mislabeled.** An exhaustive `switch` over an erased union takes no\n * branch and returns `undefined`, or a trailing `else` quietly generates something else. A corpus\n * whose manifest says it holds one transaction and holds another is a golden file that lies.\n *\n * So a selector is resolved against its own set, once, before anything is generated, and an\n * unrecognised one is a fatal `SYNTH_UNSUPPORTED_KIND`. Like every fatal here it carries a code and a\n * fixed message, and quotes neither the request nor the set.\n *\n * @module\n */\n\nimport { SYNTH_FATAL_CODES, SynthError } from \"./codes.js\";\n\n/**\n * Resolve one caller-supplied selector against the closed set that governs it, or **fail closed**.\n *\n * @param allowed - Every value the selector may take.\n * @param requested - The selector the caller supplied.\n * @returns `requested`, narrowed to the union.\n * @throws SynthError `SYNTH_UNSUPPORTED_KIND` when `requested` is not in `allowed`.\n * @example\n * ```ts\n * import { resolveKind } from \"@cosyte/synth\";\n * resolveKind([\"ccd\", \"referralNote\"] as const, \"ccd\"); // \"ccd\"\n * ```\n */\nexport function resolveKind<T extends string>(allowed: readonly T[], requested: string): T {\n const match = allowed.find((value) => value === requested);\n if (match === undefined) throw new SynthError(SYNTH_FATAL_CODES.SYNTH_UNSUPPORTED_KIND);\n return match;\n}\n\n/**\n * Resolve every entry of a caller-supplied corpus mix, in order, or **fail closed** on the first\n * unrecognised one.\n *\n * It substitutes the default **only** when the caller supplied nothing, which is exactly what the\n * `??` it replaced did. An empty array is a supplied mix and is returned as one. An earlier version\n * of this function also treated `[]` as \"nothing supplied\", on the stated grounds that it matched the\n * previous behaviour; it did not: `??` fires on `undefined` and never on `[]`, and it changed the\n * result of six published entry points, turning an explicit empty selection into \"generate one of\n * everything\". A convenience that fails open is not a convenience.\n *\n * @param allowed - Every kind the corpus may generate.\n * @param requested - The mix the caller supplied, or `undefined` for the default.\n * @param fallback - The default mix, used only when `requested` is `undefined`.\n * @returns The resolved mix.\n * @throws SynthError `SYNTH_UNSUPPORTED_KIND` on the first unrecognised entry.\n * @example\n * ```ts\n * import { resolveMix } from \"@cosyte/synth\";\n * resolveMix([\"Result\", \"Order\"] as const, [\"Order\"], [\"Result\", \"Order\"]); // [\"Order\"]\n * ```\n */\nexport function resolveMix<T extends string>(\n allowed: readonly T[],\n requested: readonly string[] | undefined,\n fallback: readonly T[],\n): readonly T[] {\n if (requested === undefined) return fallback;\n return requested.map((entry) => resolveKind(allowed, entry));\n}\n","/**\n * Synthetic FHIR R4 **`Patient`** generation: the anchor of the US Core clinical spine. Built through\n * `@cosyte/fhir`'s model constructors, every identity field drawn from the\n * synthetic-safety providers. In `us-core` mode the resource claims US Core Patient via\n * `meta.profile`, satisfies its required elements (`identifier` + `system` + `value`, `name`, `gender`),\n * and carries the must-support race / ethnicity / birthsex extensions.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport {\n bool,\n coding,\n fhirPatientIdentity,\n meta,\n mrnIdentifier,\n narrative,\n prop,\n str,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_ETHNICITY_CATEGORIES, EXAMPLE_RACE_CATEGORIES } from \"./example-codes.js\";\nimport {\n US_CORE_BIRTHSEX_EXTENSION,\n US_CORE_ETHNICITY_EXTENSION,\n US_CORE_PROFILE,\n US_CORE_RACE_EXTENSION,\n} from \"./us-core.js\";\nimport { resolveKind } from \"../select.js\";\n\n/** Every value {@link GeneratePatientOptions.profile} admits. Erased at run time, so it is resolved. */\nconst PATIENT_PROFILES: readonly (\"base\" | \"us-core\")[] = Object.freeze([\"base\", \"us-core\"]);\n\n/** Options for {@link generatePatient}. */\nexport interface GeneratePatientOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /**\n * The profile posture. `\"base\"` (default) emits a spec-clean base-R4 `Patient`; `\"us-core\"` adds the\n * US Core `meta.profile` and the race/ethnicity/birthsex must-support extensions (the required\n * elements, identifier/name/gender, are always present).\n */\n readonly profile?: \"base\" | \"us-core\";\n}\n\n/** A US Core `us-core-race` / `us-core-ethnicity` complex extension with one OMB category + text. */\nfunction ombExtension(\n url: string,\n category: { system: string; code: string; display: string },\n): FhirComplex {\n return complex([\n prop(\"url\", str(url)),\n prop(\n \"extension\",\n list([\n complex([prop(\"url\", str(\"ombCategory\")), prop(\"valueCoding\", coding(category))]),\n complex([prop(\"url\", str(\"text\")), prop(\"valueString\", str(category.display))]),\n ]),\n ),\n ]);\n}\n\n/**\n * Generate a spec-clean synthetic FHIR R4 `Patient` (base or US Core), built through `@cosyte/fhir`.\n *\n * @param options - Seed and profile posture. See {@link GeneratePatientOptions}.\n * @returns The `Patient` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generatePatient } from \"@cosyte/synth/fhir\";\n * import { serializeResource } from \"@cosyte/fhir\";\n * const patient = generatePatient({ seed: 42, profile: \"us-core\" });\n * serializeResource(patient);\n * ```\n */\nexport function generatePatient(options: GeneratePatientOptions = {}): FhirComplex {\n const { seed = 0 } = options;\n const profile = resolveKind(PATIENT_PROFILES, options.profile ?? \"base\");\n const rng = createRng(seed);\n const id = fhirPatientIdentity(rng);\n const usCore = profile === \"us-core\";\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Patient\")),\n prop(\"id\", str(`syn-patient-${id.id}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.PATIENT])));\n props.push(\n prop(\n \"text\",\n narrative(\n `Synthetic patient ${id.person.given} ${id.person.family} (${id.gender}, born ${id.birthDate}).`,\n ),\n ),\n );\n\n if (usCore) {\n const race = rng.pick(EXAMPLE_RACE_CATEGORIES);\n const ethnicity = rng.pick(EXAMPLE_ETHNICITY_CATEGORIES);\n const birthsex = id.gender === \"male\" ? \"M\" : \"F\";\n props.push(\n prop(\n \"extension\",\n list([\n ombExtension(US_CORE_RACE_EXTENSION, race),\n ombExtension(US_CORE_ETHNICITY_EXTENSION, ethnicity),\n complex([prop(\"url\", str(US_CORE_BIRTHSEX_EXTENSION)), prop(\"valueCode\", str(birthsex))]),\n ]),\n ),\n );\n }\n\n props.push(prop(\"identifier\", list([mrnIdentifier(id.mrn)])));\n props.push(prop(\"active\", bool(true)));\n props.push(\n prop(\n \"name\",\n list([\n complex([\n prop(\"use\", str(\"official\")),\n prop(\"family\", str(id.person.family)),\n prop(\"given\", list([str(id.person.given)])),\n ]),\n ]),\n ),\n );\n props.push(\n prop(\n \"telecom\",\n list([\n complex([\n prop(\"system\", str(\"phone\")),\n prop(\"value\", str(id.phone)),\n prop(\"use\", str(\"home\")),\n ]),\n complex([prop(\"system\", str(\"email\")), prop(\"value\", str(id.email))]),\n ]),\n ),\n );\n props.push(prop(\"gender\", str(id.gender)));\n props.push(prop(\"birthDate\", str(id.birthDate)));\n props.push(\n prop(\n \"address\",\n list([\n complex([\n prop(\"use\", str(\"home\")),\n prop(\"line\", list([str(id.address.street)])),\n prop(\"city\", str(id.address.city)),\n prop(\"state\", str(id.address.state)),\n prop(\"postalCode\", str(id.address.zip)),\n ]),\n ]),\n ),\n );\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Condition`** generation: a US Core \"Problems and Health Concerns\" problem-list\n * item. Built through `@cosyte/fhir`; the `code` comes from the license-clean SNOMED\n * example pool, the `subject` from a supplied or derived synthetic Patient reference.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { codeableConcept, meta, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { EXAMPLE_CONDITIONS } from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateCondition}. */\nexport interface GenerateConditionOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Condition` (problem-list item), built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject reference, and US Core posture. See {@link GenerateConditionOptions}.\n * @returns The `Condition` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateCondition } from \"@cosyte/synth/fhir\";\n * const condition = generateCondition({ seed: 7, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateCondition(options: GenerateConditionOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const code = rng.pick(EXAMPLE_CONDITIONS);\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Condition\")),\n prop(\"id\", str(`syn-cond-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.CONDITION])));\n props.push(prop(\"text\", narrative(`Synthetic condition: ${code.display}.`)));\n props.push(\n prop(\n \"clinicalStatus\",\n codeableConcept({ system: SYSTEM.CONDITION_CLINICAL, code: \"active\", display: \"Active\" }),\n ),\n );\n props.push(\n prop(\n \"verificationStatus\",\n codeableConcept({\n system: SYSTEM.CONDITION_VER_STATUS,\n code: \"confirmed\",\n display: \"Confirmed\",\n }),\n ),\n );\n props.push(\n prop(\n \"category\",\n list([\n codeableConcept({\n system: SYSTEM.CONDITION_CATEGORY,\n code: \"problem-list-item\",\n display: \"Problem List Item\",\n }),\n ]),\n ),\n );\n props.push(prop(\"code\", codeableConcept(code)));\n props.push(prop(\"subject\", reference(subject)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Observation`** generation: US Core Laboratory Result and US Core Vital Signs. Built\n * through `@cosyte/fhir`; `code` and the measured `valueQuantity` come from\n * the license-clean LOINC/UCUM example pool, `subject` from a supplied or derived Patient reference.\n * The measured value is drawn from the seeded generator within a structurally-sane band: it implies no\n * real measurement.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng, type Rng } from \"../rng/rng.js\";\nimport {\n codeableConcept,\n dec,\n meta,\n narrative,\n prop,\n reference,\n str,\n type Prop,\n} from \"./builder.js\";\nimport {\n EXAMPLE_LAB_OBSERVATIONS,\n EXAMPLE_VITAL_SIGNS,\n type QuantConcept,\n} from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateObservationLab} / {@link generateVitalSign}. */\nexport interface GenerateObservationOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/** Draw a synthetic `decimal` value string within the concept's band, at its declared precision. */\nfunction drawValue(rng: Rng, concept: QuantConcept): string {\n const span = concept.high - concept.low;\n const raw = concept.low + rng.float() * span;\n return raw.toFixed(concept.decimals);\n}\n\n/** A UCUM `valueQuantity` for a measured concept: `value` (decimal), `unit`, UCUM `system` + `code`. */\nfunction valueQuantity(rng: Rng, concept: QuantConcept): FhirComplex {\n return complex([\n prop(\"value\", dec(drawValue(rng, concept))),\n prop(\"unit\", str(concept.unit)),\n prop(\"system\", str(SYSTEM.UCUM)),\n prop(\"code\", str(concept.unit)),\n ]);\n}\n\n/** Build an `Observation` of the given category from a measured concept pool. */\nfunction buildObservation(\n seed: number,\n subject: string,\n usCore: boolean,\n profileUrl: string,\n category: { code: string; display: string },\n pool: readonly QuantConcept[],\n effective: boolean,\n): FhirComplex {\n const rng = createRng(seed);\n const concept = rng.pick(pool);\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Observation\")),\n prop(\"id\", str(`syn-obs-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([profileUrl])));\n props.push(\n prop(\"text\", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`)),\n );\n props.push(prop(\"status\", str(\"final\")));\n props.push(\n prop(\n \"category\",\n list([\n codeableConcept({\n system: SYSTEM.OBSERVATION_CATEGORY,\n code: category.code,\n display: category.display,\n }),\n ]),\n ),\n );\n props.push(prop(\"code\", codeableConcept(concept)));\n props.push(prop(\"subject\", reference(subject)));\n // Draw the effective instant deterministically (a plausible recent date) before the value.\n const y = rng.int(2020, 2025);\n const m = String(rng.int(1, 12)).padStart(2, \"0\");\n const d = String(rng.int(1, 28)).padStart(2, \"0\");\n if (effective) props.push(prop(\"effectiveDateTime\", str(`${String(y)}-${m}-${d}`)));\n props.push(prop(\"valueQuantity\", valueQuantity(rng, concept)));\n return complex(props);\n}\n\n/**\n * Generate a spec-clean synthetic US Core **Laboratory Result** `Observation`.\n *\n * @param options - Seed, subject reference, US Core posture. See {@link GenerateObservationOptions}.\n * @returns The `Observation` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateObservationLab } from \"@cosyte/synth/fhir\";\n * const obs = generateObservationLab({ seed: 3, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateObservationLab(options: GenerateObservationOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n return buildObservation(\n seed,\n subject,\n usCore,\n US_CORE_PROFILE.OBSERVATION_LAB,\n { code: \"laboratory\", display: \"Laboratory\" },\n EXAMPLE_LAB_OBSERVATIONS,\n false,\n );\n}\n\n/**\n * Generate a spec-clean synthetic US Core **Vital Signs** `Observation` (a single-value vital such as\n * heart rate or body weight; `effectiveDateTime` is required by the vital-signs profile).\n *\n * @param options - Seed, subject reference, US Core posture. See {@link GenerateObservationOptions}.\n * @returns The `Observation` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateVitalSign } from \"@cosyte/synth/fhir\";\n * const vs = generateVitalSign({ seed: 5, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateVitalSign(options: GenerateObservationOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n return buildObservation(\n seed,\n subject,\n usCore,\n US_CORE_PROFILE.VITAL_SIGNS,\n { code: \"vital-signs\", display: \"Vital Signs\" },\n EXAMPLE_VITAL_SIGNS,\n true,\n );\n}\n","/**\n * Synthetic FHIR R4 **`MedicationRequest`** generation: a US Core MedicationRequest with an inline\n * `medicationCodeableConcept`. Built through `@cosyte/fhir`; the medication comes\n * from the license-clean RxNorm example pool. US Core invariant `us-core-21` requires a `requester`\n * whenever `intent = order`, so a synthetic requester reference is always emitted.\n *\n * @module\n */\n\nimport { complex } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { codeableConcept, meta, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { EXAMPLE_MEDICATIONS } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateMedicationRequest}. */\nexport interface GenerateMedicationRequestOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** The `requester` reference. Defaults to a synthetic `Practitioner` reference. */\n readonly requester?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `MedicationRequest`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject/requester references, US Core posture.\n * @returns The `MedicationRequest` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateMedicationRequest } from \"@cosyte/synth/fhir\";\n * const mr = generateMedicationRequest({ seed: 9, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateMedicationRequest(\n options: GenerateMedicationRequestOptions = {},\n): FhirComplex {\n const {\n seed = 0,\n subject = \"Patient/syn-patient-1\",\n requester = \"Practitioner/syn-practitioner-1\",\n usCore = true,\n } = options;\n const rng = createRng(seed);\n const med = rng.pick(EXAMPLE_MEDICATIONS);\n const y = rng.int(2020, 2025);\n const m = String(rng.int(1, 12)).padStart(2, \"0\");\n const d = String(rng.int(1, 28)).padStart(2, \"0\");\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"MedicationRequest\")),\n prop(\"id\", str(`syn-medreq-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));\n props.push(prop(\"text\", narrative(`Synthetic medication order: ${med.display}.`)));\n props.push(prop(\"status\", str(\"active\")));\n props.push(prop(\"intent\", str(\"order\")));\n props.push(prop(\"medicationCodeableConcept\", codeableConcept(med)));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"authoredOn\", str(`${String(y)}-${m}-${d}`)));\n props.push(prop(\"requester\", reference(requester)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Encounter`** generation: a US Core Encounter. Built through `@cosyte/fhir`'s model\n * constructors; `class` and `type` come from the\n * license-clean v3-ActCode / SNOMED example pools, `subject` from a supplied or derived synthetic\n * Patient reference. The required elements (`status`, `class`, `type`, `subject`) are always present.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n coding,\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_ENCOUNTER_CLASSES, EXAMPLE_ENCOUNTER_TYPES } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateEncounter}. */\nexport interface GenerateEncounterOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Encounter`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject reference, and US Core posture. See {@link GenerateEncounterOptions}.\n * @returns The `Encounter` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateEncounter } from \"@cosyte/synth/fhir\";\n * const encounter = generateEncounter({ seed: 11, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateEncounter(options: GenerateEncounterOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const cls = rng.pick(EXAMPLE_ENCOUNTER_CLASSES);\n const type = rng.pick(EXAMPLE_ENCOUNTER_TYPES);\n const id = safe.identifier(rng, \"AN\");\n const start = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Encounter\")),\n prop(\"id\", str(`syn-enc-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.ENCOUNTER])));\n props.push(prop(\"text\", narrative(`Synthetic encounter: ${type.display}.`)));\n props.push(\n prop(\n \"identifier\",\n list([\n complex([\n prop(\"system\", str(`urn:oid:${id.assigningAuthorityOid}`)),\n prop(\"value\", str(id.value)),\n ]),\n ]),\n ),\n );\n props.push(prop(\"status\", str(\"finished\")));\n props.push(prop(\"class\", coding(cls)));\n props.push(prop(\"type\", list([codeableConcept(type)])));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"period\", complex([prop(\"start\", str(`${start}T09:00:00Z`))])));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Immunization`** generation: a US Core Immunization. Built through `@cosyte/fhir`;\n * `vaccineCode` comes from the license-clean CVX example\n * pool, `patient` from a supplied or derived synthetic Patient reference. The required elements\n * (`status`, `vaccineCode`, `patient`, `occurrenceDateTime`) are always present.\n *\n * @module\n */\n\nimport { complex } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n bool,\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_VACCINES } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateImmunization}. */\nexport interface GenerateImmunizationOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `patient` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly patient?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Immunization`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, patient reference, and US Core posture. See {@link GenerateImmunizationOptions}.\n * @returns The `Immunization` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateImmunization } from \"@cosyte/synth/fhir\";\n * const imm = generateImmunization({ seed: 13, patient: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateImmunization(options: GenerateImmunizationOptions = {}): FhirComplex {\n const { seed = 0, patient = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const vaccine = rng.pick(EXAMPLE_VACCINES);\n const occurrence = toFhirDate(safe.dateYmd(rng, 2015, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Immunization\")),\n prop(\"id\", str(`syn-imm-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.IMMUNIZATION])));\n props.push(prop(\"text\", narrative(`Synthetic immunization: ${vaccine.display}.`)));\n props.push(prop(\"status\", str(\"completed\")));\n props.push(prop(\"vaccineCode\", codeableConcept(vaccine)));\n props.push(prop(\"patient\", reference(patient)));\n props.push(prop(\"occurrenceDateTime\", str(occurrence)));\n props.push(prop(\"primarySource\", bool(true)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`AllergyIntolerance`** generation: a US Core AllergyIntolerance. Built through\n * `@cosyte/fhir`; the allergen `code` and reaction\n * `manifestation` come from the license-clean RxNorm/SNOMED example pools, `patient` from a supplied or\n * derived synthetic Patient reference. `clinicalStatus` + `verificationStatus` are emitted together so\n * the base `ait-1`/`ait-2` invariants hold; the required `code` and `patient` are always present.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { codeableConcept, meta, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { EXAMPLE_ALLERGENS, EXAMPLE_ALLERGY_MANIFESTATIONS } from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateAllergyIntolerance}. */\nexport interface GenerateAllergyIntoleranceOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `patient` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly patient?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `AllergyIntolerance`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, patient reference, and US Core posture. See\n * {@link GenerateAllergyIntoleranceOptions}.\n * @returns The `AllergyIntolerance` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateAllergyIntolerance } from \"@cosyte/synth/fhir\";\n * const allergy = generateAllergyIntolerance({ seed: 15, patient: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateAllergyIntolerance(\n options: GenerateAllergyIntoleranceOptions = {},\n): FhirComplex {\n const { seed = 0, patient = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const allergen = rng.pick(EXAMPLE_ALLERGENS);\n const manifestation = rng.pick(EXAMPLE_ALLERGY_MANIFESTATIONS);\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"AllergyIntolerance\")),\n prop(\"id\", str(`syn-allergy-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));\n props.push(prop(\"text\", narrative(`Synthetic allergy: ${allergen.display}.`)));\n props.push(\n prop(\n \"clinicalStatus\",\n codeableConcept({ system: SYSTEM.ALLERGY_CLINICAL, code: \"active\", display: \"Active\" }),\n ),\n );\n props.push(\n prop(\n \"verificationStatus\",\n codeableConcept({\n system: SYSTEM.ALLERGY_VERIFICATION,\n code: \"confirmed\",\n display: \"Confirmed\",\n }),\n ),\n );\n props.push(prop(\"code\", codeableConcept(allergen)));\n props.push(prop(\"patient\", reference(patient)));\n props.push(\n prop(\n \"reaction\",\n list([complex([prop(\"manifestation\", list([codeableConcept(manifestation)]))])]),\n ),\n );\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Procedure`** generation: a US Core Procedure. Built through `@cosyte/fhir`; the\n * `code` comes from the license-clean SNOMED procedure\n * example pool (never CPT), `subject` from a supplied or derived synthetic Patient\n * reference. The required elements (`status`, `code`, `subject`) plus the must-support\n * `performedDateTime` are always present.\n *\n * @module\n */\n\nimport { complex } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_PROCEDURES } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateProcedure}. */\nexport interface GenerateProcedureOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Procedure`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject reference, and US Core posture. See {@link GenerateProcedureOptions}.\n * @returns The `Procedure` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateProcedure } from \"@cosyte/synth/fhir\";\n * const procedure = generateProcedure({ seed: 17, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateProcedure(options: GenerateProcedureOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const code = rng.pick(EXAMPLE_PROCEDURES);\n const performed = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Procedure\")),\n prop(\"id\", str(`syn-proc-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.PROCEDURE])));\n props.push(prop(\"text\", narrative(`Synthetic procedure: ${code.display}.`)));\n props.push(prop(\"status\", str(\"completed\")));\n props.push(prop(\"code\", codeableConcept(code)));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"performedDateTime\", str(`${performed}T10:00:00Z`)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`DiagnosticReport`** generation: the US Core DiagnosticReport Profile for\n * Laboratory Results Reporting. Built through `@cosyte/fhir`;\n * the report `code` comes from the license-clean LOINC example pool, `subject` from a supplied or\n * derived synthetic Patient reference. The required `category` carries the profile's mandated `LAB`\n * slice, and `effectiveDateTime` + `issued` are always present so the `us-core-8`/`us-core-9`\n * invariants hold for a `final` report. Optional `result` references wire the report to its\n * `Observation`s (used by the `document` Bundle).\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_DIAGNOSTIC_REPORTS } from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateDiagnosticReport}. */\nexport interface GenerateDiagnosticReportOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** `result` references to the report's `Observation`s (empty ⇒ omitted). */\n readonly results?: readonly string[];\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core Laboratory `DiagnosticReport`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject, result references, US Core posture. See\n * {@link GenerateDiagnosticReportOptions}.\n * @returns The `DiagnosticReport` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateDiagnosticReport } from \"@cosyte/synth/fhir\";\n * const report = generateDiagnosticReport({ seed: 19, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateDiagnosticReport(\n options: GenerateDiagnosticReportOptions = {},\n): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", results = [], usCore = true } = options;\n const rng = createRng(seed);\n const code = rng.pick(EXAMPLE_DIAGNOSTIC_REPORTS);\n const day = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"DiagnosticReport\")),\n prop(\"id\", str(`syn-dr-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));\n props.push(prop(\"text\", narrative(`Synthetic laboratory report: ${code.display}.`)));\n props.push(prop(\"status\", str(\"final\")));\n props.push(\n prop(\n \"category\",\n list([\n codeableConcept({\n system: SYSTEM.DIAGNOSTIC_SERVICE_SECTION,\n code: \"LAB\",\n display: \"Laboratory\",\n }),\n ]),\n ),\n );\n props.push(prop(\"code\", codeableConcept(code)));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"effectiveDateTime\", str(`${day}T08:30:00Z`)));\n props.push(prop(\"issued\", str(`${day}T09:00:00.000Z`)));\n if (results.length > 0) {\n props.push(prop(\"result\", list(results.map((r) => reference(r)))));\n }\n return complex(props);\n}\n","/**\n * The `Corpus` abstraction: a seed plus a self-describing manifest of what was generated, so a\n * fixture set is itself reproducible and regenerable. A downstream repo pins a seed\n * and gets a stable fixture set that regenerates identically.\n *\n * Generated artifacts and the `Corpus` are **deep-frozen**: this is where the archetype's immutability\n * invariant lives in a generator: a consumer cannot mutate a shared fixture out from under\n * another test.\n *\n * @module\n */\n\n/** The format an artifact was generated for. */\nexport type SynthFormat = \"hl7v2\" | \"fhir\" | \"ccda\" | \"x12\" | \"ncpdp\" | \"astm\";\n\n/**\n * One generated artifact: the serialized wire text plus the metadata needed to reproduce and check\n * it. `warnings` records what the artifact's own parser reported on the round-trip (zero for a\n * spec-clean artifact).\n */\nexport interface Artifact {\n /** The format this artifact belongs to. */\n readonly format: SynthFormat;\n /** A format-specific kind label (e.g. `\"ADT^A01\"`). */\n readonly kind: string;\n /** The serialized wire text, produced by the parser's own conservative serializer. */\n readonly content: string;\n /** The warning codes the parser emitted when the artifact was round-tripped (empty = spec-clean). */\n readonly warnings: readonly string[];\n}\n\n/** A self-describing manifest of a {@link Corpus}. */\nexport interface CorpusManifest {\n /** The formats present in the corpus. */\n readonly formats: readonly SynthFormat[];\n /** Per-kind artifact counts (e.g. `{ \"ADT^A01\": 3 }`). */\n readonly counts: Readonly<Record<string, number>>;\n /** The quirk names applied. */\n readonly quirks: readonly string[];\n}\n\n/** A reproducible, self-describing set of generated artifacts. */\nexport interface Corpus {\n /** The seed the corpus was generated from: regenerating from it yields byte-identical artifacts. */\n readonly seed: number;\n /** The manifest describing what was generated. */\n readonly manifest: CorpusManifest;\n /** The generated artifacts, in generation order. */\n readonly artifacts: readonly Artifact[];\n}\n\n/**\n * Assemble a deep-frozen {@link Corpus} from a seed and its artifacts, deriving the manifest.\n *\n * @param seed - The seed the artifacts were generated from.\n * @param artifacts - The generated artifacts, in order.\n * @param quirks - The quirk names applied (default none).\n * @returns A deep-frozen, self-describing {@link Corpus}.\n * @example\n * ```ts\n * import { makeCorpus } from \"@cosyte/synth\";\n * const corpus = makeCorpus(1, [{ format: \"hl7v2\", kind: \"ADT^A01\", content, warnings: [] }]);\n * corpus.manifest.counts[\"ADT^A01\"]; // 1\n * ```\n */\nexport function makeCorpus(\n seed: number,\n artifacts: readonly Artifact[],\n quirks: readonly string[] = [],\n): Corpus {\n const counts: Record<string, number> = {};\n const formats = new Set<SynthFormat>();\n const frozenArtifacts = artifacts.map((a) => {\n counts[a.kind] = (counts[a.kind] ?? 0) + 1;\n formats.add(a.format);\n return Object.freeze({ ...a, warnings: Object.freeze([...a.warnings]) });\n });\n const manifest: CorpusManifest = Object.freeze({\n formats: Object.freeze([...formats]),\n counts: Object.freeze(counts),\n quirks: Object.freeze([...quirks]),\n });\n return Object.freeze({\n seed,\n manifest,\n artifacts: Object.freeze(frozenArtifacts),\n });\n}\n","/**\n * Synthetic FHIR R4 **`Composition`** generation: the mandatory first resource of a `document` Bundle\n * (FHIR invariant `bdl-11`), built through `@cosyte/fhir`.\n * A Composition is a base-R4 resource (US Core 6.1.0 defines no Composition profile), so it is grounded\n * against base FHIR R4; every reference it carries (`subject`, `author`, `custodian`, section `entry`s)\n * is an in-bundle `urn:uuid:` fullUrl so the document is self-contained and its references resolve.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport type { Rng } from \"../rng/rng.js\";\nimport { codeableConcept, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { SYSTEM } from \"./us-core.js\";\n\n/** A document section: a LOINC section code, a human title, and the entry references it summarizes. */\nexport interface CompositionSection {\n /** The LOINC section code. */\n readonly code: string;\n /** The section's human title / display. */\n readonly title: string;\n /** In-bundle `urn:uuid:` references to the resources the section summarizes. */\n readonly entries: readonly string[];\n}\n\n/** Inputs for {@link buildComposition}. */\nexport interface BuildCompositionInput {\n /** The `subject` reference (the patient's in-bundle fullUrl). */\n readonly subject: string;\n /** The `author` + `custodian` reference (an in-bundle Organization fullUrl). */\n readonly organization: string;\n /** The document date (`YYYY-MM-DD`). */\n readonly date: string;\n /** The document sections. */\n readonly sections: readonly CompositionSection[];\n}\n\n/** One `Composition.section`: title, LOINC code, and its `entry` references (satisfies `cmp-1`). */\nfunction section(sec: CompositionSection): FhirComplex {\n return complex([\n prop(\"title\", str(sec.title)),\n prop(\"code\", codeableConcept({ system: SYSTEM.LOINC, code: sec.code, display: sec.title })),\n prop(\"entry\", list(sec.entries.map((e) => reference(e)))),\n ]);\n}\n\n/**\n * Build a spec-clean synthetic base-R4 `Composition` for a `document` Bundle, through `@cosyte/fhir`.\n *\n * @param rng - The seeded generator (for the resource id).\n * @param input - Subject/organization references, date, and sections. See {@link BuildCompositionInput}.\n * @returns The `Composition` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { createRng } from \"@cosyte/synth\";\n * import { buildComposition } from \"@cosyte/synth/fhir\";\n * // buildComposition(createRng(1), { subject, organization, date: \"2020-01-01\", sections: [] });\n * ```\n */\nexport function buildComposition(rng: Rng, input: BuildCompositionInput): FhirComplex {\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Composition\")),\n prop(\"id\", str(`syn-comp-${rng.digits(8)}`)),\n prop(\"text\", narrative(\"Synthetic continuity-of-care document summary.\")),\n prop(\"status\", str(\"final\")),\n prop(\n \"type\",\n codeableConcept({\n system: SYSTEM.LOINC,\n code: \"34133-9\",\n display: \"Summarization of Episode Note\",\n }),\n ),\n prop(\"subject\", reference(input.subject)),\n prop(\"date\", str(`${input.date}T09:00:00Z`)),\n prop(\"author\", list([reference(input.organization)])),\n prop(\"title\", str(\"Synthetic Continuity of Care Document\")),\n prop(\"custodian\", reference(input.organization)),\n prop(\"section\", list(input.sections.map((s) => section(s)))),\n ];\n return complex(props);\n}\n","/**\n * The **round-trip-through-the-parser harness** for FHIR: the headline gate for the synthetic-fixture\n * generator. A generated resource is \"spec-clean\" only if `@cosyte/fhir`, not\n * `@cosyte/synth`'s own opinion, reads it back, validates it, and re-serializes it byte-identically.\n * This harness serializes a generated resource, parses it back, validates it (optionally against\n * supplied US Core / vendor `StructureDefinition`s), and re-serializes, reporting what the parser found\n * so a false \"spec-clean\" claim cannot hide.\n *\n * `@cosyte/synth` bundles **no** profile content: to validate US Core conformance, a caller supplies\n * the `StructureDefinition`s via {@link RoundTripOptions.profiles}, exactly the content-free posture of\n * `@cosyte/fhir.validateResource({ profiles })`.\n *\n * @module\n */\n\nimport { parseResource, serializeResource, validateResource } from \"@cosyte/fhir\";\nimport type { FhirComplex, StructureDefinition } from \"@cosyte/fhir\";\n\n/** Options for {@link roundTrip}. */\nexport interface RoundTripOptions {\n /**\n * US Core / vendor profiles (`StructureDefinition`s) to validate against. **None is bundled**: a\n * caller supplies them (BYO), matching `@cosyte/fhir`'s content-free posture.\n */\n readonly profiles?: readonly StructureDefinition[];\n}\n\n/** The verdict of one round-trip through `@cosyte/fhir`. */\nexport interface RoundTripResult {\n /** The serialized FHIR JSON text (the parser's own conservative emit). */\n readonly content: string;\n /**\n * The validation issue codes at `error`/`fatal` severity (empty ⇒ valid). `information`/`warning`\n * findings (e.g. `MUST_SUPPORT_ABSENT`, `INVARIANT_UNCHECKED`, base `dom-6`) are advisory and are\n * excluded here: they never make a resource invalid.\n */\n readonly errors: readonly string[];\n /** All non-informational issue codes (errors **and** warnings), for the `Corpus` artifact record. */\n readonly warnings: readonly string[];\n /** Whether re-serializing the re-parsed resource is byte-identical to `content`. */\n readonly byteStable: boolean;\n /** Whether `@cosyte/fhir.validateResource` reported no `error`/`fatal` findings. */\n readonly valid: boolean;\n /** `true` iff the artifact is spec-clean: **valid** (zero errors) **and** byte-stable. */\n readonly specClean: boolean;\n}\n\n/**\n * Round-trip a generated FHIR resource through serialize → parse → validate → serialize and report the\n * verdict. A spec-clean artifact validates with **zero errors** and re-serializes byte-identically.\n *\n * @param resource - The resource model to check (typically from a `generate*` function).\n * @param options - Optional US Core / vendor profiles to validate against. See {@link RoundTripOptions}.\n * @returns The {@link RoundTripResult}.\n * @example\n * ```ts\n * import { generatePatient, roundTrip } from \"@cosyte/synth/fhir\";\n * const { specClean, errors } = roundTrip(generatePatient({ seed: 1 }));\n * // specClean === true, errors.length === 0\n * ```\n */\nexport function roundTrip(resource: FhirComplex, options: RoundTripOptions = {}): RoundTripResult {\n const content = serializeResource(resource);\n const { resource: reparsed } = parseResource(content);\n const byteStable = serializeResource(reparsed) === content;\n const result = validateResource(\n reparsed,\n options.profiles !== undefined\n ? { mode: \"strict\", profiles: options.profiles }\n : { mode: \"strict\" },\n );\n const errors = result.issues\n .filter((i) => i.severity === \"error\" || i.severity === \"fatal\")\n .map((i) => i.code);\n const warnings = result.issues\n .filter((i) => i.severity === \"error\" || i.severity === \"fatal\" || i.severity === \"warning\")\n .map((i) => i.code);\n const valid = result.valid;\n return { content, errors, warnings, byteStable, valid, specClean: valid && byteStable };\n}\n","/**\n * Synthetic FHIR R4 **`Bundle`** generation: a self-contained `collection`,\n * `transaction`, or `document` Bundle assembling a synthetic US Core `Patient` and its full clinical\n * spine (`Condition`, lab + vital-sign `Observation`s, `MedicationRequest`, `Encounter`,\n * `Immunization`, `AllergyIntolerance`, `Procedure`, `DiagnosticReport`), wired by `urn:uuid:`\n * `fullUrl`s so every intra-bundle reference resolves. Built through `@cosyte/fhir`. The `document`\n * shape prepends the FHIR-mandated `Composition` (invariant `bdl-11`) and a synthetic\n * `Organization` author/custodian, and carries the required `identifier` + `timestamp` (`bdl-9`/`bdl-10`).\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng, type Rng } from \"../rng/rng.js\";\nimport { makeCorpus, type Corpus } from \"../corpus.js\";\nimport { bool, narrative, prop, str, toFhirDate, type Prop } from \"./builder.js\";\nimport { buildComposition, type CompositionSection } from \"./composition.js\";\nimport { generatePatient } from \"./patient.js\";\nimport { generateCondition } from \"./condition.js\";\nimport { generateObservationLab, generateVitalSign } from \"./observation.js\";\nimport { generateMedicationRequest } from \"./medication-request.js\";\nimport { generateEncounter } from \"./encounter.js\";\nimport { generateImmunization } from \"./immunization.js\";\nimport { generateAllergyIntolerance } from \"./allergy-intolerance.js\";\nimport { generateProcedure } from \"./procedure.js\";\nimport { generateDiagnosticReport } from \"./diagnostic-report.js\";\nimport { roundTrip } from \"./round-trip.js\";\nimport { safe } from \"../safe/index.js\";\nimport { resolveKind, resolveMix } from \"../select.js\";\n\n/** The Bundle shapes `@cosyte/synth` supports. */\nexport type FhirBundleType = \"collection\" | \"transaction\" | \"document\";\n\n/** Every value {@link FhirBundleType} admits. Erased at run time, so it is resolved, not trusted. */\nconst BUNDLE_TYPES: readonly FhirBundleType[] = Object.freeze([\n \"collection\",\n \"transaction\",\n \"document\",\n]);\n\n/** Options for {@link generateBundle}. */\nexport interface GenerateBundleOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The Bundle shape. Defaults to `\"collection\"`. */\n readonly type?: FhirBundleType;\n}\n\n/** The `resourceType` string of a generated resource (its `request.url` in a transaction Bundle). */\nfunction resourceTypeOf(resource: FhirComplex): string {\n const rt = resource.properties.find((p) => p.name === \"resourceType\");\n return rt !== undefined && rt.value.kind === \"primitive\" ? String(rt.value.value) : \"Resource\";\n}\n\n/** A minimal synthetic `Organization` (author/custodian), no PHI, name is clearly synthetic. */\nfunction buildOrganization(rng: Rng): FhirComplex {\n const id = safe.identifier(rng, \"AN\");\n return complex([\n prop(\"resourceType\", str(\"Organization\")),\n prop(\"id\", str(`syn-org-${rng.digits(8)}`)),\n prop(\"text\", narrative(\"Synthetic health organization.\")),\n prop(\n \"identifier\",\n list([\n complex([\n prop(\"system\", str(`urn:oid:${id.assigningAuthorityOid}`)),\n prop(\"value\", str(id.value)),\n ]),\n ]),\n ),\n prop(\"active\", bool(true)),\n prop(\"name\", str(\"Synthetic Health Organization\")),\n ]);\n}\n\n/** One assembled spine member: its stable in-bundle `urn:uuid:` fullUrl and its resource model. */\ninterface SpineEntry {\n readonly fullUrl: string;\n readonly resource: FhirComplex;\n}\n\n/** The assembled clinical spine plus the shared patient / organization fullUrls a document references. */\ninterface Spine {\n readonly patientUrl: string;\n readonly orgUrl: string;\n readonly date: string;\n /** Per-kind fullUrls, for the document Composition's section entries. */\n readonly urls: Readonly<Record<string, string>>;\n /** The clinical entries (Patient first, then Organization, then the clinical resources). */\n readonly entries: readonly SpineEntry[];\n}\n\n/** Build the shared clinical spine: every reference wired to an in-bundle `urn:uuid:` fullUrl. */\nfunction buildSpine(rng: Rng): Spine {\n const patientUrl = `urn:uuid:${safe.uuid(rng)}`;\n const orgUrl = `urn:uuid:${safe.uuid(rng)}`;\n const date = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const patient: SpineEntry = {\n fullUrl: patientUrl,\n resource: generatePatient({ seed: rng.nextUint32(), profile: \"us-core\" }),\n };\n const org: SpineEntry = { fullUrl: orgUrl, resource: buildOrganization(rng) };\n\n const condUrl = `urn:uuid:${safe.uuid(rng)}`;\n const cond = generateCondition({ seed: rng.nextUint32(), subject: patientUrl });\n const labUrl = `urn:uuid:${safe.uuid(rng)}`;\n const lab = generateObservationLab({ seed: rng.nextUint32(), subject: patientUrl });\n const vitalUrl = `urn:uuid:${safe.uuid(rng)}`;\n const vital = generateVitalSign({ seed: rng.nextUint32(), subject: patientUrl });\n const medUrl = `urn:uuid:${safe.uuid(rng)}`;\n const med = generateMedicationRequest({\n seed: rng.nextUint32(),\n subject: patientUrl,\n requester: orgUrl,\n });\n const encUrl = `urn:uuid:${safe.uuid(rng)}`;\n const enc = generateEncounter({ seed: rng.nextUint32(), subject: patientUrl });\n const immUrl = `urn:uuid:${safe.uuid(rng)}`;\n const imm = generateImmunization({ seed: rng.nextUint32(), patient: patientUrl });\n const allergyUrl = `urn:uuid:${safe.uuid(rng)}`;\n const allergy = generateAllergyIntolerance({ seed: rng.nextUint32(), patient: patientUrl });\n const procUrl = `urn:uuid:${safe.uuid(rng)}`;\n const proc = generateProcedure({ seed: rng.nextUint32(), subject: patientUrl });\n const drUrl = `urn:uuid:${safe.uuid(rng)}`;\n const dr = generateDiagnosticReport({\n seed: rng.nextUint32(),\n subject: patientUrl,\n results: [labUrl],\n });\n\n const entries: SpineEntry[] = [\n patient,\n org,\n { fullUrl: condUrl, resource: cond },\n { fullUrl: labUrl, resource: lab },\n { fullUrl: vitalUrl, resource: vital },\n { fullUrl: medUrl, resource: med },\n { fullUrl: encUrl, resource: enc },\n { fullUrl: immUrl, resource: imm },\n { fullUrl: allergyUrl, resource: allergy },\n { fullUrl: procUrl, resource: proc },\n { fullUrl: drUrl, resource: dr },\n ];\n const urls = {\n condition: condUrl,\n lab: labUrl,\n vital: vitalUrl,\n medication: medUrl,\n encounter: encUrl,\n immunization: immUrl,\n allergy: allergyUrl,\n procedure: procUrl,\n diagnosticReport: drUrl,\n };\n return { patientUrl, orgUrl, date, urls, entries };\n}\n\n/** The document sections summarizing the clinical spine (LOINC section codes → entry references). */\nfunction documentSections(urls: Readonly<Record<string, string>>): CompositionSection[] {\n const at = (k: string): string[] => (urls[k] !== undefined ? [urls[k]] : []);\n return [\n { code: \"11450-4\", title: \"Problem List\", entries: at(\"condition\") },\n {\n code: \"30954-2\",\n title: \"Relevant Diagnostic Tests/Laboratory Data\",\n entries: [...at(\"diagnosticReport\"), ...at(\"lab\"), ...at(\"vital\")],\n },\n { code: \"10160-0\", title: \"History of Medication Use\", entries: at(\"medication\") },\n { code: \"48765-2\", title: \"Allergies and Adverse Reactions\", entries: at(\"allergy\") },\n { code: \"11369-6\", title: \"History of Immunizations\", entries: at(\"immunization\") },\n { code: \"47519-4\", title: \"History of Procedures\", entries: at(\"procedure\") },\n { code: \"46240-8\", title: \"History of Encounters\", entries: at(\"encounter\") },\n ];\n}\n\n/**\n * Generate a spec-clean synthetic FHIR `Bundle` (`collection`, `transaction`, or `document`) built\n * through `@cosyte/fhir`, containing a US Core `Patient` and its full clinical spine wired by\n * `urn:uuid:` references so every reference resolves in-bundle.\n *\n * @param options - Seed and Bundle shape. See {@link GenerateBundleOptions}.\n * @returns The `Bundle` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateBundle } from \"@cosyte/synth/fhir\";\n * const bundle = generateBundle({ seed: 42, type: \"document\" });\n * ```\n */\nexport function generateBundle(options: GenerateBundleOptions = {}): FhirComplex {\n const { seed = 0 } = options;\n const type = resolveKind(BUNDLE_TYPES, options.type ?? \"collection\");\n const rng = createRng(seed);\n const spine = buildSpine(rng);\n\n const members: SpineEntry[] =\n type === \"document\"\n ? [\n {\n fullUrl: `urn:uuid:${safe.uuid(rng)}`,\n resource: buildComposition(rng, {\n subject: spine.patientUrl,\n organization: spine.orgUrl,\n date: spine.date,\n sections: documentSections(spine.urls),\n }),\n },\n ...spine.entries,\n ]\n : [...spine.entries];\n\n const entries = members.map((member) => {\n const entryProps: Prop[] = [\n prop(\"fullUrl\", str(member.fullUrl)),\n prop(\"resource\", member.resource),\n ];\n // A document Bundle forbids entry.request/response (bdl-3a); a transaction requires request.\n if (type === \"transaction\") {\n entryProps.push(\n prop(\n \"request\",\n complex([prop(\"method\", str(\"POST\")), prop(\"url\", str(resourceTypeOf(member.resource)))]),\n ),\n );\n }\n return complex(entryProps);\n });\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Bundle\")),\n prop(\"id\", str(`syn-bundle-${rng.digits(8)}`)),\n ];\n // A document Bundle requires an identifier (bdl-9) and a timestamp (bdl-10).\n if (type === \"document\") {\n const id = safe.identifier(rng, \"AN\");\n props.push(\n prop(\n \"identifier\",\n complex([\n prop(\"system\", str(`urn:oid:${id.assigningAuthorityOid}`)),\n prop(\"value\", str(`urn:uuid:${safe.uuid(rng)}`)),\n ]),\n ),\n );\n }\n props.push(prop(\"type\", str(type)));\n if (type === \"document\") props.push(prop(\"timestamp\", str(`${spine.date}T09:00:00.000Z`)));\n props.push(prop(\"entry\", list(entries)));\n\n return complex(props);\n}\n\n/** A FHIR resource kind the {@link fhirCorpus} can generate. */\nexport type FhirResourceKind =\n | \"Patient\"\n | \"USCorePatient\"\n | \"Condition\"\n | \"ObservationLab\"\n | \"VitalSign\"\n | \"MedicationRequest\"\n | \"Encounter\"\n | \"Immunization\"\n | \"AllergyIntolerance\"\n | \"Procedure\"\n | \"DiagnosticReport\"\n | \"Bundle\"\n | \"DocumentBundle\";\n\n/** Every value {@link FhirResourceKind} admits. Erased at run time, so a mix entry is resolved. */\nconst ALL_KINDS: readonly FhirResourceKind[] = Object.freeze([\n \"Patient\",\n \"USCorePatient\",\n \"Condition\",\n \"ObservationLab\",\n \"VitalSign\",\n \"MedicationRequest\",\n \"Encounter\",\n \"Immunization\",\n \"AllergyIntolerance\",\n \"Procedure\",\n \"DiagnosticReport\",\n \"Bundle\",\n \"DocumentBundle\",\n]);\n\n/** The default corpus mix: the full US Core clinical spine plus a collection Bundle. */\nconst DEFAULT_MIX: readonly FhirResourceKind[] = Object.freeze([\n \"USCorePatient\",\n \"Condition\",\n \"ObservationLab\",\n \"VitalSign\",\n \"MedicationRequest\",\n \"Encounter\",\n \"Immunization\",\n \"AllergyIntolerance\",\n \"Procedure\",\n \"DiagnosticReport\",\n \"Bundle\",\n]);\n\n/** Generate one resource of the given kind from a seed. */\nfunction generateKind(kind: FhirResourceKind, seed: number): FhirComplex {\n switch (kind) {\n case \"Patient\":\n return generatePatient({ seed, profile: \"base\" });\n case \"USCorePatient\":\n return generatePatient({ seed, profile: \"us-core\" });\n case \"Condition\":\n return generateCondition({ seed });\n case \"ObservationLab\":\n return generateObservationLab({ seed });\n case \"VitalSign\":\n return generateVitalSign({ seed });\n case \"MedicationRequest\":\n return generateMedicationRequest({ seed });\n case \"Encounter\":\n return generateEncounter({ seed });\n case \"Immunization\":\n return generateImmunization({ seed });\n case \"AllergyIntolerance\":\n return generateAllergyIntolerance({ seed });\n case \"Procedure\":\n return generateProcedure({ seed });\n case \"DiagnosticReport\":\n return generateDiagnosticReport({ seed });\n case \"Bundle\":\n return generateBundle({ seed });\n case \"DocumentBundle\":\n return generateBundle({ seed, type: \"document\" });\n }\n}\n\n/** Options for {@link fhirCorpus}. */\nexport interface FhirCorpusOptions {\n /** The seed for the whole corpus (deterministic). */\n readonly seed: number;\n /** How many resources to generate. Defaults to `1`. */\n readonly count?: number;\n /** The resource kinds to cycle through. Defaults to the full US Core clinical spine + a Bundle. */\n readonly mix?: readonly FhirResourceKind[];\n}\n\n/**\n * Build a reproducible {@link Corpus} of spec-clean FHIR resources across the supported kinds. Each\n * resource is generated from a distinct sub-seed derived from the corpus seed and round-tripped through\n * `@cosyte/fhir`; the per-artifact `warnings` record the validator's non-informational findings (empty\n * ⇒ spec-clean, no US Core profiles supplied). Pass US Core `StructureDefinition`s to a per-resource\n * {@link roundTrip} call to additionally assert profile conformance (BYO, none is bundled).\n *\n * @param options - Seed, count, and the resource mix. See {@link FhirCorpusOptions}.\n * @returns A deep-frozen {@link Corpus}.\n * @example\n * ```ts\n * import { fhirCorpus } from \"@cosyte/synth/fhir\";\n * const corpus = fhirCorpus({ seed: 42, count: 6 });\n * corpus.artifacts.every((a) => a.warnings.length === 0); // spec-clean (structural)\n * ```\n */\nexport function fhirCorpus(options: FhirCorpusOptions): Corpus {\n const { seed, count = 1 } = options;\n const kinds = resolveMix(ALL_KINDS, options.mix, DEFAULT_MIX);\n const seedStream = createRng(seed);\n const artifacts = Array.from({ length: count }, (_unused, i) => {\n const kind = kinds[i % kinds.length] ?? \"USCorePatient\";\n const rt = roundTrip(generateKind(kind, seedStream.nextUint32()));\n // The artifact records the findings that break spec-cleanliness: validator **errors** (empty ⇒\n // spec-clean). Advisory warnings a legal resource may carry (e.g. `REFERENCE_UNRESOLVED` on a\n // collection Bundle's external reference, or the base `dom-6` narrative best-practice) are not\n // spec-cleanliness violations and are excluded here; a caller wanting the full picture calls\n // `roundTrip` directly (it exposes both `errors` and `warnings`).\n return { format: \"fhir\" as const, kind, content: rt.content, warnings: rt.errors };\n });\n return makeCorpus(seed, artifacts);\n}\n"]}
1
+ {"version":3,"sources":["../../src/rng/splitmix32.ts","../../src/rng/sfc32.ts","../../src/codes.ts","../../src/rng/rng.ts","../../src/safe/reserved.ts","../../src/safe/names-pool.ts","../../src/safe/providers.ts","../../src/safe/index.ts","../../src/fhir/us-core.ts","../../src/fhir/builder.ts","../../src/fhir/example-codes.ts","../../src/select.ts","../../src/fhir/patient.ts","../../src/fhir/condition.ts","../../src/fhir/observation.ts","../../src/fhir/medication-request.ts","../../src/fhir/encounter.ts","../../src/fhir/immunization.ts","../../src/fhir/allergy-intolerance.ts","../../src/fhir/procedure.ts","../../src/fhir/provenance.ts","../../src/fhir/diagnostic-report.ts","../../src/corpus.ts","../../src/fhir/composition.ts","../../src/fhir/round-trip.ts","../../src/fhir/bundle.ts","../../src/fhir/coverage.ts"],"names":["name","address","phone","email","complex","list"],"mappings":";;;;;AA0BO,SAAS,WAAW,IAAA,EAA4B;AACrD,EAAA,IAAI,IAAI,IAAA,GAAO,CAAA;AACf,EAAA,OAAO,SAAS,IAAA,GAAe;AAC7B,IAAA,CAAA,GAAK,IAAI,UAAA,GAAc,CAAA;AACvB,IAAA,IAAI,CAAA,GAAI,IAAK,CAAA,KAAM,EAAA;AACnB,IAAA,CAAA,GAAI,IAAA,CAAK,IAAA,CAAK,CAAA,EAAG,SAAU,CAAA;AAC3B,IAAA,CAAA,GAAI,IAAK,CAAA,KAAM,EAAA;AACf,IAAA,CAAA,GAAI,IAAA,CAAK,IAAA,CAAK,CAAA,EAAG,UAAU,CAAA;AAC3B,IAAA,CAAA,GAAI,IAAK,CAAA,KAAM,EAAA;AACf,IAAA,OAAO,CAAA,KAAM,CAAA;AAAA,EACf,CAAA;AACF;;;ACOO,SAAS,UAAU,CAAA,EAAuB;AAC/C,EAAA,CAAA,CAAE,CAAA,IAAK,CAAA;AACP,EAAA,CAAA,CAAE,CAAA,IAAK,CAAA;AACP,EAAA,CAAA,CAAE,CAAA,IAAK,CAAA;AACP,EAAA,CAAA,CAAE,CAAA,IAAK,CAAA;AACP,EAAA,MAAM,KAAO,CAAA,CAAE,CAAA,GAAI,EAAE,CAAA,GAAK,CAAA,IAAK,EAAE,CAAA,GAAK,CAAA;AACtC,EAAA,CAAA,CAAE,CAAA,GAAK,CAAA,CAAE,CAAA,GAAI,CAAA,GAAK,CAAA;AAClB,EAAA,CAAA,CAAE,C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A,EACjF,qBAAqB,CAAC,IAAA,KAAiB,iBAAA,CAAkB,EAAE,MAAM,CAAA;AAAA,EACjE,sBAAsB,CAAC,IAAA,KAAiB,kBAAA,CAAmB,EAAE,MAAM,CAAA;AAAA,EACnE,uBAAuB,CAAC,IAAA,KAAiB,iBAAA,CAAkB,EAAE,MAAM;AACrE,CAAC,CAAA;AAaH,IAAM,WAA6C,MAAA,CAAO,MAAA;AAAA,EACxD,wBAAA,CAAyB,GAAA;AAAA,IAAI,CAAC,OAAA,KAC5B,MAAA,CAAO,MAAA,CAAO;AAAA,MACZ,OAAA;AAAA,MACA,SAAA,EAAW,CAAA,EAAG,oBAAoB,CAAA,EAAG,OAAO,CAAA,CAAA;AAAA,MAC5C,SAAA,EAAW,UAAA,CAAW,OAAO,CAAA,KAAM;AAAA,KACpC;AAAA;AAEL,CAAA;AAgBO,SAAS,cAAA,GAAmD;AACjE,EAAA,OAAO,QAAA;AACT;AA2BO,SAAS,sBAAsB,OAAA,EAAoD;AACxF,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,wBAAA,EAA0B,OAAA,CAAQ,OAAO,CAAA;AACrE,EAAA,MAAM,QAAA,GAAW,WAAW,OAAO,CAAA;AACnC,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,MAAM,IAAI,UAAA,CAAW,iBAAA,CAAkB,2BAA2B,CAAA;AAAA,EACpE;AACA,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,IAAA,IAAQ,CAAC,CAAA;AACnC","file":"index.mjs","sourcesContent":["/**\n * `splitmix32`: a tiny, well-studied 32-bit mixing PRNG used **only** to expand a single integer\n * seed into the four 32-bit state words that seed {@link ../rng/sfc32.sfc32}. It is not the corpus\n * generator itself (that is `sfc32`); it exists so that a one-number seed deterministically produces a\n * well-distributed 128-bit `sfc32` state, avoiding the poor low-bit behavior of naive\n * `state = seed`-style initialization.\n *\n * Zero-dependency, `Math.random`-free (lint-enforced): the whole point of the library is that a seed,\n * and only the seed, determines the output, on any machine, any run.\n *\n * @module\n */\n\n/**\n * A stateful `splitmix32` step function. Each call advances the internal 32-bit state and returns the\n * next unsigned 32-bit integer. Deterministic for a given seed.\n *\n * @param seed - The 32-bit seed. Coerced to a 32-bit integer via `| 0`.\n * @returns A nullary function returning the next `uint32` in the stream.\n * @example\n * ```ts\n * import { splitmix32 } from \"@cosyte/synth\";\n * const next = splitmix32(12345);\n * const a = next(); // deterministic uint32\n * ```\n */\nexport function splitmix32(seed: number): () => number {\n let a = seed | 0;\n return function next(): number {\n a = (a + 0x9e3779b9) | 0;\n let t = a ^ (a >>> 16);\n t = Math.imul(t, 0x21f0aaad);\n t = t ^ (t >>> 15);\n t = Math.imul(t, 0x735a2d97);\n t = t ^ (t >>> 15);\n return t >>> 0;\n };\n}\n","/**\n * `sfc32` (Small Fast Counter, 32-bit, 128-bit state): the deterministic, non-cryptographic PRNG that\n * drives every value `@cosyte/synth` generates. Chosen over `mulberry32` (whose author flags that it\n * skips ~1/3 of 32-bit outputs) and over a CSPRNG (`node:crypto`, which is **not seedable** and would\n * defeat reproducibility). A synthetic-fixture generator has **no secrets**: statistical quality plus\n * byte-for-byte reproducibility is exactly the right trade.\n *\n * The state is four 32-bit words. This module exposes the raw step function; {@link ../rng/rng.Rng}\n * wraps it with a seed-expansion ({@link ./splitmix32.splitmix32}) and the ergonomic draw helpers.\n *\n * @module\n */\n\n/**\n * The mutable four-word `sfc32` state. Threaded explicitly (never global) by {@link ../rng/rng.Rng}.\n */\nexport interface Sfc32State {\n /** State word `a`. */\n a: number;\n /** State word `b`. */\n b: number;\n /** State word `c`. */\n c: number;\n /** Counter word `d`. */\n d: number;\n}\n\n/**\n * Advance an {@link Sfc32State} in place by one step and return the next unsigned 32-bit integer.\n *\n * This is the canonical `sfc32` step. The state object is mutated (the counter `d` increments and the\n * mixing words rotate); callers that need reproducible independence hold their own state and never\n * share it: {@link ../rng/rng.Rng} creates a fresh state per seed so two runs from the same seed are\n * identical.\n *\n * @param s - The state to advance. Mutated in place.\n * @returns The next `uint32` in the stream.\n * @example\n * ```ts\n * import { sfc32Next, type Sfc32State } from \"@cosyte/synth\";\n * const s: Sfc32State = { a: 1, b: 2, c: 3, d: 4 };\n * const x = sfc32Next(s); // uint32\n * ```\n */\nexport function sfc32Next(s: Sfc32State): number {\n s.a |= 0;\n s.b |= 0;\n s.c |= 0;\n s.d |= 0;\n const t = (((s.a + s.b) | 0) + s.d) | 0;\n s.d = (s.d + 1) | 0;\n s.a = s.b ^ (s.b >>> 9);\n s.b = (s.c + (s.c << 3)) | 0;\n s.c = (s.c << 21) | (s.c >>> 11);\n s.c = (s.c + t) | 0;\n return t >>> 0;\n}\n","/**\n * Stable diagnostic codes for `@cosyte/synth` and the {@link SynthError} they travel on.\n *\n * Unlike a parser (which recovers from bad *input* into Tier-2 warnings), a **generator** has no input\n * to tolerate: its reflex is *synthetic-by-construction* and *fail-closed on impossibility*. So the\n * codes here are **fatal**: a caller asked for something the library cannot honor spec-clean, and the\n * only safe answer is to throw, never to silently fabricate a value or a byte workaround. Codes are `key ===\n * value` and part of the public contract:\n * renaming one is a breaking change.\n *\n * @module\n */\n\n/**\n * The stable **fatal** code registry. Additions-only thereafter.\n *\n * @example\n * ```ts\n * import { SYNTH_FATAL_CODES, SynthError } from \"@cosyte/synth\";\n * try {\n * // ...generate...\n * } catch (err) {\n * if (err instanceof SynthError && err.code === SYNTH_FATAL_CODES.SYNTH_UNSUPPORTED_FORMAT) {\n * // handle an unsupported format request\n * }\n * }\n * ```\n */\nexport const SYNTH_FATAL_CODES = {\n /**\n * A format was requested that this build cannot generate through a real parser builder/serializer.\n * Fatal, never a hand-written byte fallback.\n *\n * **No code path in this build raises it.** All six formats generate, so it is reserved for a\n * future format that does not, and is kept because removing a published code is a breaking change.\n * An unsupported *kind* within a format that does generate is `SYNTH_UNSUPPORTED_KIND`.\n */\n SYNTH_UNSUPPORTED_FORMAT: \"SYNTH_UNSUPPORTED_FORMAT\",\n /**\n * A vendor quirk was requested that the target format's profile system does not support. Fatal,\n * never a silent no-op and never a fabricated quirk.\n */\n SYNTH_UNSUPPORTED_QUIRK: \"SYNTH_UNSUPPORTED_QUIRK\",\n /**\n * A quirk transform found no structural anchor to mutate, so the fixture would not carry the\n * deviation it is labelled with. Fatal: a golden file that lies about its parser verdict is worse\n * than no golden file.\n */\n SYNTH_QUIRK_ANCHOR_ABSENT: \"SYNTH_QUIRK_ANCHOR_ABSENT\",\n /**\n * A bare parse of a freshly-generated quirk artifact did not produce exactly the declared intended\n * warning code(s). Fatal, never emit a mislabeled fixture.\n */\n SYNTH_INTENDED_WARNING_MISMATCH: \"SYNTH_INTENDED_WARNING_MISMATCH\",\n /** A concept's code-system URI has no OID mapping in the C-CDA example-code table. Fatal. */\n SYNTH_UNMAPPED_CODE_SYSTEM: \"SYNTH_UNMAPPED_CODE_SYSTEM\",\n /** A money value could not be read as an X12 decimal. Fatal: a generator never rounds to a float. */\n SYNTH_INVALID_DECIMAL: \"SYNTH_INVALID_DECIMAL\",\n /** An integer range was requested with its maximum below its minimum. Fatal. */\n SYNTH_INVALID_RANGE: \"SYNTH_INVALID_RANGE\",\n /** A value was drawn from an empty pool. Fatal, never a fabricated substitute. */\n SYNTH_EMPTY_POOL: \"SYNTH_EMPTY_POOL\",\n /** A `defineSynthProfile` spec was not usable (a missing or blank `name`). Fatal. */\n SYNTH_INVALID_PROFILE: \"SYNTH_INVALID_PROFILE\",\n /**\n * A caller-supplied selector (a message kind, a document type, a corpus mix entry, a claim\n * variant, a Bundle type, a resource profile) is not in the closed set that governs it. Fatal:\n * see `resolveKind`: a selector union is erased at run time, and a selector that falls through\n * either mislabels the fixture or hands the value to a peer builder that quotes it back.\n */\n SYNTH_UNSUPPORTED_KIND: \"SYNTH_UNSUPPORTED_KIND\",\n /**\n * A requested profile IS published by the adopted implementation guide, and this build does not\n * generate it. Deliberately distinct from `SYNTH_UNSUPPORTED_KIND`, which says the name is not in\n * the adopted set at all: \"the guide does not publish this\" and \"we do not generate this yet\" are\n * different answers, and a caller building to a regulatory profile set has to be able to tell them\n * apart without matching message text. Fatal, and raised **before** anything is generated: a\n * mislabelled artifact is worse than no artifact.\n */\n SYNTH_PROFILE_NOT_GENERATED: \"SYNTH_PROFILE_NOT_GENERATED\",\n} as const;\n\n/**\n * A value from {@link SYNTH_FATAL_CODES}: the type carried by a thrown {@link SynthError}.\n */\nexport type SynthFatalCode = (typeof SYNTH_FATAL_CODES)[keyof typeof SYNTH_FATAL_CODES];\n\n/**\n * The **frozen message registry**: the only place a {@link SynthError} message can come from.\n *\n * A message here is a fixed string. It never quotes the request that produced it, and there is no\n * parameter through which it could: {@link SynthError} takes a code and nothing else. That is the\n * whole mechanism, and it is deliberately a mechanism rather than a habit. Every one of these\n * messages used to be assembled by interpolating the caller's value into a template, and the reason\n * that was safe was not the design: it was that the caller happened to be passing a quirk name.\n *\n * The trade is real and is accepted: a fatal no longer tells you *which* value it rejected. It tells\n * you which rule refused, on `err.code`, and the stack frame tells you where. The caller already\n * holds the value it passed.\n *\n * @example\n * ```ts\n * import { SYNTH_FATAL_CODES, SYNTH_FATAL_MESSAGES } from \"@cosyte/synth\";\n * SYNTH_FATAL_MESSAGES[SYNTH_FATAL_CODES.SYNTH_EMPTY_POOL]; // => \"A value was drawn from an empty pool.\"\n * ```\n */\nexport const SYNTH_FATAL_MESSAGES: Readonly<Record<SynthFatalCode, string>> = Object.freeze({\n SYNTH_UNSUPPORTED_FORMAT:\n \"The requested format is not generable by this build. A generator has no byte fallback: it \" +\n \"builds through a parser's own serializer or it refuses.\",\n SYNTH_UNSUPPORTED_QUIRK:\n \"The requested vendor quirk is not in the target format's quirk registry. Compare the request \" +\n \"against that format's exported registry (HL7_QUIRKS, CCDA_QUIRKS, ASTM_QUIRKS).\",\n SYNTH_QUIRK_ANCHOR_ABSENT:\n \"The quirk transform found no structural anchor to mutate, so the fixture would not carry the \" +\n \"deviation it is labelled with. Refusing to emit a mislabeled fixture.\",\n SYNTH_INTENDED_WARNING_MISMATCH:\n \"A bare parse of the generated quirk artifact did not produce exactly the declared intended \" +\n \"warning code(s). Refusing to emit a mislabeled fixture.\",\n SYNTH_UNMAPPED_CODE_SYSTEM:\n \"The concept's code-system URI has no OID mapping in the C-CDA example-code table.\",\n SYNTH_INVALID_DECIMAL: \"The value could not be read as an X12 decimal.\",\n SYNTH_INVALID_RANGE: \"An integer range was requested with its maximum below its minimum.\",\n SYNTH_EMPTY_POOL: \"A value was drawn from an empty pool.\",\n SYNTH_INVALID_PROFILE: \"defineSynthProfile requires a non-empty string name.\",\n SYNTH_UNSUPPORTED_KIND:\n \"The requested kind, document type, corpus mix entry, variant or profile is not one this \" +\n \"generator supports. The supported set is the exported union for that option.\",\n SYNTH_PROFILE_NOT_GENERATED:\n \"The requested profile is published by the adopted implementation guide, and this build does \" +\n \"not generate it. The coverage surface reports, per adopted profile, whether it is generated.\",\n});\n\n/**\n * The typed error every fatal `@cosyte/synth` condition throws. Carries a stable\n * {@link SynthFatalCode} so callers branch on `err.code` without matching message text.\n *\n * It takes **no value parameter**. The message is whatever {@link SYNTH_FATAL_MESSAGES} holds for the\n * code, so no caller-supplied string can reach a diagnostic surface by any route, not `message`, not\n * `stack`, not a field on the thrown object.\n *\n * @example\n * ```ts\n * import { SynthError, SYNTH_FATAL_CODES } from \"@cosyte/synth\";\n * throw new SynthError(SYNTH_FATAL_CODES.SYNTH_UNSUPPORTED_FORMAT);\n * ```\n */\nexport class SynthError extends Error {\n /** The stable fatal code. */\n public readonly code: SynthFatalCode;\n\n /**\n * @param code - The stable {@link SynthFatalCode}. The message comes from the frozen registry.\n */\n public constructor(code: SynthFatalCode) {\n super(SYNTH_FATAL_MESSAGES[code]);\n this.name = \"SynthError\";\n this.code = code;\n }\n}\n","/**\n * `Rng`: the seeded, deterministic random source every `@cosyte/synth` provider draws from.\n *\n * **The reproducibility contract.** A seed, and only the seed, determines the output.\n * `createRng(seed)` expands the integer seed through {@link ./splitmix32.splitmix32} into the four\n * `sfc32` state words, then every draw advances that state via {@link ./sfc32.sfc32Next}. Two `Rng`s\n * created from the same seed emit the **identical** sequence on any machine, any run: the property\n * the parsers', `transform`'s, and `deid`'s regression suites depend on.\n *\n * **Explicit, never global.** An `Rng` is a value you thread through a build; there is no ambient\n * shared generator and **`Math.random` is lint-banned** in `src/` (it is not seedable: its seed is\n * engine-chosen and cannot be reset, so a corpus built on it is not reproducible). Because each\n * generation creates a fresh `Rng` from its seed, generations are independent and parallel-safe.\n *\n * The `Rng` object is stateful by nature (a PRNG advances). Immutability in this library lives where it\n * is testable and matters: the generated **artifacts and the `Corpus` are deep-frozen** (see\n * `../corpus.ts`). Determinism, not object-immutability, is the `Rng`'s guarantee.\n *\n * @module\n */\n\nimport { splitmix32 } from \"./splitmix32.js\";\nimport { sfc32Next, type Sfc32State } from \"./sfc32.js\";\nimport { SYNTH_FATAL_CODES, SynthError } from \"../codes.js\";\n\n/**\n * A seeded, deterministic random source. Created via {@link createRng}; passed explicitly to every\n * provider. All draw methods advance the internal state deterministically.\n */\nexport interface Rng {\n /** The integer seed this generator was created from (part of the `Corpus` manifest). */\n readonly seed: number;\n /** The next unsigned 32-bit integer. */\n nextUint32(): number;\n /** The next float in `[0, 1)`. */\n float(): number;\n /**\n * A uniformly-distributed integer in the inclusive range `[min, max]`.\n *\n * @param min - Inclusive lower bound (integer).\n * @param max - Inclusive upper bound (integer, `>= min`).\n */\n int(min: number, max: number): number;\n /** `true` with probability `p` (default `0.5`). */\n bool(p?: number): boolean;\n /**\n * Pick one element from a non-empty array.\n *\n * @param items - A non-empty readonly array.\n */\n pick<T>(items: readonly T[]): T;\n /**\n * A string of `n` decimal digits (`0`–`9`), each drawn uniformly.\n *\n * @param n - The number of digits (`>= 0`).\n */\n digits(n: number): string;\n}\n\n/**\n * The concrete {@link Rng}. Holds the mutable `sfc32` state; every method advances it deterministically.\n */\nclass Sfc32Rng implements Rng {\n public readonly seed: number;\n readonly #state: Sfc32State;\n\n public constructor(seed: number) {\n this.seed = seed | 0;\n // Expand the single seed into four well-distributed state words. Seeding sfc32 directly from the\n // raw seed gives poor low-bit behavior; splitmix32 is the standard fix (bryc / roadmap §5).\n const mix = splitmix32(this.seed);\n this.#state = { a: mix(), b: mix(), c: mix(), d: mix() };\n // A short warm-up so nearby seeds diverge immediately.\n for (let i = 0; i < 8; i += 1) sfc32Next(this.#state);\n }\n\n public nextUint32(): number {\n return sfc32Next(this.#state);\n }\n\n public float(): number {\n return this.nextUint32() / 0x1_0000_0000;\n }\n\n public int(min: number, max: number): number {\n if (max < min) throw new SynthError(SYNTH_FATAL_CODES.SYNTH_INVALID_RANGE);\n const span = max - min + 1;\n return min + Math.floor(this.float() * span);\n }\n\n public bool(p = 0.5): boolean {\n return this.float() < p;\n }\n\n public pick<T>(items: readonly T[]): T {\n if (items.length === 0) throw new SynthError(SYNTH_FATAL_CODES.SYNTH_EMPTY_POOL);\n // `int(0, length-1)` is always in-bounds on a non-empty array, so this access cannot be a hole;\n // the cast discharges `noUncheckedIndexedAccess`'s `T | undefined` without a runtime re-check.\n return items[this.int(0, items.length - 1)] as T;\n }\n\n public digits(n: number): string {\n let out = \"\";\n for (let i = 0; i < n; i += 1) out += String(this.int(0, 9));\n return out;\n }\n}\n\n/**\n * Create a seeded, deterministic {@link Rng}. The same `seed` yields the same sequence everywhere.\n *\n * @param seed - The integer seed. Coerced to a 32-bit integer.\n * @returns A fresh, independent {@link Rng}.\n * @example\n * ```ts\n * import { createRng } from \"@cosyte/synth\";\n * const rng = createRng(12345);\n * rng.int(1, 6); // deterministic for seed 12345\n * ```\n */\nexport function createRng(seed: number): Rng {\n return new Sfc32Rng(seed);\n}\n","/**\n * The reserved / never-collide identifier facts that make a `@cosyte/synth` value **provably\n * synthetic**: the ground truth behind the synthetic-safety invariant.\n *\n * These are **facts**, not copyrighted prose: ranges and check-digit rules published by SSA, the\n * IRS, HHS, NANPA and the IETF that are guaranteed never to denote a real person or a real routable\n * resource. Where two authorities share one number space (SSN and ITIN), a value must be outside\n * both. Every provider draws only from these; the predicates here are the executable half of the CI\n * synthetic-safety gate: they let a test assert that no emitted value falls **outside** a reserved\n * source.\n *\n * Every entry below names its authority by that authority's **own published identifier**, never by a\n * bare hostname, so a reader can open the text and check the claim instead of taking this module's\n * word for it. Two loci have no reserving authority and one rests on a source that is not the\n * issuing agency; each says so at the point of use rather than being left out of this list.\n *\n * Sources:\n * - **SSN**, SSA POMS RM 10201.035 (Invalid Social Security Numbers (SSNs)) defines an invalid SSN\n * as \"one that we never assigned\", and identifies one by a first three digits (former area number)\n * of `000`, `666`, or \"in the 900 series\", or a second group of two digits (former group number)\n * of `00`. <https://secure.ssa.gov/poms.nsf/lnx/0110201035>\n * - **ITIN**, an IRS Individual Taxpayer Identification Number shares the SSN number space by\n * construction: it is a `9NN-GG-NNNN` value whose group `GG` falls in a published ITIN group\n * range. Area `900-999` alone therefore does not prove a value cannot be a federally issued\n * identifier, so a synthetic SSN also keeps its group outside every published range. IRS Internal\n * Revenue Manual 3.21.263: \"An ITIN begins with a `9` and the 4th and 5th digits are 50-65, 70-88,\n * 90-92 and 94-99\". <https://www.irs.gov/irm/part3/irm_03-021-263r>\n * - **Phone**, NANPA's 555 Line Numbers page: \"The fictitious, non-working numbers, 555-0100 through\n * 555-0199, will remain reserved for entertainment/advertising.\"\n * <https://nanpa.com/numbering/555-line-numbers>\n * - **Email/domain**, RFC 2606 (Reserved Top Level DNS Names) reserves the `.test`, `.example`,\n * `.invalid` and `.localhost` top-level names and the second-level names `example.com`/`.net`/\n * `.org`; RFC 6761 section 6.5 carries the example domains into the special-use registry.\n * <https://datatracker.ietf.org/doc/html/rfc2606>,\n * <https://datatracker.ietf.org/doc/html/rfc6761>\n * - **IP**, RFC 5737: the blocks `192.0.2.0/24` (TEST-NET-1), `198.51.100.0/24` (TEST-NET-2) and\n * `203.0.113.0/24` (TEST-NET-3) \"are provided for use in documentation\"; RFC 3849: \"The prefix\n * allocated for documentation purposes is 2001:DB8::/32\".\n * <https://datatracker.ietf.org/doc/html/rfc5737>,\n * <https://datatracker.ietf.org/doc/html/rfc3849>\n * - **NPI**, a real National Provider Identifier is a 10-digit number whose last digit is a Luhn\n * check digit computed over the `80840` prefix + the 9-digit base. The rule is 69 FR 3434, the\n * final rule adopting the NPI (FR Doc 04-1149, docket CMS-0045-F), whose issuing agency that\n * document records as \"Centers for Medicare & Medicaid Services, HHS\": \"the NPI check digit\n * calculation must always be performed as though the NPI is preceded by\" `80840`, and the check\n * digit is \"calculated using the ISO standard Luhn check digit algorithm\". A number whose check\n * digit is **wrong** therefore cannot be a validly issued NPI. `synth` emits NPIs with a\n * deliberately-invalid check digit, so no generated NPI can collide with a real provider.\n * <https://www.federalregister.gov/documents/full_text/text/2004/01/23/04-1149.txt>\n * - **DEA**, the check-digit formula is **not** attributed to the DEA and no DEA-published text\n * stating it is cited anywhere here. See {@link deaCheckDigit}, which names the non-normative\n * source the claim does rest on, and what that source is not.\n * - **MRN / member / account**, **no authority reserves this locus**: there is no reserved MRN range\n * and none is claimed. See {@link SYNTHETIC_ASSIGNING_AUTHORITY} for what the floor rests on\n * instead.\n *\n * @module\n */\n\n/**\n * The synthetic **assigning authority** `@cosyte/synth` mints MRNs / account / member identifiers\n * under.\n *\n * **No authority reserves this locus.** An MRN is unique only within its assigning-authority / OID\n * namespace, no registry reserves a range of them, and none is cited here. What the floor rests on\n * instead is the *namespace*, as a documented design decision: every synthetic identifier is scoped\n * to a namespace that clearly cannot be a real facility's, a `SYNTH`-labelled authority this package\n * mints and no real facility uses. A value under this AA can never collide with a real record\n * whatever its digits are, because the namespace itself is synthetic.\n *\n * The OID is **uncited for the same reason**. `2.16.840.1.113883.19.999` is a value this package\n * chose; no published text designating the root `2.16.840.1.113883.19` for example use could be\n * shown, so this module claims no such designation and the guarantee above does not rest on one.\n */\nexport const SYNTHETIC_ASSIGNING_AUTHORITY = Object.freeze({\n /** The human-readable assigning-authority namespace id (HL7 HD.1). */\n namespaceId: \"COSYTE-SYNTH\",\n /** The universal id, an OID this package chose under the root `2.16.840.1.113883.19` (HD.2). */\n universalId: \"2.16.840.1.113883.19.999\",\n /** The universal id type (HD.3). */\n universalIdType: \"ISO\",\n});\n\n/** RFC 2606 / 6761 reserved email domains `@cosyte/synth` draws from. */\nexport const RESERVED_EMAIL_DOMAINS: readonly string[] = Object.freeze([\n \"example.com\",\n \"example.org\",\n \"example.net\",\n]);\n\n/** RFC 5737 IPv4 documentation (TEST-NET) `/24` network prefixes. */\nexport const TEST_NET_V4_PREFIXES: readonly string[] = Object.freeze([\n \"192.0.2\", // TEST-NET-1\n \"198.51.100\", // TEST-NET-2\n \"203.0.113\", // TEST-NET-3\n]);\n\n/** RFC 3849 IPv6 documentation prefix. */\nexport const DOC_V6_PREFIX = \"2001:db8\";\n\n/**\n * The published **IRS ITIN group ranges**, inclusive `[min, max]` bands over the two group digits\n * (positions 4 and 5) of a `9NN-GG-NNNN` value. An Individual Taxpayer Identification Number is an\n * SSN-format number that begins with `9` and carries a group inside one of these bands, so these\n * bands are what separates an SSN the SSA manual calls invalid from a validly formatted ITIN.\n *\n * These are **facts** about the number's shape, not copyrighted prose (IRS Internal Revenue Manual\n * 3.21.263). Group values `89` and `93` sit between the bands on purpose: the IRM records them as\n * reserved for other IRS programs rather than for ITINs, so a value carrying one is **not**\n * ITIN-formatted (see {@link isItinFormatted}).\n */\nexport const ITIN_GROUP_RANGES: readonly Readonly<{ min: number; max: number }>[] = Object.freeze([\n Object.freeze({ min: 50, max: 65 }),\n Object.freeze({ min: 70, max: 88 }),\n Object.freeze({ min: 90, max: 92 }),\n Object.freeze({ min: 94, max: 99 }),\n]);\n\n/**\n * The two group values the IRM records as reserved for other IRS programs rather than for ITINs.\n * They are **not** ITIN-formatted (so {@link isItinFormatted} must not claim them), and they are\n * still an issuing authority's space, so {@link SSN_SYNTHETIC_GROUPS} does not draw from them\n * either: the generator stays out of every federally used group, not merely out of the ITIN ones.\n *\n * @internal\n */\nconst ITIN_EXCLUDED_GROUPS: readonly number[] = Object.freeze([89, 93]);\n\n/**\n * The two-digit **group values a synthetic SSN may carry**: every value from `00` to `99` that is\n * outside every band in {@link ITIN_GROUP_RANGES} and outside {@link ITIN_EXCLUDED_GROUPS}. Derived\n * from those two lists rather than written out, so the pool can never drift from the published\n * ranges it is defined against.\n *\n * Combined with an area in the `900-999` band, a value drawn from this pool is provably outside both\n * issuing authorities that share the number space: SSA POMS RM 10201.035 identifies that area as\n * marking an **invalid** SSN, and a group outside every published ITIN band is not ITIN-formatted.\n *\n * @internal\n */\nexport const SSN_SYNTHETIC_GROUPS: readonly string[] = Object.freeze(\n Array.from({ length: 100 }, (_unused, group) => group)\n .filter(\n (group) =>\n !ITIN_GROUP_RANGES.some((range) => group >= range.min && group <= range.max) &&\n !ITIN_EXCLUDED_GROUPS.includes(group),\n )\n .map((group) => String(group).padStart(2, \"0\")),\n);\n\n/**\n * The `80840` prefix prepended to a 10-digit NPI before the Luhn check. A real NPI satisfies\n * `luhn(\"80840\" + npi) ≡ 0 (mod 10)`.\n *\n * The rule is **69 FR 3434**, the final rule adopting the NPI (FR Doc 04-1149, docket CMS-0045-F),\n * issued by the agency that document names as \"Centers for Medicare & Medicaid Services, HHS\": \"the\n * NPI check digit calculation must always be performed as though the NPI is preceded by\" `80840`.\n * The prefix itself is not that rule's: it credits the NCITS.284 standard health care identification\n * card, which \"requires that the first five digits of the card issuer identifier be\" `80840`, \"where\n * the initial two digits, 80, signify health applications, the next three digits, 840, signify\n * United States\". The rule cites no ISO document number for the prefix or for the check digit, and\n * neither does this module.\n * <https://www.federalregister.gov/documents/full_text/text/2004/01/23/04-1149.txt>\n */\nexport const NPI_LUHN_PREFIX = \"80840\";\n\n/**\n * The Luhn sum (mod 10) of a numeric string, doubling every second digit from the right. Used to\n * verify (or deliberately break) an NPI check digit.\n *\n * @param digits - A string of decimal digits.\n * @returns The Luhn sum modulo 10 (0 ⇒ the string passes the Luhn check).\n * @internal\n */\nexport function luhnMod10(digits: string): number {\n let sum = 0;\n // Standard Luhn: the RIGHTMOST digit is never doubled; doubling starts one position in and\n // alternates. For a full payload+check string this makes a Luhn-valid string sum to 0 (mod 10);\n // for a payload with a `0` placeholder in the check position it yields the complement of the\n // correct check digit.\n let double = false;\n for (let i = digits.length - 1; i >= 0; i -= 1) {\n let d = digits.charCodeAt(i) - 48;\n if (d < 0 || d > 9) continue;\n if (double) {\n d *= 2;\n if (d > 9) d -= 9;\n }\n sum += d;\n double = !double;\n }\n return sum % 10;\n}\n\n/**\n * The correct NPI check digit for a 9-digit base: the value that makes `80840` + base + check pass\n * the Luhn check.\n *\n * The algorithm this inverts is cited: 69 FR 3434 (FR Doc 04-1149) requires the check digit to be\n * \"calculated using the ISO standard Luhn check digit algorithm\", a modulus 10 double-add-double\n * algorithm, performed as though the NPI were preceded by {@link NPI_LUHN_PREFIX}. That rule names\n * the algorithm and its behaviour but no ISO document number, and points onward for the step-by-step\n * form: \"The specification for calculation of the NPI check digit will be made available on the CMS\n * Web site\". What this function implements is the rule's own description, modulus 10 Luhn over the\n * prefixed digits; no separate specification is cited for it.\n * <https://www.federalregister.gov/documents/full_text/text/2004/01/23/04-1149.txt>\n *\n * @param base9 - The 9-digit NPI base (positions 1 to 9).\n * @returns The check digit (`0`–`9`) a real NPI would carry for this base.\n * @example\n * ```ts\n * import { npiCheckDigit } from \"@cosyte/synth\";\n * npiCheckDigit(\"123456789\"); // 3, so 1234567893 is a Luhn-valid NPI shape\n * ```\n */\nexport function npiCheckDigit(base9: string): number {\n // Luhn over \"80840\" + base9 with a trailing 0 check placeholder; the check digit closes the sum.\n const partial = luhnMod10(`${NPI_LUHN_PREFIX}${base9}0`);\n return (10 - partial) % 10;\n}\n\n/**\n * The DEA-registration prefix letters `@cosyte/synth` draws a synthetic DEA number's first character\n * from. A real DEA number is `<registrant-type><last-name-initial>` + 7 digits; the first letter is the\n * registrant type (A/B/F/G/M/P/R/X are the widely-published values; the second letter is the\n * registrant's last-name initial). These letters are a **fact** about the number's shape, not\n * copyrighted prose: they only shape the value; the synthetic guarantee is the deliberately-**invalid\n * checksum** (see {@link dea} / {@link isSyntheticDea}).\n */\nexport const DEA_REGISTRANT_TYPES: readonly string[] = Object.freeze([\n \"A\",\n \"B\",\n \"F\",\n \"G\",\n \"M\",\n \"P\",\n \"R\",\n \"X\",\n]);\n\n/**\n * The correct DEA check digit for a 7-digit numeric base. The checksum is\n * `(d1 + d3 + d5) + 2·(d2 + d4 + d6)`, whose **units digit** is the 7th (check) digit. A real DEA\n * number satisfies this; a number whose 7th digit differs cannot be a validly-issued DEA registration.\n *\n * **NON-NORMATIVELY SOURCED, and this is the one locus in this module that is.** The formula above\n * is quoted from a pharmacy journal article, Gabay, \"Federal Controlled Substances Act: Controlled\n * Substances Prescriptions\", Hospital Pharmacy (PMC3847977): \"add the sum of the first, third, and\n * fifth digits to twice the sum of the second, fourth, and sixth digits. The total should be a\n * number whose last digit is the same as the last digit of the DEA number.\"\n * <https://pmc.ncbi.nlm.nih.gov/articles/PMC3847977/>\n *\n * **That article is not the DEA.** It is a secondary description of the agency's algorithm, not the\n * agency's own statement of it, and no DEA-published text stating the algorithm is cited here. The\n * consequence is stated rather than hidden: if the formula is wrong, a value this package builds to\n * fail it may in fact **pass** the real check, and the generator would then emit a checksum-valid\n * DEA number while {@link isSyntheticDea} asserts the opposite. Every other entry in this module's\n * `Sources:` list names the issuing authority's own text; this one cannot.\n *\n * @param base6 - The first 6 digits of the DEA number (positions 1 to 6).\n * @returns The check digit (`0`–`9`) a real DEA number would carry for this base.\n * @example\n * ```ts\n * import { deaCheckDigit } from \"@cosyte/synth\";\n * deaCheckDigit(\"123456\"); // the units digit of (1+3+5) + 2·(2+4+6)\n * ```\n */\nexport function deaCheckDigit(base6: string): number {\n let odd = 0;\n let even = 0;\n for (let i = 0; i < 6; i += 1) {\n const digit = base6.charCodeAt(i) - 48;\n if (i % 2 === 0) odd += digit;\n else even += digit;\n }\n return (odd + 2 * even) % 10;\n}\n\n/**\n * Whether a DEA number (`XX` + 7 digits, case-insensitive) is **provably synthetic**: its check digit\n * (the 7th digit) does **not** match the checksum {@link deaCheckDigit} computes, so it cannot be a\n * validly-issued DEA registration. A checksum-valid DEA number (which *could* denote a real\n * prescriber) returns `false`; a value that is not the DEA shape returns `false`.\n *\n * **NON-NORMATIVELY SOURCED.** This predicate is only as strong as the algorithm it inverts, and\n * that algorithm is cited to a pharmacy journal article (PMC3847977), **not to the DEA**: no\n * DEA-published statement of it is cited anywhere in this package. Read `true` as \"fails the\n * formula {@link deaCheckDigit} implements\", never as \"the DEA could not have issued this\". The\n * full citation and the consequence of the formula being wrong are on {@link deaCheckDigit}.\n *\n * @param value - The candidate DEA number (with or without incidental separators).\n * @returns `true` when the DEA number's checksum is wrong (never a real DEA registration).\n * @example\n * ```ts\n * import { isSyntheticDea } from \"@cosyte/synth\";\n * isSyntheticDea(\"AF1234561\"); // depends on the base: true when the 7th digit is wrong\n * ```\n */\nexport function isSyntheticDea(value: string): boolean {\n const compact = value.replace(/[\\s-]/g, \"\").toUpperCase();\n if (!/^[A-Z]{2}\\d{7}$/.test(compact)) return false;\n const digits = compact.slice(2);\n const check = digits.charCodeAt(6) - 48;\n return deaCheckDigit(digits.slice(0, 6)) !== check;\n}\n\n/**\n * Whether a 10-digit NPI is **provably synthetic**, i.e. its check digit is invalid, so it cannot be\n * a validly issued NPI. A Luhn-valid 10-digit NPI (which *could* denote a real registered provider)\n * returns `false`; a non-10-digit value returns `false` (not an NPI shape).\n *\n * The check this inverts is the one 69 FR 3434 (FR Doc 04-1149) requires: the Luhn check digit,\n * computed as though the NPI were preceded by {@link NPI_LUHN_PREFIX}. Unlike the DEA locus, this\n * one cites the issuing rule itself.\n * <https://www.federalregister.gov/documents/full_text/text/2004/01/23/04-1149.txt>\n *\n * @param value - The candidate NPI (digits only, or with incidental separators).\n * @returns `true` when the NPI's check digit is wrong (never a real NPI).\n * @example\n * ```ts\n * import { isSyntheticNpi } from \"@cosyte/synth\";\n * isSyntheticNpi(\"1234567894\"); // true: invalid check digit (valid would be 1234567893)\n * isSyntheticNpi(\"1234567893\"); // false: Luhn-valid, could be a real NPI\n * ```\n */\nexport function isSyntheticNpi(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n if (digits.length !== 10) return false;\n return luhnMod10(`${NPI_LUHN_PREFIX}${digits}`) !== 0;\n}\n\n/**\n * Whether a `ddd-dd-dddd` (or `ddddddddd`) SSN string carries an area SSA's own manual identifies\n * as **invalid**: `000`, `666`, or \"in the 900 series\". A real, issuable SSN returns `false`.\n *\n * The citable claim is SSA POMS RM 10201.035, which defines an invalid SSN as \"one that we never\n * assigned\" and lists those three areas as identifying one. The wording here says invalid rather\n * than never-issued because invalidity is what the manual states.\n * <https://secure.ssa.gov/poms.nsf/lnx/0110201035>\n *\n * @param value - The candidate SSN (dashes optional).\n * @returns `true` when the SSN is provably synthetic.\n * @example\n * ```ts\n * import { isSyntheticSsn } from \"@cosyte/synth\";\n * isSyntheticSsn(\"900-12-3456\"); // true (the 900 series marks an invalid SSN)\n * isSyntheticSsn(\"123456789\"); // false (issuable area 123)\n * ```\n */\nexport function isSyntheticSsn(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n if (digits.length !== 9) return false;\n const area = Number(digits.slice(0, 3));\n return area === 0 || area === 666 || area >= 900;\n}\n\n/**\n * Whether a `ddd-dd-dddd` (or `ddddddddd`) value is a **validly formatted IRS ITIN**: it begins\n * with `9` and its group digits (positions 4 and 5) fall inside a published ITIN group range\n * ({@link ITIN_GROUP_RANGES}). This is the second issuing authority sharing the SSN number space,\n * so `isSyntheticSsn(v) && !isItinFormatted(v)` is the full \"cannot be a federally issued national\n * id\" guarantee, of which the area rule alone is only half.\n *\n * `true` means the value is ITIN-shaped and therefore **must not** be emitted at an SSN locus. A\n * value that is not exactly 9 digits once separators are stripped returns `false` (not an SSN/ITIN\n * shape) rather than throwing, as do the group values `89` and `93`, which the IRM reserves for\n * other IRS programs rather than for ITINs.\n *\n * @param value - The candidate national id (dashes and other separators optional).\n * @returns `true` when the value is formatted as a valid ITIN.\n * @example\n * ```ts\n * import { isItinFormatted } from \"@cosyte/synth\";\n * isItinFormatted(\"912-70-1234\"); // true: group 70 is inside a published ITIN range\n * isItinFormatted(\"912-66-1234\"); // false: group 66 is outside every published ITIN range\n * ```\n */\nexport function isItinFormatted(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n if (digits.length !== 9) return false;\n if (!digits.startsWith(\"9\")) return false;\n const group = Number(digits.slice(3, 5));\n return ITIN_GROUP_RANGES.some((range) => group >= range.min && group <= range.max);\n}\n\n/**\n * Whether a phone string contains the NANP `555-0100…555-0199` reserved fictional line range.\n *\n * @param value - The candidate phone (any formatting).\n * @returns `true` when the number is in the reserved fictional block.\n * @example\n * ```ts\n * import { isSyntheticPhone } from \"@cosyte/synth\";\n * isSyntheticPhone(\"(202) 555-0142\"); // true\n * ```\n */\nexport function isSyntheticPhone(value: string): boolean {\n const digits = value.replace(/\\D/g, \"\");\n // The reserved guarantee is the 7-digit tail: exchange 555 + line 01NN.\n const tail = digits.slice(-7);\n return /^555 ?01\\d\\d$/.test(tail) || /^55501\\d\\d$/.test(tail);\n}\n\n/**\n * Whether an email's domain is an RFC 2606 / 6761 reserved / test domain.\n *\n * @param value - The candidate email address.\n * @returns `true` when the domain is reserved (never real).\n * @example\n * ```ts\n * import { isSyntheticEmail } from \"@cosyte/synth\";\n * isSyntheticEmail(\"faux.testerson@example.com\"); // true\n * ```\n */\nexport function isSyntheticEmail(value: string): boolean {\n const at = value.lastIndexOf(\"@\");\n if (at < 0) return false;\n const domain = value.slice(at + 1).toLowerCase();\n if (RESERVED_EMAIL_DOMAINS.includes(domain)) return true;\n return /\\.(example|test|invalid|localhost)$/.test(domain);\n}\n\n/**\n * Whether an IP string is in an RFC 5737 (IPv4 TEST-NET) or RFC 3849 (IPv6 documentation) reserved\n * block. A real routable address returns `false`.\n *\n * @param value - The candidate IPv4 or IPv6 address.\n * @returns `true` when the address is a reserved documentation address.\n * @example\n * ```ts\n * import { isSyntheticIp } from \"@cosyte/synth\";\n * isSyntheticIp(\"192.0.2.44\"); // true (TEST-NET-1)\n * isSyntheticIp(\"8.8.8.8\"); // false (real)\n * ```\n */\nexport function isSyntheticIp(value: string): boolean {\n if (value.toLowerCase().startsWith(`${DOC_V6_PREFIX}:`)) return true;\n return TEST_NET_V4_PREFIXES.some((prefix) => value.startsWith(`${prefix}.`));\n}\n","/**\n * The shipped **clearly-fake name pool**: `@cosyte/synth`'s own license-clean synthetic data.\n *\n * Deliberately **not** a `faker`-style realistic-name corpus (which could match a real person at a real\n * address: the exact hazard the synthetic-safety invariant forbids). Every token is\n * an obviously-invented, fixture-flavoured word: a reader can tell at a glance it names no one. The pool\n * is small on purpose: structural coverage, not demographic realism, is the goal.\n *\n * `# synthetic: true`\n *\n * @module\n */\n\n/** Obviously-synthetic given names. None is a plausible real person's name. */\nexport const SYNTHETIC_GIVEN_NAMES: readonly string[] = Object.freeze([\n \"Testina\",\n \"Fixtura\",\n \"Synthos\",\n \"Placeholda\",\n \"Sampleton\",\n \"Prototius\",\n \"Stubbina\",\n \"Exampla\",\n \"Quilliam\",\n \"Fabrica\",\n \"Simula\",\n \"Testry\",\n \"Seedwin\",\n \"Corpora\",\n \"Reprodo\",\n \"Mocktavia\",\n \"Dummett\",\n \"Voidwin\",\n \"Deteria\",\n \"Randomir\",\n]);\n\n/** Obviously-synthetic family names. None is a plausible real surname at a real address. */\nexport const SYNTHETIC_FAMILY_NAMES: readonly string[] = Object.freeze([\n \"Testerson\",\n \"Fauxman\",\n \"Placeholt\",\n \"Mockridge\",\n \"Fixtingham\",\n \"Synthwell\",\n \"Dummerton\",\n \"Examplewood\",\n \"Fabricant\",\n \"Simulacre\",\n \"Nonesuch\",\n \"Seedman\",\n \"Corpusworth\",\n \"Reprodus\",\n \"Voidmark\",\n \"Deterwood\",\n \"Randomson\",\n \"Quillfeather\",\n \"Notreal\",\n \"Genfield\",\n]);\n\n/** Obviously-synthetic street names for structured address fields. */\nexport const SYNTHETIC_STREET_NAMES: readonly string[] = Object.freeze([\n \"Fixture Lane\",\n \"Sample Street\",\n \"Placeholder Avenue\",\n \"Synthetic Way\",\n \"Example Boulevard\",\n \"Testing Terrace\",\n \"Mock Road\",\n \"Prototype Court\",\n]);\n\n/**\n * Obviously-synthetic city names. Combined only ever with a synthetic street + a fake name (the\n * *combination* is what identifies, and the combination is always synthetic).\n */\nexport const SYNTHETIC_CITY_NAMES: readonly string[] = Object.freeze([\n \"Faketon\",\n \"Synthville\",\n \"Exampleburg\",\n \"Testford\",\n \"Mockhaven\",\n \"Fixtureton\",\n]);\n","/**\n * The synthetic-safety provider layer: every identifier, contact point, name, and date\n * `@cosyte/synth` emits is minted here, and **only** from a guaranteed-non-colliding source. There is no code\n * path that returns a value not drawn from a reserved range or the\n * shipped fake-name pool. This is the inverse of a parser's liberality: the generator is *closed-world*\n * on its data sources, so no output *can* be real or plausibly-real PHI.\n *\n * All providers are pure functions of an explicit {@link ../rng/rng.Rng}, same seed, same values.\n *\n * @module\n */\n\nimport type { Rng } from \"../rng/rng.js\";\n\nimport {\n RESERVED_EMAIL_DOMAINS,\n TEST_NET_V4_PREFIXES,\n DOC_V6_PREFIX,\n SYNTHETIC_ASSIGNING_AUTHORITY,\n npiCheckDigit,\n deaCheckDigit,\n DEA_REGISTRANT_TYPES,\n SSN_SYNTHETIC_GROUPS,\n} from \"./reserved.js\";\nimport {\n SYNTHETIC_GIVEN_NAMES,\n SYNTHETIC_FAMILY_NAMES,\n SYNTHETIC_STREET_NAMES,\n SYNTHETIC_CITY_NAMES,\n} from \"./names-pool.js\";\n\n/** A synthetic person name drawn from the shipped fake-name pool. */\nexport interface SyntheticName {\n /** A clearly-fake given name. */\n readonly given: string;\n /** A clearly-fake family name. */\n readonly family: string;\n}\n\n/** A synthetic postal address: synthetic street + city, a fixed non-real ZIP. */\nexport interface SyntheticAddress {\n /** A clearly-fake street line. */\n readonly street: string;\n /** A clearly-fake city. */\n readonly city: string;\n /** A US state abbreviation (structural only; never combined with a real street + name + DOB). */\n readonly state: string;\n /** A reserved non-real ZIP (`00000`). */\n readonly zip: string;\n}\n\n/** A synthetic identifier scoped to the synthetic assigning authority. */\nexport interface SyntheticIdentifier {\n /** The identifier value (digits): unique only within the synthetic namespace. */\n readonly value: string;\n /** HL7 identifier type code (`MR` = medical record, `AN` = account, `MB` = member). */\n readonly typeCode: \"MR\" | \"AN\" | \"MB\";\n /** The synthetic assigning-authority namespace id. */\n readonly assigningAuthority: string;\n /** The synthetic assigning-authority OID (HL7 example arc). */\n readonly assigningAuthorityOid: string;\n}\n\n/** Which SSN reserved space to draw from. */\nexport type SsnBlock = \"never-issued\" | \"advertising\";\n\n/**\n * A **synthetic SSN**: dashed `AAA-GG-SSSS`, drawn so it can be neither an SSA-assignable Social\n * Security number nor a validly formatted IRS ITIN. Two authorities share this number space: SSA\n * never issues area `900-999`, and the IRS issues ITINs *inside* that area, distinguished by the\n * group digits. So the area rule alone is only half the guarantee, and both blocks below also keep\n * the group outside every published ITIN group range (see {@link isItinFormatted}).\n *\n * Default draws the never-issued area space (`900-999`) with a group from\n * {@link SSN_SYNTHETIC_GROUPS}; `block: \"advertising\"` returns the fixed display block\n * `987-00-4320` to `987-00-4329`, whose group `00` is one SSA never assigns and one no published\n * ITIN range contains.\n *\n * **`\"advertising\"` no longer means SSA's own advertising block.** That published block is\n * `987-65-4320` to `987-65-4329`, and group `65` sits inside a published ITIN group range, so every\n * value in it is ITIN-formatted and none of them can be emitted here. The option keeps its name\n * (renaming it would break call sites for a property no test asserts) and keeps its purpose, a fixed\n * ten-value block safe to print on screen, but it is a display block of this package's choosing now,\n * not a citation of SSA's. Do not reintroduce the `65` group to recover the provenance.\n *\n * @param rng - The seeded generator.\n * @param block - Which reserved space to draw from. Defaults to `\"never-issued\"`.\n * @returns A dashed synthetic SSN string.\n * @example\n * ```ts\n * import { createRng, ssn } from \"@cosyte/synth\";\n * ssn(createRng(1)); // e.g. a 900-area, never-issued, never-ITIN-formatted SSN\n * ```\n */\nexport function ssn(rng: Rng, block: SsnBlock = \"never-issued\"): string {\n if (block === \"advertising\") {\n // The fixed display block: last digit 0..9 within -4320..-4329, group 00 so no value here is\n // ITIN-formatted (the previous group, 65, sat inside the published ITIN range 50-65).\n return `987-00-432${String(rng.int(0, 9))}`;\n }\n const area = rng.int(900, 999); // SSA never issues 900-999.\n // Never a bare two-digit draw: 44 of the 100 group values would make the result a validly\n // formatted ITIN. The pool is the complement, so an ITIN-shaped candidate is never produced\n // rather than produced and rejected (generation never fails for a seed).\n const group = rng.pick(SSN_SYNTHETIC_GROUPS);\n const serial = rng.digits(4);\n return `${String(area)}-${group}-${serial}`;\n}\n\n/**\n * A **synthetic phone** in the NANP reserved fictional block: `(AAA) 555-01NN`. The reserved\n * guarantee is the `555-01NN` tail (exchange 555, line 0100–0199); the area code is any NANP-valid\n * `NXX`. Can never be a working number.\n *\n * @param rng - The seeded generator.\n * @returns A formatted synthetic phone string.\n * @example\n * ```ts\n * import { createRng, phone } from \"@cosyte/synth\";\n * phone(createRng(1)); // e.g. \"(2XX) 555-01NN\"\n * ```\n */\nexport function phone(rng: Rng): string {\n const area = `${String(rng.int(2, 9))}${rng.digits(2)}`; // NXX area code.\n const line = `01${rng.digits(2)}`; // reserved 0100-0199.\n return `(${area}) 555-${line}`;\n}\n\n/**\n * A **synthetic name** drawn from the shipped clearly-fake pool.\n *\n * @param rng - The seeded generator.\n * @returns A {@link SyntheticName}.\n * @example\n * ```ts\n * import { createRng, name } from \"@cosyte/synth\";\n * const { given, family } = name(createRng(1));\n * ```\n */\nexport function name(rng: Rng): SyntheticName {\n return { given: rng.pick(SYNTHETIC_GIVEN_NAMES), family: rng.pick(SYNTHETIC_FAMILY_NAMES) };\n}\n\n/**\n * A **synthetic email** at an RFC 2606 / 6761 reserved domain: `<slug>@example.com`.\n *\n * @param rng - The seeded generator.\n * @param person - Optional name to derive the local-part slug from; otherwise a random slug is used.\n * @returns A synthetic email address.\n * @example\n * ```ts\n * import { createRng, email, name } from \"@cosyte/synth\";\n * email(createRng(1), name(createRng(1))); // \"<given>.<family>@example.com\"\n * ```\n */\nexport function email(rng: Rng, person?: SyntheticName): string {\n const domain = rng.pick(RESERVED_EMAIL_DOMAINS);\n const slug = person ? `${person.given}.${person.family}`.toLowerCase() : `synth${rng.digits(6)}`;\n return `${slug}@${domain}`;\n}\n\n/**\n * A **synthetic IPv4** in an RFC 5737 TEST-NET block, never routable.\n *\n * @param rng - The seeded generator.\n * @returns A TEST-NET IPv4 address string.\n * @example\n * ```ts\n * import { createRng, ipv4 } from \"@cosyte/synth\";\n * ipv4(createRng(1)); // e.g. \"192.0.2.NN\"\n * ```\n */\nexport function ipv4(rng: Rng): string {\n return `${rng.pick(TEST_NET_V4_PREFIXES)}.${String(rng.int(1, 254))}`;\n}\n\n/**\n * A **synthetic IPv6** in the RFC 3849 documentation prefix `2001:db8::/32`, never routable.\n *\n * @param rng - The seeded generator.\n * @returns A documentation-prefix IPv6 address string.\n * @example\n * ```ts\n * import { createRng, ipv6 } from \"@cosyte/synth\";\n * ipv6(createRng(1)); // e.g. \"2001:db8::NNNN\"\n * ```\n */\nexport function ipv6(rng: Rng): string {\n const tail = rng.nextUint32().toString(16).padStart(4, \"0\").slice(-4);\n return `${DOC_V6_PREFIX}::${tail}`;\n}\n\n/**\n * A **deterministic UUIDv4-shaped** surrogate key from the seeded generator. Because it is seeded (not\n * from `node:crypto`, which is not reproducible), the cryptographic non-collision argument is weaker,\n * acceptable because the identifier namespace is synthetic anyway, and noted honestly.\n *\n * @param rng - The seeded generator.\n * @returns A canonical `8-4-4-4-12` lowercase-hex UUID string with version `4` and RFC 4122 variant.\n * @example\n * ```ts\n * import { createRng, uuid } from \"@cosyte/synth\";\n * uuid(createRng(1)); // \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\"\n * ```\n */\nexport function uuid(rng: Rng): string {\n const bytes = new Uint8Array(16);\n for (let i = 0; i < 16; i += 1) bytes[i] = rng.int(0, 255);\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40; // version 4\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80; // variant 10xx\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(6, 8).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10, 16).join(\"\")}`;\n}\n\n/**\n * A **synthetic NPI**: a 10-digit National Provider Identifier with a **deliberately-invalid Luhn\n * check digit**, so it can never be a NPPES-issued NPI (a real NPI must satisfy the `80840`-prefixed\n * Luhn check). The 9-digit base is drawn from the seeded generator; the check digit is\n * set to `(correct + 1) mod 10`, guaranteeing the full value fails validation.\n *\n * @param rng - The seeded generator.\n * @returns A 10-digit NPI-shaped string that is provably not a real NPI.\n * @example\n * ```ts\n * import { createRng, npi, isSyntheticNpi } from \"@cosyte/synth\";\n * isSyntheticNpi(npi(createRng(1))); // true: invalid check digit by construction\n * ```\n */\nexport function npi(rng: Rng): string {\n const base9 = rng.digits(9);\n const wrongCheck = (npiCheckDigit(base9) + 1) % 10;\n return `${base9}${String(wrongCheck)}`;\n}\n\n/**\n * A **synthetic DEA number**: `<registrant-type><initial>` + 7 digits with a **deliberately-invalid\n * checksum**, so it can never be a validly-issued DEA registration (a real DEA number's 7th digit\n * satisfies the published DEA checksum). The first letter is a registrant-type letter, the\n * second is derived from `person` (its family initial) when supplied so the number reads plausibly; the\n * 6-digit base is seeded and the check digit is set to `(correct + 1) mod 10`, guaranteeing the value\n * fails validation. NCPDP carries prescriber DEA, and this is the identity locus a refuter attacks\n * hardest, so, like {@link npi}, non-collision is a construction-level guarantee, not a heuristic.\n *\n * @param rng - The seeded generator.\n * @param person - Optional name whose family initial becomes the DEA's second letter.\n * @returns A DEA-shaped string that is provably not a real DEA registration.\n * @example\n * ```ts\n * import { createRng, dea, isSyntheticDea } from \"@cosyte/synth\";\n * isSyntheticDea(dea(createRng(1))); // true: invalid checksum by construction\n * ```\n */\nexport function dea(rng: Rng, person?: SyntheticName): string {\n const type = rng.pick(DEA_REGISTRANT_TYPES);\n const initialSource = person?.family ?? rng.pick(SYNTHETIC_FAMILY_NAMES);\n const initial = initialSource.slice(0, 1).toUpperCase();\n const base6 = rng.digits(6);\n const wrongCheck = (deaCheckDigit(base6) + 1) % 10;\n return `${type}${initial}${base6}${String(wrongCheck)}`;\n}\n\n/**\n * A **synthetic identifier** (MRN / account / member id) scoped to the synthetic assigning authority.\n * There is no reserved MRN range, so non-collision is guaranteed by the *namespace*, not the value: the\n * identifier lives under a `SYNTH` authority no real facility uses.\n *\n * @param rng - The seeded generator.\n * @param typeCode - The HL7 identifier type: `MR` (default), `AN`, or `MB`.\n * @returns A {@link SyntheticIdentifier}.\n * @example\n * ```ts\n * import { createRng, identifier } from \"@cosyte/synth\";\n * identifier(createRng(1), \"MR\"); // { value, typeCode: \"MR\", assigningAuthority: \"COSYTE-SYNTH\", ... }\n * ```\n */\nexport function identifier(\n rng: Rng,\n typeCode: SyntheticIdentifier[\"typeCode\"] = \"MR\",\n): SyntheticIdentifier {\n return {\n value: rng.digits(8),\n typeCode,\n assigningAuthority: SYNTHETIC_ASSIGNING_AUTHORITY.namespaceId,\n assigningAuthorityOid: SYNTHETIC_ASSIGNING_AUTHORITY.universalId,\n };\n}\n\n/**\n * A **synthetic address**: a fake street + city, a reserved non-real ZIP (`00000`). A real state\n * abbreviation may appear (structural only) but is never combined with a real street + name + DOB.\n *\n * @param rng - The seeded generator.\n * @returns A {@link SyntheticAddress}.\n * @example\n * ```ts\n * import { createRng, address } from \"@cosyte/synth\";\n * address(createRng(1)); // { street, city, state, zip: \"00000\" }\n * ```\n */\nexport function address(rng: Rng): SyntheticAddress {\n const number = rng.int(1, 9999);\n return {\n street: `${String(number)} ${rng.pick(SYNTHETIC_STREET_NAMES)}`,\n city: rng.pick(SYNTHETIC_CITY_NAMES),\n state: rng.pick(US_STATES),\n zip: \"00000\",\n };\n}\n\n/**\n * A **synthetic date** in HL7 `YYYYMMDD` form, drawn uniformly within an inclusive year range. Comes\n * from the seeded generator (never wall-clock), so it is reproducible and implies no real event.\n *\n * @param rng - The seeded generator.\n * @param minYear - Inclusive lower year bound (default `1930`).\n * @param maxYear - Inclusive upper year bound (default `2010`).\n * @returns An `YYYYMMDD` date string (always a valid calendar day).\n * @example\n * ```ts\n * import { createRng, dateYmd } from \"@cosyte/synth\";\n * dateYmd(createRng(1), 1970, 2000); // \"YYYYMMDD\"\n * ```\n */\nexport function dateYmd(rng: Rng, minYear = 1930, maxYear = 2010): string {\n const year = rng.int(minYear, maxYear);\n const month = rng.int(1, 12);\n const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();\n const day = rng.int(1, daysInMonth);\n return `${String(year).padStart(4, \"0\")}${String(month).padStart(2, \"0\")}${String(day).padStart(2, \"0\")}`;\n}\n\n/** US state abbreviations: structural only (see {@link address}). */\nconst US_STATES: readonly string[] = Object.freeze([\n \"AL\",\n \"AK\",\n \"AZ\",\n \"AR\",\n \"CA\",\n \"CO\",\n \"CT\",\n \"DE\",\n \"FL\",\n \"GA\",\n \"HI\",\n \"ID\",\n \"IL\",\n \"IN\",\n \"IA\",\n \"KS\",\n \"KY\",\n \"LA\",\n \"ME\",\n \"MD\",\n \"MA\",\n \"MI\",\n \"MN\",\n \"MS\",\n \"MO\",\n \"MT\",\n \"NE\",\n \"NV\",\n \"NH\",\n \"NJ\",\n \"NM\",\n \"NY\",\n \"NC\",\n \"ND\",\n \"OH\",\n \"OK\",\n \"OR\",\n \"PA\",\n \"RI\",\n \"SC\",\n \"SD\",\n \"TN\",\n \"TX\",\n \"UT\",\n \"VT\",\n \"VA\",\n \"WA\",\n \"WV\",\n \"WI\",\n \"WY\",\n]);\n","/**\n * The `safe` namespace: the single entry point for every synthetic-by-construction value provider.\n *\n * Grouped under one object so a consumer reads `safe.ssn(rng)` / `safe.phone(rng)` and it is\n * self-evident that the value is drawn from a guaranteed-non-colliding synthetic source.\n * The individual functions and the reserved-range predicates are also exported by name from the\n * package root for direct import.\n *\n * @module\n */\n\nimport {\n ssn,\n phone,\n name,\n email,\n ipv4,\n ipv6,\n uuid,\n identifier,\n address,\n dateYmd,\n npi,\n dea,\n} from \"./providers.js\";\n\nexport * from \"./providers.js\";\nexport * from \"./reserved.js\";\nexport * from \"./names-pool.js\";\n\n/**\n * The synthetic-safety provider namespace. Every function draws only from a reserved range or the\n * shipped fake-name pool, no value it returns can be real or plausibly-real PHI.\n *\n * @example\n * ```ts\n * import { createRng, safe } from \"@cosyte/synth\";\n * const rng = createRng(42);\n * safe.ssn(rng); // never-issued SSN\n * safe.phone(rng); // reserved 555-01NN number\n * ```\n */\nexport const safe = Object.freeze({\n ssn,\n phone,\n name,\n email,\n ipv4,\n ipv6,\n uuid,\n identifier,\n address,\n dateYmd,\n npi,\n dea,\n});\n","/**\n * US Core + base-FHIR **canonical URLs and code-system identifiers**: the facts `@cosyte/synth` needs\n * to emit US-Core-conformant resources, and nothing more.\n *\n * **Content-free, exactly like `@cosyte/fhir`.** These are *identifiers*: canonical URLs and code\n * `system` URIs, not the copyrighted terminology tables or the profile `StructureDefinition` content\n * they name. `@cosyte/synth` bundles **no** US Core IG: a consumer who wants to *validate* generated\n * output against US Core supplies the `StructureDefinition`s themselves (BYO), exactly as\n * `@cosyte/fhir.validateResource({ profiles })` requires. What is encoded here is only which canonical\n * URL a resource's `meta.profile` claims and which `system` a coding carries: public facts.\n *\n * The URLs target **US Core 6.1.0** (the USCDI v3 / ONC HTI-1 §170.315(g)(10) anchor, FHIR R4 4.0.1),\n * grounded firsthand against the published IG (`hl7.org/fhir/us/core/STU6.1`): the same version the\n * test corpus validates against.\n *\n * @module\n */\n\n/** The canonical `meta.profile` URLs for the US Core 6.1.0 profiles `@cosyte/synth` generates. */\nexport const US_CORE_PROFILE = Object.freeze({\n /** US Core Patient. */\n PATIENT: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient\",\n /** US Core Condition (Problems and Health Concerns). */\n CONDITION:\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-problems-health-concerns\",\n /** US Core Laboratory Result Observation. */\n OBSERVATION_LAB: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab\",\n /** US Core Vital Signs (derived from the base FHIR vital-signs profile). */\n VITAL_SIGNS: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-vital-signs\",\n /** US Core MedicationRequest. */\n MEDICATION_REQUEST: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-medicationrequest\",\n /** US Core Encounter. */\n ENCOUNTER: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter\",\n /** US Core DiagnosticReport Profile for Laboratory Results Reporting. */\n DIAGNOSTIC_REPORT_LAB:\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-lab\",\n /** US Core Immunization. */\n IMMUNIZATION: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-immunization\",\n /** US Core AllergyIntolerance. */\n ALLERGY_INTOLERANCE: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-allergyintolerance\",\n /** US Core Procedure. */\n PROCEDURE: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-procedure\",\n /** US Core Provenance. */\n PROVENANCE: \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-provenance\",\n} as const);\n\n/**\n * The canonical prefix every US Core 6.1.0 resource profile's `url` shares. A profile's canonical is\n * this prefix followed by its profile id.\n *\n * @example\n * ```ts\n * import { US_CORE_PROFILE_BASE } from \"@cosyte/synth/fhir\";\n * `${US_CORE_PROFILE_BASE}us-core-provenance`;\n * ```\n */\nexport const US_CORE_PROFILE_BASE = \"http://hl7.org/fhir/us/core/StructureDefinition/\";\n\n/**\n * The **adopted set**: the profile ids of every US Core 6.1.0 **resource profile** the implementation\n * guide publishes, transcribed from the guide's own artifact index (\"Structures: Resource Profiles\").\n * This is the closed set a profile-addressed request is resolved against, and it is *identifiers\n * only*, never IG content, exactly like {@link US_CORE_PROFILE}.\n *\n * `45 CFR 170.215` adopts FHIR R4.0.1 and US Core STU 6.1.0, so this is the profile set a developer\n * building to `45 CFR 170.315(g)(10)` addresses. It is **not** the count of\n * `StructureDefinition-us-core-*.json` files in the guide's source tree: that directory also holds\n * the guide's extension definitions and omits profiles the guide publishes.\n *\n * The guide's 10 **extension definitions** (`us-core-race`, `us-core-birthsex`, …) are deliberately\n * absent: an extension is not a standalone artifact, so a request naming one is refused like any\n * other name outside this set.\n *\n * @example\n * ```ts\n * import { US_CORE_ADOPTED_PROFILES } from \"@cosyte/synth/fhir\";\n * US_CORE_ADOPTED_PROFILES.includes(\"us-core-provenance\"); // true\n * ```\n */\nexport const US_CORE_ADOPTED_PROFILES = Object.freeze([\n \"head-occipital-frontal-circumference-percentile\",\n \"pediatric-bmi-for-age\",\n \"pediatric-weight-for-height\",\n \"us-core-allergyintolerance\",\n \"us-core-blood-pressure\",\n \"us-core-bmi\",\n \"us-core-body-height\",\n \"us-core-body-temperature\",\n \"us-core-body-weight\",\n \"us-core-careplan\",\n \"us-core-careteam\",\n \"us-core-condition-encounter-diagnosis\",\n \"us-core-condition-problems-health-concerns\",\n \"us-core-coverage\",\n \"us-core-diagnosticreport-lab\",\n \"us-core-diagnosticreport-note\",\n \"us-core-documentreference\",\n \"us-core-encounter\",\n \"us-core-goal\",\n \"us-core-head-circumference\",\n \"us-core-heart-rate\",\n \"us-core-immunization\",\n \"us-core-implantable-device\",\n \"us-core-location\",\n \"us-core-medication\",\n \"us-core-medicationdispense\",\n \"us-core-medicationrequest\",\n \"us-core-observation-clinical-result\",\n \"us-core-observation-lab\",\n \"us-core-observation-occupation\",\n \"us-core-observation-pregnancyintent\",\n \"us-core-observation-pregnancystatus\",\n \"us-core-observation-screening-assessment\",\n \"us-core-observation-sexual-orientation\",\n \"us-core-organization\",\n \"us-core-patient\",\n \"us-core-practitioner\",\n \"us-core-practitionerrole\",\n \"us-core-procedure\",\n \"us-core-provenance\",\n \"us-core-pulse-oximetry\",\n \"us-core-questionnaireresponse\",\n \"us-core-relatedperson\",\n \"us-core-respiratory-rate\",\n \"us-core-servicerequest\",\n \"us-core-simple-observation\",\n \"us-core-smokingstatus\",\n \"us-core-specimen\",\n \"us-core-vital-signs\",\n] as const);\n\n/** One profile id from the adopted US Core 6.1.0 set. Erased at run time, so it is resolved, not trusted. */\nexport type UsCoreProfileId = (typeof US_CORE_ADOPTED_PROFILES)[number];\n\n/** The US Core `us-core-race` extension URL (a Patient must-support extension). */\nexport const US_CORE_RACE_EXTENSION =\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race\";\n/** The US Core `us-core-ethnicity` extension URL (a Patient must-support extension). */\nexport const US_CORE_ETHNICITY_EXTENSION =\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity\";\n/** The US Core `us-core-birthsex` extension URL (a Patient must-support extension). */\nexport const US_CORE_BIRTHSEX_EXTENSION =\n \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex\";\n\n/**\n * The code-system `system` URIs the generators reference. Public identity URIs (HL7-published),\n * never the code-system *content*, no SNOMED/LOINC/RxNorm table is bundled.\n */\nexport const SYSTEM = Object.freeze({\n /** FHIR `administrative-gender` (`Patient.gender`). */\n ADMINISTRATIVE_GENDER: \"http://hl7.org/fhir/administrative-gender\",\n /** HL7 Terminology `observation-category`. */\n OBSERVATION_CATEGORY: \"http://terminology.hl7.org/CodeSystem/observation-category\",\n /** HL7 Terminology `condition-category`. */\n CONDITION_CATEGORY: \"http://terminology.hl7.org/CodeSystem/condition-category\",\n /** HL7 Terminology `condition-clinical`. */\n CONDITION_CLINICAL: \"http://terminology.hl7.org/CodeSystem/condition-clinical\",\n /** HL7 Terminology `condition-ver-status`. */\n CONDITION_VER_STATUS: \"http://terminology.hl7.org/CodeSystem/condition-ver-status\",\n /** HL7 v2 `0203` identifier-type (`Identifier.type.coding.code` = `MR`). */\n IDENTIFIER_TYPE: \"http://terminology.hl7.org/CodeSystem/v2-0203\",\n /** OMB race & ethnicity category system (US Core race/ethnicity `ombCategory`). */\n OMB_RACE_ETHNICITY: \"urn:oid:2.16.840.1.113883.6.238\",\n /** LOINC, `Observation.code` (lab + vital-signs). */\n LOINC: \"http://loinc.org\",\n /** SNOMED CT, `Condition.code`. */\n SNOMED: \"http://snomed.info/sct\",\n /** RxNorm, `MedicationRequest.medicationCodeableConcept` + an allergen substance. */\n RXNORM: \"http://www.nlm.nih.gov/research/umls/rxnorm\",\n /** UCUM, `Quantity.system` for units of measure. */\n UCUM: \"http://unitsofmeasure.org\",\n /** CVX (CDC vaccine administered), `Immunization.vaccineCode`. */\n CVX: \"http://hl7.org/fhir/sid/cvx\",\n /** HL7 v3 `ActCode`, `Encounter.class`. */\n V3_ACT_CODE: \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",\n /** HL7 v2 `0074` diagnostic-service-section, `DiagnosticReport.category` (`LAB`). */\n DIAGNOSTIC_SERVICE_SECTION: \"http://terminology.hl7.org/CodeSystem/v2-0074\",\n /** HL7 Terminology `allergyintolerance-clinical`, `AllergyIntolerance.clinicalStatus`. */\n ALLERGY_CLINICAL: \"http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical\",\n /** HL7 Terminology `allergyintolerance-verification`, `AllergyIntolerance.verificationStatus`. */\n ALLERGY_VERIFICATION: \"http://terminology.hl7.org/CodeSystem/allergyintolerance-verification\",\n /** HL7 Terminology `provenance-participant-type`, `Provenance.agent.type` (`author`). */\n PROVENANCE_PARTICIPANT_TYPE: \"http://terminology.hl7.org/CodeSystem/provenance-participant-type\",\n /** US Core `us-core-provenance-participant-type`, `Provenance.agent.type` (`transmitter`). */\n US_CORE_PROVENANCE_PARTICIPANT_TYPE:\n \"http://hl7.org/fhir/us/core/CodeSystem/us-core-provenance-participant-type\",\n} as const);\n\n/** A US Core profile canonical URL. */\nexport type UsCoreProfileUrl = (typeof US_CORE_PROFILE)[keyof typeof US_CORE_PROFILE];\n","/**\n * Shared FHIR model-construction helpers: the small vocabulary every resource generator uses\n * to build **through `@cosyte/fhir`'s own model constructors** (`complex` / `list` / `primitive` /\n * `decimal`). A generated resource is a `FhirComplex` tree assembled here and serialized by\n * `@cosyte/fhir`'s conservative writer, so it is **spec-clean by construction**: the same mechanism\n * that makes the parser's emit side spec-clean. Nothing here hand-writes JSON\n * bytes.\n *\n * Identity fields (`name`, `identifier`, `birthDate`, `telecom`, `address`) are minted from the\n * synthetic-safety providers in `../safe`, so no value a resource carries can be real or plausibly-real\n * PHI. The `fhirPatientIdentity` bundle draws them in a **fixed order** for the\n * reproducibility contract.\n *\n * @module\n */\n\nimport { complex, decimal, list, primitive } from \"@cosyte/fhir\";\nimport type { FhirComplex, FhirNode } from \"@cosyte/fhir\";\n\nimport type { Rng } from \"../rng/rng.js\";\nimport {\n safe,\n type SyntheticName,\n type SyntheticAddress,\n type SyntheticIdentifier,\n} from \"../safe/index.js\";\n\nimport { SYSTEM } from \"./us-core.js\";\n\n/** A named FHIR property (`{ name, value }`): the shape `complex` consumes. */\nexport type Prop = { readonly name: string; readonly value: FhirNode };\n\n/**\n * Build a named FHIR property.\n *\n * @param name - The property name.\n * @param value - The property's node value.\n * @returns A {@link Prop}.\n * @example\n * ```ts\n * import { prop, str } from \"@cosyte/synth/fhir\";\n * prop(\"gender\", str(\"female\"));\n * ```\n */\nexport function prop(name: string, value: FhirNode): Prop {\n return { name, value };\n}\n\n/**\n * A `string`/`code`/`uri`/`date` primitive leaf.\n *\n * @param value - The lexical string value.\n * @returns A primitive `FhirNode`.\n * @example\n * ```ts\n * import { str } from \"@cosyte/synth/fhir\";\n * str(\"final\");\n * ```\n */\nexport function str(value: string): FhirNode {\n return primitive(value);\n}\n\n/**\n * A `decimal` primitive leaf, precision-preserving via `@cosyte/fhir`'s string-backed `FhirDecimal`.\n *\n * @param raw - The exact decimal lexical form (never routed through a JS `number`).\n * @returns A primitive `FhirNode`.\n * @example\n * ```ts\n * import { dec } from \"@cosyte/synth/fhir\";\n * dec(\"6.3\");\n * ```\n */\nexport function dec(raw: string): FhirNode {\n return primitive(decimal(raw));\n}\n\n/**\n * A `boolean` primitive leaf.\n *\n * @param value - The boolean value.\n * @returns A primitive `FhirNode`.\n * @example\n * ```ts\n * import { bool } from \"@cosyte/synth/fhir\";\n * bool(true);\n * ```\n */\nexport function bool(value: boolean): FhirNode {\n return primitive(value);\n}\n\n/**\n * A single `Coding` element (`system` + `code` + `display`).\n *\n * @param concept - The coding's `system`, `code`, and `display`.\n * @returns A `Coding` `FhirComplex`.\n * @example\n * ```ts\n * import { coding } from \"@cosyte/synth/fhir\";\n * coding({ system: \"http://loinc.org\", code: \"2345-7\", display: \"Glucose\" });\n * ```\n */\nexport function coding(concept: { system: string; code: string; display: string }): FhirComplex {\n return complex([\n prop(\"system\", str(concept.system)),\n prop(\"code\", str(concept.code)),\n prop(\"display\", str(concept.display)),\n ]);\n}\n\n/**\n * A `CodeableConcept` wrapping a single `Coding`.\n *\n * @param concept - The coding's `system`, `code`, and `display`.\n * @returns A `CodeableConcept` `FhirComplex`.\n * @example\n * ```ts\n * import { codeableConcept } from \"@cosyte/synth/fhir\";\n * codeableConcept({ system: \"http://snomed.info/sct\", code: \"59621000\", display: \"Essential hypertension\" });\n * ```\n */\nexport function codeableConcept(concept: {\n system: string;\n code: string;\n display: string;\n}): FhirComplex {\n return complex([prop(\"coding\", list([coding(concept)]))]);\n}\n\n/**\n * A literal `Reference` element (`{ reference: \"<Type>/<id>\" }` or a `urn:uuid:` fullUrl).\n *\n * @param ref - The reference string.\n * @returns A `Reference` `FhirComplex`.\n * @example\n * ```ts\n * import { reference } from \"@cosyte/synth/fhir\";\n * reference(\"Patient/syn-patient-1\");\n * ```\n */\nexport function reference(ref: string): FhirComplex {\n return complex([prop(\"reference\", str(ref))]);\n}\n\n/**\n * A generated `Narrative` (`text`) with `status: \"generated\"` and an XHTML `div` carrying only\n * synthetic text, satisfies the base `dom-6` best-practice constraint so a generated resource is\n * robust as well as valid. The `div` is XHTML-namespaced and carries no markup beyond a paragraph, so\n * it round-trips byte-for-byte through `@cosyte/fhir`'s codec.\n *\n * @param text - The plain synthetic summary text (no PHI: it is composed from synthetic values).\n * @returns A `Narrative` `FhirComplex`.\n * @example\n * ```ts\n * import { narrative } from \"@cosyte/synth/fhir\";\n * narrative(\"Synthetic patient summary.\");\n * ```\n */\nexport function narrative(text: string): FhirComplex {\n const escaped = text.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n return complex([\n prop(\"status\", str(\"generated\")),\n prop(\"div\", str(`<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>${escaped}</p></div>`)),\n ]);\n}\n\n/**\n * A `meta.profile` element pinning the resource to one or more canonical profile URLs (US Core\n * conformance is claimed via `meta.profile`). No version is pinned, so validating against any supplied\n * version of the named profile never raises a version-mismatch.\n *\n * @param profiles - The canonical profile URLs to claim.\n * @returns A `meta` `FhirComplex`.\n * @example\n * ```ts\n * import { meta, US_CORE_PROFILE } from \"@cosyte/synth/fhir\";\n * meta([US_CORE_PROFILE.PATIENT]);\n * ```\n */\nexport function meta(profiles: readonly string[]): FhirComplex {\n return complex([prop(\"profile\", list(profiles.map((p) => str(p))))]);\n}\n\n/** A synthetic FHIR patient identity: every field drawn from `../safe`. */\nexport interface FhirPatientIdentity {\n /** A synthetic resource `id` (a seeded UUID), never a real record key. */\n readonly id: string;\n /** Name from the shipped fake-name pool. */\n readonly person: SyntheticName;\n /** Medical-record identifier scoped to the synthetic assigning authority. */\n readonly mrn: SyntheticIdentifier;\n /** Date of birth as a FHIR `date` (`YYYY-MM-DD`) from the seeded generator. */\n readonly birthDate: string;\n /** FHIR administrative-gender code. */\n readonly gender: \"male\" | \"female\";\n /** Synthetic postal address (reserved non-real ZIP). */\n readonly address: SyntheticAddress;\n /** Reserved `555-01xx` phone number. */\n readonly phone: string;\n /** Synthetic email at a reserved (`example.*`) domain. */\n readonly email: string;\n}\n\n/**\n * Reformat a `YYYYMMDD` synthetic date (from `safe.dateYmd`) as a FHIR `date` (`YYYY-MM-DD`).\n *\n * @param ymd - The `YYYYMMDD` date string.\n * @returns The `YYYY-MM-DD` FHIR date string.\n * @example\n * ```ts\n * import { toFhirDate } from \"@cosyte/synth/fhir\";\n * toFhirDate(\"19700131\"); // \"1970-01-31\"\n * ```\n */\nexport function toFhirDate(ymd: string): string {\n return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;\n}\n\n/**\n * Mint a complete synthetic {@link FhirPatientIdentity}. Every value comes from a synthetic-safety\n * provider, no code path here can return a real or plausibly-real identifier. The draw\n * order is fixed (id → name → MRN → DOB → gender → address → phone → email) so the same seed yields the\n * same identity.\n *\n * @param rng - The seeded generator.\n * @returns A synthetic {@link FhirPatientIdentity}.\n * @example\n * ```ts\n * import { createRng } from \"@cosyte/synth\";\n * // const id = fhirPatientIdentity(createRng(1)); // id.person, id.mrn, …\n * ```\n */\nexport function fhirPatientIdentity(rng: Rng): FhirPatientIdentity {\n const id = safe.uuid(rng);\n const person = safe.name(rng);\n const mrn = safe.identifier(rng, \"MR\");\n const birthDate = toFhirDate(safe.dateYmd(rng, 1930, 2010));\n const gender = rng.pick([\"male\", \"female\"] as const);\n const address = safe.address(rng);\n const phone = safe.phone(rng);\n const email = safe.email(rng, person);\n return { id, person, mrn, birthDate, gender, address, phone, email };\n}\n\n/**\n * The US Core Patient `identifier` element for a synthetic MRN: `type` (`MR`), the synthetic\n * assigning-authority OID as `system`, and the synthetic value. Satisfies US Core Patient's required\n * `identifier.system` + `identifier.value`.\n *\n * @param mrn - The synthetic identifier from `safe.identifier`.\n * @returns An `Identifier` `FhirComplex`.\n * @example\n * ```ts\n * import { createRng, safe } from \"@cosyte/synth\";\n * import { mrnIdentifier } from \"@cosyte/synth/fhir\";\n * mrnIdentifier(safe.identifier(createRng(1), \"MR\"));\n * ```\n */\nexport function mrnIdentifier(mrn: SyntheticIdentifier): FhirComplex {\n return complex([\n prop(\n \"type\",\n complex([\n prop(\n \"coding\",\n list([\n coding({\n system: SYSTEM.IDENTIFIER_TYPE,\n code: \"MR\",\n display: \"Medical Record Number\",\n }),\n ]),\n ),\n ]),\n ),\n prop(\"system\", str(`urn:oid:${mrn.assigningAuthorityOid}`)),\n prop(\"value\", str(mrn.value)),\n ]);\n}\n","/**\n * A tiny, curated, **license-clean** pool of example codes for filling coded fields in generated FHIR\n * resources (`Observation.code`, `Condition.code`, `MedicationRequest.medication[x]`, and the OMB\n * race/ethnicity categories). These are **public code facts**: codes drawn from the published FHIR R4\n * and US Core specification examples, not copyrighted terminology tables: `@cosyte/synth` bundles\n * **no** SNOMED/LOINC/RxNorm content. The pool exists only so a\n * generated resource is *structurally* realistic; a consumer who needs their own codes supplies them.\n *\n * Nothing here is PHI: codes and their display text are not patient identifiers. The synthetic-safety\n * invariant governs identity fields (name/DOB/identifier/telecom/address), which come from `../safe`.\n *\n * @module\n */\n\n/** A coded concept: a `system` URI, a `code`, and its human-readable `display`. */\nexport interface CodeConcept {\n /** The code-system URI (`Coding.system`). */\n readonly system: string;\n /** The code value (`Coding.code`). */\n readonly code: string;\n /** The human-readable display text (`Coding.display`). */\n readonly display: string;\n}\n\n/**\n * A quantitative observation concept: a LOINC code plus the UCUM unit and a plausible synthetic value\n * range the seeded generator draws within. The range implies **no** real measurement: it only keeps a\n * generated result inside a structurally-sane band.\n */\nexport interface QuantConcept extends CodeConcept {\n /** The UCUM unit code (`Quantity.code` and, as text, `Quantity.unit`). */\n readonly unit: string;\n /** Inclusive lower bound of the synthetic value (in `unit`). */\n readonly low: number;\n /** Inclusive upper bound of the synthetic value (in `unit`). */\n readonly high: number;\n /** Decimal places to render (keeps the emitted `decimal` lexical form stable and realistic). */\n readonly decimals: number;\n}\n\nimport { SYSTEM } from \"./us-core.js\";\n\n/**\n * LOINC laboratory-result example codes (for a US Core Laboratory Result `Observation`). Public LOINC\n * identifiers used purely as illustrative structural fillers, with UCUM units and synthetic value bands.\n */\nexport const EXAMPLE_LAB_OBSERVATIONS: readonly QuantConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"2345-7\",\n display: \"Glucose [Mass/volume] in Serum or Plasma\",\n unit: \"mg/dL\",\n low: 70,\n high: 140,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"718-7\",\n display: \"Hemoglobin [Mass/volume] in Blood\",\n unit: \"g/dL\",\n low: 12,\n high: 17,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"2951-2\",\n display: \"Sodium [Moles/volume] in Serum or Plasma\",\n unit: \"mmol/L\",\n low: 135,\n high: 145,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"2823-3\",\n display: \"Potassium [Moles/volume] in Serum or Plasma\",\n unit: \"mmol/L\",\n low: 4,\n high: 5,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"4548-4\",\n display: \"Hemoglobin A1c/Hemoglobin.total in Blood\",\n unit: \"%\",\n low: 4,\n high: 9,\n decimals: 1,\n }),\n]);\n\n/**\n * LOINC vital-sign example codes (for a US Core Vital Signs `Observation`). Public LOINC identifiers\n * with their required UCUM units and synthetic value bands. Simple single-value vitals only:\n * multi-component vitals (e.g. blood-pressure panel `85354-9`) are not generated.\n */\nexport const EXAMPLE_VITAL_SIGNS: readonly QuantConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"8867-4\",\n display: \"Heart rate\",\n unit: \"/min\",\n low: 55,\n high: 100,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"9279-1\",\n display: \"Respiratory rate\",\n unit: \"/min\",\n low: 12,\n high: 20,\n decimals: 0,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"8310-5\",\n display: \"Body temperature\",\n unit: \"Cel\",\n low: 36,\n high: 38,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"29463-7\",\n display: \"Body weight\",\n unit: \"kg\",\n low: 50,\n high: 100,\n decimals: 1,\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"8302-2\",\n display: \"Body height\",\n unit: \"cm\",\n low: 150,\n high: 190,\n decimals: 0,\n }),\n]);\n\n/**\n * SNOMED CT problem/condition example codes (for a US Core `Condition.code`). Public SNOMED identifiers\n * used as structural fillers; `@cosyte/synth` bundles no SNOMED content.\n */\nexport const EXAMPLE_CONDITIONS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.SNOMED, code: \"59621000\", display: \"Essential hypertension\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"44054006\", display: \"Type 2 diabetes mellitus\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"195967001\", display: \"Asthma\" }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"13645005\",\n display: \"Chronic obstructive lung disease\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"38341003\", display: \"Hypertensive disorder\" }),\n]);\n\n/**\n * RxNorm medication example codes (for a US Core `MedicationRequest.medicationCodeableConcept`). Public\n * RxNorm identifiers used as structural fillers; `@cosyte/synth` bundles no RxNorm content.\n */\nexport const EXAMPLE_MEDICATIONS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"1049221\",\n display: \"Acetaminophen 325 MG Oral Tablet\",\n }),\n Object.freeze({ system: SYSTEM.RXNORM, code: \"197361\", display: \"Amlodipine 5 MG Oral Tablet\" }),\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"860975\",\n display: \"24 HR Metformin hydrochloride 500 MG Extended Release Oral Tablet\",\n }),\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"308136\",\n display: \"Amoxicillin 250 MG Oral Capsule\",\n }),\n Object.freeze({\n system: SYSTEM.RXNORM,\n code: \"617314\",\n display: \"Atorvastatin 40 MG Oral Tablet\",\n }),\n]);\n\n/**\n * OMB race categories (US Core `us-core-race` `ombCategory`): the five OMB categories, public code\n * facts from the CDC Race &amp; Ethnicity code system (`urn:oid:2.16.840.1.113883.6.238`).\n */\nexport const EXAMPLE_RACE_CATEGORIES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.OMB_RACE_ETHNICITY, code: \"2106-3\", display: \"White\" }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2054-5\",\n display: \"Black or African American\",\n }),\n Object.freeze({ system: SYSTEM.OMB_RACE_ETHNICITY, code: \"2028-9\", display: \"Asian\" }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"1002-5\",\n display: \"American Indian or Alaska Native\",\n }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2076-8\",\n display: \"Native Hawaiian or Other Pacific Islander\",\n }),\n]);\n\n/**\n * OMB ethnicity categories (US Core `us-core-ethnicity` `ombCategory`): the two OMB categories, public\n * code facts from the CDC Race &amp; Ethnicity code system.\n */\nexport const EXAMPLE_ETHNICITY_CATEGORIES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2135-2\",\n display: \"Hispanic or Latino\",\n }),\n Object.freeze({\n system: SYSTEM.OMB_RACE_ETHNICITY,\n code: \"2186-5\",\n display: \"Not Hispanic or Latino\",\n }),\n]);\n\n/**\n * CVX vaccine-administered example codes (for a US Core `Immunization.vaccineCode`). Public CDC CVX\n * identifiers used as structural fillers; `@cosyte/synth` bundles no CVX content.\n */\nexport const EXAMPLE_VACCINES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.CVX,\n code: \"140\",\n display: \"Influenza, seasonal, injectable, preservative free\",\n }),\n Object.freeze({ system: SYSTEM.CVX, code: \"03\", display: \"MMR\" }),\n Object.freeze({ system: SYSTEM.CVX, code: \"20\", display: \"DTaP\" }),\n Object.freeze({ system: SYSTEM.CVX, code: \"133\", display: \"Pneumococcal conjugate PCV 13\" }),\n Object.freeze({\n system: SYSTEM.CVX,\n code: \"208\",\n display: \"COVID-19, mRNA, LNP-S, PF, 30 mcg/0.3 mL dose\",\n }),\n]);\n\n/**\n * Allergen-substance example codes (for a US Core `AllergyIntolerance.code`). Public RxNorm / SNOMED CT\n * identifiers used as structural fillers; no terminology content is bundled.\n */\nexport const EXAMPLE_ALLERGENS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.RXNORM, code: \"7980\", display: \"Penicillin G\" }),\n Object.freeze({ system: SYSTEM.RXNORM, code: \"2670\", display: \"Codeine\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"762952008\", display: \"Peanut (substance)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"227493005\", display: \"Cashew nuts (substance)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"3718001\", display: \"Cow's milk (substance)\" }),\n]);\n\n/**\n * Allergy-reaction manifestation example codes (for `AllergyIntolerance.reaction.manifestation`).\n * Public SNOMED CT clinical-finding identifiers used as structural fillers.\n */\nexport const EXAMPLE_ALLERGY_MANIFESTATIONS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.SNOMED, code: \"247472004\", display: \"Wheal (finding)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"126485001\", display: \"Urticaria (disorder)\" }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"271807003\",\n display: \"Eruption of skin (disorder)\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"267036007\", display: \"Dyspnea (finding)\" }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"422587007\", display: \"Nausea (finding)\" }),\n]);\n\n/**\n * SNOMED CT procedure example codes (for a US Core `Procedure.code`). Public SNOMED identifiers used as\n * structural fillers, **not** CPT (which is never bundled).\n */\nexport const EXAMPLE_PROCEDURES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"80146002\",\n display: \"Excision of appendix (procedure)\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"73761001\", display: \"Colonoscopy (procedure)\" }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"5880005\",\n display: \"Physical examination procedure (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"108252007\",\n display: \"Laboratory procedure (procedure)\",\n }),\n Object.freeze({ system: SYSTEM.SNOMED, code: \"71651007\", display: \"Mammography (procedure)\" }),\n]);\n\n/**\n * LOINC diagnostic-report example codes (for a US Core Laboratory `DiagnosticReport.code`). Public LOINC\n * panel identifiers used as structural fillers.\n */\nexport const EXAMPLE_DIAGNOSTIC_REPORTS: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24323-8\",\n display: \"Comprehensive metabolic 2000 panel - Serum or Plasma\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"58410-2\",\n display: \"CBC panel - Blood by Automated count\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24357-6\",\n display: \"Urinalysis complete panel - Urine\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24331-1\",\n display: \"Lipid 1996 panel - Serum or Plasma\",\n }),\n Object.freeze({\n system: SYSTEM.LOINC,\n code: \"24321-2\",\n display: \"Basic metabolic 1998 panel - Serum or Plasma\",\n }),\n]);\n\n/**\n * SNOMED CT encounter-type example codes (for a US Core `Encounter.type`). Public SNOMED identifiers\n * used as structural fillers.\n */\nexport const EXAMPLE_ENCOUNTER_TYPES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"308335008\",\n display: \"Patient encounter procedure (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"185349003\",\n display: \"Encounter for check up (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"185347001\",\n display: \"Encounter for problem (procedure)\",\n }),\n Object.freeze({\n system: SYSTEM.SNOMED,\n code: \"390906007\",\n display: \"Follow-up encounter (procedure)\",\n }),\n]);\n\n/**\n * HL7 v3 `ActCode` encounter-class example codes (for `Encounter.class`, a single `Coding`). Public\n * ActCode identifiers used as structural fillers.\n */\nexport const EXAMPLE_ENCOUNTER_CLASSES: readonly CodeConcept[] = Object.freeze([\n Object.freeze({ system: SYSTEM.V3_ACT_CODE, code: \"AMB\", display: \"ambulatory\" }),\n Object.freeze({ system: SYSTEM.V3_ACT_CODE, code: \"EMER\", display: \"emergency\" }),\n Object.freeze({ system: SYSTEM.V3_ACT_CODE, code: \"IMP\", display: \"inpatient encounter\" }),\n]);\n","/**\n * The **selector chokepoint**. A generator's options are almost all *selectors*: a message kind, a\n * document type, a corpus mix, a claim variant, a Bundle type, a profile. Each is typed as a closed\n * union, and every one of those unions is **erased at run time**, so a JavaScript caller (or a\n * `as never` in someone's test) reaches the branch with any string at all.\n *\n * Three things went wrong when that was left unchecked, and they are all the same bug:\n *\n * 1. **The value reached a diagnostic.** An unrecognised `documentType` travelled into\n * `@cosyte/ccda`'s `buildCcda`, which is entitled to quote it back in its own `TypeError` and\n * does. This package then has a caller-supplied string on an `err.message` and an `err.stack`,\n * through its own public entry point, having taken no care of it.\n * 2. **The value reached the model.** A corpus mix entry becomes an `Artifact.kind` and a\n * `manifest.counts` key, which is precisely the structural-identifier position a downstream\n * package interpolates to describe a location.\n * 3. **The fixture was silently mislabeled.** An exhaustive `switch` over an erased union takes no\n * branch and returns `undefined`, or a trailing `else` quietly generates something else. A corpus\n * whose manifest says it holds one transaction and holds another is a golden file that lies.\n *\n * So a selector is resolved against its own set, once, before anything is generated, and an\n * unrecognised one is a fatal `SYNTH_UNSUPPORTED_KIND`. Like every fatal here it carries a code and a\n * fixed message, and quotes neither the request nor the set.\n *\n * @module\n */\n\nimport { SYNTH_FATAL_CODES, SynthError } from \"./codes.js\";\n\n/**\n * Resolve one caller-supplied selector against the closed set that governs it, or **fail closed**.\n *\n * @param allowed - Every value the selector may take.\n * @param requested - The selector the caller supplied.\n * @returns `requested`, narrowed to the union.\n * @throws SynthError `SYNTH_UNSUPPORTED_KIND` when `requested` is not in `allowed`.\n * @example\n * ```ts\n * import { resolveKind } from \"@cosyte/synth\";\n * resolveKind([\"ccd\", \"referralNote\"] as const, \"ccd\"); // \"ccd\"\n * ```\n */\nexport function resolveKind<T extends string>(allowed: readonly T[], requested: string): T {\n const match = allowed.find((value) => value === requested);\n if (match === undefined) throw new SynthError(SYNTH_FATAL_CODES.SYNTH_UNSUPPORTED_KIND);\n return match;\n}\n\n/**\n * Resolve every entry of a caller-supplied corpus mix, in order, or **fail closed** on the first\n * unrecognised one.\n *\n * It substitutes the default **only** when the caller supplied nothing, which is exactly what the\n * `??` it replaced did. An empty array is a supplied mix and is returned as one. An earlier version\n * of this function also treated `[]` as \"nothing supplied\", on the stated grounds that it matched the\n * previous behaviour; it did not: `??` fires on `undefined` and never on `[]`, and it changed the\n * result of six published entry points, turning an explicit empty selection into \"generate one of\n * everything\". A convenience that fails open is not a convenience.\n *\n * @param allowed - Every kind the corpus may generate.\n * @param requested - The mix the caller supplied, or `undefined` for the default.\n * @param fallback - The default mix, used only when `requested` is `undefined`.\n * @returns The resolved mix.\n * @throws SynthError `SYNTH_UNSUPPORTED_KIND` on the first unrecognised entry.\n * @example\n * ```ts\n * import { resolveMix } from \"@cosyte/synth\";\n * resolveMix([\"Result\", \"Order\"] as const, [\"Order\"], [\"Result\", \"Order\"]); // [\"Order\"]\n * ```\n */\nexport function resolveMix<T extends string>(\n allowed: readonly T[],\n requested: readonly string[] | undefined,\n fallback: readonly T[],\n): readonly T[] {\n if (requested === undefined) return fallback;\n return requested.map((entry) => resolveKind(allowed, entry));\n}\n","/**\n * Synthetic FHIR R4 **`Patient`** generation: the anchor of the US Core clinical spine. Built through\n * `@cosyte/fhir`'s model constructors, every identity field drawn from the\n * synthetic-safety providers. In `us-core` mode the resource claims US Core Patient via\n * `meta.profile`, satisfies its required elements (`identifier` + `system` + `value`, `name`, `gender`),\n * and carries the must-support race / ethnicity / birthsex extensions.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport {\n bool,\n coding,\n fhirPatientIdentity,\n meta,\n mrnIdentifier,\n narrative,\n prop,\n str,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_ETHNICITY_CATEGORIES, EXAMPLE_RACE_CATEGORIES } from \"./example-codes.js\";\nimport {\n US_CORE_BIRTHSEX_EXTENSION,\n US_CORE_ETHNICITY_EXTENSION,\n US_CORE_PROFILE,\n US_CORE_RACE_EXTENSION,\n} from \"./us-core.js\";\nimport { resolveKind } from \"../select.js\";\n\n/** Every value {@link GeneratePatientOptions.profile} admits. Erased at run time, so it is resolved. */\nconst PATIENT_PROFILES: readonly (\"base\" | \"us-core\")[] = Object.freeze([\"base\", \"us-core\"]);\n\n/** Options for {@link generatePatient}. */\nexport interface GeneratePatientOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /**\n * The profile posture. `\"base\"` (default) emits a spec-clean base-R4 `Patient`; `\"us-core\"` adds the\n * US Core `meta.profile` and the race/ethnicity/birthsex must-support extensions (the required\n * elements, identifier/name/gender, are always present).\n */\n readonly profile?: \"base\" | \"us-core\";\n}\n\n/** A US Core `us-core-race` / `us-core-ethnicity` complex extension with one OMB category + text. */\nfunction ombExtension(\n url: string,\n category: { system: string; code: string; display: string },\n): FhirComplex {\n return complex([\n prop(\"url\", str(url)),\n prop(\n \"extension\",\n list([\n complex([prop(\"url\", str(\"ombCategory\")), prop(\"valueCoding\", coding(category))]),\n complex([prop(\"url\", str(\"text\")), prop(\"valueString\", str(category.display))]),\n ]),\n ),\n ]);\n}\n\n/**\n * Generate a spec-clean synthetic FHIR R4 `Patient` (base or US Core), built through `@cosyte/fhir`.\n *\n * @param options - Seed and profile posture. See {@link GeneratePatientOptions}.\n * @returns The `Patient` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generatePatient } from \"@cosyte/synth/fhir\";\n * import { serializeResource } from \"@cosyte/fhir\";\n * const patient = generatePatient({ seed: 42, profile: \"us-core\" });\n * serializeResource(patient);\n * ```\n */\nexport function generatePatient(options: GeneratePatientOptions = {}): FhirComplex {\n const { seed = 0 } = options;\n const profile = resolveKind(PATIENT_PROFILES, options.profile ?? \"base\");\n const rng = createRng(seed);\n const id = fhirPatientIdentity(rng);\n const usCore = profile === \"us-core\";\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Patient\")),\n prop(\"id\", str(`syn-patient-${id.id}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.PATIENT])));\n props.push(\n prop(\n \"text\",\n narrative(\n `Synthetic patient ${id.person.given} ${id.person.family} (${id.gender}, born ${id.birthDate}).`,\n ),\n ),\n );\n\n if (usCore) {\n const race = rng.pick(EXAMPLE_RACE_CATEGORIES);\n const ethnicity = rng.pick(EXAMPLE_ETHNICITY_CATEGORIES);\n const birthsex = id.gender === \"male\" ? \"M\" : \"F\";\n props.push(\n prop(\n \"extension\",\n list([\n ombExtension(US_CORE_RACE_EXTENSION, race),\n ombExtension(US_CORE_ETHNICITY_EXTENSION, ethnicity),\n complex([prop(\"url\", str(US_CORE_BIRTHSEX_EXTENSION)), prop(\"valueCode\", str(birthsex))]),\n ]),\n ),\n );\n }\n\n props.push(prop(\"identifier\", list([mrnIdentifier(id.mrn)])));\n props.push(prop(\"active\", bool(true)));\n props.push(\n prop(\n \"name\",\n list([\n complex([\n prop(\"use\", str(\"official\")),\n prop(\"family\", str(id.person.family)),\n prop(\"given\", list([str(id.person.given)])),\n ]),\n ]),\n ),\n );\n props.push(\n prop(\n \"telecom\",\n list([\n complex([\n prop(\"system\", str(\"phone\")),\n prop(\"value\", str(id.phone)),\n prop(\"use\", str(\"home\")),\n ]),\n complex([prop(\"system\", str(\"email\")), prop(\"value\", str(id.email))]),\n ]),\n ),\n );\n props.push(prop(\"gender\", str(id.gender)));\n props.push(prop(\"birthDate\", str(id.birthDate)));\n props.push(\n prop(\n \"address\",\n list([\n complex([\n prop(\"use\", str(\"home\")),\n prop(\"line\", list([str(id.address.street)])),\n prop(\"city\", str(id.address.city)),\n prop(\"state\", str(id.address.state)),\n prop(\"postalCode\", str(id.address.zip)),\n ]),\n ]),\n ),\n );\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Condition`** generation: a US Core \"Problems and Health Concerns\" problem-list\n * item. Built through `@cosyte/fhir`; the `code` comes from the license-clean SNOMED\n * example pool, the `subject` from a supplied or derived synthetic Patient reference.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { codeableConcept, meta, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { EXAMPLE_CONDITIONS } from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateCondition}. */\nexport interface GenerateConditionOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Condition` (problem-list item), built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject reference, and US Core posture. See {@link GenerateConditionOptions}.\n * @returns The `Condition` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateCondition } from \"@cosyte/synth/fhir\";\n * const condition = generateCondition({ seed: 7, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateCondition(options: GenerateConditionOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const code = rng.pick(EXAMPLE_CONDITIONS);\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Condition\")),\n prop(\"id\", str(`syn-cond-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.CONDITION])));\n props.push(prop(\"text\", narrative(`Synthetic condition: ${code.display}.`)));\n props.push(\n prop(\n \"clinicalStatus\",\n codeableConcept({ system: SYSTEM.CONDITION_CLINICAL, code: \"active\", display: \"Active\" }),\n ),\n );\n props.push(\n prop(\n \"verificationStatus\",\n codeableConcept({\n system: SYSTEM.CONDITION_VER_STATUS,\n code: \"confirmed\",\n display: \"Confirmed\",\n }),\n ),\n );\n props.push(\n prop(\n \"category\",\n list([\n codeableConcept({\n system: SYSTEM.CONDITION_CATEGORY,\n code: \"problem-list-item\",\n display: \"Problem List Item\",\n }),\n ]),\n ),\n );\n props.push(prop(\"code\", codeableConcept(code)));\n props.push(prop(\"subject\", reference(subject)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Observation`** generation: US Core Laboratory Result and US Core Vital Signs. Built\n * through `@cosyte/fhir`; `code` and the measured `valueQuantity` come from\n * the license-clean LOINC/UCUM example pool, `subject` from a supplied or derived Patient reference.\n * The measured value is drawn from the seeded generator within a structurally-sane band: it implies no\n * real measurement.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng, type Rng } from \"../rng/rng.js\";\nimport {\n codeableConcept,\n dec,\n meta,\n narrative,\n prop,\n reference,\n str,\n type Prop,\n} from \"./builder.js\";\nimport {\n EXAMPLE_LAB_OBSERVATIONS,\n EXAMPLE_VITAL_SIGNS,\n type QuantConcept,\n} from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateObservationLab} / {@link generateVitalSign}. */\nexport interface GenerateObservationOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/** Draw a synthetic `decimal` value string within the concept's band, at its declared precision. */\nfunction drawValue(rng: Rng, concept: QuantConcept): string {\n const span = concept.high - concept.low;\n const raw = concept.low + rng.float() * span;\n return raw.toFixed(concept.decimals);\n}\n\n/** A UCUM `valueQuantity` for a measured concept: `value` (decimal), `unit`, UCUM `system` + `code`. */\nfunction valueQuantity(rng: Rng, concept: QuantConcept): FhirComplex {\n return complex([\n prop(\"value\", dec(drawValue(rng, concept))),\n prop(\"unit\", str(concept.unit)),\n prop(\"system\", str(SYSTEM.UCUM)),\n prop(\"code\", str(concept.unit)),\n ]);\n}\n\n/** Build an `Observation` of the given category from a measured concept pool. */\nfunction buildObservation(\n seed: number,\n subject: string,\n usCore: boolean,\n profileUrl: string,\n category: { code: string; display: string },\n pool: readonly QuantConcept[],\n effective: boolean,\n): FhirComplex {\n const rng = createRng(seed);\n const concept = rng.pick(pool);\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Observation\")),\n prop(\"id\", str(`syn-obs-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([profileUrl])));\n props.push(\n prop(\"text\", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`)),\n );\n props.push(prop(\"status\", str(\"final\")));\n props.push(\n prop(\n \"category\",\n list([\n codeableConcept({\n system: SYSTEM.OBSERVATION_CATEGORY,\n code: category.code,\n display: category.display,\n }),\n ]),\n ),\n );\n props.push(prop(\"code\", codeableConcept(concept)));\n props.push(prop(\"subject\", reference(subject)));\n // Draw the effective instant deterministically (a plausible recent date) before the value.\n const y = rng.int(2020, 2025);\n const m = String(rng.int(1, 12)).padStart(2, \"0\");\n const d = String(rng.int(1, 28)).padStart(2, \"0\");\n if (effective) props.push(prop(\"effectiveDateTime\", str(`${String(y)}-${m}-${d}`)));\n props.push(prop(\"valueQuantity\", valueQuantity(rng, concept)));\n return complex(props);\n}\n\n/**\n * Generate a spec-clean synthetic US Core **Laboratory Result** `Observation`.\n *\n * @param options - Seed, subject reference, US Core posture. See {@link GenerateObservationOptions}.\n * @returns The `Observation` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateObservationLab } from \"@cosyte/synth/fhir\";\n * const obs = generateObservationLab({ seed: 3, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateObservationLab(options: GenerateObservationOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n return buildObservation(\n seed,\n subject,\n usCore,\n US_CORE_PROFILE.OBSERVATION_LAB,\n { code: \"laboratory\", display: \"Laboratory\" },\n EXAMPLE_LAB_OBSERVATIONS,\n false,\n );\n}\n\n/**\n * Generate a spec-clean synthetic US Core **Vital Signs** `Observation` (a single-value vital such as\n * heart rate or body weight; `effectiveDateTime` is required by the vital-signs profile).\n *\n * @param options - Seed, subject reference, US Core posture. See {@link GenerateObservationOptions}.\n * @returns The `Observation` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateVitalSign } from \"@cosyte/synth/fhir\";\n * const vs = generateVitalSign({ seed: 5, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateVitalSign(options: GenerateObservationOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n return buildObservation(\n seed,\n subject,\n usCore,\n US_CORE_PROFILE.VITAL_SIGNS,\n { code: \"vital-signs\", display: \"Vital Signs\" },\n EXAMPLE_VITAL_SIGNS,\n true,\n );\n}\n","/**\n * Synthetic FHIR R4 **`MedicationRequest`** generation: a US Core MedicationRequest with an inline\n * `medicationCodeableConcept`. Built through `@cosyte/fhir`; the medication comes\n * from the license-clean RxNorm example pool. US Core invariant `us-core-21` requires a `requester`\n * whenever `intent = order`, so a synthetic requester reference is always emitted.\n *\n * @module\n */\n\nimport { complex } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { codeableConcept, meta, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { EXAMPLE_MEDICATIONS } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateMedicationRequest}. */\nexport interface GenerateMedicationRequestOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** The `requester` reference. Defaults to a synthetic `Practitioner` reference. */\n readonly requester?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `MedicationRequest`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject/requester references, US Core posture.\n * @returns The `MedicationRequest` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateMedicationRequest } from \"@cosyte/synth/fhir\";\n * const mr = generateMedicationRequest({ seed: 9, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateMedicationRequest(\n options: GenerateMedicationRequestOptions = {},\n): FhirComplex {\n const {\n seed = 0,\n subject = \"Patient/syn-patient-1\",\n requester = \"Practitioner/syn-practitioner-1\",\n usCore = true,\n } = options;\n const rng = createRng(seed);\n const med = rng.pick(EXAMPLE_MEDICATIONS);\n const y = rng.int(2020, 2025);\n const m = String(rng.int(1, 12)).padStart(2, \"0\");\n const d = String(rng.int(1, 28)).padStart(2, \"0\");\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"MedicationRequest\")),\n prop(\"id\", str(`syn-medreq-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));\n props.push(prop(\"text\", narrative(`Synthetic medication order: ${med.display}.`)));\n props.push(prop(\"status\", str(\"active\")));\n props.push(prop(\"intent\", str(\"order\")));\n props.push(prop(\"medicationCodeableConcept\", codeableConcept(med)));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"authoredOn\", str(`${String(y)}-${m}-${d}`)));\n props.push(prop(\"requester\", reference(requester)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Encounter`** generation: a US Core Encounter. Built through `@cosyte/fhir`'s model\n * constructors; `class` and `type` come from the\n * license-clean v3-ActCode / SNOMED example pools, `subject` from a supplied or derived synthetic\n * Patient reference. The required elements (`status`, `class`, `type`, `subject`) are always present.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n coding,\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_ENCOUNTER_CLASSES, EXAMPLE_ENCOUNTER_TYPES } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateEncounter}. */\nexport interface GenerateEncounterOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Encounter`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject reference, and US Core posture. See {@link GenerateEncounterOptions}.\n * @returns The `Encounter` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateEncounter } from \"@cosyte/synth/fhir\";\n * const encounter = generateEncounter({ seed: 11, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateEncounter(options: GenerateEncounterOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const cls = rng.pick(EXAMPLE_ENCOUNTER_CLASSES);\n const type = rng.pick(EXAMPLE_ENCOUNTER_TYPES);\n const id = safe.identifier(rng, \"AN\");\n const start = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Encounter\")),\n prop(\"id\", str(`syn-enc-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.ENCOUNTER])));\n props.push(prop(\"text\", narrative(`Synthetic encounter: ${type.display}.`)));\n props.push(\n prop(\n \"identifier\",\n list([\n complex([\n prop(\"system\", str(`urn:oid:${id.assigningAuthorityOid}`)),\n prop(\"value\", str(id.value)),\n ]),\n ]),\n ),\n );\n props.push(prop(\"status\", str(\"finished\")));\n props.push(prop(\"class\", coding(cls)));\n props.push(prop(\"type\", list([codeableConcept(type)])));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"period\", complex([prop(\"start\", str(`${start}T09:00:00Z`))])));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Immunization`** generation: a US Core Immunization. Built through `@cosyte/fhir`;\n * `vaccineCode` comes from the license-clean CVX example\n * pool, `patient` from a supplied or derived synthetic Patient reference. The required elements\n * (`status`, `vaccineCode`, `patient`, `occurrenceDateTime`) are always present.\n *\n * @module\n */\n\nimport { complex } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n bool,\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_VACCINES } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateImmunization}. */\nexport interface GenerateImmunizationOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `patient` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly patient?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Immunization`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, patient reference, and US Core posture. See {@link GenerateImmunizationOptions}.\n * @returns The `Immunization` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateImmunization } from \"@cosyte/synth/fhir\";\n * const imm = generateImmunization({ seed: 13, patient: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateImmunization(options: GenerateImmunizationOptions = {}): FhirComplex {\n const { seed = 0, patient = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const vaccine = rng.pick(EXAMPLE_VACCINES);\n const occurrence = toFhirDate(safe.dateYmd(rng, 2015, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Immunization\")),\n prop(\"id\", str(`syn-imm-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.IMMUNIZATION])));\n props.push(prop(\"text\", narrative(`Synthetic immunization: ${vaccine.display}.`)));\n props.push(prop(\"status\", str(\"completed\")));\n props.push(prop(\"vaccineCode\", codeableConcept(vaccine)));\n props.push(prop(\"patient\", reference(patient)));\n props.push(prop(\"occurrenceDateTime\", str(occurrence)));\n props.push(prop(\"primarySource\", bool(true)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`AllergyIntolerance`** generation: a US Core AllergyIntolerance. Built through\n * `@cosyte/fhir`; the allergen `code` and reaction\n * `manifestation` come from the license-clean RxNorm/SNOMED example pools, `patient` from a supplied or\n * derived synthetic Patient reference. `clinicalStatus` + `verificationStatus` are emitted together so\n * the base `ait-1`/`ait-2` invariants hold; the required `code` and `patient` are always present.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { codeableConcept, meta, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { EXAMPLE_ALLERGENS, EXAMPLE_ALLERGY_MANIFESTATIONS } from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateAllergyIntolerance}. */\nexport interface GenerateAllergyIntoleranceOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `patient` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly patient?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `AllergyIntolerance`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, patient reference, and US Core posture. See\n * {@link GenerateAllergyIntoleranceOptions}.\n * @returns The `AllergyIntolerance` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateAllergyIntolerance } from \"@cosyte/synth/fhir\";\n * const allergy = generateAllergyIntolerance({ seed: 15, patient: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateAllergyIntolerance(\n options: GenerateAllergyIntoleranceOptions = {},\n): FhirComplex {\n const { seed = 0, patient = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const allergen = rng.pick(EXAMPLE_ALLERGENS);\n const manifestation = rng.pick(EXAMPLE_ALLERGY_MANIFESTATIONS);\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"AllergyIntolerance\")),\n prop(\"id\", str(`syn-allergy-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));\n props.push(prop(\"text\", narrative(`Synthetic allergy: ${allergen.display}.`)));\n props.push(\n prop(\n \"clinicalStatus\",\n codeableConcept({ system: SYSTEM.ALLERGY_CLINICAL, code: \"active\", display: \"Active\" }),\n ),\n );\n props.push(\n prop(\n \"verificationStatus\",\n codeableConcept({\n system: SYSTEM.ALLERGY_VERIFICATION,\n code: \"confirmed\",\n display: \"Confirmed\",\n }),\n ),\n );\n props.push(prop(\"code\", codeableConcept(allergen)));\n props.push(prop(\"patient\", reference(patient)));\n props.push(\n prop(\n \"reaction\",\n list([complex([prop(\"manifestation\", list([codeableConcept(manifestation)]))])]),\n ),\n );\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Procedure`** generation: a US Core Procedure. Built through `@cosyte/fhir`; the\n * `code` comes from the license-clean SNOMED procedure\n * example pool (never CPT), `subject` from a supplied or derived synthetic Patient\n * reference. The required elements (`status`, `code`, `subject`) plus the must-support\n * `performedDateTime` are always present.\n *\n * @module\n */\n\nimport { complex } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_PROCEDURES } from \"./example-codes.js\";\nimport { US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateProcedure}. */\nexport interface GenerateProcedureOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Procedure`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject reference, and US Core posture. See {@link GenerateProcedureOptions}.\n * @returns The `Procedure` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateProcedure } from \"@cosyte/synth/fhir\";\n * const procedure = generateProcedure({ seed: 17, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateProcedure(options: GenerateProcedureOptions = {}): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const code = rng.pick(EXAMPLE_PROCEDURES);\n const performed = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Procedure\")),\n prop(\"id\", str(`syn-proc-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.PROCEDURE])));\n props.push(prop(\"text\", narrative(`Synthetic procedure: ${code.display}.`)));\n props.push(prop(\"status\", str(\"completed\")));\n props.push(prop(\"code\", codeableConcept(code)));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"performedDateTime\", str(`${performed}T10:00:00Z`)));\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`Provenance`** generation: a US Core Provenance, the record of who authored and\n * transmitted a resource. Built through `@cosyte/fhir`'s model constructors like every other resource\n * here, so it is spec-clean by construction and needs no upstream builder of its own.\n *\n * The profile's required elements (`target`, `recorded`, `agent.who`) are always present, as is the\n * must-support `agent.onBehalfOf`, which also discharges the profile's `provenance-1` invariant\n * (\"onBehalfOf SHALL be present when Provenance.agent.who is a Practitioner or Device\") outright\n * rather than leaving it to a resolver.\n *\n * **The single agent is typed as both author and transmitter, deliberately.** US Core slices\n * `Provenance.agent` on a `type` pattern into a `ProvenanceAuthor` slice and a `ProvenanceTransmitter`\n * slice, both must-support and both optional. One synthetic source system authored this record and\n * transmitted it, so one agent carries both participation codings: a `CodeableConcept` is a set of\n * codings for exactly this reason, and the slicing is `open`. Splitting it into two agents would say\n * two parties were involved, which is not what a self-contained synthetic fixture models.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport { coding, meta, narrative, prop, reference, str, toFhirDate, type Prop } from \"./builder.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateProvenance}. */\nexport interface GenerateProvenanceOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `target` reference this provenance is about (e.g. `\"Patient/syn-patient-1\"`). */\n readonly target?: string;\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core `Provenance`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, target reference, and US Core posture. See {@link GenerateProvenanceOptions}.\n * @returns The `Provenance` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateProvenance } from \"@cosyte/synth/fhir\";\n * const provenance = generateProvenance({ seed: 19, target: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateProvenance(options: GenerateProvenanceOptions = {}): FhirComplex {\n const { seed = 0, target = \"Patient/syn-patient-1\", usCore = true } = options;\n const rng = createRng(seed);\n const recorded = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n const practitioner = `Practitioner/syn-practitioner-${rng.digits(8)}`;\n const organization = `Organization/syn-org-${rng.digits(8)}`;\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Provenance\")),\n prop(\"id\", str(`syn-prov-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.PROVENANCE])));\n props.push(prop(\"text\", narrative(\"Synthetic provenance for a generated fixture.\")));\n props.push(prop(\"target\", list([reference(target)])));\n props.push(prop(\"recorded\", str(`${recorded}T10:00:00Z`)));\n props.push(\n prop(\n \"agent\",\n list([\n complex([\n prop(\n \"type\",\n complex([\n prop(\n \"coding\",\n list([\n coding({\n system: SYSTEM.PROVENANCE_PARTICIPANT_TYPE,\n code: \"author\",\n display: \"Author\",\n }),\n coding({\n system: SYSTEM.US_CORE_PROVENANCE_PARTICIPANT_TYPE,\n code: \"transmitter\",\n display: \"Transmitter\",\n }),\n ]),\n ),\n ]),\n ),\n prop(\"who\", reference(practitioner)),\n prop(\"onBehalfOf\", reference(organization)),\n ]),\n ]),\n ),\n );\n return complex(props);\n}\n","/**\n * Synthetic FHIR R4 **`DiagnosticReport`** generation: the US Core DiagnosticReport Profile for\n * Laboratory Results Reporting. Built through `@cosyte/fhir`;\n * the report `code` comes from the license-clean LOINC example pool, `subject` from a supplied or\n * derived synthetic Patient reference. The required `category` carries the profile's mandated `LAB`\n * slice, and `effectiveDateTime` + `issued` are always present so the `us-core-8`/`us-core-9`\n * invariants hold for a `final` report. Optional `result` references wire the report to its\n * `Observation`s (used by the `document` Bundle).\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng } from \"../rng/rng.js\";\nimport { safe } from \"../safe/index.js\";\nimport {\n codeableConcept,\n meta,\n narrative,\n prop,\n reference,\n str,\n toFhirDate,\n type Prop,\n} from \"./builder.js\";\nimport { EXAMPLE_DIAGNOSTIC_REPORTS } from \"./example-codes.js\";\nimport { SYSTEM, US_CORE_PROFILE } from \"./us-core.js\";\n\n/** Options for {@link generateDiagnosticReport}. */\nexport interface GenerateDiagnosticReportOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The `subject` reference (e.g. `\"Patient/syn-patient-1\"` or a `urn:uuid:` fullUrl). */\n readonly subject?: string;\n /** `result` references to the report's `Observation`s (empty ⇒ omitted). */\n readonly results?: readonly string[];\n /** Whether to claim US Core via `meta.profile`. Defaults to `true`. */\n readonly usCore?: boolean;\n}\n\n/**\n * Generate a spec-clean synthetic US Core Laboratory `DiagnosticReport`, built through `@cosyte/fhir`.\n *\n * @param options - Seed, subject, result references, US Core posture. See\n * {@link GenerateDiagnosticReportOptions}.\n * @returns The `DiagnosticReport` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateDiagnosticReport } from \"@cosyte/synth/fhir\";\n * const report = generateDiagnosticReport({ seed: 19, subject: \"Patient/syn-patient-1\" });\n * ```\n */\nexport function generateDiagnosticReport(\n options: GenerateDiagnosticReportOptions = {},\n): FhirComplex {\n const { seed = 0, subject = \"Patient/syn-patient-1\", results = [], usCore = true } = options;\n const rng = createRng(seed);\n const code = rng.pick(EXAMPLE_DIAGNOSTIC_REPORTS);\n const day = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"DiagnosticReport\")),\n prop(\"id\", str(`syn-dr-${rng.digits(8)}`)),\n ];\n if (usCore) props.push(prop(\"meta\", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));\n props.push(prop(\"text\", narrative(`Synthetic laboratory report: ${code.display}.`)));\n props.push(prop(\"status\", str(\"final\")));\n props.push(\n prop(\n \"category\",\n list([\n codeableConcept({\n system: SYSTEM.DIAGNOSTIC_SERVICE_SECTION,\n code: \"LAB\",\n display: \"Laboratory\",\n }),\n ]),\n ),\n );\n props.push(prop(\"code\", codeableConcept(code)));\n props.push(prop(\"subject\", reference(subject)));\n props.push(prop(\"effectiveDateTime\", str(`${day}T08:30:00Z`)));\n props.push(prop(\"issued\", str(`${day}T09:00:00.000Z`)));\n if (results.length > 0) {\n props.push(prop(\"result\", list(results.map((r) => reference(r)))));\n }\n return complex(props);\n}\n","/**\n * The `Corpus` abstraction: a seed plus a self-describing manifest of what was generated, so a\n * fixture set is itself reproducible and regenerable. A downstream repo pins a seed\n * and gets a stable fixture set that regenerates identically.\n *\n * Generated artifacts and the `Corpus` are **deep-frozen**: this is where the archetype's immutability\n * invariant lives in a generator: a consumer cannot mutate a shared fixture out from under\n * another test.\n *\n * @module\n */\n\n/** The format an artifact was generated for. */\nexport type SynthFormat = \"hl7v2\" | \"fhir\" | \"ccda\" | \"x12\" | \"ncpdp\" | \"astm\";\n\n/**\n * One generated artifact: the serialized wire text plus the metadata needed to reproduce and check\n * it. `warnings` records what the artifact's own parser reported on the round-trip (zero for a\n * spec-clean artifact).\n */\nexport interface Artifact {\n /** The format this artifact belongs to. */\n readonly format: SynthFormat;\n /** A format-specific kind label (e.g. `\"ADT^A01\"`). */\n readonly kind: string;\n /** The serialized wire text, produced by the parser's own conservative serializer. */\n readonly content: string;\n /** The warning codes the parser emitted when the artifact was round-tripped (empty = spec-clean). */\n readonly warnings: readonly string[];\n}\n\n/** A self-describing manifest of a {@link Corpus}. */\nexport interface CorpusManifest {\n /** The formats present in the corpus. */\n readonly formats: readonly SynthFormat[];\n /** Per-kind artifact counts (e.g. `{ \"ADT^A01\": 3 }`). */\n readonly counts: Readonly<Record<string, number>>;\n /** The quirk names applied. */\n readonly quirks: readonly string[];\n}\n\n/** A reproducible, self-describing set of generated artifacts. */\nexport interface Corpus {\n /** The seed the corpus was generated from: regenerating from it yields byte-identical artifacts. */\n readonly seed: number;\n /** The manifest describing what was generated. */\n readonly manifest: CorpusManifest;\n /** The generated artifacts, in generation order. */\n readonly artifacts: readonly Artifact[];\n}\n\n/**\n * Assemble a deep-frozen {@link Corpus} from a seed and its artifacts, deriving the manifest.\n *\n * @param seed - The seed the artifacts were generated from.\n * @param artifacts - The generated artifacts, in order.\n * @param quirks - The quirk names applied (default none).\n * @returns A deep-frozen, self-describing {@link Corpus}.\n * @example\n * ```ts\n * import { makeCorpus } from \"@cosyte/synth\";\n * const corpus = makeCorpus(1, [{ format: \"hl7v2\", kind: \"ADT^A01\", content, warnings: [] }]);\n * corpus.manifest.counts[\"ADT^A01\"]; // 1\n * ```\n */\nexport function makeCorpus(\n seed: number,\n artifacts: readonly Artifact[],\n quirks: readonly string[] = [],\n): Corpus {\n const counts: Record<string, number> = {};\n const formats = new Set<SynthFormat>();\n const frozenArtifacts = artifacts.map((a) => {\n counts[a.kind] = (counts[a.kind] ?? 0) + 1;\n formats.add(a.format);\n return Object.freeze({ ...a, warnings: Object.freeze([...a.warnings]) });\n });\n const manifest: CorpusManifest = Object.freeze({\n formats: Object.freeze([...formats]),\n counts: Object.freeze(counts),\n quirks: Object.freeze([...quirks]),\n });\n return Object.freeze({\n seed,\n manifest,\n artifacts: Object.freeze(frozenArtifacts),\n });\n}\n","/**\n * Synthetic FHIR R4 **`Composition`** generation: the mandatory first resource of a `document` Bundle\n * (FHIR invariant `bdl-11`), built through `@cosyte/fhir`.\n * A Composition is a base-R4 resource (US Core 6.1.0 defines no Composition profile), so it is grounded\n * against base FHIR R4; every reference it carries (`subject`, `author`, `custodian`, section `entry`s)\n * is an in-bundle `urn:uuid:` fullUrl so the document is self-contained and its references resolve.\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport type { Rng } from \"../rng/rng.js\";\nimport { codeableConcept, narrative, prop, reference, str, type Prop } from \"./builder.js\";\nimport { SYSTEM } from \"./us-core.js\";\n\n/** A document section: a LOINC section code, a human title, and the entry references it summarizes. */\nexport interface CompositionSection {\n /** The LOINC section code. */\n readonly code: string;\n /** The section's human title / display. */\n readonly title: string;\n /** In-bundle `urn:uuid:` references to the resources the section summarizes. */\n readonly entries: readonly string[];\n}\n\n/** Inputs for {@link buildComposition}. */\nexport interface BuildCompositionInput {\n /** The `subject` reference (the patient's in-bundle fullUrl). */\n readonly subject: string;\n /** The `author` + `custodian` reference (an in-bundle Organization fullUrl). */\n readonly organization: string;\n /** The document date (`YYYY-MM-DD`). */\n readonly date: string;\n /** The document sections. */\n readonly sections: readonly CompositionSection[];\n}\n\n/** One `Composition.section`: title, LOINC code, and its `entry` references (satisfies `cmp-1`). */\nfunction section(sec: CompositionSection): FhirComplex {\n return complex([\n prop(\"title\", str(sec.title)),\n prop(\"code\", codeableConcept({ system: SYSTEM.LOINC, code: sec.code, display: sec.title })),\n prop(\"entry\", list(sec.entries.map((e) => reference(e)))),\n ]);\n}\n\n/**\n * Build a spec-clean synthetic base-R4 `Composition` for a `document` Bundle, through `@cosyte/fhir`.\n *\n * @param rng - The seeded generator (for the resource id).\n * @param input - Subject/organization references, date, and sections. See {@link BuildCompositionInput}.\n * @returns The `Composition` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { createRng } from \"@cosyte/synth\";\n * import { buildComposition } from \"@cosyte/synth/fhir\";\n * // buildComposition(createRng(1), { subject, organization, date: \"2020-01-01\", sections: [] });\n * ```\n */\nexport function buildComposition(rng: Rng, input: BuildCompositionInput): FhirComplex {\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Composition\")),\n prop(\"id\", str(`syn-comp-${rng.digits(8)}`)),\n prop(\"text\", narrative(\"Synthetic continuity-of-care document summary.\")),\n prop(\"status\", str(\"final\")),\n prop(\n \"type\",\n codeableConcept({\n system: SYSTEM.LOINC,\n code: \"34133-9\",\n display: \"Summarization of Episode Note\",\n }),\n ),\n prop(\"subject\", reference(input.subject)),\n prop(\"date\", str(`${input.date}T09:00:00Z`)),\n prop(\"author\", list([reference(input.organization)])),\n prop(\"title\", str(\"Synthetic Continuity of Care Document\")),\n prop(\"custodian\", reference(input.organization)),\n prop(\"section\", list(input.sections.map((s) => section(s)))),\n ];\n return complex(props);\n}\n","/**\n * The **round-trip-through-the-parser harness** for FHIR: the headline gate for the synthetic-fixture\n * generator. A generated resource is \"spec-clean\" only if `@cosyte/fhir`, not\n * `@cosyte/synth`'s own opinion, reads it back, validates it, and re-serializes it byte-identically.\n * This harness serializes a generated resource, parses it back, validates it (optionally against\n * supplied US Core / vendor `StructureDefinition`s), and re-serializes, reporting what the parser found\n * so a false \"spec-clean\" claim cannot hide.\n *\n * `@cosyte/synth` bundles **no** profile content: to validate US Core conformance, a caller supplies\n * the `StructureDefinition`s via {@link RoundTripOptions.profiles}, exactly the content-free posture of\n * `@cosyte/fhir.validateResource({ profiles })`.\n *\n * @module\n */\n\nimport { parseResource, serializeResource, validateResource } from \"@cosyte/fhir\";\nimport type { FhirComplex, StructureDefinition } from \"@cosyte/fhir\";\n\n/** Options for {@link roundTrip}. */\nexport interface RoundTripOptions {\n /**\n * US Core / vendor profiles (`StructureDefinition`s) to validate against. **None is bundled**: a\n * caller supplies them (BYO), matching `@cosyte/fhir`'s content-free posture.\n */\n readonly profiles?: readonly StructureDefinition[];\n}\n\n/** The verdict of one round-trip through `@cosyte/fhir`. */\nexport interface RoundTripResult {\n /** The serialized FHIR JSON text (the parser's own conservative emit). */\n readonly content: string;\n /**\n * The validation issue codes at `error`/`fatal` severity (empty ⇒ valid). `information`/`warning`\n * findings (e.g. `MUST_SUPPORT_ABSENT`, `INVARIANT_UNCHECKED`, base `dom-6`) are advisory and are\n * excluded here: they never make a resource invalid.\n */\n readonly errors: readonly string[];\n /** All non-informational issue codes (errors **and** warnings), for the `Corpus` artifact record. */\n readonly warnings: readonly string[];\n /** Whether re-serializing the re-parsed resource is byte-identical to `content`. */\n readonly byteStable: boolean;\n /** Whether `@cosyte/fhir.validateResource` reported no `error`/`fatal` findings. */\n readonly valid: boolean;\n /** `true` iff the artifact is spec-clean: **valid** (zero errors) **and** byte-stable. */\n readonly specClean: boolean;\n}\n\n/**\n * Round-trip a generated FHIR resource through serialize → parse → validate → serialize and report the\n * verdict. A spec-clean artifact validates with **zero errors** and re-serializes byte-identically.\n *\n * @param resource - The resource model to check (typically from a `generate*` function).\n * @param options - Optional US Core / vendor profiles to validate against. See {@link RoundTripOptions}.\n * @returns The {@link RoundTripResult}.\n * @example\n * ```ts\n * import { generatePatient, roundTrip } from \"@cosyte/synth/fhir\";\n * const { specClean, errors } = roundTrip(generatePatient({ seed: 1 }));\n * // specClean === true, errors.length === 0\n * ```\n */\nexport function roundTrip(resource: FhirComplex, options: RoundTripOptions = {}): RoundTripResult {\n const content = serializeResource(resource);\n const { resource: reparsed } = parseResource(content);\n const byteStable = serializeResource(reparsed) === content;\n const result = validateResource(\n reparsed,\n options.profiles !== undefined\n ? { mode: \"strict\", profiles: options.profiles }\n : { mode: \"strict\" },\n );\n const errors = result.issues\n .filter((i) => i.severity === \"error\" || i.severity === \"fatal\")\n .map((i) => i.code);\n const warnings = result.issues\n .filter((i) => i.severity === \"error\" || i.severity === \"fatal\" || i.severity === \"warning\")\n .map((i) => i.code);\n const valid = result.valid;\n return { content, errors, warnings, byteStable, valid, specClean: valid && byteStable };\n}\n","/**\n * Synthetic FHIR R4 **`Bundle`** generation: a self-contained `collection`,\n * `transaction`, or `document` Bundle assembling a synthetic US Core `Patient` and its full clinical\n * spine (`Condition`, lab + vital-sign `Observation`s, `MedicationRequest`, `Encounter`,\n * `Immunization`, `AllergyIntolerance`, `Procedure`, `DiagnosticReport`), wired by `urn:uuid:`\n * `fullUrl`s so every intra-bundle reference resolves. Built through `@cosyte/fhir`. The `document`\n * shape prepends the FHIR-mandated `Composition` (invariant `bdl-11`) and a synthetic\n * `Organization` author/custodian, and carries the required `identifier` + `timestamp` (`bdl-9`/`bdl-10`).\n *\n * @module\n */\n\nimport { complex, list } from \"@cosyte/fhir\";\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { createRng, type Rng } from \"../rng/rng.js\";\nimport { makeCorpus, type Corpus } from \"../corpus.js\";\nimport { bool, narrative, prop, str, toFhirDate, type Prop } from \"./builder.js\";\nimport { buildComposition, type CompositionSection } from \"./composition.js\";\nimport { generatePatient } from \"./patient.js\";\nimport { generateCondition } from \"./condition.js\";\nimport { generateObservationLab, generateVitalSign } from \"./observation.js\";\nimport { generateMedicationRequest } from \"./medication-request.js\";\nimport { generateEncounter } from \"./encounter.js\";\nimport { generateImmunization } from \"./immunization.js\";\nimport { generateAllergyIntolerance } from \"./allergy-intolerance.js\";\nimport { generateProcedure } from \"./procedure.js\";\nimport { generateDiagnosticReport } from \"./diagnostic-report.js\";\nimport { roundTrip } from \"./round-trip.js\";\nimport { safe } from \"../safe/index.js\";\nimport { resolveKind, resolveMix } from \"../select.js\";\n\n/** The Bundle shapes `@cosyte/synth` supports. */\nexport type FhirBundleType = \"collection\" | \"transaction\" | \"document\";\n\n/** Every value {@link FhirBundleType} admits. Erased at run time, so it is resolved, not trusted. */\nconst BUNDLE_TYPES: readonly FhirBundleType[] = Object.freeze([\n \"collection\",\n \"transaction\",\n \"document\",\n]);\n\n/** Options for {@link generateBundle}. */\nexport interface GenerateBundleOptions {\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n /** The Bundle shape. Defaults to `\"collection\"`. */\n readonly type?: FhirBundleType;\n}\n\n/** The `resourceType` string of a generated resource (its `request.url` in a transaction Bundle). */\nfunction resourceTypeOf(resource: FhirComplex): string {\n const rt = resource.properties.find((p) => p.name === \"resourceType\");\n return rt !== undefined && rt.value.kind === \"primitive\" ? String(rt.value.value) : \"Resource\";\n}\n\n/** A minimal synthetic `Organization` (author/custodian), no PHI, name is clearly synthetic. */\nfunction buildOrganization(rng: Rng): FhirComplex {\n const id = safe.identifier(rng, \"AN\");\n return complex([\n prop(\"resourceType\", str(\"Organization\")),\n prop(\"id\", str(`syn-org-${rng.digits(8)}`)),\n prop(\"text\", narrative(\"Synthetic health organization.\")),\n prop(\n \"identifier\",\n list([\n complex([\n prop(\"system\", str(`urn:oid:${id.assigningAuthorityOid}`)),\n prop(\"value\", str(id.value)),\n ]),\n ]),\n ),\n prop(\"active\", bool(true)),\n prop(\"name\", str(\"Synthetic Health Organization\")),\n ]);\n}\n\n/** One assembled spine member: its stable in-bundle `urn:uuid:` fullUrl and its resource model. */\ninterface SpineEntry {\n readonly fullUrl: string;\n readonly resource: FhirComplex;\n}\n\n/** The assembled clinical spine plus the shared patient / organization fullUrls a document references. */\ninterface Spine {\n readonly patientUrl: string;\n readonly orgUrl: string;\n readonly date: string;\n /** Per-kind fullUrls, for the document Composition's section entries. */\n readonly urls: Readonly<Record<string, string>>;\n /** The clinical entries (Patient first, then Organization, then the clinical resources). */\n readonly entries: readonly SpineEntry[];\n}\n\n/** Build the shared clinical spine: every reference wired to an in-bundle `urn:uuid:` fullUrl. */\nfunction buildSpine(rng: Rng): Spine {\n const patientUrl = `urn:uuid:${safe.uuid(rng)}`;\n const orgUrl = `urn:uuid:${safe.uuid(rng)}`;\n const date = toFhirDate(safe.dateYmd(rng, 2018, 2024));\n\n const patient: SpineEntry = {\n fullUrl: patientUrl,\n resource: generatePatient({ seed: rng.nextUint32(), profile: \"us-core\" }),\n };\n const org: SpineEntry = { fullUrl: orgUrl, resource: buildOrganization(rng) };\n\n const condUrl = `urn:uuid:${safe.uuid(rng)}`;\n const cond = generateCondition({ seed: rng.nextUint32(), subject: patientUrl });\n const labUrl = `urn:uuid:${safe.uuid(rng)}`;\n const lab = generateObservationLab({ seed: rng.nextUint32(), subject: patientUrl });\n const vitalUrl = `urn:uuid:${safe.uuid(rng)}`;\n const vital = generateVitalSign({ seed: rng.nextUint32(), subject: patientUrl });\n const medUrl = `urn:uuid:${safe.uuid(rng)}`;\n const med = generateMedicationRequest({\n seed: rng.nextUint32(),\n subject: patientUrl,\n requester: orgUrl,\n });\n const encUrl = `urn:uuid:${safe.uuid(rng)}`;\n const enc = generateEncounter({ seed: rng.nextUint32(), subject: patientUrl });\n const immUrl = `urn:uuid:${safe.uuid(rng)}`;\n const imm = generateImmunization({ seed: rng.nextUint32(), patient: patientUrl });\n const allergyUrl = `urn:uuid:${safe.uuid(rng)}`;\n const allergy = generateAllergyIntolerance({ seed: rng.nextUint32(), patient: patientUrl });\n const procUrl = `urn:uuid:${safe.uuid(rng)}`;\n const proc = generateProcedure({ seed: rng.nextUint32(), subject: patientUrl });\n const drUrl = `urn:uuid:${safe.uuid(rng)}`;\n const dr = generateDiagnosticReport({\n seed: rng.nextUint32(),\n subject: patientUrl,\n results: [labUrl],\n });\n\n const entries: SpineEntry[] = [\n patient,\n org,\n { fullUrl: condUrl, resource: cond },\n { fullUrl: labUrl, resource: lab },\n { fullUrl: vitalUrl, resource: vital },\n { fullUrl: medUrl, resource: med },\n { fullUrl: encUrl, resource: enc },\n { fullUrl: immUrl, resource: imm },\n { fullUrl: allergyUrl, resource: allergy },\n { fullUrl: procUrl, resource: proc },\n { fullUrl: drUrl, resource: dr },\n ];\n const urls = {\n condition: condUrl,\n lab: labUrl,\n vital: vitalUrl,\n medication: medUrl,\n encounter: encUrl,\n immunization: immUrl,\n allergy: allergyUrl,\n procedure: procUrl,\n diagnosticReport: drUrl,\n };\n return { patientUrl, orgUrl, date, urls, entries };\n}\n\n/** The document sections summarizing the clinical spine (LOINC section codes → entry references). */\nfunction documentSections(urls: Readonly<Record<string, string>>): CompositionSection[] {\n const at = (k: string): string[] => (urls[k] !== undefined ? [urls[k]] : []);\n return [\n { code: \"11450-4\", title: \"Problem List\", entries: at(\"condition\") },\n {\n code: \"30954-2\",\n title: \"Relevant Diagnostic Tests/Laboratory Data\",\n entries: [...at(\"diagnosticReport\"), ...at(\"lab\"), ...at(\"vital\")],\n },\n { code: \"10160-0\", title: \"History of Medication Use\", entries: at(\"medication\") },\n { code: \"48765-2\", title: \"Allergies and Adverse Reactions\", entries: at(\"allergy\") },\n { code: \"11369-6\", title: \"History of Immunizations\", entries: at(\"immunization\") },\n { code: \"47519-4\", title: \"History of Procedures\", entries: at(\"procedure\") },\n { code: \"46240-8\", title: \"History of Encounters\", entries: at(\"encounter\") },\n ];\n}\n\n/**\n * Generate a spec-clean synthetic FHIR `Bundle` (`collection`, `transaction`, or `document`) built\n * through `@cosyte/fhir`, containing a US Core `Patient` and its full clinical spine wired by\n * `urn:uuid:` references so every reference resolves in-bundle.\n *\n * @param options - Seed and Bundle shape. See {@link GenerateBundleOptions}.\n * @returns The `Bundle` resource model (a `FhirComplex`).\n * @example\n * ```ts\n * import { generateBundle } from \"@cosyte/synth/fhir\";\n * const bundle = generateBundle({ seed: 42, type: \"document\" });\n * ```\n */\nexport function generateBundle(options: GenerateBundleOptions = {}): FhirComplex {\n const { seed = 0 } = options;\n const type = resolveKind(BUNDLE_TYPES, options.type ?? \"collection\");\n const rng = createRng(seed);\n const spine = buildSpine(rng);\n\n const members: SpineEntry[] =\n type === \"document\"\n ? [\n {\n fullUrl: `urn:uuid:${safe.uuid(rng)}`,\n resource: buildComposition(rng, {\n subject: spine.patientUrl,\n organization: spine.orgUrl,\n date: spine.date,\n sections: documentSections(spine.urls),\n }),\n },\n ...spine.entries,\n ]\n : [...spine.entries];\n\n const entries = members.map((member) => {\n const entryProps: Prop[] = [\n prop(\"fullUrl\", str(member.fullUrl)),\n prop(\"resource\", member.resource),\n ];\n // A document Bundle forbids entry.request/response (bdl-3a); a transaction requires request.\n if (type === \"transaction\") {\n entryProps.push(\n prop(\n \"request\",\n complex([prop(\"method\", str(\"POST\")), prop(\"url\", str(resourceTypeOf(member.resource)))]),\n ),\n );\n }\n return complex(entryProps);\n });\n\n const props: Prop[] = [\n prop(\"resourceType\", str(\"Bundle\")),\n prop(\"id\", str(`syn-bundle-${rng.digits(8)}`)),\n ];\n // A document Bundle requires an identifier (bdl-9) and a timestamp (bdl-10).\n if (type === \"document\") {\n const id = safe.identifier(rng, \"AN\");\n props.push(\n prop(\n \"identifier\",\n complex([\n prop(\"system\", str(`urn:oid:${id.assigningAuthorityOid}`)),\n prop(\"value\", str(`urn:uuid:${safe.uuid(rng)}`)),\n ]),\n ),\n );\n }\n props.push(prop(\"type\", str(type)));\n if (type === \"document\") props.push(prop(\"timestamp\", str(`${spine.date}T09:00:00.000Z`)));\n props.push(prop(\"entry\", list(entries)));\n\n return complex(props);\n}\n\n/** A FHIR resource kind the {@link fhirCorpus} can generate. */\nexport type FhirResourceKind =\n | \"Patient\"\n | \"USCorePatient\"\n | \"Condition\"\n | \"ObservationLab\"\n | \"VitalSign\"\n | \"MedicationRequest\"\n | \"Encounter\"\n | \"Immunization\"\n | \"AllergyIntolerance\"\n | \"Procedure\"\n | \"DiagnosticReport\"\n | \"Bundle\"\n | \"DocumentBundle\";\n\n/** Every value {@link FhirResourceKind} admits. Erased at run time, so a mix entry is resolved. */\nconst ALL_KINDS: readonly FhirResourceKind[] = Object.freeze([\n \"Patient\",\n \"USCorePatient\",\n \"Condition\",\n \"ObservationLab\",\n \"VitalSign\",\n \"MedicationRequest\",\n \"Encounter\",\n \"Immunization\",\n \"AllergyIntolerance\",\n \"Procedure\",\n \"DiagnosticReport\",\n \"Bundle\",\n \"DocumentBundle\",\n]);\n\n/** The default corpus mix: the full US Core clinical spine plus a collection Bundle. */\nconst DEFAULT_MIX: readonly FhirResourceKind[] = Object.freeze([\n \"USCorePatient\",\n \"Condition\",\n \"ObservationLab\",\n \"VitalSign\",\n \"MedicationRequest\",\n \"Encounter\",\n \"Immunization\",\n \"AllergyIntolerance\",\n \"Procedure\",\n \"DiagnosticReport\",\n \"Bundle\",\n]);\n\n/** Generate one resource of the given kind from a seed. */\nfunction generateKind(kind: FhirResourceKind, seed: number): FhirComplex {\n switch (kind) {\n case \"Patient\":\n return generatePatient({ seed, profile: \"base\" });\n case \"USCorePatient\":\n return generatePatient({ seed, profile: \"us-core\" });\n case \"Condition\":\n return generateCondition({ seed });\n case \"ObservationLab\":\n return generateObservationLab({ seed });\n case \"VitalSign\":\n return generateVitalSign({ seed });\n case \"MedicationRequest\":\n return generateMedicationRequest({ seed });\n case \"Encounter\":\n return generateEncounter({ seed });\n case \"Immunization\":\n return generateImmunization({ seed });\n case \"AllergyIntolerance\":\n return generateAllergyIntolerance({ seed });\n case \"Procedure\":\n return generateProcedure({ seed });\n case \"DiagnosticReport\":\n return generateDiagnosticReport({ seed });\n case \"Bundle\":\n return generateBundle({ seed });\n case \"DocumentBundle\":\n return generateBundle({ seed, type: \"document\" });\n }\n}\n\n/** Options for {@link fhirCorpus}. */\nexport interface FhirCorpusOptions {\n /** The seed for the whole corpus (deterministic). */\n readonly seed: number;\n /** How many resources to generate. Defaults to `1`. */\n readonly count?: number;\n /** The resource kinds to cycle through. Defaults to the full US Core clinical spine + a Bundle. */\n readonly mix?: readonly FhirResourceKind[];\n}\n\n/**\n * Build a reproducible {@link Corpus} of spec-clean FHIR resources across the supported kinds. Each\n * resource is generated from a distinct sub-seed derived from the corpus seed and round-tripped through\n * `@cosyte/fhir`; the per-artifact `warnings` record the validator's non-informational findings (empty\n * ⇒ spec-clean, no US Core profiles supplied). Pass US Core `StructureDefinition`s to a per-resource\n * {@link roundTrip} call to additionally assert profile conformance (BYO, none is bundled).\n *\n * @param options - Seed, count, and the resource mix. See {@link FhirCorpusOptions}.\n * @returns A deep-frozen {@link Corpus}.\n * @example\n * ```ts\n * import { fhirCorpus } from \"@cosyte/synth/fhir\";\n * const corpus = fhirCorpus({ seed: 42, count: 6 });\n * corpus.artifacts.every((a) => a.warnings.length === 0); // spec-clean (structural)\n * ```\n */\nexport function fhirCorpus(options: FhirCorpusOptions): Corpus {\n const { seed, count = 1 } = options;\n const kinds = resolveMix(ALL_KINDS, options.mix, DEFAULT_MIX);\n const seedStream = createRng(seed);\n const artifacts = Array.from({ length: count }, (_unused, i) => {\n const kind = kinds[i % kinds.length] ?? \"USCorePatient\";\n const rt = roundTrip(generateKind(kind, seedStream.nextUint32()));\n // The artifact records the findings that break spec-cleanliness: validator **errors** (empty ⇒\n // spec-clean). Advisory warnings a legal resource may carry (e.g. `REFERENCE_UNRESOLVED` on a\n // collection Bundle's external reference, or the base `dom-6` narrative best-practice) are not\n // spec-cleanliness violations and are excluded here; a caller wanting the full picture calls\n // `roundTrip` directly (it exposes both `errors` and `warnings`).\n return { format: \"fhir\" as const, kind, content: rt.content, warnings: rt.errors };\n });\n return makeCorpus(seed, artifacts);\n}\n","/**\n * **Profile-addressed generation, and the coverage surface it is resolved against.**\n *\n * A consumer building to `45 CFR 170.315(g)(10)` does not think in this package's generator names: it\n * thinks in US Core 6.1.0 profile names, because that is what the regulation adopts. So this module\n * offers exactly two things, and the pair is the whole contract:\n *\n * 1. {@link usCoreCoverage} reports one entry for **every** profile the adopted guide publishes, each\n * carrying its canonical URL and whether this build generates it. \"The guide does not publish this\"\n * and \"we do not generate this yet\" are different answers, and without a published closed set\n * nothing could tell them apart.\n * 2. {@link generateUsCoreProfile} takes a profile name and either returns an artifact claiming that\n * profile, or **fails closed before anything is generated**, on the `resolveKind` discipline every\n * other caller-supplied selector here already holds. Two distinct codes: `SYNTH_UNSUPPORTED_KIND`\n * for a name outside the adopted set (an extension definition, a typo, a blank, a non-string), and\n * `SYNTH_PROFILE_NOT_GENERATED` for an adopted profile this build does not yet cover. Neither\n * quotes the requested name, so no caller string reaches a diagnostic surface.\n *\n * **Coverage is derived, never declared twice.** The `generated` flag is read off the generator map\n * below, so a profile cannot be advertised as covered without a generator behind it, and the\n * conformance suite additionally requires a committed `StructureDefinition` for every profile this\n * surface reports as generated.\n *\n * No IG content is bundled: what is encoded here is a set of identifiers, exactly like `./us-core.js`.\n *\n * @module\n */\n\nimport type { FhirComplex } from \"@cosyte/fhir\";\n\nimport { SYNTH_FATAL_CODES, SynthError } from \"../codes.js\";\nimport { resolveKind } from \"../select.js\";\nimport { generateAllergyIntolerance } from \"./allergy-intolerance.js\";\nimport { generateCondition } from \"./condition.js\";\nimport { generateDiagnosticReport } from \"./diagnostic-report.js\";\nimport { generateEncounter } from \"./encounter.js\";\nimport { generateImmunization } from \"./immunization.js\";\nimport { generateMedicationRequest } from \"./medication-request.js\";\nimport { generateObservationLab, generateVitalSign } from \"./observation.js\";\nimport { generatePatient } from \"./patient.js\";\nimport { generateProcedure } from \"./procedure.js\";\nimport { generateProvenance } from \"./provenance.js\";\nimport { US_CORE_ADOPTED_PROFILES, US_CORE_PROFILE_BASE, type UsCoreProfileId } from \"./us-core.js\";\n\n/**\n * The generators, one per **covered** adopted profile. A profile absent from this map is adopted and\n * uncovered: {@link usCoreCoverage} reports it as such and {@link generateUsCoreProfile} refuses it\n * with `SYNTH_PROFILE_NOT_GENERATED`.\n */\nconst GENERATORS: Readonly<Partial<Record<UsCoreProfileId, (seed: number) => FhirComplex>>> =\n Object.freeze({\n \"us-core-allergyintolerance\": (seed: number) => generateAllergyIntolerance({ seed }),\n \"us-core-condition-problems-health-concerns\": (seed: number) => generateCondition({ seed }),\n \"us-core-diagnosticreport-lab\": (seed: number) => generateDiagnosticReport({ seed }),\n \"us-core-encounter\": (seed: number) => generateEncounter({ seed }),\n \"us-core-immunization\": (seed: number) => generateImmunization({ seed }),\n \"us-core-medicationrequest\": (seed: number) => generateMedicationRequest({ seed }),\n \"us-core-observation-lab\": (seed: number) => generateObservationLab({ seed }),\n \"us-core-patient\": (seed: number) => generatePatient({ seed, profile: \"us-core\" }),\n \"us-core-procedure\": (seed: number) => generateProcedure({ seed }),\n \"us-core-provenance\": (seed: number) => generateProvenance({ seed }),\n \"us-core-vital-signs\": (seed: number) => generateVitalSign({ seed }),\n });\n\n/** One adopted US Core 6.1.0 resource profile, and whether this build generates a fixture for it. */\nexport interface UsCoreProfileCoverage {\n /** The profile id, as the guide's artifact index spells it. */\n readonly profile: UsCoreProfileId;\n /** The profile's canonical URL: the value a generated artifact's `meta.profile` claims. */\n readonly canonical: string;\n /** `true` when {@link generateUsCoreProfile} returns an artifact for this profile. */\n readonly generated: boolean;\n}\n\n/** The coverage report, computed once: the adopted set is frozen and the generator map is frozen. */\nconst COVERAGE: readonly UsCoreProfileCoverage[] = Object.freeze(\n US_CORE_ADOPTED_PROFILES.map((profile) =>\n Object.freeze({\n profile,\n canonical: `${US_CORE_PROFILE_BASE}${profile}`,\n generated: GENERATORS[profile] !== undefined,\n }),\n ),\n);\n\n/**\n * Report this build's US Core 6.1.0 coverage: one entry per **adopted** resource profile, in the\n * guide's own order, each carrying its canonical URL and whether this build generates it.\n *\n * The report is exhaustive over the adopted set by construction, so a profile the guide publishes and\n * this build does not generate is *named* here rather than being indistinguishable from a typo.\n *\n * @returns One frozen {@link UsCoreProfileCoverage} entry per adopted profile.\n * @example\n * ```ts\n * import { usCoreCoverage } from \"@cosyte/synth/fhir\";\n * usCoreCoverage().filter((entry) => !entry.generated).map((entry) => entry.profile);\n * ```\n */\nexport function usCoreCoverage(): readonly UsCoreProfileCoverage[] {\n return COVERAGE;\n}\n\n/** Options for {@link generateUsCoreProfile}. */\nexport interface GenerateUsCoreProfileOptions {\n /**\n * The US Core 6.1.0 profile id to generate. Resolved against the adopted set **before** anything is\n * generated; there is deliberately no default, so a blank or absent name refuses rather than\n * falling through to some other profile's artifact.\n */\n readonly profile: UsCoreProfileId;\n /** The seed (deterministic). Defaults to `0`. */\n readonly seed?: number;\n}\n\n/**\n * Generate a fixture **by US Core 6.1.0 profile name**, or fail closed before anything is generated.\n *\n * @param options - The profile name and seed. See {@link GenerateUsCoreProfileOptions}.\n * @returns The resource model (a `FhirComplex`) claiming that profile in `meta.profile`.\n * @throws SynthError `SYNTH_UNSUPPORTED_KIND` when the name is not in the adopted set.\n * @throws SynthError `SYNTH_PROFILE_NOT_GENERATED` when the profile is adopted and not generated here.\n * @example\n * ```ts\n * import { generateUsCoreProfile } from \"@cosyte/synth/fhir\";\n * const provenance = generateUsCoreProfile({ profile: \"us-core-provenance\", seed: 42 });\n * ```\n */\nexport function generateUsCoreProfile(options: GenerateUsCoreProfileOptions): FhirComplex {\n const profile = resolveKind(US_CORE_ADOPTED_PROFILES, options.profile);\n const generate = GENERATORS[profile];\n if (generate === undefined) {\n throw new SynthError(SYNTH_FATAL_CODES.SYNTH_PROFILE_NOT_GENERATED);\n }\n return generate(options.seed ?? 0);\n}\n"]}