-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappointment.cpp
More file actions
517 lines (434 loc) · 15.7 KB
/
Copy pathappointment.cpp
File metadata and controls
517 lines (434 loc) · 15.7 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
/******************************
Class Appointment
Implemented by Mohammad Amir Alam Bin Rahim Omar (73563)
******************************/
/*Class Appointment implementation file*/
#include <iostream>
#include <string>
#include <fstream>
#include <conio.h>
#include "appointment.h"
#include "record.h"
#include "patient.h"
#include "doctor.h"
#include "payment.h"
using namespace std;
//Classes
Payment paym;
Patient pa;
/*Constructor*/
Appointment::Appointment(){}
/*Setter*/
void Appointment::setAppointmentID(string apid){AppointmentID = apid;}
void Appointment::setAppointmentDate(string apd){AppointmentDate = apd;}
void Appointment::setAppointmentTime(string apt) {AppointmentTime = apt;}
void Appointment::setAppointmentIllness(string apil) {AppointmentIllness = apil;}
void Appointment::setAppointmentDoctor(string apdoc) {AppointmentDoctor = apdoc;}
void Appointment::setAppointmentSpecialization(string apspe) {AppointmentSpecialization = apspe;}
/*Getter*/
string Appointment::getAppointmentID() {return AppointmentID;}
string Appointment::getAppointmentDate() {return AppointmentDate;}
string Appointment::getAppointmentTime() {return AppointmentTime;}
string Appointment::getAppointmentIllness() {return AppointmentIllness;}
string Appointment::getAppointmentDoctor() {return AppointmentDoctor;}
string Appointment::getAppointmentSpecialization() {return AppointmentSpecialization;}
//function for appointment menu
void Appointment::appMenu()
{
//variable declaration
char appOption = '0';
char key;
fflush(stdin);
system("cls");
system("Color F0");
cout << "\n";
cout << "=================================================" << endl;
cout << " SMART HEALTH CONSULTING SYSTEM " << endl;
cout << "=================================================" << endl;
cout << "-------------Patient Appointment Menu------------" << endl;
cout << "| |\n";
cout << "| 1. Add Appointment |" << endl;
cout << "| 2. Remove Appointment |" << endl;
cout << "| 3. Edit Appointment |" << endl;
cout << "| 4. View Appointment |" << endl;
cout << "| 5. Return to Patient Menu |" << endl;
cout << "| |\n";
cout << "-------------------------------------------------"<<endl;
cout << "\n";
cout << " Please enter your option (1/2/3/4/5)";
cout << "\n >> ";
cin >> appOption;
switch(appOption)
{
case '1':
addAppointment();
appMenu();
break;
case '2':
removeAppointment();
appMenu();
break;
case '3':
editAppointment();
appMenu();
break;
case '4':
viewAppointment();
appMenu();
break;
case '5':
pa.patientPlatform();
break;
default:
appMenu();
break;
}
return ;
}
//function for user to add appointment
void Appointment::addAppointment()
{
//variable declaration
string apid, apd, apt, apil, apdoc, apspe, space;;
char key;
string cost;
string kosong;
system("cls");
system("Color F0");
cout << "=====================================================" << endl;
cout << " SMART HEALTH CONSULTING SYSTEM " << endl;
cout << "=====================================================" << endl;
cout << "\n";
cout << "------------------Set Appointment------------------" << endl;
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout << "\n| Doctor's Schedule |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout << "\n| (i) - Appointment ID: APP 01 |";
cout << "\n| - Appointment Date: 5/1/2022 |";
cout << "\n| - Appointment Time: 1400 |";
cout << "\n| - Doctor: Azreen Shafieqah |";
cout << "\n| - Specialization: Paediatric (PDC) |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout << "\n| (ii) - Appointment ID: APP 02 |";
cout << "\n| - Appointment Date: 6/1/2022 |";
cout << "\n| - Appointment Time: 1500 |";
cout << "\n| - Doctor: Mohammad Amir |";
cout << "\n| - Specialization: Cardiologist (CAR) |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout << "\n| (iii) - Appointment ID: APP 03 |";
cout << "\n| - Appointment Date: 7/1/2022 |";
cout << "\n| - Appointment Time: 1600 |";
cout << "\n| - Doctor: Henry Zaynal |";
cout << "\n| - Specialization: Dermatologist (DRT) |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++\n";
cout << "\n| (iv) - Appointment ID: APP 04 |";
cout << "\n| - Appointment Date: 10/1/2022 |";
cout << "\n| - Appointment Time: 1800 |";
cout << "\n| - Doctor: Azreen Shafieqah |";
cout << "\n| - Specialization: Paediatric (PDC) |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout << "\n| (v) - Appointment ID: APP 05 |";
cout << "\n| - Appointment Date: 11/1/2022 |";
cout << "\n| - Appointment Time: 1400 |";
cout << "\n| - Doctor: Mohammad Amir |";
cout << "\n| - Specialization: Cardiologist (CAR) |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++";
cout << "\n| (vi) - Appointment ID: APP 06 |";
cout << "\n| - Appointment Date: 12/1/2022 |";
cout << "\n| - Appointment Time: 1700 |";
cout << "\n| - Doctor: Henry Zaynal |";
cout << "\n| - Specialization: Dermatologist (DRT) |";
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++\n";
cout << "\n Note: Please choose the doctor based on the appointment ID\n";
cout << " Please enter any key to continue or '0' to cancel: " << endl;
key = getch();
if(key == '0')
{
return;
}
fflush(stdin);
cout << "\n Enter new appointment ID (eg: PDC 01, CAR 02, DRT 03)";
cout << "\n [ Note: Please enter appointment ID according on the table above.]";
cout << "\n >> ";
getline(cin, AppointmentID);
fflush(stdin);
cout << "\n Enter appointment date (In DD/MM/YY format)";
cout << "\n [ Note: Please enter appointment date according on the table above.]";
cout << "\n >> ";
getline(cin, AppointmentDate);
fflush(stdin);
cout << "\n Enter appointment time (In 24-Hour format)";
cout << "\n [ Note: Please enter appointment time according on the table above.]";
cout << "\n >> ";
getline(cin, AppointmentTime);
fflush(stdin);
cout << "\n Enter illness";
cout << "\n >> ";
getline(cin, AppointmentIllness);
fflush(stdin);
cout << "\n Enter the doctor that you which to set an appointment ";
cout << "\n [Azreen/ Mohammad Amir/ Henry Zaynal] ";
cout << "\n >> ";
getline(cin, AppointmentDoctor);
fflush(stdin);
cout << "\n Enter the doctor specialization or their specialization code";
cout << "\n [(PDC) Paediatric/ (CAR) Cardiologist/ (DRT) Dermatologist] ";
cout << "\n >> ";
getline(cin, AppointmentSpecialization);
ofstream patApp;
patApp.open("Appointment.txt", ofstream::app);
patApp << getAppointmentID() << endl;
patApp << getAppointmentDate() << endl;
patApp << getAppointmentTime() << endl;
patApp << getAppointmentIllness() << endl;
patApp << getAppointmentDoctor() << endl;
patApp << getAppointmentSpecialization() << endl;
patApp.close();
cout << "\n---------------------------------------------------";
cout << "\n";
cout << "Thank you! Your appointment has been set up. " << endl;
cout << "\n";
system(" pause");
}
//function for user to remove appointment
void Appointment::removeAppointment()
{
//variable declaration
char yes_no, key;
system("cls");
system("Color F0");
cout << "=====================================================" << endl;
cout << " SMART HEALTH CONSULTING SYSTEM " << endl;
cout << "=====================================================" << endl;
cout << "\n";
cout << "-----------------Remove Appointment-----------------" << endl;
cout << "\n Do you want remove Appointment ?";
cout << "\n Note: All appointment will be removed if you choose still want to proceed";
cout << "\n Enter any key to continue or '0' to cancel: ";
key = getch();
if(key == '0')
{
return;
}
else
{
ifstream patApp;
patApp.open("Appointment.txt");
if(!patApp)
{
cout << "\n Sorry but there is no appointment recorded in the system. \n";
system(" pause");
patApp.close();
return;
}
patApp.close();
viewAppointment();
fflush(stdin);
char yes_no;
cout << " \n Enter any key to cancel all appointments/'X' to exit: ";
yes_no = getch();
if(yes_no == 'X' || yes_no == 'x')
{
cout << endl;
system(" pause");
return;
}
else
{
ofstream deleteAppointment;
deleteAppointment.open("Appointment.txt", ofstream::out | ofstream::trunc);
deleteAppointment.close();
remove("Appointment.txt");
}
cout << "\n All appointment are deleted. ";
}
system("\n pause");
}
//function for patient to edit their appointment
void Appointment::editAppointment(){
//variable declaration
string find, line, apid, apd, apt, api;
int choice;
char key;
system("cls");
system("Color F0");
cout << "=====================================================" << endl;
cout << " SMART HEALTH CONSULTING SYSTEM " << endl;
cout << "=====================================================" << endl;
cout << "\n";
cout << "-----------------Edit Appointment--------------------" << endl;
cout << "\n Do you want to edit your appointment?"<< endl;
cout << " Enter any key to continue or '0' to cancel: ";
key = getch();
if(key == '0')
{
return;
}
else
{
fflush(stdin);
cout << "\n\n Please enter your patient ID to update your appointment"<<endl;
cout << " >> ";
cin >> find;
ifstream patApp; //for reading records
patApp.open("Appointment.txt");
ofstream tempApp;
tempApp.open("tempApp.txt");
while (getline(patApp, line))
{
if (line != find)
tempApp << line << endl;
}
patApp.close();
tempApp.close();
remove("Appointment.txt"); //remove the previous appointment
rename("tempApp.txt", "Appointment.txt"); //rename the previous appointment
cout << "\n-----------------------------------------------------" << endl;
fflush(stdin);
cout << "\n Enter your new appointment ID (eg: PDC 2001, CAR 3001, DRT 4001)" << endl;
cout << " >> ";
getline(cin, AppointmentID);
fflush(stdin);
cout << "\n Enter your new appointment date (In DD/MM/YY format" << endl;
cout << " >> ";
getline(cin, AppointmentDate);
fflush(stdin);
cout << "\n Enter your new appointment time (In 24-Hour format)" << endl;
cout << " >> ";
getline(cin, AppointmentTime);
fflush(stdin);
cout << "\n Enter your new illness" << endl;
cout << " >> ";
getline(cin, AppointmentIllness);
fflush(stdin);
cout << "\n Enter a new doctor that you which to set an appointment ";
cout << "\n [Azreen/ Mohammad Amir/ Henry Zaynal] ";
cout << "\n >> ";
getline(cin, AppointmentDoctor);
fflush(stdin);
cout << "\n Enter a new doctor specialization or their specialization code";
cout << "\n [(PDC) Paediatric/ (CAR) Cardiologist/ (DRT) Dermatologist] ";
cout << "\n >> ";
getline(cin, AppointmentSpecialization);
cout << "\n-----------------------------------------------------" << endl;
cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << " ***Updated Appointment*** " << endl;
cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++\n" << endl;
cout << " " << AppointmentID << endl;
cout << " " << AppointmentDate << endl;
cout << " " << AppointmentTime << endl;
cout << " " << AppointmentIllness << endl;
cout << " " << AppointmentDoctor << endl;
cout << " " << AppointmentSpecialization << endl;
cout << "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << "\n Confirmation (Yes [1]/ Cancel [0])" << endl;
cout << " >> ";
cin >> choice;
if (choice == 0)
{
cout << " Sorry but there is no update is done! Please try again." << endl;
}
else
{
ofstream patApp;
patApp.open("Appointment.txt", ios::app | ios::out);
patApp << AppointmentID << endl;
patApp << AppointmentDate << endl;
patApp << AppointmentTime << endl;
patApp << AppointmentIllness << endl;
patApp << AppointmentDoctor << endl;
patApp << AppointmentSpecialization << endl;
cout << " Your appointment have been successfully updated in the system." << endl;
viewAppointment();
}
}
}
//function for patient to view appointment
void Appointment::viewAppointment()
{
//variable declaration
string apid, apd, apt, apil, apdoc, apspe, space;
int i = 1, n = 1;
system("cls");
system("Color F0");
cout << "=====================================================" << endl;
cout << " SMART HEALTH CONSULTING SYSTEM " << endl;
cout << "=====================================================" << endl;
cout << "\n";
cout << "---------------------Appointment---------------------" << endl;
ifstream patApp;
patApp.open("Appointment.txt");
if(!patApp)
{
cout << "\n Sorry but there is no appointment recorded in the system. ";
system("\n pause");
patApp.close();
}
else
{
while(!patApp.eof())
{
getline(patApp, AppointmentID);
getline(patApp, AppointmentDate);
getline(patApp, AppointmentTime);
getline(patApp, AppointmentIllness);
getline(patApp, AppointmentDoctor);
getline(patApp, AppointmentSpecialization);
getline(patApp, space);
fflush(stdin);
cout << "\n";
cout << " (" << n <<") AppointmentID " << i << " : " << AppointmentID << endl;
cout << " Appointment Date: " << AppointmentDate << endl;
cout << " Appointment Time : " << AppointmentTime << endl;
cout << " Ilness : " << AppointmentIllness << endl;
cout << " Doctor : " << AppointmentDoctor << endl;
cout << " Specialization : " << AppointmentSpecialization << endl;
cout << "\n";
cout << space;
i++;
n++;
}
}
patApp.close();
cout << endl;
cout << "-----------------------------------------------------" << endl;
system("\n pause");
}
//function for patient to go ro the payment page after already setting up their appointment
void Appointment::payment()
{
ifstream patApp;
patApp.open("Appointment.txt");
if(!patApp)
{
cout << " \n Sorry but there is no appointment set in the system. Please set up an appointment first before you make payment\n";
system(" pause");
patApp.close();
return;
}
patApp.close();
system("cls");
system("Color F0");
viewAppointment();
int opt;
cout << "\n Do you want to proceed with payment?( [Y] = 1 | [N] = 0) : ";
cout << "\n >> ";
cin >> opt;
if (opt == 1) //proceed with payment
{
system("cls");
paym.makePayment();
system(" pause");
return;
}
else if (opt == 0) //return to patient menu page
{
return;
}
else
{
cout << " You have entered an invalid input! Please try again." << endl;
system("cls");
payment();
}
}