Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏥 AI-Powered Hospital Management System (HQMS)

An intelligent, role-based hospital management platform that combines AI-powered patient triage, real-time queue management, EHR, appointments, billing, pharmacy, and automated resource allocation into a unified healthcare workflow system.


🚀 Overview

HQMS (Hospital Queue & Management System) is a full-stack hospital workflow platform designed to digitize and streamline day-to-day clinical and administrative operations.

The system connects patients, doctors, receptionists, pharmacists, and administrators through role-specific dashboards while using AI-assisted triage and real-time communication to improve patient prioritization and hospital workflow efficiency.


✨ Key Features

🤖 AI-Powered Patient Triage

  • AI-based symptom and severity analysis.
  • Flask-based machine learning service.
  • scikit-learn model for severity prediction.
  • Automatic fallback severity logic if the ML service is unavailable.
  • Helps prioritize emergency and high-severity patients.

🎫 Real-Time Queue Management

  • Token-based patient registration.
  • Live queue updates using Socket.IO.
  • Emergency/priority queue handling.
  • Queue statistics and monitoring.
  • Next-patient dispatch.
  • Patient completion tracking.

👨‍⚕️ Doctor & Room Assignment

  • Automatic doctor assignment during patient registration.
  • Automatic room allocation based on availability.
  • Doctor weekly shift configuration.
  • Reduces manual coordination and waiting time.

🩺 Electronic Health Records (EHR)

  • Complete patient visit timeline.
  • Medical history tracking.
  • Visit records and clinical information.
  • Manual/automatic audit provenance.
  • EHR filtering.
  • PDF report export.

💊 Pharmacy & Medicine Management

  • Medicine inventory management.
  • Stock tracking.
  • Automatic inventory reduction during billing.
  • Symptom-based medicine recommendations.
  • Pharmacist dashboard.
  • Previous billing information.

💳 Billing Management

  • Draft billing workflow.
  • Bill finalization.
  • Automatic bill number generation.
  • Unique bill number enforcement.
  • Inventory stock reduction after billing.
  • Billing history.

📅 Appointment Scheduling

  • Doctor availability management.
  • Weekly doctor shift configuration.
  • Automatic appointment slot generation.
  • Conflict detection.
  • Appointment status management.

🏢 Hospital Facilities

  • Facility management.
  • Facility availability tracking.
  • Symptom-based facility recommendations.
  • Integration with patient workflow.

🔐 Authentication & Authorization

  • JWT authentication.
  • Access and refresh token system.
  • HTTP-only cookies.
  • Role-based authorization.
  • Protected API routes.
  • Role-aware frontend navigation.

👥 User Roles

Role Responsibilities
👨‍💼 Admin Manage users, doctors, medicines, facilities and hospital operations
👨‍⚕️ Doctor Manage patients, consultations, EHR and appointments
🧑‍💼 Receptionist Register patients, generate tokens, manage queues and appointments
💊 Pharmacist Manage medicines, inventory and billing information

🧠 AI Triage Workflow

Patient Symptoms
       │
       ▼
Patient Registration
       │
       ▼
Node.js / Express Backend
       │
       ▼
Flask ML Service
       │
       ▼
Scikit-learn Model
       │
       ▼
Severity Prediction
       │
       ├── Emergency
       ├── High
       ├── Medium
       └── Low
       │
       ▼
Queue Prioritization
       │
       ▼
Doctor Assignment

If the ML service is unavailable, HQMS uses a fallback severity classification mechanism to maintain system availability.


🏗️ System Architecture

                    ┌──────────────────────┐
                    │   React + Vite UI    │
                    │  Tailwind Dashboard  │
                    └──────────┬───────────┘
                               │
                       REST API / Socket.IO
                               │
                               ▼
                    ┌──────────────────────┐
                    │   Node.js + Express  │
                    │      Backend API      │
                    └──────┬─────────┬─────┘
                           │         │
                ┌──────────┘         └──────────┐
                ▼                               ▼
        ┌──────────────┐                ┌──────────────┐
        │    MongoDB   │                │  Flask ML    │
        │   Database   │                │   Service    │
        └──────────────┘                └──────┬───────┘
                                               │
                                               ▼
                                        Scikit-learn
                                            Model

🛠️ Tech Stack

Frontend

  • React
  • Vite
  • Tailwind CSS
  • Axios
  • Recharts
  • jsPDF
  • Socket.IO Client

Backend

  • Node.js
  • Express.js
  • Mongoose
  • Socket.IO
  • JWT

AI / Machine Learning

  • Python
  • Flask
  • scikit-learn
  • Joblib

Database

  • MongoDB

📂 Project Structure

HQMS/
│
├── frontend/
│   ├── src/
│   ├── public/
│   ├── package.json
│   └── ...
│
├── backend/
│   ├── controllers/
│   ├── models/
│   ├── routes/
│   ├── middleware/
│   ├── services/
│   ├── Symptoms.txt
│   ├── package.json
│   └── ...
│
├── ml_service/
│   ├── app.py
│   ├── model/
│   ├── requirements.txt
│   └── ...
│
└── README.md

⚙️ Installation & Setup

Prerequisites

Make sure you have installed:

  • Node.js
  • npm
  • Python 3.x
  • MongoDB
  • Git

1. Clone Repository

git clone <YOUR_GITHUB_REPOSITORY_URL>
cd HQMS

2. Backend Setup

cd backend
npm install

Create:

backend/.env

Add:

MONGO_URI=mongodb://localhost:27017/hqms
PORT=5000
ML_SERVICE_URL=http://localhost:5001
CLIENT_ORIGIN=http://localhost:5173

JWT_SECRET=change_this_dev_jwt_secret_64chars_minimum_recommended_1234567890
JWT_REFRESH_SECRET=change_this_dev_refresh_secret_64chars_minimum_recommended_0987654321

Start backend:

npm run dev

3. AI/ML Service Setup

Open a new terminal:

cd ml_service
pip install -r requirements.txt
python app.py

ML service:

http://localhost:5001

4. Frontend Setup

Open another terminal:

cd frontend
npm install
npm run dev

Frontend:

http://localhost:5173

🔑 Default Development Accounts

Role Username Password
Admin admin password123
Doctor doctor password123
Receptionist receptionist password123
Pharmacist pharmacist password123

⚠️ These credentials are for local development only. Change them before production deployment.


🔌 API Endpoints

Authentication

POST /api/auth/login
POST /api/auth/refresh
POST /api/auth/logout
POST /api/auth/register

Patients & EHR

GET /api/patients
GET /api/patients/:id
GET /api/patients/:id/visits
GET /api/patients/token/:token

Queue

GET /api/queue
GET /api/queue/stats
GET /api/queue/next
GET /api/queue/complete/:id

Doctors & Shifts

GET /api/doctors
GET /api/doctors/:id/shifts

Billing

POST /api/bills/draft
POST /api/bills/finalize/:id
GET /api/bills/number/:billNumber
GET /api/bills

Appointments

GET /api/appointments
GET /api/appointments/slots
GET /api/appointments/:id/status

Recommendations

GET /api/recommendations/symptoms

Facilities, Medicines & Analytics

GET /api/facilities
GET /api/medicines
GET /api/stats/analytics

Most endpoints are protected using role-based authorization.


🔄 Core Hospital Workflow

Patient Registration
        │
        ▼
AI Triage & Severity Analysis
        │
        ▼
Automatic Doctor / Room Assignment
        │
        ▼
Token Generation
        │
        ▼
Real-Time Queue
        │
        ▼
Doctor Consultation
        │
        ▼
EHR Visit Record
        │
        ├───────────────┐
        ▼               ▼
   Prescription      Facility
        │
        ▼
Pharmacy / Billing
        │
        ▼
Inventory Update
        │
        ▼
Final Bill & Patient History

⚡ Real-Time Queue Architecture

HQMS uses Socket.IO to synchronize queue updates between hospital users in real time.

Receptionist
     │
     │ Patient Registration
     ▼
Backend Server
     │
     │ Socket.IO Event
     ▼
Doctor Dashboard
     │
     ▼
Live Queue Update

This allows doctors and staff to see queue changes without manually refreshing the application.


🗄️ Database & Seed Data

HQMS uses MongoDB as its primary database.

The backend automatically initializes development seed data during startup, including:

  • Users
  • Doctors
  • Facilities
  • Medicines

Bill numbers are generated atomically and enforced as unique identifiers to prevent duplicate billing numbers.


🔒 Security

HQMS includes:

  • JWT authentication
  • Access & refresh tokens
  • HTTP-only cookies
  • Role-based authorization
  • Protected API endpoints
  • Role-aware navigation
  • Environment-based configuration
  • Unique bill number enforcement
  • EHR audit provenance

For production deployment, use HTTPS, secure cookies, strong secrets, rate limiting, input validation, monitoring, and managed secret storage.


🚀 Future Enhancements

  • 📱 Patient & Doctor mobile applications
  • 🔔 SMS / Email / Push notifications
  • 🧠 Advanced AI-assisted diagnosis
  • 📊 Predictive patient volume forecasting
  • 🏥 Multi-hospital and multi-branch support
  • 💳 Online payment integration
  • 📄 Automated medical report generation
  • 🗣️ Voice-assisted patient registration
  • 📈 Advanced hospital analytics
  • ☁️ Cloud-native deployment
  • 🛡️ Advanced audit and security monitoring

📜 License

This project is licensed under the MIT License.


👨‍💻 Project

AI-Powered Hospital Management System (HQMS)

Built with:

React · Node.js · Express.js · MongoDB · Python · Flask · scikit-learn · Socket.IO

HQMS — Connecting AI, clinical workflows, and hospital operations in one intelligent platform.

About

HQMS is a role-based hospital workflow platform with AI triage, real-time queue operations, EHR history, billing, pharmacy, facilities, and appointment scheduling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages