Repository navigation
Expand file tree
/
Copy pathFunctionalities.cpp
More file actions
763 lines (689 loc) · 28.6 KB
/
Copy pathFunctionalities.cpp
File metadata and controls
763 lines (689 loc) · 28.6 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
#include "Functionalities.h"
#include <iostream>
#include <vector>
#include <sstream> //for the vector of strings available days
#include "Trie.h"
#include "Patient.h"
#include <cstdlib> // Required for system()
#include "Doctor.h"
#include "Clinics.h"
#include "CityGraph.h"
using namespace std;
extern vector<Patient>hospitalPatients;
extern vector<Doctor>hospitalDoctors;
extern vector<Clinic>hospitalClinics;
extern Trie<Patient>patientsnames;
extern Trie<Patient>patientsids;
extern Trie<Doctor>doctorsnames;
extern Trie<Doctor>doctorsids;
extern Trie<Clinic>clinictypes;
#if defined(_WIN32) || defined(_WIN64)
const std::string CLEAR_COMMAND = "cls";
#else
const std::string CLEAR_COMMAND = "clear";
#endif
bool endOfProgram= false;
bool backToTheMainMenu=false;
Clinic*searchClinic(string clinictype) {
if (clinictypes.search(clinictype))
return clinictypes.search(clinictype);
else
return nullptr;
}
bool checkBack(){ //check if the user want to back to the last page
short back=1;
do {
cout << "\n\n[1] Back to the last page" << endl << "[2] Back to the main menu\n\n";
cout << "Please enter your choice : ";
cin >> back;
if (back == 2)
backToTheMainMenu = true;
}while(back!=1 && back!=2); //validate input
return (back==2);
}
/*
Checkback() function is used all over the other options to check if the user wants to either go back to the previous menu or to go back to the main menu
It's only used of there exists a previous menu not the main menu
*/
//function that will be used multiple times to check the input
int checkinput(int choice,int first,int last){
//The while loop is to check if the choice is within the range of the list
while (choice < first || choice > last ){
cout << "Please enter a number between "<<first<< " and " <<last <<" inclusively : ";
cin >> choice;
}
return choice; // return the value after exiting the while loop with the right value that's within the range
}
void creditsmenu(){
cout<<"--------------------------------------------Thanks for using our program---------------------------------------------\n\n";
cout<<"-------------------------------------------------------Credits-------------------------------------------------------\n\n";
cout<<"--------------------------------------------------Salah eldin Elsayed------------------------------------------------\n\n";
cout<<"----------------------------------------------------Omar El Nabarawy-------------------------------------------------\n\n";
cout<<"--------------------------------------------------Abdulrahman Abogendia----------------------------------------------\n\n";
cout<<"-----------------------------------------------------Fouad Hashesh---------------------------------------------------\n\n";
cout<<"----------------------------------------------------Mohamed Farouk---------------------------------------------------\n\n";
cout<<"-----------------------------Under the Supervision of Dr. Hala Zayed & Eng.Rameez Barakat----------------------------\n\n";
}
void mainmenu(){
short choice=1;
do{
system(CLEAR_COMMAND.c_str()); //clear screen
cout<<"1-Edit Database\n2-Display Info\n3-Reserve a clinic\n4-Emergency Request\n5-Close The program"<<endl;
cout<<"\nPlease enter your choice : ";
cin>>choice;
if (choice==1)
editmenu();
if (choice==2)
displaymenu();
if (choice==3)
clinicmenu();
if (choice==4)
emergencymenu();
system(CLEAR_COMMAND.c_str()); //clear screen
if(backToTheMainMenu) { //check if the user want to back to the main menu
choice = 1;
backToTheMainMenu=false;
}
if(endOfProgram) //if the user want to end the program
break;
}while(choice!=5);
creditsmenu();
system("pause>0");
}
void editmenu(){
short choice;
do{
system(CLEAR_COMMAND.c_str()); //clear screen
cout<<"===Edit menu=== "<<endl;
cout<<"1-Edit Doctor Info\n2-Add Doctor\n3-Remove Doctor\n4-Edit Patient Info\n5-Add Patient\n6-Remove Patient\n";
cout<<"Enter your choice : ";
cin>>choice;
if (choice<1 || choice > 6) {
continue;
}
if (choice == 1) {
string input;
cout << "Enter the id or name of the Doctor you want to edit : ";
cin.ignore();
getline(cin,input);
if (searchDoctor_byname(input)|| searchDoctor_byid(input)){
input= searchDoctor_byname(input)? searchDoctor_byname(input)->getID(): searchDoctor_byid(input)->getID();
editDoctor(input);
} else
cout<<"ID not found"<<endl;
}
else if (choice == 2) {
addDoctor();
}
else if (choice==3){
string input;
cout << "Enter the id or name of the Doctor you want to remove : ";
cin.ignore();
getline(cin,input);
if (searchDoctor_byname(input)|| searchDoctor_byid(input)){
input= searchDoctor_byname(input)? searchDoctor_byname(input)->getID(): searchDoctor_byid(input)->getID();
removeDoctor(input);
} else
cout<<"ID not found"<<endl;
}
else if (choice==4){
string input;
cout << "Enter the id or name of the patient you want to edit : ";
cin.ignore();
getline(cin,input);
if (searchPatient_byName(input)|| searchPatient_byid(input)){
input= searchPatient_byName(input) ? searchPatient_byName(input)->getID() : searchPatient_byid(input)->getID();
editPatient(input);
} else
cout<<"ID not found"<<endl;
}
else if (choice==5){
addPatient();
}
else if (choice==6){
string input;
cout << "Enter the id or name of the patient you want to remove : ";
cin.ignore();
getline(cin,input);
if (searchPatient_byName(input)|| searchPatient_byid(input)){
input= searchPatient_byName(input) ? searchPatient_byName(input)->getID() : searchPatient_byid(input)->getID();
removePatient(input);
} else
cout<<"ID not found"<<endl;
}
if(choice>0 && choice<7)
checkBack(); //check if the user want to back to the last menu
}while(!backToTheMainMenu); //check if the user want to back to the main menu
}
void displaymenu(){
short choice;
do{
system(CLEAR_COMMAND.c_str()); //clear screen
cout<<"1-Display All clinics info"<<endl
<<"2-Display All Doctors info"<<endl
<<"3-Display All Patients info"<<endl
<<"4-Display a clinic info"<<endl
<<"5-Display a Doctor info"<<endl
<<"6-Display a Patient info"<<endl;
cout<<"Please Enter Your choice : ";
cin>>choice;
if (choice<1 || choice > 6) {
continue;
}
if (choice == 1) { //add member
displayclinics();
}
else if (choice == 2) { //remove member
displaydoctors();
}
else if (choice==3){
displaypatients();
}
else if (choice==4){
cout << "Enter clinic type : ";
string input;
cin.ignore();
getline(cin,input);
if (searchClinic(input)){
searchClinic(input)->printInfo();
}
else{
cout<< "Invalid Clinic type"<<endl;
}
}
else if (choice==5){
string input;
cout << "Enter the id or name of the Doctor you want to View : ";
cin.ignore();
getline(cin,input);
if (searchDoctor_byname(input) || searchDoctor_byid(input)){
searchDoctor_byname(input)? searchDoctor_byname(input)->displayinfo(): searchDoctor_byid(input)->displayinfo();
}
else
cout<<"Doctor not found"<<endl;
}
else if (choice==6){
string input;
cout << "Enter the id or name of the patient you want to View : ";
cin.ignore();
getline(cin,input);
if (searchPatient_byName(input) || searchPatient_byid(input)){
searchPatient_byName(input) ? searchPatient_byName(input)->displayinfo() : searchPatient_byid(input)->displayinfo() ;
} else
cout<<"Patient not found"<<endl;
}
if(choice>0 && choice<7)
checkBack(); //check if the user want to back to the last menu
}while(!backToTheMainMenu); //check if the user want to back to the main menu
}
void clinicmenu(){
short choice;
do{
system(CLEAR_COMMAND.c_str()); //clear screen
cout << "===Clinic Menu===\n";
cout << "1- Reserve a Clinic\n";
cout << "2- Display Clinic Schedule\n";
cout << "3- Remove patient\n";
cout << "Enter your choice: ";
cin >> choice;
if (choice<1 || choice > 3) {
continue;
}
if (choice == 1) {
reserveClinic();
}
else if (choice == 2) {
displayClinicSchedule(); // lesa htt3mel
}
else if (choice == 3){
RemovePatientFromQueue();
}
if(choice>0 && choice<4)
checkBack(); //check if the user want to back to the last menu
}while(!backToTheMainMenu); //check if the user want to back to the main menu
}
//Patients' funcions
//function to search patient by id
Patient* searchPatient_byid(string id){
if (patientsids.search(id)){
return patientsids.search(id);
}
else
return nullptr;
}
Patient* searchPatient_byName(string name){
if(patientsnames.search(name)) {
return patientsnames.search(name);
}
else
return nullptr;
}
void addPatient() {
string name;
string id;
int age;
bool gender;
string condition;
cout<<"Enter Patient Data"<<endl;
cout<<"\nName : ";
cin.ignore();
getline(cin,name); //takes the name of the patient from the user
cout<<"\nID : ";
cin>>id;
cout<<"\nage: ";
cin>>age; //takes the age of the patient from the user
cout<<"\ngender (1 male 0 female ) : ";
cin>>gender; //takes the gender of the patient from the user
cout<<"\ncondition description : ";
cin.ignore();
getline(cin,condition); //takes the condition of the patient from the user
int airwaylevel,breathinglevel,pulselevel,disabilitylevel,exposurelevel;
cout << "\nplease enter the airway level : ";
cin >> airwaylevel; //takes the airway level of the patient from the user
cout << "\nplease enter the breathing level : ";
cin >> breathinglevel; //takes the breathing level of the patient from the user
cout << "\nplease enter the pulse level : ";
cin >> pulselevel; //takes the pulse level of the patient from the user
cout << "\nplease enter the disbaility level : ";
cin >> disabilitylevel; //takes the disability level of the patient from the user
cout << "\nplease enter the exposure level : ";
cin >> exposurelevel; //takes the exposure level of the patient from the user
//The following line initializes an object of class diagnosis and calls its constructor with the
//given info from the user to put it in the patient class
Diagnosis d1(airwaylevel,breathinglevel,pulselevel,disabilitylevel,exposurelevel);
//The following line initializes an object of class patient with all the members collected from the user
Patient* patient=new Patient(name,id,age,gender,condition,d1);
hospitalPatients.push_back(*patient); // push(store) patient object(with all the info collected from the user ) in the vector
patientsnames.insert(name,patient);
patientsids.insert(id, patient);
cout << "\n=== Patient added successfully ==="<<endl;
}
//function to remove the patient from the vector
void removePatient(string id_toberemoved){
for (int i = 0; i < hospitalPatients.size() ; i++ ){ //iterate over the whole vector
if (id_toberemoved == hospitalPatients[i].getID() ){ //if condition to get the patient
// with the id to be removed
cout << "The patient is being removed... "<< endl;
system("timeout /t 1 >nul");
patientsnames.deleteWord(hospitalPatients[i].getName());
patientsids.deleteWord(hospitalPatients[i].getID());
hospitalPatients.erase(hospitalPatients.begin() + i); //remove the patient wanted to remove
// from the vector
cout << "Patient with id "<<id_toberemoved << " is removed successfully "<< endl;
return ;
}
}
cout << "patient with ID " << id_toberemoved << " not found." << endl;
}
void editPatient(string id_tobe_edited){
for (int i = 0; i < hospitalPatients.size() ; i++ ){
int choice;
if(id_tobe_edited == hospitalPatients[i].getID()){
hospitalPatients[i].displayinfo();
cout << "what do you want to edit in the patient with id : "<< id_tobe_edited<<endl;
cout << "1- Patient's name\n2- Patient's id\n3- Patient's age\n4- Patient's gender\n";
cout << "5- Condition description\n";
cout <<"6- Diagnosis level\nEnter your choice : ";
cin >> choice;
choice = checkinput(choice,1,6);
if (choice == 1){
string name;
cout << "Enter the new name of the patient : ";
cin.ignore(); //clear the buffer to ensure that getline works correctly
getline(cin,name);
patientsnames.deleteWord(patientsids.search(id_tobe_edited)->getName());
hospitalPatients[i].setName(name);
patientsids.deleteWord(id_tobe_edited);
// patientsids.search(id_tobe_edited)->setName(name);
patientsnames.insert(name,&hospitalPatients[i]);
patientsids.insert(id_tobe_edited,&hospitalPatients[i]);
}
else if (choice == 2){
string id;
cout << "Enter the new id of the patient : ";
cin >> id;
string oldname = patientsids.search(id_tobe_edited)->getName();
patientsnames.deleteWord(patientsids.search(id_tobe_edited)->getName());
patientsids.deleteWord(id_tobe_edited);
hospitalPatients[i].setId(id);
patientsnames.insert(oldname,&hospitalPatients[i]);
patientsids.insert(id,&hospitalPatients[i]);
}
else if (choice == 3){
int age;
cout << "Enter the new age of the patient : ";
cin >> age;
hospitalPatients[i].setAge(age);
patientsids.search(id_tobe_edited)->setAge(age);
}
else if (choice == 4){
bool gen;
cout << "Enter the right gender of the patient (1 for male and 0 for female) : ";
cin >> gen;
hospitalPatients[i].setGender(gen);
patientsids.search(id_tobe_edited)->setGender(gen);
}
else if (choice == 5){
string condition;
cout << "Enter the condition description of the patient : ";
cin.ignore();
getline(cin,condition);
hospitalPatients[i].setConditionDescription(condition);
patientsids.search(id_tobe_edited)->setConditionDescription(condition);
}
else if(choice == 6){
int airwaylevel,breathinglevel,pulselevel,disabilitylevel,exposurelevel;
cout << "please enter the airway level : ";
cin >> airwaylevel;
cout << "please enter the breathing level : ";
cin >> breathinglevel;
cout << "please enter the pulse level : ";
cin >> pulselevel;
cout << "please enter the disbaility level : ";
cin >> disabilitylevel;
cout << "please enter the exposure level : ";
cin >> exposurelevel;
Diagnosis d1(airwaylevel,breathinglevel,pulselevel,disabilitylevel,exposurelevel);
hospitalPatients[i].setDiagnosis(d1);
patientsids.search(id_tobe_edited)->setDiagnosis(d1);
}
cout << "\n=== Patient is edited successfully ==="<<endl;
return;
}
}
cout << "patient with ID " << id_tobe_edited << " not found." << endl;
}
void displaypatients(){
cout << "printing all patients details..."<<endl<<endl;
system("timeout /t 1 >nul");
for (auto it: hospitalPatients){
it.displayinfo() ;
cout << endl<<endl;
}
cout << "This is the end of the patients list "<<endl;
}
//Doctors' functions
Doctor* searchDoctor_byid(string id){
if (doctorsids.search(id))
return doctorsids.search(id);
else
return nullptr;
}
Doctor* searchDoctor_byname(string name){
if (doctorsnames.search(name)) {
return doctorsnames.search(name);
}
else
return nullptr;
}
void addDoctor(){
string name;
vector<string>availableDays;
string inputline;
string clinicType;
string id;
cout<<"Enter Doctor Data"<<endl;
cout<<"Name : ";
cin.ignore();
getline(cin,name); //takes the name of the doctor from the user
cout<<"\nAvailable Days : ";
getline(cin, inputline);//get the whole line as inputline becausecin can't take more than one word
stringstream line(inputline);
string day;
while(line>>day){ //days separated by spaces not commas
day = capitalizeFirstLetter(day);
availableDays.push_back(day);
}
cout << "\nClinic type : ";
getline(cin,clinicType);
cout << "\nDoctor id : ";
cin>>id;
Doctor *doc=new Doctor(name,availableDays,clinicType,id);
hospitalDoctors.push_back(*doc);
doctorsnames.insert(name,doc);
doctorsids.insert(id,doc);
cout << "\n=== Doctor added successfully ==="<<endl;
}
void removeDoctor(string id_toberemoved){ //to be tested
for (auto i = 0; i < hospitalDoctors.size() ; i++ ){ // iterate over the whole vector of Doctors
if (id_toberemoved == hospitalDoctors[i].getID() ){ //if condition to get the doctor with the id to be removed
cout << "The Doctor is being removed... "<< endl;
system("timeout /t 1 >nul");
doctorsnames.deleteWord(hospitalDoctors[i].getName());
doctorsids.deleteWord(hospitalDoctors[i].getID());
hospitalDoctors.erase( hospitalDoctors.begin() + i ); //remove the doctor from the vector
cout << "Doctor with id "<< id_toberemoved<< " is removed successfully "<< endl;
return ; // exits the function after erasing the doctor
}
}
cout << "Doctor with ID " << id_toberemoved << " not found." << endl; // if the id doesn't exist
}
void editDoctor(string id_tobe_edited){
int choice;
for(int i = 0; i < hospitalDoctors.size() ; i++ ){ //loop over the whole vector
if( id_tobe_edited == hospitalDoctors[i].getID() ){ //if condition to get the doctor with the id to be edited
hospitalDoctors[i].displayinfo();
cout << "What do you want to edit in the doctor with id : "<<id_tobe_edited <<endl;
cout << "1-Doctor's name\n2-Doctor's available days \n3-clinic type\n4-Doctor's id\n"
"Enter your choice : ";
cin >> choice;
choice = checkinput(choice,1,4);
if (choice == 1){
string name;
cout <<"Enter the Doctor's right name: ";
cin.ignore(); //clear the buffer to ensure that getline works correctly
getline(cin,name); //get the whole line as the name as cin gets only the first word
doctorsnames.deleteWord(doctorsids.search(id_tobe_edited)->getName());
hospitalDoctors[i].setName(name); //set the name to the edited name
doctorsids.deleteWord(id_tobe_edited);
doctorsnames.insert(name,&hospitalDoctors[i]);
doctorsids.insert(id_tobe_edited,&hospitalDoctors[i]);
}
if (choice == 2){
vector<string> avd;
cout <<"Enter Doctor's available days (separated by spaces) : ";
string inputline; //string that'll be used to obtain the whole line
cin.ignore(); //clear the buffer to ensure that getline works correctly
getline(cin, inputline); //function to obtain the whole line and store it in inputline
stringstream line(inputline);
string day;
//The following loop takes every whole word, store it in string day and push it in the vector
while(line>>day){ //days separated by spaces not commas
day = capitalizeFirstLetter(day);
avd.push_back(day);
}
hospitalDoctors[i].setAvailableDays(avd); //edit the available days to the inserted one
doctorsids.search(id_tobe_edited)->setAvailableDays(avd);
}
if (choice == 3){
string clinic;
cout <<"Enter the clinic type : ";
cin.ignore(); //clear the buffer to ensure that getline works correctly
getline(cin,clinic); //function to obtain the whole line and store it in inputline
hospitalDoctors[i].setClinicType(clinic);
doctorsids.search(id_tobe_edited)->setClinicType(clinic);
}
if (choice == 4){
string id;
cout << "Enter the Doctor's new id : ";
cin.ignore(); //take the id as input to give it to the setter
getline(cin,id);
string oldname=doctorsids.search(id_tobe_edited)->getName();
doctorsids.deleteWord(id_tobe_edited);
doctorsnames.deleteWord(oldname);
hospitalDoctors[i].setID(id); //set the id to the inserted idfrom the user
doctorsids.insert(id,&hospitalDoctors[i]);
doctorsnames.insert(oldname,&hospitalDoctors[i]);
}
cout << "\n=== Doctor is edited successfully ==="<<endl;
return;
}
}
cout << "Doctor with ID " << id_tobe_edited << " not found." << endl;
}
void displaydoctors(){
cout << "printing all doctors details..."<<endl << endl;
system("timeout /t 1 >nul");
for (auto it: hospitalDoctors){
it.displayinfo() ;
cout << endl<<endl;
}
cout << "This is the end of the doctors list "<<endl;
}
void reserveClinic() {
string type;
cout << "Today's day : "<<getcurrentday()<<endl;
cout<<"Enter Type of the Clinic : ";
cin.ignore();
getline(cin,type);
if(clinictypes.search(type)){
bool isavailable= false;
int intemp ;
for (auto it2 = 0 ; it2 <hospitalClinics.size(); it2++) { // loop 3l clinics
vector<Doctor> temp = hospitalClinics[it2].getDoctor();
for (auto i = 0; i< temp.size() ; i++) { //loop3l doctors
for (auto it: temp[i].getAvailableDays()) { // loop 3l available days
if (it == getcurrentday()) {
isavailable = true;
intemp = it2;
}
}
}
}
if (isavailable) {
string input;
cout << "Enter the id or name of the Patient : ";
getline(cin,input);
if (searchPatient_byid(input) || searchPatient_byName(input)) {
input= searchPatient_byName(input) ? searchPatient_byName(input)->getID() : searchPatient_byid(input)->getID();
searchClinic(type)->addtoWaiting(*searchPatient_byid(input));
hospitalClinics[intemp].addtoWaiting(*searchPatient_byid(input));
cout << "CLinic reserved successfully" <<endl;//test
} else
cout << "ID not found" << endl;
} else
cout<<"Clinic isn't Available for Reserving Today "<<endl;
}
else cout<<"Clinic is not found "<<endl;
}
void displayClinicSchedule() {
string t;
cout<<"Enter The type of Clinic : ";
cin.ignore();
getline(cin,t);
if (clinictypes.search(t)) {
for (auto it2 = 0;it2< searchClinic(t)->getDoctor().size(); it2++){ //iterate over every doctor with this clinic
cout << "Doctor's name : "<<searchClinic(t)->getDoctor()[it2].getName()<<endl;
cout << "Doctor's available days : ";
for (auto it: searchClinic(t)->getDoctor()[it2].getAvailableDays()) { //iterate over the available days of the doctors
cout << it << " " ;
}
cout<<endl;
}
} else
cout<<"Clinic Not found "<<endl;
}
void displayclinics(){
cout << "printing all Clinics details..."<<endl << endl;
system("timeout /t 1 >nul");
for (auto it: hospitalClinics){
it.printInfo() ;
cout << endl<<endl;
}
cout << "This is the end of the Clinics list "<<endl;
}
void RemovePatientFromQueue(){
string t;
cout<<"Enter The type of Clinic : ";
cin.ignore();
getline(cin,t);
if(clinictypes.search(t)){
searchClinic(t)->removefromWaiting();
for (auto it=0; it < hospitalClinics.size() ; it++){
if (hospitalClinics[it].getType() == t){
hospitalClinics[it].removefromWaiting();
cout << "Patient removed successfully"<<endl;
}
}
}
else {
cout << "Clinic not found "<<endl;
}
}
void emergencymenu(){
system(CLEAR_COMMAND.c_str()); //clear screen
short choice;
do{
CityGraph Metropolis;
cout << "Choose Emergency address: \n\n";
cout << "1. Maple Grove Residences" << endl;
cout << "2. Willow Heights" << endl;
cout << "3. Sunset Pines Apartments" << endl;
cout << "4. Cedar Ridge Villas" << endl;
cout << "5. Lakeside Manor" << endl;
cout << "6. Harbor View Estates" << endl;
cout << "7. Oakwood Park Residences" << endl;
cout << "8. Riverstone Apartments" << endl;
cout << "9. Meadowlark Homes" << endl << endl;
cout << "Your Choice: ";
string address;
cin >> choice;
if (choice<1 || choice > 9) {
system(CLEAR_COMMAND.c_str());
continue;
}
switch (choice) {
case 1:
address = "Maple Grove Residences";
break;
case 2:
address = "Willow Heights";
break;
case 3:
address = "Sunset Pines Apartments";
break;
case 4:
address = "Cedar Ridge Villas";
break;
case 5:
address = "Lakeside Manor";
break;
case 6:
address = "Harbor View Estates";
break;
case 7:
address = "Oakwood Park Residences";
break;
case 8:
address = "Riverstone Apartments";
break;
case 9:
address = "Meadowlark Homes";
break;
}
pair<int, string> route = Metropolis.shortestPath(address);
cout << "ETA : " << route.first << " mins" << endl;
cout << "Shortest route for Ambulance : " << route.second << endl;
if(choice>0 && choice<10)
checkBack(); //check if the user want to back to the last menu
}while(!backToTheMainMenu); //check if the user want to back to the main menu
}
string getcurrentday() {
string daysOfWeek[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
time_t t = time(nullptr);
tm *now = localtime(&t); // Get the current time
int dayOfWeek = now->tm_wday; // Get the day of the week as tm have an attribute called
//wday that gives the day of the week in integers (0-6, where 0 is Sunday)
// Return the day of the week
return daysOfWeek[dayOfWeek];
}
// Function to capitalize ONLY the first letter of a string
string capitalizeFirstLetter(const string& str) {
if (str.empty()) return str;
string capitalized = str;
capitalized[0] = toupper(capitalized[0]);
for (size_t i = 1; i < capitalized.size(); ++i) {
capitalized[i] = tolower(capitalized[i]);
}
return capitalized;
}