Skip to content

ethan-ngo/calhacks2025

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

69 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฅ TriageFlow

AI-powered triage system that empowers nurses with instant, expert-level assistance on ESI assessments using Fetch.AI to manage Claude and ChromaDB, ensuring critical patients never wait while reducing burnout.

๐ŸŒ Live App | ๐Ÿ“‹ Devpost Submission


โœจ Inspiration

One of our teammates went to the ER with a broken arm and waited almost 6 hours. In busy emergency rooms like his, even the smallest inefficiencies can add up. We were inspired by the idea that digital tools and automation can support nursing staff, not replace them, by monitoring evolving conditions, surfacing early warnings, and giving transparent, actionable recommendations.


๐ŸŽฏ What It Does

  • ๐ŸŽฏ Triage Score Determination: Calculates ESI (Emergency Severity Index) priority levels based on current symptoms, history, images of injuries, and patient comments following established medical guidelines.
  • ๐Ÿ“‹ Patient Records Retrieval (HL7 FHIR): Retrieves prior visits, known conditions, and reason for visit so nurses and the system have full context.
  • ๐ŸŽค Voice & Text Patient Intake: Patients can speak or type their current symptoms and comments. The system uses AI to extract structured data and prompts for clarifying details.
  • ๐Ÿ‘ฉโ€โš•๏ธ Nurse Dashboard: Presents a real-time queue, allows manual add/remove of patients, queue re-ordering, and re-running of triage logic.
  • ๐Ÿšจ Smart Alert System: If a patient's condition changes during chatbot conversations (ESI increases/decreases), the system triggers an alert to the nurse with the new recommendation and rationale.
  • ๐Ÿ“ฑ Patient View: Unique links for each patient sent via SMS, allowing patients to update their symptoms in real-time through a chatbot interface.

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React - UI framework
  • Vite - Build tool
  • React Router - Navigation
  • Browser Web Speech API - Voice recognition
  • Vercel - Hosting

Backend

  • Python - Core language
  • Flask - Web framework
  • Gunicorn - Production server
  • Render - Backend hosting

AI & Agents

  • Claude 3 Haiku (Anthropic) - Triage assessment and structured data extraction
  • Fetch.AI UAgents - Smart agent orchestration for data flow
  • ChromaDB - Vector database for semantic search of patient medical records (HL7 FHIR)

Integrations

  • Twilio - SMS communication for patient links and updates

๐Ÿ“ Project Structure

calhacks2025/
โ”œโ”€โ”€ nurse-ui/              # Frontend React application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/        # Page components (Queue, Nurse Form, Patient Chat, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ components/   # Reusable UI components
โ”‚   โ”‚   โ””โ”€โ”€ utils/        # Utility functions (queue management)
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ backend/               # Flask backend API
โ”‚   โ”œโ”€โ”€ app.py            # Main Flask application
โ”‚   โ”œโ”€โ”€ agents/           # AI agent implementations
โ”‚   โ”‚   โ”œโ”€โ”€ triage.py     # ESI triage logic and prompts
โ”‚   โ”‚   โ”œโ”€โ”€ nurse_agent.py
โ”‚   โ”‚   โ””โ”€โ”€ patient_agent.py
โ”‚   โ””โ”€โ”€ requirements.txt
โ”‚
โ”œโ”€โ”€ Chromadb_rag/         # ChromaDB integration for patient records
โ”‚
โ””โ”€โ”€ README.md

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • Python (v3.11 or higher)
  • Anthropic API Key - Get one at console.anthropic.com
  • Twilio Account (for SMS features) - Sign up at twilio.com
  • ChromaDB (local or cloud instance)

Frontend Setup

# Navigate to frontend directory
cd nurse-ui

# Install dependencies
npm install

# Start development server
npm run dev

The frontend will be available at http://localhost:5173

Backend Setup

# Navigate to backend directory
cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
cat > .env << EOF
ANTHROPIC_API_KEY=your_anthropic_api_key_here
TWILIO_ACCOUNT_SID=your_twilio_sid_here
TWILIO_AUTH_TOKEN=your_twilio_token_here
TWILIO_PHONE_NUMBER=your_twilio_number_here
CHROMADB_URL=your_chromadb_url_here
EOF

# Run the Flask server
python app.py

The backend will be available at http://localhost:5000

Configuration

Update the API base URL in nurse-ui/src/config.js if running locally:

export const API_BASE_URL = 'http://localhost:5000'  // Local
// or
export const API_BASE_URL = 'https://calhacks2025-ncoi.onrender.com'  // Production

๐ŸŽฎ Usage

For Nurses

  1. Navigate to Queue Page: View all patients and their current ESI scores
  2. Add Patient: Click "Add Patient" to register a new patient
  3. Fill Triage Form: Enter vitals, symptoms, pain level, and comments
    • Voice Input: Click the microphone icon to speak patient information - AI will automatically fill the form
  4. View Dashboard: See triage assessment results with ESI score and rationale
  5. Respond to Alerts: When patient conditions change, review and accept/reject ESI updates

For Patients

  1. Receive SMS link with unique patient ID
  2. Click link to access patient waiting page
  3. Chat with AI assistant to update symptoms
  4. View estimated wait time and queue position
  5. Receive notifications if triage level changes

๐Ÿ” Key Features Explained

ESI Triage Scale

The Emergency Severity Index (ESI) is a 5-level triage algorithm:

  • ESI 1: Resuscitation - Immediate life-saving intervention needed
  • ESI 2: Emergency - High risk situation, should be seen immediately
  • ESI 3: Urgent - Multiple resources needed, complex workup
  • ESI 4: Less Urgent - One resource needed, simple workup
  • ESI 5: Non-Urgent - No resources needed, simple treatment

Real-time Alert System

The system continuously monitors patient chatbot conversations. When symptoms change significantly (e.g., pain increases from 3/10 to 9/10), the AI re-evaluates the ESI score and sends an alert to the nurse with:

  • Current ESI vs. Suggested ESI
  • Brief summary of the change
  • Option to accept or reject the update

๐Ÿ† Accomplishments

  • โœ… Fully custom priority queue system that supports real-time triage reordering
  • โœ… Consistent AI-generated feedback using advanced prompt engineering and model tuning
  • โœ… Successful integration of all components (backend, agent, triage logic, frontend) into a cohesive working prototype
  • โœ… Voice-to-form automation using Claude for structured data extraction
  • โœ… Real-time alert system for dynamic triage updates

๐Ÿง  Challenges We Faced

  • LiveKit Integration Issues: Managing rooms, sessions, and audio streaming was complex. We pivoted to Browser Web Speech API for more reliable voice input.
  • Custom Priority Queue: Ensuring triage scoring and patient order dynamically updated in real-time required careful state management.
  • Prompt Engineering: Tuning prompts so the AI agent produced stable, actionable outputs each time required extensive iteration.
  • Working with AI Agents: Learning how to manage message flow, context retention, and error recovery in multi-agent systems.

๐Ÿšง Future Improvements

  • Deploy backend and agent services on secure, scalable cloud infrastructure
  • Integrate live hospital databases to access authentic patient records
  • Fine-tune waiting time predictions using queue length and patient flow analytics
  • Refine chatbot prompts for more empathetic, context-aware responses
  • Expand multilingual and accessibility support
  • Add monitoring dashboards for hospital administrators
  • Implement WebSocket connections for real-time updates (eliminate polling)

๐Ÿ‘ฅ Team

Created for Cal Hacks 12.0

  • Maor Barzilay
  • Hritika Arjunwadkar
  • Samuel Araya
  • Ethan Ngo

๐Ÿ“ License

This project was created for Cal Hacks 12.0 hackathon. All rights reserved.


๐Ÿ”— Links


Built with โค๏ธ at Cal Hacks 12.0

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors