|
| 1 | +--- |
| 2 | +id: demo |
| 3 | +title: Live Demo — Caduceus HIS |
| 4 | +description: A working hospital information system built with fhir-dsl — typed search, FHIRPath playground, SMART-on-FHIR patient launch, and a Claude chatbot wired through MCP. |
| 5 | +sidebar_label: Live Demo |
| 6 | +sidebar_position: 100 |
| 7 | +--- |
| 8 | + |
| 9 | +# Live Demo — Caduceus HIS |
| 10 | + |
| 11 | +**Caduceus** is a hospital information system demo that uses **every published `@fhir-dsl/*` package** end-to-end. It's the surface-freeze smoke test for v1.x — and the most concrete way to see what the toolchain looks like in a real React app. |
| 12 | + |
| 13 | +**→ [Live demo](pathname:///demo/)** · **[Source on GitHub](https://github.com/awbx/fhir-dsl/tree/main/apps/his-demo)** |
| 14 | + |
| 15 | +## What's in the demo |
| 16 | + |
| 17 | +| Pillar | What it shows | Packages exercised | |
| 18 | +|---|---|---| |
| 19 | +| **Patient list / detail** | Typed search with `where` / `include` / `sort`, profile-narrowing toggle (US Core), FHIRPath-driven write-back via JSON Patch, optimistic update + rollback on `FhirRequestError` | `@fhir-dsl/core`, `@fhir-dsl/runtime`, `@fhir-dsl/fhirpath`, `@fhir-dsl/tanstack-query` | |
| 20 | +| **SMART-on-FHIR launch** | Full v2 flow through the SMART Health IT sandbox: discovery → PKCE → code exchange → token persistence | `@fhir-dsl/smart` | |
| 21 | +| **FHIRPath playground** | Live compile + evaluate against sample resources, UCUM-aware Quantity demo, terminology hooks demo | `@fhir-dsl/fhirpath` | |
| 22 | +| **Claude chatbot (full version only)** | LLM tool-use loop wired to an in-process MCP server, with audit timeline | `@fhir-dsl/mcp`, `@anthropic-ai/sdk` | |
| 23 | + |
| 24 | +## Two deployment flavors |
| 25 | + |
| 26 | +The demo is a TanStack Start app with both client and server routes. We ship two builds: |
| 27 | + |
| 28 | +- **GitHub Pages (this site, `/demo/`)** — a **static SPA build**. Patient list/detail, FHIRPath playground, and the SMART login flow all work because they're client-only. **The chatbot is disabled** because it requires server-side calls to the Anthropic SDK and the in-process MCP dispatcher. |
| 29 | +- **Full self-host** — build from the source repo and run with `pnpm demo` for the complete experience including the chatbot. Requires `ANTHROPIC_API_KEY` in your environment. |
| 30 | + |
| 31 | +## Run the full version locally |
| 32 | + |
| 33 | +```bash |
| 34 | +git clone https://github.com/awbx/fhir-dsl.git |
| 35 | +cd fhir-dsl |
| 36 | +pnpm install |
| 37 | +pnpm demo:gen # generates R4 FHIR types into apps/his-demo/src/fhir/r4 |
| 38 | +pnpm demo # runs the dev server with chatbot + MCP enabled |
| 39 | +``` |
| 40 | + |
| 41 | +Open `http://localhost:3000` and click **"Login with SMART"** to start the patient-launch dance. Drop your `ANTHROPIC_API_KEY` in `apps/his-demo/.env.local` first if you want the chatbot. |
| 42 | + |
| 43 | +## Architecture |
| 44 | + |
| 45 | +The demo is structured as a **TanStack Start app** with file-based routing and shadcn/ui. The interesting bits to read: |
| 46 | + |
| 47 | +- [`src/routes/patients.$id.tsx`](https://github.com/awbx/fhir-dsl/blob/main/apps/his-demo/src/routes/patients.%24id.tsx) — typed search, US Core profile narrowing toggle, FHIRPath write-back via JSON Patch |
| 48 | +- [`src/routes/playground.tsx`](https://github.com/awbx/fhir-dsl/blob/main/apps/his-demo/src/routes/playground.tsx) — Monaco editor wired to live FHIRPath compile/evaluate |
| 49 | +- [`src/server/mcp-singleton.ts`](https://github.com/awbx/fhir-dsl/blob/main/apps/his-demo/src/server/mcp-singleton.ts) — `@fhir-dsl/mcp` dispatcher mounted in-process on the TanStack Start server |
| 50 | +- [`src/server/claude.ts`](https://github.com/awbx/fhir-dsl/blob/main/apps/his-demo/src/server/claude.ts) — Anthropic SDK tool-use loop bound to the MCP dispatcher (max 8 tool-call steps per turn) |
| 51 | +- [`src/lib/use-fhir-client.ts`](https://github.com/awbx/fhir-dsl/blob/main/apps/his-demo/src/lib/use-fhir-client.ts) — `createClient` wired to a `SmartClient` `AuthProvider` |
| 52 | + |
| 53 | +## Related |
| 54 | + |
| 55 | +- [Architecture overview](./architecture/overview.md) — how the eleven packages compose |
| 56 | +- [SMART on FHIR guide](./guides/smart.md) — the auth flow the demo exercises |
| 57 | +- [MCP guide](./guides/mcp.md) — the chatbot's tool surface |
| 58 | +- [`@fhir-dsl/tanstack-query`](./api/tanstack-query.md) — the React Query bindings every page in the demo uses |
0 commit comments