@cosyte/terminology 0.0.13 → 0.1.0
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 +152 -0
- package/README.md +102 -10
- package/dist/index.cjs +254 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +221 -31
- package/dist/index.d.ts +221 -31
- package/dist/index.mjs +254 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +48 -26
- package/vendor/ucum/NOTICE.md +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -111,9 +111,12 @@ declare function codeableConcept(init: CodeableConcept): CodeableConcept;
|
|
|
111
111
|
*
|
|
112
112
|
* Read that as the rule, and note what it does **not** say. It does not say no factory takes a
|
|
113
113
|
* `string` parameter. Several do: `malformed(path, fault)` in `conceptmap/load.ts` and
|
|
114
|
-
* `valueset/load.ts`, and `cannotExpand(detail, path)`, `truncated(detail, path)
|
|
115
|
-
* `underPath(d, prefix)` in `valueset/`, where `expand.ts`
|
|
116
|
-
*
|
|
114
|
+
* `valueset/load.ts`, and `cannotExpand(detail, path)`, `truncated(detail, path)`,
|
|
115
|
+
* `enumeratedUndefined(detail, path)` and `underPath(d, prefix)` in `valueset/`, where `expand.ts`
|
|
116
|
+
* and `validate.ts` each carry their own copy of the ones both operations raise
|
|
117
|
+
* (`enumeratedUndefined` is `expand.ts`'s alone: membership decides that case rather than reporting
|
|
118
|
+
* it, and a decided outcome carries no diagnostic). It says every **argument** reaching them is
|
|
119
|
+
* engine-owned: each `fault` and `detail` is a
|
|
117
120
|
* literal at the call site, each `path` and `prefix` is built from indices by the loader that
|
|
118
121
|
* raises it. That distinction is the thing to preserve: an absolute "no factory takes a value
|
|
119
122
|
* parameter" reads as a stronger guarantee than the one the code makes, and those factories are the
|
|
@@ -227,19 +230,43 @@ declare const DIAGNOSTIC_CODES: {
|
|
|
227
230
|
readonly TERM_CONCEPT_HEADER_NOT_BILLABLE: "TERM_CONCEPT_HEADER_NOT_BILLABLE";
|
|
228
231
|
/**
|
|
229
232
|
* A ValueSet `compose` part could **not be expanded**: an intensional `include`/`exclude` whose
|
|
230
|
-
* code system was not supplied, an unresolvable referenced value set,
|
|
231
|
-
* engine does not implement
|
|
233
|
+
* code system was not supplied, an unresolvable referenced value set, a `filter` operator the
|
|
234
|
+
* engine does not implement, or a component whose declared code system version disagrees with the
|
|
235
|
+
* supplied release (or names a pin that release carries no version to confirm). Surfaced as a
|
|
236
|
+
* typed outcome that marks the expansion **incomplete**;
|
|
232
237
|
* the engine **never** fabricates a member and **never** returns a silently-empty "no members"
|
|
233
238
|
* answer for a part it could not compute (a false "not a member" is a clinical error).
|
|
234
239
|
*/
|
|
235
240
|
readonly TERM_VALUESET_CANNOT_EXPAND: "TERM_VALUESET_CANNOT_EXPAND";
|
|
236
241
|
/**
|
|
237
242
|
* A **pre-computed** `ValueSet.expansion` is **incomplete**: its `total` exceeds the number of
|
|
238
|
-
* `contains` entries,
|
|
239
|
-
* hazard)
|
|
240
|
-
*
|
|
243
|
+
* `contains` entries, it is flagged too-costly (the VSAC `$expand` >1200-code truncation
|
|
244
|
+
* hazard), or it is marked `unclosed` (the value set is unbounded because it includes
|
|
245
|
+
* post-coordinated content, so no expansion can enumerate it). The engine **never treats an
|
|
246
|
+
* incomplete expansion as complete membership**: a code absent from one is `undetermined`, never
|
|
247
|
+
* a confident "not a member". The diagnostic's `detail` says which of those it was.
|
|
241
248
|
*/
|
|
242
249
|
readonly TERM_VALUESET_EXPANSION_TRUNCATED: "TERM_VALUESET_EXPANSION_TRUNCATED";
|
|
250
|
+
/**
|
|
251
|
+
* A `ValueSet.compose` component **enumerated** a code the release supplied for its `system` does
|
|
252
|
+
* not define, so the code was **not admitted** as a member. The never-fabricate invariant applied
|
|
253
|
+
* to an extensional selection: enumerating a code is the value set's claim that it exists, and
|
|
254
|
+
* asserting membership for it while holding the very release that shows it does not is the engine
|
|
255
|
+
* deciding against its own evidence.
|
|
256
|
+
*
|
|
257
|
+
* Raised **only** where the evidence is in hand: a release keyed by the component's `system` that
|
|
258
|
+
* the component's declared `version` (if any) agrees with. No release for that system, a declared
|
|
259
|
+
* version the supplied release does not agree with, or a component naming no `system` at all
|
|
260
|
+
* leaves the engine with no contrary evidence, so every enumerated code is carried and **no
|
|
261
|
+
* diagnostic is raised**: absence of evidence is not evidence the code is undefined.
|
|
262
|
+
*
|
|
263
|
+
* The answer stays **decided**, unlike {@link TERM_VALUESET_CANNOT_EXPAND}: the engine computed
|
|
264
|
+
* membership on the evidence it was given, so `expand` reports `complete: true` and
|
|
265
|
+
* `validateCodeInValueSet` reports a decided non-member for the dropped code, rather than a lower
|
|
266
|
+
* bound or a refusal. One diagnostic is raised per affected component, located by that
|
|
267
|
+
* component's own index path, however many of its codes were dropped.
|
|
268
|
+
*/
|
|
269
|
+
readonly TERM_VALUESET_ENUMERATED_CODE_UNDEFINED: "TERM_VALUESET_ENUMERATED_CODE_UNDEFINED";
|
|
243
270
|
/**
|
|
244
271
|
* A UCUM unit expression is **not valid**: it does not parse against the UCUM grammar, or it
|
|
245
272
|
* names an atom absent from the vendored UCUM table. A **first-class typed outcome, never an
|
|
@@ -652,6 +679,29 @@ interface TranslateMatch {
|
|
|
652
679
|
/** Author's free-text comment on this mapping, when present (carried verbatim, e.g. map advice). */
|
|
653
680
|
readonly comment?: string;
|
|
654
681
|
}
|
|
682
|
+
/**
|
|
683
|
+
* One target the map explicitly asserted is **not related** to the source: an R4 `disjoint` row,
|
|
684
|
+
* carried verbatim on a {@link TranslateUnmapped} result so the assertion the map author made is
|
|
685
|
+
* not lost when the source reports as not translated.
|
|
686
|
+
*
|
|
687
|
+
* This is the opposite of a {@link TranslateMatch}: a `disjoint` row is a declared non-mapping, so
|
|
688
|
+
* it never counts toward the translated verdict. It is surfaced because dropping it would discard
|
|
689
|
+
* what the steward said. A pure `unmatched` assertion carries no target code and is not surfaced
|
|
690
|
+
* here.
|
|
691
|
+
*/
|
|
692
|
+
interface TranslateNotRelated {
|
|
693
|
+
/** The target {@link Coding} exactly as declared in the map (frozen). */
|
|
694
|
+
readonly target: Coding;
|
|
695
|
+
/**
|
|
696
|
+
* The normalized, version-neutral relationship (R5 vocabulary), folded from the token below by
|
|
697
|
+
* the same table every match uses: always `not-related-to` for a `disjoint` row.
|
|
698
|
+
*/
|
|
699
|
+
readonly relationship: Relationship;
|
|
700
|
+
/** Always `disjoint`: the verbatim FHIR R4 `equivalence` token this assertion was declared with. */
|
|
701
|
+
readonly equivalence: "disjoint";
|
|
702
|
+
/** Author's free-text comment on this assertion, when present (carried verbatim). */
|
|
703
|
+
readonly comment?: string;
|
|
704
|
+
}
|
|
655
705
|
/**
|
|
656
706
|
* The FHIR R4 `group.unmapped.mode` an unmapped source fell through to: the map author's declared
|
|
657
707
|
* fallback behavior. Surfaced (never silently acted on): the caller decides whether to trust a
|
|
@@ -660,7 +710,8 @@ interface TranslateMatch {
|
|
|
660
710
|
* - `provided`: echo the source code as the target (the map declares no real mapping).
|
|
661
711
|
* - `fixed`: a single fixed fallback code the map declares for *all* unmapped sources.
|
|
662
712
|
* - `other-map`: consult the referenced ConceptMap (which this engine does not auto-follow).
|
|
663
|
-
* - `none`: no `group.unmapped` directive applied (plain no-match, or an
|
|
713
|
+
* - `none`: no `group.unmapped` directive applied (plain no-match, or an authored non-mapping: an
|
|
714
|
+
* explicit `unmatched`, or a source whose every declared target is `disjoint`).
|
|
664
715
|
*/
|
|
665
716
|
type UnmappedMode = "provided" | "fixed" | "other-map" | "none";
|
|
666
717
|
/** Provenance of a translation, which map (and which group's systems) produced it. */
|
|
@@ -680,11 +731,21 @@ interface MapProvenance {
|
|
|
680
731
|
/** The target code system of the group that matched, when known. */
|
|
681
732
|
readonly targetSystem?: string;
|
|
682
733
|
}
|
|
683
|
-
/**
|
|
734
|
+
/**
|
|
735
|
+
* A successful translation: one or more matches, never empty (an empty result is `unmapped`), and
|
|
736
|
+
* **at least one of them asserts a relationship** to the source. A `disjoint` row still appears in
|
|
737
|
+
* `matches`, in its declared position, whenever some other target for the same source does assert a
|
|
738
|
+
* relationship: nothing the map said is dropped. When *every* declared target asserts non-relation
|
|
739
|
+
* there is no relationship to report, so the result is a {@link TranslateUnmapped} carrying those
|
|
740
|
+
* rows on `notRelated` instead.
|
|
741
|
+
*/
|
|
684
742
|
interface TranslateMatched {
|
|
685
743
|
/** Discriminant: the source mapped. */
|
|
686
744
|
readonly unmapped: false;
|
|
687
|
-
/**
|
|
745
|
+
/**
|
|
746
|
+
* The target concepts, in declared order. Non-empty and frozen. At least one carries a
|
|
747
|
+
* relationship other than `not-related-to`.
|
|
748
|
+
*/
|
|
688
749
|
readonly matches: readonly TranslateMatch[];
|
|
689
750
|
/** Where this translation came from. */
|
|
690
751
|
readonly provenance: MapProvenance;
|
|
@@ -694,6 +755,11 @@ interface TranslateMatched {
|
|
|
694
755
|
* **no target is ever guessed**. Any `group.unmapped` fallback the author declared is reported via
|
|
695
756
|
* {@link UnmappedMode} (and `fixedTarget`/`otherMapUrl`) for the caller to accept or reject: the
|
|
696
757
|
* engine does not silently substitute it.
|
|
758
|
+
*
|
|
759
|
+
* A source whose every declared target asserts non-relation (R4 `disjoint` or `unmatched`) reports
|
|
760
|
+
* here too: the map said these concepts are *not* related, which is an answer, not a translation.
|
|
761
|
+
* The `disjoint` rows it asserted are carried on `notRelated`, verbatim. Any target on this result
|
|
762
|
+
* was declared in the map; none of it is a mapping.
|
|
697
763
|
*/
|
|
698
764
|
interface TranslateUnmapped {
|
|
699
765
|
/** Discriminant: the source did not map. */
|
|
@@ -704,6 +770,13 @@ interface TranslateUnmapped {
|
|
|
704
770
|
readonly mode: UnmappedMode;
|
|
705
771
|
/** The original source {@link Coding}, surfaced untouched. */
|
|
706
772
|
readonly source: Coding;
|
|
773
|
+
/**
|
|
774
|
+
* The `disjoint` rows the map declared for this source, in declared order, when it declared any:
|
|
775
|
+
* explicit assertions that those targets are **not related** to the source. Present (frozen and
|
|
776
|
+
* non-empty) only when every declared target asserted non-relation, which is what put the result
|
|
777
|
+
* here; omitted otherwise. These are declared non-mappings, never candidates to fall back to.
|
|
778
|
+
*/
|
|
779
|
+
readonly notRelated?: readonly TranslateNotRelated[];
|
|
707
780
|
/** For `mode: "fixed"`, the author's fixed fallback coding: reported, not auto-applied. */
|
|
708
781
|
readonly fixedTarget?: Coding;
|
|
709
782
|
/** For `mode: "other-map"`, the referenced map's URL: reported, not auto-followed. */
|
|
@@ -831,7 +904,10 @@ declare function loadConceptMap(json: unknown): ConceptMap;
|
|
|
831
904
|
* a **typed {@link TranslateUnmapped}**. Two invariants govern it:
|
|
832
905
|
*
|
|
833
906
|
* 1. **Never fabricate.** An unmapped source yields a surfaced `unmapped` result: never a guessed
|
|
834
|
-
* target. Every target returned is drawn verbatim from the map; the engine invents nothing.
|
|
907
|
+
* target. Every target returned is drawn verbatim from the map; the engine invents nothing. A
|
|
908
|
+
* map that explicitly asserts non-relation (R4 `disjoint`) has answered, so that source reports
|
|
909
|
+
* as not translated with the asserted rows carried on `notRelated`: reading a declared
|
|
910
|
+
* "not related" as a successful translation would be a fabrication of the same kind.
|
|
835
911
|
* 2. **Never invert.** Translation reads the map in its authored direction only: a source coding is
|
|
836
912
|
* matched against `group.element.code` (the source side) and **never** against target codes. A
|
|
837
913
|
* directional map therefore cannot be run backwards: reverse translation requires an explicit
|
|
@@ -846,9 +922,14 @@ declare function loadConceptMap(json: unknown): ConceptMap;
|
|
|
846
922
|
* Matches the coding's `code` against each applicable group's `element.code` (the **source** side,
|
|
847
923
|
* never targets, so the map is never inverted) and returns every declared target for it. A target
|
|
848
924
|
* with an `unmatched` equivalence, or with no `code`, is treated as "no target" (the FHIR way of
|
|
849
|
-
* asserting a non-mapping), and does not count as a match.
|
|
850
|
-
*
|
|
851
|
-
*
|
|
925
|
+
* asserting a non-mapping), and does not count as a match. A `disjoint` target is the map's
|
|
926
|
+
* explicit assertion that the target is *not related* to the source, so it does not count as a
|
|
927
|
+
* match either: when **every** declared target for the source asserts non-relation the result is
|
|
928
|
+
* `unmapped`, carrying those `disjoint` rows verbatim on `notRelated`. When at least one target
|
|
929
|
+
* does assert a relationship, the result is matched and carries every declared target, `disjoint`
|
|
930
|
+
* rows included, in declared order. When nothing matches, the map author's `group.unmapped`
|
|
931
|
+
* directive (if any) is *reported* via the result's {@link UnmappedMode} but never silently
|
|
932
|
+
* applied.
|
|
852
933
|
*
|
|
853
934
|
* @param sourceCoding - The source concept to translate.
|
|
854
935
|
* @param map - A {@link ConceptMap} from {@link loadConceptMap}.
|
|
@@ -1589,7 +1670,16 @@ interface ConceptSetFilter {
|
|
|
1589
1670
|
interface ConceptRef {
|
|
1590
1671
|
/** The code, drawn verbatim from the value set. */
|
|
1591
1672
|
readonly code: string;
|
|
1592
|
-
/**
|
|
1673
|
+
/**
|
|
1674
|
+
* The display, when the value set supplied one (carried verbatim, never fabricated).
|
|
1675
|
+
*
|
|
1676
|
+
* This is the value set's **own** display and it always wins. Where the value set supplies none,
|
|
1677
|
+
* {@link expand} falls back to the display the supplied {@link CodeSystem} release carries for the
|
|
1678
|
+
* same code, again **verbatim**: the engine still synthesizes nothing, so a member whose release
|
|
1679
|
+
* was not supplied, or which that release carries with no display, comes back with no display at
|
|
1680
|
+
* all. A code a *usable* release does not carry is a membership question rather than a display
|
|
1681
|
+
* one: see {@link ConceptSetComponent.concept}.
|
|
1682
|
+
*/
|
|
1593
1683
|
readonly display?: string;
|
|
1594
1684
|
}
|
|
1595
1685
|
/**
|
|
@@ -1600,9 +1690,28 @@ interface ConceptRef {
|
|
|
1600
1690
|
interface ConceptSetComponent {
|
|
1601
1691
|
/** The code system these codes are drawn from (canonical URI), when the component names one. */
|
|
1602
1692
|
readonly system?: string;
|
|
1603
|
-
/**
|
|
1693
|
+
/**
|
|
1694
|
+
* The code system version to pin the selection to, when declared.
|
|
1695
|
+
*
|
|
1696
|
+
* Wherever the selection actually resolves a supplied {@link CodeSystem} (a `filter`, or a
|
|
1697
|
+
* whole-system component with no {@link concept} list), the pin is **checked** against that
|
|
1698
|
+
* release's own `version`: a disagreement, or a release that declares no version to agree with, is
|
|
1699
|
+
* a typed {@link DiagnosticCode.TERM_VALUESET_CANNOT_EXPAND} that marks the outcome incomplete or
|
|
1700
|
+
* undetermined, never membership computed from the other release. The check is that the two
|
|
1701
|
+
* declarations agree, not that either is true: a mislabelled release is still trusted.
|
|
1702
|
+
*/
|
|
1604
1703
|
readonly version?: string;
|
|
1605
|
-
/**
|
|
1704
|
+
/**
|
|
1705
|
+
* An explicit, enumerated code list (extensional). Mutually exclusive with {@link filter} in FHIR.
|
|
1706
|
+
*
|
|
1707
|
+
* An entry is admitted as a member only where the evidence the caller supplied does not
|
|
1708
|
+
* contradict it. Where a release keyed by this component's {@link system} is in hand and the
|
|
1709
|
+
* declared {@link version} (if any) agrees with it, a code that release does not define is **not**
|
|
1710
|
+
* a member: {@link expand} omits it, reporting one typed
|
|
1711
|
+
* {@link DiagnosticCode.TERM_VALUESET_ENUMERATED_CODE_UNDEFINED} for this component while staying
|
|
1712
|
+
* `complete: true`, and {@link validateCodeInValueSet} decides it a non-member. Where no usable
|
|
1713
|
+
* release was supplied, the engine holds no contrary evidence and every enumerated code stands.
|
|
1714
|
+
*/
|
|
1606
1715
|
readonly concept?: readonly ConceptRef[];
|
|
1607
1716
|
/** Intensional filters over {@link system}. Each code must satisfy **all** filters. */
|
|
1608
1717
|
readonly filter?: readonly ConceptSetFilter[];
|
|
@@ -1615,6 +1724,21 @@ interface ValueSetCompose {
|
|
|
1615
1724
|
readonly include: readonly ConceptSetComponent[];
|
|
1616
1725
|
/** The `exclude` components: codes removed from the include union. */
|
|
1617
1726
|
readonly exclude: readonly ConceptSetComponent[];
|
|
1727
|
+
/**
|
|
1728
|
+
* `ValueSet.compose.inactive`, when the resource declares one: whether codes the supplied release
|
|
1729
|
+
* marks as **not active** belong to the membership.
|
|
1730
|
+
*
|
|
1731
|
+
* A declared `false` is an **active-only** value set, and the engine honours it: an `include`
|
|
1732
|
+
* contributes only the codes the supplied {@link CodeSystem} release marks active. A release that
|
|
1733
|
+
* carries no status for a selected concept is not evidence of inactivity, so that member is kept;
|
|
1734
|
+
* a component whose activity cannot be checked against any usable release contributes **nothing**
|
|
1735
|
+
* and marks the outcome incomplete, so `contains` stays a lower bound rather than a set that may
|
|
1736
|
+
* hold inactive codes.
|
|
1737
|
+
*
|
|
1738
|
+
* Absent, or `true`, and no code is ever omitted on activity grounds. This is the value set's own
|
|
1739
|
+
* declaration and nothing else: `$expand`'s `activeOnly` **request** parameter is not modelled.
|
|
1740
|
+
*/
|
|
1741
|
+
readonly inactive?: boolean;
|
|
1618
1742
|
}
|
|
1619
1743
|
/** One `ValueSet.expansion.contains` entry from a **pre-computed** expansion. */
|
|
1620
1744
|
interface ExpansionContains {
|
|
@@ -1640,9 +1764,26 @@ interface ValueSetExpansion {
|
|
|
1640
1764
|
/**
|
|
1641
1765
|
* Derived at load: the expansion is **incomplete**. True when `total` exceeds `contains.length`, or
|
|
1642
1766
|
* the `http://hl7.org/fhir/StructureDefinition/valueset-toocostly` extension flagged it too-costly
|
|
1643
|
-
* (the VSAC >1200-code truncation hazard). A truncated expansion never
|
|
1767
|
+
* (the VSAC >1200-code truncation hazard), or {@link unclosed} is set. A truncated expansion never
|
|
1768
|
+
* reads as complete membership.
|
|
1644
1769
|
*/
|
|
1645
1770
|
readonly truncated: boolean;
|
|
1771
|
+
/**
|
|
1772
|
+
* Derived at load: the server marked the expansion `unclosed`
|
|
1773
|
+
* (`http://hl7.org/fhir/StructureDefinition/valueset-unclosed`), meaning the value set is
|
|
1774
|
+
* **unbounded** because it includes post-coordinated content (SNOMED CT, UCUM), so codes other
|
|
1775
|
+
* than the ones listed may be valid and no expansion can enumerate its membership.
|
|
1776
|
+
*
|
|
1777
|
+
* A source of incompleteness in its own right: whenever this is `true` so is {@link truncated}.
|
|
1778
|
+
* It is carried separately so a caller can tell an unbounded value set from a truncated page, and
|
|
1779
|
+
* the mark is read **fail-safe**: an entry that names the extension but carries no readable
|
|
1780
|
+
* boolean is taken as set, and only an explicit `valueBoolean: false` reads as absent.
|
|
1781
|
+
*
|
|
1782
|
+
* The engine only ever **reads** this off a supplied expansion. It never sets it on an expansion
|
|
1783
|
+
* it computes: `expand` runs over consumer-supplied code systems and cannot assert
|
|
1784
|
+
* post-coordination.
|
|
1785
|
+
*/
|
|
1786
|
+
readonly unclosed: boolean;
|
|
1646
1787
|
}
|
|
1647
1788
|
/**
|
|
1648
1789
|
* A loaded, immutable `ValueSet`: the subset of the FHIR R4 `ValueSet` resource the binding layer
|
|
@@ -1676,9 +1817,17 @@ interface ExpansionContext {
|
|
|
1676
1817
|
/** Referenced value sets, keyed by canonical URL, for `compose.include.valueSet`. */
|
|
1677
1818
|
readonly valueSets?: ReadonlyMap<string, ValueSet>;
|
|
1678
1819
|
}
|
|
1679
|
-
/**
|
|
1820
|
+
/**
|
|
1821
|
+
* A surfaced expansion concern: a part that could not be expanded, a truncated snapshot, or an
|
|
1822
|
+
* enumerated code the supplied release does not define.
|
|
1823
|
+
*/
|
|
1680
1824
|
interface ExpansionDiagnostic {
|
|
1681
|
-
/**
|
|
1825
|
+
/**
|
|
1826
|
+
* The stable code (`TERM_VALUESET_CANNOT_EXPAND` / `TERM_VALUESET_EXPANSION_TRUNCATED` /
|
|
1827
|
+
* `TERM_VALUESET_ENUMERATED_CODE_UNDEFINED`). Branch on it: the first two mean the answer is a
|
|
1828
|
+
* lower bound, the third reports a **decided** answer the engine narrowed on the caller's own
|
|
1829
|
+
* evidence.
|
|
1830
|
+
*/
|
|
1682
1831
|
readonly code: DiagnosticCode;
|
|
1683
1832
|
/** A **value-free** structural description of the concern (never echoes a patient value). */
|
|
1684
1833
|
readonly detail: string;
|
|
@@ -1699,9 +1848,15 @@ interface ExpansionDiagnostic {
|
|
|
1699
1848
|
* The result of {@link expand}: the flattened membership plus an honest **completeness** signal.
|
|
1700
1849
|
*
|
|
1701
1850
|
* `complete` is `false` whenever any part could not be fully computed (a missing code system, an
|
|
1702
|
-
* unresolved referenced value set, an unimplemented `filter` op,
|
|
1703
|
-
* expansion
|
|
1851
|
+
* unresolved referenced value set, an unimplemented `filter` op, a truncated pre-computed
|
|
1852
|
+
* expansion, or a component whose declared {@link ConceptSetComponent.version} disagrees with the
|
|
1853
|
+
* supplied release). A `false` here is the never-fabricate contract in action: the `contains` set is a
|
|
1704
1854
|
* **lower bound**, so it must never be read as exhaustive membership.
|
|
1855
|
+
*
|
|
1856
|
+
* An enumerated code the supplied release does not define does **not** set it: that member was
|
|
1857
|
+
* decided, not left unresolved, so the answer stays `complete: true` and carries a
|
|
1858
|
+
* {@link DiagnosticCode.TERM_VALUESET_ENUMERATED_CODE_UNDEFINED} diagnostic instead. A `complete`
|
|
1859
|
+
* expansion can therefore carry diagnostics: read {@link diagnostics} on both.
|
|
1705
1860
|
*/
|
|
1706
1861
|
interface ExpandResult {
|
|
1707
1862
|
/** Whether the expansion is exhaustive. When `false`, `contains` is a lower bound, not the whole set. */
|
|
@@ -1760,9 +1915,11 @@ type ValueSetMembership = ValueSetMemberDecided | ValueSetMemberUndetermined;
|
|
|
1760
1915
|
* Load an untrusted FHIR R4 `ValueSet` JSON value into an immutable {@link ValueSet}.
|
|
1761
1916
|
*
|
|
1762
1917
|
* Accepts the standard resource shape: `resourceType: "ValueSet"` with an optional intensional
|
|
1763
|
-
* `compose` (`include`/`exclude` of `system`/`concept`/`filter`/`valueSet
|
|
1764
|
-
*
|
|
1765
|
-
* `
|
|
1918
|
+
* `compose` (`include`/`exclude` of `system`/`concept`/`filter`/`valueSet`, plus the `inactive`
|
|
1919
|
+
* declaration that decides whether non-active codes belong to the membership) and/or a **pre-computed**
|
|
1920
|
+
* `expansion` (`contains`, with `total` and the `valueset-toocostly` / `valueset-unclosed`
|
|
1921
|
+
* extensions read into a derived `truncated` flag, the last of them also surfaced on its own
|
|
1922
|
+
* `unclosed` flag). The result is deep-frozen. Anything structurally unusable throws a
|
|
1766
1923
|
* {@link TerminologyError} carrying {@link FATAL_CODES.TERM_VALUESET_MALFORMED}.
|
|
1767
1924
|
*
|
|
1768
1925
|
* @param json - The untrusted resource (typically `JSON.parse` output, hence `unknown`).
|
|
@@ -1796,13 +1953,26 @@ declare function loadValueSet(json: unknown): ValueSet;
|
|
|
1796
1953
|
* releases: the union of `include` components minus the union of `exclude` components. Each component
|
|
1797
1954
|
* selects by explicit `concept`, by `filter` (subsumption + property predicates), by the whole
|
|
1798
1955
|
* `system`, and/or by intersecting referenced value sets.
|
|
1956
|
+
* - A `compose` that declares `inactive: false` is **active-only**: a code the supplied release marks
|
|
1957
|
+
* not active is omitted from every `include` branch alike, and a component whose activity no
|
|
1958
|
+
* supplied release can decide contributes nothing and marks the result incomplete.
|
|
1799
1959
|
*
|
|
1800
1960
|
* **Never fabricate.** A part that cannot be computed (a missing code system, an unresolved
|
|
1801
|
-
* referenced value set, an unimplemented `filter` operator
|
|
1961
|
+
* referenced value set, an unimplemented `filter` operator, or a component whose declared code
|
|
1962
|
+
* system version disagrees with the supplied release) yields a typed
|
|
1802
1963
|
* {@link ../common/diagnostics.DIAGNOSTIC_CODES.TERM_VALUESET_CANNOT_EXPAND} and marks the result
|
|
1803
1964
|
* `complete: false`, so the `contains` set is an explicit **lower bound**, never a silently-empty or
|
|
1804
1965
|
* fabricated membership.
|
|
1805
1966
|
*
|
|
1967
|
+
* The same rule read the other way bounds an **enumeration**: a `concept` entry is admitted only
|
|
1968
|
+
* where the evidence the caller supplied does not contradict it. Where a usable release for the
|
|
1969
|
+
* component's `system` is in hand and does not define the code, the code is **not** a member, the
|
|
1970
|
+
* answer stays decided and `complete: true` (the engine decided it, on that evidence), and the drop
|
|
1971
|
+
* is surfaced as a typed
|
|
1972
|
+
* {@link ../common/diagnostics.DIAGNOSTIC_CODES.TERM_VALUESET_ENUMERATED_CODE_UNDEFINED} rather
|
|
1973
|
+
* than happening silently. Where no usable release was supplied there is no contrary evidence, so
|
|
1974
|
+
* the value set's own enumeration stands untouched.
|
|
1975
|
+
*
|
|
1806
1976
|
* @packageDocumentation
|
|
1807
1977
|
*/
|
|
1808
1978
|
|
|
@@ -1845,10 +2015,21 @@ declare function expand(vs: ValueSet, ctx?: ExpansionContext): ExpandResult;
|
|
|
1845
2015
|
* (`result: true`/`false`) **only when it can prove it**: a code found in a computable `include` and
|
|
1846
2016
|
* not removed by any computable `exclude` is a definite member; a code absent from a fully-evaluated
|
|
1847
2017
|
* value set is a definite non-member. When any relevant part cannot be evaluated (a missing code
|
|
1848
|
-
* system, a truncated pre-computed expansion, an unimplemented `filter
|
|
2018
|
+
* system, a truncated pre-computed expansion, an unimplemented `filter`, a component whose declared
|
|
2019
|
+
* code system version disagrees with the supplied release, or an active-only value set whose
|
|
2020
|
+
* activity no supplied release can decide), the answer is a typed
|
|
1849
2021
|
* {@link ValueSetMemberUndetermined}: **never** a fabricated `false` (a false "not a member" is a
|
|
1850
2022
|
* clinical error).
|
|
1851
2023
|
*
|
|
2024
|
+
* The mirror of that rule is that a code is never decided a member on evidence the caller did not
|
|
2025
|
+
* supply either: a `Coding` carrying no `system` names no code in a system-scoped component, so such
|
|
2026
|
+
* a component is a definite non-match, and a value set whose components all name a system decides
|
|
2027
|
+
* `false` rather than asserting an unqualified code into it. Nor is it decided a member against
|
|
2028
|
+
* evidence the caller DID supply: a code an `include` enumerates but the usable release for that
|
|
2029
|
+
* component's `system` does not define is a definite non-member, matching the entry {@link expand}
|
|
2030
|
+
* drops for the same reason. Where no usable release was supplied, the enumeration alone decides,
|
|
2031
|
+
* exactly as before.
|
|
2032
|
+
*
|
|
1852
2033
|
* @packageDocumentation
|
|
1853
2034
|
*/
|
|
1854
2035
|
|
|
@@ -1959,8 +2140,11 @@ interface FilterMatch {
|
|
|
1959
2140
|
* Evaluate one {@link ConceptSetFilter} against one {@link Concept}, using the release's hierarchy.
|
|
1960
2141
|
*
|
|
1961
2142
|
* The `concept` filter property (and the hierarchy operators regardless of property) reads the code
|
|
1962
|
-
* itself / its subsumption; other properties read the concept's `property` values.
|
|
1963
|
-
*
|
|
2143
|
+
* itself / its subsumption; other properties read the concept's `property` values. `CodeSystem
|
|
2144
|
+
* .concept.property` is `0..*`, so **every** value the concept carries for the property is read:
|
|
2145
|
+
* `=` and `in` match on ANY of them, `not-in` matches only where NONE of them is in the filter's
|
|
2146
|
+
* set, and `exists` follows whether the concept carries any at all. An unimplemented operator
|
|
2147
|
+
* returns `{ supported: false }`: never a coerced `matched`.
|
|
1964
2148
|
*
|
|
1965
2149
|
* @param concept - The concept under test.
|
|
1966
2150
|
* @param filter - The filter predicate.
|
|
@@ -3637,6 +3821,9 @@ declare function isSynonymTermType(tty: TermType): boolean;
|
|
|
3637
3821
|
* - {@link loadConceptMap} + {@link translate}: the ConceptMap `$translate` engine, with the
|
|
3638
3822
|
* **never-fabricate / never-invert** invariants: an unmapped source is a typed
|
|
3639
3823
|
* {@link TranslateUnmapped}, never a guessed target; a directional map is never run backwards.
|
|
3824
|
+
* A source whose every declared target asserts non-relation (R4 `disjoint` / `unmatched`) is not
|
|
3825
|
+
* translated either: it reports as {@link TranslateUnmapped}, carrying the `disjoint` rows the
|
|
3826
|
+
* map asserted on `notRelated`.
|
|
3640
3827
|
*
|
|
3641
3828
|
* **The CodeSystem load layer**, with the FHIR `$lookup` / `$validate-code` operations:
|
|
3642
3829
|
*
|
|
@@ -3655,6 +3842,9 @@ declare function isSynonymTermType(tty: TermType): boolean;
|
|
|
3655
3842
|
* - {@link expand}: flatten membership over the supplied {@link CodeSystem}s (`include`/`exclude`,
|
|
3656
3843
|
* explicit `concept` lists, `is-a`/property `filter`s, referenced value sets), with an honest
|
|
3657
3844
|
* `complete` flag: an unresolvable part is a typed `TERM_VALUESET_CANNOT_EXPAND`, never a guess.
|
|
3845
|
+
* An enumerated code the release you supplied for that component does not define is not a member
|
|
3846
|
+
* either: it is omitted, the answer stays `complete: true`, and the drop is a typed
|
|
3847
|
+
* `TERM_VALUESET_ENUMERATED_CODE_UNDEFINED` rather than a silent one.
|
|
3658
3848
|
* - {@link validateCodeInValueSet}: binding membership, returning a **decided** `result` only when
|
|
3659
3849
|
* proven and a typed `undetermined` otherwise (a truncated expansion never reads as complete).
|
|
3660
3850
|
*
|
|
@@ -3749,4 +3939,4 @@ declare function isSynonymTermType(tty: TermType): boolean;
|
|
|
3749
3939
|
*/
|
|
3750
3940
|
declare const VERSION: string;
|
|
3751
3941
|
|
|
3752
|
-
export { type AnnotationNode, type ApproximateMatchOptions, type BillableFlag, COMPLEX_MAP_SOURCE_SYSTEM, type CodeSystem, type CodeSystemSource, type CodeableConcept, type Coding, type ComplexMap, type ComplexMapApplyResult, type ComplexMapContextRequired, type ComplexMapEntry, type ComplexMapGroupNoMap, type ComplexMapGroupResolved, type ComplexMapGroupResult, type ComplexMapInput, type ComplexMapLoadWarning, type ComplexMapMatched, type ComponentNode, type Concept, type ConceptActivity, type ConceptMap, type ConceptMapElement, type ConceptMapGroup, type ConceptMapTarget, type ConceptMapUnmapped, type ConceptRef, type ConceptSetComponent, type ConceptSetFilter, type ConceptStatus, type CrosswalkNoMap, type CrosswalkUnmapped, type CsvColumnMap, type CsvSource, DIAGNOSTIC_CODES, type DiagnosticCode, type ExpandResult, type ExpansionContains, type ExpansionContext, type ExpansionDiagnostic, FATAL_CODES, type FactorNode, type FatalCode, type FhirCodeSystemSource, type FieldSlice, type FilterMatch, type FilterOperator, type FixedWidthFieldMap, type FixedWidthPropertyField, type FixedWidthSource, type GemApplyResult, type GemChoiceList, type GemDirection, type GemEntry, type GemFlags, type GemLoadWarning, type GemMap, type GemMatched, type GemScenario, type GemSource, type GroupNode, HL7_V2_OID_ROOT, HL7_V2_URL_PREFIX, ICD10CM_ORDER_FILE_FIELDS, ICD10CM_SYSTEM, ICD9CM_SYSTEM, type LinearReduction, type LoadWarning, type LookupOutcome, type LookupResult, type LookupUnknown, MAP_CATEGORIES, type MapCategoryId, type MapProvenance, NO_MAP_CATEGORIES, type NdcResolution, type NdcResult, type NdcStatus, type NdcUnmapped, type ParseFailure, type ParseResult, type PatientContext, type Property, type R4Equivalence, RELA, RELA_INVERSE, RXNORM_SYSTEM, type Reduction, type RelaName, type Relationship, type ResolveSystemResult, type RrfColumnMap, type RrfPropertyColumn, type RrfSource, type RxNormApproximateMatch, type RxNormConcept, type RxNormEdge, type RxNormGraph, type RxNormGraphSource, type RxNormLoadWarning, type RxNormNavResult, type RxNormRelated, type RxNormUnknown, SNOMEDCT_SYSTEM, SYSTEM_IDENTITIES, type SimpleUnitNode, type SpecialReduction, type StatusMapper, type Subsumption, type SystemIdentity, TERM_TYPES, type TermType, TerminologyError, type TranslateMatch, type TranslateMatched, type TranslateResult, type TranslateUnmapped, type UcumAtom, type UcumEssence, type UcumPrefix, type UcumValidation, type UnitNode, type UnknownSystem, type UnmappedMode, VERSION, type ValidateCodeResult, type ValueSet, type ValueSetCompose, type ValueSetExpansion, type ValueSetMemberDecided, type ValueSetMemberUndetermined, type ValueSetMembership, applyComplexMap, applyGem, approximateMatch, asTermType, brandsFor, buildSubsumption, codeableConcept, coding, consistsOf, defaultStatusMapper, doseFormsOf, expand, genericFor, getArray, getBoolean, getConcept, getNumber, getString, ingredientsOf, invertGem, isA, isJsonObject, isSynonymTermType, isUnknownSystem, loadCodeSystem, loadComplexMap, loadConceptMap, loadGems, loadRxNormGraph, loadUcumEssence, loadValueSet, lookup, makeStatus, matchesFilter, parseCsv, parseCsvSource, parseFhirCodeSystem, parseFixedWidth, parseRrf, parseRrfLine, parseUcum, reduce, relatedByRela, resolveNdc, resolveSystem, sliceField, translate, ucumEqual, unsupportedOps, validateCode, validateCodeInValueSet, validateUcum };
|
|
3942
|
+
export { type AnnotationNode, type ApproximateMatchOptions, type BillableFlag, COMPLEX_MAP_SOURCE_SYSTEM, type CodeSystem, type CodeSystemSource, type CodeableConcept, type Coding, type ComplexMap, type ComplexMapApplyResult, type ComplexMapContextRequired, type ComplexMapEntry, type ComplexMapGroupNoMap, type ComplexMapGroupResolved, type ComplexMapGroupResult, type ComplexMapInput, type ComplexMapLoadWarning, type ComplexMapMatched, type ComponentNode, type Concept, type ConceptActivity, type ConceptMap, type ConceptMapElement, type ConceptMapGroup, type ConceptMapTarget, type ConceptMapUnmapped, type ConceptRef, type ConceptSetComponent, type ConceptSetFilter, type ConceptStatus, type CrosswalkNoMap, type CrosswalkUnmapped, type CsvColumnMap, type CsvSource, DIAGNOSTIC_CODES, type DiagnosticCode, type ExpandResult, type ExpansionContains, type ExpansionContext, type ExpansionDiagnostic, FATAL_CODES, type FactorNode, type FatalCode, type FhirCodeSystemSource, type FieldSlice, type FilterMatch, type FilterOperator, type FixedWidthFieldMap, type FixedWidthPropertyField, type FixedWidthSource, type GemApplyResult, type GemChoiceList, type GemDirection, type GemEntry, type GemFlags, type GemLoadWarning, type GemMap, type GemMatched, type GemScenario, type GemSource, type GroupNode, HL7_V2_OID_ROOT, HL7_V2_URL_PREFIX, ICD10CM_ORDER_FILE_FIELDS, ICD10CM_SYSTEM, ICD9CM_SYSTEM, type LinearReduction, type LoadWarning, type LookupOutcome, type LookupResult, type LookupUnknown, MAP_CATEGORIES, type MapCategoryId, type MapProvenance, NO_MAP_CATEGORIES, type NdcResolution, type NdcResult, type NdcStatus, type NdcUnmapped, type ParseFailure, type ParseResult, type PatientContext, type Property, type R4Equivalence, RELA, RELA_INVERSE, RXNORM_SYSTEM, type Reduction, type RelaName, type Relationship, type ResolveSystemResult, type RrfColumnMap, type RrfPropertyColumn, type RrfSource, type RxNormApproximateMatch, type RxNormConcept, type RxNormEdge, type RxNormGraph, type RxNormGraphSource, type RxNormLoadWarning, type RxNormNavResult, type RxNormRelated, type RxNormUnknown, SNOMEDCT_SYSTEM, SYSTEM_IDENTITIES, type SimpleUnitNode, type SpecialReduction, type StatusMapper, type Subsumption, type SystemIdentity, TERM_TYPES, type TermType, TerminologyError, type TranslateMatch, type TranslateMatched, type TranslateNotRelated, type TranslateResult, type TranslateUnmapped, type UcumAtom, type UcumEssence, type UcumPrefix, type UcumValidation, type UnitNode, type UnknownSystem, type UnmappedMode, VERSION, type ValidateCodeResult, type ValueSet, type ValueSetCompose, type ValueSetExpansion, type ValueSetMemberDecided, type ValueSetMemberUndetermined, type ValueSetMembership, applyComplexMap, applyGem, approximateMatch, asTermType, brandsFor, buildSubsumption, codeableConcept, coding, consistsOf, defaultStatusMapper, doseFormsOf, expand, genericFor, getArray, getBoolean, getConcept, getNumber, getString, ingredientsOf, invertGem, isA, isJsonObject, isSynonymTermType, isUnknownSystem, loadCodeSystem, loadComplexMap, loadConceptMap, loadGems, loadRxNormGraph, loadUcumEssence, loadValueSet, lookup, makeStatus, matchesFilter, parseCsv, parseCsvSource, parseFhirCodeSystem, parseFixedWidth, parseRrf, parseRrfLine, parseUcum, reduce, relatedByRela, resolveNdc, resolveSystem, sliceField, translate, ucumEqual, unsupportedOps, validateCode, validateCodeInValueSet, validateUcum };
|