[FEATURE] New project: Clinical Early-Warning Agent (Gemini tool-calling with NEWS2, qSOFA, personal baselines and trends)

Author: ishan-one8Created Sep 25, 2026Updated Sep 25, 2026

Feature Description

A new project, clinical_early_warning_agent: an agent that reads a patient's recent vital signs and explains whether they are deteriorating, and how urgently a clinician should review them.

Gemini does the reasoning and the writing, but every number comes from deterministic, tested tools it calls:

  • NEWS2 — the Royal College of Physicians early warning score, implemented exactly from the official chart (including SpO₂ scale 2 for COPD patients with a prescribed 88–92% target).
  • qSOFA — the bedside sepsis screen.
  • Personal baseline — what is normal for this patient (7-day median and MAD), so a runner's resting heart rate of 52 or a hypertensive patient's usual BP of 150 are judged against themselves.
  • Trend — a 3-hour least-squares slope with its standard error widened for autocorrelation, so a slow slide inside "normal" ranges is caught without noise faking trends.

The output is a short assessment for a clinician: the level (Stable / Watch / Warning / Critical), the contributing factors with their values, a plain-language explanation, and a suggested urgency. It never diagnoses.

Target Project

clinical_early_warning_agent

Project Directory

advance_ai_agents

Motivation

The collection has no clinical-monitoring example (the closest, voice_agents/healthcare_contact_center, handles bookings and FAQs). Early warning scores apply the same thresholds to everyone, so slow deterioration can hide inside "normal" ranges. This project shows a pattern that matters for any high-stakes agent: let the LLM reason and explain, but take every number from auditable tools, so scores can't be hallucinated and each one can be traced.

Proposed Solution

advance_ai_agents/clinical_early_warning_agent/
├── early_warning/        # scoring.py (NEWS2, qSOFA), baseline.py, trend.py, tools.py, agent.py, report.py
├── data/                 # synthetic sample patients: stable, slow hypoxia, early sepsis
├── tests/                # pytest for the clinical tools and the agent's offline path
├── app.py                # Streamlit UI: pick or upload a patient, run the agent, see the factors
├── main.py               # CLI
├── pyproject.toml, .env.example, README.md (following .github/README_TEMPLATE.md), assets/
  • Google Gemini via the google-genai SDK with automatic function calling; the tools are plain Python functions.
  • An --offline mode that runs the same tools and a template explanation without an API key, so the project can be tried and tested without credentials.
  • Ruff-clean, with a pytest suite that needs no API key.

User Impact

Developers get a compact, well-tested example of a tool-calling agent in a domain where correctness matters, and a reusable pattern for keeping LLM outputs grounded in deterministic calculations. Anyone curious about clinical early-warning scores gets a readable reference implementation.

Alternatives Considered

  • Letting the model compute NEWS2 itself — rejected: threshold and arithmetic mistakes, and nothing to audit.
  • A heavier framework (CrewAI, ADK) — plain google-genai function calling keeps the example short; the tools would port unchanged.

Screenshots/Mockups

A screenshot of the Streamlit UI will be added to assets/ with the PR.

Note: synthetic data only; an educational example, not a medical device.

Implementation Checklist

  • I have searched for similar feature requests
  • I have provided a detailed description of the feature
  • I have explained the motivation and user impact
  • I have considered alternative solutions

Source: Arindam200/awesome-ai-apps