-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctionalities.h
More file actions
277 lines (244 loc) · 7.85 KB
/
functionalities.h
File metadata and controls
277 lines (244 loc) · 7.85 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
#ifndef FUNCTIONALITIES_H
#define FUNCTIONALITIES_H
#include <iostream>
#include "Part1/Btree.h"
#include "Part2/BST.h"
#include "Part3/AVL.h"
#include "Interfaces/Hospital.h"
#include "Interfaces/MedicalInfo.h"
#include "Interfaces/Patient.h"
using namespace std;
namespace DriverFunctions
{
bool checkId(const string &ID)
{
try
{
stoll(ID);
return true;
}
catch (...)
{
return false;
}
}
MedicalInfo EnterMedicalinfos()
{
MedicalInfo medicalInfo;
string Allergeies, CD, Note;
float BP(0), HR(0);
char Depart;
vector<string> MedicalTaken;
cout << "Enter Depart Chronic Disease of the Patient if available: ";
getline(cin >> ws, CD);
cout << "Enter the Allergies of the Patient: ";
getline(cin >> ws, Allergeies);
bool notDigit = true;
do
{
string text;
cout << "Enter the current Blood Pressure of the Patient: ";
cin >> text;
try
{
BP = stof(text);
notDigit = false;
}
catch (...)
{
cout << "Please enter the Blood Pressure as A Number !" << endl;
}
} while (notDigit);
notDigit = true;
do
{
string text;
cout
<< "Enter the current Heart Rate of the Patient: ";
cin >> text;
try
{
BP = stof(text);
notDigit = false;
}
catch (...)
{
cout
<< "Please enter the Heart Rate as A Number !" << endl;
}
} while (notDigit);
do
{
cout << "Enter the Department of the Patient:(A OR B OR C OR D OR E( where E Is the critical Unit department)) :";
cin >> Depart;
} while (!(Depart == 'A' || Depart == 'B' || Depart == 'C' || Depart == 'D' || Depart == 'E'));
cout << "Enter the Medicals taken by the Patient (-1) to quit: ";
string medical;
while (true)
{
cin >> medical;
if (medical == "-1")
break;
MedicalTaken.push_back(medical);
}
cout << "Enter an Addtional Note: ";
getline(cin >> ws, Note);
medicalInfo.setAllergies(Allergeies);
medicalInfo.setCd(CD);
medicalInfo.setDepartment(Depart);
medicalInfo.setMedicalstaken(MedicalTaken);
medicalInfo.setBP(BP);
medicalInfo.setHr(HR);
medicalInfo.setNote(Note);
medicalInfo.setTime(getTime());
return medicalInfo;
}
Patient enterPatient()
{
Patient patient;
string fullName, bDay, adress, tel, ABO;
char FM;
cout << "Enter the name of the patient : ";
getline(cin >> ws, fullName);
cout << "Enter the Adress of the patient : ";
getline(cin >> ws, adress);
cout << "Enter the Birth Date of the patient \" dd/mm/yyyy \" : ";
cin >> bDay;
cout << "Enter the gender of the patient ( M for male & F for female) : ";
cin >> FM;
cout << "Enter the blood type of the patient : ";
cin >> ABO;
cout << "Enter the phone number of the patient : ";
cin >> tel;
MedicalInfo info = EnterMedicalinfos();
patient.setAbo(ABO);
patient.setAddress(adress);
patient.setBday(bDay);
patient.setFm(FM);
patient.setMedicalInfo(info);
patient.setName(fullName);
patient.setPhone(tel);
return patient;
}
void DoctorInput()
{
// The Developer has the right to edit the ADT used in the hospital.
Hospital<BST> Hospital;
char Depart;
while (true)
{
cout << "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "Dear Doctor, Please Pick An Option Among The Following Ones, Concerning the Hospital: (Enter The Character That is corresponding to the desired option) \n"
<< "Depart) Add A Patient\n"
<< "u) Update The Information Of an Existing Patient\n"
<< "r) Remove A Patient\n"
<< "s) Search For Depart Patient (Check if Depart Patient already exists)\n"
<< "l) Patient is leaving Hospital\n"
<< "p) Display Patient\n"
<< "m) Move Patient to Department\n"
<< "h) Display All History of the Desired Patient\n"
<< "q) Quit The Program\n"
<< "Your Input: ";
cin >> Depart;
cout << "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
switch (Depart)
{
case 'a':
{
Patient patient = enterPatient();
Hospital.insert(patient);
break;
}
case 'u':
{
string ID;
do
{
cout << "\nEnter the ID of the Existing Patient Desired to be Updated: ";
cin >> ID;
} while (!checkId(ID));
MedicalInfo medInfo = EnterMedicalinfos();
Hospital.update(ID, medInfo);
break;
}
case 'r':
{
string ID;
do
{
cout << "\nEnter the ID of the Existing Patient Desired to be Removed: ";
cin >> ID;
} while (!checkId(ID));
Hospital.deletePatient(ID);
break;
}
case 's':
{
string ID;
do
{
cout << "\nEnter the ID of the Patient you want to check its Existence: ";
cin >> ID;
} while (!checkId(ID));
cout << (Hospital.contains(ID) ? "\nPatient already exists\n" : "\nPatient does not exists\n");
break;
}
case 'l':
{
string ID;
do
{
cout << "\nEnter the ID of the Existing Patient Desired to Leave: ";
cin >> ID;
} while (!checkId(ID));
Hospital.LeaveHospital(ID);
break;
}
case 'p':
{
string ID;
do
{
cout << "\nEnter the ID of the Existing Patient Desired to be Displayed: ";
cin >> ID;
} while (!checkId(ID));
Hospital.printPatient(ID);
break;
}
case 'm':
{
string ID;
do
{
cout << "\nEnter the ID of the Existing Patient Desired to be Moved: ";
cin >> ID;
} while (!checkId(ID));
char dep;
cout << "Enter the new desired Departement: ";
cin >> dep;
Hospital.MoveToDepartement(ID, dep);
break;
}
case 'h':
{
string ID;
do
{
cout << "\nEnter the ID of the Existing Patient Desired to Display its History: ";
cin >> ID;
} while (!checkId(ID));
vector<MedicalInfo>
allHistory = FileHandler().getAllHistory(ID);
for (const MedicalInfo &info : allHistory)
info.printInfo();
break;
}
case 'q':
{
return;
}
}
}
}
}
#endif