Skip to content

amirul12/clinicpulse_ai

Repository files navigation

ClinicPulse AI

ClinicPulse AI Flow Source: gemeni

ClinicPulse AI is a smart clinic flow manager that coordinates patient intake, triage, and clinician briefing using a multi-agent architecture powered by Google's Agent Development Kit (ADK). The goal is to reduce bottlenecks in outpatient clinics by giving every care team member up-to-date context before a consultation begins.

Problem

Smaller clinics still rely on manual questioning, paper forms, and ad-hoc note taking. As a result:

  • Patients repeat the same information multiple times.
  • Staff lose precious minutes clarifying missing details.
  • Clinicians only see partial context when they enter the exam room.

Solution

ClinicPulse AI orchestrates a multi-stage pipeline:

  1. Intake Agent – Collects demographics, chief complaints, and symptom duration. Uses a loop validator to ensure all mandatory fields are captured before handing off.
  2. Triage Agent – Prioritizes queues using guideline lookups (Google Search tool) and custom EHR tools to pull vitals/lab history.
  3. Lab Wait Agent – When diagnostics are pending, this loop agent pauses the workflow until lab data is provided, demonstrating long-running operations and resume support.
  4. Clinician Briefing Agent – Generates a concise patient dossier with recommended next steps, outstanding orders, and suggested follow-up questions.

Session memory keeps a shared patient dossier so every agent reads/writes from the same state. Observability hooks emit structured logs (think: patient_id, step, result) using clinicpulse.logging_utils for compliance audits.

Planned Capstone Features

  • Multi-agent system: Sequential pipeline with loop agents for intake and triage validation.
  • Tools: Combination of built-in Google Search, custom EHR lookup tool (mocked), and a code execution tool for quick vital-score computations.
  • Sessions & Memory: InMemorySessionService plus a simple embedded “Patient Memory Bank” file to simulate persistence across pauses.
  • Observability: Logging/tracing for agent handoffs; metrics for average loop retries.
  • Long-running operations: Ability to pause when waiting for lab uploads and resume once data is available.
  • Agent evaluation: Automated script that grades briefing quality using a rubric (clarity, completeness, safety flags).
  • Deployment readiness: Instructions for running via adk web locally; optional Agent Engine/Cloud Run deployment notes for bonus points.

Architecture Snapshot

ClinicPulse AI Flow

                         ┌───────────────────────────────────────────┐
                         │           clinicpulse_ai (root)           │
                         │   Orchestrator / entry Agent              │
                         └───────────────────────────────────────────┘
                                           │
                                           │ user session
                                           ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                        intake_loop  (Loop Agent)                            │
│                                                                             │
│   ┌─────────────────────────────┐          ┌─────────────────────────────┐  │
│   │   intake_collector          │ ───────► │    intake_validator         │  │
│   │   - asks questions          │          │    - checks dossier fields  │  │
│   │   - updates patient dossier │ ◄─────── │    - returns missing items  │  │
│   └─────────────────────────────┘          └─────────────────────────────┘  │
│                                                                             │
│     loop until: demographics + chief complaint + onset + severity complete  │
└─────────────────────────────────────────────────────────────────────────────┘
                                           │
                                           │ dossier complete
                                           ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                         triage_loop  (Loop Agent)                           │
│                                                                             │
│   ┌─────────────────────────────┐                                           │
│   │     triage_coordinator      │                                           │
│   │   - reads dossier           │                                           │
│   │   - calls tools / validator │                                           │
│   └─────────────────────────────┘                                           │
│                     │                                ▲                      │
│                     │ calls                          │ feedback             │
│                     ▼                                │                      │
│           ┌───────────────────────────┐              │                      │
│           │     triage_validator      │              │                      │
│           │  - checks safety &        │──────────────┘                      │
│           │    completeness           │      loop until triage decision ok  │
│           └───────────────────────────┘                                     │
│                                                                             │
│   External tools used by triage_coordinator:                                │
│                                                                             │
│      ┌────────────────────┐       ┌────────────────────┐                    │
│      │ record_triage_     │       │   google_search    │                    │
│      │ decision           │       │ - guideline lookup │                    │
│      │ - log priority     │       └────────────────────┘                    │
│      └────────────────────┘                     ▲                           │
│                     ▲                          /                            │
│                     │ calls                   /                             │
│                     ▼                        /                              │
│      ┌────────────────────────┐             /                               │
│      │  fetch_patient_records │◄───────────                                │
│      │  - mocked EHR tool     │                                             │
│      └────────────────────────┘                                             │
└─────────────────────────────────────────────────────────────────────────────┘
                                           │
                                           │ triage complete
                                           ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│                         clinician_briefing (Agent)                          │
│                                                                             │
│   - reads full patient dossier                                              │
│   - synthesizes:                                                            │
│        • summary                                                            │
│        • problem list                                                       │
│        • suggested clinician questions                                      │
│        • suggested next steps / orders                                      │
│                                                                             │
│   Optional long-running wait:                                               │
│                                                                             │
│      ┌──────────────────────────────┐                                       │
│      │   wait_for_lab_results      │                                        │
│      │   - tool to simulate        │                                        │
│      │     pause/resume on labs    │                                        │
│      └──────────────────────────────┘                                       │
└─────────────────────────────────────────────────────────────────────────────┘

Shared state is managed through ADK session services. Tools expose the following interfaces:

  • fetch_patient_records(patient_id) – mocked EHR dataset.
  • record_triage_decision(patient_id, priority_level) – logs decision to state + external sink.
  • wait_for_lab_results(patient_id) – demonstrates long-running operations by pausing/resuming agents.

Repository Layout (initial draft)

clinicpulse_ai/
├── README.md
├── requirements.txt
├── clinicpulse/
│   ├── __init__.py
│   ├── agent.py
│   ├── config.py
│   ├── tools.py
│   ├── logging_utils.py
│   ├── agent_utils.py
│   ├── validation/
│   │   ├── __init__.py
│   │   └── checkers.py
│   └── sub_agents/
│       ├── __init__.py
│       ├── intake.py
│       ├── triage.py
│       ├── labs.py
│       └── briefing.py
├── eval/
│   ├── README.md
│   └── evaluate_briefing.py
├── tests/
│   ├── README.md
│   └── test_agent.py
└── diagrams/
    └── architecture.png (placeholder)

Upcoming tasks:

  • Populate requirements.txt with ADK + testing deps.
  • Implement config + tool stubs.
  • Build sub-agent logic and validation loops.
  • Add evaluation harness + documentation updates.

Getting Started

Requirements

  • Python 3.11+
  • Access to Google ADK-compatible credentials (Vertex AI or AI Studio API key)

Install dependencies:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Copy .env and populate the appropriate credentials:

cp .env .env.local  # optional

Set GOOGLE_GENAI_USE_VERTEXAI=True with ADC or switch to AI Studio using GOOGLE_API_KEY.

Running the Agent Locally

  1. Configure credentials as above.
  2. Launch ADK web runner from the project root:
adk web
  1. Interact with ClinicPulse AI through the UI or via the integration harness:
python -m tests.test_agent

Evaluation Harness

After generating a clinician briefing, point the rubric script at the Markdown file:

python -m eval.evaluate_briefing --file path/to/briefing.md

The script outputs a JSON summary with structure, completeness, safety scores, and a total. Use it to gate submissions before sharing with clinicians.

Observability & Pause/Resume

  • Logging – All tools and validation checkers log structured events through clinicpulse.logging_utils. Set CLINICPULSE_LOG_LEVEL=DEBUG (environment variable) to increase verbosity while debugging conversations.
  • Long-running labs – When diagnostics are outstanding, trigger the lab_wait_loop. It keeps the session alive but blocks progression until lab_results are written to state, effectively pausing the agent until the user supplies the necessary data. The wait_for_lab_results tool mirrors this behavior when called directly.

About

A multi-agent healthcare system that automates patient intake, triage, lab waiting, and clinician briefings using Google ADK.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages