fhir-dsl
Type-safe FHIR query builder and code generator for TypeScript
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[]Built for the FHIR spec, not around it
End-to-end type safety from the StructureDefinitions on the server to the `.where()` calls in your editor.
Type-Safe Queries
Every resource, search parameter, and operator is validated at compile time. No malformed FHIR queries at runtime.
Code Generation
Generate TypeScript interfaces from official StructureDefinitions. R4, R4B, R5, R6, or any published IG.
Profile-Aware
Query against US Core or custom IG profiles with automatic type narrowing — profile constraints enforced by the type system.
Immutable Builders
Every query method returns a new instance. Safe to store, fork, and compose — no hidden mutation.
Zero Runtime Overhead
The core DSL has no runtime dependencies beyond @fhir-dsl/types. Type safety compiles away to plain objects.
Kysely-Inspired
If you know Kysely, you already know fhir-dsl. A familiar fluent, chainable API adapted to the FHIR REST spec.
Ready to query FHIR with confidence?
Generate types, spin up a client, and write your first type-safe query in under two minutes.