A web-based hospital triage system that prioritizes patients based on medical urgency using Data Structures and Algorithms. Developed as part of a Data Structures academic project.
This project simulates a real-world Hospital Emergency Room Queue where patients are treated based on their medical condition rather than simple arrival order.
Patient priority is calculated using:
- Severity level
- Vital signs (Heart Rate, Blood Pressure, SpO₂)
- Age
- Waiting time
The system provides a web interface connected to a C++ backend that manages the triage logic.
Tech Stack
- C++ (Backend)
- HTTP Server using
cpp-httplib - HTML, CSS, JavaScript (Frontend)
- CMake (Build System)
- ➕ Add new patient
- 🔄 Update patient medical details
- 💊 Treat highest-priority patient first
- 📋 Live queue display sorted by urgency
- 🧹 Reset queue (clears all data and restarts IDs)
- 🔒 Thread-safe backend using mutex
- 🌐 Simple web interface
| Structure | Purpose |
|---|---|
unordered_map<int, Patient> |
Stores patient records with O(1) access |
vector<Patient> |
Used for sorting patients by priority |
| Custom sorting (lambda) | Orders patients by priority and arrival time |
mutex |
Ensures thread-safe operations |
Priority score is calculated as:
Base Severity Score
+ SpO₂ condition bonus
+ Heart Rate condition bonus
+ Blood Pressure condition bonus
+ Age factor (≥ 65)
+ Waiting time factor
| Severity | Priority Base |
|---|---|
| 1 (Immediate) | 100 |
| 2 | 85 |
| 3 | 70 |
| 4 | 55 |
| 5 (Non-Urgent) | 40 |
Higher priority score → Treated first.
If two patients have equal priority, the one who arrived earlier is treated first.
hospital-queue-web/
│
├── src/
│ └── main.cpp # C++ backend logic
│
├── public/
│ └── index.html # Web interface
│
├── third_party/
│ └── httplib.h # HTTP library
│
├── build/ # Generated build files
├── CMakeLists.txt
└── README.md
git clone https://github.com/your-username/hospital-queue-web.git
cd hospital-queue-web
mkdir build
cd build
cmake ..
cmake --build .
From project root:
./build/server
You should see:
Triage backend running at http://localhost:8080
http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
| POST | /add |
Add new patient |
| POST | /update |
Update patient |
| POST | /treat |
Treat highest-priority patient |
| GET | /list |
Get sorted queue |
| POST | /reset |
Clear queue and reset IDs |
| Operation | Complexity |
|---|---|
| Add Patient | O(1) |
| Update Patient | O(1) |
| Treat Patient | O(n) |
| List Queue (sorting) | O(n log n) |
- Implementation of priority-based scheduling
- Use of C++ STL in real-world applications
- REST API development in C++
- Integration of frontend with backend
- Thread-safe programming using mutex
Mohammad Amir
CSE (AI & ML)
DSA Project
This project is for academic and educational purposes.