@fhir-dsl/terminology 1.2.0 → 1.2.2
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/README.md +64 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @fhir-dsl/terminology
|
|
2
|
+
|
|
3
|
+
Compile-time FHIR terminology resolver. Loads pre-expanded ValueSets and CodeSystems from a FHIR spec or Implementation Guide, resolves bindings (required / extensible / preferred / example) by strength, and walks CodeSystem hierarchies (`is-a`, `descendent-of`, `regex` filters with transitive subsumption).
|
|
4
|
+
|
|
5
|
+
This is the engine behind `@fhir-dsl/cli generate --expand-valuesets` / `--resolve-codesystems`. Most users never import it directly — install standalone only when you need the same resolver outside the generator (e.g. a custom binding-strength linter or an offline `validate-code` runner).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @fhir-dsl/terminology
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Resolve a ValueSet from a parsed bundle
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
TerminologyRegistry,
|
|
20
|
+
parseCodeSystem,
|
|
21
|
+
parseExpansionsBundle,
|
|
22
|
+
resolveValueSet,
|
|
23
|
+
} from "@fhir-dsl/terminology";
|
|
24
|
+
|
|
25
|
+
const registry = new TerminologyRegistry();
|
|
26
|
+
parseExpansionsBundle(expansionsBundleJson, registry);
|
|
27
|
+
parseCodeSystem(codeSystemJson, registry);
|
|
28
|
+
|
|
29
|
+
const vs = resolveValueSet(
|
|
30
|
+
"http://hl7.org/fhir/ValueSet/administrative-gender",
|
|
31
|
+
registry,
|
|
32
|
+
);
|
|
33
|
+
// vs?.codes: ResolvedCode[] — { code, display?, system, definition? }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Walk a CodeSystem hierarchy
|
|
37
|
+
|
|
38
|
+
`TerminologyRegistry` exposes the parsed CodeSystem graph for transitive subsumption (`is-a` + `descendent-of` filters). The generator uses it to expand `compose.include[].filter` against in-house concept trees without needing a live terminology server.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { resolveCompose } from "@fhir-dsl/terminology";
|
|
42
|
+
|
|
43
|
+
// resolveCompose handles the full ValueSet.compose grammar:
|
|
44
|
+
// - include.system + include.concept[]
|
|
45
|
+
// - include.system + include.filter[].op (= "is-a" | "descendent-of" | "regex" | "in" | "not-in" | "exists")
|
|
46
|
+
// - include.valueSet[]
|
|
47
|
+
// - exclude.* (subtracts from the union)
|
|
48
|
+
const codes = resolveCompose(compose, registry);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Coverage
|
|
52
|
+
|
|
53
|
+
- **Bindings by strength** — `required`, `extensible`, `preferred`, `example`. The generator narrows enums for `required` (and `extensible` under `--strict-extensible`); `preferred` / `example` keep the open `string` type.
|
|
54
|
+
- **CodeSystem filters** — `is-a` and `descendent-of` walk transitive `concept.concept[]` hierarchies; `regex` matches `code` against the supplied pattern; `in` / `not-in` membership checks; `exists` against `concept.property[]`.
|
|
55
|
+
- **Pre-expanded ValueSets** — when a ValueSet ships an `expansion.contains[]` block, that wins over `compose` (matches the FHIR spec's hint that pre-expansion is authoritative).
|
|
56
|
+
|
|
57
|
+
## What's not in scope
|
|
58
|
+
|
|
59
|
+
- **Live `$expand` / `$validate-code` against a remote server** — that lives in `@fhir-dsl/core` (`client.terminology.*`). This package is purely offline.
|
|
60
|
+
- **SNOMED post-coordination, LOINC parts** — out of scope; treat them as opaque codes.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
[MIT](https://github.com/awbx/fhir-dsl/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fhir-dsl/terminology",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Compile-time FHIR terminology resolver for ValueSets and CodeSystems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@fhir-dsl/utils": "1.2.
|
|
25
|
+
"@fhir-dsl/utils": "1.2.2"
|
|
26
26
|
},
|
|
27
27
|
"author": "Abdelhadi Sabani",
|
|
28
28
|
"license": "MIT",
|