forked from ansh8tu/Project-META
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
206 lines (185 loc) · 9.07 KB
/
main.c
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include "addPatientDetails.h"
#include "permanentCountOfPatients.h"
#include "temporaryCountOfPatients.h"
#include "deletePatientRecord.h"
#include "displayPatientDetails.h"
#include "updatePatientDetails.h"
#include "onExit.h"
#include "activeCountOfCovidCases.h"
//global variable to assign pId's to the new patients
extern int autoPId;
int main(){
//opening the autoPId file to get the last entry
FILE* readAutoPId;
readAutoPId = fopen("autoPIdStatus.txt", "r");
fscanf(readAutoPId, "%d", &autoPId);
fclose(readAutoPId);
//storing variables for switch-cases
int userChoice;
int patientChoice;
int dataAnalystChoice;
int dischargePId;
int displayDetailsPId;
int updateDetailsPId;
int passwordAuthForReceptionist, passwordAuthForDataAnalyst;
char passwordForReceptionist[20], passwordForDataAnalyst[20];
char passwordCheckForReceptionist[14] = "ab", passwordCheckForDataAnalyst[13] = "ab";
char psForR, psForDA;
int numberOfAttemptsForReceptionist = 0, numberOfAttemptsForDataAnalyst = 0;
do{
printf("\n\t\t====================================");
printf("\n\t\t|| Login as Receptionist >> 1 ||");
printf("\n\t\t|| Login as Data Analyst >> 2 ||");
printf("\n\t\t|| Exit >> 3 ||");
printf("\n\t\t====================================");
printf("\n\n\nEnter your choice: ");
scanf("%d", &userChoice);
switch(userChoice){
case 1:
do{
do{
printf("\n\nEnter Password : ");
int i=0;
while((psForR = _getch()) != 13){
passwordForReceptionist[i] = psForR;
i++;
printf("*");
}
passwordForReceptionist[i] = '\0';
printf("\n");
if(strcmp(passwordForReceptionist, passwordCheckForReceptionist) == 0){
passwordAuthForReceptionist = 1;
fflush(stdin);
}
else{
printf("\nSorry, Wrong Password! Try Again!");
printf("\n");
printf("Attempts Left = %d", 2 - numberOfAttemptsForReceptionist);
printf("\n");
passwordAuthForReceptionist = 0;
numberOfAttemptsForReceptionist++;
fflush(stdin);
}
}while(passwordAuthForReceptionist == 0 && numberOfAttemptsForReceptionist < 3);
if(passwordAuthForReceptionist ==1){
printf("\n\n\t\tHello, Receptionist!\n");
printf("\n\t\t========================================");
printf("\n\t\t|| Add Patient Entry >> 1 ||");
printf("\n\t\t|| Discharge Patient >> 2 ||");
printf("\n\t\t|| Display Patient Details >> 3 ||");
printf("\n\t\t|| Update Patient Details >> 4 ||");
printf("\n\t\t|| Return to Main Screen >> 5 ||");
printf("\n\t\t========================================");
printf("\n\n\nEnter your choice : ");
scanf("%d", &patientChoice);
printf("\n");
switch(patientChoice){
case 1:
addPatientDetails();
break;
case 2:
printf("\nEnter the P-ID of Patient that you want to discharge : ");
scanf("%d", &dischargePId);
deleteRecordFromTemporaryFile(dischargePId);
break;
case 3:
printf("\nEnter the P-ID of Patient that you want to display details for : ");
scanf("%d", &displayDetailsPId);
displayRecordForPatient(displayDetailsPId,0);
break;
case 4:
printf("\nEnter the P-ID of Patient that you want to update details for : ");
scanf("%d", &updateDetailsPId);
updateRecordForPatient(updateDetailsPId);
break;
case 5:
onExit();
break;
}
}
else{
numberOfAttemptsForReceptionist = 0;
break;
}
}while(patientChoice != 5 );
break;
case 2:
do{
do{
printf("\n\nEnter Password : ");
int i=0;
while((psForDA = _getch()) != 13){
passwordForDataAnalyst[i] = psForDA;
i++;
printf("*");
}
passwordForDataAnalyst[i] = '\0';
printf("\n");
if(strcmp(passwordForDataAnalyst, passwordCheckForDataAnalyst) == 0){
passwordAuthForDataAnalyst = 1;
fflush(stdin);
}
else{
printf("\nSorry, Wrong Password! Try Again!");
printf("\n");
printf("Attempts Left = %d", 2 - numberOfAttemptsForDataAnalyst);
printf("\n");
passwordAuthForDataAnalyst = 0;
numberOfAttemptsForDataAnalyst++;
fflush(stdin);
}
}while(passwordAuthForDataAnalyst == 0 && numberOfAttemptsForDataAnalyst < 3);
if(passwordAuthForDataAnalyst ==1){
printf("\n\n\t\tHello, Data Analyst!\n");
printf("\n\t\t=================================================================");
printf("\n\t\t|| Permanent Count of Patients >> 1 ||");
printf("\n\t\t|| Temporary Count of Patients >> 2 ||");
printf("\n\t\t|| Search Patient details in hospital records >> 3 ||");
printf("\n\t\t|| Search Patient details in active patient records >> 4 ||");
printf("\n\t\t|| Active count of covid cases >> 5 ||");
printf("\n\t\t|| Return to Main Screen >> 6 ||");
printf("\n\t\t=================================================================");
printf("\n\nEnter your choice : ");
scanf("%d", &dataAnalystChoice);
printf("\n");
int searchPId;
switch(dataAnalystChoice){
case 1:
displayNumberOfRecords();
break;
case 2:
displayTemporaryNumberOfRecords();
break;
case 3:
printf("\nEnter the P-ID of Patient that you want to search the details for in hospital record : ");
scanf("%d", &searchPId);
displayRecordForPatient(searchPId,0);
break;
case 4:
printf("\nEnter the P-ID of Patient that you want to search the details for in temporary record : ");
scanf("%d", &searchPId);
displayRecordForPatient(searchPId,1);
break;
case 5:
activeCountOfCovidPatients();
break;
case 6:
break;
}
}
else{
numberOfAttemptsForDataAnalyst = 0;
break;
}
}while(dataAnalystChoice != 6);
break;
case 3:
printf("\nThank you for your visit!\n\n");
break;
}
}while(userChoice!=3);
}