@cosyte/synth 0.0.6 → 0.0.8
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 +165 -17
- package/README.md +47 -45
- package/dist/astm/index.cjs +7 -7
- package/dist/astm/index.cjs.map +1 -1
- package/dist/astm/index.d.cts +47 -47
- package/dist/astm/index.d.ts +47 -47
- package/dist/astm/index.mjs +7 -7
- package/dist/astm/index.mjs.map +1 -1
- package/dist/ccda/index.cjs +15 -15
- package/dist/ccda/index.cjs.map +1 -1
- package/dist/ccda/index.d.cts +31 -31
- package/dist/ccda/index.d.ts +31 -31
- package/dist/ccda/index.mjs +15 -15
- package/dist/ccda/index.mjs.map +1 -1
- package/dist/deid/index.cjs +15 -15
- package/dist/deid/index.cjs.map +1 -1
- package/dist/deid/index.d.cts +37 -37
- package/dist/deid/index.d.ts +37 -37
- package/dist/deid/index.mjs +15 -15
- package/dist/deid/index.mjs.map +1 -1
- package/dist/{example-codes-DeXcnCSK.d.cts → example-codes-88f3_bQZ.d.cts} +8 -8
- package/dist/{example-codes-DeXcnCSK.d.ts → example-codes-88f3_bQZ.d.ts} +8 -8
- package/dist/fhir/index.cjs +12 -12
- package/dist/fhir/index.cjs.map +1 -1
- package/dist/fhir/index.d.cts +46 -46
- package/dist/fhir/index.d.ts +46 -46
- package/dist/fhir/index.mjs +12 -12
- package/dist/fhir/index.mjs.map +1 -1
- package/dist/hl7/index.cjs +6 -6
- package/dist/hl7/index.cjs.map +1 -1
- package/dist/hl7/index.d.cts +45 -45
- package/dist/hl7/index.d.ts +45 -45
- package/dist/hl7/index.mjs +6 -6
- package/dist/hl7/index.mjs.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -49
- package/dist/index.d.ts +49 -49
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/dist/ncpdp/index.cjs +3 -3
- package/dist/ncpdp/index.cjs.map +1 -1
- package/dist/ncpdp/index.d.cts +42 -42
- package/dist/ncpdp/index.d.ts +42 -42
- package/dist/ncpdp/index.mjs +3 -3
- package/dist/ncpdp/index.mjs.map +1 -1
- package/dist/{providers-OLz3zAc-.d.cts → providers-B9uVinAe.d.cts} +24 -24
- package/dist/{providers-OLz3zAc-.d.ts → providers-B9uVinAe.d.ts} +24 -24
- package/dist/{quirk-C9t9CkPS.d.ts → quirk-HZdznAkM.d.ts} +23 -23
- package/dist/{quirk-DYMDojVw.d.cts → quirk-IaHp4z7N.d.cts} +23 -23
- package/dist/x12/index.cjs +6 -6
- package/dist/x12/index.cjs.map +1 -1
- package/dist/x12/index.d.cts +44 -44
- package/dist/x12/index.d.ts +44 -44
- package/dist/x12/index.mjs +6 -6
- package/dist/x12/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/astm/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as SyntheticName, R as Rng, C as Corpus } from '../providers-
|
|
2
|
-
import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-
|
|
1
|
+
import { S as SyntheticName, R as Rng, C as Corpus } from '../providers-B9uVinAe.cjs';
|
|
2
|
+
import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-IaHp4z7N.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Spec-clean ASTM (E1394 / CLSI LIS02) message generation
|
|
5
|
+
* Spec-clean ASTM (E1394 / CLSI LIS02) message generation: the `H`/`P`/`O`/`R`/`C`/`L` record report,
|
|
6
6
|
* built through `@cosyte/astm`'s `buildAstmMessage` so the delimiter declaration (`H|\^&`), the record
|
|
7
7
|
* type letters, the per-type sequence counters, the `L` terminator, and every escape are the parser's
|
|
8
8
|
* own conservative emit. Nothing clinical is defaulted: a
|
|
@@ -10,8 +10,8 @@ import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as Quirk
|
|
|
10
10
|
*
|
|
11
11
|
* A framed **E1381 / CLSI LIS01** variant is also offered ({@link generateAstmResultFramed}) via
|
|
12
12
|
* `composeAstmFrames`, which frames each record into `<STX> FN text <ETB|ETX> CS <CR><LF>` with the
|
|
13
|
-
* **modulo-256 checksum and the `0`–`7` frame number computed by the parser
|
|
14
|
-
* trip through `@cosyte/astm` cleanly (`parseAstmRecords` / `parseFramedAstm
|
|
13
|
+
* **modulo-256 checksum and the `0`–`7` frame number computed by the parser**, never faked. Both round
|
|
14
|
+
* trip through `@cosyte/astm` cleanly (`parseAstmRecords` / `parseFramedAstm`: see `./round-trip`).
|
|
15
15
|
*
|
|
16
16
|
* Every value at a PHI-bearing locus (the `P` record's name / DOB / practice+lab IDs) is
|
|
17
17
|
* drawn from the synthetic-safety providers via `./identity`, so no output can be real or plausibly-real
|
|
@@ -22,7 +22,7 @@ import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as Quirk
|
|
|
22
22
|
*/
|
|
23
23
|
/** Options for the ASTM message generators. */
|
|
24
24
|
interface GenerateAstmOptions {
|
|
25
|
-
/** The seed (deterministic
|
|
25
|
+
/** The seed (deterministic: same seed yields a byte-identical message). */
|
|
26
26
|
readonly seed: number;
|
|
27
27
|
/** How many `R` (result) records to emit. Defaults to a seeded 1–4. */
|
|
28
28
|
readonly resultCount?: number;
|
|
@@ -30,7 +30,7 @@ interface GenerateAstmOptions {
|
|
|
30
30
|
readonly comment?: boolean;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Generate a spec-clean ASTM **result message
|
|
33
|
+
* Generate a spec-clean ASTM **result message**: an `H`/`P`/`O`/`R`…/`C`/`L` record stream, built
|
|
34
34
|
* through `@cosyte/astm`'s `buildAstmMessage`. Every identity value is synthetic-by-construction; the message
|
|
35
35
|
* round-trips through `parseAstmRecords` with zero warnings and re-serializes
|
|
36
36
|
* byte-identically (see `./round-trip`).
|
|
@@ -45,7 +45,7 @@ interface GenerateAstmOptions {
|
|
|
45
45
|
*/
|
|
46
46
|
declare function generateAstmResult(options: GenerateAstmOptions): string;
|
|
47
47
|
/**
|
|
48
|
-
* Generate a spec-clean ASTM **order message
|
|
48
|
+
* Generate a spec-clean ASTM **order message**: an `H`/`P`/`O`/`L` record stream with no results, for
|
|
49
49
|
* the order side of the flow. Built through `buildAstmMessage`; synthetic-by-construction; round-trips
|
|
50
50
|
* clean.
|
|
51
51
|
*
|
|
@@ -59,10 +59,10 @@ declare function generateAstmResult(options: GenerateAstmOptions): string;
|
|
|
59
59
|
*/
|
|
60
60
|
declare function generateAstmOrder(options: GenerateAstmOptions): string;
|
|
61
61
|
/**
|
|
62
|
-
* Generate a spec-clean **framed** ASTM result message
|
|
62
|
+
* Generate a spec-clean **framed** ASTM result message: the same `H`/`P`/`O`/`R`…/`C`/`L` records,
|
|
63
63
|
* wrapped in the **E1381 / CLSI LIS01** frame envelope (`<STX> FN text <ETB|ETX> CS <CR><LF>`) via
|
|
64
64
|
* `@cosyte/astm`'s `composeAstmFrames`. The **modulo-256 checksum and the `0`–`7` frame number are
|
|
65
|
-
* computed by the parser** (never hand-written), and a record over 240 bytes is split across frames
|
|
65
|
+
* computed by the parser** (never hand-written), and a record over 240 bytes is split across frames,
|
|
66
66
|
* so the bytes round-trip through `parseFramedAstm` with zero frame **and** record warnings (see
|
|
67
67
|
* `./round-trip`). Each record is framed independently (one `ETX`-closed run per record), mirroring what
|
|
68
68
|
* `decodeAstmFrames` reassembles.
|
|
@@ -72,21 +72,21 @@ declare function generateAstmOrder(options: GenerateAstmOptions): string;
|
|
|
72
72
|
* @example
|
|
73
73
|
* ```ts
|
|
74
74
|
* import { generateAstmResultFramed } from "@cosyte/synth/astm";
|
|
75
|
-
* const bytes = generateAstmResultFramed({ seed: 42 }); // Uint8Array
|
|
75
|
+
* const bytes = generateAstmResultFramed({ seed: 42 }); // Uint8Array, E1381 framed
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
78
|
declare function generateAstmResultFramed(options: GenerateAstmOptions): Uint8Array;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* The **round-trip-through-the-parser harness** for ASTM
|
|
81
|
+
* The **round-trip-through-the-parser harness** for ASTM: the headline gate for the synthetic-fixture
|
|
82
82
|
* generator. A generated ASTM record stream (or framed byte stream) is "spec-clean" only
|
|
83
|
-
* if `@cosyte/astm
|
|
83
|
+
* if `@cosyte/astm`, not `@cosyte/synth`'s own opinion, reads it back cleanly. Each harness parses the
|
|
84
84
|
* generated wire straight back through the parser and reports what it found, so a false "spec-clean"
|
|
85
85
|
* claim cannot hide.
|
|
86
86
|
*
|
|
87
87
|
* The **record** layer (E1394) and the **frame** layer (E1381) are separate concerns, so each gets its
|
|
88
88
|
* own harness; both report the same {@link AstmRoundTripResult} shape (the framed one additionally folds
|
|
89
|
-
* the frame-layer warnings
|
|
89
|
+
* the frame-layer warnings (bad checksum, sequence gap, unterminated, oversize) into `warnings`, so a
|
|
90
90
|
* framing defect is caught by the same gate).
|
|
91
91
|
*
|
|
92
92
|
* @module
|
|
@@ -122,7 +122,7 @@ declare function astmRoundTrip(raw: string): AstmRoundTripResult;
|
|
|
122
122
|
* byte-identically.
|
|
123
123
|
*
|
|
124
124
|
* @param bytes - The framed byte stream (typically from `generateAstmResultFramed`).
|
|
125
|
-
* @returns The {@link AstmRoundTripResult}
|
|
125
|
+
* @returns The {@link AstmRoundTripResult}: `content` holds the framed bytes decoded as latin1.
|
|
126
126
|
* @example
|
|
127
127
|
* ```ts
|
|
128
128
|
* import { generateAstmResultFramed, astmFramedRoundTrip } from "@cosyte/synth/astm";
|
|
@@ -132,7 +132,7 @@ declare function astmRoundTrip(raw: string): AstmRoundTripResult;
|
|
|
132
132
|
declare function astmFramedRoundTrip(bytes: Uint8Array): AstmRoundTripResult;
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Synthetic identity for ASTM (E1394 / CLSI LIS02) messages
|
|
135
|
+
* Synthetic identity for ASTM (E1394 / CLSI LIS02) messages: every value `synth` puts into a `P`
|
|
136
136
|
* (patient) record, an `O` (order) accession, or the `H` header is minted here, and **only** from the
|
|
137
137
|
* synthetic-safety providers. ASTM's PHI-dense locus is the **`P` record**: it carries the
|
|
138
138
|
* patient **name** (`Last^First^Middle`), **birthdate**, **sex**, and the **practice-assigned** and
|
|
@@ -146,7 +146,7 @@ declare function astmFramedRoundTrip(bytes: Uint8Array): AstmRoundTripResult;
|
|
|
146
146
|
* @module
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
|
-
/** A synthetic ASTM patient
|
|
149
|
+
/** A synthetic ASTM patient: every field drawn from `../safe`. */
|
|
150
150
|
interface AstmPatient {
|
|
151
151
|
/** Name from the shipped fake-name pool, plus a fictional middle initial. */
|
|
152
152
|
readonly person: SyntheticName;
|
|
@@ -154,21 +154,21 @@ interface AstmPatient {
|
|
|
154
154
|
readonly middle: string;
|
|
155
155
|
/** Birthdate `YYYYMMDD`, from the seeded generator (no real event implied). */
|
|
156
156
|
readonly birthDate: string;
|
|
157
|
-
/** Sex code, emitted verbatim (`M` / `F
|
|
157
|
+
/** Sex code, emitted verbatim (`M` / `F`, structural, never defaulted by the builder). */
|
|
158
158
|
readonly sex: "M" | "F";
|
|
159
|
-
/** Practice-assigned patient ID
|
|
159
|
+
/** Practice-assigned patient ID, synthetic-AA scoped (`PRA`-prefixed). Distinct from the lab ID. */
|
|
160
160
|
readonly practiceAssignedId: string;
|
|
161
|
-
/** Laboratory-assigned patient ID
|
|
161
|
+
/** Laboratory-assigned patient ID, synthetic-AA scoped (`LAB`-prefixed). Distinct from the practice ID. */
|
|
162
162
|
readonly laboratoryAssignedId: string;
|
|
163
163
|
}
|
|
164
|
-
/** A synthetic ASTM order identity
|
|
164
|
+
/** A synthetic ASTM order identity: the specimen / accession id and priority. */
|
|
165
165
|
interface AstmOrder {
|
|
166
|
-
/** Specimen / accession id
|
|
166
|
+
/** Specimen / accession id: synthetic-AA scoped (`ACC`-prefixed). */
|
|
167
167
|
readonly specimenId: string;
|
|
168
168
|
/** Priority code, emitted verbatim (`R` routine, `S` stat). */
|
|
169
169
|
readonly priority: "R" | "S";
|
|
170
170
|
}
|
|
171
|
-
/** A synthetic ASTM header identity
|
|
171
|
+
/** A synthetic ASTM header identity: the sender and analyzer strings for the `H` record. */
|
|
172
172
|
interface AstmHeaderIdentity {
|
|
173
173
|
/** The sending system id (clearly synthetic). */
|
|
174
174
|
readonly sender: string;
|
|
@@ -191,7 +191,7 @@ interface AstmHeaderIdentity {
|
|
|
191
191
|
*/
|
|
192
192
|
declare function astmPatient(rng: Rng): AstmPatient;
|
|
193
193
|
/**
|
|
194
|
-
* Mint a synthetic order identity for an `O` record
|
|
194
|
+
* Mint a synthetic order identity for an `O` record: a synthetic-AA-scoped accession id and a priority.
|
|
195
195
|
*
|
|
196
196
|
* @param rng - The seeded generator.
|
|
197
197
|
* @returns A synthetic {@link AstmOrder}.
|
|
@@ -204,7 +204,7 @@ declare function astmPatient(rng: Rng): AstmPatient;
|
|
|
204
204
|
*/
|
|
205
205
|
declare function astmOrder(rng: Rng): AstmOrder;
|
|
206
206
|
/**
|
|
207
|
-
* Mint a synthetic header identity for the `H` record
|
|
207
|
+
* Mint a synthetic header identity for the `H` record: a clearly-synthetic sender and analyzer.
|
|
208
208
|
*
|
|
209
209
|
* @param rng - The seeded generator.
|
|
210
210
|
* @returns A synthetic {@link AstmHeaderIdentity}.
|
|
@@ -218,18 +218,18 @@ declare function astmOrder(rng: Rng): AstmOrder;
|
|
|
218
218
|
declare function astmHeaderIdentity(rng: Rng): AstmHeaderIdentity;
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
* A small, **license-clean** pool of example ASTM laboratory tests
|
|
221
|
+
* A small, **license-clean** pool of example ASTM laboratory tests: the analyte codes, units, and
|
|
222
222
|
* plausible value ranges `synth` draws on when populating `O` (order) and `R` (result) records. The
|
|
223
223
|
* codes are **facts** (a LOINC number is a public identifier, and the local analyzer codes here are
|
|
224
|
-
* invented), never a bundled terminology table. Nothing clinical is asserted
|
|
224
|
+
* invented), never a bundled terminology table. Nothing clinical is asserted: a `synth` result pairs a value
|
|
225
225
|
* and a code with no claim of clinical coherence: the pool exists only to make a *structurally* realistic
|
|
226
226
|
* result record.
|
|
227
227
|
*
|
|
228
228
|
* @module
|
|
229
229
|
*/
|
|
230
|
-
/** One example laboratory analyte
|
|
230
|
+
/** One example laboratory analyte: its codes, units, reference range, and a seeded value window. */
|
|
231
231
|
interface AstmExampleTest {
|
|
232
|
-
/** A local analyzer test code (invented
|
|
232
|
+
/** A local analyzer test code (invented, never a real vendor assay id). */
|
|
233
233
|
readonly localCode: string;
|
|
234
234
|
/** The public LOINC identifier for the analyte (a fact, not bundled terminology prose). */
|
|
235
235
|
readonly loinc: string;
|
|
@@ -248,7 +248,7 @@ interface AstmExampleTest {
|
|
|
248
248
|
}
|
|
249
249
|
/**
|
|
250
250
|
* The example test pool. A handful of common chemistry/hematology analytes, each with a public LOINC
|
|
251
|
-
* code, invented local code, units, and a value window the seeded generator samples. Frozen
|
|
251
|
+
* code, invented local code, units, and a value window the seeded generator samples. Frozen: the pool
|
|
252
252
|
* is shared, immutable data.
|
|
253
253
|
*
|
|
254
254
|
* @example
|
|
@@ -262,14 +262,14 @@ declare const EXAMPLE_ASTM_TESTS: readonly AstmExampleTest[];
|
|
|
262
262
|
declare const ASTM_ABNORMAL_FLAGS: readonly string[];
|
|
263
263
|
/** Result-status codes `synth` draws from (`F` final, `P` preliminary, `C` correction). */
|
|
264
264
|
declare const ASTM_RESULT_STATUSES: readonly string[];
|
|
265
|
-
/** Free-text result comments
|
|
265
|
+
/** Free-text result comments: clearly synthetic, carry no PHI. */
|
|
266
266
|
declare const ASTM_COMMENT_TEXT: readonly string[];
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
* ASTM E1394 **vendor-quirk generation**. A quirk deviates the
|
|
270
270
|
* *structure* of an otherwise spec-clean record report (built through `@cosyte/astm`'s
|
|
271
271
|
* `buildAstmMessage`) so it round-trips through `parseAstmRecords` to **exactly** one intended, stable
|
|
272
|
-
* warning code
|
|
272
|
+
* warning code: a code in the parser's `defineAstmProfile` tolerable set. Where a built-in public
|
|
273
273
|
* profile tolerates the quirk, the warning is **re-badged** to the value-free `PROFILE_QUIRK_APPLIED`
|
|
274
274
|
* marker (`expected: true`), exactly as the parser's `profileQuirkApplied` does.
|
|
275
275
|
*
|
|
@@ -280,11 +280,11 @@ declare const ASTM_COMMENT_TEXT: readonly string[];
|
|
|
280
280
|
* `referenceCorpus` profile (the redistributable kxepal/python-astm + senaite OSS corpus), which
|
|
281
281
|
* re-badges it.
|
|
282
282
|
* - **`unknown-record-type`** → `ASTM_RECORD_UNKNOWN_TYPE`. A record's leading type letter is changed to
|
|
283
|
-
* a site-defined `Z
|
|
283
|
+
* a site-defined `Z`: a real ASTM tolerance (the parser's tolerable set includes this code), but no
|
|
284
284
|
* built-in profile tolerates it, so it is a `"bare"` quirk (a consumer authors a `defineAstmProfile`
|
|
285
285
|
* to re-badge it).
|
|
286
286
|
*
|
|
287
|
-
* A quirk **never** introduces a real-looking value
|
|
287
|
+
* A quirk **never** introduces a real-looking value: it changes an escape body or a record type letter,
|
|
288
288
|
* never a P-record identity locus, so the synthetic-safety gate still runs and stays zero.
|
|
289
289
|
*
|
|
290
290
|
* @module
|
|
@@ -293,16 +293,16 @@ declare const ASTM_COMMENT_TEXT: readonly string[];
|
|
|
293
293
|
/** Every ASTM quirk this package ships. */
|
|
294
294
|
type AstmQuirkName = "unknown-escape" | "unknown-record-type";
|
|
295
295
|
/**
|
|
296
|
-
* Both shipped ASTM quirks are **result-report** deviations
|
|
296
|
+
* Both shipped ASTM quirks are **result-report** deviations: `unknown-escape` targets an `R` record's
|
|
297
297
|
* units field and `unknown-record-type` a `C` (comment) record, neither of which an *order* report
|
|
298
298
|
* carries. So the quirk base is always a result report (`generateAstmResult`).
|
|
299
299
|
*/
|
|
300
300
|
type AstmQuirkKind = "Result";
|
|
301
|
-
/** The ASTM quirk registry
|
|
301
|
+
/** The ASTM quirk registry: each recipe bound to the exact `@cosyte/astm` warning code it targets. */
|
|
302
302
|
declare const ASTM_QUIRKS: Readonly<Record<AstmQuirkName, QuirkDescriptor>>;
|
|
303
303
|
/** Options for {@link generateAstmQuirk}. */
|
|
304
304
|
interface GenerateAstmQuirkOptions {
|
|
305
|
-
/** The seed
|
|
305
|
+
/** The seed: the same seed + quirk yields a byte-identical record stream. Defaults to `0`. */
|
|
306
306
|
readonly seed?: number;
|
|
307
307
|
/** The quirk to inject. Required. */
|
|
308
308
|
readonly quirk: AstmQuirkName;
|
|
@@ -314,21 +314,21 @@ interface GenerateAstmQuirkOptions {
|
|
|
314
314
|
* the requested vendor deviation injected post-serialize. Deterministic in `seed` + `quirk` + `kind`.
|
|
315
315
|
*
|
|
316
316
|
* @param options - Seed, quirk, and base kind. See {@link GenerateAstmQuirkOptions}.
|
|
317
|
-
* @returns The {@link QuirkArtifact}
|
|
317
|
+
* @returns The {@link QuirkArtifact}: its `content` round-trips to `intendedWarnings` exactly.
|
|
318
318
|
* @throws SynthError `SYNTH_UNSUPPORTED_QUIRK` if `quirk` is not a supported ASTM quirk.
|
|
319
319
|
* @throws Error if the base report does not contain the structural anchor the quirk targets.
|
|
320
320
|
* @example
|
|
321
321
|
* ```ts
|
|
322
322
|
* import { generateAstmQuirk, astmQuirkRoundTrip } from "@cosyte/synth/astm";
|
|
323
323
|
* const rt = astmQuirkRoundTrip(generateAstmQuirk({ seed: 1, quirk: "unknown-escape" }));
|
|
324
|
-
* rt.withProfile?.tolerated; // true
|
|
324
|
+
* rt.withProfile?.tolerated; // true, `referenceCorpus` re-badges ASTM_UNKNOWN_ESCAPE_SEQUENCE
|
|
325
325
|
* ```
|
|
326
326
|
*/
|
|
327
327
|
declare function generateAstmQuirk(options: GenerateAstmQuirkOptions): QuirkArtifact;
|
|
328
328
|
/**
|
|
329
329
|
* Round-trip an ASTM quirk artifact through `@cosyte/astm` and report the intended-warning verdict: a bare
|
|
330
|
-
* parse must produce **exactly** the intended code, and
|
|
331
|
-
* profile tolerates the quirk
|
|
330
|
+
* parse must produce **exactly** the intended code, and, when a built-in public
|
|
331
|
+
* profile tolerates the quirk, the profiled parse must re-badge it to `PROFILE_QUIRK_APPLIED`.
|
|
332
332
|
*
|
|
333
333
|
* @param artifact - The quirk artifact (from {@link generateAstmQuirk}).
|
|
334
334
|
* @returns The {@link QuirkRoundTripResult}.
|
|
@@ -367,28 +367,28 @@ declare function astmQuirkCorpus(options: AstmQuirkCorpusOptions): Corpus;
|
|
|
367
367
|
declare const astmQuirkProfile: SynthProfile;
|
|
368
368
|
|
|
369
369
|
/**
|
|
370
|
-
* `@cosyte/synth/astm
|
|
370
|
+
* `@cosyte/synth/astm`: the ASTM generation surface, exposed as its own subpath so importing the
|
|
371
371
|
* package root does **not** pull `@cosyte/astm`. This is the **lazy, per-format** boundary: a consumer
|
|
372
372
|
* who only needs ASTM fixtures imports `@cosyte/synth/astm`; one who needs only the core primitives
|
|
373
373
|
* never loads a parser.
|
|
374
|
-
* `@cosyte/astm` is an **optional peer dependency
|
|
374
|
+
* `@cosyte/astm` is an **optional peer dependency**, present only for this subpath.
|
|
375
375
|
*
|
|
376
376
|
* This subpath ships spec-clean generation of the E1394 record report and its E1381 framed twin, each
|
|
377
377
|
* built through `@cosyte/astm`'s own emit surface:
|
|
378
378
|
*
|
|
379
379
|
* - **Records (E1394):** `generateAstmResult` (`H`/`P`/`O`/`R`…/`C`/`L`) and `generateAstmOrder`
|
|
380
|
-
* (`H`/`P`/`O`/`L`) via `buildAstmMessage
|
|
380
|
+
* (`H`/`P`/`O`/`L`) via `buildAstmMessage`, each round-tripping through `parseAstmRecords` with zero
|
|
381
381
|
* warnings and byte-stable, and carrying a `P` record whose name / DOB / practice+lab IDs are all
|
|
382
382
|
* synthetic-by-construction. The practice- and laboratory-assigned patient IDs are
|
|
383
383
|
* minted independently, so they stay **distinct**.
|
|
384
|
-
* - **Framing (E1381):** `generateAstmResultFramed` via `composeAstmFrames
|
|
384
|
+
* - **Framing (E1381):** `generateAstmResultFramed` via `composeAstmFrames`, the modulo-256 checksum
|
|
385
385
|
* and the `0`–`7` frame number are **computed by the parser, never faked**, and the bytes round-trip
|
|
386
386
|
* through `parseFramedAstm` with zero frame **and** record warnings.
|
|
387
387
|
*
|
|
388
388
|
* @module
|
|
389
389
|
*/
|
|
390
390
|
|
|
391
|
-
/** Every ASTM message kind {@link astmCorpus} generates
|
|
391
|
+
/** Every ASTM message kind {@link astmCorpus} generates: the label used as the corpus `kind`. */
|
|
392
392
|
type AstmCorpusKind = "Result" | "Order";
|
|
393
393
|
/** Options for {@link astmCorpus}. */
|
|
394
394
|
interface AstmCorpusOptions {
|
|
@@ -410,7 +410,7 @@ interface AstmCorpusOptions {
|
|
|
410
410
|
* ```ts
|
|
411
411
|
* import { astmCorpus } from "@cosyte/synth/astm";
|
|
412
412
|
* const corpus = astmCorpus({ seed: 42 });
|
|
413
|
-
* corpus.artifacts.every((a) => a.warnings.length === 0); // true
|
|
413
|
+
* corpus.artifacts.every((a) => a.warnings.length === 0); // true, spec-clean
|
|
414
414
|
* ```
|
|
415
415
|
*/
|
|
416
416
|
declare function astmCorpus(options: AstmCorpusOptions): Corpus;
|
package/dist/astm/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as SyntheticName, R as Rng, C as Corpus } from '../providers-
|
|
2
|
-
import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-
|
|
1
|
+
import { S as SyntheticName, R as Rng, C as Corpus } from '../providers-B9uVinAe.js';
|
|
2
|
+
import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as QuirkRoundTripResult } from '../quirk-HZdznAkM.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Spec-clean ASTM (E1394 / CLSI LIS02) message generation
|
|
5
|
+
* Spec-clean ASTM (E1394 / CLSI LIS02) message generation: the `H`/`P`/`O`/`R`/`C`/`L` record report,
|
|
6
6
|
* built through `@cosyte/astm`'s `buildAstmMessage` so the delimiter declaration (`H|\^&`), the record
|
|
7
7
|
* type letters, the per-type sequence counters, the `L` terminator, and every escape are the parser's
|
|
8
8
|
* own conservative emit. Nothing clinical is defaulted: a
|
|
@@ -10,8 +10,8 @@ import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as Quirk
|
|
|
10
10
|
*
|
|
11
11
|
* A framed **E1381 / CLSI LIS01** variant is also offered ({@link generateAstmResultFramed}) via
|
|
12
12
|
* `composeAstmFrames`, which frames each record into `<STX> FN text <ETB|ETX> CS <CR><LF>` with the
|
|
13
|
-
* **modulo-256 checksum and the `0`–`7` frame number computed by the parser
|
|
14
|
-
* trip through `@cosyte/astm` cleanly (`parseAstmRecords` / `parseFramedAstm
|
|
13
|
+
* **modulo-256 checksum and the `0`–`7` frame number computed by the parser**, never faked. Both round
|
|
14
|
+
* trip through `@cosyte/astm` cleanly (`parseAstmRecords` / `parseFramedAstm`: see `./round-trip`).
|
|
15
15
|
*
|
|
16
16
|
* Every value at a PHI-bearing locus (the `P` record's name / DOB / practice+lab IDs) is
|
|
17
17
|
* drawn from the synthetic-safety providers via `./identity`, so no output can be real or plausibly-real
|
|
@@ -22,7 +22,7 @@ import { Q as QuirkDescriptor, S as SynthProfile, a as QuirkArtifact, b as Quirk
|
|
|
22
22
|
*/
|
|
23
23
|
/** Options for the ASTM message generators. */
|
|
24
24
|
interface GenerateAstmOptions {
|
|
25
|
-
/** The seed (deterministic
|
|
25
|
+
/** The seed (deterministic: same seed yields a byte-identical message). */
|
|
26
26
|
readonly seed: number;
|
|
27
27
|
/** How many `R` (result) records to emit. Defaults to a seeded 1–4. */
|
|
28
28
|
readonly resultCount?: number;
|
|
@@ -30,7 +30,7 @@ interface GenerateAstmOptions {
|
|
|
30
30
|
readonly comment?: boolean;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Generate a spec-clean ASTM **result message
|
|
33
|
+
* Generate a spec-clean ASTM **result message**: an `H`/`P`/`O`/`R`…/`C`/`L` record stream, built
|
|
34
34
|
* through `@cosyte/astm`'s `buildAstmMessage`. Every identity value is synthetic-by-construction; the message
|
|
35
35
|
* round-trips through `parseAstmRecords` with zero warnings and re-serializes
|
|
36
36
|
* byte-identically (see `./round-trip`).
|
|
@@ -45,7 +45,7 @@ interface GenerateAstmOptions {
|
|
|
45
45
|
*/
|
|
46
46
|
declare function generateAstmResult(options: GenerateAstmOptions): string;
|
|
47
47
|
/**
|
|
48
|
-
* Generate a spec-clean ASTM **order message
|
|
48
|
+
* Generate a spec-clean ASTM **order message**: an `H`/`P`/`O`/`L` record stream with no results, for
|
|
49
49
|
* the order side of the flow. Built through `buildAstmMessage`; synthetic-by-construction; round-trips
|
|
50
50
|
* clean.
|
|
51
51
|
*
|
|
@@ -59,10 +59,10 @@ declare function generateAstmResult(options: GenerateAstmOptions): string;
|
|
|
59
59
|
*/
|
|
60
60
|
declare function generateAstmOrder(options: GenerateAstmOptions): string;
|
|
61
61
|
/**
|
|
62
|
-
* Generate a spec-clean **framed** ASTM result message
|
|
62
|
+
* Generate a spec-clean **framed** ASTM result message: the same `H`/`P`/`O`/`R`…/`C`/`L` records,
|
|
63
63
|
* wrapped in the **E1381 / CLSI LIS01** frame envelope (`<STX> FN text <ETB|ETX> CS <CR><LF>`) via
|
|
64
64
|
* `@cosyte/astm`'s `composeAstmFrames`. The **modulo-256 checksum and the `0`–`7` frame number are
|
|
65
|
-
* computed by the parser** (never hand-written), and a record over 240 bytes is split across frames
|
|
65
|
+
* computed by the parser** (never hand-written), and a record over 240 bytes is split across frames,
|
|
66
66
|
* so the bytes round-trip through `parseFramedAstm` with zero frame **and** record warnings (see
|
|
67
67
|
* `./round-trip`). Each record is framed independently (one `ETX`-closed run per record), mirroring what
|
|
68
68
|
* `decodeAstmFrames` reassembles.
|
|
@@ -72,21 +72,21 @@ declare function generateAstmOrder(options: GenerateAstmOptions): string;
|
|
|
72
72
|
* @example
|
|
73
73
|
* ```ts
|
|
74
74
|
* import { generateAstmResultFramed } from "@cosyte/synth/astm";
|
|
75
|
-
* const bytes = generateAstmResultFramed({ seed: 42 }); // Uint8Array
|
|
75
|
+
* const bytes = generateAstmResultFramed({ seed: 42 }); // Uint8Array, E1381 framed
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
78
|
declare function generateAstmResultFramed(options: GenerateAstmOptions): Uint8Array;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* The **round-trip-through-the-parser harness** for ASTM
|
|
81
|
+
* The **round-trip-through-the-parser harness** for ASTM: the headline gate for the synthetic-fixture
|
|
82
82
|
* generator. A generated ASTM record stream (or framed byte stream) is "spec-clean" only
|
|
83
|
-
* if `@cosyte/astm
|
|
83
|
+
* if `@cosyte/astm`, not `@cosyte/synth`'s own opinion, reads it back cleanly. Each harness parses the
|
|
84
84
|
* generated wire straight back through the parser and reports what it found, so a false "spec-clean"
|
|
85
85
|
* claim cannot hide.
|
|
86
86
|
*
|
|
87
87
|
* The **record** layer (E1394) and the **frame** layer (E1381) are separate concerns, so each gets its
|
|
88
88
|
* own harness; both report the same {@link AstmRoundTripResult} shape (the framed one additionally folds
|
|
89
|
-
* the frame-layer warnings
|
|
89
|
+
* the frame-layer warnings (bad checksum, sequence gap, unterminated, oversize) into `warnings`, so a
|
|
90
90
|
* framing defect is caught by the same gate).
|
|
91
91
|
*
|
|
92
92
|
* @module
|
|
@@ -122,7 +122,7 @@ declare function astmRoundTrip(raw: string): AstmRoundTripResult;
|
|
|
122
122
|
* byte-identically.
|
|
123
123
|
*
|
|
124
124
|
* @param bytes - The framed byte stream (typically from `generateAstmResultFramed`).
|
|
125
|
-
* @returns The {@link AstmRoundTripResult}
|
|
125
|
+
* @returns The {@link AstmRoundTripResult}: `content` holds the framed bytes decoded as latin1.
|
|
126
126
|
* @example
|
|
127
127
|
* ```ts
|
|
128
128
|
* import { generateAstmResultFramed, astmFramedRoundTrip } from "@cosyte/synth/astm";
|
|
@@ -132,7 +132,7 @@ declare function astmRoundTrip(raw: string): AstmRoundTripResult;
|
|
|
132
132
|
declare function astmFramedRoundTrip(bytes: Uint8Array): AstmRoundTripResult;
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Synthetic identity for ASTM (E1394 / CLSI LIS02) messages
|
|
135
|
+
* Synthetic identity for ASTM (E1394 / CLSI LIS02) messages: every value `synth` puts into a `P`
|
|
136
136
|
* (patient) record, an `O` (order) accession, or the `H` header is minted here, and **only** from the
|
|
137
137
|
* synthetic-safety providers. ASTM's PHI-dense locus is the **`P` record**: it carries the
|
|
138
138
|
* patient **name** (`Last^First^Middle`), **birthdate**, **sex**, and the **practice-assigned** and
|
|
@@ -146,7 +146,7 @@ declare function astmFramedRoundTrip(bytes: Uint8Array): AstmRoundTripResult;
|
|
|
146
146
|
* @module
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
|
-
/** A synthetic ASTM patient
|
|
149
|
+
/** A synthetic ASTM patient: every field drawn from `../safe`. */
|
|
150
150
|
interface AstmPatient {
|
|
151
151
|
/** Name from the shipped fake-name pool, plus a fictional middle initial. */
|
|
152
152
|
readonly person: SyntheticName;
|
|
@@ -154,21 +154,21 @@ interface AstmPatient {
|
|
|
154
154
|
readonly middle: string;
|
|
155
155
|
/** Birthdate `YYYYMMDD`, from the seeded generator (no real event implied). */
|
|
156
156
|
readonly birthDate: string;
|
|
157
|
-
/** Sex code, emitted verbatim (`M` / `F
|
|
157
|
+
/** Sex code, emitted verbatim (`M` / `F`, structural, never defaulted by the builder). */
|
|
158
158
|
readonly sex: "M" | "F";
|
|
159
|
-
/** Practice-assigned patient ID
|
|
159
|
+
/** Practice-assigned patient ID, synthetic-AA scoped (`PRA`-prefixed). Distinct from the lab ID. */
|
|
160
160
|
readonly practiceAssignedId: string;
|
|
161
|
-
/** Laboratory-assigned patient ID
|
|
161
|
+
/** Laboratory-assigned patient ID, synthetic-AA scoped (`LAB`-prefixed). Distinct from the practice ID. */
|
|
162
162
|
readonly laboratoryAssignedId: string;
|
|
163
163
|
}
|
|
164
|
-
/** A synthetic ASTM order identity
|
|
164
|
+
/** A synthetic ASTM order identity: the specimen / accession id and priority. */
|
|
165
165
|
interface AstmOrder {
|
|
166
|
-
/** Specimen / accession id
|
|
166
|
+
/** Specimen / accession id: synthetic-AA scoped (`ACC`-prefixed). */
|
|
167
167
|
readonly specimenId: string;
|
|
168
168
|
/** Priority code, emitted verbatim (`R` routine, `S` stat). */
|
|
169
169
|
readonly priority: "R" | "S";
|
|
170
170
|
}
|
|
171
|
-
/** A synthetic ASTM header identity
|
|
171
|
+
/** A synthetic ASTM header identity: the sender and analyzer strings for the `H` record. */
|
|
172
172
|
interface AstmHeaderIdentity {
|
|
173
173
|
/** The sending system id (clearly synthetic). */
|
|
174
174
|
readonly sender: string;
|
|
@@ -191,7 +191,7 @@ interface AstmHeaderIdentity {
|
|
|
191
191
|
*/
|
|
192
192
|
declare function astmPatient(rng: Rng): AstmPatient;
|
|
193
193
|
/**
|
|
194
|
-
* Mint a synthetic order identity for an `O` record
|
|
194
|
+
* Mint a synthetic order identity for an `O` record: a synthetic-AA-scoped accession id and a priority.
|
|
195
195
|
*
|
|
196
196
|
* @param rng - The seeded generator.
|
|
197
197
|
* @returns A synthetic {@link AstmOrder}.
|
|
@@ -204,7 +204,7 @@ declare function astmPatient(rng: Rng): AstmPatient;
|
|
|
204
204
|
*/
|
|
205
205
|
declare function astmOrder(rng: Rng): AstmOrder;
|
|
206
206
|
/**
|
|
207
|
-
* Mint a synthetic header identity for the `H` record
|
|
207
|
+
* Mint a synthetic header identity for the `H` record: a clearly-synthetic sender and analyzer.
|
|
208
208
|
*
|
|
209
209
|
* @param rng - The seeded generator.
|
|
210
210
|
* @returns A synthetic {@link AstmHeaderIdentity}.
|
|
@@ -218,18 +218,18 @@ declare function astmOrder(rng: Rng): AstmOrder;
|
|
|
218
218
|
declare function astmHeaderIdentity(rng: Rng): AstmHeaderIdentity;
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
* A small, **license-clean** pool of example ASTM laboratory tests
|
|
221
|
+
* A small, **license-clean** pool of example ASTM laboratory tests: the analyte codes, units, and
|
|
222
222
|
* plausible value ranges `synth` draws on when populating `O` (order) and `R` (result) records. The
|
|
223
223
|
* codes are **facts** (a LOINC number is a public identifier, and the local analyzer codes here are
|
|
224
|
-
* invented), never a bundled terminology table. Nothing clinical is asserted
|
|
224
|
+
* invented), never a bundled terminology table. Nothing clinical is asserted: a `synth` result pairs a value
|
|
225
225
|
* and a code with no claim of clinical coherence: the pool exists only to make a *structurally* realistic
|
|
226
226
|
* result record.
|
|
227
227
|
*
|
|
228
228
|
* @module
|
|
229
229
|
*/
|
|
230
|
-
/** One example laboratory analyte
|
|
230
|
+
/** One example laboratory analyte: its codes, units, reference range, and a seeded value window. */
|
|
231
231
|
interface AstmExampleTest {
|
|
232
|
-
/** A local analyzer test code (invented
|
|
232
|
+
/** A local analyzer test code (invented, never a real vendor assay id). */
|
|
233
233
|
readonly localCode: string;
|
|
234
234
|
/** The public LOINC identifier for the analyte (a fact, not bundled terminology prose). */
|
|
235
235
|
readonly loinc: string;
|
|
@@ -248,7 +248,7 @@ interface AstmExampleTest {
|
|
|
248
248
|
}
|
|
249
249
|
/**
|
|
250
250
|
* The example test pool. A handful of common chemistry/hematology analytes, each with a public LOINC
|
|
251
|
-
* code, invented local code, units, and a value window the seeded generator samples. Frozen
|
|
251
|
+
* code, invented local code, units, and a value window the seeded generator samples. Frozen: the pool
|
|
252
252
|
* is shared, immutable data.
|
|
253
253
|
*
|
|
254
254
|
* @example
|
|
@@ -262,14 +262,14 @@ declare const EXAMPLE_ASTM_TESTS: readonly AstmExampleTest[];
|
|
|
262
262
|
declare const ASTM_ABNORMAL_FLAGS: readonly string[];
|
|
263
263
|
/** Result-status codes `synth` draws from (`F` final, `P` preliminary, `C` correction). */
|
|
264
264
|
declare const ASTM_RESULT_STATUSES: readonly string[];
|
|
265
|
-
/** Free-text result comments
|
|
265
|
+
/** Free-text result comments: clearly synthetic, carry no PHI. */
|
|
266
266
|
declare const ASTM_COMMENT_TEXT: readonly string[];
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
* ASTM E1394 **vendor-quirk generation**. A quirk deviates the
|
|
270
270
|
* *structure* of an otherwise spec-clean record report (built through `@cosyte/astm`'s
|
|
271
271
|
* `buildAstmMessage`) so it round-trips through `parseAstmRecords` to **exactly** one intended, stable
|
|
272
|
-
* warning code
|
|
272
|
+
* warning code: a code in the parser's `defineAstmProfile` tolerable set. Where a built-in public
|
|
273
273
|
* profile tolerates the quirk, the warning is **re-badged** to the value-free `PROFILE_QUIRK_APPLIED`
|
|
274
274
|
* marker (`expected: true`), exactly as the parser's `profileQuirkApplied` does.
|
|
275
275
|
*
|
|
@@ -280,11 +280,11 @@ declare const ASTM_COMMENT_TEXT: readonly string[];
|
|
|
280
280
|
* `referenceCorpus` profile (the redistributable kxepal/python-astm + senaite OSS corpus), which
|
|
281
281
|
* re-badges it.
|
|
282
282
|
* - **`unknown-record-type`** → `ASTM_RECORD_UNKNOWN_TYPE`. A record's leading type letter is changed to
|
|
283
|
-
* a site-defined `Z
|
|
283
|
+
* a site-defined `Z`: a real ASTM tolerance (the parser's tolerable set includes this code), but no
|
|
284
284
|
* built-in profile tolerates it, so it is a `"bare"` quirk (a consumer authors a `defineAstmProfile`
|
|
285
285
|
* to re-badge it).
|
|
286
286
|
*
|
|
287
|
-
* A quirk **never** introduces a real-looking value
|
|
287
|
+
* A quirk **never** introduces a real-looking value: it changes an escape body or a record type letter,
|
|
288
288
|
* never a P-record identity locus, so the synthetic-safety gate still runs and stays zero.
|
|
289
289
|
*
|
|
290
290
|
* @module
|
|
@@ -293,16 +293,16 @@ declare const ASTM_COMMENT_TEXT: readonly string[];
|
|
|
293
293
|
/** Every ASTM quirk this package ships. */
|
|
294
294
|
type AstmQuirkName = "unknown-escape" | "unknown-record-type";
|
|
295
295
|
/**
|
|
296
|
-
* Both shipped ASTM quirks are **result-report** deviations
|
|
296
|
+
* Both shipped ASTM quirks are **result-report** deviations: `unknown-escape` targets an `R` record's
|
|
297
297
|
* units field and `unknown-record-type` a `C` (comment) record, neither of which an *order* report
|
|
298
298
|
* carries. So the quirk base is always a result report (`generateAstmResult`).
|
|
299
299
|
*/
|
|
300
300
|
type AstmQuirkKind = "Result";
|
|
301
|
-
/** The ASTM quirk registry
|
|
301
|
+
/** The ASTM quirk registry: each recipe bound to the exact `@cosyte/astm` warning code it targets. */
|
|
302
302
|
declare const ASTM_QUIRKS: Readonly<Record<AstmQuirkName, QuirkDescriptor>>;
|
|
303
303
|
/** Options for {@link generateAstmQuirk}. */
|
|
304
304
|
interface GenerateAstmQuirkOptions {
|
|
305
|
-
/** The seed
|
|
305
|
+
/** The seed: the same seed + quirk yields a byte-identical record stream. Defaults to `0`. */
|
|
306
306
|
readonly seed?: number;
|
|
307
307
|
/** The quirk to inject. Required. */
|
|
308
308
|
readonly quirk: AstmQuirkName;
|
|
@@ -314,21 +314,21 @@ interface GenerateAstmQuirkOptions {
|
|
|
314
314
|
* the requested vendor deviation injected post-serialize. Deterministic in `seed` + `quirk` + `kind`.
|
|
315
315
|
*
|
|
316
316
|
* @param options - Seed, quirk, and base kind. See {@link GenerateAstmQuirkOptions}.
|
|
317
|
-
* @returns The {@link QuirkArtifact}
|
|
317
|
+
* @returns The {@link QuirkArtifact}: its `content` round-trips to `intendedWarnings` exactly.
|
|
318
318
|
* @throws SynthError `SYNTH_UNSUPPORTED_QUIRK` if `quirk` is not a supported ASTM quirk.
|
|
319
319
|
* @throws Error if the base report does not contain the structural anchor the quirk targets.
|
|
320
320
|
* @example
|
|
321
321
|
* ```ts
|
|
322
322
|
* import { generateAstmQuirk, astmQuirkRoundTrip } from "@cosyte/synth/astm";
|
|
323
323
|
* const rt = astmQuirkRoundTrip(generateAstmQuirk({ seed: 1, quirk: "unknown-escape" }));
|
|
324
|
-
* rt.withProfile?.tolerated; // true
|
|
324
|
+
* rt.withProfile?.tolerated; // true, `referenceCorpus` re-badges ASTM_UNKNOWN_ESCAPE_SEQUENCE
|
|
325
325
|
* ```
|
|
326
326
|
*/
|
|
327
327
|
declare function generateAstmQuirk(options: GenerateAstmQuirkOptions): QuirkArtifact;
|
|
328
328
|
/**
|
|
329
329
|
* Round-trip an ASTM quirk artifact through `@cosyte/astm` and report the intended-warning verdict: a bare
|
|
330
|
-
* parse must produce **exactly** the intended code, and
|
|
331
|
-
* profile tolerates the quirk
|
|
330
|
+
* parse must produce **exactly** the intended code, and, when a built-in public
|
|
331
|
+
* profile tolerates the quirk, the profiled parse must re-badge it to `PROFILE_QUIRK_APPLIED`.
|
|
332
332
|
*
|
|
333
333
|
* @param artifact - The quirk artifact (from {@link generateAstmQuirk}).
|
|
334
334
|
* @returns The {@link QuirkRoundTripResult}.
|
|
@@ -367,28 +367,28 @@ declare function astmQuirkCorpus(options: AstmQuirkCorpusOptions): Corpus;
|
|
|
367
367
|
declare const astmQuirkProfile: SynthProfile;
|
|
368
368
|
|
|
369
369
|
/**
|
|
370
|
-
* `@cosyte/synth/astm
|
|
370
|
+
* `@cosyte/synth/astm`: the ASTM generation surface, exposed as its own subpath so importing the
|
|
371
371
|
* package root does **not** pull `@cosyte/astm`. This is the **lazy, per-format** boundary: a consumer
|
|
372
372
|
* who only needs ASTM fixtures imports `@cosyte/synth/astm`; one who needs only the core primitives
|
|
373
373
|
* never loads a parser.
|
|
374
|
-
* `@cosyte/astm` is an **optional peer dependency
|
|
374
|
+
* `@cosyte/astm` is an **optional peer dependency**, present only for this subpath.
|
|
375
375
|
*
|
|
376
376
|
* This subpath ships spec-clean generation of the E1394 record report and its E1381 framed twin, each
|
|
377
377
|
* built through `@cosyte/astm`'s own emit surface:
|
|
378
378
|
*
|
|
379
379
|
* - **Records (E1394):** `generateAstmResult` (`H`/`P`/`O`/`R`…/`C`/`L`) and `generateAstmOrder`
|
|
380
|
-
* (`H`/`P`/`O`/`L`) via `buildAstmMessage
|
|
380
|
+
* (`H`/`P`/`O`/`L`) via `buildAstmMessage`, each round-tripping through `parseAstmRecords` with zero
|
|
381
381
|
* warnings and byte-stable, and carrying a `P` record whose name / DOB / practice+lab IDs are all
|
|
382
382
|
* synthetic-by-construction. The practice- and laboratory-assigned patient IDs are
|
|
383
383
|
* minted independently, so they stay **distinct**.
|
|
384
|
-
* - **Framing (E1381):** `generateAstmResultFramed` via `composeAstmFrames
|
|
384
|
+
* - **Framing (E1381):** `generateAstmResultFramed` via `composeAstmFrames`, the modulo-256 checksum
|
|
385
385
|
* and the `0`–`7` frame number are **computed by the parser, never faked**, and the bytes round-trip
|
|
386
386
|
* through `parseFramedAstm` with zero frame **and** record warnings.
|
|
387
387
|
*
|
|
388
388
|
* @module
|
|
389
389
|
*/
|
|
390
390
|
|
|
391
|
-
/** Every ASTM message kind {@link astmCorpus} generates
|
|
391
|
+
/** Every ASTM message kind {@link astmCorpus} generates: the label used as the corpus `kind`. */
|
|
392
392
|
type AstmCorpusKind = "Result" | "Order";
|
|
393
393
|
/** Options for {@link astmCorpus}. */
|
|
394
394
|
interface AstmCorpusOptions {
|
|
@@ -410,7 +410,7 @@ interface AstmCorpusOptions {
|
|
|
410
410
|
* ```ts
|
|
411
411
|
* import { astmCorpus } from "@cosyte/synth/astm";
|
|
412
412
|
* const corpus = astmCorpus({ seed: 42 });
|
|
413
|
-
* corpus.artifacts.every((a) => a.warnings.length === 0); // true
|
|
413
|
+
* corpus.artifacts.every((a) => a.warnings.length === 0); // true, spec-clean
|
|
414
414
|
* ```
|
|
415
415
|
*/
|
|
416
416
|
declare function astmCorpus(options: AstmCorpusOptions): Corpus;
|