JSPM

  • Created
  • Published
  • Downloads 214
  • Score
    100M100P100Q103592F
  • License ISC

BabelFHIR-TS: generate TypeScript interfaces, validators, and helper classes from FHIR R4/R4B/R5 StructureDefinitions (profiles) directly inside package archives.

Package Exports

  • babelfhir-ts
  • babelfhir-ts/out/src/main.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babelfhir-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

BabelFHIR-TS Logo

BabelFHIR-TS

Generate production-ready TypeScript from FHIR® StructureDefinitions — typed interfaces, runtime validators, and FHIR clients.

npm FHIR R4/R4B/R5 License: ISC

TypeScript Node.js Zod

client-r4 client-r4b client-r5 smart-auth

zod dicomweb

BabelFHIR-TS transforms FHIR® StructureDefinitions into production-ready TypeScript code with full type safety and built-in validation. Unlike generic FHIR type definitions, BabelFHIR-TS generates profile-aware interfaces that understand your Implementation Guide's constraints, extensions, and slicing rules.

What you get

  • Strongly typed interfaces that merge profile constraints with base FHIR types (types come from @types/fhir)
  • Compiled output by default — packages ship JavaScript (.js) plus TypeScript declarations (.d.ts)
  • Runtime validation using FHIRPath expressions from the profile—no external validator required for basic checks
  • Type-safe extension handling with proper slicing and nested extension support
  • Random data builders for testing and development (when class generation is enabled)
  • Zero manual mapping—consume any FHIR package or Implementation Guide directly from registries
  • Fast and lightweight—minimal runtime deps; only fhirpath is required for validators
  • Type-safe FHIR client — generated client extends @babelfhir-ts/client-r4 / client-r4b / client-r5 with profile-specific methods (e.g., .usCorePatient(), .pASClaim()) on top of base resource accessors
  • Install any FHIR profile as a node module—use babelfhir-ts install to add Implementation Guides directly to your project

Continuous Validation

Every pull request runs two independent CI pipelines that validate generated code against real-world FHIR Implementation Guides. For each IG, the pipeline:

  1. Downloads the FHIR package from a registry
  2. Generates TypeScript interfaces, validators, and classes
  3. Compiles the output with tsc (zero errors required)
  4. Generates empty() and random() test resources for every profile
  5. Validates those resources against two external FHIR validators

Tested Implementation Guides (30 packages)

Category Implementation Guide Package FHIR
US US Core hl7.fhir.us.core@8.0.0 R4
US QI-Core hl7.fhir.us.qicore@6.0.0 R4
US mCODE hl7.fhir.us.mcode@4.0.0 R4
US SDOH Clinical Care hl7.fhir.us.sdoh-clinicalcare@2.2.0 R4
US NDH (National Directory) hl7.fhir.us.ndh@1.0.0 R4
US CARIN BB hl7.fhir.us.carin-bb@2.1.0 R4
US CQF Measures hl7.fhir.us.cqfmeasures@4.0.0 R4
US Physical Activity hl7.fhir.us.physical-activity@1.0.0 R4
DaVinci PAS hl7.fhir.us.davinci-pas@2.0.1 R4
DaVinci CDex hl7.fhir.us.davinci-cdex@2.1.0 R4
DaVinci PDex hl7.fhir.us.davinci-pdex@2.1.0 R4
DaVinci DTR hl7.fhir.us.davinci-dtr@2.1.0 R4
DaVinci Alerts hl7.fhir.us.davinci-alerts@1.0.0 R4
DaVinci DEQM hl7.fhir.us.davinci-deqm@4.0.0 R4
DaVinci Drug Formulary hl7.fhir.us.davinci-drug-formulary@2.1.0 R4
Universal IPS hl7.fhir.uv.ips@2.0.0 R4
Universal SMART App Launch hl7.fhir.uv.smart-app-launch@2.2.0 R4
Universal SDC (Structured Data Capture) hl7.fhir.uv.sdc@3.0.0 R4
Universal Genomics Reporting hl7.fhir.uv.genomics-reporting@3.0.0 R4
Universal CPG (Clinical Practice Guidelines) hl7.fhir.uv.cpg@2.0.0 R4
DE ISiK Basis de.gematik.isik-basismodul@4.0.3 R4
DE KBV eRezept kbv.ita.erp@1.1.1 R4
DE DE Basisprofil de.basisprofil.r4@1.5.0 R4
DE ISiK Medikation de.gematik.isik-medikation@4.0.1 R4
CH CH Core (Switzerland) ch.fhir.ig.ch-core@5.0.0 R4
AU AU Core (Australia) hl7.fhir.au.core@1.0.0 R4
IHE PIXm ihe.iti.pixm@3.0.4 R4
IHE MHD ihe.iti.mhd@4.2.2 R4
R5 AE Research (R5) hl7.fhir.uv.ae-research-ig@1.0.1 R5
R5 eMedicinal Product (R5) hl7.fhir.uv.emedicinal-product-info@1.0.0 R5

Validation with Firely .NET SDK

The first pipeline validates generated resources using the Firely .NET SDK validator. Results are published as live badges:

US Core QI-Core mCODE SDOH Clinical Care NDH (National Directory) CARIN BB CQF Measures Physical Activity DaVinci PAS DaVinci CDex DaVinci PDex DaVinci DTR DaVinci Alerts DaVinci DEQM DaVinci Drug Formulary IPS SMART App Launch SDC (Structured Data Capture) Genomics Reporting CPG (Clinical Practice Guidelines) ISiK Basis KBV eRezept DE Basisprofil ISiK Medikation CH Core (Switzerland) AU Core (Australia) PIXm MHD

Validation with HL7 Java Validator

The second pipeline validates using the official HL7 FHIR Validator, the reference implementation for FHIR conformance checking:

US Core QI-Core mCODE SDOH Clinical Care NDH (National Directory) CARIN BB CQF Measures Physical Activity DaVinci PAS DaVinci CDex DaVinci PDex DaVinci DTR DaVinci Alerts DaVinci DEQM DaVinci Drug Formulary IPS SMART App Launch SDC (Structured Data Capture) Genomics Reporting CPG (Clinical Practice Guidelines) ISiK Basis KBV eRezept DE Basisprofil ISiK Medikation CH Core (Switzerland) AU Core (Australia) PIXm MHD

Terminology validation requires a tx server. The pipeline uses --tx-server https://tx.fhir.org/{r4|r5} (matching the package's FHIR version) during generation to expand ValueSets and produce valid codes.

📊 Full Report

Installation

npm install -g babelfhir-ts

Or on-demand: npx babelfhir-ts --help

Requirements: Node.js 18+ and an internet connection for remote registries.

Quick Start

# Generate from a local folder
babelfhir-ts input/ output/

# Download and process from a registry
babelfhir-ts --package hl7.fhir.us.core@8.0.0

# Install as a project dependency
babelfhir-ts install hl7.fhir.us.core@8.0.0
import { USCorePatientClass } from "./output/USCorePatientClass";

const patient = USCorePatientClass.random();
const { errors, warnings } = await patient.validate();

CLI Reference

Documentation

Full documentation is available at max-health-inc.github.io/BabelFHIR-TS/docs/

License

ISC © Maximilian Nussbaumer

Changelog

Release notes are published automatically on GitHub Releases: View all releases

Contributing

Contributions are welcome! See the Contributing guide for dev setup, scripts, and how to submit changes.

Security

For security issues, please see SECURITY.md for our security policy and how to report vulnerabilities.