Skip to content

rishabhpatel9/Healthcare-Triage-Assistant

Repository files navigation

Healthcare Triage Assistant

Python FastAPI Streamlit GenAI Docker License: MIT

End-to-end ML deployment project predicting patient triage levels using FastAPI, Streamlit, and Docker followed by a short GenAI explanation of the predictions.

Try the demo!: Healthcare Triage Assistant Frontend


Overview

The Healthcare Triage Assistant is a ML project designed to support emergency departments by predicting patient triage levels based on vital signs, symptoms, and arrival mode. It provides a user friendly interface for healthcare staff to quickly assess patient urgency and prioritize care effectively. Also includes a GenAI explanation feature to help non-clinical staff understand the model's predictions in an intuitive way.

The project demonstrates the full ML lifecycle:

  • Data wrangling & feature engineering
  • Model training & evaluation
  • FastAPI backend for serving predictions
  • Streamlit frontend with intuitive hospital friendly UI
  • Dockerized deployment for portability
  • GenAI integration for explainability

Dataset

This project uses the Synthetic Medical Triage Priority Dataset from Kaggle for model development and evaluation.


Project Features

  • Predicts triage levels (Routine, Urgent, Emergency, Self-care/Non-urgent)
  • FastAPI backend with RESTful API endpoints
  • Streamlit frontend with segmented controls and color coded outputs
  • Dockerized setup with docker-compose for easy deployment
  • Interactive API documentation (/docs) for API exploration
  • GenAI integration for explainability

Project Structure

Healthcare-Triage-Assistant/
├── app/
│   └── streamlit_app.py                    # Streamlit frontend
├── data/
│   └── raw/
│       └──synthetic_medical_triage.csv     # Raw dataset
├── notebooks/
│   └── cleandata.ipynb                    # Data cleaning & Model training
├── src/
│   ├── api.py                              # FastAPI backend
│   └── model.pkl                           # Trained ML model
├── .dockerignore
├── docker-compose.yml                      # Docker Compose configuration
├── Dockerfile.backend                      # Docker definition for backend
├── Dockerfile.frontend                     # Docker definition for frontend
├── example.env
├── LICENSE
├── README.md
├── requirements-backend.txt                # For docker backend
├── requirements-frontend.txt               # For docker frontend
└── requirements.txt                        # For local deployment

Installation

Clone the repo:

git clone https://github.com/rishabhpatel9/Healthcare-Triage-Assistant.git
cd Healthcare-Triage-Assistant

Environment Variables

Before running the application, you need to configure your environment variables:

  1. Copy example.env to .env:
cp example.env .env
  1. Open .env and fill in the required variables (specifically OPENROUTER_API_KEY for the GenAI explanations).

Install dependencies:

pip install -r requirements.txt

Run FastAPI backend:

uvicorn src.api:app --reload

Run Streamlit frontend:

streamlit run app/streamlit_app.py

Deployment with Docker

Build and run with docker-compose:

docker-compose up --build

Use Streamlit app frontend → http://localhost:8501


API Documentation

Once backend is running, visit:

  • API Documentation → http://localhost:8000/docs
  • Redoc → http://localhost:8000/redoc

Model Training Features

The triage classifier was trained on patient intake data with the following features:

  • Age → Patient’s age in years
  • Heart Rate → Beats per minute
  • Systolic Blood Pressure → mmHg
  • Oxygen Saturation (SpO₂) → Percentage
  • Body Temperature → Patient's body temperature (°C)
  • Chronic Disease Count → Number of chronic conditions
  • Previous ER Visits → Number of prior emergency room visits
  • Pain Level → Self-reported scale (0–10)
  • Arrival Mode → Walk-in, Ambulance, Referral

Target Variable - Triage Level

Ouput shown as:

  • 🟢 Routine
  • 🟡 Urgent
  • 🔴 Emergency
  • 🔵 Self-care / Non-urgent

along with a short GenAI explanation of the prediction.


Future Work

  • Improve model accuracy with larger datasets
  • Integrate hospital database for real patient records
  • Add authentication & role-based access control

Contributing

Contributions are welcome!

  • Fork the repo
  • Create a feature branch
  • Submit a pull request