-
Notifications
You must be signed in to change notification settings - Fork 1
/
complexsearchwindow.cpp
364 lines (279 loc) · 12.9 KB
/
complexsearchwindow.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
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
#include "complexsearchwindow.h"
#include "ui_complexsearchwindow.h"
ComplexSearchWindow::ComplexSearchWindow(QWidget *parent) : QDialog(parent),
ui(new Ui::ComplexSearchWindow)
{
ui->setupUi(this);
this->p = new Patient;
this->appointmentsLog = new QVector<Appointment>;
this->arrDoc = new QVector<Doctor>;
this->emergencyVisitLog = new QVector<EmergencyVisit>;
this->roomLog = new QVector<Room>;
this->homeVisitLog = new QVector<HomeVisit>;
}
ComplexSearchWindow::~ComplexSearchWindow()
{
delete ui;
}
void ComplexSearchWindow::on_showAllButton_clicked()
{
// This function displays all instances of the selected type
ui->criteriaLineEdit->setText("");
if (!(ui->patientRadioButton->isChecked() || ui->doctorRadioButton->isChecked() || ui->appointmentRadioButton->isChecked() || ui->roomVisitRadioButton->isChecked() || ui->homeVisitRadioButton->isChecked() || ui->emergencyVisitRadioButton->isChecked()))
{
ui->searchResultDisplay->setText("Please Select a Type to Search for.");
return;
}
// If user selected to saerch for Patient
if (ui->patientRadioButton->isChecked())
{
// Clear current search results
ui->searchResultDisplay->setText("");
// This is a for each loop. It goes over each element in the userMap.
for (auto i : this->p->userMap)
{
// Display Patient Name and Patient ID. // You can add more details (look for the attributes in Patient.h)
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + "Patient Name: " + i.second.getName() + ", Patient ID: " + QString::number(i.second.getPatientID()) + ", Patient Balance: " + QString::number(i.second.getBalance()) + '\n');
}
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There are no patients registered.");
}
// Return after the loop (end function, do not run the code below)
return;
}
// If user selected to search for Appointment
else if (ui->appointmentRadioButton->isChecked())
{
// Clear current search results
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->appointmentsLog->size(); i++)
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->appointmentsLog->at(i).showAppointment() + '\n');
}
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There are no appointments booked.");
}
// Return after the loop (end function, do not run the code below)
return;
}
else if (ui->doctorRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->arrDoc->size(); i++)
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + "Doctor's Name: " + this->arrDoc->at(i).getName() + ", Doctor's Department: " + this->arrDoc->at(i).getDepartment() + ", Doctor's Rating: " + QString::number(this->arrDoc->at(i).getRating()) + ", Doctor's Fees: $" + QString::number(this->arrDoc->at(i).getFees()) + '\n');
}
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There are no doctors registered.");
}
return;
}
else if (ui->emergencyVisitRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->emergencyVisitLog->size(); i++)
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->emergencyVisitLog->at(i).showVisit() + '\n');
}
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There are no emergency visits booked.");
}
return;
}
else if (ui->roomVisitRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->roomLog->size(); i++)
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->roomLog->at(i).showRoom() + '\n');
}
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There are no room visits booked.");
}
return;
}
else if (ui->homeVisitRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->homeVisitLog->size(); i++)
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->homeVisitLog->at(i).showHomeVisit() + '\n');
}
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There are no home visits booked.");
}
return;
}
}
void ComplexSearchWindow::on_showByCriteriaButton_clicked()
{
// This function displays a specific instance of the selected type according to the written criteria
// Very similar to the showAllButton, but it only displays when the if condition is true (which is the criteria we want)
if (!(ui->patientRadioButton->isChecked() || ui->doctorRadioButton->isChecked() || ui->appointmentRadioButton->isChecked() || ui->roomVisitRadioButton->isChecked() || ui->homeVisitRadioButton->isChecked() || ui->emergencyVisitRadioButton->isChecked()))
{
ui->searchResultDisplay->setText("Please Select a Type to Search for.");
ui->criteriaLineEdit->setText("");
return;
}
// If user selected to saerch for Patient
if (ui->patientRadioButton->isChecked())
{
// Clear current search results
ui->searchResultDisplay->setText("");
// This is a for each loop. It goes over each element in the userMap.
for (auto i : this->p->userMap)
{
// Display Patient Name and Patient ID. // You can add more details (look for the attributes in Patient.h)
// Only of the instance that meets the criteria
if (QString::number(i.second.getPatientID()) == ui->criteriaLineEdit->text())
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + "Patient Name: " + i.second.getName() + ", Patient ID: " + QString::number(i.second.getPatientID()) + ", Patient Balance: " + QString::number(i.second.getBalance()) + '\n');
}
}
// If the loop ended, and no instance was found, display as Not Found.
if (ui->searchResultDisplay->text() == "")
{
ui->searchResultDisplay->setText("There is no patient registered that meets this criteria.");
}
// Return after the loop (end function, do not run the code below)
ui->criteriaLineEdit->setText("");
return;
}
// If user selected to search for Appointment
else if (ui->appointmentRadioButton->isChecked())
{
// Clear current search results
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->appointmentsLog->size(); i++)
{
if (ui->criteriaLineEdit->text() == this->appointmentsLog->at(i).doctorName || ui->criteriaLineEdit->text() == this->appointmentsLog->at(i).dt.getDt() || ui->criteriaLineEdit->text() == this->appointmentsLog->at(i).patientName || ui->criteriaLineEdit->text() == QString::number(this->appointmentsLog->at(i).fees))
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->appointmentsLog->at(i).showAppointment() + '\n');
}
}
// Return after the loop (end function, do not run the code below)
ui->criteriaLineEdit->setText("");
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There is no appointment booked that meets this criteria.");
}
return;
}
else if (ui->doctorRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->arrDoc->size(); i++)
{
if (ui->criteriaLineEdit->text() == this->arrDoc->at(i).getName() || ui->criteriaLineEdit->text() == QString::number(this->arrDoc->at(i).getRating()) || ui->criteriaLineEdit->text() == QString::number(this->arrDoc->at(i).getFees()) || ui->criteriaLineEdit->text() == this->arrDoc->at(i).getDepartment())
{
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + "Doctor's Name: " + this->arrDoc->at(i).getName() + ", Doctor's Department: " + this->arrDoc->at(i).getDepartment() + " Doctor's Rating: " + QString::number(this->arrDoc->at(i).getRating()) + " Doctor's Fees: $" + QString::number(this->arrDoc->at(i).getFees()) + '\n');
}
}
ui->criteriaLineEdit->setText("");
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There is no doctor registered that meets this criteria.");
}
return;
}
else if (ui->emergencyVisitRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->emergencyVisitLog->size(); i++)
{
if (ui->criteriaLineEdit->text() == this->emergencyVisitLog->at(i).showVisit() || ui->criteriaLineEdit->text() == this->emergencyVisitLog->at(i).dt.getDt())
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->emergencyVisitLog->at(i).showVisit() + '\n');
}
ui->criteriaLineEdit->setText("");
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There is no emergency visit booked that meets this criteria.");
}
return;
}
else if (ui->roomVisitRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->roomLog->size(); i++)
{
if (ui->criteriaLineEdit->text() == this->roomLog->at(i).getRoomType() || ui->criteriaLineEdit->text() == this->roomLog->at(i).dt.getDt())
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->roomLog->at(i).showRoom() + '\n');
}
ui->criteriaLineEdit->setText("");
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There is no room visit booked that meets this criteria.");
}
return;
}
else if (ui->homeVisitRadioButton->isChecked())
{
ui->searchResultDisplay->setText("");
for (int i = 0; i < this->homeVisitLog->size(); i++)
{
if (ui->criteriaLineEdit->text() == this->homeVisitLog->at(i).getPatientName() || ui->criteriaLineEdit->text() == this->homeVisitLog->at(i).getHomeAddress())
ui->searchResultDisplay->setText(ui->searchResultDisplay->text() + this->homeVisitLog->at(i).showHomeVisit() + '\n');
}
ui->criteriaLineEdit->setText("");
if (ui->searchResultDisplay->text() == ""){
ui->searchResultDisplay->setText("There is no home visit booked that meets this criteria.");
}
return;
}
else
{
ui->searchByTitle->setText("Please Select a Type to Search for.");
ui->criteriaLineEdit->setText("");
return;
}
}
void ComplexSearchWindow::on_selectTypeButton_clicked()
{
// This button clarifies what the user needs to enter as a criteria in the lineEdit
// If user wants to search for a Patient
if (ui->patientRadioButton->isChecked())
{
// Tell them that they can search by the Patient ID
ui->searchByTitle->setText("Search By Patient ID: ");
ui->criteriaLineEdit->setText("");
return;
}
// If user wants to search for an Appointment
else if (ui->appointmentRadioButton->isChecked())
{
// Tell them they can search by the Doctor Name, Patient Name, Fees, or Time
ui->searchByTitle->setText("Search By Doctor Name, Patient Name, Fees, or Time: ");
ui->criteriaLineEdit->setText("");
return;
}
else if (ui->doctorRadioButton->isChecked())
{
ui->searchByTitle->setText("Search By Doctor Name, Department, Fees, or Rating: ");
ui->criteriaLineEdit->setText("");
return;
}
else if (ui->emergencyVisitRadioButton->isChecked())
{
ui->searchByTitle->setText("Search by Time: ");
ui->criteriaLineEdit->setText("");
return;
}
else if (ui->roomVisitRadioButton->isChecked())
{
ui->searchByTitle->setText("Search by Room Type, Doctor Name, Patient Name, Fees or Time: ");
ui->criteriaLineEdit->setText("");
return;
}
else if (ui->homeVisitRadioButton->isChecked())
{
ui->searchByTitle->setText("Search by Patient Name or Home Address:");
ui->criteriaLineEdit->setText("");
return;
}
else
{
ui->searchResultDisplay->setText("Please Select a Type to Search for.");
ui->criteriaLineEdit->setText("");
return;
}
}
void ComplexSearchWindow::on_backButton_clicked()
{
this->close();
}