babelfhir-ts 1.0.41 → 1.0.42

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 CHANGED
@@ -5,6 +5,7 @@
5
5
  # BabelFHIR-TS
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/babelfhir-ts.svg)](https://www.npmjs.com/package/babelfhir-ts)
8
+ [![@babelfhir-ts/client-r4](https://img.shields.io/npm/v/@babelfhir-ts/client-r4.svg?label=%40babelfhir-ts%2Fclient-r4)](https://www.npmjs.com/package/@babelfhir-ts/client-r4)
8
9
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
9
10
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue)](https://www.typescriptlang.org/)
10
11
  [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)](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 -->
@@ -53,6 +55,7 @@ The first pipeline validates generated resources using the [Firely .NET SDK vali
53
55
  ![IPS 2.0.0](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-ips.json)
54
56
  ![SMART 2.2.0](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-smart.json)
55
57
  ![CH Core 5.0.0](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-ch-core.json)
58
+ ![DaVinci PAS 2.0.1](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-davinci-pas.json)
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
 
@@ -65,6 +68,7 @@ The second pipeline validates using the [official HL7 FHIR Validator](https://co
65
68
  ![IPS 2.0.0](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-hl7-ips.json)
66
69
  ![SMART 2.2.0](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-hl7-smart.json)
67
70
  ![CH Core 5.0.0](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-hl7-ch-core.json)
71
+ ![DaVinci PAS 2.0.1](https://img.shields.io/endpoint?url=https://max-health-inc.github.io/BabelFHIR-TS/badges/badge-hl7-davinci-pas.json)
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
 
@@ -123,6 +127,21 @@ const patient = USCorePatientClass.random();
123
127
  const { errors, warnings } = await patient.validate();
124
128
  ```
125
129
 
130
+ Or use the generated FHIR client to interact with a FHIR server:
131
+
132
+ ```ts
133
+ import { FhirClient } from "./output/fhir-client";
134
+
135
+ const client = new FhirClient("https://hapi.fhir.org/baseR4");
136
+
137
+ // Profile-specific methods generated from your IG
138
+ const patient = await client.read().usCorePatient().read("123");
139
+ const bundle = await client.read().usCoreCondition().search({ patient: "123" });
140
+
141
+ // All 145 base R4 resource types are also available
142
+ const appointment = await client.read().appointment().read("456");
143
+ ```
144
+
126
145
  ## Using the generated code in your project
127
146
 
128
147
  Generated profile packages installed via `babelfhir-ts install` are published as **compiled JavaScript with TypeScript declarations**:
@@ -131,6 +150,7 @@ Generated profile packages installed via `babelfhir-ts install` are published as
131
150
  - Type declarations for IDE/TS: `index.d.ts`, `*.d.ts`
132
151
  - Dependencies:
133
152
  - `@types/fhir` is included as a dependency of the generated package (no extra setup in your app)
153
+ - [`@babelfhir-ts/client-r4`](https://www.npmjs.com/package/@babelfhir-ts/client-r4) is included as a dependency (base FHIR R4 client that the generated client extends)
134
154
  - `fhirpath` is a peer dependency (required only if you use the generated validators/classes)
135
155
 
136
156
  Install `fhirpath` in your app if you plan to call `.validate()` or use the generated classes.
@@ -176,6 +196,7 @@ babelfhir-ts [options] [<input> [output]]
176
196
  | `--log <level>` | Control logging output:`none` (default), `console`, or `file`. |
177
197
  | `--no-cache` | Remove the `.cache` directory once generation completes. |
178
198
  | `--no-classes` | Skip emitting helper classes (interfaces & validators only). |
199
+ | `--no-client` | Skip FHIR client generation (`fhir-client/` module). |
179
200
  | `--cache-dir <path>` | Custom cache directory (default:`.cache`). Also configurable via `FHIR_CACHE_ROOT` env var. |
180
201
  | `-h, --help` | Print usage help. |
181
202
  | `-v, --version` | Print the BabelFHIR-TS version. |
@@ -283,7 +304,9 @@ For security issues, please see [SECURITY.md](SECURITY.md) for our security poli
283
304
 
284
305
  ## Links
285
306
 
286
- - [npm package](https://www.npmjs.com/package/babelfhir-ts)
307
+ - [npm package — babelfhir-ts](https://www.npmjs.com/package/babelfhir-ts)
308
+ - [npm package — @babelfhir-ts/client-r4](https://www.npmjs.com/package/@babelfhir-ts/client-r4)
287
309
  - [GitHub repository](https://github.com/Max-Health-Inc/BabelFHIR-TS)
310
+ - [Validation report](https://max-health-inc.github.io/BabelFHIR-TS/)
288
311
  - [Issue tracker](https://github.com/Max-Health-Inc/BabelFHIR-TS/issues)
289
312
  - [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 |