npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

babelfhir-ts

v1.5.1

Published

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

Readme

BabelFHIR-TS

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 | [email protected] | R4 | | US | QI-Core | [email protected] | R4 | | US | mCODE | [email protected] | R4 | | US | SDOH Clinical Care | [email protected] | R4 | | US | NDH (National Directory) | [email protected] | R4 | | US | CARIN BB | [email protected] | R4 | | US | CQF Measures | [email protected] | R4 | | US | Physical Activity | [email protected] | R4 | | DaVinci | PAS | [email protected] | R4 | | DaVinci | CDex | [email protected] | R4 | | DaVinci | PDex | [email protected] | R4 | | DaVinci | DTR | [email protected] | R4 | | DaVinci | Alerts | [email protected] | R4 | | DaVinci | DEQM | [email protected] | R4 | | DaVinci | Drug Formulary | [email protected] | R4 | | Universal | IPS | [email protected] | R4 | | Universal | SMART App Launch | [email protected] | R4 | | Universal | SDC (Structured Data Capture) | [email protected] | R4 | | Universal | Genomics Reporting | [email protected] | R4 | | Universal | CPG (Clinical Practice Guidelines) | [email protected] | R4 | | DE | ISiK Basis | [email protected] | R4 | | DE | KBV eRezept | [email protected] | R4 | | DE | DE Basisprofil | [email protected] | R4 | | DE | ISiK Medikation | [email protected] | R4 | | CH | CH Core (Switzerland) | [email protected] | R4 | | AU | AU Core (Australia) | [email protected] | R4 | | IHE | PIXm | [email protected] | R4 | | IHE | MHD | [email protected] | R4 | | R5 | AE Research (R5) | [email protected] | R5 | | R5 | eMedicinal Product (R5) | [email protected] | 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 [email protected]

# Install as a project dependency
babelfhir-ts install [email protected]
import { USCorePatientClass } from "./output/USCorePatientClass";

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

CLI Reference

BabelFHIR-TS: Generate TypeScript interfaces from FHIR StructureDefinitions

Usage:
  babelfhir-ts [options] [<input> [output]]
  babelfhir-ts install [--package] <pkg[@version]|path> [--registry <url>] [options]
  babelfhir-ts update [<pkg@version>] [--recursive] [options]

Arguments:
  input   Input can be:
          - Canonical URL of a FHIR profile (http://... or https://...)
          - Directory containing FHIR packages (.tgz/.zip files)
          - Single FHIR package (.tgz/.zip file)
          - Single StructureDefinition (.json file)
          - Directory containing StructureDefinition files
  output  Output directory or archive name (optional)

Commands:
  install                Download, process, and npm install package as dependency
  update                 Regenerate all installed packages (or a specific one) with current babelfhir-ts

Options:
  -h, --help               Show this help message
  -v, --version            Show version number
  --log <dest>             Log destination: console (default) or file
  --log-level <level>      Log verbosity: error, warn, info (default), or debug
  --cache-dir <path>       Custom cache directory (default: ~/.fhir/packages for FHIR packages, .cache for working files)
  --no-cache               Delete .cache working folder after generation (does not affect shared ~/.fhir/packages)
  --no-classes             Only generate interfaces and types (skip class generation)
  --no-client              Skip FHIR client generation (client generated by default)
  --schema <format>        Generate schema files alongside outputs (supported: zod)
  --dicomweb               Generate DICOMweb helpers typed to ImagingStudy profiles in the IG
  --prefab                 Generate Prefab UI render functions per profile (@maxhealth.tech/prefab)
  --prefab-styles <path>   Path to styles module (.ts/.js) copied into the generated prefab/ folder
  --recursive              (update only) Recursively search subdirectories for lib/ folders
  --force                  (update only) Force regeneration even if version and flags haven't changed
  --outDir <dir>           Output directory (alias for second positional argument)
  --fhir-version <ver>     FHIR version to target: r4, r4b, or r5 (auto-detected from package if omitted)
  --package <pkg[@version]>  Download FHIR package from registry and process it (latest if no version)
  --registry <url>         FHIR package registry URL (default: https://packages.simplifier.net)
  --tx-server <url>        Terminology server URL for ValueSet expansion (e.g., https://tx.fhir.org/r4)
                           When set, expands ValueSets without explicit codes using $expand operation
  --display-language <lang> BCP-47 language(s) for display terms (e.g., de or de,fr,en).
                           Single value replaces concept displays. Comma-separated values
                           also generate a multi-language display map with getDisplay() helper.

Examples:
  babelfhir-ts                                             # Process ./input to ./output
  babelfhir-ts http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient  # Generate from profile URL
  babelfhir-ts package.tgz                                 # Process package to current directory
  babelfhir-ts package.tgz modified-package.tgz            # Embed interfaces in package
  babelfhir-ts profiles/ generated/                        # Process directory to directory
  babelfhir-ts --package [email protected]            # Download and process from default registry
  babelfhir-ts --package [email protected] output/    # Download and output to directory
  babelfhir-ts --package pkg@version --log console --log-level debug  # With verbose logging
  babelfhir-ts install de.gematik.isik-basismodul                           # Download latest, process, and install
  babelfhir-ts install [email protected]                   # Download specific version
  babelfhir-ts install ./package.tgz                                      # Install from local package file
  babelfhir-ts install [email protected] --registry <url>            # Install from custom registry
  babelfhir-ts install --package [email protected] --registry <url>  # Alternative syntax
  babelfhir-ts update                                                      # Regenerate all packages in ./lib
  babelfhir-ts update [email protected]                               # Regenerate a specific package
  babelfhir-ts update --recursive                                          # Regenerate packages in all subdirectories

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.

Links