Home / Work / Clinical documentation agent

Asha Health · AI medical scribe · 2023–2025

A clinical
documentation agent
doctors kept using

Most scribe products win the demo and lose the third week. The interesting engineering was not the transcription — it was everything that had to be true before a physician would let a generated sentence into a patient record.

Role
SDE, Python & Generative AI
Domain
Healthcare · protected health data
Outcome
≈40% less manual documentation time
Stack
LangGraph · LangChain · AWS Bedrock · Lambda · DynamoDB · Langfuse

The constraint

Clinicians were spending a large share of every consultation typing rather than looking at the patient, and the documentation backlog was following them home. A summarisation model on top of a transcript gets you a plausible-looking note in an afternoon. It does not get you a note anyone will sign.

Three things had to hold before that was possible. Every clinical claim in the note had to trace back to something said in the encounter or recorded in the patient's history. Nothing identifiable could reach a model that had no business seeing it. And when the output was wrong — it would sometimes be wrong — we had to be able to reconstruct exactly which prompt version, which retrieved context and which model call produced it.

A demo needs the model to be right. A clinical system needs you to be able to prove why it was right, and to notice quickly when it stops being.

How it was built

A state machine, not a prompt chain

The workflow was a LangGraph state machine with conditional branching across documentation, coding and review stages. That structure mattered more than any individual prompt. A linear chain fails over to a human the moment anything is ambiguous; a graph can route — send an under-specified medication mention to a clarification node, hold a low-confidence code for review, and carry on with the rest of the note instead of abandoning the whole run.

State lived outside the model, in DynamoDB, so a run could be inspected, resumed and replayed rather than existing only inside a context window.

Retrieval as the grounding contract

A RAG pipeline on AWS Bedrock grounded every generated note in patient history and clinical guidelines. The retrieval layer was not there to make output sound better — it was the mechanism that made the output admissible. Generation nodes could only assert what retrieval had supplied, and every assertion carried its source through to review.

Redaction before inference

PII and PHI were stripped at the pipeline boundary, before anything reached a model endpoint. Doing it at the boundary rather than per-call meant a new node could be added later without someone having to remember the rule.

Prompt governance and observability

Prompts were versioned artefacts, not string literals in application code. Langfuse traced every model call, and token spend, latency and quality KPIs were watched continuously — which is how regressions were caught before clinicians ran into them rather than after. That single decision, made early, did more for trust in the system than any model upgrade.

Encounter audioASR TRANSCRIPT PHI redactionBOUNDARY LANGGRAPH STATE MACHINE Extract Draft Review Code STATE IN DYNAMODB · RESUMABLE Bedrock retrieval PATIENT HISTORYCLINICAL GUIDELINES Clinician review HUMAN APPROVES→ PATIENT RECORD LANGFUSE — EVERY CALL TRACED · PROMPTS VERSIONED · SPEND, LATENCY AND QUALITY WATCHED

Simplified architecture. Redaction sits at the boundary, retrieval gates what the generator is allowed to assert, and tracing spans the whole run.

What changed

Manual transcription time fell by roughly 40%. The number worth more attention is the second-order one: because prompts were versioned and every call traced, changing the system stopped being frightening. A prompt could be revised on a Tuesday and its effect on note quality read off the traces by Wednesday — which is the difference between an AI feature that ossifies after launch and one that keeps improving.

The part I would carry into any regulated build unchanged: decide what the system is allowed to assert, and make retrieval — not the prompt — the thing that enforces it.

My role

  • Designed and built the LangGraph stateful agent workflows across documentation, coding and review.
  • Shipped the RAG pipeline on AWS Bedrock grounding generated notes in patient history and clinical guidelines.
  • Owned prompt governance and observability through Langfuse — versioning, tracing, and the token, latency and quality KPIs.
  • Gathered requirements directly from clinical stakeholders and converted them into agent behaviour specs, without engineering jargon in the room.

Client-confidential implementation detail is deliberately omitted. Figures are approximate and reflect internal measurement at the time.