-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
103 lines (89 loc) · 3.22 KB
/
main.cpp
File metadata and controls
103 lines (89 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// Created by haris on 12/22/2025.
//
#include "er_triage.h"
#include <iostream>
#include <limits>
#include <string>
using namespace std;
static int readInt(const string& prompt, int minVal, int maxVal) {
while (true) {
cout << prompt;
int x;
if (cin >> x && x >= minVal && x <= maxVal) {
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return x;
}
cout << "Invalid input. Enter a number between " << minVal << " and " << maxVal << ".\n";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
static string readLine(const string& prompt) {
cout << prompt;
string s;
getline(cin, s);
return s;
}
static void menu() {
cout << "\n===== ER TRIAGE CLI =====\n"
<< "1) Add patient (arrival)\n"
<< "2) Update triage score (re-triage)\n"
<< "3) Call next patient (treat)\n"
<< "4) Show lobby\n"
<< "5) Advance time (minutes)\n"
<< "6) Quick simulate: 'critical' patient arrives\n"
<< "0) Exit\n";
}
int main() {
cout << "ER Triage System\n";
int agingRate = readInt("Set aging rate per 10 minutes (0-10 recommended): ", 0, 50);
er_triage er(agingRate);
while (true) {
menu();
int choice = readInt("Choose option: ", 0, 6);
if (choice == 0) {
cout << "Goodbye.\n";
break;
}
if (choice == 1) {
string name = readLine("Patient name: ");
int age = readInt("Age (0-120): ", 0, 120);
string complaint = readLine("Complaint: ");
int triage = readInt("Triage score (0-100, higher = more urgent): ", 0, 100);
int id = er.addPatient(name, age, complaint, triage);
cout << "[OK] Added patient id=" << id << "\n";
er.showLobby();
}
else if (choice == 2) {
int id = readInt("Patient id to update: ", 1, 1'000'000);
int triage = readInt("New triage score (0-100): ", 0, 100);
er.updateTriage(id, triage);
er.showLobby();
}
else if (choice == 3) {
er.callNext();
er.showLobby();
}
else if (choice == 4) {
er.showLobby();
}
else if (choice == 5) {
int minutes = readInt("Advance time by minutes (1-1440): ", 1, 1440);
er.advanceTime(minutes);
er.showLobby();
}
else if (choice == 6) {
// This is your “someone critical arrives and cuts the line” demo
cout << "\n[SIM] Critical patient arriving...\n";
string name = readLine("Critical patient name: ");
int age = readInt("Age (0-120): ", 0, 120);
string complaint = readLine("Complaint (e.g., Chest pain, unresponsive): ");
int triage = readInt("Triage score (80-100 recommended): ", 0, 100);
int id = er.addPatient(name, age, complaint, triage);
cout << "[ALERT] Critical patient added id=" << id << " — should jump near the top.\n";
er.showLobby();
}
}
return 0;
}