@cosyte/hl7 0.0.2 → 0.0.4
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 +287 -0
- package/README.md +14 -6
- package/dist/index.cjs +187 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +314 -267
- package/dist/index.d.ts +314 -267
- package/dist/index.mjs +187 -122
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -241,14 +241,15 @@ declare function encodingMismatch(position: Hl7Position, detail: string): Hl7Par
|
|
|
241
241
|
*/
|
|
242
242
|
declare function missingRequiredField(position: Hl7Position, segmentName: string, fieldIndex: number): Hl7ParseWarning;
|
|
243
243
|
/**
|
|
244
|
-
* Build a `MISSING_EXPECTED_GROUP` warning
|
|
244
|
+
* Build a `MISSING_EXPECTED_GROUP` warning. Emitted once per
|
|
245
245
|
* absent Required segment group when the message's (MSH-9.1, MSH-9.2) type is
|
|
246
246
|
* one the structure safety net recognizes and an expected group is entirely
|
|
247
247
|
* missing: e.g. an `ORU^R01` carrying no `OBR`/`OBX` result group, the
|
|
248
248
|
* signature of a truncated or misrouted feed. Tier-2 and additive: lenient
|
|
249
249
|
* parse never throws on it, `strict` mode may promote it. The message carries
|
|
250
250
|
* only the structural fact (message type, group name, anchor segment names),
|
|
251
|
-
*
|
|
251
|
+
* never a field value: the message type is shape-checked before it is
|
|
252
|
+
* interpolated, and withheld if it does not match. `position` references MSH-9.
|
|
252
253
|
*
|
|
253
254
|
* @example
|
|
254
255
|
* ```ts
|
|
@@ -292,8 +293,8 @@ declare function versionMismatch(position: Hl7Position, declared: string, expect
|
|
|
292
293
|
* Table-0211 character set**. The parser never guesses an encoding: it reads the
|
|
293
294
|
* raw bytes as `latin1` (a 1:1 byte mapping) so single-byte content stays
|
|
294
295
|
* recoverable, rather than corrupting it with replacement characters. The
|
|
295
|
-
* message carries the charset code only, never a decoded field value
|
|
296
|
-
*
|
|
296
|
+
* message carries the charset code only, never a decoded field value: the code
|
|
297
|
+
* is shape-checked before it is interpolated, and withheld if it does not match.
|
|
297
298
|
*
|
|
298
299
|
* @example
|
|
299
300
|
* ```ts
|
|
@@ -315,8 +316,8 @@ declare function unknownCharset(position: Hl7Position, requested: string): Hl7Pa
|
|
|
315
316
|
* coincide with a structural delimiter: see the parser's known-limitations).
|
|
316
317
|
* The switch escapes (`\Cxxyy\` / `\Mxxyyzz\`) are recognized and preserved by
|
|
317
318
|
* the escape layer; full stateful decoding is a documented non-goal. The message
|
|
318
|
-
* carries the charset code only, never a decoded field value
|
|
319
|
-
*
|
|
319
|
+
* carries the charset code only, never a decoded field value: the code is
|
|
320
|
+
* shape-checked before it is interpolated, and withheld if it does not match.
|
|
320
321
|
*
|
|
321
322
|
* @example
|
|
322
323
|
* ```ts
|
|
@@ -326,7 +327,7 @@ declare function unknownCharset(position: Hl7Position, requested: string): Hl7Pa
|
|
|
326
327
|
*/
|
|
327
328
|
declare function unsupportedCharset(position: Hl7Position, code: string): Hl7ParseWarning;
|
|
328
329
|
/**
|
|
329
|
-
* Build an `ACK_NO_CORRELATION_ID` warning. Emitted by `buildAck
|
|
330
|
+
* Build an `ACK_NO_CORRELATION_ID` warning. Emitted by `buildAck`,
|
|
330
331
|
* not by the parser: the inbound message carried no MSH-10 message control ID,
|
|
331
332
|
* so the generated ACK leaves MSA-2 empty and, when a positive accept was
|
|
332
333
|
* requested, downgrades it to an error code rather than fabricating an
|
|
@@ -342,7 +343,7 @@ declare function unsupportedCharset(position: Hl7Position, code: string): Hl7Par
|
|
|
342
343
|
*/
|
|
343
344
|
declare function ackNoCorrelationId(position: Hl7Position): Hl7ParseWarning;
|
|
344
345
|
/**
|
|
345
|
-
* Build a `MERGE_MISSING_PRIOR_OR_SURVIVOR` warning
|
|
346
|
+
* Build a `MERGE_MISSING_PRIOR_OR_SURVIVOR` warning. Emitted
|
|
346
347
|
* by `identityEvents()` (a read-side helper: it attaches to the returned
|
|
347
348
|
* `IdentityEvent.warnings`, never to `Hl7Message.warnings`) when a merge/move
|
|
348
349
|
* trigger event (A18/A34/A35/A36/A39/A40/A41/A42/A43/A44) is missing one side
|
|
@@ -368,7 +369,7 @@ declare function ackNoCorrelationId(position: Hl7Position): Hl7ParseWarning;
|
|
|
368
369
|
*/
|
|
369
370
|
declare function mergeMissingPriorOrSurvivor(position: Hl7Position, eventType: string, missing: "prior" | "survivor"): Hl7ParseWarning;
|
|
370
371
|
/**
|
|
371
|
-
* Build a `BATCH_COUNT_MISMATCH` warning
|
|
372
|
+
* Build a `BATCH_COUNT_MISMATCH` warning. Emitted by
|
|
372
373
|
* `splitBatch()`: attached to the returned `BatchSplitResult.warnings`, never
|
|
373
374
|
* to `Hl7Message.warnings`: when a declared envelope count does not equal the
|
|
374
375
|
* count actually split out: a **BTS-1** batch message count that differs from
|
|
@@ -392,7 +393,7 @@ declare function mergeMissingPriorOrSurvivor(position: Hl7Position, eventType: s
|
|
|
392
393
|
*/
|
|
393
394
|
declare function batchCountMismatch(position: Hl7Position, unit: "message" | "batch", declared: number, actual: number): Hl7ParseWarning;
|
|
394
395
|
/**
|
|
395
|
-
* Build a `BATCH_MISSING_TRAILER` warning
|
|
396
|
+
* Build a `BATCH_MISSING_TRAILER` warning. Emitted by
|
|
396
397
|
* `splitBatch()` (attached to `BatchSplitResult.warnings`) when an envelope
|
|
397
398
|
* header opens a scope that is never closed: a **BHS** batch header with no
|
|
398
399
|
* matching **BTS** trailer, or an **FHS** file header with no matching **FTS**
|
|
@@ -413,7 +414,7 @@ declare function batchCountMismatch(position: Hl7Position, unit: "message" | "ba
|
|
|
413
414
|
*/
|
|
414
415
|
declare function batchMissingTrailer(position: Hl7Position, header: "FHS" | "BHS", expectedTrailer: "FTS" | "BTS"): Hl7ParseWarning;
|
|
415
416
|
/**
|
|
416
|
-
* Build an `UNTERMINATED_STREAM_MESSAGE` warning
|
|
417
|
+
* Build an `UNTERMINATED_STREAM_MESSAGE` warning. Emitted by
|
|
417
418
|
* `parseStream()`: attached to a {@link StreamMessageEntry}'s `streamWarnings`,
|
|
418
419
|
* NOT to `Hl7Message.warnings`: when the **final** message in a stream ends
|
|
419
420
|
* without a segment terminator (its last segment ran to end-of-stream with no
|
|
@@ -535,9 +536,8 @@ interface ParseOptions {
|
|
|
535
536
|
* (`defineProfile()`). `fields` maps a caller-visible field NAME to its
|
|
536
537
|
* 1-indexed HL7 position within the segment. Declared here (alongside
|
|
537
538
|
* `Profile`) to keep the parser's type module the single source of truth;
|
|
538
|
-
* `src/profiles/define.ts` re-exports this type so consumers can write
|
|
539
|
-
* `import type { CustomSegmentDefinition } from "@cosyte/hl7"
|
|
540
|
-
* after Plan 06's barrel-sweep.
|
|
539
|
+
* `src/profiles/define.ts` re-exports this type, so consumers can write
|
|
540
|
+
* `import type { CustomSegmentDefinition } from "@cosyte/hl7"`.
|
|
541
541
|
*
|
|
542
542
|
* @example
|
|
543
543
|
* ```ts
|
|
@@ -553,11 +553,10 @@ interface CustomSegmentDefinition {
|
|
|
553
553
|
/**
|
|
554
554
|
* Structural placeholder for HL7 profiles. A profile bundles vendor-specific
|
|
555
555
|
* tolerances, date formats, custom segment definitions, and optional
|
|
556
|
-
* callbacks.
|
|
557
|
-
* and runtime effects land in Phase 6.
|
|
556
|
+
* callbacks. Profiles are built with the `defineProfile()` factory.
|
|
558
557
|
*
|
|
559
|
-
*
|
|
560
|
-
* `
|
|
558
|
+
* `customSegments` is narrowed to the locked `CustomSegmentDefinition` shape,
|
|
559
|
+
* and `Profile` carries an optional `describe?` method
|
|
561
560
|
* so `defineProfile()`-produced profiles can be introspected without
|
|
562
561
|
* consumers needing to narrow away from the `Profile` type. The `describe`
|
|
563
562
|
* method is only populated by `defineProfile()`: hand-authored `Profile`
|
|
@@ -737,8 +736,8 @@ interface RawSegment {
|
|
|
737
736
|
|
|
738
737
|
/**
|
|
739
738
|
* The HL7 default 5-tuple of encoding characters used when a message does
|
|
740
|
-
* not override them via MSH-1 / MSH-2. Re-used by downstream stages (
|
|
741
|
-
* escape map,
|
|
739
|
+
* not override them via MSH-1 / MSH-2. Re-used by downstream stages (the
|
|
740
|
+
* escape map, `parseHL7`) as a synthetic-message fallback.
|
|
742
741
|
*
|
|
743
742
|
* @example
|
|
744
743
|
* ```ts
|
|
@@ -754,7 +753,7 @@ declare const DEFAULT_ENCODING_CHARACTERS: EncodingCharacters;
|
|
|
754
753
|
* a human (or a downstream display / FHIR `.text`) can read, instead of the
|
|
755
754
|
* raw `\H\`/`\.br\` sentinels the lenient parser preserves.
|
|
756
755
|
*
|
|
757
|
-
*
|
|
756
|
+
* `renderText` is a read projection: it never mutates the
|
|
758
757
|
* raw field value (rendering is opt-in on top of the tolerant parse), and it
|
|
759
758
|
* **never fabricates**: an escape it cannot render is preserved as its literal
|
|
760
759
|
* characters AND flagged in {@link RenderedText.unrenderedSequences}, never
|
|
@@ -909,9 +908,9 @@ declare function renderText(input: string, enc?: EncodingCharacters, opts?: Rend
|
|
|
909
908
|
|
|
910
909
|
/**
|
|
911
910
|
* CE: HL7 v2 Coded Element composite. 6-component coded-element shape
|
|
912
|
-
* parsed from a `RawRepetition` on demand by `Field.asCe()
|
|
913
|
-
*
|
|
914
|
-
*
|
|
911
|
+
* parsed from a `RawRepetition` on demand by `Field.asCe()`. Fields are
|
|
912
|
+
* OMITTED when absent (exactOptionalPropertyTypes): NEVER set to
|
|
913
|
+
* `undefined`.
|
|
915
914
|
*
|
|
916
915
|
* CE is the older, simpler sibling of CWE: 6 components, no version ids,
|
|
917
916
|
* no originalText. Still common in OBX.3 and similar observation-identifier
|
|
@@ -964,8 +963,8 @@ interface CE {
|
|
|
964
963
|
}
|
|
965
964
|
/**
|
|
966
965
|
* Parse an HL7 v2 CE repetition into a structured `CE` object. Components
|
|
967
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
968
|
-
*
|
|
966
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
967
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
969
968
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
970
969
|
*
|
|
971
970
|
* @example
|
|
@@ -984,9 +983,9 @@ declare function parseCe(rep: RawRepetition, enc: EncodingCharacters): CE;
|
|
|
984
983
|
|
|
985
984
|
/**
|
|
986
985
|
* CWE: HL7 v2 Coded with Exceptions composite. 9-component coded-element
|
|
987
|
-
* shape parsed from a `RawRepetition` on demand by `Field.asCwe()
|
|
988
|
-
*
|
|
989
|
-
*
|
|
986
|
+
* shape parsed from a `RawRepetition` on demand by `Field.asCwe()`. Fields
|
|
987
|
+
* are OMITTED when absent (exactOptionalPropertyTypes), NEVER set to
|
|
988
|
+
* `undefined`.
|
|
990
989
|
*
|
|
991
990
|
* Note: full HL7 v2.6+ CWE has 22 components. v1 of this library ships the 9
|
|
992
991
|
* core components: identifier, text, coding-system trio + version ids, and
|
|
@@ -1046,8 +1045,8 @@ interface CWE {
|
|
|
1046
1045
|
}
|
|
1047
1046
|
/**
|
|
1048
1047
|
* Parse an HL7 v2 CWE repetition into a structured `CWE` object. Components
|
|
1049
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1050
|
-
*
|
|
1048
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1049
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1051
1050
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1052
1051
|
*
|
|
1053
1052
|
* @example
|
|
@@ -1097,8 +1096,8 @@ interface HD {
|
|
|
1097
1096
|
}
|
|
1098
1097
|
/**
|
|
1099
1098
|
* Parse an HL7 v2 HD repetition into a structured `HD` object. Components
|
|
1100
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1101
|
-
*
|
|
1099
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1100
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1102
1101
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1103
1102
|
*
|
|
1104
1103
|
* @example
|
|
@@ -1119,7 +1118,7 @@ declare function parseHd(rep: RawRepetition, enc: EncodingCharacters): HD;
|
|
|
1119
1118
|
/**
|
|
1120
1119
|
* CX: HL7 v2 Extended Composite ID (with check digit) composite.
|
|
1121
1120
|
* 10-component structured-identifier shape parsed from a `RawRepetition` on
|
|
1122
|
-
* demand by `Field.asCx()
|
|
1121
|
+
* demand by `Field.asCx()`. Fields are OMITTED when
|
|
1123
1122
|
* absent (exactOptionalPropertyTypes): NEVER set to `undefined`.
|
|
1124
1123
|
*
|
|
1125
1124
|
* Component 4 (`assigningAuthority`) is the ONE nested-composite field in
|
|
@@ -1178,8 +1177,8 @@ interface CX {
|
|
|
1178
1177
|
}
|
|
1179
1178
|
/**
|
|
1180
1179
|
* Parse an HL7 v2 CX repetition into a structured `CX` object. Components
|
|
1181
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1182
|
-
*
|
|
1180
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1181
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1183
1182
|
* from the result (exactOptionalPropertyTypes semantics). Component 4
|
|
1184
1183
|
* (`assigningAuthority`) is parsed as a nested `HD`; see component table in
|
|
1185
1184
|
* the `CX` interface JSDoc for the v1 simplifications on components 6/9/10.
|
|
@@ -1257,7 +1256,7 @@ declare function parseNm(rep: RawRepetition, _enc: EncodingCharacters): NM;
|
|
|
1257
1256
|
* PL: HL7 v2 Person Location composite. 11-component structured-location
|
|
1258
1257
|
* shape (v1 trimmed from the HL7 v2.5 full 12-component PL: slot 12
|
|
1259
1258
|
* `entityIdentifier` is rarely used; v2 may restore the full shape) parsed
|
|
1260
|
-
* from a `RawRepetition` on demand by `Field.asPl()
|
|
1259
|
+
* from a `RawRepetition` on demand by `Field.asPl()`.
|
|
1261
1260
|
* Fields are OMITTED when absent (exactOptionalPropertyTypes): NEVER set
|
|
1262
1261
|
* to `undefined`.
|
|
1263
1262
|
*
|
|
@@ -1319,8 +1318,8 @@ interface PL {
|
|
|
1319
1318
|
}
|
|
1320
1319
|
/**
|
|
1321
1320
|
* Parse an HL7 v2 PL repetition into a structured `PL` object. Components
|
|
1322
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1323
|
-
*
|
|
1321
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1322
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1324
1323
|
* from the result (exactOptionalPropertyTypes semantics). Component 4
|
|
1325
1324
|
* (`facility`) is parsed as a nested `HD`; see component table in the `PL`
|
|
1326
1325
|
* interface JSDoc for the v1 simplifications.
|
|
@@ -1421,15 +1420,15 @@ declare function parseSn(rep: RawRepetition, enc: EncodingCharacters): SN | unde
|
|
|
1421
1420
|
/**
|
|
1422
1421
|
* HL7 v2 TS/DTM datetime handling for the `@cosyte/hl7` parser pipeline.
|
|
1423
1422
|
*
|
|
1424
|
-
*
|
|
1425
|
-
* `Date`-coercing helper
|
|
1423
|
+
* This module is a **fidelity-first** datetime parser rather than a
|
|
1424
|
+
* `Date`-coercing helper. The HL7 v2 Ch. 2A
|
|
1426
1425
|
* DTM datatype is `YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]`, where the
|
|
1427
1426
|
* number of populated characters (excluding the offset) sets the precision and
|
|
1428
1427
|
* a missing offset "defaults to that of the local time zone of the sender",
|
|
1429
1428
|
* NOT UTC and NOT the parser's zone. The old behavior (zero-fill truncations,
|
|
1430
|
-
* assume-UTC on a missing offset, eager `Date`) is an architectural defect
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1429
|
+
* assume-UTC on a missing offset, eager `Date`) is an architectural defect:
|
|
1430
|
+
* it silently shifts a day-only birth date (`|19880705|`) by a day in any
|
|
1431
|
+
* negative-offset zone.
|
|
1433
1432
|
*
|
|
1434
1433
|
* This module therefore:
|
|
1435
1434
|
* - `parseDtm(raw)` decodes the DTM into typed **parts** (`DtmParts`),
|
|
@@ -1639,13 +1638,12 @@ interface DtmToDateOptions {
|
|
|
1639
1638
|
declare function dtmToDate(parts: DtmParts, options?: DtmToDateOptions): Date | undefined;
|
|
1640
1639
|
|
|
1641
1640
|
/**
|
|
1642
|
-
* TS/DTM: HL7 v2 Time Stamp composite. Delegates parsing to the
|
|
1641
|
+
* TS/DTM: HL7 v2 Time Stamp composite. Delegates parsing to the parser
|
|
1643
1642
|
* helper `src/parser/dates.ts::parseDtm` (D-10 "zero duplicate date logic").
|
|
1644
1643
|
*
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
* {@link DtmParts}: raw string + typed parts + stated precision + timezone
|
|
1644
|
+
* The composite is fidelity-preserving: rather than a `{ raw, date }` shape
|
|
1645
|
+
* that would zero-fill truncations and assume UTC for a missing offset, it is
|
|
1646
|
+
* a {@link DtmParts}: raw string + typed parts + stated precision + timezone
|
|
1649
1647
|
* presence, with **no eager `Date`**. Callers that need an absolute instant
|
|
1650
1648
|
* opt in explicitly via `dtmToDate(ts, opts)`: which refuses to guess a zone
|
|
1651
1649
|
* for an offset-less value rather than silently defaulting to UTC.
|
|
@@ -1699,9 +1697,9 @@ declare function parseTs(rep: RawRepetition, _enc: EncodingCharacters): TS;
|
|
|
1699
1697
|
|
|
1700
1698
|
/**
|
|
1701
1699
|
* XAD: HL7 v2 Extended Address composite. 12-component structured address
|
|
1702
|
-
* shape parsed from a `RawRepetition` on demand by `Field.asXad()
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1700
|
+
* shape parsed from a `RawRepetition` on demand by `Field.asXad()`. Fields
|
|
1701
|
+
* are OMITTED when absent (exactOptionalPropertyTypes), NEVER set to
|
|
1702
|
+
* `undefined`.
|
|
1705
1703
|
*
|
|
1706
1704
|
* Zero runtime deps: pure function over the raw positional tree + `unescape`.
|
|
1707
1705
|
*/
|
|
@@ -1747,8 +1745,8 @@ interface XAD {
|
|
|
1747
1745
|
}
|
|
1748
1746
|
/**
|
|
1749
1747
|
* Parse an HL7 v2 XAD repetition into a structured `XAD` object. Components
|
|
1750
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1751
|
-
*
|
|
1748
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1749
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1752
1750
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1753
1751
|
*
|
|
1754
1752
|
* @example
|
|
@@ -1829,8 +1827,8 @@ interface XCN {
|
|
|
1829
1827
|
}
|
|
1830
1828
|
/**
|
|
1831
1829
|
* Parse an HL7 v2 XCN repetition into a structured `XCN` object. Components
|
|
1832
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1833
|
-
*
|
|
1830
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1831
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1834
1832
|
* from the result (exactOptionalPropertyTypes semantics). Component 9
|
|
1835
1833
|
* (`assigningAuthority`) is parsed as a nested `HD`; see component table in
|
|
1836
1834
|
* the `XCN` interface JSDoc for the v1 trimming.
|
|
@@ -1864,9 +1862,9 @@ declare function parseXcn(rep: RawRepetition, enc: EncodingCharacters): XCN;
|
|
|
1864
1862
|
|
|
1865
1863
|
/**
|
|
1866
1864
|
* XPN: HL7 v2 Extended Person Name composite. 14-component structured-name
|
|
1867
|
-
* shape parsed from a `RawRepetition` on demand by `Field.asXpn()
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1865
|
+
* shape parsed from a `RawRepetition` on demand by `Field.asXpn()`. Fields
|
|
1866
|
+
* are OMITTED when absent (exactOptionalPropertyTypes), NEVER set to
|
|
1867
|
+
* `undefined`.
|
|
1870
1868
|
*
|
|
1871
1869
|
* Zero runtime deps: pure function over the raw positional tree + `unescape`.
|
|
1872
1870
|
*/
|
|
@@ -1916,8 +1914,8 @@ interface XPN {
|
|
|
1916
1914
|
}
|
|
1917
1915
|
/**
|
|
1918
1916
|
* Parse an HL7 v2 XPN repetition into a structured `XPN` object. Components
|
|
1919
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1920
|
-
*
|
|
1917
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1918
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1921
1919
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1922
1920
|
*
|
|
1923
1921
|
* @example
|
|
@@ -1938,9 +1936,9 @@ declare function parseXpn(rep: RawRepetition, enc: EncodingCharacters): XPN;
|
|
|
1938
1936
|
* XTN: HL7 v2 Extended Telecommunication Number composite. 12-component
|
|
1939
1937
|
* structured telecom shape (v1 trimmed from the HL7 v2.5 full 14-component
|
|
1940
1938
|
* XTN: slots 13/14 are rarely-used legacy fields; v2 may restore the full
|
|
1941
|
-
* shape) parsed from a `RawRepetition` on demand by `Field.asXtn()
|
|
1942
|
-
*
|
|
1943
|
-
|
|
1939
|
+
* shape) parsed from a `RawRepetition` on demand by `Field.asXtn()`. Fields
|
|
1940
|
+
* are OMITTED when absent (exactOptionalPropertyTypes): NEVER set to
|
|
1941
|
+
* `undefined`.
|
|
1944
1942
|
*
|
|
1945
1943
|
* Zero runtime deps: pure function over the raw positional tree + `unescape`.
|
|
1946
1944
|
*/
|
|
@@ -1993,8 +1991,8 @@ interface XTN {
|
|
|
1993
1991
|
}
|
|
1994
1992
|
/**
|
|
1995
1993
|
* Parse an HL7 v2 XTN repetition into a structured `XTN` object. Components
|
|
1996
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1997
|
-
*
|
|
1994
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1995
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1998
1996
|
* from the result (exactOptionalPropertyTypes semantics). Components past
|
|
1999
1997
|
* position 12 are silently ignored in v1.
|
|
2000
1998
|
*
|
|
@@ -2049,11 +2047,11 @@ declare class Field {
|
|
|
2049
2047
|
readonly isNull: boolean;
|
|
2050
2048
|
/** Reference to the underlying `RawField.repetitions` (no defensive copy). */
|
|
2051
2049
|
readonly repetitions: readonly RawRepetition[];
|
|
2052
|
-
/** The 5 encoding characters for this message. Exposed for composite parsers
|
|
2050
|
+
/** The 5 encoding characters for this message. Exposed for composite parsers. @internal */
|
|
2053
2051
|
readonly enc: EncodingCharacters;
|
|
2054
2052
|
/** Position of this field in the parent message: used for position-aware error messages. @internal */
|
|
2055
2053
|
readonly position: Hl7Position;
|
|
2056
|
-
/** The full `RawField` this wrapper wraps. Exposed for composite parsers
|
|
2054
|
+
/** The full `RawField` this wrapper wraps. Exposed for composite parsers. @internal */
|
|
2057
2055
|
readonly raw: RawField;
|
|
2058
2056
|
/**
|
|
2059
2057
|
* Construct a new `Field`. Called internally by `Segment.field(n)`; user
|
|
@@ -2064,7 +2062,7 @@ declare class Field {
|
|
|
2064
2062
|
/**
|
|
2065
2063
|
* First-repetition, first-component, first-subcomponent value as a decoded
|
|
2066
2064
|
* string: unescaped ONCE by the tokenizer on parse, returned verbatim here
|
|
2067
|
-
* (never re-unescaped
|
|
2065
|
+
* (never re-unescaped). Returns `""` when the field is
|
|
2068
2066
|
* empty or HL7 null. Equivalent to `msg.get('SEG.N')` for a top-level access.
|
|
2069
2067
|
*
|
|
2070
2068
|
* @example
|
|
@@ -2087,7 +2085,7 @@ declare class Field {
|
|
|
2087
2085
|
* vendor-quirk control id containing an unescaped delimiter (`ID^X`) must
|
|
2088
2086
|
* not be truncated to its first component.
|
|
2089
2087
|
*
|
|
2090
|
-
* **Byte-verbatim for parsed content
|
|
2088
|
+
* **Byte-verbatim for parsed content.** The parse pipeline stores
|
|
2091
2089
|
* *decoded* content, but also records the original wire bytes of any escape
|
|
2092
2090
|
* whose decode is not byte-faithful (`RawComponent.rawSubcomponents`), so
|
|
2093
2091
|
* re-serialization preserves the sender's exact escape bytes: hex escapes
|
|
@@ -2300,7 +2298,7 @@ declare class Field {
|
|
|
2300
2298
|
* calls `new Segment(...)` directly.
|
|
2301
2299
|
*
|
|
2302
2300
|
* The wrapper does NOT copy `raw.fields`: it holds a reference so mutations
|
|
2303
|
-
* through
|
|
2301
|
+
* through `setField` / `addSegment` / `removeSegment` stay visible.
|
|
2304
2302
|
*/
|
|
2305
2303
|
|
|
2306
2304
|
/**
|
|
@@ -2317,7 +2315,24 @@ declare class Field {
|
|
|
2317
2315
|
* ```
|
|
2318
2316
|
*/
|
|
2319
2317
|
declare class Segment {
|
|
2320
|
-
/**
|
|
2318
|
+
/**
|
|
2319
|
+
* Segment identifier: three characters with a leading letter, e.g. `"PID"`,
|
|
2320
|
+
* `"OBX"`, `"ZPI"`.
|
|
2321
|
+
*
|
|
2322
|
+
* **Bounded, and it is `"<withheld>"` when the raw name is not that shape.**
|
|
2323
|
+
* A line with no field separator has its whole content read as a segment
|
|
2324
|
+
* name, so an unescaped line break inside a narrative field forges a
|
|
2325
|
+
* "segment" whose name is clinical text. This field presents itself as a
|
|
2326
|
+
* structural identifier and consumers interpolate it into labels, loci and
|
|
2327
|
+
* reports, so it never carries that text. `""` still means absent, which is
|
|
2328
|
+
* a different fact from withheld.
|
|
2329
|
+
*
|
|
2330
|
+
* Use {@link Segment.raw}`.name` when you need the verbatim text: it is the
|
|
2331
|
+
* unbounded value, and it is what serialization emits, so the byte-verbatim
|
|
2332
|
+
* round-trip is unaffected. One consequence worth knowing: a segment whose
|
|
2333
|
+
* raw name fails the shape (a 4-character vendor Z-segment, which HL7 v2
|
|
2334
|
+
* Ch. 2 §2.5 does not permit) is not matched by `msg.segments(name)`.
|
|
2335
|
+
*/
|
|
2321
2336
|
readonly type: string;
|
|
2322
2337
|
/** Reference to the underlying `RawSegment.fields`: 1-indexed per HL7 convention. */
|
|
2323
2338
|
readonly fields: readonly RawField[];
|
|
@@ -2325,7 +2340,7 @@ declare class Segment {
|
|
|
2325
2340
|
readonly enc: EncodingCharacters;
|
|
2326
2341
|
/** Absolute index of this segment in `Hl7Message.rawSegments[]`. Used for position tracking. @internal */
|
|
2327
2342
|
readonly absoluteIndex: number;
|
|
2328
|
-
/** The full `RawSegment` this wrapper wraps. Exposed for mutation methods
|
|
2343
|
+
/** The full `RawSegment` this wrapper wraps. Exposed for mutation methods. @internal */
|
|
2329
2344
|
readonly raw: RawSegment;
|
|
2330
2345
|
/**
|
|
2331
2346
|
* Lookup map from profile-declared field name → 1-indexed HL7 position.
|
|
@@ -2342,7 +2357,7 @@ declare class Segment {
|
|
|
2342
2357
|
* should obtain `Segment` instances via `msg.segments(type)` or
|
|
2343
2358
|
* `msg.allSegments()`.
|
|
2344
2359
|
*
|
|
2345
|
-
* The optional `customFields` parameter is the per-segment
|
|
2360
|
+
* The optional `customFields` parameter is the per-segment portion of the
|
|
2346
2361
|
* applied profile's merged `customSegments` map (PROF-07 / D-16). When
|
|
2347
2362
|
* supplied, `get(name)` resolves names against it; otherwise `get(name)`
|
|
2348
2363
|
* always returns `undefined`.
|
|
@@ -2400,7 +2415,7 @@ declare class Segment {
|
|
|
2400
2415
|
}
|
|
2401
2416
|
|
|
2402
2417
|
/**
|
|
2403
|
-
* `identityEvents`:
|
|
2418
|
+
* `identityEvents`: read-side helper that recognizes the ADT
|
|
2404
2419
|
* patient-identity management trigger events and surfaces the MRG segment's
|
|
2405
2420
|
* *prior* (non-surviving) identifiers alongside the PID/PV1 *surviving*
|
|
2406
2421
|
* identifiers, each labelled by role.
|
|
@@ -2455,7 +2470,7 @@ type IdentityEventKind = "merge" | "move" | "link" | "unlink" | "add" | "update"
|
|
|
2455
2470
|
/**
|
|
2456
2471
|
* Role of one party in an identity event. `surviving` / `subject` / `linked`
|
|
2457
2472
|
* parties are ONLY ever sourced from PID (+ PV1); `prior` parties are ONLY
|
|
2458
|
-
* ever sourced from MRG
|
|
2473
|
+
* ever sourced from MRG. That is the role-labelling invariant.
|
|
2459
2474
|
*
|
|
2460
2475
|
* @example
|
|
2461
2476
|
* ```ts
|
|
@@ -2557,17 +2572,17 @@ interface IdentityEvent {
|
|
|
2557
2572
|
}
|
|
2558
2573
|
|
|
2559
2574
|
/**
|
|
2560
|
-
*
|
|
2575
|
+
* Helper type declarations: the 9 typed shapes returned by
|
|
2561
2576
|
* `Hl7Message.meta`/`.patient`/`.visit` getters and the 6 collection methods
|
|
2562
2577
|
* (`observations()`, `orders()`, `nextOfKin()`, `allergies()`, `diagnoses()`,
|
|
2563
2578
|
* `insurance()`). Every field is `readonly`; every optional key is
|
|
2564
2579
|
* `exactOptionalPropertyTypes`-safe (never `| undefined` on the declaration).
|
|
2565
2580
|
*
|
|
2566
2581
|
* Types compose on the 11 v1 composites from `src/model/types/*.ts` (XPN, XAD,
|
|
2567
|
-
* CX, CWE, CE, XTN, PL, XCN): helpers are pure views on top of
|
|
2582
|
+
* CX, CWE, CE, XTN, PL, XCN): helpers are pure views on top of the model layer's
|
|
2568
2583
|
* composite coercions, never re-parsing the raw tree.
|
|
2569
2584
|
*
|
|
2570
|
-
* Field lists locked by
|
|
2585
|
+
* Field lists are locked by decisions D-01..D-24. Nine interfaces:
|
|
2571
2586
|
* `Meta`, `Patient`, `Visit`, `Observation` (discriminated union + `ObservationBase`),
|
|
2572
2587
|
* `Order`, `NextOfKin`, `Allergy`, `Diagnosis`, `Insurance`.
|
|
2573
2588
|
*/
|
|
@@ -2576,7 +2591,7 @@ interface IdentityEvent {
|
|
|
2576
2591
|
* MSH-derived message metadata (HELPERS-01). D-03: always defined on
|
|
2577
2592
|
* `Hl7Message.meta` (MSH absence throws `NO_MSH_SEGMENT` at parse time);
|
|
2578
2593
|
* individual fields are optional because vendor-quirky messages routinely
|
|
2579
|
-
* omit pieces of MSH.
|
|
2594
|
+
* omit pieces of MSH. `timestamp` is the fidelity `TS` (precision +
|
|
2580
2595
|
* timezone preserved), not an eager UTC-assuming `Date`.
|
|
2581
2596
|
*
|
|
2582
2597
|
* @example
|
|
@@ -2603,7 +2618,7 @@ interface Meta {
|
|
|
2603
2618
|
readonly messageStructure?: string;
|
|
2604
2619
|
/** MSH-10 message control ID: unique per message per sender. */
|
|
2605
2620
|
readonly controlId?: string;
|
|
2606
|
-
/** MSH-7 message date/time as the fidelity `TS
|
|
2621
|
+
/** MSH-7 message date/time as the fidelity `TS`. */
|
|
2607
2622
|
readonly timestamp?: TS;
|
|
2608
2623
|
/** MSH-12 HL7 version string (e.g. "2.5", "2.5.1"). */
|
|
2609
2624
|
readonly version?: string;
|
|
@@ -2656,7 +2671,7 @@ interface Patient {
|
|
|
2656
2671
|
/** Composed Western-order name "Given Middle Family, Suffix" (D-17). */
|
|
2657
2672
|
readonly fullName?: string;
|
|
2658
2673
|
/**
|
|
2659
|
-
* PID-7 date of birth as the fidelity `TS
|
|
2674
|
+
* PID-7 date of birth as the fidelity `TS`. A day-only DOB keeps
|
|
2660
2675
|
* `precision: "day"`: never coerced to a UTC-midnight instant that would
|
|
2661
2676
|
* read as the previous day in a negative-offset zone.
|
|
2662
2677
|
*/
|
|
@@ -2674,7 +2689,7 @@ interface Patient {
|
|
|
2674
2689
|
/** PID-15 primary language. */
|
|
2675
2690
|
readonly language?: CE;
|
|
2676
2691
|
/**
|
|
2677
|
-
* NTE note lines positionally attached to the (first) PID
|
|
2692
|
+
* NTE note lines positionally attached to the (first) PID: notes
|
|
2678
2693
|
* immediately following the patient's PID segment, HL7-unescaped, in
|
|
2679
2694
|
* document order. OMITTED when the patient carries no notes. High-PHI-risk
|
|
2680
2695
|
* clinical narrative.
|
|
@@ -2684,7 +2699,7 @@ interface Patient {
|
|
|
2684
2699
|
/**
|
|
2685
2700
|
* PV1-derived visit view (HELPERS-03). `msg.visit` is `undefined` when no PV1
|
|
2686
2701
|
* segment exists; this interface describes the shape when present. D-24a:
|
|
2687
|
-
* doctor fields use XCN (not flat strings).
|
|
2702
|
+
* doctor fields use XCN (not flat strings). Date/time fields are the
|
|
2688
2703
|
* fidelity `TS` (precision + timezone preserved).
|
|
2689
2704
|
*
|
|
2690
2705
|
* @example
|
|
@@ -2704,9 +2719,9 @@ interface Visit {
|
|
|
2704
2719
|
readonly patientClass?: string;
|
|
2705
2720
|
/** PV1-3 assigned patient location (ward / room / bed) as PL. */
|
|
2706
2721
|
readonly location?: PL;
|
|
2707
|
-
/** PV1-44 admit date/time as the fidelity `TS
|
|
2722
|
+
/** PV1-44 admit date/time as the fidelity `TS`. */
|
|
2708
2723
|
readonly admitDateTime?: TS;
|
|
2709
|
-
/** PV1-45 discharge date/time as the fidelity `TS
|
|
2724
|
+
/** PV1-45 discharge date/time as the fidelity `TS`. */
|
|
2710
2725
|
readonly dischargeDateTime?: TS;
|
|
2711
2726
|
/** PV1-7 attending doctor (D-24a XCN). */
|
|
2712
2727
|
readonly attendingDoctor?: XCN;
|
|
@@ -2752,10 +2767,10 @@ interface ObservationBase {
|
|
|
2752
2767
|
readonly abnormalFlags?: string;
|
|
2753
2768
|
/** OBX-11 observation result status (e.g. "F"=final, "P"=preliminary). */
|
|
2754
2769
|
readonly status?: string;
|
|
2755
|
-
/** OBX-14 date/time of observation as the fidelity `TS
|
|
2770
|
+
/** OBX-14 date/time of observation as the fidelity `TS`. */
|
|
2756
2771
|
readonly observedDateTime?: TS;
|
|
2757
2772
|
/**
|
|
2758
|
-
* NTE note lines positionally attached to this OBX
|
|
2773
|
+
* NTE note lines positionally attached to this OBX: each
|
|
2759
2774
|
* non-empty NTE-3 (Comment, FT) repetition of every NTE immediately
|
|
2760
2775
|
* following this observation, HL7-unescaped, in document order. OMITTED when
|
|
2761
2776
|
* the observation carries no notes. High-PHI-risk clinical narrative.
|
|
@@ -2767,7 +2782,7 @@ interface ObservationBase {
|
|
|
2767
2782
|
* `valueType` (OBX-2) per D-13:
|
|
2768
2783
|
* - `"NM"` → `number | undefined`
|
|
2769
2784
|
* - `"SN"` → `SN | undefined` (structured numeric: comparator / range / ratio)
|
|
2770
|
-
* - `"TS" | "DT"` → `TS | undefined` (fidelity parts
|
|
2785
|
+
* - `"TS" | "DT"` → `TS | undefined` (fidelity parts preserved)
|
|
2771
2786
|
* - `"CWE" | "CE"` → `CWE | CE | undefined` (full composite per D-14)
|
|
2772
2787
|
* - other (`"ST"`, `"TX"`, `"FT"`, `"ID"`, `"IS"`, `"NA"`, unknown) →
|
|
2773
2788
|
* `string | undefined` (decoded, D-23)
|
|
@@ -2809,7 +2824,7 @@ type Observation = ObservationBase & ({
|
|
|
2809
2824
|
});
|
|
2810
2825
|
/**
|
|
2811
2826
|
* How an order/medication `RepeatPattern` code (HL7 Table 0335) is classified,
|
|
2812
|
-
* **provenance only, never used to resolve a schedule
|
|
2827
|
+
* **provenance only, never used to resolve a schedule**. The `code`
|
|
2813
2828
|
* is always authoritative and surfaced verbatim; this flag only tells a
|
|
2814
2829
|
* consumer *what kind* of pattern it is looking at so it can decide whether a
|
|
2815
2830
|
* load-bearing integer is present.
|
|
@@ -2827,7 +2842,7 @@ type Observation = ObservationBase & ({
|
|
|
2827
2842
|
type RepeatPatternKind = "parametric" | "named" | "unknown";
|
|
2828
2843
|
/**
|
|
2829
2844
|
* An order/medication timing **repeat pattern** (HL7 Table 0335): the
|
|
2830
|
-
* frequency/SIG field (TQ1-3, or the legacy embedded TQ interval RI.1)
|
|
2845
|
+
* frequency/SIG field (TQ1-3, or the legacy embedded TQ interval RI.1).
|
|
2831
2846
|
*
|
|
2832
2847
|
* **Safety contract.** `code` is the **decoded field value** (HL7 escapes are
|
|
2833
2848
|
* unescaped as with every field read) and is **never resolved to clock times,
|
|
@@ -2861,7 +2876,7 @@ interface RepeatPattern {
|
|
|
2861
2876
|
}
|
|
2862
2877
|
/**
|
|
2863
2878
|
* A composite-quantity (CQ) value on an order/medication timing: the TQ1-2
|
|
2864
|
-
* service quantity
|
|
2879
|
+
* service quantity. `value` is strict-`Number()` parsed (`undefined`,
|
|
2865
2880
|
* never `NaN`); `units` carries any CQ.2 units. Both keys OMITTED when absent.
|
|
2866
2881
|
*
|
|
2867
2882
|
* @example
|
|
@@ -2878,14 +2893,14 @@ interface TimingQuantity {
|
|
|
2878
2893
|
}
|
|
2879
2894
|
/**
|
|
2880
2895
|
* The order/medication **timing** structure: one TQ1 segment (v2.5+) or the
|
|
2881
|
-
* legacy embedded TQ in ORC-7 / RXE-1 (pre-v2.5)
|
|
2896
|
+
* legacy embedded TQ in ORC-7 / RXE-1 (pre-v2.5). Attached to
|
|
2882
2897
|
* {@link Order.timings} and {@link Medication.timings}.
|
|
2883
2898
|
*
|
|
2884
2899
|
* **Safety contract.** hl7 surfaces the timing **structure**; it does **not**
|
|
2885
2900
|
* compute administration schedules, resolve "institution-specified times" to
|
|
2886
2901
|
* clock times, or interpret sig. The load-bearing {@link repeatPattern} and
|
|
2887
2902
|
* {@link totalOccurrences} are preserved verbatim (see {@link RepeatPattern});
|
|
2888
|
-
* `startDateTime`/`endDateTime` keep the
|
|
2903
|
+
* `startDateTime`/`endDateTime` keep the `TS` precision + timezone
|
|
2889
2904
|
* fidelity. A malformed timing never throws: absent pieces are omitted keys.
|
|
2890
2905
|
*
|
|
2891
2906
|
* @example
|
|
@@ -2917,9 +2932,9 @@ interface OrderTiming {
|
|
|
2917
2932
|
readonly explicitTime?: string;
|
|
2918
2933
|
/** TQ1-6 / legacy TQ.3 service duration: surfaced verbatim. */
|
|
2919
2934
|
readonly serviceDuration?: string;
|
|
2920
|
-
/** TQ1-7 / legacy TQ.4 start date/time as the fidelity `TS
|
|
2935
|
+
/** TQ1-7 / legacy TQ.4 start date/time as the fidelity `TS`. */
|
|
2921
2936
|
readonly startDateTime?: TS;
|
|
2922
|
-
/** TQ1-8 / legacy TQ.5 end date/time as the fidelity `TS
|
|
2937
|
+
/** TQ1-8 / legacy TQ.5 end date/time as the fidelity `TS`. */
|
|
2923
2938
|
readonly endDateTime?: TS;
|
|
2924
2939
|
/** TQ1-9 priority (CWE) / legacy TQ.6 priority (surfaced as a CWE `{ identifier }`). */
|
|
2925
2940
|
readonly priority?: CWE;
|
|
@@ -2934,8 +2949,8 @@ interface OrderTiming {
|
|
|
2934
2949
|
/**
|
|
2935
2950
|
* OBR-derived order (HELPERS-05, D-16) with positionally-grouped OBX children
|
|
2936
2951
|
* (D-12). `observations` is ALWAYS present: empty when no OBX follows this
|
|
2937
|
-
* OBR before the next OBR or end-of-message.
|
|
2938
|
-
*
|
|
2952
|
+
* OBR before the next OBR or end-of-message. `timings` is ALWAYS present,
|
|
2953
|
+
* empty when the order carries no TQ1 / legacy embedded TQ.
|
|
2939
2954
|
*
|
|
2940
2955
|
* @example
|
|
2941
2956
|
* ```ts
|
|
@@ -2957,7 +2972,7 @@ interface Order {
|
|
|
2957
2972
|
readonly fillerOrderNumber?: string;
|
|
2958
2973
|
/** OBR-4 universal service identifier (test code + description). */
|
|
2959
2974
|
readonly universalServiceId?: CWE;
|
|
2960
|
-
/** OBR-
|
|
2975
|
+
/** OBR-25 result status (HL7 Table 0123, e.g. `"F"` final, `"P"` preliminary). */
|
|
2961
2976
|
readonly orderStatus?: string;
|
|
2962
2977
|
/** ORC-1 order control when an ORC precedes this OBR. */
|
|
2963
2978
|
readonly orderControl?: string;
|
|
@@ -2966,13 +2981,13 @@ interface Order {
|
|
|
2966
2981
|
/** OBX children grouped under this OBR (D-12 positional grouping). Always present. */
|
|
2967
2982
|
readonly observations: readonly Observation[];
|
|
2968
2983
|
/**
|
|
2969
|
-
* TQ1 / legacy embedded-TQ timing(s) grouped under this order
|
|
2984
|
+
* TQ1 / legacy embedded-TQ timing(s) grouped under this order.
|
|
2970
2985
|
* Always present: empty when the order carries no timing. See
|
|
2971
2986
|
* {@link OrderTiming}.
|
|
2972
2987
|
*/
|
|
2973
2988
|
readonly timings: readonly OrderTiming[];
|
|
2974
2989
|
/**
|
|
2975
|
-
* NTE note lines positionally attached to this order
|
|
2990
|
+
* NTE note lines positionally attached to this order: the
|
|
2976
2991
|
* ORC-region notes (before the OBR) followed by the OBR-region notes, in
|
|
2977
2992
|
* document order. Several ORCs before one OBR all contribute here; nothing is
|
|
2978
2993
|
* dropped. OMITTED when the order carries no notes. A note on a trailing or
|
|
@@ -3008,7 +3023,7 @@ interface NextOfKin {
|
|
|
3008
3023
|
readonly contactRole?: CWE;
|
|
3009
3024
|
}
|
|
3010
3025
|
/**
|
|
3011
|
-
* AL1-derived allergy entry (HELPERS-06).
|
|
3026
|
+
* AL1-derived allergy entry (HELPERS-06). `onsetDate` is the fidelity `TS`.
|
|
3012
3027
|
*
|
|
3013
3028
|
* @example
|
|
3014
3029
|
* ```ts
|
|
@@ -3030,11 +3045,11 @@ interface Allergy {
|
|
|
3030
3045
|
readonly severity?: string;
|
|
3031
3046
|
/** AL1-5 allergy reaction description (first value). */
|
|
3032
3047
|
readonly reaction?: string;
|
|
3033
|
-
/** AL1-6 onset date as the fidelity `TS
|
|
3048
|
+
/** AL1-6 onset date as the fidelity `TS`. */
|
|
3034
3049
|
readonly onsetDate?: TS;
|
|
3035
3050
|
}
|
|
3036
3051
|
/**
|
|
3037
|
-
* DG1-derived diagnosis entry (HELPERS-06).
|
|
3052
|
+
* DG1-derived diagnosis entry (HELPERS-06). `dateTime` is the fidelity `TS`.
|
|
3038
3053
|
*
|
|
3039
3054
|
* @example
|
|
3040
3055
|
* ```ts
|
|
@@ -3051,7 +3066,7 @@ interface Diagnosis {
|
|
|
3051
3066
|
readonly code?: CWE;
|
|
3052
3067
|
/** DG1-4 diagnosis description. */
|
|
3053
3068
|
readonly description?: string;
|
|
3054
|
-
/** DG1-5 diagnosis date/time as the fidelity `TS
|
|
3069
|
+
/** DG1-5 diagnosis date/time as the fidelity `TS`. */
|
|
3055
3070
|
readonly dateTime?: TS;
|
|
3056
3071
|
/** DG1-6 diagnosis type (A=admitting, W=working, F=final). */
|
|
3057
3072
|
readonly type?: string;
|
|
@@ -3059,7 +3074,7 @@ interface Diagnosis {
|
|
|
3059
3074
|
/**
|
|
3060
3075
|
* Which pharmacy/treatment segment a `Medication` was extracted from: the
|
|
3061
3076
|
* clinical "phase" of the medication. Each value maps 1:1 to one RX* parent
|
|
3062
|
-
* segment (
|
|
3077
|
+
* segment (Ch. 4A):
|
|
3063
3078
|
* - `"order"`: **RXO** (Pharmacy/Treatment Order): the originally *requested*
|
|
3064
3079
|
* give code/amount/dosage-form, before pharmacy encoding.
|
|
3065
3080
|
* - `"encoded"`: **RXE** (Encoded Order): the pharmacy-encoded give
|
|
@@ -3076,7 +3091,7 @@ interface Diagnosis {
|
|
|
3076
3091
|
*/
|
|
3077
3092
|
type MedicationContext = "order" | "encoded" | "dispense" | "administration";
|
|
3078
3093
|
/**
|
|
3079
|
-
* The give / dispense / administered amount of a `Medication
|
|
3094
|
+
* The give / dispense / administered amount of a `Medication`.
|
|
3080
3095
|
* Carries the HL7 min/max amount pair and its units.
|
|
3081
3096
|
*
|
|
3082
3097
|
* - For an **order** (RXO-2/3) or **encoded** order (RXE-3/4) the amount is a
|
|
@@ -3106,11 +3121,11 @@ interface MedicationAmount {
|
|
|
3106
3121
|
}
|
|
3107
3122
|
/**
|
|
3108
3123
|
* The give *strength* of an **encoded** `Medication` (RXE-25 value + RXE-26
|
|
3109
|
-
* units)
|
|
3124
|
+
* units). Strength is the concentration of active ingredient (e.g.
|
|
3110
3125
|
* "250 mg"), distinct from the give *amount* (how much is administered, e.g.
|
|
3111
3126
|
* "2 tablets"). Only the `"encoded"` (RXE) context carries strength.
|
|
3112
3127
|
*
|
|
3113
|
-
* **Fail-safe
|
|
3128
|
+
* **Fail-safe:** strength is surfaced exactly as the explicit
|
|
3114
3129
|
* RXE-25/26 fields declare it, and is NEVER reconciled against any strength
|
|
3115
3130
|
* *implied* by the give code (e.g. an NDC that encodes "250 mg"). A consumer
|
|
3116
3131
|
* that sees both an explicit strength here and a coded drug in `giveCode` must
|
|
@@ -3130,8 +3145,8 @@ interface MedicationStrength {
|
|
|
3130
3145
|
readonly units?: CWE;
|
|
3131
3146
|
}
|
|
3132
3147
|
/**
|
|
3133
|
-
* One RXR (Pharmacy/Treatment Route) grouped under its parent RX* segment
|
|
3134
|
-
*
|
|
3148
|
+
* One RXR (Pharmacy/Treatment Route) grouped under its parent RX* segment.
|
|
3149
|
+
* `route` is HL7 Table 0162 (CWE); `site` is Table 0163 (CWE).
|
|
3135
3150
|
* Provenance travels on the CWE (`route.nameOfCodingSystem`): a "PO" route is
|
|
3136
3151
|
* only safe to act on when you know the system it was coded against.
|
|
3137
3152
|
*
|
|
@@ -3149,7 +3164,7 @@ interface MedicationRoute {
|
|
|
3149
3164
|
}
|
|
3150
3165
|
/**
|
|
3151
3166
|
* One RXC (Pharmacy/Treatment Component Order) grouped under its parent RX*
|
|
3152
|
-
* segment
|
|
3167
|
+
* segment: a component of a compound/IV. Surfaced STRUCTURALLY
|
|
3153
3168
|
* (the component list as authored), NOT pharmacologically resolved.
|
|
3154
3169
|
*
|
|
3155
3170
|
* @example
|
|
@@ -3169,8 +3184,8 @@ interface MedicationComponent {
|
|
|
3169
3184
|
readonly units?: CWE;
|
|
3170
3185
|
}
|
|
3171
3186
|
/**
|
|
3172
|
-
* A medication extracted from one RXO/RXE/RXD/RXA segment
|
|
3173
|
-
*
|
|
3187
|
+
* A medication extracted from one RXO/RXE/RXD/RXA segment, with its RXR
|
|
3188
|
+
* (route) and RXC (component) children grouped
|
|
3174
3189
|
* positionally. `context` records which RX* segment this came from (give
|
|
3175
3190
|
* vs dispense vs administered).
|
|
3176
3191
|
*
|
|
@@ -3180,12 +3195,12 @@ interface MedicationComponent {
|
|
|
3180
3195
|
* (`giveCode.nameOfCodingSystem`: e.g. `RXN` RxNorm, `NDC`). The helper
|
|
3181
3196
|
* surfaces the *claim*; it never validates or looks the code up.
|
|
3182
3197
|
* - `amount` (how much) and `strength` (concentration) are SEPARATE fields and
|
|
3183
|
-
* are never reconciled: including against any strength a coded drug
|
|
3184
|
-
*
|
|
3198
|
+
* are never reconciled: including against any strength a coded drug
|
|
3199
|
+
* implies. A disagreement is preserved for the consumer to see.
|
|
3185
3200
|
* - Malformed RX* segments never throw: absent fields are omitted keys.
|
|
3186
3201
|
*
|
|
3187
|
-
* `routes` and `components` are ALWAYS present (possibly empty).
|
|
3188
|
-
* `timings`:
|
|
3202
|
+
* `routes` and `components` are ALWAYS present (possibly empty). So is
|
|
3203
|
+
* `timings`: empty when no TQ1 / legacy embedded TQ (RXE-1)
|
|
3189
3204
|
* accompanies the medication; the repeat pattern is surfaced **verbatim, never
|
|
3190
3205
|
* normalized to a schedule**. Deferred (not v1): sig/frequency *interpretation*,
|
|
3191
3206
|
* dose-range or interaction checking, pharmacologic resolution of compounds.
|
|
@@ -3220,8 +3235,8 @@ interface Medication {
|
|
|
3220
3235
|
/** RXC children grouped under this RX* (compound components). Always present (possibly empty). */
|
|
3221
3236
|
readonly components: readonly MedicationComponent[];
|
|
3222
3237
|
/**
|
|
3223
|
-
* TQ1 / legacy embedded-TQ (RXE-1) timing(s) grouped under this medication
|
|
3224
|
-
*
|
|
3238
|
+
* TQ1 / legacy embedded-TQ (RXE-1) timing(s) grouped under this medication.
|
|
3239
|
+
* Always present: empty when the medication carries no timing.
|
|
3225
3240
|
* See {@link OrderTiming}.
|
|
3226
3241
|
*/
|
|
3227
3242
|
readonly timings: readonly OrderTiming[];
|
|
@@ -3256,9 +3271,9 @@ interface Insurance {
|
|
|
3256
3271
|
readonly groupNumber?: string;
|
|
3257
3272
|
/** IN1-16 insured's name. */
|
|
3258
3273
|
readonly insuredName?: XPN;
|
|
3259
|
-
/** IN1-12 plan effective date as the fidelity `TS
|
|
3274
|
+
/** IN1-12 plan effective date as the fidelity `TS`. */
|
|
3260
3275
|
readonly effectiveDate?: TS;
|
|
3261
|
-
/** IN1-13 plan expiration date as the fidelity `TS
|
|
3276
|
+
/** IN1-13 plan expiration date as the fidelity `TS`. */
|
|
3262
3277
|
readonly expirationDate?: TS;
|
|
3263
3278
|
/** `true` iff an IN2 segment follows this IN1 before the next IN1. */
|
|
3264
3279
|
readonly hasIn2: boolean;
|
|
@@ -3285,7 +3300,7 @@ interface Insurance {
|
|
|
3285
3300
|
type ImmunizationRecordOrigin = "administered" | "historical";
|
|
3286
3301
|
/**
|
|
3287
3302
|
* A vaccine dose extracted from one RXA (Pharmacy/Treatment Administration)
|
|
3288
|
-
* segment of a VXU^V04 immunization message
|
|
3303
|
+
* segment of a VXU^V04 immunization message, with its RXR
|
|
3289
3304
|
* (route/site) and OBX (e.g. VFC eligibility / funding source) children grouped
|
|
3290
3305
|
* positionally under the RXA, and `orderControl` from the preceding ORC of the
|
|
3291
3306
|
* VXU order group (`ORC`→`RXA`→`[RXR]`→`[{OBX}]`).
|
|
@@ -3350,11 +3365,11 @@ interface Immunization {
|
|
|
3350
3365
|
readonly informationSource?: CWE;
|
|
3351
3366
|
/** Derived administered-vs-historical classification from RXA-9.1. See {@link ImmunizationRecordOrigin}. */
|
|
3352
3367
|
readonly recordOrigin?: ImmunizationRecordOrigin;
|
|
3353
|
-
/** RXA-3 date/time start of administration as the fidelity `TS
|
|
3368
|
+
/** RXA-3 date/time start of administration as the fidelity `TS`. */
|
|
3354
3369
|
readonly administeredDateTime?: TS;
|
|
3355
3370
|
/** RXA-15 substance lot number (first repetition). */
|
|
3356
3371
|
readonly lotNumber?: string;
|
|
3357
|
-
/** RXA-16 substance expiration date (first repetition) as the fidelity `TS
|
|
3372
|
+
/** RXA-16 substance expiration date (first repetition) as the fidelity `TS`. */
|
|
3358
3373
|
readonly expirationDate?: TS;
|
|
3359
3374
|
/** RXA-17 substance manufacturer (MVX, HL7 Table 0227; first repetition). */
|
|
3360
3375
|
readonly manufacturer?: CWE;
|
|
@@ -3370,7 +3385,7 @@ interface Immunization {
|
|
|
3370
3385
|
readonly observations: readonly Observation[];
|
|
3371
3386
|
}
|
|
3372
3387
|
/**
|
|
3373
|
-
* One appointment resource grouped under a `SCH
|
|
3388
|
+
* One appointment resource grouped under a `SCH`: an AIS (service),
|
|
3374
3389
|
* AIG (general resource), AIL (location), or AIP (personnel / provider) segment.
|
|
3375
3390
|
* The resource identifier lives at position 3 of every AI* segment; for the
|
|
3376
3391
|
* personnel resource (AIP) it is additionally surfaced as a typed `person`
|
|
@@ -3398,7 +3413,7 @@ interface AppointmentResource {
|
|
|
3398
3413
|
readonly person?: XCN;
|
|
3399
3414
|
}
|
|
3400
3415
|
/**
|
|
3401
|
-
* SCH-derived appointment entry (
|
|
3416
|
+
* SCH-derived appointment entry (SIU scheduling breadth). Surfaces the
|
|
3402
3417
|
* appointment identifiers, filler status (SCH-25, Table 0278), SCH-11 start/end
|
|
3403
3418
|
* timing, and the AI* resource groups. NOT a scheduling-workflow state machine.
|
|
3404
3419
|
*
|
|
@@ -3419,15 +3434,15 @@ interface Appointment {
|
|
|
3419
3434
|
readonly fillerAppointmentId?: string;
|
|
3420
3435
|
/** SCH-25 filler status code (HL7 Table 0278): the appointment status, verbatim/provenance-only. */
|
|
3421
3436
|
readonly fillerStatusCode?: CWE;
|
|
3422
|
-
/** Appointment start date/time: SCH-11 TQ.4 (fidelity `TS
|
|
3437
|
+
/** Appointment start date/time: SCH-11 TQ.4 (fidelity `TS`). */
|
|
3423
3438
|
readonly startDateTime?: TS;
|
|
3424
|
-
/** Appointment end date/time: SCH-11 TQ.5 (fidelity `TS
|
|
3439
|
+
/** Appointment end date/time: SCH-11 TQ.5 (fidelity `TS`). */
|
|
3425
3440
|
readonly endDateTime?: TS;
|
|
3426
3441
|
/** AIS/AIG/AIL/AIP resources grouped under this SCH. Always present (possibly empty). */
|
|
3427
3442
|
readonly resources: readonly AppointmentResource[];
|
|
3428
3443
|
}
|
|
3429
3444
|
/**
|
|
3430
|
-
* TXA-derived clinical-document entry (
|
|
3445
|
+
* TXA-derived clinical-document entry (MDM document breadth). The
|
|
3431
3446
|
* load-bearing safety property: **completion status (TXA-17) and availability
|
|
3432
3447
|
* status (TXA-19) are DISTINCT fields and are never conflated**: a document can
|
|
3433
3448
|
* be *available* before it is *authenticated*, and reading a preliminary
|
|
@@ -3460,7 +3475,7 @@ interface ClinicalDocument {
|
|
|
3460
3475
|
* {@link completionStatus}; verbatim, never validated, never merged.
|
|
3461
3476
|
*/
|
|
3462
3477
|
readonly availabilityStatus?: string;
|
|
3463
|
-
/** TXA-4 activity date/time (fidelity `TS
|
|
3478
|
+
/** TXA-4 activity date/time (fidelity `TS`). */
|
|
3464
3479
|
readonly activityDateTime?: TS;
|
|
3465
3480
|
/** TXA-12 unique document number (EI first component, verbatim). */
|
|
3466
3481
|
readonly uniqueDocumentNumber?: string;
|
|
@@ -3470,7 +3485,7 @@ interface ClinicalDocument {
|
|
|
3470
3485
|
readonly observations: readonly Observation[];
|
|
3471
3486
|
}
|
|
3472
3487
|
/**
|
|
3473
|
-
* FT1-derived charge entry (
|
|
3488
|
+
* FT1-derived charge entry (DFT financial breadth). Billing-critical
|
|
3474
3489
|
* fields surfaced with **no billing logic and no money-as-float**: the
|
|
3475
3490
|
* extended/unit amounts are the verbatim CP wire text, never parsed to a number.
|
|
3476
3491
|
*
|
|
@@ -3486,7 +3501,7 @@ interface ClinicalDocument {
|
|
|
3486
3501
|
* ```
|
|
3487
3502
|
*/
|
|
3488
3503
|
interface Charge {
|
|
3489
|
-
/** FT1-4 transaction date (fidelity `TS
|
|
3504
|
+
/** FT1-4 transaction date (fidelity `TS`). */
|
|
3490
3505
|
readonly transactionDate?: TS;
|
|
3491
3506
|
/** FT1-6 transaction type (HL7 Table 0017: `CG` charge, `CD` credit, `PY` payment, `AJ` adjustment). Verbatim. */
|
|
3492
3507
|
readonly transactionType?: string;
|
|
@@ -3503,7 +3518,7 @@ interface Charge {
|
|
|
3503
3518
|
}
|
|
3504
3519
|
|
|
3505
3520
|
/**
|
|
3506
|
-
* Message-type & structure awareness
|
|
3521
|
+
* Message-type & structure awareness: a conservative
|
|
3507
3522
|
* **misroute / truncation safety net**, NOT an abstract-message-syntax
|
|
3508
3523
|
* validator.
|
|
3509
3524
|
*
|
|
@@ -3605,9 +3620,19 @@ interface StructureGroup {
|
|
|
3605
3620
|
interface MessageStructure {
|
|
3606
3621
|
/** `true` when a `MESSAGE_STRUCTURE_DEFINITIONS` entry matched the type. */
|
|
3607
3622
|
readonly recognized: boolean;
|
|
3608
|
-
/**
|
|
3623
|
+
/**
|
|
3624
|
+
* MSH-9.1 message code observed on the message. `""` when absent, and
|
|
3625
|
+
* `"<withheld>"` when `recognized` is `false` and the observed value is not
|
|
3626
|
+
* identifier-shaped (MSH-9 can hold a data field on a malformed message).
|
|
3627
|
+
*/
|
|
3609
3628
|
readonly messageCode: string;
|
|
3610
|
-
/**
|
|
3629
|
+
/**
|
|
3630
|
+
* MSH-9.2 trigger event observed on the message. `""` when absent, and
|
|
3631
|
+
* `"<withheld>"` when `recognized` is `false` and the observed value is not
|
|
3632
|
+
* identifier-shaped. Note that on the `recognized` branch this is echoed
|
|
3633
|
+
* verbatim, which for a definition matching on message code alone (`ACK`)
|
|
3634
|
+
* means an arbitrary MSH-9.2.
|
|
3635
|
+
*/
|
|
3611
3636
|
readonly triggerEvent: string;
|
|
3612
3637
|
/** Per-expected-group presence verdicts (empty when unrecognized). */
|
|
3613
3638
|
readonly expectedGroups: readonly StructureGroup[];
|
|
@@ -3640,9 +3665,8 @@ declare function analyzeMessageStructure(messageCode: string, triggerEvent: stri
|
|
|
3640
3665
|
* `Hl7Message`. Mirrors `rawSegments` one-for-one; preserves `isNull`;
|
|
3641
3666
|
* always includes `warnings: []`; omits `profile` when absent.
|
|
3642
3667
|
*
|
|
3643
|
-
*
|
|
3644
|
-
*
|
|
3645
|
-
* `emitJson` function body is filled in Phase 5 Plan 03 (to-json).
|
|
3668
|
+
* `SerializedMessage` is exported from this module and re-exported from
|
|
3669
|
+
* `src/index.ts`, so consumers can reference the type directly.
|
|
3646
3670
|
*
|
|
3647
3671
|
* Decisions:
|
|
3648
3672
|
* - D-17: shape is a raw-tree mirror (encodingCharacters + segments +
|
|
@@ -3703,8 +3727,8 @@ interface SerializedMessage {
|
|
|
3703
3727
|
}
|
|
3704
3728
|
|
|
3705
3729
|
/**
|
|
3706
|
-
* Typed-composite **encoders** for the `@cosyte/hl7` emit path
|
|
3707
|
-
*
|
|
3730
|
+
* Typed-composite **encoders** for the `@cosyte/hl7` emit path: the
|
|
3731
|
+
* conservative-emit mirror of the `src/model/types/*` read parsers.
|
|
3708
3732
|
*
|
|
3709
3733
|
* Each encoder takes one typed composite (an {@link XPN} name, a {@link CX}
|
|
3710
3734
|
* identifier, a {@link TS} timestamp, …) and produces a `RawField` whose
|
|
@@ -3713,7 +3737,7 @@ interface SerializedMessage {
|
|
|
3713
3737
|
*
|
|
3714
3738
|
* - **No delimiter injection.** Component values are stored **decoded** (the
|
|
3715
3739
|
* same surface `parseXxx` returns), and the serializer (`emit-field.ts`)
|
|
3716
|
-
* runs every subcomponent through `reescape` (the
|
|
3740
|
+
* runs every subcomponent through `reescape` (the encode-safe codec)
|
|
3717
3741
|
* on the way out. A `familyName` of `"Smith^Jr"` is therefore emitted as
|
|
3718
3742
|
* `Smith\S\Jr` (one component) and re-parses to the exact string `"Smith^Jr"`,
|
|
3719
3743
|
* never forging a component boundary. The caller never hand-assembles
|
|
@@ -3907,13 +3931,12 @@ declare function encodeCompositeReps<K extends CompositeKind>(kind: K, values: r
|
|
|
3907
3931
|
|
|
3908
3932
|
/**
|
|
3909
3933
|
* `Hl7Message`: the immutable parsed-message model produced by `parseHL7`.
|
|
3910
|
-
*
|
|
3911
|
-
*
|
|
3912
|
-
*
|
|
3913
|
-
*
|
|
3914
|
-
* `
|
|
3915
|
-
*
|
|
3916
|
-
* the typed `segments(type)` method.
|
|
3934
|
+
* A read-only shell over the raw segment tree, plus the read-path traversal
|
|
3935
|
+
* methods (`get`, `getAll`, `segments`, `allSegments`) on top of lazy,
|
|
3936
|
+
* referentially stable Segment/Field caches. `init.segments` is the
|
|
3937
|
+
* parser-side constructor key; the public raw-tree field is exposed as
|
|
3938
|
+
* `rawSegments`, which frees the name `segments` for the typed
|
|
3939
|
+
* `segments(type)` method.
|
|
3917
3940
|
*/
|
|
3918
3941
|
|
|
3919
3942
|
/**
|
|
@@ -3928,8 +3951,8 @@ declare function encodeCompositeReps<K extends CompositeKind>(kind: K, values: r
|
|
|
3928
3951
|
* descriptor. This matches the `Hl7Message.profile` public field shape
|
|
3929
3952
|
* (`... | undefined`).
|
|
3930
3953
|
*
|
|
3931
|
-
* The init key is
|
|
3932
|
-
*
|
|
3954
|
+
* The init key is named `segments` (not `rawSegments`) so parser code that
|
|
3955
|
+
* constructs `Hl7Message` does not need to change. Inside
|
|
3933
3956
|
* the class body the raw tree is stored on `this.rawSegments`.
|
|
3934
3957
|
*
|
|
3935
3958
|
* @internal
|
|
@@ -3965,10 +3988,10 @@ interface Hl7MessageInit {
|
|
|
3965
3988
|
*
|
|
3966
3989
|
* @remarks
|
|
3967
3990
|
* The `warnings` array is frozen at the model boundary so downstream
|
|
3968
|
-
* traversal and
|
|
3969
|
-
* field is populated
|
|
3970
|
-
*
|
|
3971
|
-
*
|
|
3991
|
+
* traversal and helpers cannot mutate parser output. The `profile`
|
|
3992
|
+
* field is populated when a profile is passed, and is `undefined`
|
|
3993
|
+
* otherwise. Segment/Field wrappers are cached per-message and
|
|
3994
|
+
* invalidated wholesale by the mutation methods.
|
|
3972
3995
|
*
|
|
3973
3996
|
* @example
|
|
3974
3997
|
* ```ts
|
|
@@ -3986,11 +4009,20 @@ declare class Hl7Message {
|
|
|
3986
4009
|
* Raw positional tree produced by the parser. 1-indexed per HL7 convention
|
|
3987
4010
|
* (`fields[0]` is the segment-name / MSH separator placeholder slot). Use
|
|
3988
4011
|
* `segments(type)` / `allSegments()` for typed wrapper access: this field
|
|
3989
|
-
* is exposed for advanced callers that need the raw tree directly
|
|
3990
|
-
* future serialization phase 5).
|
|
4012
|
+
* is exposed for advanced callers that need the raw tree directly.
|
|
3991
4013
|
*/
|
|
3992
4014
|
readonly rawSegments: readonly RawSegment[];
|
|
3993
4015
|
readonly encodingCharacters: EncodingCharacters;
|
|
4016
|
+
/**
|
|
4017
|
+
* HL7 version the model asserts for this message, from MSH-12.1.1, e.g.
|
|
4018
|
+
* `"2.5"` or `"2.5.1"`.
|
|
4019
|
+
*
|
|
4020
|
+
* **Bounded, and it is `"<withheld>"` when MSH-12 does not hold a version.**
|
|
4021
|
+
* Same reasoning as {@link Segment.type}: it presents as an identifier and
|
|
4022
|
+
* consumers label with it. `meta.version` keeps MSH-12 exactly as it
|
|
4023
|
+
* arrived, and is what version-scoped field selection reads, so this bound
|
|
4024
|
+
* changes no parsing behaviour.
|
|
4025
|
+
*/
|
|
3994
4026
|
readonly version: string;
|
|
3995
4027
|
readonly warnings: readonly Hl7ParseWarning[];
|
|
3996
4028
|
readonly profile: {
|
|
@@ -4006,7 +4038,7 @@ declare class Hl7Message {
|
|
|
4006
4038
|
readonly dateFormats: readonly string[];
|
|
4007
4039
|
/**
|
|
4008
4040
|
* Merged `customSegments` map from the applied profile, stored so
|
|
4009
|
-
* `allSegments()` can hand per-segment
|
|
4041
|
+
* `allSegments()` can hand per-segment portions to `Segment` constructors
|
|
4010
4042
|
* (D-16). Undefined when no profile was applied.
|
|
4011
4043
|
* @internal
|
|
4012
4044
|
*/
|
|
@@ -4015,40 +4047,40 @@ declare class Hl7Message {
|
|
|
4015
4047
|
* Lazily built cache of Segment wrappers keyed by segment type. Built on
|
|
4016
4048
|
* first `segments(type)` call and filtered from `_allSegments` so
|
|
4017
4049
|
* individual Segment instances are identical across both caches (D-11).
|
|
4018
|
-
*
|
|
4050
|
+
* The mutation methods drop this cache wholesale.
|
|
4019
4051
|
* @internal
|
|
4020
4052
|
*/
|
|
4021
4053
|
private _segmentsByType;
|
|
4022
4054
|
/**
|
|
4023
4055
|
* Lazily built cache of every Segment wrapper in document order. Built on
|
|
4024
|
-
* first `segments(type)` / `allSegments()` call.
|
|
4056
|
+
* first `segments(type)` / `allSegments()` call. The mutation methods
|
|
4025
4057
|
* drop this cache wholesale.
|
|
4026
4058
|
* @internal
|
|
4027
4059
|
*/
|
|
4028
4060
|
private _allSegments;
|
|
4029
4061
|
/**
|
|
4030
|
-
* Lazily built `Meta` view (
|
|
4062
|
+
* Lazily built `Meta` view (memoized). Dropped wholesale
|
|
4031
4063
|
* by `invalidateCaches`. `Meta` is always defined (D-03: MSH absence
|
|
4032
4064
|
* throws `NO_MSH_SEGMENT` at parse time) so no null-sentinel is needed.
|
|
4033
4065
|
* @internal
|
|
4034
4066
|
*/
|
|
4035
4067
|
private _meta;
|
|
4036
4068
|
/**
|
|
4037
|
-
* Lazily built `MessageStructure` view
|
|
4069
|
+
* Lazily built `MessageStructure` view. Dropped wholesale by
|
|
4038
4070
|
* `invalidateCaches`. Always defined: `analyzeMessageStructure` returns an
|
|
4039
4071
|
* `recognized: false` summary for unmodelled types rather than absence.
|
|
4040
4072
|
* @internal
|
|
4041
4073
|
*/
|
|
4042
4074
|
private _structure;
|
|
4043
4075
|
/**
|
|
4044
|
-
* Lazily built `Patient | undefined` view (
|
|
4076
|
+
* Lazily built `Patient | undefined` view (memoized). Uses
|
|
4045
4077
|
* a null-sentinel cache because `undefined` means "not yet computed" while
|
|
4046
4078
|
* `null` means "computed, absent". D-04: no PID → public value `undefined`.
|
|
4047
4079
|
* @internal
|
|
4048
4080
|
*/
|
|
4049
4081
|
private _patient;
|
|
4050
4082
|
/**
|
|
4051
|
-
* Lazily built `Visit | undefined` view (
|
|
4083
|
+
* Lazily built `Visit | undefined` view (memoized). Same
|
|
4052
4084
|
* null-sentinel convention as `_patient`. HELPERS-03: no PV1 → public
|
|
4053
4085
|
* value `undefined`.
|
|
4054
4086
|
* @internal
|
|
@@ -4064,8 +4096,8 @@ declare class Hl7Message {
|
|
|
4064
4096
|
constructor(init: Hl7MessageInit);
|
|
4065
4097
|
/**
|
|
4066
4098
|
* Resolve a dot-path (e.g. `PID.5.1`, `OBX[2].5`, `PID.3[0].1`) to its
|
|
4067
|
-
* decoded leaf string (unescaped once at parse: never re-unescaped on
|
|
4068
|
-
*
|
|
4099
|
+
* decoded leaf string (unescaped once at parse: never re-unescaped on
|
|
4100
|
+
* read). Returns `undefined` when the path doesn't
|
|
4069
4101
|
* resolve: never throws on missing path (MODEL-05). Throws `TypeError`
|
|
4070
4102
|
* on malformed path syntax (e.g. `"pid.5"`, empty string).
|
|
4071
4103
|
*
|
|
@@ -4096,7 +4128,7 @@ declare class Hl7Message {
|
|
|
4096
4128
|
* Return the cached array of `Segment` wrappers for `segmentType` in
|
|
4097
4129
|
* document order. The returned array identity and the individual Segment
|
|
4098
4130
|
* instances are both stable across calls (D-11). Invalidated wholesale
|
|
4099
|
-
* by
|
|
4131
|
+
* by the mutation methods.
|
|
4100
4132
|
*
|
|
4101
4133
|
* @example
|
|
4102
4134
|
* ```ts
|
|
@@ -4109,7 +4141,7 @@ declare class Hl7Message {
|
|
|
4109
4141
|
* Iterate every `Segment` in document order (MSH first, then every
|
|
4110
4142
|
* subsequent segment). Cached per-message; same array reference and same
|
|
4111
4143
|
* Segment instances on repeat calls (D-11). Invalidated wholesale by
|
|
4112
|
-
*
|
|
4144
|
+
* the mutation methods.
|
|
4113
4145
|
*
|
|
4114
4146
|
* @example
|
|
4115
4147
|
* ```ts
|
|
@@ -4128,14 +4160,14 @@ declare class Hl7Message {
|
|
|
4128
4160
|
* @example
|
|
4129
4161
|
* ```ts
|
|
4130
4162
|
* console.log(msg.meta.type); // "ADT^A01"
|
|
4131
|
-
* console.log(msg.meta.timestamp?.raw); // fidelity TS
|
|
4163
|
+
* console.log(msg.meta.timestamp?.raw); // fidelity TS
|
|
4132
4164
|
* console.log(msg.meta.controlId); // "MSG001"
|
|
4133
4165
|
* ```
|
|
4134
4166
|
*/
|
|
4135
4167
|
get meta(): Meta;
|
|
4136
4168
|
/**
|
|
4137
|
-
* Structural-conformance summary for the common message types
|
|
4138
|
-
*
|
|
4169
|
+
* Structural-conformance summary for the common message types: a
|
|
4170
|
+
* misroute/truncation safety net, NOT a conformance validator.
|
|
4139
4171
|
* Reports, per the message's recognized (MSH-9.1, MSH-9.2) type, which
|
|
4140
4172
|
* Required segment groups are present and which are entirely absent
|
|
4141
4173
|
* (`missingGroups`: the same set the parser flags as
|
|
@@ -4189,7 +4221,7 @@ declare class Hl7Message {
|
|
|
4189
4221
|
observations(): readonly Observation[];
|
|
4190
4222
|
/**
|
|
4191
4223
|
* Every OBR as an Order with its OBX children grouped positionally (D-12) and
|
|
4192
|
-
* its TQ1 / legacy embedded-TQ (ORC-7) `timings` (
|
|
4224
|
+
* its TQ1 / legacy embedded-TQ (ORC-7) `timings` (the repeat pattern is
|
|
4193
4225
|
* surfaced verbatim, never resolved to a schedule). D-05: returns `[]` when no
|
|
4194
4226
|
* OBR present. D-06: not memoized.
|
|
4195
4227
|
*
|
|
@@ -4203,7 +4235,7 @@ declare class Hl7Message {
|
|
|
4203
4235
|
*/
|
|
4204
4236
|
orders(): readonly Order[];
|
|
4205
4237
|
/**
|
|
4206
|
-
* Message-level NTE notes
|
|
4238
|
+
* Message-level NTE notes: every NTE segment with no recognized
|
|
4207
4239
|
* preceding parent (not immediately following a `PID`, `ORC`, `OBR`, or
|
|
4208
4240
|
* `OBX`), surfaced verbatim in document order so nothing is dropped. Notes
|
|
4209
4241
|
* that DO attach to a specific patient / order / result are exposed on those
|
|
@@ -4218,7 +4250,7 @@ declare class Hl7Message {
|
|
|
4218
4250
|
notes(): readonly string[];
|
|
4219
4251
|
/**
|
|
4220
4252
|
* Every recognized ADT patient-identity event (merge / move / link /
|
|
4221
|
-
* unlink / person add/update
|
|
4253
|
+
* unlink / person add/update), with the MRG-sourced
|
|
4222
4254
|
* `prior` and PID/PV1-sourced `surviving` parties labelled by role and the
|
|
4223
4255
|
* spec-constant `direction: "MRG_TO_PID"` on merge/move events. Returns
|
|
4224
4256
|
* `[]` when the trigger event is not in the identity family. D-06: not
|
|
@@ -4237,13 +4269,13 @@ declare class Hl7Message {
|
|
|
4237
4269
|
identityEvents(): readonly IdentityEvent[];
|
|
4238
4270
|
/**
|
|
4239
4271
|
* Every RXO/RXE/RXD/RXA as a typed `Medication`, with RXR (route) and RXC
|
|
4240
|
-
* (component) segments grouped positionally under their parent
|
|
4241
|
-
*
|
|
4242
|
-
*
|
|
4243
|
-
*
|
|
4272
|
+
* (component) segments grouped positionally under their parent. D-05:
|
|
4273
|
+
* returns `[]` when no RX* parent present. D-06: not memoized. The give
|
|
4274
|
+
* *amount* and give *strength* are surfaced separately and never
|
|
4275
|
+
* reconciled.
|
|
4244
4276
|
*
|
|
4245
4277
|
* Each medication also carries its TQ1 / legacy embedded-TQ (RXE-1) `timings`
|
|
4246
|
-
* (
|
|
4278
|
+
* (repeat pattern verbatim, never resolved to a schedule).
|
|
4247
4279
|
*
|
|
4248
4280
|
* @example
|
|
4249
4281
|
* ```ts
|
|
@@ -4258,7 +4290,7 @@ declare class Hl7Message {
|
|
|
4258
4290
|
/**
|
|
4259
4291
|
* Every RXA of a VXU^V04 as a typed `Immunization`, with RXR (route/site)
|
|
4260
4292
|
* and OBX children grouped positionally under the RXA and `orderControl`
|
|
4261
|
-
* from the preceding ORC of the VXU order group
|
|
4293
|
+
* from the preceding ORC of the VXU order group. D-05:
|
|
4262
4294
|
* returns `[]` when no RXA present. D-06: not memoized. The vaccine code
|
|
4263
4295
|
* carries its own provenance; the action code (RXA-21) is surfaced verbatim
|
|
4264
4296
|
* and `recordOrigin` (administered vs historical) is derived only from the
|
|
@@ -4316,7 +4348,7 @@ declare class Hl7Message {
|
|
|
4316
4348
|
*/
|
|
4317
4349
|
insurance(): readonly Insurance[];
|
|
4318
4350
|
/**
|
|
4319
|
-
* Every SCH of an SIU message as a typed `Appointment
|
|
4351
|
+
* Every SCH of an SIU message as a typed `Appointment`, with
|
|
4320
4352
|
* the AIS/AIG/AIL/AIP resource segments that follow it grouped positionally
|
|
4321
4353
|
* under that SCH. Surfaces the placer/filler appointment ids, SCH-25 filler
|
|
4322
4354
|
* status (Table 0278), SCH-11 start/end timing, and the resource groups
|
|
@@ -4334,7 +4366,7 @@ declare class Hl7Message {
|
|
|
4334
4366
|
*/
|
|
4335
4367
|
appointments(): readonly Appointment[];
|
|
4336
4368
|
/**
|
|
4337
|
-
* Every TXA of an MDM message as a typed `ClinicalDocument
|
|
4369
|
+
* Every TXA of an MDM message as a typed `ClinicalDocument`,
|
|
4338
4370
|
* with the OBX narrative body grouped positionally under that TXA. The
|
|
4339
4371
|
* completion status (TXA-17) and availability status (TXA-19) are surfaced as
|
|
4340
4372
|
* **distinct** fields and never conflated: a document can be available before
|
|
@@ -4352,7 +4384,7 @@ declare class Hl7Message {
|
|
|
4352
4384
|
*/
|
|
4353
4385
|
documents(): readonly ClinicalDocument[];
|
|
4354
4386
|
/**
|
|
4355
|
-
* Every FT1 of a DFT message as a typed `Charge
|
|
4387
|
+
* Every FT1 of a DFT message as a typed `Charge`, one per
|
|
4356
4388
|
* FT1 in document order. Surfaces billing-critical fields (FT1-6 transaction
|
|
4357
4389
|
* type, FT1-7 code, FT1-11/12 extended/unit amount, FT1-19 diagnosis linkage)
|
|
4358
4390
|
* with **no billing logic and no money-as-float**: amounts are the verbatim
|
|
@@ -4438,7 +4470,7 @@ declare class Hl7Message {
|
|
|
4438
4470
|
* `TypeError` with an actionable message otherwise).
|
|
4439
4471
|
*
|
|
4440
4472
|
* The value is accepted verbatim: unescaped delimiter characters are NOT
|
|
4441
|
-
* rejected on input (D-18). Re-escaping
|
|
4473
|
+
* rejected on input (D-18). Re-escaping is the serializer's concern.
|
|
4442
4474
|
*
|
|
4443
4475
|
* MSH-1 / MSH-2 follow the user-facing HL7 convention: `setField("MSH.3", ...)`
|
|
4444
4476
|
* targets MSH-3 (sending application), matching `msg.get("MSH.3")`.
|
|
@@ -4455,11 +4487,11 @@ declare class Hl7Message {
|
|
|
4455
4487
|
*/
|
|
4456
4488
|
setField(path: string, value: string): this;
|
|
4457
4489
|
/**
|
|
4458
|
-
* Set a **typed composite** at a field (or field-repetition) dot-path
|
|
4459
|
-
*
|
|
4490
|
+
* Set a **typed composite** at a field (or field-repetition) dot-path:
|
|
4491
|
+
* the conservative-emit mirror of the typed read accessors
|
|
4460
4492
|
* (`asXpn`/`asCx`/…). The caller passes a structured value (an XPN name, a CX
|
|
4461
4493
|
* identifier, a TS timestamp, …) by its {@link CompositeKind}, and the setter
|
|
4462
|
-
* encodes it into a spec-clean field using the
|
|
4494
|
+
* encodes it into a spec-clean field using the encode-safe path: any
|
|
4463
4495
|
* delimiter embedded in a component value is **escaped, never injected**, so
|
|
4464
4496
|
* a `familyName` of `"Smith^Jr"` re-parses to exactly that string rather than
|
|
4465
4497
|
* forging a component boundary. No hand-assembly of `^`/`&`/`~`.
|
|
@@ -4533,8 +4565,8 @@ declare class Hl7Message {
|
|
|
4533
4565
|
readonly all?: boolean;
|
|
4534
4566
|
}): this;
|
|
4535
4567
|
/**
|
|
4536
|
-
* Drop every wrapper AND helper cache wholesale (
|
|
4537
|
-
*
|
|
4568
|
+
* Drop every wrapper AND helper cache wholesale (D-17 + D-02). Called by
|
|
4569
|
+
* every mutation method so subsequent `segments(type)` /
|
|
4538
4570
|
* `allSegments()` / `meta` / `patient` / `visit` reads rebuild from the
|
|
4539
4571
|
* mutated `rawSegments` tree.
|
|
4540
4572
|
* @internal
|
|
@@ -4594,9 +4626,8 @@ declare function parseHL7(raw: string | Buffer, options: ParseOptions): Hl7Messa
|
|
|
4594
4626
|
* severe is a Tier-2 warning (see `./warnings.ts`). `Hl7ParseError` is
|
|
4595
4627
|
* thrown directly; consumers narrow via the `code` discriminant.
|
|
4596
4628
|
*
|
|
4597
|
-
* `ProfileDefinitionError` is declared here so the error taxonomy
|
|
4598
|
-
*
|
|
4599
|
-
* across phases.
|
|
4629
|
+
* `ProfileDefinitionError` is declared here so the whole error taxonomy
|
|
4630
|
+
* lives in one module.
|
|
4600
4631
|
*/
|
|
4601
4632
|
|
|
4602
4633
|
/**
|
|
@@ -4653,9 +4684,31 @@ type FatalCode = (typeof FATAL_CODES)[keyof typeof FATAL_CODES];
|
|
|
4653
4684
|
* snippet of the offending input so consumers can log actionable errors.
|
|
4654
4685
|
*
|
|
4655
4686
|
* @remarks
|
|
4656
|
-
*
|
|
4657
|
-
* the call site if required by your
|
|
4658
|
-
*
|
|
4687
|
+
* `snippet` may contain PHI when parsing real clinical messages, and the
|
|
4688
|
+
* library does not redact it: redact at the call site if required by your
|
|
4689
|
+
* compliance posture. **It is the only field carrying input verbatim and
|
|
4690
|
+
* unfiltered** (capped at 40 characters plus an ellipsis, but not shape-checked
|
|
4691
|
+
* in any way), so it is the one to redact first.
|
|
4692
|
+
*
|
|
4693
|
+
* `message` is bounded but not absolutely content-free, and the difference is
|
|
4694
|
+
* worth stating because `message` is what a logger prints by default and what
|
|
4695
|
+
* `stack` embeds. A token lifted from the input is echoed only when it matches
|
|
4696
|
+
* the form the spec defines for it: a three-character segment identifier, an
|
|
4697
|
+
* MSH-9 type, an MSH-12 version, or a charset label the closed Table 0211
|
|
4698
|
+
* actually contains. Anything else becomes `<withheld>`. So a message cannot
|
|
4699
|
+
* carry a field's value, but it can carry a residue of up to three characters
|
|
4700
|
+
* when a malformed line happens to look like a segment identifier. The other
|
|
4701
|
+
* shapes are narrower in practice than their patterns allow, because the
|
|
4702
|
+
* library only ever feeds them registry-matched values, but the patterns
|
|
4703
|
+
* themselves admit more (a message type up to 26 characters, a version up to
|
|
4704
|
+
* 14), which matters if you construct warnings yourself.
|
|
4705
|
+
*
|
|
4706
|
+
* Under `{ strict: true }` an escalated Tier-2 warning is thrown as this
|
|
4707
|
+
* error, carrying the warning's own bounded message and a `snippet` of the
|
|
4708
|
+
* **first 40 characters of the input**. That snippet is the head of the
|
|
4709
|
+
* message rather than the deviation's own segment, so it is usually the MSH
|
|
4710
|
+
* header; it is deliberately not re-pointed at the offending segment, since
|
|
4711
|
+
* doing so would move more clinical content into the unredacted field.
|
|
4659
4712
|
*
|
|
4660
4713
|
* @example
|
|
4661
4714
|
* ```ts
|
|
@@ -4682,12 +4735,11 @@ declare class Hl7ParseError extends Error {
|
|
|
4682
4735
|
constructor(code: FatalCode, message: string, position: Hl7Position, snippet: string);
|
|
4683
4736
|
}
|
|
4684
4737
|
/**
|
|
4685
|
-
* Thrown by `defineProfile()` and profile-validation code
|
|
4738
|
+
* Thrown by `defineProfile()` and profile-validation code when a
|
|
4686
4739
|
* profile definition is structurally invalid: e.g. references an undefined
|
|
4687
4740
|
* parent, declares a malformed custom segment, or includes an unsupported
|
|
4688
|
-
* date format.
|
|
4689
|
-
*
|
|
4690
|
-
* for better diagnostics.
|
|
4741
|
+
* date format. Callers may optionally supply the offending profile name for
|
|
4742
|
+
* better diagnostics.
|
|
4691
4743
|
*
|
|
4692
4744
|
* @example
|
|
4693
4745
|
* ```ts
|
|
@@ -4702,7 +4754,7 @@ declare class ProfileDefinitionError extends Error {
|
|
|
4702
4754
|
readonly profileName: string | undefined;
|
|
4703
4755
|
/**
|
|
4704
4756
|
* Construct a new `ProfileDefinitionError`. `profileName` is optional so
|
|
4705
|
-
*
|
|
4757
|
+
* callers may omit it when the offending profile cannot be named
|
|
4706
4758
|
* (e.g. during initial validation before a name is parsed).
|
|
4707
4759
|
*
|
|
4708
4760
|
* @internal
|
|
@@ -4712,12 +4764,12 @@ declare class ProfileDefinitionError extends Error {
|
|
|
4712
4764
|
|
|
4713
4765
|
/**
|
|
4714
4766
|
* HL7 v2 **Table 0211 (Alternate Character Sets)** resolution for the parser's
|
|
4715
|
-
* `Buffer`-decode stage
|
|
4767
|
+
* `Buffer`-decode stage. Mirrors the frozen read-only registries
|
|
4716
4768
|
* `KNOWN_SEGMENTS` / `KNOWN_CODING_SYSTEMS`: a single source of truth mapping an
|
|
4717
4769
|
* MSH-18 character-set code to how the parser treats it: **decode** (single-byte
|
|
4718
4770
|
* ISO-8859 family + Unicode UTF-8) or **preserve-verbatim** (the multibyte /
|
|
4719
4771
|
* ISO-2022-switched East-Asian sets and UTF-16/32, which HL7 renders through
|
|
4720
|
-
* stateful `\Mxxyyzz\` escapes
|
|
4772
|
+
* stateful `\Mxxyyzz\` escapes the parser deliberately does not fully decode).
|
|
4721
4773
|
*
|
|
4722
4774
|
* Spec traceability: HL7 v2 Chapter 2, **MSH-18** (item 00692) + **Table 0211**
|
|
4723
4775
|
* (OID 2.16.840.1.113883.18.116). MSH-18 is **repeating**: the first occurrence
|
|
@@ -4928,7 +4980,7 @@ declare function reescape(input: string, enc: EncodingCharacters): string;
|
|
|
4928
4980
|
* escapes preserved verbatim), with no warning plumbing to wire up.
|
|
4929
4981
|
* - {@link encodeText} is the **encode-safe** direction: an arbitrary string in,
|
|
4930
4982
|
* a spec-clean field body out that can **never inject a delimiter or forge a
|
|
4931
|
-
* component boundary**. This is the primitive
|
|
4983
|
+
* component boundary**. This is the primitive the typed emit path builds on.
|
|
4932
4984
|
*
|
|
4933
4985
|
* For a human-readable rendering (formatting commands → whitespace, highlight
|
|
4934
4986
|
* dropped), use {@link renderText} instead of {@link decodeText}.
|
|
@@ -5005,7 +5057,7 @@ declare function encodeText(input: string, enc?: EncodingCharacters): string;
|
|
|
5005
5057
|
*
|
|
5006
5058
|
* - `text.decode(field.text)`: resolve delimiter/hex/`\.br\` escapes to a value;
|
|
5007
5059
|
* - `text.render(field.text)`: normalize formatting + highlight to a display model;
|
|
5008
|
-
* - `text.encode(anyString)`: encode-safe: no delimiter injection
|
|
5060
|
+
* - `text.encode(anyString)`: encode-safe: no delimiter injection.
|
|
5009
5061
|
*
|
|
5010
5062
|
* ```ts
|
|
5011
5063
|
* import { text } from "@cosyte/hl7";
|
|
@@ -5029,17 +5081,17 @@ declare namespace index$1 {
|
|
|
5029
5081
|
* `undefined` on missing path). Zero runtime deps: a hand-rolled linear scan
|
|
5030
5082
|
* (analog: `src/parser/dates.ts::matchTokenFormat`).
|
|
5031
5083
|
*
|
|
5032
|
-
* Indexing conventions
|
|
5084
|
+
* Indexing conventions:
|
|
5033
5085
|
* - `[N]` is ALWAYS 0-indexed: applies to segment repeats AND field repeats (D-01).
|
|
5034
|
-
* - Dot-numbers are ALWAYS 1-indexed: matches HL7 spec and
|
|
5086
|
+
* - Dot-numbers are ALWAYS 1-indexed: matches HL7 spec and the 1-indexed
|
|
5035
5087
|
* `RawSegment.fields` (D-02). `PID.5` → `fields[5]`.
|
|
5036
5088
|
* - MSH.1 / MSH.2 are the separator char and encoding-chars string, both
|
|
5037
|
-
* stored at `fields[0]` / `fields[1]` by
|
|
5089
|
+
* stored at `fields[0]` / `fields[1]` by tokenize.ts (D-05).
|
|
5038
5090
|
* - Missing subcomponent on a single-sub component returns the component
|
|
5039
5091
|
* string (depth-collapse, D-04).
|
|
5040
5092
|
* - Leaf reads return the subcomponent verbatim: the tokenizer (parser-02)
|
|
5041
5093
|
* already unescaped it once on parse, so the stored value is decoded and a
|
|
5042
|
-
* second `unescape` here would double-decode it
|
|
5094
|
+
* second `unescape` here would double-decode it.
|
|
5043
5095
|
*/
|
|
5044
5096
|
|
|
5045
5097
|
/**
|
|
@@ -5134,7 +5186,7 @@ declare namespace namespace {
|
|
|
5134
5186
|
|
|
5135
5187
|
/**
|
|
5136
5188
|
* `pickMrn`: pick the Medical Record Number string from a PID-3 identifier
|
|
5137
|
-
* list. Isolated from `patient.ts` so
|
|
5189
|
+
* list. Isolated from `patient.ts` so a profile hook can substitute
|
|
5138
5190
|
* a profile-aware variant without patching the helper that calls it.
|
|
5139
5191
|
*
|
|
5140
5192
|
* Silent (D-21: helpers emit no warnings). Never throws (D-22).
|
|
@@ -5177,12 +5229,11 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5177
5229
|
* `buildMessage`: top-level outbound factory for the `@cosyte/hl7`
|
|
5178
5230
|
* package. Synthesizes a complete MSH `RawSegment` from `BuildMessageInit`
|
|
5179
5231
|
* and returns a real `Hl7Message` (not a builder subtype). Callers chain
|
|
5180
|
-
* `.addSegment(...)` (
|
|
5232
|
+
* `.addSegment(...)` (mutation method) to append PID,
|
|
5181
5233
|
* OBX, etc. Symmetric with `parseHL7` (D-09).
|
|
5182
5234
|
*
|
|
5183
|
-
*
|
|
5184
|
-
*
|
|
5185
|
-
* `buildMessage` function body is filled in Phase 5 Plan 05 (build-message).
|
|
5235
|
+
* `BuildMessageInit` is exported from this module and re-exported from
|
|
5236
|
+
* `src/index.ts`, so consumers can reference the type directly.
|
|
5186
5237
|
*
|
|
5187
5238
|
* Decisions:
|
|
5188
5239
|
* - D-09: top-level named export from `src/index.ts`.
|
|
@@ -5193,8 +5244,8 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5193
5244
|
* - D-13: `timestamp` accepts `Date | string`; `Date` formats to
|
|
5194
5245
|
* `YYYYMMDDHHmmss` UTC.
|
|
5195
5246
|
* - D-14: encoding chars always `DEFAULT_ENCODING_CHARACTERS`.
|
|
5196
|
-
* - D-15: subsequent `.addSegment(name, fields)`
|
|
5197
|
-
*
|
|
5247
|
+
* - D-15: subsequent `.addSegment(name, fields)` takes `readonly string[]`
|
|
5248
|
+
* field input.
|
|
5198
5249
|
* - D-16: missing/empty `type` throws `TypeError`.
|
|
5199
5250
|
*
|
|
5200
5251
|
* **Absent vs. explicit null at the wire level:** at the HL7 wire level,
|
|
@@ -5202,7 +5253,7 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5202
5253
|
* (both emit as absent: `||` in the line). If you need to distinguish
|
|
5203
5254
|
* "explicitly null" (HL7 `""`) from "absent" in an outbound message, use
|
|
5204
5255
|
* `buildMessage({...}).setField(path, '""')` after construction: the
|
|
5205
|
-
*
|
|
5256
|
+
* `setField` mutation method sets `RawField.isNull = true`, which
|
|
5206
5257
|
* the emitter preserves as the literal two-char string `""` per D-02.
|
|
5207
5258
|
*/
|
|
5208
5259
|
|
|
@@ -5216,7 +5267,7 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5216
5267
|
* empty string produce IDENTICAL wire output (both emit as an absent
|
|
5217
5268
|
* positional field). To emit an HL7 explicit null (`""`) at a specific
|
|
5218
5269
|
* position in an outbound message, build the message first and then call
|
|
5219
|
-
* `.setField(path, '""')`: the
|
|
5270
|
+
* `.setField(path, '""')`: the mutation method sets `isNull=true`
|
|
5220
5271
|
* on the underlying `RawField`, and the emitter preserves that as the
|
|
5221
5272
|
* literal two-char output per D-02.
|
|
5222
5273
|
*
|
|
@@ -5276,7 +5327,7 @@ interface BuildMessageInit {
|
|
|
5276
5327
|
* Construct an outbound `Hl7Message` from semantic MSH fields (SER-06).
|
|
5277
5328
|
* Synthesises a complete MSH `RawSegment` per D-10/D-11 and hands to
|
|
5278
5329
|
* `new Hl7Message({...})`. Callers chain `.addSegment(name, fields)`
|
|
5279
|
-
* (
|
|
5330
|
+
* (mutation method) to append PID, OBX, etc.
|
|
5280
5331
|
*
|
|
5281
5332
|
* Defaults applied when fields are omitted (D-10):
|
|
5282
5333
|
* - `controlId` → `generateControlId()` (D-12)
|
|
@@ -5300,9 +5351,7 @@ interface BuildMessageInit {
|
|
|
5300
5351
|
* // msg.toString() now emits MSH-3 as `""` (2 chars), not as absent.
|
|
5301
5352
|
* ```
|
|
5302
5353
|
*
|
|
5303
|
-
*
|
|
5304
|
-
* the input shape; this function-level doc reinforces it for developers
|
|
5305
|
-
* who land on the impl.
|
|
5354
|
+
* `BuildMessageInit` carries the same note on the input shape.
|
|
5306
5355
|
*
|
|
5307
5356
|
* @example
|
|
5308
5357
|
* ```ts
|
|
@@ -5324,7 +5373,7 @@ declare function buildMessage(init: BuildMessageInit): Hl7Message;
|
|
|
5324
5373
|
|
|
5325
5374
|
/**
|
|
5326
5375
|
* Shared field/segment assembly primitives for the typed builders
|
|
5327
|
-
* (`buildAdt`/`buildOru
|
|
5376
|
+
* (`buildAdt`/`buildOru`). Centralises the MSH synthesis and
|
|
5328
5377
|
* the sparse positional-segment assembly so each builder stays declarative and
|
|
5329
5378
|
* every builder emits an identical, spec-clean MSH.
|
|
5330
5379
|
*
|
|
@@ -5356,11 +5405,11 @@ interface MessageEnvelope {
|
|
|
5356
5405
|
|
|
5357
5406
|
/**
|
|
5358
5407
|
* `buildAdt`: author a spec-clean HL7 v2 **ADT** (admit/discharge/transfer)
|
|
5359
|
-
* message from typed inputs
|
|
5408
|
+
* message from typed inputs. The conservative-emit mirror of
|
|
5360
5409
|
* the read helpers (`msg.patient`, `msg.visit`): a caller supplies structured
|
|
5361
5410
|
* values (an {@link XPN} name, {@link CX} identifiers, a {@link TS} birth date,
|
|
5362
5411
|
* a {@link PL} location, …) and `buildAdt` assembles `MSH + EVN + PID + PV1`
|
|
5363
|
-
* with correct `^`/`&`/`~` structure via the
|
|
5412
|
+
* with correct `^`/`&`/`~` structure via the encode-safe path: never
|
|
5364
5413
|
* hand-assembling delimiters, never injecting one.
|
|
5365
5414
|
*
|
|
5366
5415
|
* **Structurally complete + zero-warning.** The emitted message carries the
|
|
@@ -5467,11 +5516,11 @@ declare function buildAdt(event: string, init: BuildAdtInit): Hl7Message;
|
|
|
5467
5516
|
|
|
5468
5517
|
/**
|
|
5469
5518
|
* `buildOru`: author a spec-clean HL7 v2 **ORU^R01** (observation result)
|
|
5470
|
-
* message from typed inputs
|
|
5519
|
+
* message from typed inputs. The conservative-emit mirror of
|
|
5471
5520
|
* the read helpers (`msg.orders`, `msg.observations`): a caller supplies a
|
|
5472
5521
|
* typed patient, an optional order (OBR), and one or more typed observations
|
|
5473
5522
|
* (OBX), and `buildOru` assembles `MSH + PID + OBR + OBX…` with correct
|
|
5474
|
-
* `^`/`&`/`~` structure via the
|
|
5523
|
+
* `^`/`&`/`~` structure via the encode-safe path.
|
|
5475
5524
|
*
|
|
5476
5525
|
* **Structurally complete + zero-warning.** The emitted message carries the
|
|
5477
5526
|
* ORU^R01 result group the parser's structure net marks Required (OBR/OBX), so
|
|
@@ -5573,7 +5622,7 @@ interface BuildOruInit extends MessageEnvelope {
|
|
|
5573
5622
|
declare function buildOru(init: BuildOruInit): Hl7Message;
|
|
5574
5623
|
|
|
5575
5624
|
/**
|
|
5576
|
-
* Frozen HL7 control-vocabulary tables for ACK generation
|
|
5625
|
+
* Frozen HL7 control-vocabulary tables for ACK generation. These
|
|
5577
5626
|
* are read-only enums sourced from the HL7 v2 standard: `@cosyte/hl7` is the
|
|
5578
5627
|
* single owner of this vocabulary; siblings (notably `@cosyte/mllp`) consume
|
|
5579
5628
|
* `buildAck` rather than re-declaring these codes.
|
|
@@ -5711,7 +5760,7 @@ type AckMode = "original" | "enhanced";
|
|
|
5711
5760
|
|
|
5712
5761
|
/**
|
|
5713
5762
|
* `buildAck`: generate a spec-clean HL7 v2 acknowledgment (ACK) message from
|
|
5714
|
-
* an inbound message
|
|
5763
|
+
* an inbound message. The boundary with `@cosyte/mllp` is resolved
|
|
5715
5764
|
* (hl7 roadmap §10.1): **hl7 owns ACK *content*** (this file + the control
|
|
5716
5765
|
* tables); mllp owns *policy/timing* (the commit contract) and *framing*.
|
|
5717
5766
|
*
|
|
@@ -5814,7 +5863,7 @@ declare function detectAckMode(inbound: Hl7Message): AckMode;
|
|
|
5814
5863
|
* - **MSA**: MSA-1 = `code`; **MSA-2 echoes the full inbound MSH-10 field**
|
|
5815
5864
|
* (the raw field structure is carried over whole: a vendor-quirk id like
|
|
5816
5865
|
* `ID^X` is never truncated to its first component). The echo carries the
|
|
5817
|
-
* inbound field's escape-fidelity overlay
|
|
5866
|
+
* inbound field's escape-fidelity overlay, so an id bearing a hex
|
|
5818
5867
|
* escape (`ID\X41\Q`) or a preserved escape (`\H\`) echoes **byte-verbatim**,
|
|
5819
5868
|
* not canonicalized: exactly the bytes the sender put on the wire, which is
|
|
5820
5869
|
* what MSA-2 correlation compares. The only structural transform is
|
|
@@ -5829,7 +5878,7 @@ declare function detectAckMode(inbound: Hl7Message): AckMode;
|
|
|
5829
5878
|
* (when given), ERR-3 the Table 0357 condition code as a CWE
|
|
5830
5879
|
* (`code^text^HL70357`), ERR-4 the Table 0516 severity.
|
|
5831
5880
|
*
|
|
5832
|
-
* **Fail-safe
|
|
5881
|
+
* **Fail-safe.** If the inbound message has no MSH-10, the
|
|
5833
5882
|
* ACK cannot be correlated. `buildAck` then leaves MSA-2 empty and, if a
|
|
5834
5883
|
* positive accept (`AA`/`CA`) was requested, **downgrades it** to the matching
|
|
5835
5884
|
* error code (`AE`/`CE`): it never fabricates an unverifiable positive ACK.
|
|
@@ -5852,8 +5901,8 @@ declare function buildAck(inbound: Hl7Message, options: BuildAckOptions): Hl7Mes
|
|
|
5852
5901
|
|
|
5853
5902
|
/**
|
|
5854
5903
|
* `interpretAck`: read-side helper that interprets an inbound HL7 v2
|
|
5855
|
-
* acknowledgment (ACK) message into a typed {@link Acknowledgment} view
|
|
5856
|
-
*
|
|
5904
|
+
* acknowledgment (ACK) message into a typed {@link Acknowledgment} view.
|
|
5905
|
+
* The mechanical inverse of `buildAck`: it reads MSA-1 (code),
|
|
5857
5906
|
* MSA-2 (the correlated control id), and every ERR segment.
|
|
5858
5907
|
*
|
|
5859
5908
|
* Fail-safe: an absent or unrecognized MSA-1 yields `accepted: false`: the
|
|
@@ -5938,10 +5987,9 @@ declare function interpretAck(msg: Hl7Message): Acknowledgment;
|
|
|
5938
5987
|
* `defineProfile()`: public factory for building `Profile` objects with
|
|
5939
5988
|
* validation + `describe()` attached (PROF-01, PROF-04, PROF-05).
|
|
5940
5989
|
*
|
|
5941
|
-
*
|
|
5942
|
-
*
|
|
5943
|
-
*
|
|
5944
|
-
* IGNORED, resulting in `lineage === [opts.name]` regardless.
|
|
5990
|
+
* `opts.extends` is honoured: parents are merged into the returned
|
|
5991
|
+
* profile (lineage, `dateFormats`, `customSegments`, `description` and
|
|
5992
|
+
* `onWarning`), and the merged result is re-validated before it is frozen.
|
|
5945
5993
|
*
|
|
5946
5994
|
* Zero runtime deps. Matches CLAUDE.md engineering guardrails: no `any`,
|
|
5947
5995
|
* JSDoc `@example` on every public export, immutability at the return
|
|
@@ -5985,10 +6033,11 @@ interface DefineProfileOptions {
|
|
|
5985
6033
|
* unknown top-level keys with typo hints (D-07), and missing/empty
|
|
5986
6034
|
* name.
|
|
5987
6035
|
*
|
|
5988
|
-
*
|
|
5989
|
-
*
|
|
5990
|
-
*
|
|
5991
|
-
*
|
|
6036
|
+
* `opts.extends` accepts a single parent `Profile` or an array of them.
|
|
6037
|
+
* Parents are merged into the result: `lineage` is the parents' lineages
|
|
6038
|
+
* followed by this profile's own name, `dateFormats` and `customSegments`
|
|
6039
|
+
* are merged, `description` inherits when not supplied, and `onWarning`
|
|
6040
|
+
* handlers are composed. With no parent, `lineage === [opts.name]`.
|
|
5992
6041
|
*
|
|
5993
6042
|
* @example
|
|
5994
6043
|
* ```ts
|
|
@@ -6197,8 +6246,8 @@ declare const genericLab: Profile;
|
|
|
6197
6246
|
* Z-segments: `ZF1` (provider-encounter copay data) and `ZF2`
|
|
6198
6247
|
* (encounter-procedure data). BIP-03.
|
|
6199
6248
|
*
|
|
6200
|
-
* Grounded in **publicly downloadable** MEDITECH interface specifications
|
|
6201
|
-
*
|
|
6249
|
+
* Grounded in **publicly downloadable** MEDITECH interface specifications,
|
|
6250
|
+
* not invented:
|
|
6202
6251
|
*
|
|
6203
6252
|
* - The **minute-precision** date/time format is confirmed by *two*
|
|
6204
6253
|
* public MEDITECH specs: "MEDITECH Admissions and Registration to Other
|
|
@@ -6220,10 +6269,8 @@ declare const genericLab: Profile;
|
|
|
6220
6269
|
* ZF2-5 ENCOUNTER PROCEDURE QUANTITY, ZF2-6 ENCOUNTER PROCEDURE CHARGE,
|
|
6221
6270
|
* ZF2-7 PRV PROCEDURE AMOUNT PAID, ZF2-8 PRV PROCEDURE AMOUNT DUE).
|
|
6222
6271
|
*
|
|
6223
|
-
* (
|
|
6224
|
-
*
|
|
6225
|
-
* re-grounding, ADR 0018. Field positions here are transcribed directly
|
|
6226
|
-
* from the spec's segment tables.)
|
|
6272
|
+
* (Field positions above are transcribed directly from the spec's segment
|
|
6273
|
+
* tables.)
|
|
6227
6274
|
*
|
|
6228
6275
|
* Authored from the public `defineProfile()` API: zero privileged
|
|
6229
6276
|
* internal coupling. Consumers extend this profile via
|
|
@@ -6271,7 +6318,7 @@ declare const meditech: Profile;
|
|
|
6271
6318
|
*
|
|
6272
6319
|
* Grounded in the public **Vue PACS 12.2.8 HL7 Interface Specifications**
|
|
6273
6320
|
* (Philips, document HA1669 Rev A), §§5.11–5.16: a publicly downloadable
|
|
6274
|
-
* vendor interface spec, not an invented quirk
|
|
6321
|
+
* vendor interface spec, not an invented quirk. The spec's
|
|
6275
6322
|
* `TS` timestamps are the HL7-native `YYYYMMDDHHMMSS` form (§2.6), so this
|
|
6276
6323
|
* profile declares **no** custom `dateFormats`: only the Z-segments.
|
|
6277
6324
|
*
|
|
@@ -6332,7 +6379,7 @@ declare const philips: Profile;
|
|
|
6332
6379
|
* and ORM" with `ZDS-1` = Study Instance UID (`RP`: 1.1 Pointer, 1.2
|
|
6333
6380
|
* Application ID, 1.3 Type of Data, 1.4 Subtype). It is a publicly
|
|
6334
6381
|
* downloadable federal interface spec on the VA VistA Documentation Library
|
|
6335
|
-
* (`va.gov/vdl`), not an invented quirk
|
|
6382
|
+
* (`va.gov/vdl`), not an invented quirk. The spec's messaging is
|
|
6336
6383
|
* HL7-native v2.4, so its `TS` timestamps use the `YYYYMMDDHHMMSS` form: this
|
|
6337
6384
|
* profile therefore declares **no** custom `dateFormats`, only the ZDS
|
|
6338
6385
|
* segment.
|
|
@@ -6372,7 +6419,7 @@ declare const va: Profile;
|
|
|
6372
6419
|
* (V23.00, Jun 2026, Visage Imaging GmbH), §4.4 "ORM Messages" + the ZDS
|
|
6373
6420
|
* segment table ("Study Instance UID … contained in the first component of
|
|
6374
6421
|
* the first field of the ZDS Segment"): a publicly downloadable vendor
|
|
6375
|
-
* interface spec, not an invented quirk
|
|
6422
|
+
* interface spec, not an invented quirk. Dates in that spec use
|
|
6376
6423
|
* the HL7-native `YYYYMMDDHHMMSS` form, so this profile declares **no**
|
|
6377
6424
|
* custom `dateFormats`: only the ZDS segment.
|
|
6378
6425
|
*
|
|
@@ -6463,7 +6510,7 @@ declare const profiles: {
|
|
|
6463
6510
|
declare const KNOWN_SEGMENTS: ReadonlySet<string>;
|
|
6464
6511
|
|
|
6465
6512
|
/**
|
|
6466
|
-
* Coding-system provenance (HL7 Table 0396, READ-ONLY)
|
|
6513
|
+
* Coding-system provenance (HL7 Table 0396, READ-ONLY).
|
|
6467
6514
|
*
|
|
6468
6515
|
* Answers one question about a coded element: **"what coding system does this
|
|
6469
6516
|
* code CLAIM?"** It surfaces the sender's CWE.3 / CE.3 "Name of Coding System"
|
|
@@ -6606,8 +6653,8 @@ declare function codingSystemOf(coded: CodedSystemFields): CodingSystemInfo | un
|
|
|
6606
6653
|
declare function alternateCodingSystemOf(coded: CodedSystemFields): CodingSystemInfo | undefined;
|
|
6607
6654
|
|
|
6608
6655
|
/**
|
|
6609
|
-
* Batch / file envelope splitting for the `@cosyte/hl7` parser
|
|
6610
|
-
*
|
|
6656
|
+
* Batch / file envelope splitting for the `@cosyte/hl7` parser. Real lab /
|
|
6657
|
+
* ELR / IIS feeds ship many messages wrapped in the HL7
|
|
6611
6658
|
* v2 batch protocol envelope (Ch. 2 §2.10.3):
|
|
6612
6659
|
*
|
|
6613
6660
|
* ```
|
|
@@ -6651,8 +6698,8 @@ type BatchEnvelopeName = "FHS" | "BHS" | "BTS" | "FTS";
|
|
|
6651
6698
|
* A raw batch-envelope segment (`FHS`/`BHS`/`BTS`/`FTS`) surfaced by
|
|
6652
6699
|
* {@link splitBatch}. `fields` is the segment split on its own field separator
|
|
6653
6700
|
* with `fields[0]` holding the segment name: deliberately the raw token
|
|
6654
|
-
* array, not a typed model:
|
|
6655
|
-
*
|
|
6701
|
+
* array, not a typed model: typed FHS/BHS field helpers beyond the raw
|
|
6702
|
+
* fields are not part of this surface. Note the
|
|
6656
6703
|
* HL7 MSH-family indexing quirk: for `FHS`/`BHS`, `fields[1]` is the
|
|
6657
6704
|
* encoding-characters field (FHS-2/BHS-2); for `BTS`/`FTS`, `fields[1]` is
|
|
6658
6705
|
* field 1 (BTS-1 batch message count / FTS-1 file batch count).
|
|
@@ -6815,7 +6862,7 @@ declare function splitBatch(raw: string | Buffer, profile: Profile): BatchSplitR
|
|
|
6815
6862
|
declare function splitBatch(raw: string | Buffer, options: ParseOptions): BatchSplitResult;
|
|
6816
6863
|
|
|
6817
6864
|
/**
|
|
6818
|
-
* Public types for the conformance-profile engine
|
|
6865
|
+
* Public types for the conformance-profile engine. A
|
|
6819
6866
|
* **consumer authors** a declarative {@link ConformanceProfile}: a bounded
|
|
6820
6867
|
* subset of the HL7 v2 Message-Profile / NIST-IGAMT model (usage codes,
|
|
6821
6868
|
* cardinality, length, value-set binding against a consumer-supplied code
|
|
@@ -6901,7 +6948,7 @@ interface Cardinality {
|
|
|
6901
6948
|
readonly max?: number | "*";
|
|
6902
6949
|
}
|
|
6903
6950
|
/**
|
|
6904
|
-
* A rule for one **field position** within a segment
|
|
6951
|
+
* A rule for one **field position** within a segment. Every
|
|
6905
6952
|
* constraint is optional; a rule with only a `field` index is a no-op.
|
|
6906
6953
|
*
|
|
6907
6954
|
* @remarks
|
|
@@ -6947,7 +6994,7 @@ interface FieldRule {
|
|
|
6947
6994
|
readonly severity?: FindingSeverity;
|
|
6948
6995
|
}
|
|
6949
6996
|
/**
|
|
6950
|
-
* A rule for one **segment type
|
|
6997
|
+
* A rule for one **segment type**. `usage` constrains whether
|
|
6951
6998
|
* the segment must / must not appear; `cardinality` constrains how many times;
|
|
6952
6999
|
* `fields` are the per-field rules, applied to **every** occurrence of the
|
|
6953
7000
|
* segment.
|
|
@@ -6969,7 +7016,7 @@ interface SegmentRule {
|
|
|
6969
7016
|
readonly severity?: FindingSeverity;
|
|
6970
7017
|
}
|
|
6971
7018
|
/**
|
|
6972
|
-
* A **user-authored, declarative** conformance profile
|
|
7019
|
+
* A **user-authored, declarative** conformance profile. The
|
|
6973
7020
|
* consumer supplies this; hl7 ships none. It is a bounded subset of the HL7 v2
|
|
6974
7021
|
* Message-Profile model: usage / cardinality / length / consumer-supplied
|
|
6975
7022
|
* value set: with **no** conditional-predicate language, **no** bundled code
|
|
@@ -7101,7 +7148,7 @@ interface ConformanceResult {
|
|
|
7101
7148
|
}
|
|
7102
7149
|
|
|
7103
7150
|
/**
|
|
7104
|
-
* The conformance-profile engine
|
|
7151
|
+
* The conformance-profile engine: `validateAgainstProfile`.
|
|
7105
7152
|
* Runs a **consumer-authored** declarative {@link ConformanceProfile} against a
|
|
7106
7153
|
* parsed {@link Hl7Message} and returns typed {@link ConformanceFinding}s.
|
|
7107
7154
|
*
|
|
@@ -7123,7 +7170,7 @@ interface ConformanceResult {
|
|
|
7123
7170
|
|
|
7124
7171
|
/**
|
|
7125
7172
|
* Validate a parsed HL7 v2 message against a **user-authored** declarative
|
|
7126
|
-
* conformance profile
|
|
7173
|
+
* conformance profile and return typed findings.
|
|
7127
7174
|
*
|
|
7128
7175
|
* **Never throws.** A well-formed profile is evaluated rule by rule; a
|
|
7129
7176
|
* malformed profile is reported as `PROFILE_MALFORMED` findings (the engine
|
|
@@ -7167,7 +7214,7 @@ interface ConformanceResult {
|
|
|
7167
7214
|
declare function validateAgainstProfile(message: Hl7Message, profile: ConformanceProfile): ConformanceResult;
|
|
7168
7215
|
|
|
7169
7216
|
/**
|
|
7170
|
-
* Profile-shape validation for the conformance engine
|
|
7217
|
+
* Profile-shape validation for the conformance engine. A
|
|
7171
7218
|
* conformance profile is **consumer-authored configuration**, so it can be
|
|
7172
7219
|
* malformed. Two entry points share one total defect collector:
|
|
7173
7220
|
*
|
|
@@ -7209,9 +7256,9 @@ interface ProfileDefect {
|
|
|
7209
7256
|
*/
|
|
7210
7257
|
declare function collectProfileDefects(profile: unknown): readonly ProfileDefect[];
|
|
7211
7258
|
/**
|
|
7212
|
-
* The **fail-fast authoring** gate for a conformance profile
|
|
7213
|
-
*
|
|
7214
|
-
* validation
|
|
7259
|
+
* The **fail-fast authoring** gate for a conformance profile: a malformed
|
|
7260
|
+
* profile raises a typed `ProfileDefinitionError` at build time, before any
|
|
7261
|
+
* validation runs. Runs {@link collectProfileDefects}; on any defect, throws a
|
|
7215
7262
|
* single {@link ProfileDefinitionError} listing every defect. On success,
|
|
7216
7263
|
* returns the profile typed as {@link ConformanceProfile}.
|
|
7217
7264
|
*
|
|
@@ -7236,7 +7283,7 @@ declare function collectProfileDefects(profile: unknown): readonly ProfileDefect
|
|
|
7236
7283
|
declare function defineConformanceProfile(profile: unknown): ConformanceProfile;
|
|
7237
7284
|
|
|
7238
7285
|
/**
|
|
7239
|
-
* Barrel for the conformance-profile engine
|
|
7286
|
+
* Barrel for the conformance-profile engine. Re-exports the
|
|
7240
7287
|
* engine, the fail-fast profile-authoring gate, and the public types. Also
|
|
7241
7288
|
* available as the `conformance` namespace object from the package root.
|
|
7242
7289
|
*
|
|
@@ -7265,8 +7312,8 @@ declare namespace index {
|
|
|
7265
7312
|
}
|
|
7266
7313
|
|
|
7267
7314
|
/**
|
|
7268
|
-
* Streaming / incremental parse for the `@cosyte/hl7` parser
|
|
7269
|
-
*
|
|
7315
|
+
* Streaming / incremental parse for the `@cosyte/hl7` parser. Real ELR / IIS
|
|
7316
|
+
* / lab feeds and files ship many messages and can be
|
|
7270
7317
|
* far too large to buffer whole; a live source (an already-de-framed MLLP feed,
|
|
7271
7318
|
* a growing file) has no "whole" to buffer at all. `parseStream()` consumes a
|
|
7272
7319
|
* **chunked** byte/string source: a Node `Readable`, an async-iterable, or a
|