@cosyte/transform 0.0.7 → 0.0.9
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 +51 -0
- package/README.md +19 -19
- package/dist/index.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -130
- package/dist/index.d.ts +130 -130
- package/dist/index.mjs +14 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -9,39 +9,39 @@ import { HD, TS, CX, CWE, XPN, XAD, NM, Hl7Message } from '@cosyte/hl7';
|
|
|
9
9
|
* or removing one is a **breaking change** (mirrors the parser archetype's stable-warning-code rule).
|
|
10
10
|
* New codes are **additions only**.
|
|
11
11
|
*
|
|
12
|
-
* - {@link ISSUE_CODES}
|
|
12
|
+
* - {@link ISSUE_CODES}: non-fatal, typed diagnostics carried on a {@link TransformResult}. Every
|
|
13
13
|
* fail-safe decision the transform makes (a naked timestamp, an unresolvable assigning authority,
|
|
14
|
-
* an unmapped code, a non-UCUM unit, a dropped element) surfaces as one of these
|
|
14
|
+
* an unmapped code, a non-UCUM unit, a dropped element) surfaces as one of these, **never** a
|
|
15
15
|
* silently-defaulted or fabricated FHIR value.
|
|
16
|
-
* - {@link FATAL_CODES}
|
|
16
|
+
* - {@link FATAL_CODES}: the small set of unrecoverable conditions reserved for message-level
|
|
17
17
|
* entry points. **Nothing in this library throws one today**: the datatype converters and
|
|
18
18
|
* `toFhir` alike fail safe to a value-free issue instead.
|
|
19
19
|
*
|
|
20
20
|
* @packageDocumentation
|
|
21
21
|
*/
|
|
22
22
|
/**
|
|
23
|
-
* Stable **non-fatal issue codes
|
|
23
|
+
* Stable **non-fatal issue codes**: the typed diagnostics the fail-safe rule emits.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
27
|
* import { ISSUE_CODES } from "@cosyte/transform";
|
|
28
28
|
* if (issue.code === ISSUE_CODES.TRANSFORM_TIMESTAMP_NO_TIMEZONE) {
|
|
29
|
-
* // a v2 timestamp had a time-of-day but no timezone offset
|
|
29
|
+
* // a v2 timestamp had a time-of-day but no timezone offset: reduced to date precision
|
|
30
30
|
* }
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
declare const ISSUE_CODES: {
|
|
34
34
|
/** A v2 DTM/TS carried a time-of-day but no timezone offset. FHIR forbids time-without-zone, so
|
|
35
|
-
* the value was reduced to date precision (or an explicit sender offset applied via options)
|
|
35
|
+
* the value was reduced to date precision (or an explicit sender offset applied via options),
|
|
36
36
|
* **never** a guessed UTC. */
|
|
37
37
|
readonly TRANSFORM_TIMESTAMP_NO_TIMEZONE: "TRANSFORM_TIMESTAMP_NO_TIMEZONE";
|
|
38
38
|
/** A v2 DTM/TS could not be parsed into a valid FHIR date/time; no value was emitted. */
|
|
39
39
|
readonly TRANSFORM_TIMESTAMP_INVALID: "TRANSFORM_TIMESTAMP_INVALID";
|
|
40
40
|
/** The assigning authority (HD) could not be resolved to a FHIR `Identifier.system` URI via the
|
|
41
|
-
* NamingSystem registry. The identifier is emitted with its value and **no** system
|
|
41
|
+
* NamingSystem registry. The identifier is emitted with its value and **no** system: a system URI
|
|
42
42
|
* is **never** synthesized from HD.1 alone. */
|
|
43
43
|
readonly TRANSFORM_IDENTIFIER_SYSTEM_UNRESOLVED: "TRANSFORM_IDENTIFIER_SYSTEM_UNRESOLVED";
|
|
44
|
-
/** A coded value could not be mapped to a FHIR concept
|
|
44
|
+
/** A coded value could not be mapped to a FHIR concept: either it carried no coding-system context
|
|
45
45
|
* (CWE.3 absent), or it is a table code the IG ConceptMap has **no target** for (e.g. an OBX-11/
|
|
46
46
|
* OBR-25 result status the HL70085/HL70123 map does not carry, or an OBX-8 abnormal flag absent from
|
|
47
47
|
* HL70078). The original code is preserved / the FHIR value left absent; **never** coerced to a
|
|
@@ -51,14 +51,14 @@ declare const ISSUE_CODES: {
|
|
|
51
51
|
* be emitted. The code is preserved; a URI is **never** invented. */
|
|
52
52
|
readonly TRANSFORM_CODE_SYSTEM_UNRESOLVED: "TRANSFORM_CODE_SYSTEM_UNRESOLVED";
|
|
53
53
|
/** A unit was not a valid UCUM code (or was not declared UCUM). It is preserved verbatim in
|
|
54
|
-
* `Quantity.unit`; `Quantity.code`/`.system` are left absent
|
|
54
|
+
* `Quantity.unit`; `Quantity.code`/`.system` are left absent: a UCUM code is **never** fabricated
|
|
55
55
|
* and a magnitude is **never** converted. */
|
|
56
56
|
readonly TRANSFORM_UNIT_NOT_UCUM: "TRANSFORM_UNIT_NOT_UCUM";
|
|
57
|
-
/** A v2 numeric value (NM) could not be represented as a FHIR `decimal` without altering it
|
|
57
|
+
/** A v2 numeric value (NM) could not be represented as a FHIR `decimal` without altering it, e.g.
|
|
58
58
|
* a leading `+`, a leading zero, or a trailing dot, which FHIR's `decimal` lexical form forbids. No
|
|
59
59
|
* `Quantity` value is emitted rather than a canonicalized (and therefore altered) magnitude. */
|
|
60
60
|
readonly TRANSFORM_QUANTITY_VALUE_INVALID: "TRANSFORM_QUANTITY_VALUE_INVALID";
|
|
61
|
-
/** A populated source element was not carried to its FHIR target and was dropped
|
|
61
|
+
/** A populated source element was not carried to its FHIR target and was dropped, either because
|
|
62
62
|
* the IG map defines no target, or because that target's conversion is **not implemented**
|
|
63
63
|
* (e.g. XTN→ContactPoint telecom, PV1 participants). Surfaced here rather than silently discarded,
|
|
64
64
|
* never a fabricated value. */
|
|
@@ -71,20 +71,20 @@ declare const ISSUE_CODES: {
|
|
|
71
71
|
readonly TRANSFORM_ADDRESS_USE_UNMAPPED: "TRANSFORM_ADDRESS_USE_UNMAPPED";
|
|
72
72
|
/** The message's trigger event has no IG *message* map, so its resource graph was assembled from
|
|
73
73
|
* the reusable IG *segment* maps rather than a message map. The graph is best-effort and flagged
|
|
74
|
-
* as such
|
|
74
|
+
* as such, never a fabricated message map. */
|
|
75
75
|
readonly TRANSFORM_SEGMENT_ASSEMBLED: "TRANSFORM_SEGMENT_ASSEMBLED";
|
|
76
76
|
/** A produced FHIR resource failed `@cosyte/fhir` R4 structural validation and was **withheld**
|
|
77
|
-
* from the bundle rather than emitted as a silently-invalid resource
|
|
77
|
+
* from the bundle rather than emitted as a silently-invalid resource: the conservative-emit gate. */
|
|
78
78
|
readonly TRANSFORM_RESOURCE_INVALID: "TRANSFORM_RESOURCE_INVALID";
|
|
79
79
|
/** A FHIR-required element's value could not be faithfully derived from the source, so it was
|
|
80
|
-
* emitted with a `data-absent-reason` extension (value `unknown`) rather than fabricated
|
|
80
|
+
* emitted with a `data-absent-reason` extension (value `unknown`) rather than fabricated, e.g.
|
|
81
81
|
* `MessageHeader.source.endpoint` from an MSH-3 application namespace that is not a URL. */
|
|
82
82
|
readonly TRANSFORM_REQUIRED_ELEMENT_UNKNOWN: "TRANSFORM_REQUIRED_ELEMENT_UNKNOWN";
|
|
83
83
|
};
|
|
84
|
-
/** A value from {@link ISSUE_CODES}
|
|
84
|
+
/** A value from {@link ISSUE_CODES}: the type consumers narrow `issue.code` against. */
|
|
85
85
|
type IssueCode = (typeof ISSUE_CODES)[keyof typeof ISSUE_CODES];
|
|
86
86
|
/**
|
|
87
|
-
* Stable **fatal codes
|
|
87
|
+
* Stable **fatal codes**: the reserved names for unrecoverable input conditions. **Nothing in this
|
|
88
88
|
* library throws one today**; every path, datatype and message level alike, fails safe to a
|
|
89
89
|
* value-free issue instead. They are declared so that a future one is an addition rather than a
|
|
90
90
|
* rename.
|
|
@@ -101,23 +101,23 @@ declare const FATAL_CODES: {
|
|
|
101
101
|
/** The input was not a shape this transform accepts. */
|
|
102
102
|
readonly TRANSFORM_UNSUPPORTED_INPUT: "TRANSFORM_UNSUPPORTED_INPUT";
|
|
103
103
|
};
|
|
104
|
-
/** A value from {@link FATAL_CODES}
|
|
104
|
+
/** A value from {@link FATAL_CODES}: the type carried by a thrown fatal error. */
|
|
105
105
|
type FatalCode = (typeof FATAL_CODES)[keyof typeof FATAL_CODES];
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
* The value-free {@link TransformIssue}
|
|
108
|
+
* The value-free {@link TransformIssue}: the single diagnostic shape the whole library emits.
|
|
109
109
|
*
|
|
110
110
|
* Every issue is **`OperationOutcome`-shaped and PHI-safe by construction**: it carries the *v2
|
|
111
|
-
* location* (segment / field / component index
|
|
111
|
+
* location* (segment / field / component index, never a value) and the *FHIR path* it concerns,
|
|
112
112
|
* plus a **static, per-code** severity and human-readable message drawn from {@link ISSUE_REGISTRY}.
|
|
113
|
-
* Nothing in an issue is interpolated from patient data
|
|
113
|
+
* Nothing in an issue is interpolated from patient data: the factory takes only positional metadata,
|
|
114
114
|
* so there is no code path by which a name, DOB, MRN, or result value can reach a log line (the
|
|
115
115
|
* discipline `@cosyte/fhir` already proved with its value-free `OperationOutcome`).
|
|
116
116
|
*
|
|
117
117
|
* @packageDocumentation
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
|
-
/** The severity a {@link TransformIssue} carries
|
|
120
|
+
/** The severity a {@link TransformIssue} carries: an `OperationOutcome.issue.severity` value. */
|
|
121
121
|
type TransformSeverity = "error" | "warning" | "information";
|
|
122
122
|
/**
|
|
123
123
|
* A single value-free diagnostic.
|
|
@@ -134,7 +134,7 @@ interface TransformIssue {
|
|
|
134
134
|
readonly code: IssueCode;
|
|
135
135
|
/** The `OperationOutcome`-style severity, fixed per code. */
|
|
136
136
|
readonly severity: TransformSeverity;
|
|
137
|
-
/** The v2 source location
|
|
137
|
+
/** The v2 source location: a segment / field / component **index**, never a value. */
|
|
138
138
|
readonly v2Location: string;
|
|
139
139
|
/** The FHIR path this issue concerns (e.g. `Identifier.system`), when applicable. */
|
|
140
140
|
readonly fhirPath?: string;
|
|
@@ -146,12 +146,12 @@ interface IssueMeta {
|
|
|
146
146
|
readonly severity: TransformSeverity;
|
|
147
147
|
/** The FHIR `OperationOutcome.issue.code` (R4 `issue-type` value set) this maps to. */
|
|
148
148
|
readonly fhirIssueType: string;
|
|
149
|
-
/** A static, value-free message. Contains no interpolated data
|
|
149
|
+
/** A static, value-free message. Contains no interpolated data: safe to log verbatim. */
|
|
150
150
|
readonly message: string;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* The per-code registry: severity, FHIR `issue-type`, and a static message. Frozen and exhaustive
|
|
154
|
-
* over {@link ISSUE_CODES} (enforced by the `Record<IssueCode, …>` type
|
|
154
|
+
* over {@link ISSUE_CODES} (enforced by the `Record<IssueCode, …>` type: a new code will not
|
|
155
155
|
* compile until it has an entry).
|
|
156
156
|
*/
|
|
157
157
|
declare const ISSUE_REGISTRY: Readonly<Record<IssueCode, IssueMeta>>;
|
|
@@ -160,7 +160,7 @@ declare const ISSUE_REGISTRY: Readonly<Record<IssueCode, IssueMeta>>;
|
|
|
160
160
|
* {@link ISSUE_REGISTRY}; the caller supplies only positional metadata, so an issue can carry no PHI.
|
|
161
161
|
*
|
|
162
162
|
* @param code - The stable {@link IssueCode}.
|
|
163
|
-
* @param v2Location - The v2 source location (segment / field / component index)
|
|
163
|
+
* @param v2Location - The v2 source location (segment / field / component index), never a value.
|
|
164
164
|
* @param fhirPath - The FHIR path the issue concerns, when applicable.
|
|
165
165
|
* @example
|
|
166
166
|
* ```ts
|
|
@@ -171,7 +171,7 @@ declare const ISSUE_REGISTRY: Readonly<Record<IssueCode, IssueMeta>>;
|
|
|
171
171
|
*/
|
|
172
172
|
declare function issue(code: IssueCode, v2Location: string, fhirPath?: string): TransformIssue;
|
|
173
173
|
/**
|
|
174
|
-
* The FHIR `issue-type` code for an {@link IssueCode}
|
|
174
|
+
* The FHIR `issue-type` code for an {@link IssueCode}: used by the `OperationOutcome` renderer.
|
|
175
175
|
*
|
|
176
176
|
* @param code - The stable {@link IssueCode}.
|
|
177
177
|
* @example
|
|
@@ -222,7 +222,7 @@ interface ConvertResult<T> {
|
|
|
222
222
|
* materializes it as an actual `@cosyte/fhir` resource node a consumer can serialize, validate, or
|
|
223
223
|
* return alongside a bundle. It is **value-free**: every field is drawn from the issue's static
|
|
224
224
|
* metadata (code, severity, message) and its positional locations (v2 location → `diagnostics`, FHIR
|
|
225
|
-
* path → `expression`)
|
|
225
|
+
* path → `expression`). No patient data is reachable here.
|
|
226
226
|
*
|
|
227
227
|
* @packageDocumentation
|
|
228
228
|
*/
|
|
@@ -246,15 +246,15 @@ declare const TRANSFORM_ISSUE_SYSTEM = "https://cosyte.com/fhir/CodeSystem/trans
|
|
|
246
246
|
declare function toOperationOutcome(issues: readonly TransformIssue[]): FhirComplex;
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
* The NamingSystem registry
|
|
249
|
+
* The NamingSystem registry: how an HL7 v2 identity/coding namespace becomes a FHIR canonical URI.
|
|
250
250
|
*
|
|
251
251
|
* Two resolutions live here, and both are **fail-safe by refusal**:
|
|
252
252
|
*
|
|
253
253
|
* 1. **Assigning authority (HD) → `Identifier.system`.** The IG's CX→Identifier map says CX.4 maps to
|
|
254
|
-
* `Identifier.system` *only when the authority is in an identifier registry
|
|
254
|
+
* `Identifier.system` *only when the authority is in an identifier registry*: the URI comes from a
|
|
255
255
|
* NamingSystem lookup, **not** string concatenation. There is no deterministic algorithm from an
|
|
256
256
|
* HD to a URI, so this resolver **never synthesizes a system from HD.1 (the bare namespace
|
|
257
|
-
* mnemonic) alone
|
|
257
|
+
* mnemonic) alone**: doing so would let two hospitals reusing "MR"/"HOSPMRN" collide and merge two
|
|
258
258
|
* patients. The *only* auto-derivations are the unambiguous ones: `urn:oid:<oid>` when HD.2 is a
|
|
259
259
|
* valid OID with HD.3 = `ISO`, and `urn:uuid:<uuid>` when HD.3 = `UUID`. Everything else must be an
|
|
260
260
|
* explicit, caller-seeded registry entry, or it resolves to `undefined` and the caller emits a
|
|
@@ -263,14 +263,14 @@ declare function toOperationOutcome(issues: readonly TransformIssue[]): FhirComp
|
|
|
263
263
|
* 2. **v2 coding-system mnemonic → canonical URI.** CWE.3/CWE.6 carry a v2 Table 0396 mnemonic
|
|
264
264
|
* (`LN`, `SCT`, …); FHIR needs the canonical URI (`http://loinc.org`, …). {@link DEFAULT_V2_CODE_SYSTEMS}
|
|
265
265
|
* seeds a small, license-clean set of the universally-fixed FHIR-core systems; an unrecognized
|
|
266
|
-
* mnemonic resolves to `undefined` (the caller preserves the raw code and flags it
|
|
266
|
+
* mnemonic resolves to `undefined` (the caller preserves the raw code and flags it: a URI is
|
|
267
267
|
* never invented). The full HL7 THO crosswalk is not bundled.
|
|
268
268
|
*
|
|
269
269
|
* @packageDocumentation
|
|
270
270
|
*/
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
|
-
* The HL7 v2 Table 0203 identifier-type code system canonical URI
|
|
273
|
+
* The HL7 v2 Table 0203 identifier-type code system canonical URI: used to build `Identifier.type`.
|
|
274
274
|
* (FHIR R4 terminologies-systems.html)
|
|
275
275
|
*/
|
|
276
276
|
declare const V2_0203_SYSTEM = "http://terminology.hl7.org/CodeSystem/v2-0203";
|
|
@@ -278,7 +278,7 @@ declare const V2_0203_SYSTEM = "http://terminology.hl7.org/CodeSystem/v2-0203";
|
|
|
278
278
|
* A small, license-clean seed of v2 Table 0396 coding-system mnemonic → canonical URI, for the
|
|
279
279
|
* FHIR-core-fixed systems whose URIs are universally cited (FHIR R4 terminologies-systems.html).
|
|
280
280
|
* The full HL7 THO NamingSystem crosswalk is not bundled; callers extend this via
|
|
281
|
-
* {@link createNamingSystem}. **No terminology *content* is bundled
|
|
281
|
+
* {@link createNamingSystem}. **No terminology *content* is bundled: only identity URIs.**
|
|
282
282
|
*/
|
|
283
283
|
declare const DEFAULT_V2_CODE_SYSTEMS: Readonly<Record<string, string>>;
|
|
284
284
|
/** A seed for {@link createNamingSystem}: extra coding systems and explicit assigning authorities. */
|
|
@@ -321,7 +321,7 @@ declare function createNamingSystem(seed?: NamingSystemSeed): NamingSystemRegist
|
|
|
321
321
|
/**
|
|
322
322
|
* The options and context threaded through the datatype converters.
|
|
323
323
|
*
|
|
324
|
-
* These are **types only
|
|
324
|
+
* These are **types only**, no runtime behavior. {@link TransformOptions} carries the policy knobs a
|
|
325
325
|
* caller can set; {@link TransformContext} additionally carries the
|
|
326
326
|
* {@link NamingSystemRegistry} the identity- and code-resolution paths consult.
|
|
327
327
|
*
|
|
@@ -333,7 +333,7 @@ declare function createNamingSystem(seed?: NamingSystemSeed): NamingSystemRegist
|
|
|
333
333
|
*
|
|
334
334
|
* @remarks
|
|
335
335
|
* `assumeTimezoneOffsetMinutes` is the **only** way a naked v2 timestamp acquires a time-of-day in
|
|
336
|
-
* FHIR: the caller asserts the sender's offset (in minutes east of UTC
|
|
336
|
+
* FHIR: the caller asserts the sender's offset (in minutes east of UTC, e.g. `-300` for US Eastern
|
|
337
337
|
* standard time). It is a *sender-asserted* value, flagged as such; absent it, a naked timestamp is
|
|
338
338
|
* reduced to date precision, **never** assumed to be UTC.
|
|
339
339
|
*/
|
|
@@ -343,7 +343,7 @@ interface TransformOptions {
|
|
|
343
343
|
/**
|
|
344
344
|
* The {@link NamingSystemRegistry} the message-level transform threads into every datatype
|
|
345
345
|
* conversion (HD → `Identifier.system`, v2 mnemonic → canonical URI). When omitted, a default
|
|
346
|
-
* registry (`createNamingSystem()`) is used
|
|
346
|
+
* registry (`createNamingSystem()`) is used: it resolves only the FHIR-core-fixed systems and the
|
|
347
347
|
* two unambiguous HD auto-derivations, so an un-seeded assigning authority surfaces a typed issue
|
|
348
348
|
* rather than a guessed system.
|
|
349
349
|
*/
|
|
@@ -351,7 +351,7 @@ interface TransformOptions {
|
|
|
351
351
|
/**
|
|
352
352
|
* Allocator for the `urn:uuid:` `Bundle.entry.fullUrl` / reference identities the assembler mints.
|
|
353
353
|
* Defaults to `crypto.randomUUID`. Inject a deterministic generator to make bundle output
|
|
354
|
-
* reproducible (e.g. for golden fixtures). It must return a fresh, unique value per call
|
|
354
|
+
* reproducible (e.g. for golden fixtures). It must return a fresh, unique value per call: the
|
|
355
355
|
* assembler relies on uniqueness for intra-bundle reference integrity.
|
|
356
356
|
*/
|
|
357
357
|
readonly generateId?: () => string;
|
|
@@ -369,7 +369,7 @@ interface TransformContext {
|
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
/**
|
|
372
|
-
* DTM / TS → FHIR `dateTime
|
|
372
|
+
* DTM / TS → FHIR `dateTime`: the single most dangerous conversion.
|
|
373
373
|
*
|
|
374
374
|
* Grounded on the IG datatype ConceptMap **DTM → dateTime** (`DTM.1` *is equivalent to* the FHIR
|
|
375
375
|
* `dateTime.$value`, with the instruction to "convert v2 date time format to FHIR date time format")
|
|
@@ -378,14 +378,14 @@ interface TransformContext {
|
|
|
378
378
|
* offset** whenever a time is present. Two fail-safe consequences follow:
|
|
379
379
|
*
|
|
380
380
|
* - **Naked timestamp (no offset).** A `20260721143000` cannot become a valid zoned FHIR `dateTime`
|
|
381
|
-
* without inventing an offset
|
|
381
|
+
* without inventing an offset: assuming UTC would silently shift the clinical instant by hours. So
|
|
382
382
|
* the value is **reduced to date precision** (`2026-07-21`) and {@link ISSUE_CODES.TRANSFORM_TIMESTAMP_NO_TIMEZONE}
|
|
383
|
-
* is raised
|
|
383
|
+
* is raised, unless the caller asserts the sender's offset via `options.assumeTimezoneOffsetMinutes`.
|
|
384
384
|
* - **Partial-precision time (hour/minute only).** FHIR cannot represent `hh` or `hh:mm` without
|
|
385
385
|
* seconds, and padding `:00` would fabricate precision, so such a value is likewise reduced to date
|
|
386
|
-
* precision and flagged
|
|
386
|
+
* precision and flagged, never padded.
|
|
387
387
|
*
|
|
388
|
-
* Date-only precisions (`2026`, `2026-07`, `2026-07-21`) are preserved exactly
|
|
388
|
+
* Date-only precisions (`2026`, `2026-07`, `2026-07-21`) are preserved exactly, never zero-filled,
|
|
389
389
|
* and need no offset (FHIR permits a bare date).
|
|
390
390
|
*
|
|
391
391
|
* @packageDocumentation
|
|
@@ -409,18 +409,18 @@ interface TransformContext {
|
|
|
409
409
|
declare function toFhirDateTime(ts: TS, options?: TransformOptions): ConvertResult<string>;
|
|
410
410
|
|
|
411
411
|
/**
|
|
412
|
-
* CX → FHIR `Identifier
|
|
412
|
+
* CX → FHIR `Identifier`: the patient-identity-integrity path.
|
|
413
413
|
*
|
|
414
414
|
* Grounded on the IG datatype ConceptMap **CX → Identifier**: `CX.1` → `Identifier.value`, `CX.4`
|
|
415
415
|
* (assigning authority HD) → `Identifier.system` *when the authority resolves in a registry* (else
|
|
416
|
-
* the IG maps it to `Identifier.assigner
|
|
416
|
+
* the IG maps it to `Identifier.assigner`: a message-level Organization reference this library does
|
|
417
417
|
* not build), and `CX.5` (Table 0203) → `Identifier.type`.
|
|
418
418
|
*
|
|
419
419
|
* The load-bearing fail-safe: the assigning authority is resolved through the
|
|
420
420
|
* {@link NamingSystemRegistry}, which **never synthesizes a system URI from HD.1 (the bare namespace)
|
|
421
|
-
* alone
|
|
421
|
+
* alone**. Two hospitals reusing "MR"/"HOSPMRN" would otherwise collide and merge two patients. On
|
|
422
422
|
* an unresolved authority the identifier is emitted with its **value and no system**, plus a typed
|
|
423
|
-
* {@link ISSUE_CODES.TRANSFORM_IDENTIFIER_SYSTEM_UNRESOLVED} issue
|
|
423
|
+
* {@link ISSUE_CODES.TRANSFORM_IDENTIFIER_SYSTEM_UNRESOLVED} issue, never a guessed system.
|
|
424
424
|
*
|
|
425
425
|
* @packageDocumentation
|
|
426
426
|
*/
|
|
@@ -446,10 +446,10 @@ declare function toFhirDateTime(ts: TS, options?: TransformOptions): ConvertResu
|
|
|
446
446
|
declare function toFhirIdentifier(cx: CX, ctx?: TransformContext): ConvertResult<FhirComplex>;
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
|
-
* CWE / CE → FHIR `CodeableConcept
|
|
449
|
+
* CWE / CE → FHIR `CodeableConcept`: the code-fidelity path.
|
|
450
450
|
*
|
|
451
451
|
* Grounded on the IG datatype ConceptMap **CWE → CodeableConcept**: `CWE.1`→`coding[0].code`,
|
|
452
|
-
* `CWE.2`→`coding[0].display`, `CWE.3`→`coding[0].system` **(indirect
|
|
452
|
+
* `CWE.2`→`coding[0].display`, `CWE.3`→`coding[0].system` **(indirect: the vocabulary table gives
|
|
453
453
|
* the actual URI)**, `CWE.7`→`coding[0].version`, the alternate triplet `CWE.4/5/6`→`coding[1]` (+
|
|
454
454
|
* `CWE.8`→`coding[1].version`), and `CWE.9`→`text`. `CE` is the 6-component subset of `CWE` and maps
|
|
455
455
|
* through the same shape.
|
|
@@ -466,7 +466,7 @@ declare function toFhirIdentifier(cx: CX, ctx?: TransformContext): ConvertResult
|
|
|
466
466
|
* @packageDocumentation
|
|
467
467
|
*/
|
|
468
468
|
|
|
469
|
-
/** The subset of CWE fields a CE also provides
|
|
469
|
+
/** The subset of CWE fields a CE also provides, so `toFhirCodeableConcept` accepts both. */
|
|
470
470
|
type CodedElement = Pick<CWE, "identifier" | "text" | "nameOfCodingSystem" | "alternateIdentifier" | "alternateText" | "nameOfAlternateCodingSystem" | "codingSystemVersionId" | "alternateCodingSystemVersionId" | "originalText">;
|
|
471
471
|
/**
|
|
472
472
|
* Convert a parsed HL7 v2 CWE (or CE) to a FHIR `CodeableConcept` node, fail-safe on the coding
|
|
@@ -496,7 +496,7 @@ declare function toFhirCodeableConcept(cwe: CodedElement, ctx?: TransformContext
|
|
|
496
496
|
*
|
|
497
497
|
* `XPN.7`→`use` is a **lossy code translation**: only the codes the IG's HL70200→name-use map covers
|
|
498
498
|
* are translated; any other name-type code leaves `use` **absent** and raises
|
|
499
|
-
* {@link ISSUE_CODES.TRANSFORM_NAME_USE_UNMAPPED}
|
|
499
|
+
* {@link ISSUE_CODES.TRANSFORM_NAME_USE_UNMAPPED}, never guessed. Not converted, and flagged:
|
|
500
500
|
* the name-validity period (`XPN.12`/`XPN.13`), whose FHIR `period` needs the timezone policy of the
|
|
501
501
|
* dateTime path.
|
|
502
502
|
*
|
|
@@ -533,11 +533,11 @@ declare function toFhirHumanName(xpn: XPN): ConvertResult<FhirComplex>;
|
|
|
533
533
|
* - `XAD.7 IN {BA, BI, C, B, H, O}` → `Address.use` (via the IG **HL70190 → address-use** map);
|
|
534
534
|
* - `XAD.7 IN {M, SH}` → `Address.type` (via the IG **HL70190 → address-type** map);
|
|
535
535
|
* - a vacation address (`V` in Table 0190; the datatype map references `HV`) → an ISO-21090 extension
|
|
536
|
-
* the IG defines
|
|
536
|
+
* the IG defines, **not emitted**, and flagged rather than invented;
|
|
537
537
|
* - any other code → `use`/`type` left absent, flagged {@link ISSUE_CODES.TRANSFORM_ADDRESS_USE_UNMAPPED}.
|
|
538
538
|
*
|
|
539
539
|
* FHIR deliberately separates `use` (home/work/temp) from `type` (postal/physical), so one v2 code
|
|
540
|
-
* cannot always populate both axes
|
|
540
|
+
* cannot always populate both axes: round-trip is not stable, and the drop is surfaced, never hidden.
|
|
541
541
|
* `XAD.8` (other geographic designation) has no FHIR target and is flagged dropped.
|
|
542
542
|
*
|
|
543
543
|
* @packageDocumentation
|
|
@@ -571,7 +571,7 @@ declare function toFhirAddress(xad: XAD): ConvertResult<FhirComplex>;
|
|
|
571
571
|
* - **Never convert magnitudes.** The numeric value is carried through **precision-exact** via
|
|
572
572
|
* `@cosyte/fhir`'s string-backed `decimal` (a dose or lab value is never routed through a JS
|
|
573
573
|
* `number`). UCUM magnitude conversion (mg/dL ↔ mmol/L) is analyte-dependent and a
|
|
574
|
-
* clinical-safety footgun
|
|
574
|
+
* clinical-safety footgun: an explicit non-goal, never a transform side effect.
|
|
575
575
|
* - **Never fabricate a UCUM code.** A unit is emitted into `Quantity.code`/`.system` **only** when
|
|
576
576
|
* it is declared UCUM and passes `@cosyte/fhir`'s UCUM shape check. Any other unit is preserved
|
|
577
577
|
* verbatim in `Quantity.unit` with `code`/`system` absent, flagged
|
|
@@ -602,12 +602,12 @@ declare function toFhirAddress(xad: XAD): ConvertResult<FhirComplex>;
|
|
|
602
602
|
declare function toFhirQuantity(value: NM, units: CWE, ctx?: TransformContext): ConvertResult<FhirComplex>;
|
|
603
603
|
|
|
604
604
|
/**
|
|
605
|
-
* `toFhir
|
|
605
|
+
* `toFhir`, the message-level entry point: assemble a parsed HL7 v2 message into a FHIR R4
|
|
606
606
|
* **message Bundle** (a `MessageHeader` first, then the focal resources), grounded on the IG message
|
|
607
607
|
* and segment maps. The **ADT** family becomes **Patient + Encounter** (+ `RelatedPerson`
|
|
608
608
|
* from NK1); the **ORU^R01** results graph becomes `DiagnosticReport` + `Observation`; the
|
|
609
|
-
* order-entry graph
|
|
610
|
-
* `MedicationRequest`; and the thin IG singles
|
|
609
|
+
* order-entry graph gives **ORM_O01 / OML_O21** ORC/OBR → `ServiceRequest` and **RXO** (+ RXR) →
|
|
610
|
+
* `MedicationRequest`; and the thin IG singles give **VXU_V04** RXA/RXR/ORC → `Immunization`,
|
|
611
611
|
* **SIU_S12** SCH/AIS/PID → `Appointment`, and **MDM_T02** TXA/OBX → `DocumentReference`.
|
|
612
612
|
*
|
|
613
613
|
* The fail-safe rule holds at the message level. Two message-level fail-safes join the datatype ones:
|
|
@@ -615,15 +615,15 @@ declare function toFhirQuantity(value: NM, units: CWE, ctx?: TransformContext):
|
|
|
615
615
|
* - **Segment-assembled, not fabricated.** For an ADT trigger the IG maps ({@link IG_MAPPED_ADT_TRIGGERS}),
|
|
616
616
|
* the graph is message-map-grounded. For any other trigger there is no IG *message* map, so the
|
|
617
617
|
* graph is assembled from the reusable IG *segment* maps and flagged
|
|
618
|
-
* {@link ISSUE_CODES.TRANSFORM_SEGMENT_ASSEMBLED}
|
|
618
|
+
* {@link ISSUE_CODES.TRANSFORM_SEGMENT_ASSEMBLED}, never a fabricated message map.
|
|
619
619
|
* - **Conservative emit gate.** Every produced resource is run through `@cosyte/fhir.validateResource`
|
|
620
|
-
* before it can join the bundle
|
|
620
|
+
* before it can join the bundle: `Patient` against the built-in schema in `strict` mode, and the
|
|
621
621
|
* other types against the minimal required-cardinality {@link EMIT_SCHEMAS} in `lenient` mode (so a
|
|
622
622
|
* missing required element errors and withholds, while unmodeled sibling elements do not
|
|
623
623
|
* false-reject). A resource with any structural error is **withheld** from the bundle and flagged
|
|
624
624
|
* {@link ISSUE_CODES.TRANSFORM_RESOURCE_INVALID} rather than shipped as silently-invalid FHIR. When
|
|
625
625
|
* the Patient is withheld, the Encounter's `subject` and any RelatedPerson are dropped rather than
|
|
626
|
-
* left dangling
|
|
626
|
+
* left dangling: references always resolve within the bundle.
|
|
627
627
|
*
|
|
628
628
|
* @packageDocumentation
|
|
629
629
|
*/
|
|
@@ -639,8 +639,8 @@ interface TransformResult {
|
|
|
639
639
|
readonly issues: readonly TransformIssue[];
|
|
640
640
|
}
|
|
641
641
|
/**
|
|
642
|
-
* The ADT trigger events the IG ships a **message** map for. Other triggers still transform
|
|
643
|
-
* reusable segment maps
|
|
642
|
+
* The ADT trigger events the IG ships a **message** map for. Other triggers still transform, from the
|
|
643
|
+
* reusable segment maps, but are flagged {@link ISSUE_CODES.TRANSFORM_SEGMENT_ASSEMBLED}.
|
|
644
644
|
*/
|
|
645
645
|
declare const IG_MAPPED_ADT_TRIGGERS: ReadonlySet<string>;
|
|
646
646
|
/**
|
|
@@ -695,7 +695,7 @@ declare const IG_MAPPED_DOCUMENT_TRIGGERS: ReadonlySet<string>;
|
|
|
695
695
|
declare function toFhir(msg: Hl7Message, opts?: TransformOptions): TransformResult;
|
|
696
696
|
|
|
697
697
|
/**
|
|
698
|
-
* PID → FHIR `Patient
|
|
698
|
+
* PID → FHIR `Patient`, grounded on the IG **Segment PID to Patient** ConceptMap
|
|
699
699
|
* (`hl7.fhir.uv.v2mappings`, STU1). The field→element rows used here, verified firsthand against the
|
|
700
700
|
* published map:
|
|
701
701
|
*
|
|
@@ -709,8 +709,8 @@ declare function toFhir(msg: Hl7Message, opts?: TransformOptions): TransformResu
|
|
|
709
709
|
*
|
|
710
710
|
* Fail-safe throughout: each datatype conversion carries its own value-free issues, an unmapped
|
|
711
711
|
* administrative-sex code leaves `gender` absent (never guessed), and a birth *time* (PID-7 with a
|
|
712
|
-
* time-of-day) is dropped to `date` precision with a flag
|
|
713
|
-
* is a profile concern this library does not cover. Deferred and flagged, not silently mapped:
|
|
712
|
+
* time-of-day) is dropped to `date` precision with a flag, because the US Core `patient-birthTime`
|
|
713
|
+
* extension is a profile concern this library does not cover. Deferred and flagged, not silently mapped:
|
|
714
714
|
* PID-13/14 telecom (no XTN→ContactPoint converter), and PID-10/15/22/29/30 (US Core race/ethnicity
|
|
715
715
|
* extensions, communication language, deceased).
|
|
716
716
|
*
|
|
@@ -720,14 +720,14 @@ declare function toFhir(msg: Hl7Message, opts?: TransformOptions): TransformResu
|
|
|
720
720
|
/**
|
|
721
721
|
* HL7 v2 Table 0001 (Administrative Sex) → FHIR `administrative-gender`, exactly per the IG
|
|
722
722
|
* **Table HL70001 to Administrative Gender** ConceptMap (every row "is equivalent to"). `A`
|
|
723
|
-
* (Ambiguous) and `N` (Not applicable) both narrow to `other
|
|
723
|
+
* (Ambiguous) and `N` (Not applicable) both narrow to `other`: the map's stated equivalence, carried
|
|
724
724
|
* as-is. A code absent here (the map defines no `unmapped` default) leaves `gender` absent and is
|
|
725
|
-
* flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}
|
|
725
|
+
* flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}, never coerced to `unknown`.
|
|
726
726
|
*/
|
|
727
727
|
declare const ADMINISTRATIVE_GENDER_MAP: Readonly<Record<string, string>>;
|
|
728
728
|
|
|
729
729
|
/**
|
|
730
|
-
* PV1 → FHIR `Encounter
|
|
730
|
+
* PV1 → FHIR `Encounter`, grounded on the IG **Segment PV1 to Encounter** ConceptMap plus the two
|
|
731
731
|
* **Table HL70004** ConceptMaps (to V3 ActCode, and to Encounter Status), all verified firsthand
|
|
732
732
|
* against the published `hl7.fhir.uv.v2mappings` STU1 maps:
|
|
733
733
|
*
|
|
@@ -761,13 +761,13 @@ declare const ENCOUNTER_CLASS_V3_MAP: Readonly<Record<string, {
|
|
|
761
761
|
}>>;
|
|
762
762
|
/**
|
|
763
763
|
* HL7 v2 Table 0004 (Patient Class) → FHIR `Encounter.status`, per the IG **Table HL70004 to
|
|
764
|
-
* Encounter Status** ConceptMap. Applied only when PV1-45 (discharge date) is *not* valued
|
|
764
|
+
* Encounter Status** ConceptMap. Applied only when PV1-45 (discharge date) is *not* valued: a valued
|
|
765
765
|
* discharge sets `status = finished` per the PV1→Encounter map.
|
|
766
766
|
*/
|
|
767
767
|
declare const ENCOUNTER_STATUS_MAP: Readonly<Record<string, string>>;
|
|
768
768
|
|
|
769
769
|
/**
|
|
770
|
-
* OBX → FHIR `Observation
|
|
770
|
+
* OBX → FHIR `Observation`: the highest-clinical-stakes segment map,
|
|
771
771
|
* grounded firsthand on the IG **Segment OBX to Observation** ConceptMap plus its two governing table
|
|
772
772
|
* ConceptMaps (`hl7.fhir.uv.v2mappings`, STU1). The rows used here, verified against the published maps
|
|
773
773
|
* (`ConceptMap-segment-obx-to-observation.html`, `-table-hl70078-to-v3-observationinterpretation.html`,
|
|
@@ -775,7 +775,7 @@ declare const ENCOUNTER_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
775
775
|
*
|
|
776
776
|
* | OBX field | FHIR target | via |
|
|
777
777
|
* |---|---|---|
|
|
778
|
-
* | OBX-2 Value Type | discriminates OBX-5 → `value[x]` | {@link buildValue}
|
|
778
|
+
* | OBX-2 Value Type | discriminates OBX-5 → `value[x]` | {@link buildValue}, never assume `Quantity` |
|
|
779
779
|
* | OBX-3 Observation Identifier (CWE) | `Observation.code` | {@link toFhirCodeableConcept} |
|
|
780
780
|
* | OBX-5 Observation Value | `Observation.value[x]` | per OBX-2 |
|
|
781
781
|
* | OBX-6 Units (CWE) | `valueQuantity.unit`/`.code`/`.system` | {@link quantityFromRawMagnitude} |
|
|
@@ -789,17 +789,17 @@ declare const ENCOUNTER_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
789
789
|
* `SN`→structured (`valueQuantity` with a comparator / `valueRange` / `valueRatio`), `ST`/`TX`/`FT`→
|
|
790
790
|
* `valueString`. A value type with no first-class target here (`NA`, `ED`, `DR`, `TM`, `NR`, unknown)
|
|
791
791
|
* preserves the raw value as `valueString` and flags {@link ISSUE_CODES.TRANSFORM_ELEMENT_DROPPED}
|
|
792
|
-
* (the richer FHIR type is deferred)
|
|
792
|
+
* (the richer FHIR type is deferred), never a fabricated `Quantity`.
|
|
793
793
|
* - **A corrected/cancelled result never emits as `final`.** OBX-11 `C`→`corrected`, `X`→`cancelled`,
|
|
794
794
|
* `D`/`W`→`entered-in-error` (HL70085). A status code with **no** HL70085 target leaves
|
|
795
795
|
* `Observation.status` absent (flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}); the required-`status`
|
|
796
|
-
* emit gate then **withholds** the Observation rather than shipping it
|
|
796
|
+
* emit gate then **withholds** the Observation rather than shipping it, never coerced to `final`.
|
|
797
797
|
* - **An unrecognized abnormal flag is surfaced, never coerced to normal.** Each OBX-8 flag in
|
|
798
798
|
* {@link HL70078_INTERPRETATION_CODES} becomes an `interpretation` coding (the map is code-preserving);
|
|
799
799
|
* a flag absent from the table is flagged and dropped, never emitted as `N`/normal.
|
|
800
800
|
*
|
|
801
|
-
* Numeric magnitudes (NM, SN) are read from the **raw OBX-5 field
|
|
802
|
-
* `Observation` view's JS `number
|
|
801
|
+
* Numeric magnitudes (NM, SN) are read from the **raw OBX-5 field**, not the `@cosyte/hl7`
|
|
802
|
+
* `Observation` view's JS `number`, so a reported lab value's exact lexical precision (`120.50`) is
|
|
803
803
|
* carried through the string-backed FHIR `decimal`, never routed through a lossy `number`.
|
|
804
804
|
*
|
|
805
805
|
* @packageDocumentation
|
|
@@ -809,7 +809,7 @@ declare const ENCOUNTER_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
809
809
|
* HL7 v2 Table 0078 (Abnormal Flags) → FHIR v3 ObservationInterpretation (`Observation.interpretation`),
|
|
810
810
|
* per the IG **Table HL70078 to v3 ObservationInterpretation** ConceptMap. Every mapped row is
|
|
811
811
|
* `is equivalent to` an **identically-spelled** v3 code (the map is code-preserving), so this is the set
|
|
812
|
-
* of codes that carry a target
|
|
812
|
+
* of codes that carry a target: a flag **absent** from this set has no equivalent and is flagged
|
|
813
813
|
* {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}, never coerced (the IG leaves `AC`/`HM`/`OBX`/`QCF`/`TOX`
|
|
814
814
|
* and any local flag unmapped, and declares no `unmapped` default).
|
|
815
815
|
*/
|
|
@@ -818,14 +818,14 @@ declare const HL70078_INTERPRETATION_CODES: ReadonlySet<string>;
|
|
|
818
818
|
* HL7 v2 Table 0085 (Observation Result Status) → FHIR `observation-status` (`Observation.status`),
|
|
819
819
|
* per the IG **Table HL70085 to Observation Status** ConceptMap (each `is equivalent to`). Only these
|
|
820
820
|
* seven source codes carry a target; the codes the IG leaves unmapped (`B`, `I`, `N`, `O`, `R`, `S`,
|
|
821
|
-
* `U`, `V`) are **absent here on purpose
|
|
821
|
+
* `U`, `V`) are **absent here on purpose**: an OBX-11 with one of them (or any local code) leaves
|
|
822
822
|
* `Observation.status` absent + flagged, and the required-`status` emit gate withholds the Observation.
|
|
823
823
|
* **`C`→`corrected` and `X`→`cancelled` guarantee a corrected/cancelled result never emits as `final`.**
|
|
824
824
|
*/
|
|
825
825
|
declare const OBSERVATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
826
826
|
|
|
827
827
|
/**
|
|
828
|
-
* OBR → FHIR `DiagnosticReport
|
|
828
|
+
* OBR → FHIR `DiagnosticReport`, the ORU results-report anchor, grounded firsthand
|
|
829
829
|
* on the IG **Segment OBR to DiagnosticReport** ConceptMap and its **Table HL70123 to Diagnostic Report
|
|
830
830
|
* Status** ConceptMap (`hl7.fhir.uv.v2mappings`, STU1;
|
|
831
831
|
* `ConceptMap-segment-obr-to-diagnosticreport.html`,
|
|
@@ -837,15 +837,15 @@ declare const OBSERVATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
837
837
|
* | OBR-3 Filler Order Number | `identifier` (type `FILL`) | EI.1 → `Identifier.value`, v2-0203 type |
|
|
838
838
|
* | OBR-4 Universal Service Identifier (CWE) | `DiagnosticReport.code` | {@link toFhirCodeableConcept} |
|
|
839
839
|
* | OBR-7 Observation Date/Time | `effectiveDateTime` / `effectivePeriod.start` | {@link toFhirDateTime} |
|
|
840
|
-
* | OBR-8 Observation End Date/Time | `effectivePeriod.end` (start moves to the period when valued) |
|
|
840
|
+
* | OBR-8 Observation End Date/Time | `effectivePeriod.end` (start moves to the period when valued) | {@link toFhirDateTime} |
|
|
841
841
|
* | OBR-22 Results Rpt/Status Chng Date/Time | `DiagnosticReport.issued` (an `instant`) | {@link toFhirDateTime} |
|
|
842
842
|
* | OBR-24 Diagnostic Serv Sect ID | `DiagnosticReport.category` | v2-0074 coding |
|
|
843
843
|
* | OBR-25 Result Status | `DiagnosticReport.status` | {@link DIAGNOSTIC_REPORT_STATUS_MAP} (HL70123) |
|
|
844
844
|
* | (OBX children) | `DiagnosticReport.result` | reference wiring from the assembler |
|
|
845
845
|
*
|
|
846
846
|
* **Fail-safes.** `DiagnosticReport.status` is required (R4 1..1) and the IG itself notes an unvalued
|
|
847
|
-
* OBR-25 is an error; so an absent OBR-25
|
|
848
|
-
* `N`, `Y`, `Z`)
|
|
847
|
+
* OBR-25 is an error; so an absent OBR-25, or an OBR-25 code the HL70123 map does not carry (`A`, `M`,
|
|
848
|
+
* `N`, `Y`, `Z`), leaves `status` absent + flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}, and the
|
|
849
849
|
* required-`status` emit gate withholds the report rather than emitting an invalid one or guessing
|
|
850
850
|
* `final`. `OBR-25 = C`→`corrected` / `X`→`cancelled` are modelled exactly. OBR-22 becomes `issued`
|
|
851
851
|
* only when it is a fully-zoned instant; a date-only/naked OBR-22 is dropped + flagged (never a
|
|
@@ -859,7 +859,7 @@ declare const OBSERVATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
859
859
|
* HL7 v2 Table 0123 (Result Status) → FHIR `diagnostic-report-status` (`DiagnosticReport.status`), per
|
|
860
860
|
* the IG **Table HL70123 [Queries] to Diagnostic Report Status** ConceptMap (each `is equivalent to`).
|
|
861
861
|
* Only these **eight** source codes carry a target; the IG leaves `A`, `M`, `N`, `Y`, `Z` unmapped
|
|
862
|
-
* (verified firsthand against the published v1.0.0 ConceptMap
|
|
862
|
+
* (verified firsthand against the published v1.0.0 ConceptMap: `N` "Procedure completed, results
|
|
863
863
|
* pending" is in the `(not mapped)` group, and the map declares no `unmapped` default), so an OBR-25
|
|
864
864
|
* with one of them leaves `status` absent + flagged and the report is withheld. In particular a
|
|
865
865
|
* results-**pending** `N` is **never** emitted as the post-final `appended`. **`C`→`corrected` and
|
|
@@ -868,7 +868,7 @@ declare const OBSERVATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
868
868
|
declare const DIAGNOSTIC_REPORT_STATUS_MAP: Readonly<Record<string, string>>;
|
|
869
869
|
|
|
870
870
|
/**
|
|
871
|
-
* ORC + OBR → FHIR `ServiceRequest
|
|
871
|
+
* ORC + OBR → FHIR `ServiceRequest`: the order-entry request, grounded firsthand
|
|
872
872
|
* on the IG **Segment ORC to ServiceRequest** and **Segment OBR to ServiceRequest** ConceptMaps and
|
|
873
873
|
* the **Table HL70119 to Request Status** ConceptMap (`hl7.fhir.uv.v2mappings`, STU1;
|
|
874
874
|
* `ConceptMap-segment-orc-to-servicerequest.html`, `ConceptMap-segment-obr-to-servicerequest.html`,
|
|
@@ -894,26 +894,26 @@ declare const DIAGNOSTIC_REPORT_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
894
894
|
* {@link REQUEST_STATUS_MAP}; the many codes the IG leaves in its `(unmapped)` group (CH, CP, PA,
|
|
895
895
|
* RE, RF, RP, SC, the U* "unable to …" family, …) have **no** target and leave `status` absent +
|
|
896
896
|
* flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}. When **ORC-5** (Order Status) is valued the
|
|
897
|
-
* IG routes status through ORC-5 via an *unspecified* mapping (no code table)
|
|
897
|
+
* IG routes status through ORC-5 via an *unspecified* mapping (no code table), so we cannot derive
|
|
898
898
|
* it, flag ORC-5 unmapped, and leave `status` absent rather than mis-applying the ORC-1 table
|
|
899
|
-
* against the IG's own condition. The required-`status` emit gate then **withholds** the request
|
|
899
|
+
* against the IG's own condition. The required-`status` emit gate then **withholds** the request,
|
|
900
900
|
* never guessed, never coerced.
|
|
901
901
|
* - **`intent` (required 1..1) = `order`.** The IG maps ORC-1/OBR → `intent` as `equivalent` but ships
|
|
902
902
|
* **no value ConceptMap** for it; the ORM_O01/OML_O21 families are, by definition, *order* messages
|
|
903
903
|
* (their message maps create a `ServiceRequest`/`MedicationRequest` per order), so `intent` is fixed
|
|
904
904
|
* to the `request-intent` code `order` from that message context. This is a resource-level constant
|
|
905
|
-
* grounded in the message family
|
|
905
|
+
* grounded in the message family, **not** a fabricated per-code translation row. The finer
|
|
906
906
|
* OBR-11-conditioned intent refinement is deferred.
|
|
907
907
|
* - **`subject` (required 1..1).** Wired to the bundle's Patient; a request with no resolvable Patient
|
|
908
908
|
* is withheld rather than emitted with a dangling/absent subject.
|
|
909
909
|
*
|
|
910
|
-
* - **`priority` (0..1)
|
|
910
|
+
* - **`priority` (0..1), value-translated.** OBR-5 → `ServiceRequest.priority` via the IG
|
|
911
911
|
* **Table HL70485 to Request Priority** ConceptMap ({@link SERVICE_REQUEST_PRIORITY_MAP}): only
|
|
912
912
|
* `S→stat`, `A→asap`, `R→routine` carry a target (each `equivalent`, and all three are valid
|
|
913
|
-
* `request-priority` members). Every other v2-0485 code
|
|
914
|
-
* timing-critical family, `PRN`
|
|
913
|
+
* `request-priority` members). Every other v2-0485 code (`P`, `C`, `T`, the
|
|
914
|
+
* `T{S,M,H,D,W,L}<integer>` timing-critical family, `PRN`) sits in the IG map's `(unmapped)` group, so a valued OBR-5 the map
|
|
915
915
|
* has no target for leaves `priority` absent + flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED},
|
|
916
|
-
* never guessed. (`priority` is 0..1, so an unmapped value simply omits it
|
|
916
|
+
* never guessed. (`priority` is 0..1, so an unmapped value simply omits it: the request still emits.)
|
|
917
917
|
*
|
|
918
918
|
* Deferred and flagged elsewhere, not silently mapped: ORC-7/OBR-27 timing (`$this`), ORC-12/OBR-16
|
|
919
919
|
* requester + ORC-21..24 ordering facility/provider (need Practitioner/PractitionerRole/Organization
|
|
@@ -927,7 +927,7 @@ declare const DIAGNOSTIC_REPORT_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
927
927
|
* HL7 v2 Table 0119 (Order Control Codes) → FHIR `request-status` (`ServiceRequest.status`), per the
|
|
928
928
|
* IG **Table HL70119 to Request Status** ConceptMap (each `is equivalent to`). Only these **19** source
|
|
929
929
|
* codes carry a target; every other v2-0119 code sits in the IG's explicit `(unmapped)` group
|
|
930
|
-
* (verified firsthand against the published v1.0.0 ConceptMap
|
|
930
|
+
* (verified firsthand against the published v1.0.0 ConceptMap: CH/CN/CP/DE/LI/NA/OE/OF/OP/OR/PA/RE/
|
|
931
931
|
* RF/RP/RR/RU/SC/SN/SR/SS/UA/UC/UD/UF/UH/UM/UN/UR/UX/XO/XR/XX/MC are all `unmatched`, and the map
|
|
932
932
|
* declares no `unmapped` default), so an ORC-1 with one of them leaves `status` absent + flagged and
|
|
933
933
|
* the request is withheld. `request-status` has no `cancelled`; the cancel/discontinue codes map to
|
|
@@ -938,15 +938,15 @@ declare const REQUEST_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
938
938
|
* HL7 v2 Table 0485 (Extended Priority Codes) → FHIR `request-priority` (`ServiceRequest.priority`),
|
|
939
939
|
* per the IG **Table HL70485 to Request Priority** ConceptMap (each `is equivalent to`; verified
|
|
940
940
|
* firsthand against the published v1.0.0 ConceptMap). Only these **three** source codes carry a
|
|
941
|
-
* target; every other v2-0485 code
|
|
942
|
-
* `T{S,M,H,D,W,L}<integer>` timing-critical family, and `PRN` (As needed)
|
|
941
|
+
* target; every other v2-0485 code, namely `P` (Preop), `C` (Callback), `T` (Timing critical), the
|
|
942
|
+
* `T{S,M,H,D,W,L}<integer>` timing-critical family, and `PRN` (As needed), sits in the IG's
|
|
943
943
|
* `(unmapped)` group with no target, so an OBR-5 carrying one leaves `priority` absent + flagged.
|
|
944
944
|
* All three targets (`stat`/`asap`/`routine`) are valid `request-priority` members.
|
|
945
945
|
*/
|
|
946
946
|
declare const SERVICE_REQUEST_PRIORITY_MAP: Readonly<Record<string, string>>;
|
|
947
947
|
|
|
948
948
|
/**
|
|
949
|
-
* VXU_V04 → FHIR `Immunization
|
|
949
|
+
* VXU_V04 → FHIR `Immunization`: the thin IG single for immunization administration,
|
|
950
950
|
* grounded firsthand on the IG **VXU_V04 message map** and the **RXA/RXR/ORC → Immunization**
|
|
951
951
|
* segment maps (`hl7.fhir.uv.v2mappings`, STU1; `ConceptMap-message-vxu-v04-to-bundle.json`,
|
|
952
952
|
* `ConceptMap-segment-rxa-to-immunization.json`, `ConceptMap-segment-rxr-to-immunization.json`,
|
|
@@ -957,7 +957,7 @@ declare const SERVICE_REQUEST_PRIORITY_MAP: Readonly<Record<string, string>>;
|
|
|
957
957
|
*
|
|
958
958
|
* | v2 field | FHIR target | via |
|
|
959
959
|
* |---|---|---|
|
|
960
|
-
* | RXA-5 Administered Code (CE) | `vaccineCode` (required 1..1) | {@link toFhirCodeableConcept} (structural
|
|
960
|
+
* | RXA-5 Administered Code (CE) | `vaccineCode` (required 1..1) | {@link toFhirCodeableConcept} (structural, no IG value map) |
|
|
961
961
|
* | RXA-3 Date/Time Start of Administration (DTM) | `occurrenceDateTime` (required, occurrence[x]) | {@link toFhirDateTime} |
|
|
962
962
|
* | RXA-20 Completion Status + RXA-21 Action Code | `status` (required 1..1) | {@link buildStatus} (HL70322 + IG assignments) |
|
|
963
963
|
* | RXA-6 Administered Amount + RXA-7 Units | `doseQuantity` | {@link quantityFromRawMagnitude} |
|
|
@@ -980,18 +980,18 @@ declare const SERVICE_REQUEST_PRIORITY_MAP: Readonly<Record<string, string>>;
|
|
|
980
980
|
* event-status ConceptMap, whose targets `completed`/`not-done` are all valid `immunization-status`
|
|
981
981
|
* members). A **valued** RXA-20 the HL70322 map has no target for is flagged
|
|
982
982
|
* {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}, `status` left absent, and the required-`status` emit gate
|
|
983
|
-
* **withholds** the Immunization
|
|
983
|
+
* **withholds** the Immunization, never guessed, never coerced.
|
|
984
984
|
* - **`vaccineCode` (required 1..1) + `occurrence[x]` (required 1..1) + `patient` (required 1..1).** An
|
|
985
985
|
* absent RXA-5, RXA-3, or bundle Patient leaves the resource missing a required element, so it is
|
|
986
986
|
* withheld by the emit gate rather than emitted incomplete.
|
|
987
987
|
* - **Dose.** RXA-6/RXA-7 → `doseQuantity` via {@link quantityFromRawMagnitude}: precision-exact magnitude,
|
|
988
|
-
* non-UCUM unit preserved verbatim with `.code`/`.system` absent + flagged
|
|
988
|
+
* non-UCUM unit preserved verbatim with `.code`/`.system` absent + flagged, never a fabricated UCUM code.
|
|
989
989
|
* - **Route/site value translation.** RXR-1 route → {@link ROUTE_VALUE_MAP} (HL70162) and
|
|
990
990
|
* RXR-2 site → {@link SITE_VALUE_MAP} (HL70550) are value-translated additively (derived target coding
|
|
991
991
|
* added, raw coding preserved); a code outside the table is preserved + flagged, never coerced.
|
|
992
|
-
* - **`vaccineCode` is NOT value-translated
|
|
992
|
+
* - **`vaccineCode` is NOT value-translated: by grounding, not omission.** RXA-5 has **no** `mappedVia`
|
|
993
993
|
* value ConceptMap in the IG's RXA→Immunization segment map (verified firsthand), so the code (typically
|
|
994
|
-
* CVX) is carried **structurally** (system recognized, value preserved)
|
|
994
|
+
* CVX) is carried **structurally** (system recognized, value preserved): a translation is never
|
|
995
995
|
* invented for it.
|
|
996
996
|
*
|
|
997
997
|
* Deferred and flagged elsewhere, not silently mapped: RXA-10 performer, RXA-17 manufacturer, RXA-27/28
|
|
@@ -1014,7 +1014,7 @@ declare const SERVICE_REQUEST_PRIORITY_MAP: Readonly<Record<string, string>>;
|
|
|
1014
1014
|
declare const IMMUNIZATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
1015
1015
|
|
|
1016
1016
|
/**
|
|
1017
|
-
* SIU_S12 → FHIR `Appointment
|
|
1017
|
+
* SIU_S12 → FHIR `Appointment`: the thin IG single for scheduling, grounded
|
|
1018
1018
|
* firsthand on the IG **SIU_S12 message map**, the **SCH/AIS/PID → Appointment** segment maps, the
|
|
1019
1019
|
* **Table HL70278 → AppointmentStatus** ConceptMap, and the **TQ → Appointment** datatype map
|
|
1020
1020
|
* (`hl7.fhir.uv.v2mappings`, STU1; `ConceptMap-message-siu-s12-to-bundle.json`,
|
|
@@ -1028,7 +1028,7 @@ declare const IMMUNIZATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
1028
1028
|
* |---|---|---|
|
|
1029
1029
|
* | SCH-25 Filler Status Code | `status` (required 1..1) | {@link APPOINTMENT_STATUS_MAP} (HL70278) |
|
|
1030
1030
|
* | SCH-1 Placer / SCH-2 Filler Appointment ID | `identifier` | EI.1 → `Identifier.value` |
|
|
1031
|
-
* | SCH-7 Appointment Reason (CWE) | `reasonCode` | {@link toFhirCodeableConcept} (structural
|
|
1031
|
+
* | SCH-7 Appointment Reason (CWE) | `reasonCode` | {@link toFhirCodeableConcept} (structural: SNOMED target, BYO) |
|
|
1032
1032
|
* | SCH-8 Appointment Type (CWE) | `appointmentType` | {@link APPOINTMENT_TYPE_VALUE_MAP} (HL70277, value-translated) |
|
|
1033
1033
|
* | SCH-9 Duration + SCH-10 Units | `minutesDuration` | integer, only when SCH-10 is minutes |
|
|
1034
1034
|
* | SCH-11 Appointment Timing Quantity (TQ) | `start` / `end` (instant) | TQ.4/TQ.5 → {@link toFhirDateTime} |
|
|
@@ -1039,11 +1039,11 @@ declare const IMMUNIZATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
1039
1039
|
* - **`status` (required 1..1).** SCH-25 → {@link APPOINTMENT_STATUS_MAP} (HL70278). The three HL70278
|
|
1040
1040
|
* codes the IG leaves unmatched (`Discontinued`, `Blocked`, `Overbook`) and an absent SCH-25 leave
|
|
1041
1041
|
* `status` absent + flagged {@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED}; the required-`status` emit gate
|
|
1042
|
-
* then **withholds** the Appointment
|
|
1042
|
+
* then **withholds** the Appointment, never guessed.
|
|
1043
1043
|
* - **`participant` (required 1..*).** The bundle Patient is emitted as the required participant. Its
|
|
1044
1044
|
* `participant.status` (a required-bound `code` the IG supplies no source for) is emitted as a
|
|
1045
|
-
* `data-absent-reason` primitive (value `unknown`) + flagged {@link ISSUE_CODES.TRANSFORM_REQUIRED_ELEMENT_UNKNOWN}
|
|
1046
|
-
*
|
|
1045
|
+
* `data-absent-reason` primitive (value `unknown`) + flagged {@link ISSUE_CODES.TRANSFORM_REQUIRED_ELEMENT_UNKNOWN},
|
|
1046
|
+
* the spec-clean way to satisfy a required code whose value is genuinely unknown, never fabricated. An
|
|
1047
1047
|
* Appointment with no resolvable Patient (and no other groundable actor this library builds) has no
|
|
1048
1048
|
* participant and is withheld.
|
|
1049
1049
|
* - **`start`/`end` (instant).** SCH-11's TQ.4/TQ.5 become `start`/`end` only when they are fully-zoned
|
|
@@ -1052,10 +1052,10 @@ declare const IMMUNIZATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
1052
1052
|
* - **`appointmentType` value translation.** SCH-8 → {@link APPOINTMENT_TYPE_VALUE_MAP}
|
|
1053
1053
|
* (HL70277 `Normal`/`Tentative`/`Complete` identity into `v2-0277`); a code outside the table is
|
|
1054
1054
|
* preserved + flagged, never coerced. **`reasonCode` is NOT value-translated:** SCH-7's IG map target
|
|
1055
|
-
* is SNOMED CT (`table-hl70276-to-sct`)
|
|
1055
|
+
* is SNOMED CT (`table-hl70276-to-sct`), which is encumbered and **not bundled**, so the reason is carried
|
|
1056
1056
|
* structurally (BYO ConceptMap), never SNOMED-translated here. (The IG's SCH→Appointment map *also*
|
|
1057
1057
|
* carries a redundant SCH-7 → `appointmentType[1]` row via `table-hl70277-to-v2-0277`; it is not
|
|
1058
|
-
* applied
|
|
1058
|
+
* applied: SCH-7 carries HL70276 *reason* codes, not HL70277 *type* codes, so translating them through
|
|
1059
1059
|
* the type table would only ever produce spurious unmapped flags. `appointmentType` comes from SCH-8,
|
|
1060
1060
|
* the appointment-*type* field, per that same map's SCH-8 → `appointmentType[1]` row.)
|
|
1061
1061
|
*
|
|
@@ -1068,7 +1068,7 @@ declare const IMMUNIZATION_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
1068
1068
|
/**
|
|
1069
1069
|
* HL7 v2 Table 0278 (Filler Status Code) → FHIR `appointmentstatus` (`Appointment.status`), per the IG
|
|
1070
1070
|
* **Table HL70278 to AppointmentStatus** ConceptMap (each `is equivalent to`). The three source codes
|
|
1071
|
-
* the IG leaves **unmatched** (`Discontinued`, `Blocked`, `Overbook`) are absent here on purpose
|
|
1071
|
+
* the IG leaves **unmatched** (`Discontinued`, `Blocked`, `Overbook`) are absent here on purpose: an
|
|
1072
1072
|
* SCH-25 carrying one of them (or any local code) leaves `Appointment.status` absent + flagged and the
|
|
1073
1073
|
* required-`status` emit gate withholds the Appointment.
|
|
1074
1074
|
*/
|
|
@@ -1077,29 +1077,29 @@ declare const APPOINTMENT_STATUS_MAP: Readonly<Record<string, string>>;
|
|
|
1077
1077
|
/**
|
|
1078
1078
|
* The `$translate`-shaped ConceptMap-application engine + the **license-clean** v2-table → FHIR
|
|
1079
1079
|
* value maps it applies. This is the layer that value-**translates** a coded v2
|
|
1080
|
-
* field
|
|
1080
|
+
* field, not merely carrying its code structurally, but mapping the source table code to the FHIR
|
|
1081
1081
|
* target coding the IG's segment-map `mappedVia` ConceptMap prescribes.
|
|
1082
1082
|
*
|
|
1083
|
-
* **Grounded firsthand on the raw published IG ConceptMaps** (`hl7.fhir.uv.v2mappings`, STU1
|
|
1083
|
+
* **Grounded firsthand on the raw published IG ConceptMaps** (`hl7.fhir.uv.v2mappings`, STU1;
|
|
1084
1084
|
* `ConceptMap-table-*.json`). Each shipped map below cites the exact IG ConceptMap it transcribes and
|
|
1085
1085
|
* was verified against that resource's JSON (its `group.element[].target[]` rows and its `unmatched`
|
|
1086
1086
|
* `(unmapped)` group). The engine is **fail-safe by refusal**: a source code the IG map has **no
|
|
1087
|
-
* target** for (its `(unmapped)` group) is never coerced to a plausible neighbor
|
|
1087
|
+
* target** for (its `(unmapped)` group) is never coerced to a plausible neighbor. The caller flags it
|
|
1088
1088
|
* and preserves the raw coding, or withholds the value, but a target is **never fabricated**.
|
|
1089
1089
|
*
|
|
1090
1090
|
* **License posture.** Only maps whose target CodeSystem is **freely redistributable** are
|
|
1091
1091
|
* shipped here: the HL7 THO v2 tables (`v2-0162`, `v2-0550`, `v2-0277`, `v2-0161`) and HL7 v3
|
|
1092
|
-
* (`v3-RouteOfAdministration`) are HL7's own, license-clean. The IG's `*-to-sct` value maps
|
|
1093
|
-
* **RXR-4 method** (`table-hl70165-to-sct`) and **SCH-7 reason** (`table-hl70276-to-sct`)
|
|
1092
|
+
* (`v3-RouteOfAdministration`) are HL7's own, license-clean. The IG's `*-to-sct` value maps,
|
|
1093
|
+
* **RXR-4 method** (`table-hl70165-to-sct`) and **SCH-7 reason** (`table-hl70276-to-sct`), translate
|
|
1094
1094
|
* **into SNOMED CT**, which is **license-encumbered and is NOT bundled**; those fields stay
|
|
1095
1095
|
* structurally carried (BYO ConceptMap), never value-translated here (see their message modules).
|
|
1096
1096
|
*
|
|
1097
1097
|
* **Additive, never mutating.** A successful translation preserves the raw source coding
|
|
1098
1098
|
* (its code, display, version, and any `CWE.4/5/6` alternate triplet) and *adds* the derived target
|
|
1099
|
-
* coding
|
|
1099
|
+
* coding: recognition never overwrites or discards what the message said; it augments it with the
|
|
1100
1100
|
* IG-mapped equivalent. And it only fires when the field's primary coding is genuinely from the map's
|
|
1101
1101
|
* **bound source table** (CWE.3 absent, or naming that table): a field that declares a *foreign*
|
|
1102
|
-
* coding system (a local `99…`, SNOMED, …) is carried structurally and flagged
|
|
1102
|
+
* coding system (a local `99…`, SNOMED, …) is carried structurally and flagged, and its code is **never**
|
|
1103
1103
|
* asserted to be the standard concept just because the string happens to collide with a table code.
|
|
1104
1104
|
*
|
|
1105
1105
|
* @packageDocumentation
|
|
@@ -1135,11 +1135,11 @@ interface CodedValueMap {
|
|
|
1135
1135
|
/** The source table's canonical CodeSystem URI (what the raw v2 code is a member of when mapped). */
|
|
1136
1136
|
readonly sourceSystem: string;
|
|
1137
1137
|
/**
|
|
1138
|
-
* The CWE.3 (`nameOfCodingSystem`) mnemonics that denote this map's **bound source table
|
|
1138
|
+
* The CWE.3 (`nameOfCodingSystem`) mnemonics that denote this map's **bound source table**: the
|
|
1139
1139
|
* HL7 forms (`"HL70162"`, `"0162"`, …). Translation applies **only** when the field's primary
|
|
1140
1140
|
* coding is from the bound table: CWE.3 absent/empty (a positionally-bound bare code) **or** CWE.3 ∈
|
|
1141
1141
|
* this set. A CWE that declares a **different** coding system (a local `99…`, or SNOMED) is not a
|
|
1142
|
-
* source-table code, so the map is not applied to it
|
|
1142
|
+
* source-table code, so the map is not applied to it: the raw coding is carried structurally + its
|
|
1143
1143
|
* system flagged, never asserted as the standard concept.
|
|
1144
1144
|
*/
|
|
1145
1145
|
readonly sourceMnemonics: ReadonlySet<string>;
|
|
@@ -1147,7 +1147,7 @@ interface CodedValueMap {
|
|
|
1147
1147
|
readonly translate: (code: string) => CodedTarget | undefined;
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
|
-
* **RXR-1 Route
|
|
1150
|
+
* **RXR-1 Route**: IG `ConceptMap/table-hl70162-to-v2-0162`. Two IG groups, transcribed verbatim:
|
|
1151
1151
|
* a 41-code **identity** group (source `v2-0162` → target `v2-0162`, each `equivalent`) and a 6-code
|
|
1152
1152
|
* **remap** group into `v3-RouteOfAdministration` (`ID→IDINJ`, `IM→IM`, `IV→IVINJ`, `PO→PO`, `SC→SQ`,
|
|
1153
1153
|
* `TD→TRNSDERM`, each `equivalent`, with the IG target displays). The two source-code sets are
|
|
@@ -1156,22 +1156,22 @@ interface CodedValueMap {
|
|
|
1156
1156
|
*/
|
|
1157
1157
|
declare const ROUTE_VALUE_MAP: CodedValueMap;
|
|
1158
1158
|
/**
|
|
1159
|
-
* **RXR-2 Administration Site
|
|
1159
|
+
* **RXR-2 Administration Site**: IG `ConceptMap/table-hl70550-to-v2-0550`. A single **identity**
|
|
1160
1160
|
* group of 443 body-part codes (source `v2-0550` → target `v2-0550`, each `equivalent`), transcribed
|
|
1161
|
-
* verbatim from the published STU1 ConceptMap
|
|
1161
|
+
* verbatim from the published STU1 ConceptMap, **including** its as-published data-quality artifacts
|
|
1162
1162
|
* (`CHESTÂ`, a lone `Â`, `KIDNÂ`, where a stray U+00C2 leaked from the IG's source
|
|
1163
1163
|
* encoding). They are preserved for source-fidelity; they are inert (a clean `CHEST`/`KIDN` simply
|
|
1164
1164
|
* falls through to unmapped). A code not in the table is unmapped → raw coding preserved + flagged.
|
|
1165
1165
|
*/
|
|
1166
1166
|
declare const SITE_VALUE_MAP: CodedValueMap;
|
|
1167
1167
|
/**
|
|
1168
|
-
* **SCH-8 Appointment Type
|
|
1168
|
+
* **SCH-8 Appointment Type**: IG `ConceptMap/table-hl70277-to-v2-0277`. A single **identity** group
|
|
1169
1169
|
* of the three v2-0277 codes (`Normal`, `Tentative`, `Complete` → themselves, each `equivalent`,
|
|
1170
1170
|
* source and target both `v2-0277`). Any other code is unmapped → raw coding preserved + flagged.
|
|
1171
1171
|
*/
|
|
1172
1172
|
declare const APPOINTMENT_TYPE_VALUE_MAP: CodedValueMap;
|
|
1173
1173
|
/**
|
|
1174
|
-
* **RXO-9 Allow Substitutions
|
|
1174
|
+
* **RXO-9 Allow Substitutions**: IG `ConceptMap/table-hl70161-to-v2-0161`. A single **identity**
|
|
1175
1175
|
* group of the three v2-0161 codes (`N` NOT authorized, `G` generic, `T` therapeutic → themselves,
|
|
1176
1176
|
* each `equivalent`, source and target both `v2-0161`), the target for
|
|
1177
1177
|
* `MedicationRequest.substitution.allowedCodeableConcept`. Any other code is unmapped → the
|
|
@@ -1180,7 +1180,7 @@ declare const APPOINTMENT_TYPE_VALUE_MAP: CodedValueMap;
|
|
|
1180
1180
|
declare const SUBSTITUTION_VALUE_MAP: CodedValueMap;
|
|
1181
1181
|
/**
|
|
1182
1182
|
* The bound-table target for a coded element's **primary** coding, or `undefined` when the map does
|
|
1183
|
-
* not faithfully apply
|
|
1183
|
+
* not faithfully apply, i.e. the primary declares a coding system that is **not** this map's bound
|
|
1184
1184
|
* table (CWE.3 present and not in {@link CodedValueMap.sourceMnemonics}), the primary code is empty, or
|
|
1185
1185
|
* the code is in the IG map's `(unmapped)` group. Never asserts a standard translation for a foreign
|
|
1186
1186
|
* coding system, and never fabricates a target.
|
|
@@ -1196,7 +1196,7 @@ declare const SUBSTITUTION_VALUE_MAP: CodedValueMap;
|
|
|
1196
1196
|
*/
|
|
1197
1197
|
declare function translateBound(cwe: CodedElement, map: CodedValueMap): CodedTarget | undefined;
|
|
1198
1198
|
/**
|
|
1199
|
-
* Build a FHIR `CodeableConcept` node for a {@link CodedTarget}
|
|
1199
|
+
* Build a FHIR `CodeableConcept` node for a {@link CodedTarget}: the single translated coding, with
|
|
1200
1200
|
* an optional free-`text`. Used by translate-or-withhold callers (e.g. substitution) that build the
|
|
1201
1201
|
* CodeableConcept only on a successful translation.
|
|
1202
1202
|
*
|
|
@@ -1212,16 +1212,16 @@ declare function translateBound(cwe: CodedElement, map: CodedValueMap): CodedTar
|
|
|
1212
1212
|
declare function codeableConceptFromTarget(target: CodedTarget, text?: string): FhirComplex;
|
|
1213
1213
|
/**
|
|
1214
1214
|
* Value-translate a coded v2 element to a FHIR `CodeableConcept` **via** a license-clean
|
|
1215
|
-
* {@link CodedValueMap}, **additively** and fail-safe
|
|
1215
|
+
* {@link CodedValueMap}, **additively** and fail-safe, never mutating or discarding what the message
|
|
1216
1216
|
* said:
|
|
1217
1217
|
*
|
|
1218
|
-
* - **Primary code recognized as a bound-table code** ({@link translateBound}
|
|
1218
|
+
* - **Primary code recognized as a bound-table code** ({@link translateBound}: CWE.3 absent or names
|
|
1219
1219
|
* the bound table, and the code is in the IG map's mapped group) → the **primary** coding is emitted
|
|
1220
1220
|
* in the recognized source-table system (`map.sourceSystem`, carrying `CWE.7` version) and the
|
|
1221
1221
|
* **derived** target coding is *appended* when it differs (a remap such as `SC→SQ`); the **alternate
|
|
1222
1222
|
* triplet** (`CWE.4/5/6`, via {@link buildCoding}, with its own system resolution + flags) and the
|
|
1223
|
-
* original `CWE.9` text are preserved. No primary unmapped flag
|
|
1224
|
-
* - **Otherwise
|
|
1223
|
+
* original `CWE.9` text are preserved. No primary unmapped flag: the value was faithfully recognized.
|
|
1224
|
+
* - **Otherwise**: the primary declares a **foreign** coding system (not the bound table), the code is
|
|
1225
1225
|
* empty, or it is in the IG's `(unmapped)` group → this defers entirely to the **structural**
|
|
1226
1226
|
* {@link toFhirCodeableConcept}, which preserves the raw coding (and its `CWE.4/5/6` alternate and
|
|
1227
1227
|
* `CWE.7` version) and flags it ({@link ISSUE_CODES.TRANSFORM_CODE_UNMAPPED} /
|
|
@@ -1243,21 +1243,21 @@ declare function codeableConceptFromTarget(target: CodedTarget, text?: string):
|
|
|
1243
1243
|
declare function toFhirCodeableConceptVia(cwe: CodedElement, map: CodedValueMap, ctx?: TransformContext): ConvertResult<FhirComplex>;
|
|
1244
1244
|
|
|
1245
1245
|
/**
|
|
1246
|
-
* Public entry point for `@cosyte/transform
|
|
1246
|
+
* Public entry point for `@cosyte/transform`: the HL7 v2 → FHIR R4 transformation library.
|
|
1247
1247
|
*
|
|
1248
1248
|
* `@cosyte/transform` is **not** a parser; it is a **consumer** one tier above the parser suite. It
|
|
1249
1249
|
* takes already-parsed `@cosyte/hl7` composites and produces validated `@cosyte/fhir` model nodes,
|
|
1250
1250
|
* grounded on the official **HL7 Version 2 to FHIR** Implementation Guide (`hl7.fhir.uv.v2mappings`,
|
|
1251
1251
|
* STU Edition 1). Its whole promise is narrow and honest: **IG-grounded, fail-safe transformation
|
|
1252
|
-
* with typed, value-free diagnostics
|
|
1252
|
+
* with typed, value-free diagnostics, never a confident wrong FHIR value.**
|
|
1253
1253
|
*
|
|
1254
1254
|
* This module ships the six safety-critical datatype converters, the immutable
|
|
1255
1255
|
* `OperationOutcome`-shaped diagnostic channel and the NamingSystem resolver they consult,
|
|
1256
|
-
* the message-level assembly
|
|
1256
|
+
* the message-level assembly (HL7 v2 **ADT → FHIR Patient + Encounter**, the
|
|
1257
1257
|
* **ORU^R01 → DiagnosticReport + Observation** results graph, the order-entry graph
|
|
1258
1258
|
* (**ORM_O01 / OML_O21 → ServiceRequest** and **RXO → MedicationRequest**), and the thin IG
|
|
1259
1259
|
* singles (**VXU_V04 → Immunization**, **SIU_S12 → Appointment**, **MDM_T02 → DocumentReference**),
|
|
1260
|
-
* all through `toFhir(msg)`
|
|
1260
|
+
* all through `toFhir(msg)`), and the **terminology value-translation** layer: a
|
|
1261
1261
|
* `$translate`-shaped {@link toFhirCodeableConceptVia} engine applying the license-clean IG value
|
|
1262
1262
|
* ConceptMaps to the previously structural-only coded fields (route/site, appointment type, order
|
|
1263
1263
|
* priority, substitution). Terminology **depth beyond these maps**, profiles, and the reverse
|