clinical-fhir-agent
README.md
# clinical-fhir-agent
**An MCP server and LLM agent that answer clinical questions about synthetic FHIR R4 patients — with every answer cited, refusals when the data don't support an answer, and a reproducible evaluation of how often it gets things right.**
> ⚠️ **Not a medical device.** This is an engineering and portfolio project. It uses **synthetic data only** (Synthea), is not certified, and must not be used with real patient data or to make health decisions. See [intended use](docs/regulatory/intended-use.md).
---
## Why this project
Demos of LLM agents on medical data are easy; knowing **how often they are wrong, and how** is the hard part. This project treats the evaluation as the main deliverable:
- a golden set whose expected answers are **computed from the FHIR data**, not written from memory or by an LLM;
- a **dev/test split by patient**, so prompt tuning never sees the held-out data;
- metrics for **accuracy, hallucination, citation validity and correct refusal**, per question category, with confidence intervals over repeated runs;
- versioned, regenerable reports tied to a commit, a model ID and a dataset digest.
Development follows a lightweight version of the processes used for medical-device software (IEC 62304, ISO 14971): requirements, risk analysis with risk controls verified by evaluation metrics, SOUP list (the LLM included), and traceability enforced in CI.
## System overview
```
Synthea cohort (pinned) ──► local HAPI FHIR R4 ◄── REST ── MCP server (read-only tools)
▲ MCP
LLM agent ────┘
→ {answer, citations[], refused}
▲
evaluation: oracle golden set → runner → scorers → report
```
Details: [architecture](docs/regulatory/architecture.md) and [ADRs](docs/adr/README.md).
## Status
**Milestone 0 (foundations) complete:** a pinned synthetic cohort of 50 patients, loaded into a local FHIR server by a loader that accepts only verified synthetic data. **Milestone 1 (MCP server) in progress.** See [milestones](docs/regulatory/milestones.md).
| Milestone | Content |
|---|---|
| M0 | Repository, CI, process documents, synthetic cohort, local FHIR server |
| M1 | MCP server with read-only FHIR tools |
| M2 | Agent with cited answers and refusals |
| M3 | Evaluation v1: golden set, deterministic scorers, baseline report |
| M4 | Evaluation v2: hallucinations, calibrated judge, adversarial cases, held-out run |
| M5 | System card, final risk review, results |
## Development
Requires [uv](https://docs.astral.sh/uv/) and Docker.
```sh
uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run mypy
uv run python scripts/traceability.py --check
```
## Documentation
| Document | Content |
|---|---|
| [Intended use](docs/regulatory/intended-use.md) | Purpose, scope, foreseeable misuse, assumed safety class |
| [Development plan](docs/regulatory/sdp.md) | Lifecycle, roles, verification strategy |
| [Requirements](docs/regulatory/srs.md) · [Traceability](docs/regulatory/traceability.md) | What the software must do, and how each requirement is verified |
| [Risk analysis](docs/regulatory/risk-analysis.md) | Hazards of a wrong answer and their controls |
| [SOUP](docs/regulatory/soup.md) | Third-party software, services and models |
| [Open points](docs/regulatory/open-points.md) | Pending decisions and known gaps |
## License
Code: [Apache-2.0](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues