-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpatient.cpp
339 lines (284 loc) · 6.67 KB
/
patient.cpp
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
#include "Patient.h"
Patient::Patient() // default constructor
{
this->name = "Admin";
this->username = "Admin";
this->password = "Admin";
this->age = 19;
this->balance = 999999;
this->gender = "Male";
this->bloodType = "A+";
this->allergies = "None";
this->insured = true;
this->medicalHistory = "Excellent";
this->loggedIn = false;
this->points = 0;
this->patientID = 900200100 + this->userMap.size();
this->amountDue = 0;
}
Patient::Patient(QString p_medicalHistory, double p_balance, int p_points, int p_patientID, int p_age, QString p_gender, QString p_bloodType, QString p_allergies, bool p_insured) // parameterized constructor
{
this->medicalHistory = p_medicalHistory;
this->balance = p_balance;
this->points = p_points;
this->patientID = p_patientID;
this->age = p_age;
this->gender = p_gender;
this->bloodType = p_bloodType;
this->allergies = p_allergies;
this->insured = p_insured;
this->loggedIn = false;
this->amountDue = 0;
}
QString Patient::getName()
{
return this->name;
}
QString Patient::getMedicalHistory()
{
return this->medicalHistory;
}
double Patient::getBalance() const
{
return this->balance;
}
int Patient::getPoints()
{
return this->points;
}
int Patient::getPatientID()
{
return this->patientID;
}
int Patient::getAge()
{
return this->age;
}
QString Patient::getGender()
{
return this->gender;
}
QString Patient::getBloodType()
{
return this->bloodType;
}
QString Patient::getAllergies()
{
return this->allergies;
}
bool Patient::getInsured()
{
return this->insured;
}
void Patient::setName(QString p_name)
{
this->name = p_name;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setName(p_name);
}
}
}
void Patient::setMedicalHistory(QString p_medicalHistory)
{
this->medicalHistory = p_medicalHistory;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setMedicalHistory(p_medicalHistory);
}
}
}
void Patient::setBalance(double p_balance)
{
this->balance = p_balance;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setBalance(p_balance);
}
}
}
void Patient::setPoints(int p_points)
{
this->points = p_points;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setPoints(p_points);
}
}
}
void Patient::setpatientID(int p_patientID)
{
this->patientID = p_patientID;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setpatientID(p_patientID);
}
}
}
void Patient::setAge(int p_age)
{
this->age = p_age;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setAge(p_age);
}
}
}
void Patient::setGender(QString p_gender)
{
this->gender = p_gender;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setGender(p_gender);
}
}
}
void Patient::setBloodType(QString p_bloodType)
{
this->bloodType = p_bloodType;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setBloodType(p_bloodType);
}
}
}
void Patient::setAllergies(QString p_allergies)
{
this->allergies = p_allergies;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setAllergies(p_allergies);
}
}
}
void Patient::setInsured(bool p_insured)
{
this->insured = p_insured;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setInsured(p_insured);
}
}
}
bool Patient::reg(QString p_name, QString p_username, QString p_password, int p_age, double p_balance, QString p_gender, QString p_bloodType, QString p_allergies, bool p_insured, QString p_medicalHistory)
{
if (userMap.count(p_name) == 0)
{
Patient temp;
temp.name = p_name;
temp.username = p_username;
temp.password = p_password;
temp.age = p_age;
temp.balance = p_balance;
temp.gender = p_gender;
temp.bloodType = p_bloodType;
temp.allergies = p_allergies;
temp.insured = p_insured;
temp.medicalHistory = p_medicalHistory;
temp.loggedIn = false;
temp.points = 0;
temp.patientID = 900200100 + this->userMap.size();
temp.amountDue = 0;
*this = temp;
this->userMap.insert(pair<QString, Patient>(temp.getUsername(), temp));
return true;
}
else
{
return false;
}
}
int Patient::login(QString p_username, QString p_password)
{
if (this->userMap.find(p_username) != this->userMap.end() && this->userMap[p_username].getPassword() == p_password)
{
this->loggedIn = true;
return 0; // if username and password are correct.
}
else
{
this->loggedIn = false;
if (this->userMap.find(p_username) != this->userMap.end() && this->userMap[p_username].getPassword() != p_password)
{
return 1; // if username is correct, and the password is incorrect.
}
else
{
return 2; // if username does not exist.
}
}
}
QString Patient::getUsername()
{
return this->username;
}
QString Patient::getPassword()
{
return this->password;
}
bool Patient::getLoggedIn() const
{
return this->loggedIn;
}
void Patient::setUsername(QString p_username)
{
Patient temp;
for (auto i : this->userMap){
if (i.first == this->username){
temp = i.second;
}
}
temp.username = p_username;
temp.name = p_username;
this->userMap.erase(this->userMap.find(this->username));
this->userMap.insert(pair<QString, Patient> (temp.username, temp));
this->username = p_username;
}
void Patient::setPassword(QString p_password)
{
this->password = p_password;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setPassword(p_password);
}
}
}
void Patient::setLoggedIn(bool p_loggedIn)
{
this->loggedIn = p_loggedIn;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setLoggedIn(p_loggedIn);
}
}
}
void Patient::setAmountDue(double p_amountDue)
{
this->amountDue = p_amountDue;
for (auto i : this->userMap){
if (i.first == this->username){
i.second.setAmountDue(p_amountDue);
}
}
}
double Patient::getAmountDue() const
{
return this->amountDue;
}
void Patient::operator=(const Patient &c)
{
this->name = c.name;
this->username = c.username;
this->password = c.password;
this->age = c.age;
this->balance = c.balance;
this->gender = c.gender;
this->bloodType = c.bloodType;
this->allergies = c.allergies;
this->insured = c.insured;
this->medicalHistory = c.medicalHistory;
this->loggedIn = c.loggedIn;
this->points = c.points;
this->patientID = c.patientID;
this->amountDue = c.amountDue;
}