FHIR in Rust
Model FHIR in typed Rust —
five releases, R2 through R6 — and store it in a SQL database as real relational tables — typed columns, child tables, foreign keys, check
constraints — not JSON blobs. Get it back losslessly.
Start the tutorial Run the examples
Pre-release. Each database port is described at its own conformance level.
The conformance matrix is the status document to trust, and the audit findings list every known divergence, with evidence.
What is here
Four families, one repository
A data model, six storage libraries, a shared persistence core, and an HTTP surface — deliberately separate, composing in one direction.
The complete HL7 FHIR data model as Rust types — five releases (R2–R6) as separate
crates, generated from the official specification, with validation, builders, choice
enums, an XML bridge, a REST client, and cross-release conversion with a loss report.
Overview · Specification · Examples
Six FHIR-to-relational libraries — PostgreSQL, SQLite, MySQL, MariaDB, SQL Server,
Oracle — one specification, one shared pure-Rust core, identical across all six and
gated in CI. Schemas are generated from the FHIR specification packages.
Overview · Conformance · Specification
The engine-agnostic half of persistence, shared by every port: the tamper-evident audit
chain (SHA-256 + SHA3-256, optional HMAC), attribution, and the result types. No driver,
no socket, no HTTP.
Overview · Trust & audit spec
A FHIR RESTful API — Rust, Loco, Axum — mounted over a store. CRUD, vread, history,
search, CapabilityStatement, PASETO authentication. The split is the point: storage
guarantees live in the libraries, HTTP lives here.
Overview · Specification
| Port | Database | Status |
|---|
fhir-postgresql | PostgreSQL 18 | Reference full store, full test suite |
|---|
fhir-sqlite | SQLite 3 | Store native, embeddable, no server |
|---|
fhir-mysql | MySQL 8.4 | Store |
|---|
fhir-mariadb | MariaDB 11.4 | Store |
|---|
fhir-mssql | SQL Server | Store live-verified; a standing TLS advisory risk (F-67) |
|---|
fhir-oracle | Oracle Database | Store live-verified; no upgrade path yet, snapshot reads open |
|---|
- `build_patient` — Build a FHIR R5 `Patient` with the generated builder and serialize it
- `client_crud` — FHIR REST client CRUD against the public HAPI test server (feature `client`)
- `code_systems` — Use FHIR R5 code systems as type-safe Rust enums
- `convert_release` — Convert a resource between FHIR releases, and read the loss report
- `extensions` — Read and write FHIR extensions ergonomically with `ExtensionExt`
- `operation_outcome` — Turn validation results into a FHIR `OperationOutcome`
- `primitive_extensions` — Read and write FHIR *primitive extensions* — the `_field` siblings
- `r3_patient` — Build a FHIR R3 `Patient`, serialize it, validate it, and read it back
- `r4_and_r5_side_by_side` — Use the R4 and R5 models in one program, and convert between them
- `r4_patient` — Build a FHIR R4 `Patient`, serialize it, validate it, and read it back
- `read_bundle` — Read a FHIR R5 `Bundle` and dispatch on each entry's resource type
- `search_response` — Consume a FHIR search response: typed entries, the total, and paging
- `transaction_bundle` — Build a FHIR transaction `Bundle` and read resources back out of one
- `tutorial` — The guide's end-to-end tutorial, as a runnable program
- `validate_resource` — Validate FHIR R5 values with the [`Validate`] trait
The model is fhir = "3" — five releases behind cargo features, r5 on
by default. The database ports and the server are pre-release in the fhir-rust repository, each at the conformance level the matrix
states.