fhir-dsl
The TypeScript FHIR toolchain — typed query builder, code generator, FHIRPath, validators, SMART-on-FHIR, terminology, and an MCP bridge.
See it in action
A short narrated tour of the query builder, generator, and CLI.
The FHIR toolchain, end to end
From StructureDefinitions on the server to the .where() calls in your editor — types, validators, FHIRPath, terminology, SMART, and an MCP bridge.
Type-Safe Queries
Every resource, search parameter, operator, modifier, include, _has, and chained hop is validated at compile time. No malformed FHIR queries at runtime.
Code Generation
Generate TypeScript interfaces, profile schemas, ValueSet enums, and FHIRPath builders from any FHIR version (R4 / R4B / R5 / R6) or any published IG.
Profile-Aware
Query US Core, IPS, or any custom IG with automatic type narrowing. Slicing, typed extensions, and profile cardinality all enforced by the type system.
Standard Schema Validators
Optional zod or zero-dep native validators conforming to Standard Schema V1, with FHIRPath invariants (pat-1, dom-3, …) wired in automatically.
FHIRPath Builder
Type-safe FHIRPath expressions with autocomplete at every step, compilation to FHIRPath strings, and runtime evaluation. 70+ functions across the N1 spec.
SMART on FHIR v2
PKCE-S256, backend-services JWT (RS384 / ES384), patient-launch refresh-token rotation. Lazy-loaded — bearer-only deployments never pay the jose cost.
Terminology Engine
is-a, descendent-of, and regex ValueSet filters with transitive subsumption. Bundled $expand, $validate-code, $lookup, $translate, $subsumes operations.
MCP Server (LLM bridge)
Generated tool surface for any LLM agent, with stdio + streamable HTTP transports, three pluggable auth strategies, write gating, and full audit.
Zero Runtime Overhead
The core DSL has no runtime dependencies beyond @fhir-dsl/types. Dual ESM/CJS. Type safety compiles away to plain objects.
Fluent API, real FHIR
Search, filter across references, compose transactions, or stream large result sets — every call is fully typed against the FHIR spec.
const result = await fhir .search("Patient") .where("family", "eq", "Smith") .where("birthdate", "ge", "1990-01-01") .include("general-practitioner") .sort("birthdate", "desc") .count(10) .execute();
// result.data: Patient[] — fully typed// result.included: Practitioner[]Ten focused packages, one toolchain
Install only what you need. core + runtime get you a typed client; everything else is opt-in.
Wherever FHIR meets TypeScript
EHR & FHIR Integrators
Hit US Core, Epic, Cerner, HAPI, or any custom IG with compile-time-checked queries. Profile-aware, slice-aware, no string guessing.
Health-Tech Platforms
Generate types from your tenant's IG, validate every payload at the boundary, and ship a single FHIR client across services with no version drift.
AI & LLM Agents
Expose a FHIR endpoint as an MCP tool surface in one command. Read-only by default, write gating per resource type, full audit, stdio + HTTP transports.
Conformance Authors
Compile FHIRPath invariants, run them against generated Standard Schema validators, and emit OperationOutcome — all from your test suite.
Ready to query FHIR with confidence?
Generate types, spin up a client, and write your first type-safe query in under two minutes.