LangChain/LangGraph is an MIT-licensed framework for stateful, human-in-the-loop AI agents. We built the agent and orchestration layer for an ambient medical scribe — an auditable graph that drafts a SOAP note, waits for clinician approval, then writes it into the client's FHIR backend.
A clinical-documentation startup wanted an ambient AI scribe that listens to a visit transcript, drafts a structured SOAP note, and requires explicit clinician sign-off before anything is saved. For clinical-safety review they needed controllable, auditable agent behavior — not a black box.
- Guaranteeing a mandatory human-in-the-loop approval gate before any note touched the patient record.
- Grounding the draft in the patient's prior records via retrieval so notes were accurate, not hallucinated.
- Making every agent run auditable for clinical-safety review, with a typed, schema-validated note as output.
We modelled the scribe as a LangGraph state machine — transcribe → retrieve_patient_context → draft_SOAP_note → human_approval (interrupt) → write_to_FHIR — using the checkpointer to pause at approval, enforcing a Zod schema on output, and tracing every run for audit.
- A LangGraph graph whose checkpointer halts at a human_approval interrupt until a clinician signs off, so nothing is written without consent.
- A retrieval step that grounds the draft in the patient's prior FHIR records via a vector store before the note is generated.
- Schema-enforced output written back as a FHIR DocumentReference, with every execution traced (visit_id as metadata) for clinical-safety auditing.
A customized view of the system we shipped for this engagement — the components and how requests and data flow between them.
Before — manual bottleneck flow
Doctor reconstructs notes from memory and scribbles, typing into a clunky EMR after hours.
Notes are re-checked for omissions and compliance, adding another delay.
Earlier auto-generation tools couldn't be audited, so they were never approved for use.
After — automated optimized flow
The graph retrieves prior FHIR context and drafts a schema-valid SOAP note.
The graph pauses at a human_approval interrupt; nothing is saved until sign-off.
The approved note is written as a DocumentReference and the run is traced for audit.
“Our safety board would never have signed off on a black box. Because the approval step is built into the workflow and every run is traceable, we could actually show them how it behaves before a single note was saved. That's what got it into clinic.”

