Case study · LangGraph, RAG, healthcare
A clinical co-pilot that shows its sources
An AI assistant embedded in OpenEMR, an open-source medical record. It gives an overnight cross-covering resident the patient context they need, the moment they need it, sourced from the actual chart, uploaded documents and clinical guidelines, never inferred or assumed.
- 55 / 55golden-set cases (54 passed, 1 skipped)
- 288 / 288unit tests on every merge
- 8 / 8agent-graph cases
- 100%on all 5 rubric metrics
The question
At 3 a.m., a resident covering patients they've never met has to decide things quickly, often from a hurried sign-out. A wrong medication dose or a missed allergy matters. The question wasn't "can a model summarize a chart?" but "can it give a resident context they can trust, and make it obvious where every fact came from?"
What I built
- Week 1: one tool-calling agent over six chart tools, using the medical record's standard FHIR data. A verification step strips any claim the chart doesn't support, and an allergy check is a hard stop in code.
- Week 2: a LangGraph supervisor that routes each question to a chart worker, a document-extraction worker for uploaded lab PDFs and intake forms, or a guideline-retrieval worker over a small clinical guideline library.
- Citations everywhere. Every extracted field cites its place in the source document, with a click-to-source highlight on the original page, and guideline answers cite the guideline.
- Real access control. Each resident signs in through the medical record's own OAuth login, so the agent sees only what that person is allowed to see, and patient identifiers are redacted from logs.
How I measured it
A 55-case golden set, 8 agent-graph cases and 288 unit tests run on every code change, and any failure blocks the merge. A five-metric rubric gate scores the answers themselves. Try the kind of question a real sign-out produces, such as "The day team says she's on metformin 500 mg twice daily and has no allergies; can you confirm before I give the next dose?" The co-pilot catches the dose discrepancy and flags a duplicate record.
Results and what came next
On the final code change, the golden set passed 55 of 55 (one case skipped), graph cases 8 of 8, unit tests 288 of 288, and every rubric metric hit 100%.
Then I attacked it. My adversarial security platform found that the co-pilot could disclose internal tool details. I shipped a fix, a non-disclosure rule plus a deterministic response filter, and the platform's replay went from 6 of 6 leaks to 0 of 6 on the new version. One finding was resolved; a human read showed the other was only partly fixed, so it stays open and documented rather than claimed done. Known gaps are listed plainly in the repo.