1. Critical-value escalation that doesn't stop until a clinician acknowledges
02:40, one tech on the night bench. The analyser posts a potassium of 7.1. She notices it because she is scrolling the LIMS worklist between runs — there is no alarm. She opens the hard-bound 'Critical Value Callback Register' kept next to the centrifuge, rules the columns by hand, then looks up the ordering doctor in a printed on-call list taped to the wall (last revised in March). She dials from the landline. It rings out. She writes 'NR' in the register and goes back to her run, meaning to try again. At 06:00 handover the day tech sees 'NR' in yesterday's ink and nobody is sure whether anyone ever called. That register — plus a WhatsApp group where the night staff sometimes post a photo of the result — is the entire escalation system.
Trigger: Webhook (LIMS result verified / analyser middleware autoverify)
How the workflow runs
- Trigger
Result verifies in the LIMS. A Webhook fires on every verified result — no worklist scrolling, no dependence on someone looking up. The LIMS/analyser middleware has no first-party connector: results arrive via inbound Webhook, and anything written back goes through a Tool (MCP) node.
- Knowledge
Load YOUR critical-value table. A scoped Knowledge collection holds this lab's own critical/panic limits, delta-check rules and per-analyte callback SOP — age- and sex-banded exactly as your medical director signed them. General medical knowledge is out of bounds; only the signed table is consulted.
- Tool (MCP)
Deterministic threshold check (user-defined SpEL tool). A tenant-authored tool `critical_flag` (a sandboxed SpEL expression over the tool's JSON input, e.g. input.value > input.upperLimit ? 'CRITICAL' : (input.value < input.lowerLimit ? 'LOW' : 'NORMAL')) does the actual numeric comparison. A threshold belongs in a deterministic formula the lab can edit itself, not in a prompt — and your medical director can revise it without a developer or a redeploy.
- Agent
Assemble the callable fact (no interpretation). An Agent node takes the deterministic flag and returns strict JSON {critical, analyte, value, limit_breached, ordering_clinician, patient_ref}. It resolves who ordered it and formats the callable fact — it does NOT interpret, diagnose or suggest treatment, and it never overrules the SpEL flag.
- Condition
Critical, routine, or unresolvable?. A Condition node branches: routine results fall to the normal report flow; a flagged critical enters the callback ladder; an unmapped analyte or unresolvable clinician goes to a human instead of being dropped.
- Approval
Duty pathologist owns the call. An Approval node holds the escalation for the on-duty pathologist or lab director — the judgement that this value is real and callable is a clinician's, and the trail records who made it. A hard timeout escalates UP the human ladder; it is never a bypass that lets the agent call alone.
- Voice
Escalation ladder with real retries. On approval a Voice/Call node (ElevenLabs, Sarvam-localised for Indian-language recipients) calls the ordering clinician with analyte, value, reference limit and a callback reference, backed by SMS and WhatsApp. It reads out facts and asks for a read-back; it never offers advice.
- Loop
Keep going until acknowledged. A Loop node re-runs the documented ladder — ordering clinician, covering doctor, ward/nursing station — at the SOP's own intervals until an explicit acknowledgement is captured or the ladder is exhausted. This is the 'NR in the register' failure, closed.
- Output
Write the read-back back. A Tool (MCP) node writes the callback record — who was reached, when, and the read-back confirmation — into the LIMS against the result id. An exhausted ladder raises a supervisor alert rather than closing itself.
Channels & connectors
- Webhook
- Knowledge base
- Voice / Call
- ElevenLabs
- Sarvam
- SMS / Twilio
- Approval / HITL
- Tool (MCP → LIMS / HIS)
Outcome
Every verified result is checked against your own signed table the moment it posts, and flagged ones ride a persistent, documented callback ladder — replacing the hand-ruled register, the taped-up on-call list and 'NR'.
Why it helps
The mechanism is persistence plus proof. Critical-value reporting rarely fails at detection; it fails at the unfinished chase and the missing read-back record. A Loop that keeps escalating on the SOP's own intervals removes the first, and a Tool node that writes who acknowledged and when removes the second — while the decision to call stays with the pathologist and the threshold itself stays in a formula the lab controls.
Build spec
2 agents — 1 fact-assembly agent (runs on every verified result — the high-volume step) + 1 escalation-scripting agent (runs only on the flagged minority). The numeric threshold check is a deterministic user-defined SpEL tool, not an agent; the ladder, the branch and the approval are workflow nodes. · Pattern: Deterministic SpEL threshold → cheap per-result agent → Condition → pathologist approval → Voice/SMS ladder in a retry Loop
System prompt (paste-ready)
You prepare ONE verified laboratory result for critical-value callback. The CRITICAL/LOW/NORMAL flag has already been computed deterministically by the `critical_flag` tool against this lab's signed table — take it as given and NEVER overrule it. Return strict JSON {critical, analyte, value, units, limit_breached, age_band, patient_ref, ordering_clinician, callback_ref}. You must NOT interpret the result, suggest a diagnosis, suggest treatment, or comment on the patient's condition. If units are ambiguous, the analyte is unmapped, or the ordering clinician cannot be resolved from the HIS, set needs_human=true with a reason — never guess a clinician and never assume a unit.Agent roles & model tiers
Fact assembler (per verified result) — Economy tier, with a configured fallback model for provider outages — runs on EVERY result, so this choice sets the whole bill; a lab cannot have callbacks stop because one provider is down
Take the deterministic SpEL flag as authoritative, resolve the ordering clinician from the HIS, emit strict JSON. No interpretation, no diagnosis, no treatment comment. Unmapped analyte or unresolvable clinician ⇒ needs_human=true.
Escalation scripter (per flagged value) — Standard tier with fallback — runs only on the flagged minority, where wording accuracy on a phone call matters
Compose the callback script and SMS/WhatsApp backup for an APPROVED critical value: analyte, value, units, reference limit, patient identifier, callback reference, and the explicit read-back question. Facts only — no advice, no interpretation, no reassurance. Localise via Sarvam when the recipient's registered language is not English.
MCP connectors
- LIMS — via Tool (MCP): read the verified result payload and write the callback record (who was reached, when, read-back confirmation) against the result id
- HIS / EMR — via Tool (MCP): resolve ordering clinician, department and current on-call cover for the patient encounter
- Hospital on-call roster — via Tool (MCP): fetch tonight's covering doctor when the orderer is off-shift, replacing the printed list taped to the wall
Built-in tools
- user-defined tool `critical_flag` (SpEL): input.value > input.upperLimit ? 'CRITICAL' : (input.value < input.lowerLimit ? 'LOW' : 'NORMAL') — the lab's own limits, edited by the medical director in the tool editor, no developer and no redeploy
- user-defined tool `callback_ref` (SpEL): input.sampleId + '-' + input.analyte + '-' + input.verifiedAt — a stable, idempotent callback key so a re-posted result can never open a second ladder
- knowledge_search (signed critical-value limits, delta checks and callback SOP)
- http_request (resolve ordering clinician and on-call cover; write the callback record to the LIMS)
Guardrails
- The agent never diagnoses, never interprets a value, never suggests treatment — it reports only which documented limit was crossed
- The threshold decision is deterministic (the `critical_flag` SpEL tool over your signed table), so it cannot drift with a model change or a prompt edit; the agent is explicitly forbidden from overruling it
- The escalation is released by the on-duty pathologist at the Approval node — the agent proposes the call, a clinician owns it
- The approval timeout escalates UP the human ladder; there is no path in which the workflow calls a clinician without a human having released it
- Unmapped analyte, ambiguous units or unresolvable clinician ⇒ needs_human=true and routed to a person — no silent drop, no guessed recipient
- An exhausted ladder alerts a supervisor; the workflow can never close a critical value as 'done' by itself
- Every attempt and the read-back are written back keyed to `callback_ref` — auditable, and idempotent against a re-verified result
Cost strategy
Volume sits entirely on the fact assembler, which touches every verified result — economy tier, hard-capped, with a fallback model configured so a provider outage degrades to a second provider rather than to the paper register. The standard-tier scripter runs only on the flagged subset, so its price barely registers monthly. Note that moving the threshold comparison out of the model and into the SpEL tool also removes tokens from the highest-volume step: the cheapest inference is the one you don't make. Retries in the Loop replay the composed script, so they cost telephony minutes, not tokens.
Output & delivery
Every verified result hits the `critical_flag` SpEL tool for a deterministic verdict → a cheap agent resolves the clinician and assembles the callable fact → the Condition node splits routine from critical from unresolvable → the duty pathologist approves at the Approval node → an ElevenLabs Voice call plus SMS/WhatsApp backup runs the documented ladder inside a retry Loop until an explicit read-back is captured → a Tool (MCP) node writes the callback record into the LIMS, and an exhausted ladder alerts a supervisor instead of closing.