@cosyte/hl7 0.0.2 → 0.0.3
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 +123 -0
- package/README.md +1 -1
- package/dist/index.cjs +41 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +243 -256
- package/dist/index.d.ts +243 -256
- package/dist/index.mjs +41 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -241,7 +241,7 @@ 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
|
|
@@ -326,7 +326,7 @@ declare function unknownCharset(position: Hl7Position, requested: string): Hl7Pa
|
|
|
326
326
|
*/
|
|
327
327
|
declare function unsupportedCharset(position: Hl7Position, code: string): Hl7ParseWarning;
|
|
328
328
|
/**
|
|
329
|
-
* Build an `ACK_NO_CORRELATION_ID` warning. Emitted by `buildAck
|
|
329
|
+
* Build an `ACK_NO_CORRELATION_ID` warning. Emitted by `buildAck`,
|
|
330
330
|
* not by the parser: the inbound message carried no MSH-10 message control ID,
|
|
331
331
|
* so the generated ACK leaves MSA-2 empty and, when a positive accept was
|
|
332
332
|
* requested, downgrades it to an error code rather than fabricating an
|
|
@@ -342,7 +342,7 @@ declare function unsupportedCharset(position: Hl7Position, code: string): Hl7Par
|
|
|
342
342
|
*/
|
|
343
343
|
declare function ackNoCorrelationId(position: Hl7Position): Hl7ParseWarning;
|
|
344
344
|
/**
|
|
345
|
-
* Build a `MERGE_MISSING_PRIOR_OR_SURVIVOR` warning
|
|
345
|
+
* Build a `MERGE_MISSING_PRIOR_OR_SURVIVOR` warning. Emitted
|
|
346
346
|
* by `identityEvents()` (a read-side helper: it attaches to the returned
|
|
347
347
|
* `IdentityEvent.warnings`, never to `Hl7Message.warnings`) when a merge/move
|
|
348
348
|
* trigger event (A18/A34/A35/A36/A39/A40/A41/A42/A43/A44) is missing one side
|
|
@@ -368,7 +368,7 @@ declare function ackNoCorrelationId(position: Hl7Position): Hl7ParseWarning;
|
|
|
368
368
|
*/
|
|
369
369
|
declare function mergeMissingPriorOrSurvivor(position: Hl7Position, eventType: string, missing: "prior" | "survivor"): Hl7ParseWarning;
|
|
370
370
|
/**
|
|
371
|
-
* Build a `BATCH_COUNT_MISMATCH` warning
|
|
371
|
+
* Build a `BATCH_COUNT_MISMATCH` warning. Emitted by
|
|
372
372
|
* `splitBatch()`: attached to the returned `BatchSplitResult.warnings`, never
|
|
373
373
|
* to `Hl7Message.warnings`: when a declared envelope count does not equal the
|
|
374
374
|
* count actually split out: a **BTS-1** batch message count that differs from
|
|
@@ -392,7 +392,7 @@ declare function mergeMissingPriorOrSurvivor(position: Hl7Position, eventType: s
|
|
|
392
392
|
*/
|
|
393
393
|
declare function batchCountMismatch(position: Hl7Position, unit: "message" | "batch", declared: number, actual: number): Hl7ParseWarning;
|
|
394
394
|
/**
|
|
395
|
-
* Build a `BATCH_MISSING_TRAILER` warning
|
|
395
|
+
* Build a `BATCH_MISSING_TRAILER` warning. Emitted by
|
|
396
396
|
* `splitBatch()` (attached to `BatchSplitResult.warnings`) when an envelope
|
|
397
397
|
* header opens a scope that is never closed: a **BHS** batch header with no
|
|
398
398
|
* matching **BTS** trailer, or an **FHS** file header with no matching **FTS**
|
|
@@ -413,7 +413,7 @@ declare function batchCountMismatch(position: Hl7Position, unit: "message" | "ba
|
|
|
413
413
|
*/
|
|
414
414
|
declare function batchMissingTrailer(position: Hl7Position, header: "FHS" | "BHS", expectedTrailer: "FTS" | "BTS"): Hl7ParseWarning;
|
|
415
415
|
/**
|
|
416
|
-
* Build an `UNTERMINATED_STREAM_MESSAGE` warning
|
|
416
|
+
* Build an `UNTERMINATED_STREAM_MESSAGE` warning. Emitted by
|
|
417
417
|
* `parseStream()`: attached to a {@link StreamMessageEntry}'s `streamWarnings`,
|
|
418
418
|
* NOT to `Hl7Message.warnings`: when the **final** message in a stream ends
|
|
419
419
|
* without a segment terminator (its last segment ran to end-of-stream with no
|
|
@@ -535,9 +535,8 @@ interface ParseOptions {
|
|
|
535
535
|
* (`defineProfile()`). `fields` maps a caller-visible field NAME to its
|
|
536
536
|
* 1-indexed HL7 position within the segment. Declared here (alongside
|
|
537
537
|
* `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.
|
|
538
|
+
* `src/profiles/define.ts` re-exports this type, so consumers can write
|
|
539
|
+
* `import type { CustomSegmentDefinition } from "@cosyte/hl7"`.
|
|
541
540
|
*
|
|
542
541
|
* @example
|
|
543
542
|
* ```ts
|
|
@@ -553,11 +552,10 @@ interface CustomSegmentDefinition {
|
|
|
553
552
|
/**
|
|
554
553
|
* Structural placeholder for HL7 profiles. A profile bundles vendor-specific
|
|
555
554
|
* tolerances, date formats, custom segment definitions, and optional
|
|
556
|
-
* callbacks.
|
|
557
|
-
* and runtime effects land in Phase 6.
|
|
555
|
+
* callbacks. Profiles are built with the `defineProfile()` factory.
|
|
558
556
|
*
|
|
559
|
-
*
|
|
560
|
-
* `
|
|
557
|
+
* `customSegments` is narrowed to the locked `CustomSegmentDefinition` shape,
|
|
558
|
+
* and `Profile` carries an optional `describe?` method
|
|
561
559
|
* so `defineProfile()`-produced profiles can be introspected without
|
|
562
560
|
* consumers needing to narrow away from the `Profile` type. The `describe`
|
|
563
561
|
* method is only populated by `defineProfile()`: hand-authored `Profile`
|
|
@@ -737,8 +735,8 @@ interface RawSegment {
|
|
|
737
735
|
|
|
738
736
|
/**
|
|
739
737
|
* 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,
|
|
738
|
+
* not override them via MSH-1 / MSH-2. Re-used by downstream stages (the
|
|
739
|
+
* escape map, `parseHL7`) as a synthetic-message fallback.
|
|
742
740
|
*
|
|
743
741
|
* @example
|
|
744
742
|
* ```ts
|
|
@@ -754,7 +752,7 @@ declare const DEFAULT_ENCODING_CHARACTERS: EncodingCharacters;
|
|
|
754
752
|
* a human (or a downstream display / FHIR `.text`) can read, instead of the
|
|
755
753
|
* raw `\H\`/`\.br\` sentinels the lenient parser preserves.
|
|
756
754
|
*
|
|
757
|
-
*
|
|
755
|
+
* `renderText` is a read projection: it never mutates the
|
|
758
756
|
* raw field value (rendering is opt-in on top of the tolerant parse), and it
|
|
759
757
|
* **never fabricates**: an escape it cannot render is preserved as its literal
|
|
760
758
|
* characters AND flagged in {@link RenderedText.unrenderedSequences}, never
|
|
@@ -909,9 +907,9 @@ declare function renderText(input: string, enc?: EncodingCharacters, opts?: Rend
|
|
|
909
907
|
|
|
910
908
|
/**
|
|
911
909
|
* CE: HL7 v2 Coded Element composite. 6-component coded-element shape
|
|
912
|
-
* parsed from a `RawRepetition` on demand by `Field.asCe()
|
|
913
|
-
*
|
|
914
|
-
*
|
|
910
|
+
* parsed from a `RawRepetition` on demand by `Field.asCe()`. Fields are
|
|
911
|
+
* OMITTED when absent (exactOptionalPropertyTypes): NEVER set to
|
|
912
|
+
* `undefined`.
|
|
915
913
|
*
|
|
916
914
|
* CE is the older, simpler sibling of CWE: 6 components, no version ids,
|
|
917
915
|
* no originalText. Still common in OBX.3 and similar observation-identifier
|
|
@@ -964,8 +962,8 @@ interface CE {
|
|
|
964
962
|
}
|
|
965
963
|
/**
|
|
966
964
|
* Parse an HL7 v2 CE repetition into a structured `CE` object. Components
|
|
967
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
968
|
-
*
|
|
965
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
966
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
969
967
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
970
968
|
*
|
|
971
969
|
* @example
|
|
@@ -984,9 +982,9 @@ declare function parseCe(rep: RawRepetition, enc: EncodingCharacters): CE;
|
|
|
984
982
|
|
|
985
983
|
/**
|
|
986
984
|
* CWE: HL7 v2 Coded with Exceptions composite. 9-component coded-element
|
|
987
|
-
* shape parsed from a `RawRepetition` on demand by `Field.asCwe()
|
|
988
|
-
*
|
|
989
|
-
*
|
|
985
|
+
* shape parsed from a `RawRepetition` on demand by `Field.asCwe()`. Fields
|
|
986
|
+
* are OMITTED when absent (exactOptionalPropertyTypes), NEVER set to
|
|
987
|
+
* `undefined`.
|
|
990
988
|
*
|
|
991
989
|
* Note: full HL7 v2.6+ CWE has 22 components. v1 of this library ships the 9
|
|
992
990
|
* core components: identifier, text, coding-system trio + version ids, and
|
|
@@ -1046,8 +1044,8 @@ interface CWE {
|
|
|
1046
1044
|
}
|
|
1047
1045
|
/**
|
|
1048
1046
|
* Parse an HL7 v2 CWE repetition into a structured `CWE` object. Components
|
|
1049
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1050
|
-
*
|
|
1047
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1048
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1051
1049
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1052
1050
|
*
|
|
1053
1051
|
* @example
|
|
@@ -1097,8 +1095,8 @@ interface HD {
|
|
|
1097
1095
|
}
|
|
1098
1096
|
/**
|
|
1099
1097
|
* Parse an HL7 v2 HD repetition into a structured `HD` object. Components
|
|
1100
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1101
|
-
*
|
|
1098
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1099
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1102
1100
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1103
1101
|
*
|
|
1104
1102
|
* @example
|
|
@@ -1119,7 +1117,7 @@ declare function parseHd(rep: RawRepetition, enc: EncodingCharacters): HD;
|
|
|
1119
1117
|
/**
|
|
1120
1118
|
* CX: HL7 v2 Extended Composite ID (with check digit) composite.
|
|
1121
1119
|
* 10-component structured-identifier shape parsed from a `RawRepetition` on
|
|
1122
|
-
* demand by `Field.asCx()
|
|
1120
|
+
* demand by `Field.asCx()`. Fields are OMITTED when
|
|
1123
1121
|
* absent (exactOptionalPropertyTypes): NEVER set to `undefined`.
|
|
1124
1122
|
*
|
|
1125
1123
|
* Component 4 (`assigningAuthority`) is the ONE nested-composite field in
|
|
@@ -1178,8 +1176,8 @@ interface CX {
|
|
|
1178
1176
|
}
|
|
1179
1177
|
/**
|
|
1180
1178
|
* Parse an HL7 v2 CX repetition into a structured `CX` object. Components
|
|
1181
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1182
|
-
*
|
|
1179
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1180
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1183
1181
|
* from the result (exactOptionalPropertyTypes semantics). Component 4
|
|
1184
1182
|
* (`assigningAuthority`) is parsed as a nested `HD`; see component table in
|
|
1185
1183
|
* the `CX` interface JSDoc for the v1 simplifications on components 6/9/10.
|
|
@@ -1257,7 +1255,7 @@ declare function parseNm(rep: RawRepetition, _enc: EncodingCharacters): NM;
|
|
|
1257
1255
|
* PL: HL7 v2 Person Location composite. 11-component structured-location
|
|
1258
1256
|
* shape (v1 trimmed from the HL7 v2.5 full 12-component PL: slot 12
|
|
1259
1257
|
* `entityIdentifier` is rarely used; v2 may restore the full shape) parsed
|
|
1260
|
-
* from a `RawRepetition` on demand by `Field.asPl()
|
|
1258
|
+
* from a `RawRepetition` on demand by `Field.asPl()`.
|
|
1261
1259
|
* Fields are OMITTED when absent (exactOptionalPropertyTypes): NEVER set
|
|
1262
1260
|
* to `undefined`.
|
|
1263
1261
|
*
|
|
@@ -1319,8 +1317,8 @@ interface PL {
|
|
|
1319
1317
|
}
|
|
1320
1318
|
/**
|
|
1321
1319
|
* Parse an HL7 v2 PL repetition into a structured `PL` object. Components
|
|
1322
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1323
|
-
*
|
|
1320
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1321
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1324
1322
|
* from the result (exactOptionalPropertyTypes semantics). Component 4
|
|
1325
1323
|
* (`facility`) is parsed as a nested `HD`; see component table in the `PL`
|
|
1326
1324
|
* interface JSDoc for the v1 simplifications.
|
|
@@ -1421,15 +1419,15 @@ declare function parseSn(rep: RawRepetition, enc: EncodingCharacters): SN | unde
|
|
|
1421
1419
|
/**
|
|
1422
1420
|
* HL7 v2 TS/DTM datetime handling for the `@cosyte/hl7` parser pipeline.
|
|
1423
1421
|
*
|
|
1424
|
-
*
|
|
1425
|
-
* `Date`-coercing helper
|
|
1422
|
+
* This module is a **fidelity-first** datetime parser rather than a
|
|
1423
|
+
* `Date`-coercing helper. The HL7 v2 Ch. 2A
|
|
1426
1424
|
* DTM datatype is `YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]`, where the
|
|
1427
1425
|
* number of populated characters (excluding the offset) sets the precision and
|
|
1428
1426
|
* a missing offset "defaults to that of the local time zone of the sender",
|
|
1429
1427
|
* 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
|
-
*
|
|
1428
|
+
* assume-UTC on a missing offset, eager `Date`) is an architectural defect:
|
|
1429
|
+
* it silently shifts a day-only birth date (`|19880705|`) by a day in any
|
|
1430
|
+
* negative-offset zone.
|
|
1433
1431
|
*
|
|
1434
1432
|
* This module therefore:
|
|
1435
1433
|
* - `parseDtm(raw)` decodes the DTM into typed **parts** (`DtmParts`),
|
|
@@ -1639,13 +1637,12 @@ interface DtmToDateOptions {
|
|
|
1639
1637
|
declare function dtmToDate(parts: DtmParts, options?: DtmToDateOptions): Date | undefined;
|
|
1640
1638
|
|
|
1641
1639
|
/**
|
|
1642
|
-
* TS/DTM: HL7 v2 Time Stamp composite. Delegates parsing to the
|
|
1640
|
+
* TS/DTM: HL7 v2 Time Stamp composite. Delegates parsing to the parser
|
|
1643
1641
|
* helper `src/parser/dates.ts::parseDtm` (D-10 "zero duplicate date logic").
|
|
1644
1642
|
*
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
* {@link DtmParts}: raw string + typed parts + stated precision + timezone
|
|
1643
|
+
* The composite is fidelity-preserving: rather than a `{ raw, date }` shape
|
|
1644
|
+
* that would zero-fill truncations and assume UTC for a missing offset, it is
|
|
1645
|
+
* a {@link DtmParts}: raw string + typed parts + stated precision + timezone
|
|
1649
1646
|
* presence, with **no eager `Date`**. Callers that need an absolute instant
|
|
1650
1647
|
* opt in explicitly via `dtmToDate(ts, opts)`: which refuses to guess a zone
|
|
1651
1648
|
* for an offset-less value rather than silently defaulting to UTC.
|
|
@@ -1699,9 +1696,9 @@ declare function parseTs(rep: RawRepetition, _enc: EncodingCharacters): TS;
|
|
|
1699
1696
|
|
|
1700
1697
|
/**
|
|
1701
1698
|
* XAD: HL7 v2 Extended Address composite. 12-component structured address
|
|
1702
|
-
* shape parsed from a `RawRepetition` on demand by `Field.asXad()
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1699
|
+
* shape parsed from a `RawRepetition` on demand by `Field.asXad()`. Fields
|
|
1700
|
+
* are OMITTED when absent (exactOptionalPropertyTypes), NEVER set to
|
|
1701
|
+
* `undefined`.
|
|
1705
1702
|
*
|
|
1706
1703
|
* Zero runtime deps: pure function over the raw positional tree + `unescape`.
|
|
1707
1704
|
*/
|
|
@@ -1747,8 +1744,8 @@ interface XAD {
|
|
|
1747
1744
|
}
|
|
1748
1745
|
/**
|
|
1749
1746
|
* Parse an HL7 v2 XAD repetition into a structured `XAD` object. Components
|
|
1750
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1751
|
-
*
|
|
1747
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1748
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1752
1749
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1753
1750
|
*
|
|
1754
1751
|
* @example
|
|
@@ -1829,8 +1826,8 @@ interface XCN {
|
|
|
1829
1826
|
}
|
|
1830
1827
|
/**
|
|
1831
1828
|
* Parse an HL7 v2 XCN repetition into a structured `XCN` object. Components
|
|
1832
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1833
|
-
*
|
|
1829
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1830
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1834
1831
|
* from the result (exactOptionalPropertyTypes semantics). Component 9
|
|
1835
1832
|
* (`assigningAuthority`) is parsed as a nested `HD`; see component table in
|
|
1836
1833
|
* the `XCN` interface JSDoc for the v1 trimming.
|
|
@@ -1864,9 +1861,9 @@ declare function parseXcn(rep: RawRepetition, enc: EncodingCharacters): XCN;
|
|
|
1864
1861
|
|
|
1865
1862
|
/**
|
|
1866
1863
|
* XPN: HL7 v2 Extended Person Name composite. 14-component structured-name
|
|
1867
|
-
* shape parsed from a `RawRepetition` on demand by `Field.asXpn()
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1864
|
+
* shape parsed from a `RawRepetition` on demand by `Field.asXpn()`. Fields
|
|
1865
|
+
* are OMITTED when absent (exactOptionalPropertyTypes), NEVER set to
|
|
1866
|
+
* `undefined`.
|
|
1870
1867
|
*
|
|
1871
1868
|
* Zero runtime deps: pure function over the raw positional tree + `unescape`.
|
|
1872
1869
|
*/
|
|
@@ -1916,8 +1913,8 @@ interface XPN {
|
|
|
1916
1913
|
}
|
|
1917
1914
|
/**
|
|
1918
1915
|
* Parse an HL7 v2 XPN repetition into a structured `XPN` object. Components
|
|
1919
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1920
|
-
*
|
|
1916
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1917
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1921
1918
|
* from the result (exactOptionalPropertyTypes semantics).
|
|
1922
1919
|
*
|
|
1923
1920
|
* @example
|
|
@@ -1938,9 +1935,9 @@ declare function parseXpn(rep: RawRepetition, enc: EncodingCharacters): XPN;
|
|
|
1938
1935
|
* XTN: HL7 v2 Extended Telecommunication Number composite. 12-component
|
|
1939
1936
|
* structured telecom shape (v1 trimmed from the HL7 v2.5 full 14-component
|
|
1940
1937
|
* 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
|
-
|
|
1938
|
+
* shape) parsed from a `RawRepetition` on demand by `Field.asXtn()`. Fields
|
|
1939
|
+
* are OMITTED when absent (exactOptionalPropertyTypes): NEVER set to
|
|
1940
|
+
* `undefined`.
|
|
1944
1941
|
*
|
|
1945
1942
|
* Zero runtime deps: pure function over the raw positional tree + `unescape`.
|
|
1946
1943
|
*/
|
|
@@ -1993,8 +1990,8 @@ interface XTN {
|
|
|
1993
1990
|
}
|
|
1994
1991
|
/**
|
|
1995
1992
|
* Parse an HL7 v2 XTN repetition into a structured `XTN` object. Components
|
|
1996
|
-
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1997
|
-
*
|
|
1993
|
+
* are returned verbatim (already decoded once by the tokenizer: never
|
|
1994
|
+
* re-unescaped). Absent / empty components are OMITTED
|
|
1998
1995
|
* from the result (exactOptionalPropertyTypes semantics). Components past
|
|
1999
1996
|
* position 12 are silently ignored in v1.
|
|
2000
1997
|
*
|
|
@@ -2049,11 +2046,11 @@ declare class Field {
|
|
|
2049
2046
|
readonly isNull: boolean;
|
|
2050
2047
|
/** Reference to the underlying `RawField.repetitions` (no defensive copy). */
|
|
2051
2048
|
readonly repetitions: readonly RawRepetition[];
|
|
2052
|
-
/** The 5 encoding characters for this message. Exposed for composite parsers
|
|
2049
|
+
/** The 5 encoding characters for this message. Exposed for composite parsers. @internal */
|
|
2053
2050
|
readonly enc: EncodingCharacters;
|
|
2054
2051
|
/** Position of this field in the parent message: used for position-aware error messages. @internal */
|
|
2055
2052
|
readonly position: Hl7Position;
|
|
2056
|
-
/** The full `RawField` this wrapper wraps. Exposed for composite parsers
|
|
2053
|
+
/** The full `RawField` this wrapper wraps. Exposed for composite parsers. @internal */
|
|
2057
2054
|
readonly raw: RawField;
|
|
2058
2055
|
/**
|
|
2059
2056
|
* Construct a new `Field`. Called internally by `Segment.field(n)`; user
|
|
@@ -2064,7 +2061,7 @@ declare class Field {
|
|
|
2064
2061
|
/**
|
|
2065
2062
|
* First-repetition, first-component, first-subcomponent value as a decoded
|
|
2066
2063
|
* string: unescaped ONCE by the tokenizer on parse, returned verbatim here
|
|
2067
|
-
* (never re-unescaped
|
|
2064
|
+
* (never re-unescaped). Returns `""` when the field is
|
|
2068
2065
|
* empty or HL7 null. Equivalent to `msg.get('SEG.N')` for a top-level access.
|
|
2069
2066
|
*
|
|
2070
2067
|
* @example
|
|
@@ -2087,7 +2084,7 @@ declare class Field {
|
|
|
2087
2084
|
* vendor-quirk control id containing an unescaped delimiter (`ID^X`) must
|
|
2088
2085
|
* not be truncated to its first component.
|
|
2089
2086
|
*
|
|
2090
|
-
* **Byte-verbatim for parsed content
|
|
2087
|
+
* **Byte-verbatim for parsed content.** The parse pipeline stores
|
|
2091
2088
|
* *decoded* content, but also records the original wire bytes of any escape
|
|
2092
2089
|
* whose decode is not byte-faithful (`RawComponent.rawSubcomponents`), so
|
|
2093
2090
|
* re-serialization preserves the sender's exact escape bytes: hex escapes
|
|
@@ -2300,7 +2297,7 @@ declare class Field {
|
|
|
2300
2297
|
* calls `new Segment(...)` directly.
|
|
2301
2298
|
*
|
|
2302
2299
|
* The wrapper does NOT copy `raw.fields`: it holds a reference so mutations
|
|
2303
|
-
* through
|
|
2300
|
+
* through `setField` / `addSegment` / `removeSegment` stay visible.
|
|
2304
2301
|
*/
|
|
2305
2302
|
|
|
2306
2303
|
/**
|
|
@@ -2325,7 +2322,7 @@ declare class Segment {
|
|
|
2325
2322
|
readonly enc: EncodingCharacters;
|
|
2326
2323
|
/** Absolute index of this segment in `Hl7Message.rawSegments[]`. Used for position tracking. @internal */
|
|
2327
2324
|
readonly absoluteIndex: number;
|
|
2328
|
-
/** The full `RawSegment` this wrapper wraps. Exposed for mutation methods
|
|
2325
|
+
/** The full `RawSegment` this wrapper wraps. Exposed for mutation methods. @internal */
|
|
2329
2326
|
readonly raw: RawSegment;
|
|
2330
2327
|
/**
|
|
2331
2328
|
* Lookup map from profile-declared field name → 1-indexed HL7 position.
|
|
@@ -2342,7 +2339,7 @@ declare class Segment {
|
|
|
2342
2339
|
* should obtain `Segment` instances via `msg.segments(type)` or
|
|
2343
2340
|
* `msg.allSegments()`.
|
|
2344
2341
|
*
|
|
2345
|
-
* The optional `customFields` parameter is the per-segment
|
|
2342
|
+
* The optional `customFields` parameter is the per-segment portion of the
|
|
2346
2343
|
* applied profile's merged `customSegments` map (PROF-07 / D-16). When
|
|
2347
2344
|
* supplied, `get(name)` resolves names against it; otherwise `get(name)`
|
|
2348
2345
|
* always returns `undefined`.
|
|
@@ -2400,7 +2397,7 @@ declare class Segment {
|
|
|
2400
2397
|
}
|
|
2401
2398
|
|
|
2402
2399
|
/**
|
|
2403
|
-
* `identityEvents`:
|
|
2400
|
+
* `identityEvents`: read-side helper that recognizes the ADT
|
|
2404
2401
|
* patient-identity management trigger events and surfaces the MRG segment's
|
|
2405
2402
|
* *prior* (non-surviving) identifiers alongside the PID/PV1 *surviving*
|
|
2406
2403
|
* identifiers, each labelled by role.
|
|
@@ -2455,7 +2452,7 @@ type IdentityEventKind = "merge" | "move" | "link" | "unlink" | "add" | "update"
|
|
|
2455
2452
|
/**
|
|
2456
2453
|
* Role of one party in an identity event. `surviving` / `subject` / `linked`
|
|
2457
2454
|
* parties are ONLY ever sourced from PID (+ PV1); `prior` parties are ONLY
|
|
2458
|
-
* ever sourced from MRG
|
|
2455
|
+
* ever sourced from MRG. That is the role-labelling invariant.
|
|
2459
2456
|
*
|
|
2460
2457
|
* @example
|
|
2461
2458
|
* ```ts
|
|
@@ -2557,17 +2554,17 @@ interface IdentityEvent {
|
|
|
2557
2554
|
}
|
|
2558
2555
|
|
|
2559
2556
|
/**
|
|
2560
|
-
*
|
|
2557
|
+
* Helper type declarations: the 9 typed shapes returned by
|
|
2561
2558
|
* `Hl7Message.meta`/`.patient`/`.visit` getters and the 6 collection methods
|
|
2562
2559
|
* (`observations()`, `orders()`, `nextOfKin()`, `allergies()`, `diagnoses()`,
|
|
2563
2560
|
* `insurance()`). Every field is `readonly`; every optional key is
|
|
2564
2561
|
* `exactOptionalPropertyTypes`-safe (never `| undefined` on the declaration).
|
|
2565
2562
|
*
|
|
2566
2563
|
* 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
|
|
2564
|
+
* CX, CWE, CE, XTN, PL, XCN): helpers are pure views on top of the model layer's
|
|
2568
2565
|
* composite coercions, never re-parsing the raw tree.
|
|
2569
2566
|
*
|
|
2570
|
-
* Field lists locked by
|
|
2567
|
+
* Field lists are locked by decisions D-01..D-24. Nine interfaces:
|
|
2571
2568
|
* `Meta`, `Patient`, `Visit`, `Observation` (discriminated union + `ObservationBase`),
|
|
2572
2569
|
* `Order`, `NextOfKin`, `Allergy`, `Diagnosis`, `Insurance`.
|
|
2573
2570
|
*/
|
|
@@ -2576,7 +2573,7 @@ interface IdentityEvent {
|
|
|
2576
2573
|
* MSH-derived message metadata (HELPERS-01). D-03: always defined on
|
|
2577
2574
|
* `Hl7Message.meta` (MSH absence throws `NO_MSH_SEGMENT` at parse time);
|
|
2578
2575
|
* individual fields are optional because vendor-quirky messages routinely
|
|
2579
|
-
* omit pieces of MSH.
|
|
2576
|
+
* omit pieces of MSH. `timestamp` is the fidelity `TS` (precision +
|
|
2580
2577
|
* timezone preserved), not an eager UTC-assuming `Date`.
|
|
2581
2578
|
*
|
|
2582
2579
|
* @example
|
|
@@ -2603,7 +2600,7 @@ interface Meta {
|
|
|
2603
2600
|
readonly messageStructure?: string;
|
|
2604
2601
|
/** MSH-10 message control ID: unique per message per sender. */
|
|
2605
2602
|
readonly controlId?: string;
|
|
2606
|
-
/** MSH-7 message date/time as the fidelity `TS
|
|
2603
|
+
/** MSH-7 message date/time as the fidelity `TS`. */
|
|
2607
2604
|
readonly timestamp?: TS;
|
|
2608
2605
|
/** MSH-12 HL7 version string (e.g. "2.5", "2.5.1"). */
|
|
2609
2606
|
readonly version?: string;
|
|
@@ -2656,7 +2653,7 @@ interface Patient {
|
|
|
2656
2653
|
/** Composed Western-order name "Given Middle Family, Suffix" (D-17). */
|
|
2657
2654
|
readonly fullName?: string;
|
|
2658
2655
|
/**
|
|
2659
|
-
* PID-7 date of birth as the fidelity `TS
|
|
2656
|
+
* PID-7 date of birth as the fidelity `TS`. A day-only DOB keeps
|
|
2660
2657
|
* `precision: "day"`: never coerced to a UTC-midnight instant that would
|
|
2661
2658
|
* read as the previous day in a negative-offset zone.
|
|
2662
2659
|
*/
|
|
@@ -2674,7 +2671,7 @@ interface Patient {
|
|
|
2674
2671
|
/** PID-15 primary language. */
|
|
2675
2672
|
readonly language?: CE;
|
|
2676
2673
|
/**
|
|
2677
|
-
* NTE note lines positionally attached to the (first) PID
|
|
2674
|
+
* NTE note lines positionally attached to the (first) PID: notes
|
|
2678
2675
|
* immediately following the patient's PID segment, HL7-unescaped, in
|
|
2679
2676
|
* document order. OMITTED when the patient carries no notes. High-PHI-risk
|
|
2680
2677
|
* clinical narrative.
|
|
@@ -2684,7 +2681,7 @@ interface Patient {
|
|
|
2684
2681
|
/**
|
|
2685
2682
|
* PV1-derived visit view (HELPERS-03). `msg.visit` is `undefined` when no PV1
|
|
2686
2683
|
* segment exists; this interface describes the shape when present. D-24a:
|
|
2687
|
-
* doctor fields use XCN (not flat strings).
|
|
2684
|
+
* doctor fields use XCN (not flat strings). Date/time fields are the
|
|
2688
2685
|
* fidelity `TS` (precision + timezone preserved).
|
|
2689
2686
|
*
|
|
2690
2687
|
* @example
|
|
@@ -2704,9 +2701,9 @@ interface Visit {
|
|
|
2704
2701
|
readonly patientClass?: string;
|
|
2705
2702
|
/** PV1-3 assigned patient location (ward / room / bed) as PL. */
|
|
2706
2703
|
readonly location?: PL;
|
|
2707
|
-
/** PV1-44 admit date/time as the fidelity `TS
|
|
2704
|
+
/** PV1-44 admit date/time as the fidelity `TS`. */
|
|
2708
2705
|
readonly admitDateTime?: TS;
|
|
2709
|
-
/** PV1-45 discharge date/time as the fidelity `TS
|
|
2706
|
+
/** PV1-45 discharge date/time as the fidelity `TS`. */
|
|
2710
2707
|
readonly dischargeDateTime?: TS;
|
|
2711
2708
|
/** PV1-7 attending doctor (D-24a XCN). */
|
|
2712
2709
|
readonly attendingDoctor?: XCN;
|
|
@@ -2752,10 +2749,10 @@ interface ObservationBase {
|
|
|
2752
2749
|
readonly abnormalFlags?: string;
|
|
2753
2750
|
/** OBX-11 observation result status (e.g. "F"=final, "P"=preliminary). */
|
|
2754
2751
|
readonly status?: string;
|
|
2755
|
-
/** OBX-14 date/time of observation as the fidelity `TS
|
|
2752
|
+
/** OBX-14 date/time of observation as the fidelity `TS`. */
|
|
2756
2753
|
readonly observedDateTime?: TS;
|
|
2757
2754
|
/**
|
|
2758
|
-
* NTE note lines positionally attached to this OBX
|
|
2755
|
+
* NTE note lines positionally attached to this OBX: each
|
|
2759
2756
|
* non-empty NTE-3 (Comment, FT) repetition of every NTE immediately
|
|
2760
2757
|
* following this observation, HL7-unescaped, in document order. OMITTED when
|
|
2761
2758
|
* the observation carries no notes. High-PHI-risk clinical narrative.
|
|
@@ -2767,7 +2764,7 @@ interface ObservationBase {
|
|
|
2767
2764
|
* `valueType` (OBX-2) per D-13:
|
|
2768
2765
|
* - `"NM"` → `number | undefined`
|
|
2769
2766
|
* - `"SN"` → `SN | undefined` (structured numeric: comparator / range / ratio)
|
|
2770
|
-
* - `"TS" | "DT"` → `TS | undefined` (fidelity parts
|
|
2767
|
+
* - `"TS" | "DT"` → `TS | undefined` (fidelity parts preserved)
|
|
2771
2768
|
* - `"CWE" | "CE"` → `CWE | CE | undefined` (full composite per D-14)
|
|
2772
2769
|
* - other (`"ST"`, `"TX"`, `"FT"`, `"ID"`, `"IS"`, `"NA"`, unknown) →
|
|
2773
2770
|
* `string | undefined` (decoded, D-23)
|
|
@@ -2809,7 +2806,7 @@ type Observation = ObservationBase & ({
|
|
|
2809
2806
|
});
|
|
2810
2807
|
/**
|
|
2811
2808
|
* How an order/medication `RepeatPattern` code (HL7 Table 0335) is classified,
|
|
2812
|
-
* **provenance only, never used to resolve a schedule
|
|
2809
|
+
* **provenance only, never used to resolve a schedule**. The `code`
|
|
2813
2810
|
* is always authoritative and surfaced verbatim; this flag only tells a
|
|
2814
2811
|
* consumer *what kind* of pattern it is looking at so it can decide whether a
|
|
2815
2812
|
* load-bearing integer is present.
|
|
@@ -2827,7 +2824,7 @@ type Observation = ObservationBase & ({
|
|
|
2827
2824
|
type RepeatPatternKind = "parametric" | "named" | "unknown";
|
|
2828
2825
|
/**
|
|
2829
2826
|
* An order/medication timing **repeat pattern** (HL7 Table 0335): the
|
|
2830
|
-
* frequency/SIG field (TQ1-3, or the legacy embedded TQ interval RI.1)
|
|
2827
|
+
* frequency/SIG field (TQ1-3, or the legacy embedded TQ interval RI.1).
|
|
2831
2828
|
*
|
|
2832
2829
|
* **Safety contract.** `code` is the **decoded field value** (HL7 escapes are
|
|
2833
2830
|
* unescaped as with every field read) and is **never resolved to clock times,
|
|
@@ -2861,7 +2858,7 @@ interface RepeatPattern {
|
|
|
2861
2858
|
}
|
|
2862
2859
|
/**
|
|
2863
2860
|
* A composite-quantity (CQ) value on an order/medication timing: the TQ1-2
|
|
2864
|
-
* service quantity
|
|
2861
|
+
* service quantity. `value` is strict-`Number()` parsed (`undefined`,
|
|
2865
2862
|
* never `NaN`); `units` carries any CQ.2 units. Both keys OMITTED when absent.
|
|
2866
2863
|
*
|
|
2867
2864
|
* @example
|
|
@@ -2878,14 +2875,14 @@ interface TimingQuantity {
|
|
|
2878
2875
|
}
|
|
2879
2876
|
/**
|
|
2880
2877
|
* The order/medication **timing** structure: one TQ1 segment (v2.5+) or the
|
|
2881
|
-
* legacy embedded TQ in ORC-7 / RXE-1 (pre-v2.5)
|
|
2878
|
+
* legacy embedded TQ in ORC-7 / RXE-1 (pre-v2.5). Attached to
|
|
2882
2879
|
* {@link Order.timings} and {@link Medication.timings}.
|
|
2883
2880
|
*
|
|
2884
2881
|
* **Safety contract.** hl7 surfaces the timing **structure**; it does **not**
|
|
2885
2882
|
* compute administration schedules, resolve "institution-specified times" to
|
|
2886
2883
|
* clock times, or interpret sig. The load-bearing {@link repeatPattern} and
|
|
2887
2884
|
* {@link totalOccurrences} are preserved verbatim (see {@link RepeatPattern});
|
|
2888
|
-
* `startDateTime`/`endDateTime` keep the
|
|
2885
|
+
* `startDateTime`/`endDateTime` keep the `TS` precision + timezone
|
|
2889
2886
|
* fidelity. A malformed timing never throws: absent pieces are omitted keys.
|
|
2890
2887
|
*
|
|
2891
2888
|
* @example
|
|
@@ -2917,9 +2914,9 @@ interface OrderTiming {
|
|
|
2917
2914
|
readonly explicitTime?: string;
|
|
2918
2915
|
/** TQ1-6 / legacy TQ.3 service duration: surfaced verbatim. */
|
|
2919
2916
|
readonly serviceDuration?: string;
|
|
2920
|
-
/** TQ1-7 / legacy TQ.4 start date/time as the fidelity `TS
|
|
2917
|
+
/** TQ1-7 / legacy TQ.4 start date/time as the fidelity `TS`. */
|
|
2921
2918
|
readonly startDateTime?: TS;
|
|
2922
|
-
/** TQ1-8 / legacy TQ.5 end date/time as the fidelity `TS
|
|
2919
|
+
/** TQ1-8 / legacy TQ.5 end date/time as the fidelity `TS`. */
|
|
2923
2920
|
readonly endDateTime?: TS;
|
|
2924
2921
|
/** TQ1-9 priority (CWE) / legacy TQ.6 priority (surfaced as a CWE `{ identifier }`). */
|
|
2925
2922
|
readonly priority?: CWE;
|
|
@@ -2934,8 +2931,8 @@ interface OrderTiming {
|
|
|
2934
2931
|
/**
|
|
2935
2932
|
* OBR-derived order (HELPERS-05, D-16) with positionally-grouped OBX children
|
|
2936
2933
|
* (D-12). `observations` is ALWAYS present: empty when no OBX follows this
|
|
2937
|
-
* OBR before the next OBR or end-of-message.
|
|
2938
|
-
*
|
|
2934
|
+
* OBR before the next OBR or end-of-message. `timings` is ALWAYS present,
|
|
2935
|
+
* empty when the order carries no TQ1 / legacy embedded TQ.
|
|
2939
2936
|
*
|
|
2940
2937
|
* @example
|
|
2941
2938
|
* ```ts
|
|
@@ -2957,7 +2954,7 @@ interface Order {
|
|
|
2957
2954
|
readonly fillerOrderNumber?: string;
|
|
2958
2955
|
/** OBR-4 universal service identifier (test code + description). */
|
|
2959
2956
|
readonly universalServiceId?: CWE;
|
|
2960
|
-
/** OBR-
|
|
2957
|
+
/** OBR-25 result status (HL7 Table 0123, e.g. `"F"` final, `"P"` preliminary). */
|
|
2961
2958
|
readonly orderStatus?: string;
|
|
2962
2959
|
/** ORC-1 order control when an ORC precedes this OBR. */
|
|
2963
2960
|
readonly orderControl?: string;
|
|
@@ -2966,13 +2963,13 @@ interface Order {
|
|
|
2966
2963
|
/** OBX children grouped under this OBR (D-12 positional grouping). Always present. */
|
|
2967
2964
|
readonly observations: readonly Observation[];
|
|
2968
2965
|
/**
|
|
2969
|
-
* TQ1 / legacy embedded-TQ timing(s) grouped under this order
|
|
2966
|
+
* TQ1 / legacy embedded-TQ timing(s) grouped under this order.
|
|
2970
2967
|
* Always present: empty when the order carries no timing. See
|
|
2971
2968
|
* {@link OrderTiming}.
|
|
2972
2969
|
*/
|
|
2973
2970
|
readonly timings: readonly OrderTiming[];
|
|
2974
2971
|
/**
|
|
2975
|
-
* NTE note lines positionally attached to this order
|
|
2972
|
+
* NTE note lines positionally attached to this order: the
|
|
2976
2973
|
* ORC-region notes (before the OBR) followed by the OBR-region notes, in
|
|
2977
2974
|
* document order. Several ORCs before one OBR all contribute here; nothing is
|
|
2978
2975
|
* dropped. OMITTED when the order carries no notes. A note on a trailing or
|
|
@@ -3008,7 +3005,7 @@ interface NextOfKin {
|
|
|
3008
3005
|
readonly contactRole?: CWE;
|
|
3009
3006
|
}
|
|
3010
3007
|
/**
|
|
3011
|
-
* AL1-derived allergy entry (HELPERS-06).
|
|
3008
|
+
* AL1-derived allergy entry (HELPERS-06). `onsetDate` is the fidelity `TS`.
|
|
3012
3009
|
*
|
|
3013
3010
|
* @example
|
|
3014
3011
|
* ```ts
|
|
@@ -3030,11 +3027,11 @@ interface Allergy {
|
|
|
3030
3027
|
readonly severity?: string;
|
|
3031
3028
|
/** AL1-5 allergy reaction description (first value). */
|
|
3032
3029
|
readonly reaction?: string;
|
|
3033
|
-
/** AL1-6 onset date as the fidelity `TS
|
|
3030
|
+
/** AL1-6 onset date as the fidelity `TS`. */
|
|
3034
3031
|
readonly onsetDate?: TS;
|
|
3035
3032
|
}
|
|
3036
3033
|
/**
|
|
3037
|
-
* DG1-derived diagnosis entry (HELPERS-06).
|
|
3034
|
+
* DG1-derived diagnosis entry (HELPERS-06). `dateTime` is the fidelity `TS`.
|
|
3038
3035
|
*
|
|
3039
3036
|
* @example
|
|
3040
3037
|
* ```ts
|
|
@@ -3051,7 +3048,7 @@ interface Diagnosis {
|
|
|
3051
3048
|
readonly code?: CWE;
|
|
3052
3049
|
/** DG1-4 diagnosis description. */
|
|
3053
3050
|
readonly description?: string;
|
|
3054
|
-
/** DG1-5 diagnosis date/time as the fidelity `TS
|
|
3051
|
+
/** DG1-5 diagnosis date/time as the fidelity `TS`. */
|
|
3055
3052
|
readonly dateTime?: TS;
|
|
3056
3053
|
/** DG1-6 diagnosis type (A=admitting, W=working, F=final). */
|
|
3057
3054
|
readonly type?: string;
|
|
@@ -3059,7 +3056,7 @@ interface Diagnosis {
|
|
|
3059
3056
|
/**
|
|
3060
3057
|
* Which pharmacy/treatment segment a `Medication` was extracted from: the
|
|
3061
3058
|
* clinical "phase" of the medication. Each value maps 1:1 to one RX* parent
|
|
3062
|
-
* segment (
|
|
3059
|
+
* segment (Ch. 4A):
|
|
3063
3060
|
* - `"order"`: **RXO** (Pharmacy/Treatment Order): the originally *requested*
|
|
3064
3061
|
* give code/amount/dosage-form, before pharmacy encoding.
|
|
3065
3062
|
* - `"encoded"`: **RXE** (Encoded Order): the pharmacy-encoded give
|
|
@@ -3076,7 +3073,7 @@ interface Diagnosis {
|
|
|
3076
3073
|
*/
|
|
3077
3074
|
type MedicationContext = "order" | "encoded" | "dispense" | "administration";
|
|
3078
3075
|
/**
|
|
3079
|
-
* The give / dispense / administered amount of a `Medication
|
|
3076
|
+
* The give / dispense / administered amount of a `Medication`.
|
|
3080
3077
|
* Carries the HL7 min/max amount pair and its units.
|
|
3081
3078
|
*
|
|
3082
3079
|
* - For an **order** (RXO-2/3) or **encoded** order (RXE-3/4) the amount is a
|
|
@@ -3106,11 +3103,11 @@ interface MedicationAmount {
|
|
|
3106
3103
|
}
|
|
3107
3104
|
/**
|
|
3108
3105
|
* The give *strength* of an **encoded** `Medication` (RXE-25 value + RXE-26
|
|
3109
|
-
* units)
|
|
3106
|
+
* units). Strength is the concentration of active ingredient (e.g.
|
|
3110
3107
|
* "250 mg"), distinct from the give *amount* (how much is administered, e.g.
|
|
3111
3108
|
* "2 tablets"). Only the `"encoded"` (RXE) context carries strength.
|
|
3112
3109
|
*
|
|
3113
|
-
* **Fail-safe
|
|
3110
|
+
* **Fail-safe:** strength is surfaced exactly as the explicit
|
|
3114
3111
|
* RXE-25/26 fields declare it, and is NEVER reconciled against any strength
|
|
3115
3112
|
* *implied* by the give code (e.g. an NDC that encodes "250 mg"). A consumer
|
|
3116
3113
|
* that sees both an explicit strength here and a coded drug in `giveCode` must
|
|
@@ -3130,8 +3127,8 @@ interface MedicationStrength {
|
|
|
3130
3127
|
readonly units?: CWE;
|
|
3131
3128
|
}
|
|
3132
3129
|
/**
|
|
3133
|
-
* One RXR (Pharmacy/Treatment Route) grouped under its parent RX* segment
|
|
3134
|
-
*
|
|
3130
|
+
* One RXR (Pharmacy/Treatment Route) grouped under its parent RX* segment.
|
|
3131
|
+
* `route` is HL7 Table 0162 (CWE); `site` is Table 0163 (CWE).
|
|
3135
3132
|
* Provenance travels on the CWE (`route.nameOfCodingSystem`): a "PO" route is
|
|
3136
3133
|
* only safe to act on when you know the system it was coded against.
|
|
3137
3134
|
*
|
|
@@ -3149,7 +3146,7 @@ interface MedicationRoute {
|
|
|
3149
3146
|
}
|
|
3150
3147
|
/**
|
|
3151
3148
|
* One RXC (Pharmacy/Treatment Component Order) grouped under its parent RX*
|
|
3152
|
-
* segment
|
|
3149
|
+
* segment: a component of a compound/IV. Surfaced STRUCTURALLY
|
|
3153
3150
|
* (the component list as authored), NOT pharmacologically resolved.
|
|
3154
3151
|
*
|
|
3155
3152
|
* @example
|
|
@@ -3169,8 +3166,8 @@ interface MedicationComponent {
|
|
|
3169
3166
|
readonly units?: CWE;
|
|
3170
3167
|
}
|
|
3171
3168
|
/**
|
|
3172
|
-
* A medication extracted from one RXO/RXE/RXD/RXA segment
|
|
3173
|
-
*
|
|
3169
|
+
* A medication extracted from one RXO/RXE/RXD/RXA segment, with its RXR
|
|
3170
|
+
* (route) and RXC (component) children grouped
|
|
3174
3171
|
* positionally. `context` records which RX* segment this came from (give
|
|
3175
3172
|
* vs dispense vs administered).
|
|
3176
3173
|
*
|
|
@@ -3180,12 +3177,12 @@ interface MedicationComponent {
|
|
|
3180
3177
|
* (`giveCode.nameOfCodingSystem`: e.g. `RXN` RxNorm, `NDC`). The helper
|
|
3181
3178
|
* surfaces the *claim*; it never validates or looks the code up.
|
|
3182
3179
|
* - `amount` (how much) and `strength` (concentration) are SEPARATE fields and
|
|
3183
|
-
* are never reconciled: including against any strength a coded drug
|
|
3184
|
-
*
|
|
3180
|
+
* are never reconciled: including against any strength a coded drug
|
|
3181
|
+
* implies. A disagreement is preserved for the consumer to see.
|
|
3185
3182
|
* - Malformed RX* segments never throw: absent fields are omitted keys.
|
|
3186
3183
|
*
|
|
3187
|
-
* `routes` and `components` are ALWAYS present (possibly empty).
|
|
3188
|
-
* `timings`:
|
|
3184
|
+
* `routes` and `components` are ALWAYS present (possibly empty). So is
|
|
3185
|
+
* `timings`: empty when no TQ1 / legacy embedded TQ (RXE-1)
|
|
3189
3186
|
* accompanies the medication; the repeat pattern is surfaced **verbatim, never
|
|
3190
3187
|
* normalized to a schedule**. Deferred (not v1): sig/frequency *interpretation*,
|
|
3191
3188
|
* dose-range or interaction checking, pharmacologic resolution of compounds.
|
|
@@ -3220,8 +3217,8 @@ interface Medication {
|
|
|
3220
3217
|
/** RXC children grouped under this RX* (compound components). Always present (possibly empty). */
|
|
3221
3218
|
readonly components: readonly MedicationComponent[];
|
|
3222
3219
|
/**
|
|
3223
|
-
* TQ1 / legacy embedded-TQ (RXE-1) timing(s) grouped under this medication
|
|
3224
|
-
*
|
|
3220
|
+
* TQ1 / legacy embedded-TQ (RXE-1) timing(s) grouped under this medication.
|
|
3221
|
+
* Always present: empty when the medication carries no timing.
|
|
3225
3222
|
* See {@link OrderTiming}.
|
|
3226
3223
|
*/
|
|
3227
3224
|
readonly timings: readonly OrderTiming[];
|
|
@@ -3256,9 +3253,9 @@ interface Insurance {
|
|
|
3256
3253
|
readonly groupNumber?: string;
|
|
3257
3254
|
/** IN1-16 insured's name. */
|
|
3258
3255
|
readonly insuredName?: XPN;
|
|
3259
|
-
/** IN1-12 plan effective date as the fidelity `TS
|
|
3256
|
+
/** IN1-12 plan effective date as the fidelity `TS`. */
|
|
3260
3257
|
readonly effectiveDate?: TS;
|
|
3261
|
-
/** IN1-13 plan expiration date as the fidelity `TS
|
|
3258
|
+
/** IN1-13 plan expiration date as the fidelity `TS`. */
|
|
3262
3259
|
readonly expirationDate?: TS;
|
|
3263
3260
|
/** `true` iff an IN2 segment follows this IN1 before the next IN1. */
|
|
3264
3261
|
readonly hasIn2: boolean;
|
|
@@ -3285,7 +3282,7 @@ interface Insurance {
|
|
|
3285
3282
|
type ImmunizationRecordOrigin = "administered" | "historical";
|
|
3286
3283
|
/**
|
|
3287
3284
|
* A vaccine dose extracted from one RXA (Pharmacy/Treatment Administration)
|
|
3288
|
-
* segment of a VXU^V04 immunization message
|
|
3285
|
+
* segment of a VXU^V04 immunization message, with its RXR
|
|
3289
3286
|
* (route/site) and OBX (e.g. VFC eligibility / funding source) children grouped
|
|
3290
3287
|
* positionally under the RXA, and `orderControl` from the preceding ORC of the
|
|
3291
3288
|
* VXU order group (`ORC`→`RXA`→`[RXR]`→`[{OBX}]`).
|
|
@@ -3350,11 +3347,11 @@ interface Immunization {
|
|
|
3350
3347
|
readonly informationSource?: CWE;
|
|
3351
3348
|
/** Derived administered-vs-historical classification from RXA-9.1. See {@link ImmunizationRecordOrigin}. */
|
|
3352
3349
|
readonly recordOrigin?: ImmunizationRecordOrigin;
|
|
3353
|
-
/** RXA-3 date/time start of administration as the fidelity `TS
|
|
3350
|
+
/** RXA-3 date/time start of administration as the fidelity `TS`. */
|
|
3354
3351
|
readonly administeredDateTime?: TS;
|
|
3355
3352
|
/** RXA-15 substance lot number (first repetition). */
|
|
3356
3353
|
readonly lotNumber?: string;
|
|
3357
|
-
/** RXA-16 substance expiration date (first repetition) as the fidelity `TS
|
|
3354
|
+
/** RXA-16 substance expiration date (first repetition) as the fidelity `TS`. */
|
|
3358
3355
|
readonly expirationDate?: TS;
|
|
3359
3356
|
/** RXA-17 substance manufacturer (MVX, HL7 Table 0227; first repetition). */
|
|
3360
3357
|
readonly manufacturer?: CWE;
|
|
@@ -3370,7 +3367,7 @@ interface Immunization {
|
|
|
3370
3367
|
readonly observations: readonly Observation[];
|
|
3371
3368
|
}
|
|
3372
3369
|
/**
|
|
3373
|
-
* One appointment resource grouped under a `SCH
|
|
3370
|
+
* One appointment resource grouped under a `SCH`: an AIS (service),
|
|
3374
3371
|
* AIG (general resource), AIL (location), or AIP (personnel / provider) segment.
|
|
3375
3372
|
* The resource identifier lives at position 3 of every AI* segment; for the
|
|
3376
3373
|
* personnel resource (AIP) it is additionally surfaced as a typed `person`
|
|
@@ -3398,7 +3395,7 @@ interface AppointmentResource {
|
|
|
3398
3395
|
readonly person?: XCN;
|
|
3399
3396
|
}
|
|
3400
3397
|
/**
|
|
3401
|
-
* SCH-derived appointment entry (
|
|
3398
|
+
* SCH-derived appointment entry (SIU scheduling breadth). Surfaces the
|
|
3402
3399
|
* appointment identifiers, filler status (SCH-25, Table 0278), SCH-11 start/end
|
|
3403
3400
|
* timing, and the AI* resource groups. NOT a scheduling-workflow state machine.
|
|
3404
3401
|
*
|
|
@@ -3419,15 +3416,15 @@ interface Appointment {
|
|
|
3419
3416
|
readonly fillerAppointmentId?: string;
|
|
3420
3417
|
/** SCH-25 filler status code (HL7 Table 0278): the appointment status, verbatim/provenance-only. */
|
|
3421
3418
|
readonly fillerStatusCode?: CWE;
|
|
3422
|
-
/** Appointment start date/time: SCH-11 TQ.4 (fidelity `TS
|
|
3419
|
+
/** Appointment start date/time: SCH-11 TQ.4 (fidelity `TS`). */
|
|
3423
3420
|
readonly startDateTime?: TS;
|
|
3424
|
-
/** Appointment end date/time: SCH-11 TQ.5 (fidelity `TS
|
|
3421
|
+
/** Appointment end date/time: SCH-11 TQ.5 (fidelity `TS`). */
|
|
3425
3422
|
readonly endDateTime?: TS;
|
|
3426
3423
|
/** AIS/AIG/AIL/AIP resources grouped under this SCH. Always present (possibly empty). */
|
|
3427
3424
|
readonly resources: readonly AppointmentResource[];
|
|
3428
3425
|
}
|
|
3429
3426
|
/**
|
|
3430
|
-
* TXA-derived clinical-document entry (
|
|
3427
|
+
* TXA-derived clinical-document entry (MDM document breadth). The
|
|
3431
3428
|
* load-bearing safety property: **completion status (TXA-17) and availability
|
|
3432
3429
|
* status (TXA-19) are DISTINCT fields and are never conflated**: a document can
|
|
3433
3430
|
* be *available* before it is *authenticated*, and reading a preliminary
|
|
@@ -3460,7 +3457,7 @@ interface ClinicalDocument {
|
|
|
3460
3457
|
* {@link completionStatus}; verbatim, never validated, never merged.
|
|
3461
3458
|
*/
|
|
3462
3459
|
readonly availabilityStatus?: string;
|
|
3463
|
-
/** TXA-4 activity date/time (fidelity `TS
|
|
3460
|
+
/** TXA-4 activity date/time (fidelity `TS`). */
|
|
3464
3461
|
readonly activityDateTime?: TS;
|
|
3465
3462
|
/** TXA-12 unique document number (EI first component, verbatim). */
|
|
3466
3463
|
readonly uniqueDocumentNumber?: string;
|
|
@@ -3470,7 +3467,7 @@ interface ClinicalDocument {
|
|
|
3470
3467
|
readonly observations: readonly Observation[];
|
|
3471
3468
|
}
|
|
3472
3469
|
/**
|
|
3473
|
-
* FT1-derived charge entry (
|
|
3470
|
+
* FT1-derived charge entry (DFT financial breadth). Billing-critical
|
|
3474
3471
|
* fields surfaced with **no billing logic and no money-as-float**: the
|
|
3475
3472
|
* extended/unit amounts are the verbatim CP wire text, never parsed to a number.
|
|
3476
3473
|
*
|
|
@@ -3486,7 +3483,7 @@ interface ClinicalDocument {
|
|
|
3486
3483
|
* ```
|
|
3487
3484
|
*/
|
|
3488
3485
|
interface Charge {
|
|
3489
|
-
/** FT1-4 transaction date (fidelity `TS
|
|
3486
|
+
/** FT1-4 transaction date (fidelity `TS`). */
|
|
3490
3487
|
readonly transactionDate?: TS;
|
|
3491
3488
|
/** FT1-6 transaction type (HL7 Table 0017: `CG` charge, `CD` credit, `PY` payment, `AJ` adjustment). Verbatim. */
|
|
3492
3489
|
readonly transactionType?: string;
|
|
@@ -3503,7 +3500,7 @@ interface Charge {
|
|
|
3503
3500
|
}
|
|
3504
3501
|
|
|
3505
3502
|
/**
|
|
3506
|
-
* Message-type & structure awareness
|
|
3503
|
+
* Message-type & structure awareness: a conservative
|
|
3507
3504
|
* **misroute / truncation safety net**, NOT an abstract-message-syntax
|
|
3508
3505
|
* validator.
|
|
3509
3506
|
*
|
|
@@ -3640,9 +3637,8 @@ declare function analyzeMessageStructure(messageCode: string, triggerEvent: stri
|
|
|
3640
3637
|
* `Hl7Message`. Mirrors `rawSegments` one-for-one; preserves `isNull`;
|
|
3641
3638
|
* always includes `warnings: []`; omits `profile` when absent.
|
|
3642
3639
|
*
|
|
3643
|
-
*
|
|
3644
|
-
*
|
|
3645
|
-
* `emitJson` function body is filled in Phase 5 Plan 03 (to-json).
|
|
3640
|
+
* `SerializedMessage` is exported from this module and re-exported from
|
|
3641
|
+
* `src/index.ts`, so consumers can reference the type directly.
|
|
3646
3642
|
*
|
|
3647
3643
|
* Decisions:
|
|
3648
3644
|
* - D-17: shape is a raw-tree mirror (encodingCharacters + segments +
|
|
@@ -3703,8 +3699,8 @@ interface SerializedMessage {
|
|
|
3703
3699
|
}
|
|
3704
3700
|
|
|
3705
3701
|
/**
|
|
3706
|
-
* Typed-composite **encoders** for the `@cosyte/hl7` emit path
|
|
3707
|
-
*
|
|
3702
|
+
* Typed-composite **encoders** for the `@cosyte/hl7` emit path: the
|
|
3703
|
+
* conservative-emit mirror of the `src/model/types/*` read parsers.
|
|
3708
3704
|
*
|
|
3709
3705
|
* Each encoder takes one typed composite (an {@link XPN} name, a {@link CX}
|
|
3710
3706
|
* identifier, a {@link TS} timestamp, …) and produces a `RawField` whose
|
|
@@ -3713,7 +3709,7 @@ interface SerializedMessage {
|
|
|
3713
3709
|
*
|
|
3714
3710
|
* - **No delimiter injection.** Component values are stored **decoded** (the
|
|
3715
3711
|
* same surface `parseXxx` returns), and the serializer (`emit-field.ts`)
|
|
3716
|
-
* runs every subcomponent through `reescape` (the
|
|
3712
|
+
* runs every subcomponent through `reescape` (the encode-safe codec)
|
|
3717
3713
|
* on the way out. A `familyName` of `"Smith^Jr"` is therefore emitted as
|
|
3718
3714
|
* `Smith\S\Jr` (one component) and re-parses to the exact string `"Smith^Jr"`,
|
|
3719
3715
|
* never forging a component boundary. The caller never hand-assembles
|
|
@@ -3907,13 +3903,12 @@ declare function encodeCompositeReps<K extends CompositeKind>(kind: K, values: r
|
|
|
3907
3903
|
|
|
3908
3904
|
/**
|
|
3909
3905
|
* `Hl7Message`: the immutable parsed-message model produced by `parseHL7`.
|
|
3910
|
-
*
|
|
3911
|
-
*
|
|
3912
|
-
*
|
|
3913
|
-
*
|
|
3914
|
-
* `
|
|
3915
|
-
*
|
|
3916
|
-
* the typed `segments(type)` method.
|
|
3906
|
+
* A read-only shell over the raw segment tree, plus the read-path traversal
|
|
3907
|
+
* methods (`get`, `getAll`, `segments`, `allSegments`) on top of lazy,
|
|
3908
|
+
* referentially stable Segment/Field caches. `init.segments` is the
|
|
3909
|
+
* parser-side constructor key; the public raw-tree field is exposed as
|
|
3910
|
+
* `rawSegments`, which frees the name `segments` for the typed
|
|
3911
|
+
* `segments(type)` method.
|
|
3917
3912
|
*/
|
|
3918
3913
|
|
|
3919
3914
|
/**
|
|
@@ -3928,8 +3923,8 @@ declare function encodeCompositeReps<K extends CompositeKind>(kind: K, values: r
|
|
|
3928
3923
|
* descriptor. This matches the `Hl7Message.profile` public field shape
|
|
3929
3924
|
* (`... | undefined`).
|
|
3930
3925
|
*
|
|
3931
|
-
* The init key is
|
|
3932
|
-
*
|
|
3926
|
+
* The init key is named `segments` (not `rawSegments`) so parser code that
|
|
3927
|
+
* constructs `Hl7Message` does not need to change. Inside
|
|
3933
3928
|
* the class body the raw tree is stored on `this.rawSegments`.
|
|
3934
3929
|
*
|
|
3935
3930
|
* @internal
|
|
@@ -3965,10 +3960,10 @@ interface Hl7MessageInit {
|
|
|
3965
3960
|
*
|
|
3966
3961
|
* @remarks
|
|
3967
3962
|
* The `warnings` array is frozen at the model boundary so downstream
|
|
3968
|
-
* traversal and
|
|
3969
|
-
* field is populated
|
|
3970
|
-
*
|
|
3971
|
-
*
|
|
3963
|
+
* traversal and helpers cannot mutate parser output. The `profile`
|
|
3964
|
+
* field is populated when a profile is passed, and is `undefined`
|
|
3965
|
+
* otherwise. Segment/Field wrappers are cached per-message and
|
|
3966
|
+
* invalidated wholesale by the mutation methods.
|
|
3972
3967
|
*
|
|
3973
3968
|
* @example
|
|
3974
3969
|
* ```ts
|
|
@@ -3986,8 +3981,7 @@ declare class Hl7Message {
|
|
|
3986
3981
|
* Raw positional tree produced by the parser. 1-indexed per HL7 convention
|
|
3987
3982
|
* (`fields[0]` is the segment-name / MSH separator placeholder slot). Use
|
|
3988
3983
|
* `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).
|
|
3984
|
+
* is exposed for advanced callers that need the raw tree directly.
|
|
3991
3985
|
*/
|
|
3992
3986
|
readonly rawSegments: readonly RawSegment[];
|
|
3993
3987
|
readonly encodingCharacters: EncodingCharacters;
|
|
@@ -4006,7 +4000,7 @@ declare class Hl7Message {
|
|
|
4006
4000
|
readonly dateFormats: readonly string[];
|
|
4007
4001
|
/**
|
|
4008
4002
|
* Merged `customSegments` map from the applied profile, stored so
|
|
4009
|
-
* `allSegments()` can hand per-segment
|
|
4003
|
+
* `allSegments()` can hand per-segment portions to `Segment` constructors
|
|
4010
4004
|
* (D-16). Undefined when no profile was applied.
|
|
4011
4005
|
* @internal
|
|
4012
4006
|
*/
|
|
@@ -4015,40 +4009,40 @@ declare class Hl7Message {
|
|
|
4015
4009
|
* Lazily built cache of Segment wrappers keyed by segment type. Built on
|
|
4016
4010
|
* first `segments(type)` call and filtered from `_allSegments` so
|
|
4017
4011
|
* individual Segment instances are identical across both caches (D-11).
|
|
4018
|
-
*
|
|
4012
|
+
* The mutation methods drop this cache wholesale.
|
|
4019
4013
|
* @internal
|
|
4020
4014
|
*/
|
|
4021
4015
|
private _segmentsByType;
|
|
4022
4016
|
/**
|
|
4023
4017
|
* Lazily built cache of every Segment wrapper in document order. Built on
|
|
4024
|
-
* first `segments(type)` / `allSegments()` call.
|
|
4018
|
+
* first `segments(type)` / `allSegments()` call. The mutation methods
|
|
4025
4019
|
* drop this cache wholesale.
|
|
4026
4020
|
* @internal
|
|
4027
4021
|
*/
|
|
4028
4022
|
private _allSegments;
|
|
4029
4023
|
/**
|
|
4030
|
-
* Lazily built `Meta` view (
|
|
4024
|
+
* Lazily built `Meta` view (memoized). Dropped wholesale
|
|
4031
4025
|
* by `invalidateCaches`. `Meta` is always defined (D-03: MSH absence
|
|
4032
4026
|
* throws `NO_MSH_SEGMENT` at parse time) so no null-sentinel is needed.
|
|
4033
4027
|
* @internal
|
|
4034
4028
|
*/
|
|
4035
4029
|
private _meta;
|
|
4036
4030
|
/**
|
|
4037
|
-
* Lazily built `MessageStructure` view
|
|
4031
|
+
* Lazily built `MessageStructure` view. Dropped wholesale by
|
|
4038
4032
|
* `invalidateCaches`. Always defined: `analyzeMessageStructure` returns an
|
|
4039
4033
|
* `recognized: false` summary for unmodelled types rather than absence.
|
|
4040
4034
|
* @internal
|
|
4041
4035
|
*/
|
|
4042
4036
|
private _structure;
|
|
4043
4037
|
/**
|
|
4044
|
-
* Lazily built `Patient | undefined` view (
|
|
4038
|
+
* Lazily built `Patient | undefined` view (memoized). Uses
|
|
4045
4039
|
* a null-sentinel cache because `undefined` means "not yet computed" while
|
|
4046
4040
|
* `null` means "computed, absent". D-04: no PID → public value `undefined`.
|
|
4047
4041
|
* @internal
|
|
4048
4042
|
*/
|
|
4049
4043
|
private _patient;
|
|
4050
4044
|
/**
|
|
4051
|
-
* Lazily built `Visit | undefined` view (
|
|
4045
|
+
* Lazily built `Visit | undefined` view (memoized). Same
|
|
4052
4046
|
* null-sentinel convention as `_patient`. HELPERS-03: no PV1 → public
|
|
4053
4047
|
* value `undefined`.
|
|
4054
4048
|
* @internal
|
|
@@ -4064,8 +4058,8 @@ declare class Hl7Message {
|
|
|
4064
4058
|
constructor(init: Hl7MessageInit);
|
|
4065
4059
|
/**
|
|
4066
4060
|
* 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
|
-
*
|
|
4061
|
+
* decoded leaf string (unescaped once at parse: never re-unescaped on
|
|
4062
|
+
* read). Returns `undefined` when the path doesn't
|
|
4069
4063
|
* resolve: never throws on missing path (MODEL-05). Throws `TypeError`
|
|
4070
4064
|
* on malformed path syntax (e.g. `"pid.5"`, empty string).
|
|
4071
4065
|
*
|
|
@@ -4096,7 +4090,7 @@ declare class Hl7Message {
|
|
|
4096
4090
|
* Return the cached array of `Segment` wrappers for `segmentType` in
|
|
4097
4091
|
* document order. The returned array identity and the individual Segment
|
|
4098
4092
|
* instances are both stable across calls (D-11). Invalidated wholesale
|
|
4099
|
-
* by
|
|
4093
|
+
* by the mutation methods.
|
|
4100
4094
|
*
|
|
4101
4095
|
* @example
|
|
4102
4096
|
* ```ts
|
|
@@ -4109,7 +4103,7 @@ declare class Hl7Message {
|
|
|
4109
4103
|
* Iterate every `Segment` in document order (MSH first, then every
|
|
4110
4104
|
* subsequent segment). Cached per-message; same array reference and same
|
|
4111
4105
|
* Segment instances on repeat calls (D-11). Invalidated wholesale by
|
|
4112
|
-
*
|
|
4106
|
+
* the mutation methods.
|
|
4113
4107
|
*
|
|
4114
4108
|
* @example
|
|
4115
4109
|
* ```ts
|
|
@@ -4128,14 +4122,14 @@ declare class Hl7Message {
|
|
|
4128
4122
|
* @example
|
|
4129
4123
|
* ```ts
|
|
4130
4124
|
* console.log(msg.meta.type); // "ADT^A01"
|
|
4131
|
-
* console.log(msg.meta.timestamp?.raw); // fidelity TS
|
|
4125
|
+
* console.log(msg.meta.timestamp?.raw); // fidelity TS
|
|
4132
4126
|
* console.log(msg.meta.controlId); // "MSG001"
|
|
4133
4127
|
* ```
|
|
4134
4128
|
*/
|
|
4135
4129
|
get meta(): Meta;
|
|
4136
4130
|
/**
|
|
4137
|
-
* Structural-conformance summary for the common message types
|
|
4138
|
-
*
|
|
4131
|
+
* Structural-conformance summary for the common message types: a
|
|
4132
|
+
* misroute/truncation safety net, NOT a conformance validator.
|
|
4139
4133
|
* Reports, per the message's recognized (MSH-9.1, MSH-9.2) type, which
|
|
4140
4134
|
* Required segment groups are present and which are entirely absent
|
|
4141
4135
|
* (`missingGroups`: the same set the parser flags as
|
|
@@ -4189,7 +4183,7 @@ declare class Hl7Message {
|
|
|
4189
4183
|
observations(): readonly Observation[];
|
|
4190
4184
|
/**
|
|
4191
4185
|
* Every OBR as an Order with its OBX children grouped positionally (D-12) and
|
|
4192
|
-
* its TQ1 / legacy embedded-TQ (ORC-7) `timings` (
|
|
4186
|
+
* its TQ1 / legacy embedded-TQ (ORC-7) `timings` (the repeat pattern is
|
|
4193
4187
|
* surfaced verbatim, never resolved to a schedule). D-05: returns `[]` when no
|
|
4194
4188
|
* OBR present. D-06: not memoized.
|
|
4195
4189
|
*
|
|
@@ -4203,7 +4197,7 @@ declare class Hl7Message {
|
|
|
4203
4197
|
*/
|
|
4204
4198
|
orders(): readonly Order[];
|
|
4205
4199
|
/**
|
|
4206
|
-
* Message-level NTE notes
|
|
4200
|
+
* Message-level NTE notes: every NTE segment with no recognized
|
|
4207
4201
|
* preceding parent (not immediately following a `PID`, `ORC`, `OBR`, or
|
|
4208
4202
|
* `OBX`), surfaced verbatim in document order so nothing is dropped. Notes
|
|
4209
4203
|
* that DO attach to a specific patient / order / result are exposed on those
|
|
@@ -4218,7 +4212,7 @@ declare class Hl7Message {
|
|
|
4218
4212
|
notes(): readonly string[];
|
|
4219
4213
|
/**
|
|
4220
4214
|
* Every recognized ADT patient-identity event (merge / move / link /
|
|
4221
|
-
* unlink / person add/update
|
|
4215
|
+
* unlink / person add/update), with the MRG-sourced
|
|
4222
4216
|
* `prior` and PID/PV1-sourced `surviving` parties labelled by role and the
|
|
4223
4217
|
* spec-constant `direction: "MRG_TO_PID"` on merge/move events. Returns
|
|
4224
4218
|
* `[]` when the trigger event is not in the identity family. D-06: not
|
|
@@ -4237,13 +4231,13 @@ declare class Hl7Message {
|
|
|
4237
4231
|
identityEvents(): readonly IdentityEvent[];
|
|
4238
4232
|
/**
|
|
4239
4233
|
* 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
|
-
*
|
|
4234
|
+
* (component) segments grouped positionally under their parent. D-05:
|
|
4235
|
+
* returns `[]` when no RX* parent present. D-06: not memoized. The give
|
|
4236
|
+
* *amount* and give *strength* are surfaced separately and never
|
|
4237
|
+
* reconciled.
|
|
4244
4238
|
*
|
|
4245
4239
|
* Each medication also carries its TQ1 / legacy embedded-TQ (RXE-1) `timings`
|
|
4246
|
-
* (
|
|
4240
|
+
* (repeat pattern verbatim, never resolved to a schedule).
|
|
4247
4241
|
*
|
|
4248
4242
|
* @example
|
|
4249
4243
|
* ```ts
|
|
@@ -4258,7 +4252,7 @@ declare class Hl7Message {
|
|
|
4258
4252
|
/**
|
|
4259
4253
|
* Every RXA of a VXU^V04 as a typed `Immunization`, with RXR (route/site)
|
|
4260
4254
|
* and OBX children grouped positionally under the RXA and `orderControl`
|
|
4261
|
-
* from the preceding ORC of the VXU order group
|
|
4255
|
+
* from the preceding ORC of the VXU order group. D-05:
|
|
4262
4256
|
* returns `[]` when no RXA present. D-06: not memoized. The vaccine code
|
|
4263
4257
|
* carries its own provenance; the action code (RXA-21) is surfaced verbatim
|
|
4264
4258
|
* and `recordOrigin` (administered vs historical) is derived only from the
|
|
@@ -4316,7 +4310,7 @@ declare class Hl7Message {
|
|
|
4316
4310
|
*/
|
|
4317
4311
|
insurance(): readonly Insurance[];
|
|
4318
4312
|
/**
|
|
4319
|
-
* Every SCH of an SIU message as a typed `Appointment
|
|
4313
|
+
* Every SCH of an SIU message as a typed `Appointment`, with
|
|
4320
4314
|
* the AIS/AIG/AIL/AIP resource segments that follow it grouped positionally
|
|
4321
4315
|
* under that SCH. Surfaces the placer/filler appointment ids, SCH-25 filler
|
|
4322
4316
|
* status (Table 0278), SCH-11 start/end timing, and the resource groups
|
|
@@ -4334,7 +4328,7 @@ declare class Hl7Message {
|
|
|
4334
4328
|
*/
|
|
4335
4329
|
appointments(): readonly Appointment[];
|
|
4336
4330
|
/**
|
|
4337
|
-
* Every TXA of an MDM message as a typed `ClinicalDocument
|
|
4331
|
+
* Every TXA of an MDM message as a typed `ClinicalDocument`,
|
|
4338
4332
|
* with the OBX narrative body grouped positionally under that TXA. The
|
|
4339
4333
|
* completion status (TXA-17) and availability status (TXA-19) are surfaced as
|
|
4340
4334
|
* **distinct** fields and never conflated: a document can be available before
|
|
@@ -4352,7 +4346,7 @@ declare class Hl7Message {
|
|
|
4352
4346
|
*/
|
|
4353
4347
|
documents(): readonly ClinicalDocument[];
|
|
4354
4348
|
/**
|
|
4355
|
-
* Every FT1 of a DFT message as a typed `Charge
|
|
4349
|
+
* Every FT1 of a DFT message as a typed `Charge`, one per
|
|
4356
4350
|
* FT1 in document order. Surfaces billing-critical fields (FT1-6 transaction
|
|
4357
4351
|
* type, FT1-7 code, FT1-11/12 extended/unit amount, FT1-19 diagnosis linkage)
|
|
4358
4352
|
* with **no billing logic and no money-as-float**: amounts are the verbatim
|
|
@@ -4438,7 +4432,7 @@ declare class Hl7Message {
|
|
|
4438
4432
|
* `TypeError` with an actionable message otherwise).
|
|
4439
4433
|
*
|
|
4440
4434
|
* The value is accepted verbatim: unescaped delimiter characters are NOT
|
|
4441
|
-
* rejected on input (D-18). Re-escaping
|
|
4435
|
+
* rejected on input (D-18). Re-escaping is the serializer's concern.
|
|
4442
4436
|
*
|
|
4443
4437
|
* MSH-1 / MSH-2 follow the user-facing HL7 convention: `setField("MSH.3", ...)`
|
|
4444
4438
|
* targets MSH-3 (sending application), matching `msg.get("MSH.3")`.
|
|
@@ -4455,11 +4449,11 @@ declare class Hl7Message {
|
|
|
4455
4449
|
*/
|
|
4456
4450
|
setField(path: string, value: string): this;
|
|
4457
4451
|
/**
|
|
4458
|
-
* Set a **typed composite** at a field (or field-repetition) dot-path
|
|
4459
|
-
*
|
|
4452
|
+
* Set a **typed composite** at a field (or field-repetition) dot-path:
|
|
4453
|
+
* the conservative-emit mirror of the typed read accessors
|
|
4460
4454
|
* (`asXpn`/`asCx`/…). The caller passes a structured value (an XPN name, a CX
|
|
4461
4455
|
* identifier, a TS timestamp, …) by its {@link CompositeKind}, and the setter
|
|
4462
|
-
* encodes it into a spec-clean field using the
|
|
4456
|
+
* encodes it into a spec-clean field using the encode-safe path: any
|
|
4463
4457
|
* delimiter embedded in a component value is **escaped, never injected**, so
|
|
4464
4458
|
* a `familyName` of `"Smith^Jr"` re-parses to exactly that string rather than
|
|
4465
4459
|
* forging a component boundary. No hand-assembly of `^`/`&`/`~`.
|
|
@@ -4533,8 +4527,8 @@ declare class Hl7Message {
|
|
|
4533
4527
|
readonly all?: boolean;
|
|
4534
4528
|
}): this;
|
|
4535
4529
|
/**
|
|
4536
|
-
* Drop every wrapper AND helper cache wholesale (
|
|
4537
|
-
*
|
|
4530
|
+
* Drop every wrapper AND helper cache wholesale (D-17 + D-02). Called by
|
|
4531
|
+
* every mutation method so subsequent `segments(type)` /
|
|
4538
4532
|
* `allSegments()` / `meta` / `patient` / `visit` reads rebuild from the
|
|
4539
4533
|
* mutated `rawSegments` tree.
|
|
4540
4534
|
* @internal
|
|
@@ -4594,9 +4588,8 @@ declare function parseHL7(raw: string | Buffer, options: ParseOptions): Hl7Messa
|
|
|
4594
4588
|
* severe is a Tier-2 warning (see `./warnings.ts`). `Hl7ParseError` is
|
|
4595
4589
|
* thrown directly; consumers narrow via the `code` discriminant.
|
|
4596
4590
|
*
|
|
4597
|
-
* `ProfileDefinitionError` is declared here so the error taxonomy
|
|
4598
|
-
*
|
|
4599
|
-
* across phases.
|
|
4591
|
+
* `ProfileDefinitionError` is declared here so the whole error taxonomy
|
|
4592
|
+
* lives in one module.
|
|
4600
4593
|
*/
|
|
4601
4594
|
|
|
4602
4595
|
/**
|
|
@@ -4682,12 +4675,11 @@ declare class Hl7ParseError extends Error {
|
|
|
4682
4675
|
constructor(code: FatalCode, message: string, position: Hl7Position, snippet: string);
|
|
4683
4676
|
}
|
|
4684
4677
|
/**
|
|
4685
|
-
* Thrown by `defineProfile()` and profile-validation code
|
|
4678
|
+
* Thrown by `defineProfile()` and profile-validation code when a
|
|
4686
4679
|
* profile definition is structurally invalid: e.g. references an undefined
|
|
4687
4680
|
* parent, declares a malformed custom segment, or includes an unsupported
|
|
4688
|
-
* date format.
|
|
4689
|
-
*
|
|
4690
|
-
* for better diagnostics.
|
|
4681
|
+
* date format. Callers may optionally supply the offending profile name for
|
|
4682
|
+
* better diagnostics.
|
|
4691
4683
|
*
|
|
4692
4684
|
* @example
|
|
4693
4685
|
* ```ts
|
|
@@ -4702,7 +4694,7 @@ declare class ProfileDefinitionError extends Error {
|
|
|
4702
4694
|
readonly profileName: string | undefined;
|
|
4703
4695
|
/**
|
|
4704
4696
|
* Construct a new `ProfileDefinitionError`. `profileName` is optional so
|
|
4705
|
-
*
|
|
4697
|
+
* callers may omit it when the offending profile cannot be named
|
|
4706
4698
|
* (e.g. during initial validation before a name is parsed).
|
|
4707
4699
|
*
|
|
4708
4700
|
* @internal
|
|
@@ -4712,12 +4704,12 @@ declare class ProfileDefinitionError extends Error {
|
|
|
4712
4704
|
|
|
4713
4705
|
/**
|
|
4714
4706
|
* HL7 v2 **Table 0211 (Alternate Character Sets)** resolution for the parser's
|
|
4715
|
-
* `Buffer`-decode stage
|
|
4707
|
+
* `Buffer`-decode stage. Mirrors the frozen read-only registries
|
|
4716
4708
|
* `KNOWN_SEGMENTS` / `KNOWN_CODING_SYSTEMS`: a single source of truth mapping an
|
|
4717
4709
|
* MSH-18 character-set code to how the parser treats it: **decode** (single-byte
|
|
4718
4710
|
* ISO-8859 family + Unicode UTF-8) or **preserve-verbatim** (the multibyte /
|
|
4719
4711
|
* ISO-2022-switched East-Asian sets and UTF-16/32, which HL7 renders through
|
|
4720
|
-
* stateful `\Mxxyyzz\` escapes
|
|
4712
|
+
* stateful `\Mxxyyzz\` escapes the parser deliberately does not fully decode).
|
|
4721
4713
|
*
|
|
4722
4714
|
* Spec traceability: HL7 v2 Chapter 2, **MSH-18** (item 00692) + **Table 0211**
|
|
4723
4715
|
* (OID 2.16.840.1.113883.18.116). MSH-18 is **repeating**: the first occurrence
|
|
@@ -4928,7 +4920,7 @@ declare function reescape(input: string, enc: EncodingCharacters): string;
|
|
|
4928
4920
|
* escapes preserved verbatim), with no warning plumbing to wire up.
|
|
4929
4921
|
* - {@link encodeText} is the **encode-safe** direction: an arbitrary string in,
|
|
4930
4922
|
* a spec-clean field body out that can **never inject a delimiter or forge a
|
|
4931
|
-
* component boundary**. This is the primitive
|
|
4923
|
+
* component boundary**. This is the primitive the typed emit path builds on.
|
|
4932
4924
|
*
|
|
4933
4925
|
* For a human-readable rendering (formatting commands → whitespace, highlight
|
|
4934
4926
|
* dropped), use {@link renderText} instead of {@link decodeText}.
|
|
@@ -5005,7 +4997,7 @@ declare function encodeText(input: string, enc?: EncodingCharacters): string;
|
|
|
5005
4997
|
*
|
|
5006
4998
|
* - `text.decode(field.text)`: resolve delimiter/hex/`\.br\` escapes to a value;
|
|
5007
4999
|
* - `text.render(field.text)`: normalize formatting + highlight to a display model;
|
|
5008
|
-
* - `text.encode(anyString)`: encode-safe: no delimiter injection
|
|
5000
|
+
* - `text.encode(anyString)`: encode-safe: no delimiter injection.
|
|
5009
5001
|
*
|
|
5010
5002
|
* ```ts
|
|
5011
5003
|
* import { text } from "@cosyte/hl7";
|
|
@@ -5029,17 +5021,17 @@ declare namespace index$1 {
|
|
|
5029
5021
|
* `undefined` on missing path). Zero runtime deps: a hand-rolled linear scan
|
|
5030
5022
|
* (analog: `src/parser/dates.ts::matchTokenFormat`).
|
|
5031
5023
|
*
|
|
5032
|
-
* Indexing conventions
|
|
5024
|
+
* Indexing conventions:
|
|
5033
5025
|
* - `[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
|
|
5026
|
+
* - Dot-numbers are ALWAYS 1-indexed: matches HL7 spec and the 1-indexed
|
|
5035
5027
|
* `RawSegment.fields` (D-02). `PID.5` → `fields[5]`.
|
|
5036
5028
|
* - MSH.1 / MSH.2 are the separator char and encoding-chars string, both
|
|
5037
|
-
* stored at `fields[0]` / `fields[1]` by
|
|
5029
|
+
* stored at `fields[0]` / `fields[1]` by tokenize.ts (D-05).
|
|
5038
5030
|
* - Missing subcomponent on a single-sub component returns the component
|
|
5039
5031
|
* string (depth-collapse, D-04).
|
|
5040
5032
|
* - Leaf reads return the subcomponent verbatim: the tokenizer (parser-02)
|
|
5041
5033
|
* already unescaped it once on parse, so the stored value is decoded and a
|
|
5042
|
-
* second `unescape` here would double-decode it
|
|
5034
|
+
* second `unescape` here would double-decode it.
|
|
5043
5035
|
*/
|
|
5044
5036
|
|
|
5045
5037
|
/**
|
|
@@ -5134,7 +5126,7 @@ declare namespace namespace {
|
|
|
5134
5126
|
|
|
5135
5127
|
/**
|
|
5136
5128
|
* `pickMrn`: pick the Medical Record Number string from a PID-3 identifier
|
|
5137
|
-
* list. Isolated from `patient.ts` so
|
|
5129
|
+
* list. Isolated from `patient.ts` so a profile hook can substitute
|
|
5138
5130
|
* a profile-aware variant without patching the helper that calls it.
|
|
5139
5131
|
*
|
|
5140
5132
|
* Silent (D-21: helpers emit no warnings). Never throws (D-22).
|
|
@@ -5177,12 +5169,11 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5177
5169
|
* `buildMessage`: top-level outbound factory for the `@cosyte/hl7`
|
|
5178
5170
|
* package. Synthesizes a complete MSH `RawSegment` from `BuildMessageInit`
|
|
5179
5171
|
* and returns a real `Hl7Message` (not a builder subtype). Callers chain
|
|
5180
|
-
* `.addSegment(...)` (
|
|
5172
|
+
* `.addSegment(...)` (mutation method) to append PID,
|
|
5181
5173
|
* OBX, etc. Symmetric with `parseHL7` (D-09).
|
|
5182
5174
|
*
|
|
5183
|
-
*
|
|
5184
|
-
*
|
|
5185
|
-
* `buildMessage` function body is filled in Phase 5 Plan 05 (build-message).
|
|
5175
|
+
* `BuildMessageInit` is exported from this module and re-exported from
|
|
5176
|
+
* `src/index.ts`, so consumers can reference the type directly.
|
|
5186
5177
|
*
|
|
5187
5178
|
* Decisions:
|
|
5188
5179
|
* - D-09: top-level named export from `src/index.ts`.
|
|
@@ -5193,8 +5184,8 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5193
5184
|
* - D-13: `timestamp` accepts `Date | string`; `Date` formats to
|
|
5194
5185
|
* `YYYYMMDDHHmmss` UTC.
|
|
5195
5186
|
* - D-14: encoding chars always `DEFAULT_ENCODING_CHARACTERS`.
|
|
5196
|
-
* - D-15: subsequent `.addSegment(name, fields)`
|
|
5197
|
-
*
|
|
5187
|
+
* - D-15: subsequent `.addSegment(name, fields)` takes `readonly string[]`
|
|
5188
|
+
* field input.
|
|
5198
5189
|
* - D-16: missing/empty `type` throws `TypeError`.
|
|
5199
5190
|
*
|
|
5200
5191
|
* **Absent vs. explicit null at the wire level:** at the HL7 wire level,
|
|
@@ -5202,7 +5193,7 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5202
5193
|
* (both emit as absent: `||` in the line). If you need to distinguish
|
|
5203
5194
|
* "explicitly null" (HL7 `""`) from "absent" in an outbound message, use
|
|
5204
5195
|
* `buildMessage({...}).setField(path, '""')` after construction: the
|
|
5205
|
-
*
|
|
5196
|
+
* `setField` mutation method sets `RawField.isNull = true`, which
|
|
5206
5197
|
* the emitter preserves as the literal two-char string `""` per D-02.
|
|
5207
5198
|
*/
|
|
5208
5199
|
|
|
@@ -5216,7 +5207,7 @@ declare function pickMrn(identifiers: readonly CX[]): string | undefined;
|
|
|
5216
5207
|
* empty string produce IDENTICAL wire output (both emit as an absent
|
|
5217
5208
|
* positional field). To emit an HL7 explicit null (`""`) at a specific
|
|
5218
5209
|
* position in an outbound message, build the message first and then call
|
|
5219
|
-
* `.setField(path, '""')`: the
|
|
5210
|
+
* `.setField(path, '""')`: the mutation method sets `isNull=true`
|
|
5220
5211
|
* on the underlying `RawField`, and the emitter preserves that as the
|
|
5221
5212
|
* literal two-char output per D-02.
|
|
5222
5213
|
*
|
|
@@ -5276,7 +5267,7 @@ interface BuildMessageInit {
|
|
|
5276
5267
|
* Construct an outbound `Hl7Message` from semantic MSH fields (SER-06).
|
|
5277
5268
|
* Synthesises a complete MSH `RawSegment` per D-10/D-11 and hands to
|
|
5278
5269
|
* `new Hl7Message({...})`. Callers chain `.addSegment(name, fields)`
|
|
5279
|
-
* (
|
|
5270
|
+
* (mutation method) to append PID, OBX, etc.
|
|
5280
5271
|
*
|
|
5281
5272
|
* Defaults applied when fields are omitted (D-10):
|
|
5282
5273
|
* - `controlId` → `generateControlId()` (D-12)
|
|
@@ -5300,9 +5291,7 @@ interface BuildMessageInit {
|
|
|
5300
5291
|
* // msg.toString() now emits MSH-3 as `""` (2 chars), not as absent.
|
|
5301
5292
|
* ```
|
|
5302
5293
|
*
|
|
5303
|
-
*
|
|
5304
|
-
* the input shape; this function-level doc reinforces it for developers
|
|
5305
|
-
* who land on the impl.
|
|
5294
|
+
* `BuildMessageInit` carries the same note on the input shape.
|
|
5306
5295
|
*
|
|
5307
5296
|
* @example
|
|
5308
5297
|
* ```ts
|
|
@@ -5324,7 +5313,7 @@ declare function buildMessage(init: BuildMessageInit): Hl7Message;
|
|
|
5324
5313
|
|
|
5325
5314
|
/**
|
|
5326
5315
|
* Shared field/segment assembly primitives for the typed builders
|
|
5327
|
-
* (`buildAdt`/`buildOru
|
|
5316
|
+
* (`buildAdt`/`buildOru`). Centralises the MSH synthesis and
|
|
5328
5317
|
* the sparse positional-segment assembly so each builder stays declarative and
|
|
5329
5318
|
* every builder emits an identical, spec-clean MSH.
|
|
5330
5319
|
*
|
|
@@ -5356,11 +5345,11 @@ interface MessageEnvelope {
|
|
|
5356
5345
|
|
|
5357
5346
|
/**
|
|
5358
5347
|
* `buildAdt`: author a spec-clean HL7 v2 **ADT** (admit/discharge/transfer)
|
|
5359
|
-
* message from typed inputs
|
|
5348
|
+
* message from typed inputs. The conservative-emit mirror of
|
|
5360
5349
|
* the read helpers (`msg.patient`, `msg.visit`): a caller supplies structured
|
|
5361
5350
|
* values (an {@link XPN} name, {@link CX} identifiers, a {@link TS} birth date,
|
|
5362
5351
|
* a {@link PL} location, …) and `buildAdt` assembles `MSH + EVN + PID + PV1`
|
|
5363
|
-
* with correct `^`/`&`/`~` structure via the
|
|
5352
|
+
* with correct `^`/`&`/`~` structure via the encode-safe path: never
|
|
5364
5353
|
* hand-assembling delimiters, never injecting one.
|
|
5365
5354
|
*
|
|
5366
5355
|
* **Structurally complete + zero-warning.** The emitted message carries the
|
|
@@ -5467,11 +5456,11 @@ declare function buildAdt(event: string, init: BuildAdtInit): Hl7Message;
|
|
|
5467
5456
|
|
|
5468
5457
|
/**
|
|
5469
5458
|
* `buildOru`: author a spec-clean HL7 v2 **ORU^R01** (observation result)
|
|
5470
|
-
* message from typed inputs
|
|
5459
|
+
* message from typed inputs. The conservative-emit mirror of
|
|
5471
5460
|
* the read helpers (`msg.orders`, `msg.observations`): a caller supplies a
|
|
5472
5461
|
* typed patient, an optional order (OBR), and one or more typed observations
|
|
5473
5462
|
* (OBX), and `buildOru` assembles `MSH + PID + OBR + OBX…` with correct
|
|
5474
|
-
* `^`/`&`/`~` structure via the
|
|
5463
|
+
* `^`/`&`/`~` structure via the encode-safe path.
|
|
5475
5464
|
*
|
|
5476
5465
|
* **Structurally complete + zero-warning.** The emitted message carries the
|
|
5477
5466
|
* ORU^R01 result group the parser's structure net marks Required (OBR/OBX), so
|
|
@@ -5573,7 +5562,7 @@ interface BuildOruInit extends MessageEnvelope {
|
|
|
5573
5562
|
declare function buildOru(init: BuildOruInit): Hl7Message;
|
|
5574
5563
|
|
|
5575
5564
|
/**
|
|
5576
|
-
* Frozen HL7 control-vocabulary tables for ACK generation
|
|
5565
|
+
* Frozen HL7 control-vocabulary tables for ACK generation. These
|
|
5577
5566
|
* are read-only enums sourced from the HL7 v2 standard: `@cosyte/hl7` is the
|
|
5578
5567
|
* single owner of this vocabulary; siblings (notably `@cosyte/mllp`) consume
|
|
5579
5568
|
* `buildAck` rather than re-declaring these codes.
|
|
@@ -5711,7 +5700,7 @@ type AckMode = "original" | "enhanced";
|
|
|
5711
5700
|
|
|
5712
5701
|
/**
|
|
5713
5702
|
* `buildAck`: generate a spec-clean HL7 v2 acknowledgment (ACK) message from
|
|
5714
|
-
* an inbound message
|
|
5703
|
+
* an inbound message. The boundary with `@cosyte/mllp` is resolved
|
|
5715
5704
|
* (hl7 roadmap §10.1): **hl7 owns ACK *content*** (this file + the control
|
|
5716
5705
|
* tables); mllp owns *policy/timing* (the commit contract) and *framing*.
|
|
5717
5706
|
*
|
|
@@ -5814,7 +5803,7 @@ declare function detectAckMode(inbound: Hl7Message): AckMode;
|
|
|
5814
5803
|
* - **MSA**: MSA-1 = `code`; **MSA-2 echoes the full inbound MSH-10 field**
|
|
5815
5804
|
* (the raw field structure is carried over whole: a vendor-quirk id like
|
|
5816
5805
|
* `ID^X` is never truncated to its first component). The echo carries the
|
|
5817
|
-
* inbound field's escape-fidelity overlay
|
|
5806
|
+
* inbound field's escape-fidelity overlay, so an id bearing a hex
|
|
5818
5807
|
* escape (`ID\X41\Q`) or a preserved escape (`\H\`) echoes **byte-verbatim**,
|
|
5819
5808
|
* not canonicalized: exactly the bytes the sender put on the wire, which is
|
|
5820
5809
|
* what MSA-2 correlation compares. The only structural transform is
|
|
@@ -5829,7 +5818,7 @@ declare function detectAckMode(inbound: Hl7Message): AckMode;
|
|
|
5829
5818
|
* (when given), ERR-3 the Table 0357 condition code as a CWE
|
|
5830
5819
|
* (`code^text^HL70357`), ERR-4 the Table 0516 severity.
|
|
5831
5820
|
*
|
|
5832
|
-
* **Fail-safe
|
|
5821
|
+
* **Fail-safe.** If the inbound message has no MSH-10, the
|
|
5833
5822
|
* ACK cannot be correlated. `buildAck` then leaves MSA-2 empty and, if a
|
|
5834
5823
|
* positive accept (`AA`/`CA`) was requested, **downgrades it** to the matching
|
|
5835
5824
|
* error code (`AE`/`CE`): it never fabricates an unverifiable positive ACK.
|
|
@@ -5852,8 +5841,8 @@ declare function buildAck(inbound: Hl7Message, options: BuildAckOptions): Hl7Mes
|
|
|
5852
5841
|
|
|
5853
5842
|
/**
|
|
5854
5843
|
* `interpretAck`: read-side helper that interprets an inbound HL7 v2
|
|
5855
|
-
* acknowledgment (ACK) message into a typed {@link Acknowledgment} view
|
|
5856
|
-
*
|
|
5844
|
+
* acknowledgment (ACK) message into a typed {@link Acknowledgment} view.
|
|
5845
|
+
* The mechanical inverse of `buildAck`: it reads MSA-1 (code),
|
|
5857
5846
|
* MSA-2 (the correlated control id), and every ERR segment.
|
|
5858
5847
|
*
|
|
5859
5848
|
* Fail-safe: an absent or unrecognized MSA-1 yields `accepted: false`: the
|
|
@@ -5938,10 +5927,9 @@ declare function interpretAck(msg: Hl7Message): Acknowledgment;
|
|
|
5938
5927
|
* `defineProfile()`: public factory for building `Profile` objects with
|
|
5939
5928
|
* validation + `describe()` attached (PROF-01, PROF-04, PROF-05).
|
|
5940
5929
|
*
|
|
5941
|
-
*
|
|
5942
|
-
*
|
|
5943
|
-
*
|
|
5944
|
-
* IGNORED, resulting in `lineage === [opts.name]` regardless.
|
|
5930
|
+
* `opts.extends` is honoured: parents are merged into the returned
|
|
5931
|
+
* profile (lineage, `dateFormats`, `customSegments`, `description` and
|
|
5932
|
+
* `onWarning`), and the merged result is re-validated before it is frozen.
|
|
5945
5933
|
*
|
|
5946
5934
|
* Zero runtime deps. Matches CLAUDE.md engineering guardrails: no `any`,
|
|
5947
5935
|
* JSDoc `@example` on every public export, immutability at the return
|
|
@@ -5985,10 +5973,11 @@ interface DefineProfileOptions {
|
|
|
5985
5973
|
* unknown top-level keys with typo hints (D-07), and missing/empty
|
|
5986
5974
|
* name.
|
|
5987
5975
|
*
|
|
5988
|
-
*
|
|
5989
|
-
*
|
|
5990
|
-
*
|
|
5991
|
-
*
|
|
5976
|
+
* `opts.extends` accepts a single parent `Profile` or an array of them.
|
|
5977
|
+
* Parents are merged into the result: `lineage` is the parents' lineages
|
|
5978
|
+
* followed by this profile's own name, `dateFormats` and `customSegments`
|
|
5979
|
+
* are merged, `description` inherits when not supplied, and `onWarning`
|
|
5980
|
+
* handlers are composed. With no parent, `lineage === [opts.name]`.
|
|
5992
5981
|
*
|
|
5993
5982
|
* @example
|
|
5994
5983
|
* ```ts
|
|
@@ -6197,8 +6186,8 @@ declare const genericLab: Profile;
|
|
|
6197
6186
|
* Z-segments: `ZF1` (provider-encounter copay data) and `ZF2`
|
|
6198
6187
|
* (encounter-procedure data). BIP-03.
|
|
6199
6188
|
*
|
|
6200
|
-
* Grounded in **publicly downloadable** MEDITECH interface specifications
|
|
6201
|
-
*
|
|
6189
|
+
* Grounded in **publicly downloadable** MEDITECH interface specifications,
|
|
6190
|
+
* not invented:
|
|
6202
6191
|
*
|
|
6203
6192
|
* - The **minute-precision** date/time format is confirmed by *two*
|
|
6204
6193
|
* public MEDITECH specs: "MEDITECH Admissions and Registration to Other
|
|
@@ -6220,10 +6209,8 @@ declare const genericLab: Profile;
|
|
|
6220
6209
|
* ZF2-5 ENCOUNTER PROCEDURE QUANTITY, ZF2-6 ENCOUNTER PROCEDURE CHARGE,
|
|
6221
6210
|
* ZF2-7 PRV PROCEDURE AMOUNT PAID, ZF2-8 PRV PROCEDURE AMOUNT DUE).
|
|
6222
6211
|
*
|
|
6223
|
-
* (
|
|
6224
|
-
*
|
|
6225
|
-
* re-grounding, ADR 0018. Field positions here are transcribed directly
|
|
6226
|
-
* from the spec's segment tables.)
|
|
6212
|
+
* (Field positions above are transcribed directly from the spec's segment
|
|
6213
|
+
* tables.)
|
|
6227
6214
|
*
|
|
6228
6215
|
* Authored from the public `defineProfile()` API: zero privileged
|
|
6229
6216
|
* internal coupling. Consumers extend this profile via
|
|
@@ -6271,7 +6258,7 @@ declare const meditech: Profile;
|
|
|
6271
6258
|
*
|
|
6272
6259
|
* Grounded in the public **Vue PACS 12.2.8 HL7 Interface Specifications**
|
|
6273
6260
|
* (Philips, document HA1669 Rev A), §§5.11–5.16: a publicly downloadable
|
|
6274
|
-
* vendor interface spec, not an invented quirk
|
|
6261
|
+
* vendor interface spec, not an invented quirk. The spec's
|
|
6275
6262
|
* `TS` timestamps are the HL7-native `YYYYMMDDHHMMSS` form (§2.6), so this
|
|
6276
6263
|
* profile declares **no** custom `dateFormats`: only the Z-segments.
|
|
6277
6264
|
*
|
|
@@ -6332,7 +6319,7 @@ declare const philips: Profile;
|
|
|
6332
6319
|
* and ORM" with `ZDS-1` = Study Instance UID (`RP`: 1.1 Pointer, 1.2
|
|
6333
6320
|
* Application ID, 1.3 Type of Data, 1.4 Subtype). It is a publicly
|
|
6334
6321
|
* downloadable federal interface spec on the VA VistA Documentation Library
|
|
6335
|
-
* (`va.gov/vdl`), not an invented quirk
|
|
6322
|
+
* (`va.gov/vdl`), not an invented quirk. The spec's messaging is
|
|
6336
6323
|
* HL7-native v2.4, so its `TS` timestamps use the `YYYYMMDDHHMMSS` form: this
|
|
6337
6324
|
* profile therefore declares **no** custom `dateFormats`, only the ZDS
|
|
6338
6325
|
* segment.
|
|
@@ -6372,7 +6359,7 @@ declare const va: Profile;
|
|
|
6372
6359
|
* (V23.00, Jun 2026, Visage Imaging GmbH), §4.4 "ORM Messages" + the ZDS
|
|
6373
6360
|
* segment table ("Study Instance UID … contained in the first component of
|
|
6374
6361
|
* the first field of the ZDS Segment"): a publicly downloadable vendor
|
|
6375
|
-
* interface spec, not an invented quirk
|
|
6362
|
+
* interface spec, not an invented quirk. Dates in that spec use
|
|
6376
6363
|
* the HL7-native `YYYYMMDDHHMMSS` form, so this profile declares **no**
|
|
6377
6364
|
* custom `dateFormats`: only the ZDS segment.
|
|
6378
6365
|
*
|
|
@@ -6463,7 +6450,7 @@ declare const profiles: {
|
|
|
6463
6450
|
declare const KNOWN_SEGMENTS: ReadonlySet<string>;
|
|
6464
6451
|
|
|
6465
6452
|
/**
|
|
6466
|
-
* Coding-system provenance (HL7 Table 0396, READ-ONLY)
|
|
6453
|
+
* Coding-system provenance (HL7 Table 0396, READ-ONLY).
|
|
6467
6454
|
*
|
|
6468
6455
|
* Answers one question about a coded element: **"what coding system does this
|
|
6469
6456
|
* code CLAIM?"** It surfaces the sender's CWE.3 / CE.3 "Name of Coding System"
|
|
@@ -6606,8 +6593,8 @@ declare function codingSystemOf(coded: CodedSystemFields): CodingSystemInfo | un
|
|
|
6606
6593
|
declare function alternateCodingSystemOf(coded: CodedSystemFields): CodingSystemInfo | undefined;
|
|
6607
6594
|
|
|
6608
6595
|
/**
|
|
6609
|
-
* Batch / file envelope splitting for the `@cosyte/hl7` parser
|
|
6610
|
-
*
|
|
6596
|
+
* Batch / file envelope splitting for the `@cosyte/hl7` parser. Real lab /
|
|
6597
|
+
* ELR / IIS feeds ship many messages wrapped in the HL7
|
|
6611
6598
|
* v2 batch protocol envelope (Ch. 2 §2.10.3):
|
|
6612
6599
|
*
|
|
6613
6600
|
* ```
|
|
@@ -6651,8 +6638,8 @@ type BatchEnvelopeName = "FHS" | "BHS" | "BTS" | "FTS";
|
|
|
6651
6638
|
* A raw batch-envelope segment (`FHS`/`BHS`/`BTS`/`FTS`) surfaced by
|
|
6652
6639
|
* {@link splitBatch}. `fields` is the segment split on its own field separator
|
|
6653
6640
|
* with `fields[0]` holding the segment name: deliberately the raw token
|
|
6654
|
-
* array, not a typed model:
|
|
6655
|
-
*
|
|
6641
|
+
* array, not a typed model: typed FHS/BHS field helpers beyond the raw
|
|
6642
|
+
* fields are not part of this surface. Note the
|
|
6656
6643
|
* HL7 MSH-family indexing quirk: for `FHS`/`BHS`, `fields[1]` is the
|
|
6657
6644
|
* encoding-characters field (FHS-2/BHS-2); for `BTS`/`FTS`, `fields[1]` is
|
|
6658
6645
|
* field 1 (BTS-1 batch message count / FTS-1 file batch count).
|
|
@@ -6815,7 +6802,7 @@ declare function splitBatch(raw: string | Buffer, profile: Profile): BatchSplitR
|
|
|
6815
6802
|
declare function splitBatch(raw: string | Buffer, options: ParseOptions): BatchSplitResult;
|
|
6816
6803
|
|
|
6817
6804
|
/**
|
|
6818
|
-
* Public types for the conformance-profile engine
|
|
6805
|
+
* Public types for the conformance-profile engine. A
|
|
6819
6806
|
* **consumer authors** a declarative {@link ConformanceProfile}: a bounded
|
|
6820
6807
|
* subset of the HL7 v2 Message-Profile / NIST-IGAMT model (usage codes,
|
|
6821
6808
|
* cardinality, length, value-set binding against a consumer-supplied code
|
|
@@ -6901,7 +6888,7 @@ interface Cardinality {
|
|
|
6901
6888
|
readonly max?: number | "*";
|
|
6902
6889
|
}
|
|
6903
6890
|
/**
|
|
6904
|
-
* A rule for one **field position** within a segment
|
|
6891
|
+
* A rule for one **field position** within a segment. Every
|
|
6905
6892
|
* constraint is optional; a rule with only a `field` index is a no-op.
|
|
6906
6893
|
*
|
|
6907
6894
|
* @remarks
|
|
@@ -6947,7 +6934,7 @@ interface FieldRule {
|
|
|
6947
6934
|
readonly severity?: FindingSeverity;
|
|
6948
6935
|
}
|
|
6949
6936
|
/**
|
|
6950
|
-
* A rule for one **segment type
|
|
6937
|
+
* A rule for one **segment type**. `usage` constrains whether
|
|
6951
6938
|
* the segment must / must not appear; `cardinality` constrains how many times;
|
|
6952
6939
|
* `fields` are the per-field rules, applied to **every** occurrence of the
|
|
6953
6940
|
* segment.
|
|
@@ -6969,7 +6956,7 @@ interface SegmentRule {
|
|
|
6969
6956
|
readonly severity?: FindingSeverity;
|
|
6970
6957
|
}
|
|
6971
6958
|
/**
|
|
6972
|
-
* A **user-authored, declarative** conformance profile
|
|
6959
|
+
* A **user-authored, declarative** conformance profile. The
|
|
6973
6960
|
* consumer supplies this; hl7 ships none. It is a bounded subset of the HL7 v2
|
|
6974
6961
|
* Message-Profile model: usage / cardinality / length / consumer-supplied
|
|
6975
6962
|
* value set: with **no** conditional-predicate language, **no** bundled code
|
|
@@ -7101,7 +7088,7 @@ interface ConformanceResult {
|
|
|
7101
7088
|
}
|
|
7102
7089
|
|
|
7103
7090
|
/**
|
|
7104
|
-
* The conformance-profile engine
|
|
7091
|
+
* The conformance-profile engine: `validateAgainstProfile`.
|
|
7105
7092
|
* Runs a **consumer-authored** declarative {@link ConformanceProfile} against a
|
|
7106
7093
|
* parsed {@link Hl7Message} and returns typed {@link ConformanceFinding}s.
|
|
7107
7094
|
*
|
|
@@ -7123,7 +7110,7 @@ interface ConformanceResult {
|
|
|
7123
7110
|
|
|
7124
7111
|
/**
|
|
7125
7112
|
* Validate a parsed HL7 v2 message against a **user-authored** declarative
|
|
7126
|
-
* conformance profile
|
|
7113
|
+
* conformance profile and return typed findings.
|
|
7127
7114
|
*
|
|
7128
7115
|
* **Never throws.** A well-formed profile is evaluated rule by rule; a
|
|
7129
7116
|
* malformed profile is reported as `PROFILE_MALFORMED` findings (the engine
|
|
@@ -7167,7 +7154,7 @@ interface ConformanceResult {
|
|
|
7167
7154
|
declare function validateAgainstProfile(message: Hl7Message, profile: ConformanceProfile): ConformanceResult;
|
|
7168
7155
|
|
|
7169
7156
|
/**
|
|
7170
|
-
* Profile-shape validation for the conformance engine
|
|
7157
|
+
* Profile-shape validation for the conformance engine. A
|
|
7171
7158
|
* conformance profile is **consumer-authored configuration**, so it can be
|
|
7172
7159
|
* malformed. Two entry points share one total defect collector:
|
|
7173
7160
|
*
|
|
@@ -7209,9 +7196,9 @@ interface ProfileDefect {
|
|
|
7209
7196
|
*/
|
|
7210
7197
|
declare function collectProfileDefects(profile: unknown): readonly ProfileDefect[];
|
|
7211
7198
|
/**
|
|
7212
|
-
* The **fail-fast authoring** gate for a conformance profile
|
|
7213
|
-
*
|
|
7214
|
-
* validation
|
|
7199
|
+
* The **fail-fast authoring** gate for a conformance profile: a malformed
|
|
7200
|
+
* profile raises a typed `ProfileDefinitionError` at build time, before any
|
|
7201
|
+
* validation runs. Runs {@link collectProfileDefects}; on any defect, throws a
|
|
7215
7202
|
* single {@link ProfileDefinitionError} listing every defect. On success,
|
|
7216
7203
|
* returns the profile typed as {@link ConformanceProfile}.
|
|
7217
7204
|
*
|
|
@@ -7236,7 +7223,7 @@ declare function collectProfileDefects(profile: unknown): readonly ProfileDefect
|
|
|
7236
7223
|
declare function defineConformanceProfile(profile: unknown): ConformanceProfile;
|
|
7237
7224
|
|
|
7238
7225
|
/**
|
|
7239
|
-
* Barrel for the conformance-profile engine
|
|
7226
|
+
* Barrel for the conformance-profile engine. Re-exports the
|
|
7240
7227
|
* engine, the fail-fast profile-authoring gate, and the public types. Also
|
|
7241
7228
|
* available as the `conformance` namespace object from the package root.
|
|
7242
7229
|
*
|
|
@@ -7265,8 +7252,8 @@ declare namespace index {
|
|
|
7265
7252
|
}
|
|
7266
7253
|
|
|
7267
7254
|
/**
|
|
7268
|
-
* Streaming / incremental parse for the `@cosyte/hl7` parser
|
|
7269
|
-
*
|
|
7255
|
+
* Streaming / incremental parse for the `@cosyte/hl7` parser. Real ELR / IIS
|
|
7256
|
+
* / lab feeds and files ship many messages and can be
|
|
7270
7257
|
* far too large to buffer whole; a live source (an already-de-framed MLLP feed,
|
|
7271
7258
|
* a growing file) has no "whole" to buffer at all. `parseStream()` consumes a
|
|
7272
7259
|
* **chunked** byte/string source: a Node `Readable`, an async-iterable, or a
|