babelfhir-ts 1.0.41 → 1.0.43
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 +79 -171
- package/out/src/generator/base-r4/README.md +28 -0
- package/out/src/generator/base-r4/well-known-system-codes.json +63 -0
- package/out/src/generator/classGenerator.js +311 -439
- package/out/src/generator/constants.js +327 -0
- package/out/src/generator/fetchUtils.js +3 -2
- package/out/src/generator/fhirR4Rules.js +7 -11
- package/out/src/generator/fhirResources.json +157 -0
- package/out/src/generator/index.js +73 -14
- package/out/src/generator/packageParser.js +170 -3
- package/out/src/generator/randomSupportGenerator.js +625 -97
- package/out/src/generator/sdParser.js +99 -30
- package/out/src/generator/txClient.js +5 -4
- package/out/src/generator/utils.js +12 -4
- package/out/src/main.js +1 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
# BabelFHIR-TS
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/babelfhir-ts)
|
|
8
|
+
[](https://www.npmjs.com/package/@babelfhir-ts/client-r4)
|
|
8
9
|
[](https://opensource.org/licenses/ISC)
|
|
9
10
|
[](https://www.typescriptlang.org/)
|
|
10
11
|
[](https://nodejs.org/)
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
- **Random data builders** for testing and development (when class generation is enabled)
|
|
21
22
|
- **Zero manual mapping**—consume any FHIR package or Implementation Guide directly from registries
|
|
22
23
|
- **Fast and lightweight**—minimal runtime deps; only `fhirpath` is required for validators
|
|
24
|
+
- **Type-safe FHIR client** — generated client extends [`@babelfhir-ts/client-r4`](https://www.npmjs.com/package/@babelfhir-ts/client-r4) with profile-specific methods (e.g., `.usCorePatient()`, `.pASClaim()`) on top of 145 base R4 resource accessors
|
|
23
25
|
- **Install any FHIR profile as a node module**—use `babelfhir-ts install` to add Implementation Guides directly to your project
|
|
24
26
|
|
|
25
27
|
<!-- PARITY-BADGES:START - Do not remove or modify this section -->
|
|
@@ -46,25 +48,27 @@ Every pull request runs two independent CI pipelines that validate generated cod
|
|
|
46
48
|
|
|
47
49
|
### Validation with Firely .NET SDK
|
|
48
50
|
|
|
49
|
-
The first pipeline validates generated resources using the [Firely .NET SDK validator](https://docs.fire.ly/projects/Firely-NET-SDK/) (v3.0
|
|
51
|
+
The first pipeline validates generated resources using the [Firely .NET SDK validator](https://docs.fire.ly/projects/Firely-NET-SDK/) (v3.1.0). Results are published as live badges:
|
|
50
52
|
|
|
51
53
|

|
|
52
54
|

|
|
53
55
|

|
|
54
56
|

|
|
55
57
|

|
|
58
|
+

|
|
56
59
|
|
|
57
60
|
> 11 profiles are excluded from this pipeline due to schema loading issues in the Firely SDK. These profiles validate successfully with the HL7 Java Validator below. Details in [docs/FIRELY-VALIDATOR-BUGS.md](./docs/FIRELY-VALIDATOR-BUGS.md).
|
|
58
61
|
|
|
59
62
|
### Validation with HL7 Java Validator
|
|
60
63
|
|
|
61
|
-
The second pipeline validates using the [official HL7 FHIR Validator](https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator) (v6.
|
|
64
|
+
The second pipeline validates using the [official HL7 FHIR Validator](https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator) (v6.9.1), the reference implementation for FHIR conformance checking:
|
|
62
65
|
|
|
63
66
|

|
|
64
67
|

|
|
65
68
|

|
|
66
69
|

|
|
67
70
|

|
|
71
|
+

|
|
68
72
|
|
|
69
73
|
> Terminology validation requires a tx server. The pipeline uses `--tx-server https://tx.fhir.org/r4` during generation to expand ValueSets and produce valid codes.
|
|
70
74
|
|
|
@@ -74,48 +78,27 @@ The second pipeline validates using the [official HL7 FHIR Validator](https://co
|
|
|
74
78
|
|
|
75
79
|
## Installation
|
|
76
80
|
|
|
77
|
-
Install globally (recommended when using the CLI frequently):
|
|
78
|
-
|
|
79
81
|
```bash
|
|
80
82
|
npm install -g babelfhir-ts
|
|
81
83
|
```
|
|
82
84
|
|
|
83
|
-
Or
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
npx babelfhir-ts --help
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
> **Requirements:** Node.js 18+ (ESM support) and an internet connection when downloading packages from remote registries.
|
|
85
|
+
Or on-demand: `npx babelfhir-ts --help`
|
|
90
86
|
|
|
91
|
-
|
|
87
|
+
> **Requirements:** Node.js 18+ and an internet connection for remote registries.
|
|
92
88
|
|
|
93
|
-
|
|
89
|
+
## Quick Start
|
|
94
90
|
|
|
95
91
|
```bash
|
|
92
|
+
# Generate from a local folder
|
|
96
93
|
babelfhir-ts input/ output/
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Process a single package archive and write the generated interfaces back into a new `.tgz` file:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
babelfhir-ts hl7.fhir.us.core-8.0.0.tgz us-core-generated.tgz
|
|
103
|
-
```
|
|
104
94
|
|
|
105
|
-
Download and process
|
|
106
|
-
|
|
107
|
-
```bash
|
|
95
|
+
# Download and process from a registry
|
|
108
96
|
babelfhir-ts --package hl7.fhir.us.core@8.0.0
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Download, process and install a processed package into your current project:
|
|
112
97
|
|
|
113
|
-
|
|
98
|
+
# Install as a project dependency
|
|
114
99
|
babelfhir-ts install hl7.fhir.us.core@8.0.0
|
|
115
100
|
```
|
|
116
101
|
|
|
117
|
-
After generation you can import the emitted classes:
|
|
118
|
-
|
|
119
102
|
```ts
|
|
120
103
|
import { USCorePatientClass } from "./output/USCorePatientClass";
|
|
121
104
|
|
|
@@ -123,159 +106,82 @@ const patient = USCorePatientClass.random();
|
|
|
123
106
|
const { errors, warnings } = await patient.validate();
|
|
124
107
|
```
|
|
125
108
|
|
|
126
|
-
##
|
|
127
|
-
|
|
128
|
-
Generated profile packages installed via `babelfhir-ts install` are published as **compiled JavaScript with TypeScript declarations**:
|
|
129
|
-
|
|
130
|
-
- JavaScript for runtime: `index.js`, `*.js`
|
|
131
|
-
- Type declarations for IDE/TS: `index.d.ts`, `*.d.ts`
|
|
132
|
-
- Dependencies:
|
|
133
|
-
- `@types/fhir` is included as a dependency of the generated package (no extra setup in your app)
|
|
134
|
-
- `fhirpath` is a peer dependency (required only if you use the generated validators/classes)
|
|
135
|
-
|
|
136
|
-
Install `fhirpath` in your app if you plan to call `.validate()` or use the generated classes.
|
|
137
|
-
|
|
138
|
-
### Module resolution
|
|
139
|
-
|
|
140
|
-
Generated packages work with all modern TypeScript setups:
|
|
141
|
-
|
|
142
|
-
- **Node.js 18+** with `"type": "module"` in `package.json`
|
|
143
|
-
- **Bundlers** (Vite, esbuild, Webpack) with ESM output
|
|
144
|
-
- **TypeScript 5.0+** with any module resolution (`node16`, `nodenext`, or `bundler`)
|
|
145
|
-
|
|
146
|
-
#### FHIR type imports
|
|
147
|
-
|
|
148
|
-
Generated code imports base FHIR types from `"fhir/r4"`:
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
import { Appointment, Extension, CodeableConcept } from "fhir/r4";
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Since `@types/fhir` doesn't provide a `package.json` `exports` field, BabelFHIR-TS includes an **ambient module declaration** (`fhir-r4.d.ts`) in every generated package. The generated `index.d.ts` references this file:
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
/// <reference path="./fhir-r4.d.ts" />
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
This ensures TypeScript can resolve `fhir/r4` imports automatically without any configuration in your project's `tsconfig.json`.
|
|
161
|
-
|
|
162
|
-
## CLI reference
|
|
109
|
+
## CLI Reference
|
|
163
110
|
|
|
111
|
+
<!-- CLI_HELP_START -->
|
|
164
112
|
```
|
|
165
|
-
|
|
113
|
+
BabelFHIR-TS: Generate TypeScript interfaces from FHIR StructureDefinitions
|
|
114
|
+
|
|
115
|
+
Usage:
|
|
116
|
+
babelfhir-ts [options] [<input> [output]]
|
|
117
|
+
babelfhir-ts install [--package] <pkg@version|path> [--registry <url>] [options]
|
|
118
|
+
|
|
119
|
+
Arguments:
|
|
120
|
+
input Input can be:
|
|
121
|
+
- Canonical URL of a FHIR profile (http://... or https://...)
|
|
122
|
+
- Directory containing FHIR packages (.tgz/.zip files)
|
|
123
|
+
- Single FHIR package (.tgz/.zip file)
|
|
124
|
+
- Single StructureDefinition (.json file)
|
|
125
|
+
- Directory containing StructureDefinition files
|
|
126
|
+
output Output directory or archive name (optional)
|
|
127
|
+
|
|
128
|
+
Commands:
|
|
129
|
+
install Download, process, and npm install package as dependency
|
|
130
|
+
|
|
131
|
+
Options:
|
|
132
|
+
-h, --help Show this help message
|
|
133
|
+
-v, --version Show version number
|
|
134
|
+
--log <dest> Log destination: console (default) or file
|
|
135
|
+
--log-level <level> Log verbosity: error, warn, info (default), or debug
|
|
136
|
+
--cache-dir <path> Custom cache directory (default: .cache, env: FHIR_CACHE_ROOT)
|
|
137
|
+
--no-cache Delete .cache folder after generation
|
|
138
|
+
--no-classes Only generate interfaces and types (skip class generation)
|
|
139
|
+
--no-client Skip FHIR client generation (client generated by default)
|
|
140
|
+
--package <pkg@version> Download FHIR package from registry and process it
|
|
141
|
+
--registry <url> FHIR package registry URL (default: https://packages.simplifier.net)
|
|
142
|
+
--tx-server <url> Terminology server URL for ValueSet expansion (e.g., https://tx.fhir.org/r4)
|
|
143
|
+
When set, expands ValueSets without explicit codes using $expand operation
|
|
144
|
+
|
|
145
|
+
Examples:
|
|
146
|
+
babelfhir-ts # Process ./input to ./output
|
|
147
|
+
babelfhir-ts http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient # Generate from profile URL
|
|
148
|
+
babelfhir-ts package.tgz # Process package to current directory
|
|
149
|
+
babelfhir-ts package.tgz modified-package.tgz # Embed interfaces in package
|
|
150
|
+
babelfhir-ts profiles/ generated/ # Process directory to directory
|
|
151
|
+
babelfhir-ts --package hl7.fhir.us.core@8.0.0 # Download and process from default registry
|
|
152
|
+
babelfhir-ts --package hl7.fhir.us.core@8.0.0 output/ # Download and output to directory
|
|
153
|
+
babelfhir-ts --package pkg@version --log console --log-level debug # With verbose logging
|
|
154
|
+
babelfhir-ts install de.gematik.isik-basismodul@3.1.0 # Download, process, and npm install
|
|
155
|
+
babelfhir-ts install ./package.tgz # Install from local package file
|
|
156
|
+
babelfhir-ts install hl7.fhir.us.core@8.0.0 --registry <url> # Install from custom registry
|
|
157
|
+
babelfhir-ts install --package hl7.fhir.us.core@8.0.0 --registry <url> # Alternative syntax
|
|
166
158
|
```
|
|
159
|
+
<!-- CLI_HELP_END -->
|
|
167
160
|
|
|
168
|
-
|
|
169
|
-
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
170
|
-
| `<input>` | Directory of FHIR packages/StructureDefinitions, single package (`.tgz`/`.zip`), or single StructureDefinition `.json`. Defaults to `./input` when omitted. |
|
|
171
|
-
| `<output>` | Destination directory or archive. Defaults to `./output` when omitted. |
|
|
172
|
-
| `install` | Downloads, processes, and installs a package as a project dependency. |
|
|
173
|
-
| `--package <pkg@version>` | Fetch a package from a registry and process it without manual download. |
|
|
174
|
-
| `--registry <url>` | Custom registry base URL (default:`https://packages.simplifier.net`). |
|
|
175
|
-
| `--tx-server <url>` | Terminology server URL for ValueSet expansion (e.g., `https://tx.fhir.org/r4`). When set, expands ValueSets without explicit codes using the `$expand` operation. |
|
|
176
|
-
| `--log <level>` | Control logging output:`none` (default), `console`, or `file`. |
|
|
177
|
-
| `--no-cache` | Remove the `.cache` directory once generation completes. |
|
|
178
|
-
| `--no-classes` | Skip emitting helper classes (interfaces & validators only). |
|
|
179
|
-
| `--cache-dir <path>` | Custom cache directory (default:`.cache`). Also configurable via `FHIR_CACHE_ROOT` env var. |
|
|
180
|
-
| `-h, --help` | Print usage help. |
|
|
181
|
-
| `-v, --version` | Print the BabelFHIR-TS version. |
|
|
182
|
-
|
|
183
|
-
### Supported inputs
|
|
184
|
-
|
|
185
|
-
- **Directory** – scan all `.tgz`, `.zip`, or `.json` files inside the folder
|
|
186
|
-
- **Archive** – process a FHIR NPM package in `.tgz` or `.zip` format
|
|
187
|
-
- **StructureDefinition JSON** – generate code for a single profile definition
|
|
188
|
-
|
|
189
|
-
## Scripts for contributors
|
|
190
|
-
|
|
191
|
-
| Script | Purpose |
|
|
192
|
-
| --------------------------- | ---------------------------------------------------------------------------- |
|
|
193
|
-
| `npm run generate` | Execute the CLI against the local `input/` folder and refresh `output/`. |
|
|
194
|
-
| `npm run generate:check` | End-to-end check: generate, type-check, and lint the emitted output. |
|
|
195
|
-
| `npm test` | Type-check and run all Vitest suites (coverage enabled). |
|
|
196
|
-
| `npm test pipelineParity` | Run pipeline parity tests against Firely .NET SDK validator. |
|
|
197
|
-
|
|
198
|
-
## Caching notes
|
|
199
|
-
|
|
200
|
-
The generator caches downloaded StructureDefinitions and packages inside `.cache/`. When you need a clean run, pass `--no-cache` or manually remove the folder. Temporary downloads land in `.temp-*` directories and are cleaned up automatically.
|
|
201
|
-
|
|
202
|
-
## Why BabelFHIR-TS?
|
|
203
|
-
|
|
204
|
-
**The FHIR Challenge**: Implementation Guides define strict profiles that constrain base FHIR resources with required or must-support elements, custom extensions, value set bindings, and cardinality rules. Existing TypeScript libraries can't capture these requirements when you need profile-specific types, leading to an overhead when using TypeScript to build apps that interact with FHIR servers.
|
|
205
|
-
|
|
206
|
-
**The BabelFHIR-TS Solution**: Automatically generates TypeScript interfaces and validation logic directly from StructureDefinition JSON. Your IDE autocompletes required fields, flags missing extensions at compile-time, and validates FHIRPath invariants at runtime.
|
|
207
|
-
|
|
208
|
-
## Limitations
|
|
209
|
-
|
|
210
|
-
BabelFHIR-TS is a code generation tool that parses FHIR StructureDefinitions and produces TypeScript interfaces and validators. While it handles many common FHIR profiling patterns, there are important limitations to be aware of:
|
|
211
|
-
|
|
212
|
-
### Profile Mapping Accuracy
|
|
213
|
-
|
|
214
|
-
- **Not guaranteed for all IGs**: The generator uses heuristics to interpret StructureDefinition constraints, slicing rules, and extensions. Complex or unusual profiling patterns may not map correctly to TypeScript.
|
|
215
|
-
- **Test before production**: Always validate the generated code against your specific Implementation Guide's examples and test cases. We recommend running the official FHIR validator alongside BabelFHIR-TS in your QA pipeline.
|
|
216
|
-
- **Edge cases**: Rare profiling constructs (deeply nested slicing, conditional constraints, complex discriminators) may generate suboptimal or incomplete types.
|
|
217
|
-
|
|
218
|
-
### Validation Scope
|
|
219
|
-
|
|
220
|
-
The generated `validate()` methods DO check:
|
|
161
|
+
## Documentation
|
|
221
162
|
|
|
222
|
-
|
|
223
|
-
- **Cardinality rules** (min/max occurrences)
|
|
224
|
-
- **Required fields** from profiles
|
|
225
|
-
- **Pattern constraints** (patternCodeableConcept, patternCoding)
|
|
226
|
-
- **Slice validation** for common patterns (coding arrays, BackboneElement slices)
|
|
227
|
-
- **Data type correctness** (string, number, boolean, etc.)
|
|
163
|
+
Full documentation is available at **[max-health-inc.github.io/BabelFHIR-TS/docs/](https://max-health-inc.github.io/BabelFHIR-TS/docs/)**
|
|
228
164
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
|
|
236
|
-
For comprehensive conformance testing, use the official [HL7 FHIR Validator](https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator)!
|
|
237
|
-
|
|
238
|
-
### TypeScript Limitations
|
|
239
|
-
|
|
240
|
-
- **Runtime type checking is limited**: TypeScript types are erased at compile time. The generated interfaces provide compile-time safety but cannot enforce constraints at runtime without the validator functions.
|
|
241
|
-
- **Extension slicing**: While the generator creates typed extension interfaces, TypeScript cannot enforce that extension arrays contain exactly the required slices at compile time (this is validated at runtime).
|
|
242
|
-
- **Choice types**: FHIR's `[x]` choice types (e.g., `value[x]`) are represented as union types in TypeScript, which may require runtime type narrowing.
|
|
243
|
-
|
|
244
|
-
### Generated Helper Methods
|
|
245
|
-
|
|
246
|
-
- **`random()` is not fully conformant**: The generated `.random()` methods create test data that satisfies TypeScript types and basic cardinality, but **do not guarantee** fully valid FHIR resources. Random data may violate:
|
|
247
|
-
|
|
248
|
-
- Complex FHIRPath invariants
|
|
249
|
-
- ValueSet bindings (codes are randomly chosen from required bindings but not guaranteed to be semantically correct)
|
|
250
|
-
- Profile-specific business rules
|
|
251
|
-
- Reference integrity constraints
|
|
252
|
-
|
|
253
|
-
Use `random()` for development, testing, and prototyping, but always validate production data on the FHIR server side.
|
|
254
|
-
- **`validate()` coverage**: The generated validation methods execute FHIRPath expressions and check constraints from StructureDefinitions. They are tested against the HL7 Java Validator and the Firely .NET SDK for the Implementation Guides listed in the [Continuous Validation](#continuous-validation) section. Edge cases, complex slicing patterns, or profiles not in the CI pipeline may produce different results. For production conformance testing, use the official [HL7 FHIR Validator](https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator) as the source of truth.
|
|
255
|
-
|
|
256
|
-
### FHIR Version Support
|
|
257
|
-
|
|
258
|
-
- **R4 only**: The current version targets FHIR R4. Support for R5, DSTU2, or STU3 is not yet available.
|
|
259
|
-
- **Dependencies**: Generated code depends on `@types/fhir` (R4 definitions) and `fhirpath` (R4 compatible).
|
|
260
|
-
|
|
261
|
-
### Reporting Issues
|
|
262
|
-
|
|
263
|
-
If you encounter an Implementation Guide that doesn't generate correctly, please [open an issue](https://github.com/Max-Health-Inc/BabelFHIR-TS/issues) with:
|
|
264
|
-
|
|
265
|
-
- The package name and version
|
|
266
|
-
- The specific StructureDefinition URL
|
|
267
|
-
- Expected vs. actual generated output
|
|
268
|
-
- Any validation errors or type mismatches
|
|
269
|
-
|
|
270
|
-
We continuously improve the generator based on real-world IG usage, and your feedback helps make BabelFHIR-TS more robust.
|
|
165
|
+
- [Getting Started](https://max-health-inc.github.io/BabelFHIR-TS/docs/getting-started) — installation, quick start, first generation
|
|
166
|
+
- [CLI Reference](https://max-health-inc.github.io/BabelFHIR-TS/docs/cli-reference) — full list of commands and options
|
|
167
|
+
- [Generated Code Guide](https://max-health-inc.github.io/BabelFHIR-TS/docs/generated-code) — understanding the output, module resolution, FHIR type imports
|
|
168
|
+
- [FHIR Client](https://max-health-inc.github.io/BabelFHIR-TS/docs/fhir-client) — type-safe server interactions
|
|
169
|
+
- [Validation](https://max-health-inc.github.io/BabelFHIR-TS/docs/validation) — what validators check, CI pipelines, known Firely SDK issues
|
|
170
|
+
- [Limitations](https://max-health-inc.github.io/BabelFHIR-TS/docs/limitations) — R4 only, edge cases, random() caveats
|
|
171
|
+
- [Contributing](https://max-health-inc.github.io/BabelFHIR-TS/docs/contributing) — dev setup, scripts, project structure
|
|
271
172
|
|
|
272
173
|
## License
|
|
273
174
|
|
|
274
175
|
ISC © Maximilian Nussbaumer
|
|
275
176
|
|
|
177
|
+
## Changelog
|
|
178
|
+
|
|
179
|
+
Release notes are published automatically on GitHub Releases:
|
|
180
|
+
**[View all releases](https://github.com/Max-Health-Inc/BabelFHIR-TS/releases)**
|
|
181
|
+
|
|
276
182
|
## Contributing
|
|
277
183
|
|
|
278
|
-
Contributions are welcome!
|
|
184
|
+
Contributions are welcome! See the [Contributing guide](https://max-health-inc.github.io/BabelFHIR-TS/docs/contributing) for dev setup, scripts, and how to submit changes.
|
|
279
185
|
|
|
280
186
|
## Security
|
|
281
187
|
|
|
@@ -283,7 +189,9 @@ For security issues, please see [SECURITY.md](SECURITY.md) for our security poli
|
|
|
283
189
|
|
|
284
190
|
## Links
|
|
285
191
|
|
|
286
|
-
- [npm package](https://www.npmjs.com/package/babelfhir-ts)
|
|
192
|
+
- [npm package — babelfhir-ts](https://www.npmjs.com/package/babelfhir-ts)
|
|
193
|
+
- [npm package — @babelfhir-ts/client-r4](https://www.npmjs.com/package/@babelfhir-ts/client-r4)
|
|
287
194
|
- [GitHub repository](https://github.com/Max-Health-Inc/BabelFHIR-TS)
|
|
195
|
+
- [Validation report](https://max-health-inc.github.io/BabelFHIR-TS/)
|
|
288
196
|
- [Issue tracker](https://github.com/Max-Health-Inc/BabelFHIR-TS/issues)
|
|
289
197
|
- [Changelog](CHANGELOG.md)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Bundled Base R4 StructureDefinitions
|
|
2
|
+
|
|
3
|
+
This directory contains offline copies of FHIR R4 StructureDefinitions that the generator needs but cannot reliably fetch at runtime.
|
|
4
|
+
|
|
5
|
+
## Why?
|
|
6
|
+
|
|
7
|
+
The generator resolves StructureDefinition dependencies via network (hl7.org, Simplifier, etc.). However, some SDs are hosted on servers that are frequently unreliable — especially in CI environments. When `sdParser.ts` cannot find a SD via local cache or network fetch, it falls back to these bundled files as a last resort.
|
|
8
|
+
|
|
9
|
+
## How discovery works
|
|
10
|
+
|
|
11
|
+
Rather than a hardcoded URL-to-file map, `sdParser.ts` auto-discovers all `.json` files in this directory at runtime. For each file it reads the `url` field from the JSON and builds a lookup map. For standard FHIR base SDs (`http://hl7.org/fhir/StructureDefinition/...`), the `/R4/` URL variant is also registered automatically.
|
|
12
|
+
|
|
13
|
+
## Adding a new bundled SD
|
|
14
|
+
|
|
15
|
+
1. Place the StructureDefinition JSON file in this directory.
|
|
16
|
+
2. Ensure it has a valid `url` field (the canonical URL).
|
|
17
|
+
3. That's it — `discoverBundledBaseSds()` in `sdParser.ts` picks it up automatically.
|
|
18
|
+
|
|
19
|
+
## Current contents
|
|
20
|
+
|
|
21
|
+
| File | Canonical URL | Reason |
|
|
22
|
+
|------|---------------|--------|
|
|
23
|
+
| `Bundle.json` | `http://hl7.org/fhir/StructureDefinition/Bundle` | Core R4 base type — required by many IGs for document/transaction bundles |
|
|
24
|
+
| `Composition.json` | `http://hl7.org/fhir/StructureDefinition/Composition` | Core R4 base type — required by document-based IGs (CH Core, ISiK, etc.) |
|
|
25
|
+
| `Endpoint.json` | `http://hl7.org/fhir/StructureDefinition/Endpoint` | Core R4 base type — required by ISiK profiles |
|
|
26
|
+
| `Subscription.json` | `http://hl7.org/fhir/StructureDefinition/Subscription` | Core R4 base type — required by ISiK profiles |
|
|
27
|
+
| `ValueSet.json` | `http://hl7.org/fhir/StructureDefinition/ValueSet` | Core R4 base type — used when generating ValueSet profiles |
|
|
28
|
+
| `backport-subscription.json` | `http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription` | Cross-version IG (R4B) — ISiK profiles extend this; not available on standard R4 servers |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_description": "Curated sample codes for large external CodeSystems (LOINC, SNOMED CT, etc.) that cannot be shipped in full due to size or licensing. Used as fallback when the CodeSystem has content='not-present' to allow ValueSet resolution for core R4 ValueSets like observation-codes without requiring a terminology server.",
|
|
3
|
+
"_valueSets": "Maps core R4 ValueSet canonical URLs to included CodeSystem URLs. Used when the dependency package containing the ValueSet is not cached locally.",
|
|
4
|
+
"systems": {
|
|
5
|
+
"http://loinc.org": [
|
|
6
|
+
{ "code": "29463-7", "display": "Body weight" },
|
|
7
|
+
{ "code": "8302-2", "display": "Body height" },
|
|
8
|
+
{ "code": "85354-9", "display": "Blood pressure panel with all children optional" },
|
|
9
|
+
{ "code": "8867-4", "display": "Heart rate" },
|
|
10
|
+
{ "code": "9279-1", "display": "Respiratory rate" },
|
|
11
|
+
{ "code": "8310-5", "display": "Body temperature" },
|
|
12
|
+
{ "code": "2708-6", "display": "Oxygen saturation in Arterial blood" },
|
|
13
|
+
{ "code": "39156-5", "display": "Body mass index (BMI)" },
|
|
14
|
+
{ "code": "59408-5", "display": "Oxygen saturation in Arterial blood by Pulse oximetry" },
|
|
15
|
+
{ "code": "8480-6", "display": "Systolic blood pressure" },
|
|
16
|
+
{ "code": "8462-4", "display": "Diastolic blood pressure" },
|
|
17
|
+
{ "code": "718-7", "display": "Hemoglobin [Mass/volume] in Blood" },
|
|
18
|
+
{ "code": "2339-0", "display": "Glucose [Mass/volume] in Blood" },
|
|
19
|
+
{ "code": "55284-4", "display": "Blood pressure systolic and diastolic" },
|
|
20
|
+
{ "code": "3141-9", "display": "Body weight Measured" },
|
|
21
|
+
{ "code": "72166-2", "display": "Tobacco smoking status" },
|
|
22
|
+
{ "code": "11506-3", "display": "Provider-unspecified Progress note" },
|
|
23
|
+
{ "code": "4548-4", "display": "Hemoglobin A1c/Hemoglobin.total in Blood" },
|
|
24
|
+
{ "code": "2093-3", "display": "Cholesterol [Mass/volume] in Serum or Plasma" },
|
|
25
|
+
{ "code": "2571-8", "display": "Triglyceride [Mass/volume] in Serum or Plasma" },
|
|
26
|
+
{ "code": "6690-2", "display": "Leukocytes [#/volume] in Blood by Automated count" },
|
|
27
|
+
{ "code": "789-8", "display": "Erythrocytes [#/volume] in Blood by Automated count" },
|
|
28
|
+
{ "code": "777-3", "display": "Platelets [#/volume] in Blood by Automated count" },
|
|
29
|
+
{ "code": "1742-6", "display": "Alanine aminotransferase [Enzymatic activity/volume] in Serum or Plasma" },
|
|
30
|
+
{ "code": "1920-8", "display": "Aspartate aminotransferase [Enzymatic activity/volume] in Serum or Plasma" },
|
|
31
|
+
{ "code": "2160-0", "display": "Creatinine [Mass/volume] in Serum or Plasma" },
|
|
32
|
+
{ "code": "3094-0", "display": "Urea nitrogen [Mass/volume] in Serum or Plasma" },
|
|
33
|
+
{ "code": "2823-3", "display": "Potassium [Moles/volume] in Serum or Plasma" },
|
|
34
|
+
{ "code": "2951-2", "display": "Sodium [Moles/volume] in Serum or Plasma" },
|
|
35
|
+
{ "code": "14959-1", "display": "Microalbumin [Mass/volume] in Urine" },
|
|
36
|
+
{ "code": "82810-3", "display": "Pregnancy status" }
|
|
37
|
+
],
|
|
38
|
+
"http://snomed.info/sct": [
|
|
39
|
+
{ "code": "27113001", "display": "Body weight" },
|
|
40
|
+
{ "code": "50373000", "display": "Body height measure" },
|
|
41
|
+
{ "code": "75367002", "display": "Blood pressure" },
|
|
42
|
+
{ "code": "364075005", "display": "Heart rate" },
|
|
43
|
+
{ "code": "86290005", "display": "Respiratory rate" },
|
|
44
|
+
{ "code": "386725007", "display": "Body temperature" },
|
|
45
|
+
{ "code": "431314004", "display": "SpO2 - Loss of oxygen in blood" },
|
|
46
|
+
{ "code": "60621009", "display": "Body mass index" },
|
|
47
|
+
{ "code": "271649006", "display": "Systolic blood pressure" },
|
|
48
|
+
{ "code": "271650006", "display": "Diastolic blood pressure" },
|
|
49
|
+
{ "code": "404684003", "display": "Clinical finding" },
|
|
50
|
+
{ "code": "118228005", "display": "Functional finding" },
|
|
51
|
+
{ "code": "250171008", "display": "Clinical history and observation findings" },
|
|
52
|
+
{ "code": "363787002", "display": "Observable entity" },
|
|
53
|
+
{ "code": "386661006", "display": "Fever" }
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"valueSets": {
|
|
57
|
+
"http://hl7.org/fhir/ValueSet/observation-codes": ["http://loinc.org"],
|
|
58
|
+
"http://hl7.org/fhir/ValueSet/body-site": ["http://snomed.info/sct"],
|
|
59
|
+
"http://hl7.org/fhir/ValueSet/observation-methods": ["http://snomed.info/sct"],
|
|
60
|
+
"http://hl7.org/fhir/ValueSet/clinical-findings": ["http://snomed.info/sct"],
|
|
61
|
+
"http://hl7.org/fhir/ValueSet/condition-code": ["http://snomed.info/sct"]
|
|
62
|
+
}
|
|
63
|
+
}
|