Skip to content

Dhanraj200547/MedVisionAI-Predicting-Hospital-Readmissions

Repository files navigation

MedVisionAI — Predicting Hospital Readmissions

Overview

MedVisionAI is a full-stack machine learning application that predicts whether a patient is likely to be readmitted to the hospital. It is built for healthcare professionals to make informed decisions and improve patient care.

This project was built as a hackathon submission for the Cognizant team, combining AI, full-stack web, and cloud deployment into one seamless solution.


Tech Stack

Frontend: React + Vite + Tailwind CSS Backend: Flask (Python) ML Model: Random Forest (trained & saved as rf_model2.pkl) Database: Firebase (Firestore) Deployment: Docker + GitHub Actions CI/CD + Google Cloud Run


System Architecture

  • Doctor interacts with the React frontend.
  • Frontend sends patient data to the Flask backend API.
  • Flask backend loads and runs the ML model prediction.
  • Predictions and patient data are stored in Firebase Firestore.
  • Entire application is containerized using Docker.
  • GitHub Actions CI/CD pipeline automatically builds and deploys the app to Google Cloud Run on every push to main.

Workflow

  1. Doctor logs in to the application.
  2. Doctor enters patient medical data through the web UI.
  3. Frontend sends this data to the Flask backend.
  4. The backend uses the Random Forest model to predict readmission.
  5. Prediction results are sent back to the frontend and displayed to the user.
  6. All patient data and prediction results are stored in Firestore for future reference.
  7. Doctors can view a list of all previous predictions.

Project Structure

COGNIZANT-PROJECT/
├── dist/                     # Built frontend output (production-ready)
├── node_modules/              # Installed frontend dependencies
├── public/                    # Static assets and root index.html
├── src/                       # React (Vite) application source code

├── .env                        # Environment variables (Firebase keys, API endpoints)
├── .gitignore                  # Files/folders ignored by Git
├── app.py                      # Flask backend main application
├── bun.lockb                   # Bun package manager lockfile (if used)
├── components.json             # UI component configuration (for shadcn/ui etc.)
├── Dockerfile                  # Docker build instructions (for full-stack deployment)
├── dummy_patients.py           # Script to generate or seed dummy patient data
├── eslint.config.js            # Linting rules for the frontend
├── index.html                   # Entry HTML (used by Vite)
├── package-lock.json            # NPM lockfile for dependency versions
├── package.json                  # Frontend dependencies and scripts
├── postcss.config.js              # PostCSS configuration for Tailwind
├── README.md                         # Project documentation file
├── requirements.txt                      # Python dependencies for backend
├── rf_model2.pkl                               # Trained machine learning model (serialized)
├── serviceAccountKey.json                          # Firebase service credentials
├── tailwind.config.ts                                    # Tailwind CSS configuration
├── train_columns.npy                                         # Numpy file for model input feature columns
├── tsconfig.app.json                                               # TypeScript config for app
├── tsconfig.json                                                         # Root TypeScript config
├── tsconfig.node.json                                                           # Node environment TS config
└── vite.config.ts                                                                           # Vite build configuration

Features

  • Doctor login system (session-based authentication)
  • Input form for patient medical data
  • Predicts readmission probability using trained Random Forest model
  • Logs prediction data to Firestore
  • Displays prediction history
  • Deployed using Docker + Google Cloud Run
  • Automated deployments using GitHub Actions CI/CD

Getting Started

1. Clone the Repository

git clone https://github.com/<your-username>/COGNIZANT-PROJECT.git
cd COGNIZANT-PROJECT

2. Set up Frontend

npm install
npm run build

3. Set up Backend

pip install -r requirements.txt

4. Add Environment Variables

Create a .env file:

VITE_FIREBASE_API_KEY=...
VITE_FIREBASE_AUTH_DOMAIN=...
VITE_FIREBASE_PROJECT_ID=...

And add your serviceAccountKey.json in the root folder.

5. Run with Docker (recommended)

docker build -t medvisionai .
docker run -p 8080:8080 medvisionai

The app will be available at: http://localhost:8080


GitHub Actions CI/CD

  • Every push to the main branch triggers the CI/CD pipeline.

  • GitHub Actions:

    • Builds the Docker image
    • Pushes to Google Artifact Registry
    • Deploys to Google Cloud Run

This ensures zero-downtime deployments and production-ready releases.


Results

  • Achieved around 80% accuracy on the test dataset.
  • Predictions are fast (under 1 second) and reliable.
  • Successfully deployed the full-stack container to GCP.

Future Enhancements

  • Add patient dashboards and analytics
  • Role-based authentication (Doctors/Admins)
  • Integration with hospital EHR systems
  • Improve the model with more real-world training data

About

Developed a full-stack machine learning application to predict patient hospital readmissions, featuring a React frontend and a Flask backend serving a Ensemble Learning model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors