Skip to Content
ToolsSymptom red flags

Symptom red flags

ctx.HEALTH_CALCULATOR.symptomRedFlags matches a described physical symptom to a fixed red-flag list. It returns one of three answers: self-care, see a GP within days, or urgent.

Input

FieldTypeWhat it means
symptomstringThe symptom, for example "chest pain".
memberWordsstringWhat the person said, in their words.
durationDaysnumberOptional. How long it has lasted.
severity"mild" | "moderate" | "severe"Optional. How bad it is.
whatChangesItstringOptional. What makes it better or worse.

Returns

{ symptom: "chest pain", redFlags: [ { id: "chest_pain_spreading", reason: "Chest pain spreading to the arm, jaw, neck or back can be a heart attack.", }, ], frame: "urgent", stillToAsk: ["what makes it better or worse"], guidance: "A red flag fired. Route to emergency care and say plainly why this one cannot wait.", source: "Ollie deterministic symptom red-flag list. Screening only; it cannot diagnose.", }

frame is "urgent" when a red flag fires. Otherwise it is "see_gp_within_days" when the symptom is severe or has lasted 14 days or more, and "self_care" when not. stillToAsk lists the optional details you left out.

Use it

import { workflow } from "@loops/sdk"; type Symptom = { symptom: string; patientWords: string; country?: string }; export const symptomCheck = workflow<Symptom>({ id: "symptom-check", execute: async ({ step, event }) => { const check = await step.do("Check for red flags", ({ ctx }) => ctx.HEALTH_CALCULATOR.symptomRedFlags({ symptom: event.body.symptom, memberWords: event.body.patientWords, }), ); if (check.frame !== "urgent") return check; const routing = await step.do("Look up emergency numbers", ({ ctx }) => ctx.HEALTH_CALCULATOR.emergencyRouting({ country: event.body.country, concern: "medical_emergency", }), ); return { ...check, routing }; }, });

Call it before emergency care routing for physical symptoms, and escalate only when a flag fired.

What it won’t invent

It matches patterns in the words it is given. It cannot diagnose, and a symptom it has no rule for comes back as self-care or see a GP, never urgent.

Last updated on