-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOladoc.h
454 lines (430 loc) · 14.9 KB
/
Oladoc.h
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
#pragma once
#include <iomanip>
#include "User.h"
#include "Doctor.h"
#include "Patient.h"
#include "Admin.h"
#include "Time.h"
#include "HelpingFunc.h"
#include <iostream>
class Oladoc{
Doctor* Doc=new Doctor;
Patient* Pat=new Patient;
Admin* Adm=new Admin;
public:
void menu();
};
void Display_Doc(Doctor search){
cout<<"\nDisplaying info...\n";
cout <<"Name : "<< search.getuser() << endl;
cout <<"CNIC : "<< search.getcnic() << endl;
cout <<"EMAIL: "<< search.getmail() << endl;
cout <<"Years Of Experience : "<<search.getYOP() << endl;
cout <<"Hospital : "<< search.getHospital() << endl;
search.getCharges().view_charges();
cout <<"Specialization : "<<search.getSpecialization() << endl;
cout <<"City : "<< search.getLocation() << endl;
}
ostream& operator << (ostream& out, Appointment& obj)
{
out <<"ID : "<<obj.getID()<<endl;
out <<"Name : "<< obj.getname() << endl;
out <<"Patient CNIC : "<< obj.getpcnic() << endl;
out <<"Doctor CNIC : "<< obj.getdcnic() << endl;
out <<"Type : "<<obj.gettype() << endl;
out <<"Status : "<<obj.getstatus() << endl;
out <<"Time : "<< obj.getTime() << endl;
if (obj.Feed.getstatus()){
out<<"Feedback : "<<obj.Feed.getFeedback()<<endl;
out<<"Rating : ";
for (int x=0;x<obj.Feed.getRating();x++){
cout<<'*';
}
cout<<endl;
if (obj.Feed.getRstatus()){
out<<"Feedback Response : "<<obj.Feed.getResponse()<<endl;
}
}
out <<"Charges : "<<obj.getCharge()<<endl;
out<<"Now Displaying Doctor Info...\n\n";
Doctor Find;
ifstream read("doctor_data.dat",ios::binary);
while(read.read((char*)&Find,sizeof(Find))){
if(stringCmp(Find.getcnic(),obj.getdcnic())){
Display_Doc(Find);
break;
}
}
return out;
}
void Oladoc::menu() {
int select,select1;
cout<<"Please Select :\n\t1.Login\n\t2.Register\n\t3.View Doctors\nYour Selection : ";
cin>>select;
switch(select){
case 1:
cout<<"Please Select :\n\t1.Doctor\n\t2.Patient\n\t3.Admin\nYour Selection : ";
cin>>select1;
switch(select1){
case 1:
if (Doc->login("doctor_data.dat"))
Doc->menu();
break;
case 2:
if (Pat->login("patient_data.dat"))
Pat->menu();
break;
case 3:
if (Adm->login())
Adm->menu();
break;
}
break;
case 2:
cout<<"Please Select :\n\t1.Doctor\n\t2.Patient\nYour Selection : ";
cin>>select1;
switch(select1) {
case 1:
Doc->Register();
break;
case 2:
Pat->Register();
break;
}
break;
case 3:
Doctor search;
int counter=1;
cout<<"Displaying Doctors...\n";
ifstream read("doctor_data.dat",ios::binary);
while(read.read((char*)&search,sizeof(search))){
cout<<"Doctor # "<<counter<<endl;
Display_Doc(search);
cout<<endl<<endl;
counter++;
}
read.close();
break;
}
this->menu();
}
//Sub Functions
void Doctor::view_P_data(string Patient_CNIC){
Patient search;
ifstream obj("patient_data.dat",ios::binary);
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getcnic(),Patient_CNIC)){
cout<<"Patient found !\nDisplaying info...\n";
cout<<search;
}
}
}
//Sub Functions
int Patient::search_doctors() {
Doctor search;
string tempo;
back:
cout<<"Welcome to Doctor Search Interface!\n";
cout<<"Please Select : \n\t1.Search by Specialization\n\t2.Search by Location\n\t3.Search by Hospital\n\t4.Search by CNIC\n\t5.Go Back\nSelection : ";
int select,select1;
ifstream obj("doctor_data.dat",ios::binary);
cin>>select;
switch(select){
case 1:
cout<<"\nPlease Select\n\t1.Dermatology\n\t2.Anesthesiology\n\t3.Ophthalmology\n\t4.Pediatrics\n\t5.Psychiatry\n\t6.Go Back\nSelection : ";
cin>>select1;
switch(select1){
case 1:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getSpecialization(),"Dermatology")){
Display_Doc(search);
}}
break;
case 2:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getSpecialization(),"Anesthesiology")){
Display_Doc(search);
}}
break;
case 3:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getSpecialization(),"Ophthalmology")){
Display_Doc(search);
}}
break;
case 4:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getSpecialization(),"Pediatrics")){
Display_Doc(search);
}}
break;
case 5:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getSpecialization(),"Psychiatry")){
Display_Doc(search);
}}
break;
case 6:
goto back;
}
break;
case 2:
cout<<"\nPlease Select\n\t1.Islamabad\n\t2.Gujranwala\n\t3.Lahore\n\t4.Faislabad\n\t5.Karachi\n\t6.Go Back\nSelection : ";
cin>>select1;
switch(select1){
case 1:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getLocation(),"Islamabad")){
Display_Doc(search);
}}
break;
case 2:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getLocation(),"Gujranwala")){
Display_Doc(search);
}}
break;
case 3:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getLocation(),"Lahore")){
Display_Doc(search);
}}
break;
case 4:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getLocation(),"Faislabad")){
Display_Doc(search);
}}
break;
case 5:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getLocation(),"Karachi")){
Display_Doc(search);
}}
break;
case 6:
goto back;
}
break;
case 3:
cout<<"\nPlease Select\n\t1.Shaukat Khanum Memorial\n\t2.Pakistan Institute of Medical Sciences\n\t3.Combined Medical Hospital\n\t4.Agha Khan University Hospital\n\t5.Shifa International Hospital\n\t6.Go Back\nSelection : ";
cin>>select1;
switch(select1){
case 1:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getHospital(),"Shaukat Khanum Memorial")){
Display_Doc(search);
}}
break;
case 2:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getHospital(),"Pakistan Institute of Medical Sciences")){
Display_Doc(search);
}}
break;
case 3:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getHospital(),"Combined Medical Hospital")){
Display_Doc(search);
}}
break;
case 4:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getHospital(),"Agha Khan University Hospital")){
Display_Doc(search);
}}
break;
case 5:
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getHospital(),"Shifa International Hospital")){
Display_Doc(search);
}}
break;
case 6:
goto back;
}
break;
case 4:
cout<<"Please Enter Doctor CNIC : ";
cin>>tempo;
while(obj.read((char*)&search,sizeof (search))){
if (stringCmp(search.getcnic(),tempo)){
Display_Doc(search);
break;
}}
cout<<"Would you like to see Schedule (1|0) : ";
cin>>tempo;
if (tempo=="1"){
AvailabilityFetch.view_schedule(search.getcnic());
}
break;
case 5:
return 0;
break;
}
return 1;
}
void Appointment::Add(string file_name){
ofstream obj;
obj.open(file_name, ios::binary | ios::app);
obj.write((char*)this, sizeof(*this));
obj.close();
}
int Patient::add_appointments() {
cout<<"Welcome to Appointment Creation Portal!\n";
if (UserCheckApt(CNIC)){
cout<<"An Appointment already Exists!\n";
return 1;
}
char Hospital[100];
char Location[100];
char Specialization[100];
char ID[100];
Doctor Find;
int select;
float charges;
Clock.update_time();
AppFetch.setTime(Clock);
unique:
cout<<"Enter Appointment ID (Must be Unique) : ";
cin>>ID;
if (AppFetch.IDCheck(ID)) {
cout << "ID Must be Unique!\n";
goto unique;
}
AppFetch.setID(ID);
cout<<"Please Select:\n\t1.Shaukat Khanum Memorial\n\t2.Pakistan Institute of Medical Sciences\n\t3.Combined Medical Hospital\n\t4.Agha Khan University Hospital\n\t5.Shifa International Hospital\nSelection : ";
cin>>select;
switch(select){
case 1:
strcpy(Hospital,"Shaukat Khanum Memorial");
break;
case 2:
strcpy(Hospital,"Pakistan Institute of Medical Sciences");
break;
case 3:
strcpy(Hospital,"Combined Medical Hospital");
break;
case 4:
strcpy(Hospital,"Agha Khan University Hospital");
break;
case 5:
strcpy(Hospital,"Shifa International Hospital");
break;
}
cout<<"Please Select:\n\t1.Islamabad\n\t2.Gujranwala\n\t3.Lahore\n\t4.Faislabad\n\t5.Karachi\nSelection: ";
cin>>select;
switch (select){
case 1:
strcpy(Location,"Islamabad");
break;
case 2:
strcpy(Location,"Gujranwala");
break;
case 3:
strcpy(Location,"Lahore");
break;
case 4:
strcpy(Location,"Faislabad");
break;
case 5:
strcpy(Location,"Karachi");
break;
}
cout<<"Please Select:\n\t1.Dermatology\n\t2.Anesthesiology\n\t3.Ophthalmology\n\t4.Pediatrics\n\t5.Psychiatry\nSelection: ";
cin>>select;
switch (select){
case 1:
strcpy(Specialization,"Dermatology");
break;
case 2:
strcpy(Specialization,"Anesthesiology");
break;
case 3:
strcpy(Specialization,"Ophthalmology");
break;
case 4:
strcpy(Specialization,"Pediatrics");
break;
case 5:
strcpy(Specialization,"Psychiatry");
break;
}
Doctor search;
int counter=1;
cout<<"Displaying Doctors...\n";
ifstream read("doctor_data.dat",ios::binary);
while(read.read((char*)&search,sizeof(search))){
if (stringCmp(search.getHospital(),Hospital)){
if (stringCmp(search.getLocation(),Location)){
if (stringCmp(search.getSpecialization(),Specialization)){
cout<<"Doctor # "<<counter<<endl;
Display_Doc(search);
cout<<endl<<endl;
counter++;
}
}
}
}
read.close();
char searchCNIC[100];
counter=0;
cout<<"Enter Doctor CNIC : ";
cin>>searchCNIC;
read.open("doctor_data.dat",ios::binary);
while(read.read((char*)&search,sizeof(search))){
if (stringCmp(search.getcnic(),searchCNIC)){
cout<<"Doctor Found!\n" <<endl;
Display_Doc(search);
cout<<endl<<endl;
counter++;
break;
}
}
cout<<"Please Select:\n\t1.Online Appointment\n\t2.In-Person Appointment\nSelection : ";
cin>>select;
switch(select){
case 1:
AppFetch.setType("Online");
if (Balance>search.getCharges().get_Online()){
Balance-=search.getCharges().get_Online();
cout<<search.getCharges().get_Online()<<"Balance Deducted!\n";
AppFetch.setCharge(search.getCharges().get_Online());
}
else {
cout << "Balance not enough.. Request Failed!\n";
return 1;
}
break;
case 2:
AppFetch.setType("In-Person");
if (Balance>search.getCharges().get_person()){
Balance-=search.getCharges().get_person();
cout<<search.getCharges().get_person()<<" Balance Deducted!\n";
AppFetch.setCharge(search.getCharges().get_person());
}
else {
cout << "Balance not enough.. Request Failed!\n";
return 1;
}
break;
}
Patient Search;
fstream update("patient_data.dat",ios::binary | ios::in | ios::out);
while(update.read((char*)&Search,sizeof(Search))) {
if (stringCmp(Search.CNIC,CNIC)) {
Search.Balance = Balance;
int a = update.tellg();
int size = sizeof(Search);
update.seekp(a - size);
update.write((char *) &Search, sizeof(Search));
cout<<"Balance Updated!\n";
break;
}}
AppFetch.setpcnic(CNIC);
AppFetch.setdcnic(searchCNIC);
AppFetch.setname(Username);
AppFetch.setStatus("Completed");
AppFetch.Add("appointment_data.dat");
read.close();
}