babelfhir-ts 1.0.35 → 1.0.36

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
@@ -23,9 +23,30 @@
23
23
  - **Install any FHIR profile as a node module**—use `babelfhir-ts install` to add Implementation Guides directly to your project
24
24
 
25
25
  <!-- PARITY-BADGES:START - Do not remove or modify this section -->
26
- ## Pipeline Parity Results
26
+ ## Continuous Validation
27
27
 
28
- BabelFHIR-TS validators achieve **100% parity** with the Firely .NET SDK validator across major Implementation Guides:
28
+ Every pull request runs two independent CI pipelines that validate generated code against real-world FHIR Implementation Guides. For each IG, the pipeline:
29
+
30
+ 1. Downloads the FHIR package from a registry
31
+ 2. Generates TypeScript interfaces, validators, and classes
32
+ 3. Compiles the output with `tsc` (zero errors required)
33
+ 4. Generates `empty()` and `random()` test resources for every profile
34
+ 5. Validates those resources against two external FHIR validators
35
+
36
+ ### Tested Implementation Guides
37
+
38
+ | Implementation Guide | Package | Profiles |
39
+ |---|---|---|
40
+ | US Core | `hl7.fhir.us.core@8.0.0` | Patient, Condition, Observation, Encounter, … |
41
+ | ISiK Basis (Germany) | `de.gematik.isik-basismodul@4.0.3` | ISiKPatient, ISiKDiagnose, … |
42
+ | IPS (International Patient Summary) | `hl7.fhir.uv.ips@2.0.0` | Composition, MedicationStatement, … |
43
+ | SMART App Launch | `hl7.fhir.uv.smart-app-launch@2.2.0` | WellKnown endpoints |
44
+ | CH Core (Switzerland) | `ch.fhir.ig.ch-core@5.0.0` | CHCorePatient, CHCoreEncounter, … |
45
+ | DaVinci PAS | `hl7.fhir.us.davinci-pas@2.0.1` | PASClaim, PASClaimResponse, … |
46
+
47
+ ### Validation with Firely .NET SDK
48
+
49
+ The first pipeline validates generated resources using the [Firely .NET SDK validator](https://docs.fire.ly/projects/Firely-NET-SDK/) (v3.0.1). Results are published as live badges:
29
50
 
30
51
  ![US Core 8.0.0](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-us-core.json)
31
52
  ![ISiK Basis 4.0.3](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-isik-basis.json)
@@ -33,14 +54,11 @@ BabelFHIR-TS validators achieve **100% parity** with the Firely .NET SDK validat
33
54
  ![SMART 2.2.0](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-smart.json)
34
55
  ![CH Core 5.0.0](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-ch-core.json)
35
56
 
36
- > **11 profiles excluded** due to [Firely SDK bugs](./docs/FIRELY-VALIDATOR-BUGS.md) — validated successfully with HL7 Java Validator.
37
-
38
- 📊 **[Full Report](https://gist.github.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f)** · *Last updated: Dec 10, 2025*
57
+ > 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).
39
58
 
40
- <!-- HL7-PARITY-BADGES:START - Do not remove or modify this section -->
41
- ### HL7 Java Validator Parity
59
+ ### Validation with HL7 Java Validator
42
60
 
43
- Generated `random()` and `empty()` methods also pass structural validation with the [official HL7 FHIR Validator](https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator):
61
+ The second pipeline validates using the [official HL7 FHIR Validator](https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator) (v6.3.11), the reference implementation for FHIR conformance checking:
44
62
 
45
63
  ![US Core 8.0.0](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-hl7-us-core.json)
46
64
  ![ISiK Basis 4.0.3](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-hl7-isik-basis.json)
@@ -48,9 +66,9 @@ Generated `random()` and `empty()` methods also pass structural validation with
48
66
  ![SMART 2.2.0](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-hl7-smart.json)
49
67
  ![CH Core 5.0.0](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f/raw/badge-hl7-ch-core.json)
50
68
 
51
- > **Note:** Terminology validation (codes bound to ValueSets) requires a terminology server. The HL7 validator validates terminology bindings against `tx.fhir.org` by default, which may report errors for generated placeholder codes. Use `--tx-server https://tx.fhir.org/r4` during generation to expand ValueSets and use real codes.
69
+ > 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.
52
70
 
53
- 📊 **[Full Report](https://gist.github.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f)** · *Last updated: Jan 24, 2026*
71
+ 📊 **[Full Report & Badge Data](https://gist.github.com/quotentiroler/e9bc625cfe88a0a67a73abc06660f40f)**
54
72
  <!-- HL7-PARITY-BADGES:END -->
55
73
  <!-- PARITY-BADGES:END -->
56
74
 
@@ -233,7 +251,7 @@ For comprehensive conformance testing, use the official [HL7 FHIR Validator](htt
233
251
  - Reference integrity constraints
234
252
 
235
253
  Use `random()` for development, testing, and prototyping, but always validate production data on the FHIR server side.
236
- - **`validate()` parity**: The generated validation methods execute FHIRPath expressions and check constraints from StructureDefinitions, but are **only guaranteed to match** the Firely .NET SDK validator for scenarios covered by our test suite (see GitHub actions). Edge cases, complex slicing patterns, or profiles not in our test 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.
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.
237
255
 
238
256
  ### FHIR Version Support
239
257
 
@@ -242,7 +260,7 @@ For comprehensive conformance testing, use the official [HL7 FHIR Validator](htt
242
260
 
243
261
  ### Reporting Issues
244
262
 
245
- If you encounter an Implementation Guide that doesn't generate correctly, please [open an issue](https://github.com/quotentiroler/BabelFHIR-ts/issues) with:
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:
246
264
 
247
265
  - The package name and version
248
266
  - The specific StructureDefinition URL
@@ -266,6 +284,6 @@ For security issues, please see [SECURITY.md](SECURITY.md) for our security poli
266
284
  ## Links
267
285
 
268
286
  - [npm package](https://www.npmjs.com/package/babelfhir-ts)
269
- - [GitHub repository](https://github.com/quotentiroler/BabelFHIR-ts)
270
- - [Issue tracker](https://github.com/quotentiroler/BabelFHIR-ts/issues)
287
+ - [GitHub repository](https://github.com/Max-Health-Inc/BabelFHIR-TS)
288
+ - [Issue tracker](https://github.com/Max-Health-Inc/BabelFHIR-TS/issues)
271
289
  - [Changelog](CHANGELOG.md)
@@ -1280,7 +1280,7 @@ export async function generateIntoPackage(packageArchivePath, outArchivePath, fl
1280
1280
  license: 'MIT',
1281
1281
  // fhirpath is required at runtime by validators; keep as peer so host decides version
1282
1282
  peerDependencies: {
1283
- 'fhirpath': '^4.0.0'
1283
+ 'fhirpath': '^3.0.0 || ^4.0.0'
1284
1284
  },
1285
1285
  // Type definitions for FHIR are needed for the .d.ts files
1286
1286
  dependencies: {
@@ -1291,10 +1291,14 @@ export async function generateIntoPackage(packageArchivePath, outArchivePath, fl
1291
1291
  fs.writeFileSync(generatedPackageJsonPath, JSON.stringify(generatedPackageJson, null, 2));
1292
1292
  logger.log(`Created package.json in generated folder: ${packageName}-generated@${packageVersion}`);
1293
1293
  // Copy fhir-r4.d.ts ambient module declaration to support fhir/r4 imports
1294
- // The file is at out/fhir-r4.d.ts (root of compiled output)
1295
- const fhirR4DtsSource = path.join(path.dirname(path.dirname(fileURLToPath(import.meta.url))), 'fhir-r4.d.ts');
1294
+ // In dev: src/generator/ -> src/fhir-r4.d.ts. In compiled: out/src/generator/ -> out/fhir-r4.d.ts
1295
+ const _selfDir = path.dirname(fileURLToPath(import.meta.url));
1296
+ const fhirR4DtsSource = [
1297
+ path.join(_selfDir, '..', 'fhir-r4.d.ts'),
1298
+ path.join(_selfDir, '..', '..', 'fhir-r4.d.ts'),
1299
+ ].find(p => fs.existsSync(p));
1296
1300
  const fhirR4DtsDest = path.join(outputDir, 'fhir-r4.d.ts');
1297
- if (fs.existsSync(fhirR4DtsSource)) {
1301
+ if (fhirR4DtsSource) {
1298
1302
  fs.copyFileSync(fhirR4DtsSource, fhirR4DtsDest);
1299
1303
  logger.log('Copied fhir-r4.d.ts ambient module declaration');
1300
1304
  }
package/out/src/main.js CHANGED
@@ -5,11 +5,25 @@ import { getCacheConfig, getFhirPackagesCacheDir, clearAllCaches, ensureCacheDir
5
5
  import { fetchArrayBuffer } from "./generator/fetchUtils.js";
6
6
  import fs from 'fs';
7
7
  import path from 'path';
8
- import { createRequire } from 'module';
8
+ import { fileURLToPath } from 'url';
9
9
  import { spawn } from 'child_process';
10
10
  import { logger } from './logger.js';
11
- const require = createRequire(import.meta.url);
12
- const packageJson = require('../package.json');
11
+ // Resolve package.json relative to this file — works from both src/ (dev) and out/src/ (compiled)
12
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
+ const _pkgJsonPath = [
14
+ path.resolve(__dirname, '../package.json'),
15
+ path.resolve(__dirname, '../../package.json'),
16
+ ].find(p => {
17
+ try {
18
+ return JSON.parse(fs.readFileSync(p, 'utf8')).name === 'babelfhir-ts';
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ });
24
+ if (!_pkgJsonPath)
25
+ throw new Error('Cannot find babelfhir-ts package.json');
26
+ const packageJson = JSON.parse(fs.readFileSync(_pkgJsonPath, 'utf8'));
13
27
  function printUsage() {
14
28
  console.log("BabelFHIR-TS: Generate TypeScript interfaces from FHIR StructureDefinitions");
15
29
  console.log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babelfhir-ts",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "BabelFHIR-TS: generate TypeScript interfaces, validators, and helper classes from FHIR R4 StructureDefinitions (profiles) directly inside package archives.",
5
5
  "type": "module",
6
6
  "main": "out/src/main.js",