@cosyte/synth 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +414 -0
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/dist/astm/index.cjs +847 -0
- package/dist/astm/index.cjs.map +1 -0
- package/dist/astm/index.d.cts +418 -0
- package/dist/astm/index.d.ts +418 -0
- package/dist/astm/index.mjs +828 -0
- package/dist/astm/index.mjs.map +1 -0
- package/dist/ccda/index.cjs +1103 -0
- package/dist/ccda/index.cjs.map +1 -0
- package/dist/ccda/index.d.cts +380 -0
- package/dist/ccda/index.d.ts +380 -0
- package/dist/ccda/index.mjs +1077 -0
- package/dist/ccda/index.mjs.map +1 -0
- package/dist/deid/index.cjs +2809 -0
- package/dist/deid/index.cjs.map +1 -0
- package/dist/deid/index.d.cts +464 -0
- package/dist/deid/index.d.ts +464 -0
- package/dist/deid/index.mjs +2793 -0
- package/dist/deid/index.mjs.map +1 -0
- package/dist/example-codes-DeXcnCSK.d.cts +105 -0
- package/dist/example-codes-DeXcnCSK.d.ts +105 -0
- package/dist/fhir/index.cjs +1429 -0
- package/dist/fhir/index.cjs.map +1 -0
- package/dist/fhir/index.d.cts +772 -0
- package/dist/fhir/index.d.ts +772 -0
- package/dist/fhir/index.mjs +1384 -0
- package/dist/fhir/index.mjs.map +1 -0
- package/dist/hl7/index.cjs +1012 -0
- package/dist/hl7/index.cjs.map +1 -0
- package/dist/hl7/index.d.cts +548 -0
- package/dist/hl7/index.d.ts +548 -0
- package/dist/hl7/index.mjs +990 -0
- package/dist/hl7/index.mjs.map +1 -0
- package/dist/index.cjs +535 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +407 -0
- package/dist/index.d.ts +407 -0
- package/dist/index.mjs +488 -0
- package/dist/index.mjs.map +1 -0
- package/dist/ncpdp/index.cjs +714 -0
- package/dist/ncpdp/index.cjs.map +1 -0
- package/dist/ncpdp/index.d.cts +432 -0
- package/dist/ncpdp/index.d.ts +432 -0
- package/dist/ncpdp/index.mjs +695 -0
- package/dist/ncpdp/index.mjs.map +1 -0
- package/dist/providers-OLz3zAc-.d.cts +343 -0
- package/dist/providers-OLz3zAc-.d.ts +343 -0
- package/dist/quirk-DmkgoZdh.d.cts +239 -0
- package/dist/quirk-JLyO1Ncj.d.ts +239 -0
- package/dist/x12/index.cjs +920 -0
- package/dist/x12/index.cjs.map +1 -0
- package/dist/x12/index.d.cts +484 -0
- package/dist/x12/index.d.ts +484 -0
- package/dist/x12/index.mjs +892 -0
- package/dist/x12/index.mjs.map +1 -0
- package/package.json +210 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { S as SyntheticName, a as SyntheticIdentifier, R as Rng, C as Corpus } from '../providers-OLz3zAc-.cjs';
|
|
2
|
+
import { CcdaDocument, BuildCcdaPatient, BuildCode, BuildQuantity } from '@cosyte/ccda';
|
|
3
|
+
import { C as CodeConcept, Q as QuantConcept } from '../example-codes-DeXcnCSK.cjs';
|
|
4
|
+
import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-DmkgoZdh.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Synthetic **C-CDA document generation** — a spec-clean Continuity of Care Document
|
|
8
|
+
* (CCD) or Referral Note built **through `@cosyte/ccda`'s `buildCcda`**, so template IDs, LOINC section
|
|
9
|
+
* codes, and structured/narrative agreement are the builder's own (spec-clean *by construction*), and
|
|
10
|
+
* every `recordTarget` / clinical identifier is drawn from the synthetic-safety providers.
|
|
11
|
+
*
|
|
12
|
+
* The document round-trips through `parseCcda` with **zero warnings** — the builder's round-trip-by-
|
|
13
|
+
* construction guarantee, re-verified independently by {@link ./round-trip.roundTrip}. Coverage tracks
|
|
14
|
+
* `buildCcda`'s section/doc-type maturity: the CCD SHALL sections (Problems,
|
|
15
|
+
* Allergies, Medications, Results, Vital Signs) plus Immunizations, Procedures, and Social History
|
|
16
|
+
* (Smoking Status). Clinical *content* is drawn from the reused, license-clean example-code pools; a
|
|
17
|
+
* `synth` document exercises the parser, it is **not** a clinically-coherent record.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** The C-CDA document type a generator emits — the two `buildCcda` supports. */
|
|
23
|
+
type CcdaDocumentType = "ccd" | "referralNote";
|
|
24
|
+
/** Options common to every C-CDA generator. */
|
|
25
|
+
interface GenerateCcdaOptions {
|
|
26
|
+
/** The seed (deterministic — same seed yields a byte-identical document). Defaults to `0`. */
|
|
27
|
+
readonly seed?: number;
|
|
28
|
+
/** The document type to emit. Defaults to `"ccd"`. */
|
|
29
|
+
readonly documentType?: CcdaDocumentType;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate a spec-clean synthetic C-CDA document (CCD by default, or Referral Note), built through
|
|
33
|
+
* `@cosyte/ccda`'s `buildCcda`. The returned {@link CcdaDocument} round-trips through `parseCcda` with
|
|
34
|
+
* zero warnings, and the same seed yields a byte-identical document.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Seed and document type. See {@link GenerateCcdaOptions}.
|
|
37
|
+
* @returns The `@cosyte/ccda` `CcdaDocument` (serialize via `serializeCcda(doc)` or `doc.toString()`).
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { generateCcda } from "@cosyte/synth/ccda";
|
|
41
|
+
* import { serializeCcda } from "@cosyte/ccda";
|
|
42
|
+
* const xml = serializeCcda(generateCcda({ seed: 42 }));
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare function generateCcda(options?: GenerateCcdaOptions): CcdaDocument;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a spec-clean synthetic **Continuity of Care Document (CCD)**.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Seed (deterministic). See {@link GenerateCcdaOptions}.
|
|
50
|
+
* @returns The `CcdaDocument`.
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { generateCcd, roundTrip } from "@cosyte/synth/ccda";
|
|
54
|
+
* roundTrip(generateCcd({ seed: 1 })).specClean; // true
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function generateCcd(options?: Omit<GenerateCcdaOptions, "documentType">): CcdaDocument;
|
|
58
|
+
/**
|
|
59
|
+
* Generate a spec-clean synthetic **Referral Note** — the second document type `buildCcda` supports,
|
|
60
|
+
* with its own US Realm Header specialization and Reason-for-Referral / Assessment narrative sections.
|
|
61
|
+
*
|
|
62
|
+
* @param options - Seed (deterministic). See {@link GenerateCcdaOptions}.
|
|
63
|
+
* @returns The `CcdaDocument`.
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { generateReferralNote } from "@cosyte/synth/ccda";
|
|
67
|
+
* generateReferralNote({ seed: 1 }).documentType; // "referralNote"
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function generateReferralNote(options?: Omit<GenerateCcdaOptions, "documentType">): CcdaDocument;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The **round-trip-through-the-parser harness** for C-CDA — the headline gate for the synthetic-fixture
|
|
74
|
+
* generator. A generated document is "spec-clean" only if `@cosyte/ccda` — not
|
|
75
|
+
* `@cosyte/synth`'s own opinion — reads it back cleanly. This harness serializes a generated document,
|
|
76
|
+
* parses it straight back through `parseCcda`, and reports what the parser found, so a false
|
|
77
|
+
* "spec-clean" claim cannot hide.
|
|
78
|
+
*
|
|
79
|
+
* `@cosyte/ccda`'s `buildCcda` is round-trip-by-construction (it emits through the same DOM the parser
|
|
80
|
+
* reads), so a clean build carries zero warnings — but this harness re-verifies that *independently*,
|
|
81
|
+
* against the parser, because the parser is the judge.
|
|
82
|
+
*
|
|
83
|
+
* @module
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/** The verdict of one round-trip through `@cosyte/ccda`. */
|
|
87
|
+
interface RoundTripResult {
|
|
88
|
+
/** The serialized C-CDA XML (the builder/serializer's own conservative emit). */
|
|
89
|
+
readonly content: string;
|
|
90
|
+
/** The warning codes the parser emitted on re-parse. Empty ⇒ spec-clean. */
|
|
91
|
+
readonly warnings: readonly string[];
|
|
92
|
+
/** Whether re-serializing the re-parsed document is byte-identical to `content`. */
|
|
93
|
+
readonly byteStable: boolean;
|
|
94
|
+
/** `true` iff the artifact is spec-clean: zero warnings **and** byte-stable. */
|
|
95
|
+
readonly specClean: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Round-trip a generated `@cosyte/ccda` `CcdaDocument` through serialize → parse → serialize and report
|
|
99
|
+
* the verdict. A spec-clean document re-parses with **zero warnings** and re-serializes byte-identically.
|
|
100
|
+
*
|
|
101
|
+
* @param doc - The document to check (typically from {@link ./ccd.generateCcd}).
|
|
102
|
+
* @returns The {@link RoundTripResult}.
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { generateCcd, roundTrip } from "@cosyte/synth/ccda";
|
|
106
|
+
* const { specClean, warnings } = roundTrip(generateCcd({ seed: 1 }));
|
|
107
|
+
* // specClean === true, warnings.length === 0
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare function roundTrip(doc: CcdaDocument): RoundTripResult;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Synthetic C-CDA patient identity — the `recordTarget` demographics for a generated document, every
|
|
114
|
+
* field minted from the synthetic-safety providers in `../safe`. No value a generated
|
|
115
|
+
* C-CDA carries at a PHI locus can be real or plausibly-real: the name is from the shipped fake-name
|
|
116
|
+
* pool, the MRN lives under the synthetic assigning-authority OID (never a real facility namespace),
|
|
117
|
+
* and the birth date comes from the seeded generator (never wall-clock).
|
|
118
|
+
*
|
|
119
|
+
* The draw order is **fixed** (name → MRN → DOB → gender) so the same seed yields the same identity —
|
|
120
|
+
* the reproducibility contract.
|
|
121
|
+
*
|
|
122
|
+
* @module
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/** A synthetic C-CDA patient identity — the values threaded into a document's `recordTarget`. */
|
|
126
|
+
interface CcdaPatientIdentity {
|
|
127
|
+
/** The `BuildCcdaPatient` `@cosyte/ccda` consumes for the single `recordTarget`. */
|
|
128
|
+
readonly patient: BuildCcdaPatient;
|
|
129
|
+
/** The name from the shipped fake-name pool (also used to compose synthetic narrative/email). */
|
|
130
|
+
readonly person: SyntheticName;
|
|
131
|
+
/** The medical-record identifier, scoped to the synthetic assigning authority. */
|
|
132
|
+
readonly mrn: SyntheticIdentifier;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Mint a complete synthetic {@link CcdaPatientIdentity}. Every value comes from a synthetic-safety
|
|
136
|
+
* provider — no code path here can return a real identifier. The MRN is scoped to the
|
|
137
|
+
* synthetic assigning-authority OID (`mrnRoot`), so it is non-colliding by *namespace*, not by value.
|
|
138
|
+
*
|
|
139
|
+
* @param rng - The seeded generator.
|
|
140
|
+
* @returns A synthetic {@link CcdaPatientIdentity}.
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { createRng } from "@cosyte/synth";
|
|
144
|
+
* import { ccdaPatientIdentity } from "@cosyte/synth/ccda";
|
|
145
|
+
* // const { patient } = ccdaPatientIdentity(createRng(1));
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
declare function ccdaPatientIdentity(rng: Rng): CcdaPatientIdentity;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The C-CDA example-code pool — a thin adapter that **reuses** the same license-clean, public
|
|
152
|
+
* code facts the FHIR generators ship (`../fhir/example-codes.ts`), reshaped into `@cosyte/ccda`'s
|
|
153
|
+
* `BuildCode` tuple (an OID `codeSystem` instead of a FHIR `system` URI). Reusing one source of truth
|
|
154
|
+
* keeps the LOINC / RxNorm / SNOMED / CVX pools consistent across the FHIR and C-CDA surfaces;
|
|
155
|
+
* `@cosyte/synth` still bundles
|
|
156
|
+
* **no** terminology content — these are public spec-example codes, not copyrighted tables.
|
|
157
|
+
*
|
|
158
|
+
* Nothing here is PHI: codes and their display text are not patient identifiers. The synthetic-safety
|
|
159
|
+
* invariant governs identity fields (name / DOB / MRN / telecom), which come from `../safe`.
|
|
160
|
+
*
|
|
161
|
+
* @module
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Adapt a FHIR {@link CodeConcept} to a `@cosyte/ccda` {@link BuildCode}, resolving its `system` URI to
|
|
166
|
+
* the matching OID. The `codeSystem` is always set explicitly (never left to a per-slot default), so a
|
|
167
|
+
* SNOMED allergen or a LOINC panel carries the right OID regardless of which builder slot consumes it.
|
|
168
|
+
*
|
|
169
|
+
* @param concept - The FHIR-shaped `{ system, code, display }` concept.
|
|
170
|
+
* @returns The `@cosyte/ccda` `BuildCode`.
|
|
171
|
+
* @throws {Error} When the concept's `system` URI has no known OID mapping.
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* import { toBuildCode } from "@cosyte/synth/ccda";
|
|
175
|
+
* // toBuildCode({ system: "http://snomed.info/sct", code: "59621000", display: "Essential hypertension" });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
declare function toBuildCode(concept: CodeConcept): BuildCode;
|
|
179
|
+
/**
|
|
180
|
+
* Draw a synthetic-but-structurally-sane {@link BuildQuantity} for a quantitative concept — a value in
|
|
181
|
+
* the concept's plausible band (from the seeded generator, so reproducible) rendered to the concept's
|
|
182
|
+
* decimal precision, with its UCUM unit. The value implies **no** real measurement.
|
|
183
|
+
*
|
|
184
|
+
* @param rng - The seeded generator.
|
|
185
|
+
* @param concept - The quantitative concept (LOINC code + UCUM unit + value band).
|
|
186
|
+
* @returns A `BuildQuantity` (`{ value, unit }`) for the C-CDA builder.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* import { createRng } from "@cosyte/synth";
|
|
190
|
+
* import { quantityFor, LAB_RESULTS } from "@cosyte/synth/ccda";
|
|
191
|
+
* // quantityFor(createRng(1), LAB_RESULTS[0]);
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
declare function quantityFor(rng: Rng, concept: QuantConcept): BuildQuantity;
|
|
195
|
+
/** SNOMED CT problem/condition example codes (Problems / Past Medical History). */
|
|
196
|
+
declare const PROBLEMS: readonly CodeConcept[];
|
|
197
|
+
/** RxNorm / SNOMED CT allergen example codes (Allergies). */
|
|
198
|
+
declare const ALLERGENS: readonly CodeConcept[];
|
|
199
|
+
/** SNOMED CT allergy-reaction manifestation example codes. */
|
|
200
|
+
declare const ALLERGY_REACTIONS: readonly CodeConcept[];
|
|
201
|
+
/** RxNorm medication example codes (Medications). */
|
|
202
|
+
declare const MEDICATIONS: readonly CodeConcept[];
|
|
203
|
+
/** LOINC laboratory-result example codes with UCUM units + value bands (Results members). */
|
|
204
|
+
declare const LAB_RESULTS: readonly QuantConcept[];
|
|
205
|
+
/** LOINC panel example codes (the Result Organizer `code`). */
|
|
206
|
+
declare const RESULT_PANELS: readonly CodeConcept[];
|
|
207
|
+
/** LOINC vital-sign example codes with UCUM units + value bands (Vital Signs members). */
|
|
208
|
+
declare const VITAL_SIGNS: readonly QuantConcept[];
|
|
209
|
+
/** CVX vaccine example codes (Immunizations). */
|
|
210
|
+
declare const VACCINES: readonly CodeConcept[];
|
|
211
|
+
/** SNOMED CT procedure example codes (Procedures). */
|
|
212
|
+
declare const PROCEDURES: readonly CodeConcept[];
|
|
213
|
+
/**
|
|
214
|
+
* SNOMED CT Current Smoking Status value-set example codes (Social History). Public SNOMED CT
|
|
215
|
+
* identifiers used as structural fillers; `@cosyte/synth` bundles no SNOMED content.
|
|
216
|
+
*/
|
|
217
|
+
declare const SMOKING_STATUSES: readonly BuildCode[];
|
|
218
|
+
/**
|
|
219
|
+
* NCI Thesaurus administration-route example codes (Medications / Immunizations `route`). Public NCI
|
|
220
|
+
* concept ids used as structural fillers.
|
|
221
|
+
*/
|
|
222
|
+
declare const ROUTES: readonly BuildCode[];
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* C-CDA **vendor-quirk generation**. A quirk deviates the
|
|
226
|
+
* *structure* of an otherwise spec-clean document (built through `@cosyte/ccda`'s `buildCcda`) so it
|
|
227
|
+
* round-trips through `parseCcda` to **exactly** one intended, stable warning code — the tolerance a
|
|
228
|
+
* `defineCcdaProfile` profile encodes. With the matching built-in profile active, that warning is
|
|
229
|
+
* **re-badged** to the value-free `PROFILE_QUIRK_APPLIED` marker (`expected: true`, `toleratedCode` = the
|
|
230
|
+
* original), exactly as the parser's `profileQuirkApplied` does.
|
|
231
|
+
*
|
|
232
|
+
* The deviation is applied **post-serialize**. Three quirks ship, each
|
|
233
|
+
* publicly grounded and re-badged by a built-in public profile:
|
|
234
|
+
*
|
|
235
|
+
* - **`template-extension-absent`** → `TEMPLATE_EXTENSION_ABSENT` (profile `legacyR11`). The R2.1
|
|
236
|
+
* `@extension="2015-08-01"` version stamp is dropped from the document-type templateId — a legacy
|
|
237
|
+
* R1.1-era document shape.
|
|
238
|
+
* - **`deprecated-loinc`** → `DEPRECATED_LOINC` (profile `smartScorecard`). A result/vital observation
|
|
239
|
+
* LOINC code is swapped to a known-deprecated LOINC (`41909-3`).
|
|
240
|
+
* - **`deprecated-code-system`** → `DEPRECATED_CODE_SYSTEM` (profile `smartScorecard`). A problem
|
|
241
|
+
* observation's value is swapped to a deprecated code system (ICD-9-CM `2.16.840.1.113883.6.103`).
|
|
242
|
+
*
|
|
243
|
+
* A quirk **never** introduces a real-looking value — it changes a template stamp or a code, never a PHI
|
|
244
|
+
* locus, so the synthetic-safety gate still runs and stays zero.
|
|
245
|
+
*
|
|
246
|
+
* @module
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
/** Every C-CDA quirk this package ships. */
|
|
250
|
+
type CcdaQuirkName = "template-extension-absent" | "deprecated-loinc" | "deprecated-code-system";
|
|
251
|
+
/** The C-CDA quirk registry — each recipe bound to the exact `@cosyte/ccda` warning code it targets. */
|
|
252
|
+
declare const CCDA_QUIRKS: Readonly<Record<CcdaQuirkName, QuirkDescriptor>>;
|
|
253
|
+
/**
|
|
254
|
+
* Apply a C-CDA quirk transform to a spec-clean document, or **fail closed**. Refuses to return a
|
|
255
|
+
* document that does not carry the intended deviation (a quirk whose structural anchor is absent) —
|
|
256
|
+
* a fixture that silently lost its quirk would test the wrong thing.
|
|
257
|
+
*
|
|
258
|
+
* @param quirk - The quirk to inject.
|
|
259
|
+
* @param cleanXml - The spec-clean C-CDA XML.
|
|
260
|
+
* @returns The quirked XML.
|
|
261
|
+
* @throws Error when the quirk found no structural anchor to mutate.
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* import { injectCcdaQuirk } from "@cosyte/synth/ccda";
|
|
265
|
+
* injectCcdaQuirk("template-extension-absent", cleanXml);
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
declare function injectCcdaQuirk(quirk: CcdaQuirkName, cleanXml: string): string;
|
|
269
|
+
/** Options for {@link generateCcdaQuirk}. */
|
|
270
|
+
interface GenerateCcdaQuirkOptions {
|
|
271
|
+
/** The seed — the same seed + quirk yields a byte-identical document. Defaults to `0`. */
|
|
272
|
+
readonly seed?: number;
|
|
273
|
+
/** The quirk to inject. Required. */
|
|
274
|
+
readonly quirk: CcdaQuirkName;
|
|
275
|
+
/** The spec-clean base document type. Defaults to `"ccd"`. */
|
|
276
|
+
readonly documentType?: CcdaDocumentType;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Generate one C-CDA **quirk** artifact: a spec-clean document (built through `@cosyte/ccda`'s
|
|
280
|
+
* `buildCcda`) with the requested vendor deviation injected post-serialize. Deterministic in `seed` +
|
|
281
|
+
* `quirk` + `documentType`.
|
|
282
|
+
*
|
|
283
|
+
* @param options - Seed, quirk, and base document type. See {@link GenerateCcdaQuirkOptions}.
|
|
284
|
+
* @returns The {@link QuirkArtifact} — its `content` round-trips to `intendedWarnings` exactly.
|
|
285
|
+
* @throws SynthError `SYNTH_UNSUPPORTED_QUIRK` if `quirk` is not a supported C-CDA quirk.
|
|
286
|
+
* @throws Error if the base document does not contain the structural anchor the quirk targets.
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* import { generateCcdaQuirk, ccdaQuirkRoundTrip } from "@cosyte/synth/ccda";
|
|
290
|
+
* const rt = ccdaQuirkRoundTrip(generateCcdaQuirk({ seed: 1, quirk: "deprecated-loinc" }));
|
|
291
|
+
* rt.withProfile?.tolerated; // true — `smartScorecard` re-badges DEPRECATED_LOINC
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function generateCcdaQuirk(options: GenerateCcdaQuirkOptions): QuirkArtifact;
|
|
295
|
+
/**
|
|
296
|
+
* Round-trip a C-CDA quirk artifact through `@cosyte/ccda` and report the intended-warning verdict: a bare
|
|
297
|
+
* parse must produce **exactly** the intended code, and the matching public profile
|
|
298
|
+
* must re-badge it to `PROFILE_QUIRK_APPLIED`.
|
|
299
|
+
*
|
|
300
|
+
* @param artifact - The quirk artifact (from {@link generateCcdaQuirk}).
|
|
301
|
+
* @returns The {@link QuirkRoundTripResult}.
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* import { generateCcdaQuirk, ccdaQuirkRoundTrip } from "@cosyte/synth/ccda";
|
|
305
|
+
* ccdaQuirkRoundTrip(generateCcdaQuirk({ seed: 1, quirk: "deprecated-loinc" })).intendedWarningHeld;
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
declare function ccdaQuirkRoundTrip(artifact: QuirkArtifact): QuirkRoundTripResult;
|
|
309
|
+
/** Options for {@link ccdaQuirkCorpus}. */
|
|
310
|
+
interface CcdaQuirkCorpusOptions {
|
|
311
|
+
/** The seed for the whole corpus (deterministic). */
|
|
312
|
+
readonly seed: number;
|
|
313
|
+
/** How many quirk artifacts to generate. Defaults to the number of quirks. */
|
|
314
|
+
readonly count?: number;
|
|
315
|
+
/** The quirk names to cycle through. Defaults to every C-CDA quirk. Validated; unsupported ⇒ fatal. */
|
|
316
|
+
readonly quirks?: readonly CcdaQuirkName[];
|
|
317
|
+
/** A {@link SynthProfile} whose `quirks` drive the corpus (validated). Takes precedence over `quirks`. */
|
|
318
|
+
readonly profile?: SynthProfile;
|
|
319
|
+
/** The base document type each quirk is injected into. Defaults to `"ccd"`. */
|
|
320
|
+
readonly documentType?: CcdaDocumentType;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Build a reproducible {@link Corpus} of C-CDA quirk artifacts. Each artifact's `warnings` record the
|
|
324
|
+
* intended code for its quirk; the manifest lists the applied quirk names.
|
|
325
|
+
*
|
|
326
|
+
* @param options - Seed, count, and the quirk selection. See {@link CcdaQuirkCorpusOptions}.
|
|
327
|
+
* @returns A deep-frozen {@link Corpus}.
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* import { ccdaQuirkCorpus } from "@cosyte/synth/ccda";
|
|
331
|
+
* ccdaQuirkCorpus({ seed: 42 }).manifest.quirks; // the applied quirk names
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
declare function ccdaQuirkCorpus(options: CcdaQuirkCorpusOptions): Corpus;
|
|
335
|
+
/** A ready-made {@link SynthProfile} requesting every built-in C-CDA quirk. */
|
|
336
|
+
declare const ccdaQuirkProfile: SynthProfile;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* `@cosyte/synth/ccda` — the C-CDA generation surface, exposed as its own subpath so importing the
|
|
340
|
+
* package root does **not** pull `@cosyte/ccda`. This is the **lazy, per-format** boundary: a consumer
|
|
341
|
+
* who only needs C-CDA fixtures imports `@cosyte/synth/ccda`; one who needs only the core primitives
|
|
342
|
+
* never loads a parser.
|
|
343
|
+
* `@cosyte/ccda` is an **optional peer dependency** — present only for this subpath.
|
|
344
|
+
*
|
|
345
|
+
* This subpath ships spec-clean C-CDA document generation via `@cosyte/ccda`'s
|
|
346
|
+
* `buildCcda`: a **CCD** (`generateCcd`) and a **Referral Note** (`generateReferralNote`), each built
|
|
347
|
+
* through the parser's own emitter so it round-trips through `parseCcda` with zero warnings, and each
|
|
348
|
+
* drawing every identity value from the synthetic-safety providers.
|
|
349
|
+
*
|
|
350
|
+
* @module
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
/** Every C-CDA document kind {@link ccdaCorpus} generates — the `documentType` used as the corpus `kind`. */
|
|
354
|
+
type CcdaCorpusKind = CcdaDocumentType;
|
|
355
|
+
/** Options for {@link ccdaCorpus}. */
|
|
356
|
+
interface CcdaCorpusOptions {
|
|
357
|
+
/** The seed for the whole corpus (deterministic). */
|
|
358
|
+
readonly seed: number;
|
|
359
|
+
/** How many documents to generate. Defaults to `1`. */
|
|
360
|
+
readonly count?: number;
|
|
361
|
+
/** The document types to cycle through. Defaults to one CCD + one Referral Note. */
|
|
362
|
+
readonly mix?: readonly CcdaCorpusKind[];
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Build a reproducible {@link Corpus} of spec-clean C-CDA documents. Each document is generated from a
|
|
366
|
+
* distinct sub-seed derived from the corpus seed (so the set is deterministic) and round-tripped through
|
|
367
|
+
* `@cosyte/ccda`; the per-artifact `warnings` record the parser's verdict (empty ⇒ spec-clean).
|
|
368
|
+
*
|
|
369
|
+
* @param options - Seed, count, and the document mix. See {@link CcdaCorpusOptions}.
|
|
370
|
+
* @returns A deep-frozen {@link Corpus}.
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* import { ccdaCorpus } from "@cosyte/synth/ccda";
|
|
374
|
+
* const corpus = ccdaCorpus({ seed: 42, count: 4 });
|
|
375
|
+
* corpus.artifacts.every((a) => a.warnings.length === 0); // true — spec-clean
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
declare function ccdaCorpus(options: CcdaCorpusOptions): Corpus;
|
|
379
|
+
|
|
380
|
+
export { ALLERGENS, ALLERGY_REACTIONS, CCDA_QUIRKS, type CcdaCorpusKind, type CcdaCorpusOptions, type CcdaDocumentType, type CcdaPatientIdentity, type CcdaQuirkCorpusOptions, type CcdaQuirkName, type GenerateCcdaOptions, type GenerateCcdaQuirkOptions, LAB_RESULTS, MEDICATIONS, PROBLEMS, PROCEDURES, RESULT_PANELS, ROUTES, type RoundTripResult, SMOKING_STATUSES, VACCINES, VITAL_SIGNS, ccdaCorpus, ccdaPatientIdentity, ccdaQuirkCorpus, ccdaQuirkProfile, ccdaQuirkRoundTrip, generateCcd, generateCcda, generateCcdaQuirk, generateReferralNote, injectCcdaQuirk, quantityFor, roundTrip, toBuildCode };
|