Getting Started
Installation
Install globally (recommended when using the CLI frequently):
bash
npm install -g babelfhir-tsOr invoke on-demand without a global install:
bash
npx babelfhir-ts --helpRequirements
Node.js 18+ (ESM support) and an internet connection when downloading packages from remote registries.
Quick Start
Generate code from a local folder that contains FHIR packages:
bash
babelfhir-ts input/ output/Process a single package archive and write the generated interfaces back into a new .tgz file:
bash
babelfhir-ts hl7.fhir.us.core-8.0.0.tgz us-core-generated.tgzDownload and process a package directly from a registry (defaults to https://packages.simplifier.net):
bash
babelfhir-ts --package hl7.fhir.us.core@8.0.0Download, process, and install a processed package into your current project:
bash
babelfhir-ts install hl7.fhir.us.core@8.0.0Using the Generated Code
After generation you can import the emitted classes:
ts
import { USCorePatientClass } from "./output/USCorePatientClass";
const patient = USCorePatientClass.random();
const { errors, warnings } = await patient.validate();Or use the generated FHIR client to interact with a FHIR server:
ts
import { FhirClient } from "./output/fhir-client";
const client = new FhirClient("https://hapi.fhir.org/baseR4");
// Profile-specific methods generated from your IG
const patient = await client.read().usCorePatient().read("123");
const bundle = await client.read().usCoreCondition().search({ patient: "123" });
// All base resource types for the selected FHIR version are available
const appointment = await client.read().appointment().read("456");Next Steps
- CLI Reference — full list of commands and options
- Generated Code Guide — understanding the output
- ValueSets — generated ValueSet helpers and registry
- FHIR Client — type-safe server interactions with SMART auth
- Schema Generation — Zod schema output
- DICOMweb — FHIR ImagingStudy to DICOMweb/Cornerstone3D
- Multi-Language — localized display terms
- Validation — what the validators check and don't check
