-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPatient.cpp
251 lines (234 loc) · 8.98 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
// Patients Header File
#include <iostream>
// #include <string>
// #include <cstring>
#include <bits/stdc++.h>
#ifdef WIN32
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif
#include "Patient.h"
#include "DoctorsOffice.h"
#include "Pharmacy.h"
#include "OfficeOfAcademics.h"
#define AVAILABLE 1
#define STUDENT 1
#define FACULTY 2
#define STAFF 3
#define SUCCESSFUL 1
#define YES 1
#define NO 0
int count4=0;
char Patient::currldap[40] ={0};
int Patient::loginmode = 0;
void LOGINSTART();
void Patient:: login(int mode)
{
char ldap[40], pass[40];
std::cout << "Enter LDAP ID: " ;
std::cin >> ldap;
initscr(); // enable ncurses
printw("Enter Password: ");
noecho(); // disable character echoing
getnstr(pass,sizeof(pass));
echo(); // enable character echoing again
// getch(); // Wait for a keypress
endwin(); // disable ncurses
// std::cout << std::endl;
int loginverify = OfficeOfAcademics::VerifyCredentials(ldap, pass);
if(loginverify==SUCCESSFUL)
{
std::cout << ("\n** Login Successful! **\n\n");
strcpy(currldap, ldap);
Patient::loginmode = mode;
std::cout << "What do you wish to do?\n\n";
DisplayOptions();
}
else
{
std::cout << "\n -- Login Unsuccessful! --\n\n";
std::cout << ("Enter credentials again.\n");
count4++;
if(count4==3)
{
printf("You have entered the wrong credentials three times\n\n");
::LOGINSTART();
}
login(mode);
}
}
void Patient::GetHealthRecord()
{
std::cout << "The record below shows your past visits to the health center::\n";
DoctorsOffice::viewHealthRecord(currldap);
}
void Patient:: EnquireSpecialist()
{
int repeat = YES;
do
{
std::cout << "List of Specialists::\n";
std::cout << " 1:Gastroenterologist\n";
std::cout << " 2:Gynaecologist\n";
std::cout << " 3:Paediatrician\n";
std::cout << " 4:ENT Specialist\n";
std::cout << " 5:Dermatologist\n";
std::cout << " 6:Orthopaedic Specialist\n";
std::cout << " 7:Ophthalmologist\n";
std::cout << "Please enter the corresponding no. for the specialist which you wish to enquire about: ";
int spec;
std::cin >> spec;
int *speclist;
speclist = DoctorsOffice::getSpecList();
char specname[7][40] = {"Gastroenterologist",
"Gynaecologist",
"Paediatrician",
"ENT_Specialist",
"Dermatologist",
"Orthopaedic_Specialist",
"Ophthalmologist"};
if(speclist[spec-1]==1)
{
std::cout << specname[spec-1] << " will be available this weekend.\n";
if(loginmode==FACULTY) // if faculty
{
std::cout << "Do you wish to book an appointment? (Yes/No): ";
std::string response;
std::cin >> response;
std::transform(response.begin(), response.end(), response.begin(), ::tolower);
if(response.std::string::compare("yes")==0)
{
char appt[100];
std::cout << "Please enter the date & time: " ;
fgetc(stdin);
scanf("%[^\n]s",appt);
DoctorsOffice::addToAppointments(currldap, appt);
std::cout << "Your appointment has been booked.\n" ;
}
}
}
else
{
std::cout << specname[spec-1] << " won't be available this weekend.\n" ;
std::cout << "Do you wish to put in a request for the above specialist? (Yes/No): " ;
std::string response;
std::cin >> response;
std::transform(response.begin(), response.end(), response.begin(), ::tolower);
if(response.std::string::compare("yes")==0)
{
DoctorsOffice::addSpecialistRequest(spec,loginmode); // n - mode whether faculty or student is requesting.
std::cout << "The request was successfully registered!\n" ;
}
}
std::cout << "Do you wish to perform another enquiry? (Yes/No): ";
std::string response;
std::cin >> response;
std::transform(response.begin(), response.end(), response.begin(), ::tolower);
if(response.std::string::compare("yes")==0)
{
repeat = YES;
}
else repeat = NO;
} while(repeat == YES);
}
void Patient::GetTestResults()
{
std::cout << "Enter the e-mail to which you wish to get your report mailed: \n";
char email[60];
scanf("%s",email);
}
void Patient:: MedSupp()
{
int repeat = YES;
while(repeat == YES)
{
std::cout << "Enter the medicine you wish to enquire about:\n";
char med[40];
scanf("%s",med);
int check = Pharmacy::checkMedsInPharmacy(med);
// check availability in pharmacy
if(check==AVAILABLE)
std::cout << "That medicine/supplement is currently available at the Health Center.\n";
else
{
std::cout << "That medicine/supplement isn't currently available at the Health Center.\n";
std::cout << "Would you like to put in a request for the same? (Yes/No): ";
std::string response;
std::cin >> response;
std::transform(response.begin(), response.end(), response.begin(), ::tolower);
if(response.std::string::compare("yes")==0)
{
// send the medicine's request
Pharmacy::addMedRequest(med,currldap);
std::cout << "Your request has been successfully registered.\n";
}
}
std::cout << "\nDo you wish to enquire about any other medicines/supplements? (Yes/No): ";
std::string response;
std::cin >> response;
std::transform(response.begin(), response.end(), response.begin(), ::tolower);
if(response.std::string::compare("yes")==0)
{
repeat = YES;
}
else repeat = NO;
}
}
void Patient:: DisplayOptions()
{
int repeat = YES;
int incorrectChoice = NO;
do
{
std::cout << "\nEnter your choice (The corresponding number): ";
std::cout << " 1: Get your health record\n";
std::cout << " 2: Enquire/Book Appointment for Specialist\n";
std::cout << " 3: Get Test Results\n";
std::cout << " 4: Request Medical Supplements\n";
std::cout << "Your choice - ";
int choice;
std::cin >> choice;
switch(choice)
{
case 1: //getting health record
{
GetHealthRecord();
break;
}
case 2: // enquiring regarding specialist
{
EnquireSpecialist();
break;
}
case 3: // getting test results
{
GetTestResults();
break;
}
case 4: // requeesting otc medicines
{
MedSupp();
break;
}
default:
{
std::cout << "Please enter a valid option!\n";
incorrectChoice = YES;
}
}
if(incorrectChoice == YES)
repeat = YES;
else
{
std::cout << " \nDo you wish to perform more operations as Patient? (Yes/No): ";
std::string resp1;
std::cin >> resp1;
std::transform(resp1.begin(), resp1.end(), resp1.begin(), ::tolower);
if(resp1.std::string::compare("yes")==0)
repeat = YES;
else
repeat = NO;
}
}while(repeat == YES);
}