Patient message triage: proving that urgent symptoms were escalated in time
An agent reads incoming patient portal messages, answers administrative ones and routes clinical ones to the right care team, escalating red-flag symptoms at once. ZizkaDB records every safety check and escalation with its timing, so a missed or late escalation can be found, explained and turned into a test.
The situation
A primary care network receives thousands of patient portal messages a week: appointment changes, prescription requests, test result questions, and sometimes symptoms that need same-day attention. An AI agent now reads each message, answers purely administrative ones from approved templates, and routes clinical ones to the right nurse or doctor queue. Messages that mention red-flag symptoms (for example chest pain, signs of stroke, suicidal thoughts) must be escalated immediately and the patient told to call emergency services.
The clinical safety officer must be able to show that the red-flag screen runs on every message, and to investigate any case where an urgent message waited in a routine queue.
What goes wrong without a record
- A patient writes "my chest feels tight since this morning" in a message about a repeat prescription. It lands in the routine prescription queue and is read the next day. The investigation cannot tell whether the red-flag screen ran, what it returned, or why the message was routed as it was.
- Template answers change, and nobody can say which patients received the old wording.
- The routing model is updated and starts sending more clinical questions to the administrative queue.
How ZizkaDB is used
Each message is a session, recorded as a causal chain:
user_message: message received (message id and channel; the hospital decides whether the text is stored).red_flag_screen: the safety check, with the rule set version, which red flags were tested, and the result. It runs before anything else, and every later step is linked to it.llm_end: the classification by the model (category, urgency, confidence), recorded automatically.routing: the queue chosen and the reason; for urgent messages,escalationwith the time it was raised and the team notified.assistant_response: the reply sent to the patient (template id and version).clinician_ack: when a clinician picked the message up, so the time from arrival to action is part of the record.
The Event timeline in the ZizkaDB dashboard shows every message against time, one row per event type with errors in red, so a safety officer can see at a glance when escalations happened and how long each waited for a clinician.
Example
async with db.track(agent="portal-triage", session_id=message.id):
msg = await db.log(agent="portal-triage", event="user_message",
data={"message_id": message.id, "channel": "portal"})
screen = await db.log(agent="portal-triage", event="red_flag_screen",
data={"rules": "red-flags-v7", "matched": ["chest_pain"]},
parent_id=msg.event_id)
await db.log(agent="portal-triage", event="escalation",
data={"queue": "same-day-clinical", "notified": "duty-doctor"},
parent_id=screen.event_id)When a case is found where the agent got it wrong, the session becomes a regression test that every new version of the agent must pass:
zizkadb test from-session <session_id> --agent portal-triage --entry triage.agent:handleQuestions the practice can now answer
- Did the red-flag screen run on this message, with which rule set, and what did it return? (
whyon the routing event) - How long did each escalated message wait before a clinician acknowledged it?
- Which patients received template version 3 of the prescription reply before it was corrected?
- Did routing behaviour change after the last model update? (
baselinedrift score) - Can we show the safety record is complete and untouched? (
verify_chain)
Regulation and standards this supports
- Clinical safety standards for health IT (for example DCB0129 and DCB0160 in the NHS): hazard logs and evidence for incident investigation.
- EU Medical Device Regulation, where triage software qualifies as a medical device, and the EU AI Act obligations that follow for high-risk systems.
- HIPAA audit controls and GDPR record keeping for systems handling health data.
What to measure
- Share of messages with a recorded red-flag screen (target: every message).
- Time from arrival to clinician acknowledgement for escalated messages.
- Misrouted messages found per month, and regression tests created from them.
- Drift in routing categories after each model or rule set change.