-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisitation.cpp
804 lines (582 loc) · 23.2 KB
/
visitation.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
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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
#include <iostream>
#include <Windows.h>
#include <unistd.h>
#include <string>
#include <fstream>
#include <vector>
#include <ctime>
#include <iomanip>
//#include <conio.h>
//#include <cstdlib>
#include "display.h"
#include "visitation.h"
using namespace std;
visitation::visitation(){
}
visitation::~visitation(){
}
bool visitation::add_visitation(string visitID, string docID, int type){
//v_id can be unique or same with app_id
//(1=ONE-TIME) app_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
//(2=ROUTINE) v_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
int nav;
vector<string> tempV;
vector<string> appDetail;
//get appointment detail based on app_id
//app_ID,patient_IC,app_method,day,month,year,time,priority,app_status,ms_ID
if(type==1){ //ONE-TIME VISITATION
appDetail = app4.search_appointment(visitID);
//get user detail based on userID
//verification,role,IC,name,age,gender,race,street,city,phone,email,password
if(u3.search_user(appDetail.at(1))==false){ //fail to get patient data
system("CLS"); cout << "Fail to get patient data"; sleep(2); return false;
}
}
if(hos5.get_medical_staff_hos(docID)==false){
system("CLS"); cout << "Fail to get doctor data"; sleep(2); return false;
}
tempV.push_back(visitID);
tempV.push_back(to_string(type));
start_add_visitation2:
char ch;
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "-------------------------------------------------" << endl;
cout << "Date [dd/mm/yyyy] : "; cin >> this->v_day >> ch >> this->v_month >> ch >> this->v_year;
cin.clear(); cin.ignore(INT_MAX,'\n');
if( date_is_valid(this->v_day,this->v_month,this->v_year)==false ||
date_smaller_than_today(this->v_day,this->v_month,this->v_year)==true){
system("CLS");
cout << "Your date might be: \n";
cout << ">>> invalid\n>>> smaller than today\n\n";
system("PAUSE");
goto start_add_visitation2;
}
if(visitation_clash(docID,stoi(tempV.at(1)),this->v_day,this->v_month,this->v_year)==true){
system("CLS");
cout << ">>> Date : " << this->v_day << "-" << display_month(this->v_month) << "-" << this->v_year << endl;
cout << ">>> Please change the date. It clashed with another schedule\n\n";
system("PAUSE");
goto start_add_visitation2;
}
tempV.push_back(to_string(this->v_day));
tempV.push_back(to_string(this->v_month));
tempV.push_back(to_string(this->v_year));
do{
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "-------------------------------------------------" << endl;
display_hour(0);
cout << "Time : "; cin >> this->v_time;
cin.clear(); cin.ignore(INT_MAX,'\n');
}while(this->v_time<1 || this->v_time>11);
tempV.push_back(to_string(this->v_time));
if(type==1){ //ONE-TIME VISITATION
tempV.push_back(u3.get_userStreet()); //patient street
tempV.push_back(to_string(u3.get_userCity())); //patient city
}
else if(type==2){ //ROUTINE VISITATION
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "Time : " << display_hour(stoi(tempV.at(5))) << endl;
cout << "-------------------------------------------------" << endl;
cout << "Street : "; getline(cin >> ws, this->v_street);
tempV.push_back(this->v_street);
do{
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "Time : " << display_hour(stoi(tempV.at(5))) << endl;
cout << "Street : " << tempV.at(6) << endl;
cout << "-------------------------------------------------" << endl;
display_city(0);
cout << "City : "; cin >> this->v_city;
cin.clear(); cin.ignore(INT_MAX,'\n');
}while(this->v_city<1 || this->v_city>6);
tempV.push_back(to_string(this->v_city));
}
vector<vector<string>> trans2D;
if(type==1){ //ONE-TIME VISIT
//if doctor hospital city not match then cannot
//choose transport based on
//choose only bus(1) or boat(2)
//preview
//id,docid,type
do{
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "Time : " << display_hour(stoi(tempV.at(5))) << endl;
cout << "Street : " << tempV.at(6) << endl;
cout << "City : " << display_city(stoi(tempV.at(7))) << endl;
cout << "-------------------------------------------------" << endl;
cout << " Assign Transportation " << endl;
cout << "-------------------------------------------------" << endl;
cout << "[1] Bus" << endl;
cout << "[2] Boat" << endl;
cout << "\nChoose : "; cin >> nav;
cin.clear(); cin.ignore(INT_MAX,'\n');
trans2D = trans3.search_transportation(hos5.get_hosID(),nav);
if(nav>0 && nav<=2){ //check trans availability
for(int j=0; j<trans2D.size(); j++){
if(trans3.trans_schedule_clash(trans2D[j][0],stoi(tempV.at(2)),stoi(tempV.at(3)),stoi(tempV.at(4)))==true){ //check if clashS
trans2D.erase(trans2D.begin() + j);
j=0;
}
}
}
}while(nav<1 || nav>2);
}
else if(type==2){ //ROUTINE VISIT
do{
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "Time : " << display_hour(stoi(tempV.at(5))) << endl;
cout << "Street : " << tempV.at(6) << endl;
cout << "City : " << display_city(stoi(tempV.at(7))) << endl;
cout << "-------------------------------------------------" << endl;
cout << " Assign Transportation " << endl;
cout << "-------------------------------------------------" << endl;
display_trans(0);
cout << "\nChoose : "; cin >> nav;
cin.clear(); cin.ignore(INT_MAX,'\n');
trans2D = trans3.search_transportation(hos5.get_hosID(),nav);
if(nav>0 && nav<=3){ //check trans availability
for(int j=0; j<trans2D.size(); j++){
if(trans3.trans_schedule_clash(trans2D[j][0],stoi(tempV.at(2)),stoi(tempV.at(3)),stoi(tempV.at(4)))==true){ //check if clashS
trans2D.erase(trans2D.begin() + j);
j=0;
}
}
}
}while(nav<=0 || nav>3);
}
if(trans2D.size()==0){
system("CLS");
cout << ">>> Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << ">>> No transportation are available, please choose another date.\n\n";
system("PAUSE");
return false;
}
//choose transportation (same hospital as doctor)
//trans_id,hos_ID,trans_type
int i, transType=nav ,chooseTrans;
do{
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "Time : " << display_hour(stoi(tempV.at(5))) << endl;
cout << "Street : " << tempV.at(6) << endl;
cout << "City : " << display_city(stoi(tempV.at(7))) << endl;
cout << "-------------------------------------------------" << endl;
cout << " Assign Transportation " << endl;
cout << "-------------------------------------------------" << endl;
cout << "Type : " << display_trans(transType) << endl;
cout << "-------------------------------------------------" << endl;
i=1;
for(vector<string> temp : trans2D){
cout << left << "["
<< setw(2) << i++ << "] "
<< temp.at(0) << endl;
}
cout << "\nChoose a " << display_trans(transType) << " : "; cin >> chooseTrans;
cin.clear(); cin.ignore(INT_MAX,'\n');
}while(chooseTrans<1 || chooseTrans>trans2D.size());
tempV.push_back(trans2D[chooseTrans-1][0]); //assign trans_id
//Assigning other MS
//MS must have same hos_id as doctor (same hospital)
vector<string> assignMS;
assignMS = add_ms_to_visitation(docID,stoi(tempV.at(7)),stoi(tempV.at(2)),stoi(tempV.at(3)),stoi(tempV.at(4)));
if(assignMS.size()==0){
system("CLS"); return false;
}
bool flag;
do{
flag=false;
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Add Visitation Schedule " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << tempV.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(tempV.at(1))) << endl;
cout << "Date : " << tempV.at(2) << "-" << display_month(stoi(tempV.at(3))) << "-" << tempV.at(4) << endl;
cout << "Time : " << display_hour(stoi(tempV.at(5))) << endl;
cout << "Street : " << tempV.at(6) << endl;
cout << "City : " << display_city(stoi(tempV.at(7))) << endl;
cout << "-------------------------------------------------" << endl;
cout << " Assign Transportation " << endl;
cout << "-------------------------------------------------" << endl;
cout << "Type : " << display_trans(transType) << endl;
cout << "ID : " << tempV.at(8) << endl;
cout << "-------------------------------------------------" << endl;
cout << " Assign Medical Staff " << endl;
cout << "-------------------------------------------------" << endl;
int count=1;
string data,delimiter=",", filename="../data/userData.txt";
ifstream readFile;
readFile.open(filename);
while(getline(readFile,data)){
for(int i=0; i<assignMS.size(); i++){
if(separate(data,delimiter).at(2)==assignMS.at(i)){
cout << left << "["
<< setw(2) << count++ << "] "
<< setw(20) << separate(data,delimiter).at(2)
<< separate(data,delimiter).at(3) << endl;
}
}
}
readFile.close();
cout << "-------------------------------------------------" << endl;
cout << "\nSave Visitation Schedule? [1]Yes [0]No : "; cin >> nav;
cin.clear(); cin.ignore(INT_MAX,'\n');
if(nav==1){ //save
cout << "Confirm? [1]Yes [0]No : "; cin >> nav;
cin.clear(); cin.ignore(INT_MAX,'\n');
if(nav==0){
flag=false;
}
else if(nav==1){
flag=true;
}
else{
flag=false;
}
}
else if(nav==0){ //cancel
cout << "Cancel Visitation? [1]Yes [0]No : "; cin >> nav;
cin.clear(); cin.ignore(INT_MAX,'\n');
if(nav==0){
flag=false;
}
else if(nav==1){ //canvel visitation
return false;
}
else{
flag=false;
}
}
else{
flag=false;
}
}while(flag==false);
//save visitation detail & assigned MS
save_visitation("../data/visitation.txt",tempV);
//v_id,docID,msID_1,msID_2,msID_3,...,n
assignMS.insert(assignMS.begin(),tempV.at(0)); //
assignMS.insert(assignMS.begin()+1,docID);
save_visitation("../data/visitation_medical_staff.txt",assignMS);
tempV.clear();
assignMS.clear();
return true;
}
vector<string> visitation::add_ms_to_visitation(string docID, int city, int day, int month, int year){
//get visitation city
//get docID to eliminate
//get date to check clashes
string data, delimiter=",", filename;
ifstream readFile;
hos6.get_medical_staff_hos(docID); //get doctor hospital detail
filename="../data/medical_staff_hospital.txt";
readFile.open(filename);
//ms_id,ms_type,hos_id
vector<string> matchMS;
while(getline(readFile,data)){
if(separate(data,delimiter).at(2)==hos6.get_hosID() && separate(data,delimiter).at(0)!=docID){ //same hospital (excluding himself)
matchMS.push_back(separate(data,delimiter).at(0));
}
}
readFile.close();
filename="../data/visitation.txt";
readFile.open(filename);
//v_id,v_type,v_day,v_month,v_year,v_street,v_city,v_trans_id
vector<string> matchV;
while(getline(readFile,data)){
if( stoi(separate(data,delimiter).at(2)) == day &&
stoi(separate(data,delimiter).at(3)) == month &&
stoi(separate(data,delimiter).at(4)) == year)
{
matchV.push_back(separate(data,delimiter).at(0)); //get v_id
}
}
readFile.close();
loop:
filename="../data/visitation_medical_staff.txt";
readFile.open(filename);
vector<string> tempMS;
while(getline(readFile,data)){
tempMS = separate(data,delimiter);
for(int i=0; i<matchV.size(); i++){ //v_id
for(int j=0; j<matchMS.size(); j++){ //ms_id
for(int k=1; k<tempMS.size(); k++){ //1=v_id(skip this)
//match v_id & match MSid
if(tempMS.at(0)==matchV.at(i) && tempMS.at(k)==matchMS.at(j)){
matchMS.erase(matchMS.begin()+j); //reemove those that clashes
goto loop;
}
}
}
}
}
readFile.close();
if(matchMS.size()==0){ //no available medical staff
system("CLS");
cout << ">>> No medical staff available on this date: " << day << "-" << display_month(month) << "-" << year << endl;
cout << ">>> Please reschedule\n\n";
system("PAUSE");
return matchMS;
}
vector<string> returnLine;
filename="../data/userData.txt";
int count;
bool done,dup;
do{
done=dup=false;
system("CLS");
cout << "-------------------------------------------------" << endl;
cout << " Assign Medical Staff " << endl;
cout << "-------------------------------------------------" << endl;
cout << left << "No. " << setw(20) << "IC" << "Name" << endl;
count=1;
if(returnLine.size()>0){ //chosen MS
cout << "-------------------------------------------------" << endl;
readFile.open(filename);
while(getline(readFile,data)){
for(int i=0; i<returnLine.size(); i++){
if(separate(data,delimiter).at(2)==returnLine.at(i)){
cout << left << "["
<< setw(2) << count++ << "] "
<< setw(20) << separate(data,delimiter).at(2)
<< separate(data,delimiter).at(3) << endl;
}
}
}
readFile.close();
}
cout << "-------------------------------------------------" << endl;
cout << " Select Medical Staff " << endl;
cout << "-------------------------------------------------" << endl;
count=1;
readFile.open(filename);
while(getline(readFile,data)){
for(int i=0; i<matchMS.size() ;i++){
//verification,role,IC,name,age,gender,race,street,city,phone,email,password
if(separate(data,delimiter).at(2)==matchMS.at(i)){
cout << left << "["
<< setw(2) << count++ << "] "
<< setw(20) << separate(data,delimiter).at(2)
<< separate(data,delimiter).at(3) << endl;
}
}
}
readFile.close();
int nav;
cout << "-------------------------------------------------" << endl;
if(returnLine.size()>0) cout << "\nTo remove any medical staff use negative value [-n]remove";
cout << "\nChoose [0]Done : "; cin >> nav;
cin.clear(); cin.ignore(INT_MAX,'\n');
done=false;
if(nav==0 && returnLine.size()>0){
done=true;
}
else if(nav>0 && nav<=matchMS.size()){ //good attempt
for(int i=0; i<returnLine.size(); i++){
if(matchMS.at(nav-1)==returnLine.at(i)){ //check duplication
dup=true; break;
}
}
if(dup==false) returnLine.push_back(matchMS.at(nav-1));
}
else if(nav<0 && (abs(nav)-1)<=returnLine.size() && returnLine.size()>0){ //removing MS
returnLine.erase(returnLine.begin() + abs(nav)-1 ); //using negative value to remove medical staff
}
else if(nav==0 && returnLine.size()==0){ //not yet select any symptom
system("CLS"); cout << ">>> No medical staff selected yet"; sleep(2); done=false;
}
else if(nav<0 && abs(nav)>returnLine.size()){ //removing symptom that is not in the list
system("CLS"); cout << ">>> Nothing to remove at " << nav; sleep(2); done=false;
}
else{
system("CLS"); cout << ">>> Nothing found : " << nav; sleep(2); done=false;
}
}while(done==false);
return returnLine;
}
void visitation::save_visitation(string filename, vector<string> tempLine){
ifstream readFile;
readFile.open(filename);
string delimiter = ",";
string data;
vector<vector<string>> line2D;
while(getline(readFile,data)){
line2D.push_back(separate(data,delimiter));
}
readFile.close();
int i;
bool flag=false;
for(i=0; i<line2D.size(); i++){
if(line2D[i][0]==tempLine.at(0)){ //same v_id
line2D[i] = tempLine; //replace the line
flag=true;
break;
}
}
if(flag==false) line2D.push_back(tempLine); //if data is unique
ofstream writeFile;
writeFile.open(filename);
i=0;
for(vector<string> temp1D : line2D){
writeFile << join(temp1D,delimiter) << (i<line2D.size()-1 ? "\n" : "");
i++;
}
tempLine.clear();
line2D.clear();
writeFile.close();
system("CLS"); cout << ">>> Changes are updated successfully"; sleep(2);
}
bool visitation::search_visitation(string ID){
//get v_id
string data,delimiter=",", filename="../data/visitation.txt";
ifstream readFile;
readFile.open(filename);
//(ONE-TIME) app_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
//(ROUTINE) v_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
while(getline(readFile,data)){
if(separate(data,delimiter).at(0) == ID){
this->v_id = separate(data,delimiter).at(0);
this->v_type = stoi(separate(data,delimiter).at(1));
this->v_day = stoi(separate(data,delimiter).at(2));
this->v_month = stoi(separate(data,delimiter).at(3));
this->v_year = stoi(separate(data,delimiter).at(4));
this->v_time = stoi(separate(data,delimiter).at(5));
this->v_street = separate(data,delimiter).at(6);
this->v_city = stoi(separate(data,delimiter).at(7));
this->v_trans_id = separate(data,delimiter).at(8);
readFile.close();
return true;
}
}
readFile.close();
// sytem("CLS"); cout << ">>> Visitation: "<< ID << ", details not found"; sleep(3);
return false;
}
void visitation::preview_visitation(vector<string> temp){
//(ONE-TIME) app_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
//(ROUTINE) v_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
//type,date,city,trans_id
//cout << left << "No. " << "Type" << setw(15) << "Date" << setw(15) << "City" << "Transport ID";
cout << left
<< setw(10) << display_visitation_type(stoi(temp.at(1)))
<< temp.at(2) << "-" << display_month(stoi(temp.at(3))) << "-" << temp.at(4) << "\t";
cout << left
<< setw(15) << display_city(stoi(temp.at(7)))
<< temp.at(8) << endl;
}
void visitation::fullview_visitation(vector<string> temp){
//(ONE-TIME) app_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
//(ROUTINE) v_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
cout << "-------------------------------------------------" << endl;
cout << " Visitation Detail " << endl;
cout << "-------------------------------------------------" << endl;
cout << "ID : " << temp.at(0) << endl;
cout << "Type : " << display_visitation_type(stoi(temp.at(1))) << endl;
cout << "Date : " << temp.at(2) << "-" << display_month(stoi(temp.at(3))) << "-" << temp.at(4) << endl;
cout << "Time : " << display_hour(stoi(temp.at(5))) << endl;
cout << "Address : " << temp.at(6) << ", " << display_city(stoi(temp.at(7))) << endl;
ifstream readFile;
readFile.open("../data/transportation.txt");
string data,delimiter=",";
//trans_id,hos_ID,trans_type
while(getline(readFile,data)){
if(separate(data,delimiter).at(0) == temp.at(8)){
trans3.fullview_trans_detail(separate(data,delimiter));
break;
}
}
readFile.close();
return;
}
bool visitation::visitation_clash(string docID, int type,int day,int month,int year){
string data, delimiter="," , filename;
ifstream readFile;
vector<string> temp;
vector<string> tempV;
filename="../data/visitation_medical_staff.txt";
readFile.open(filename);
//v_id,docID,msID_1,msID_2,msID_3,...,n
while(getline(readFile,data)){
temp = separate(data,delimiter);
for(int i=1; i<temp.size(); i++){
if(temp.at(i)==docID){ //found docID
tempV.push_back(temp.at(0)); //get v_id
break;
}
}
}
readFile.close();
filename="../data/visitation.txt";
readFile.open(filename);
//v_id,v_type,v_day,v_month,v_year,v_time,v_street,v_city,v_trans_id
while(getline(readFile,data)){
temp = separate(data,delimiter);
for(int i=0; i<tempV.size(); i++){
if(tempV.at(i)==temp.at(0)){ //found v_id
//check if clash
if(type==1){ //ONE-TIME
if(day==stoi(temp.at(2)) && month==stoi(temp.at(3)) && year==stoi(temp.at(4))){
return true; //clashed
}
}
else if(type=2){ //ROUTINE (check day only)
if(day==stoi(temp.at(2))){
return true; //clashed
}
}
}
}
}
readFile.close();
filename="../data/appointment.txt";
readFile.open(filename);
//app_ID,patient_IC,app_method,day,month,year,time,priority,app_status,ms_ID(9)
while(getline(readFile,data)){
temp = separate(data,delimiter);
if (temp.at(9) == docID && stoi(temp.at(7)) != 4){ //same ms_ID & not emergency
if(day==stoi(temp.at(3)) && month==stoi(temp.at(4)) && year==stoi(temp.at(5))){
return true; //clashed with appointment
}
}
}
readFile.close();
return false;
}