-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHospital Booking Management System.c
464 lines (373 loc) · 15.7 KB
/
Hospital Booking Management System.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
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//1st Function: Get input from user
void getPatient(char typ_Patient[], char gender[], char name[], char icNum[], char phoneNum[], char work_History[], int *age, int *citizenship, int *registrationFee);
//2nd Function : Department
float getdepartments(char Department[4][15], char date[4][50], char hourClock[4][4], float time[50][50], int *numTreat);
//3rd Function : Calculate discount
void getCalc(int citizenship, char Citizenship[], int age, float totalTreatment, char work_History[], int registrationFee, float *TotalTreat, float *totalBill);
//4th Function : Calculate treatment
float getcalcTotalTreat(float totalTreatment, float Discount1, float Discount2);
//5th Function : Calculate Bill
float getcalctotalBill(int registrationFee, float TotalTreat);
//6th Function : Display Output
void getprint(char typ_Patient[], int numTreat, char name[], int age, char gender[], char icNum[], char phoneNum[], int citizenship, char Citizenship[], char work_History[], int registrationFee, float totalTreatment, char Department[4][15], char date[4][50], float time[50][50], char hourClock[4][4], float totalTreat, float totalBill);
int main()
{
//declaration for function 1
char typ_Patient[10], gender[10], name[50], icNum[15], phoneNum[15], work_History[5];
int age, citizenship, registrationFee, i, j, numTreat;
char Citizenship[15], date[4][50], hourClock[4][4], Department[4][15];
float totalTreatment, time[50][50], TotalTreat, totalBill;
//1st Function
getPatient(typ_Patient, gender, name, icNum, phoneNum, work_History, &age, &citizenship, ®istrationFee);
totalTreatment = getdepartments(Department, date, hourClock, time, &numTreat);
getCalc(citizenship, Citizenship, age, totalTreatment, work_History, registrationFee, &TotalTreat, &totalBill);
getprint(typ_Patient, numTreat, name, age, gender, icNum, phoneNum, citizenship, Citizenship, work_History, registrationFee, totalTreatment, Department, date, time, hourClock, TotalTreat, totalBill);
}
void getPatient(char typ_Patient[], char gender[], char name[], char icNum[], char phoneNum[], char work_History[], int *age, int *citizenship, int *registrationFee)
{
system("COLOR 50");
printf("\n\t\t\t\t\t\tHOSPITAL PANTAI MELAKA\n");
printf("\t\t\t\t\t\tAPPOINTMENT BOOKING SYSTEM\n");
printf("\t\t\t\t\t=========================================\n");
printf("\n\tAre you New or Usual Patient? [New/Usual] : ");
scanf(" %s", typ_Patient);
if((strcmp(typ_Patient, "New"))==0)
{
FILE *fpointer;
fpointer = fopen("NewPatient.txt","w");
printf("\n\tPlease enter your name : ");
scanf(" %[^\n]", name);
fprintf(fpointer,"PATIENT NAME\n");
fprintf(fpointer,"\n%s", name);
fclose(fpointer);
}
else
{
FILE *fpointer;
fpointer = fopen("UsualPatient.txt","w");
printf("\n\tPlease enter your name : ");
scanf(" %[^\n]", name);
fprintf(fpointer,"PATIENT NAME\n");
fprintf(fpointer,"\n%s", name);
fclose(fpointer);
}
printf("\n\tPlease enter your age : ");
scanf("%d", age);
printf("\n\tPlease enter your gender [Female/Male] : ");
scanf("%s", gender);
printf("\n\tPlease enter your IC number : ");
scanf("%s", icNum);
printf("\n\tPlease enter your phone number : ");
scanf("%s", phoneNum);
printf("\n\tPlease state your nationality [citizen(1)/foreigner(0)] : ");
scanf("%d", citizenship);
printf("\n\tDo you or any of your family members work for the government? [yes/no]: ");
scanf("%s", work_History);
//decision for type patient
if(strcmp(typ_Patient, "new") == 0)
{
*registrationFee = 5;
}
else if(strcmp(typ_Patient, "New") == 0)
{
*registrationFee = 5;
}
else
{
*registrationFee = 0;
}
}
float getdepartments(char Department[4][15], char date[4][50], char hourClock[4][4], float time[50][50], int *numTreat)
{
int i, proceed, j, fexit, treatmentFee, x;
const char * listDepart[] = {"A","B","C","D"};
char valid[15];
char department[4][4];
float totalTreatment;
do
{
proceed = 0;
totalTreatment = 0;
printf("\n\tHow many treatment do you want to book? : ");
scanf("%d", numTreat);
//looping for 1
for ( j=0; j < *numTreat; j++)
{
system("cls");
FILE * fPointer;
fPointer = fopen("ListDepartment.txt","r");
char line[120];
while(!feof(fPointer))
{
fgets(line,120,fPointer);
printf(line);
}
fclose(fPointer);
printf("\tPlease choose health department based on injury : ");
scanf(" %s", department[j]);
printf("\n\tEnter date of Appointment [dd/mm/yy] : ");
scanf(" %s", date[j]);
printf("\n\tEnter time of Appointment : ");
scanf("%f", time[j]);
printf("\n\tEnter hour Clock of Appointment [am/pm] : ");
scanf(" %s", hourClock[j]);
//decision for department & validation
if((strcmp(department[j], listDepart[0]))==0)
{
char V1[15] = "APPROVED!";
strcpy(valid, V1);
char D1[15] = "Psychology";
strcpy(Department[j], D1);
treatmentFee = 100;
}
else if((strcmp(department[j], listDepart[1]))==0)
{
char V2[15] = "APPROVED!";
strcpy(valid, V2);
char D2[15] = "Dermatology";
strcpy(Department[j], D2);
treatmentFee = 120;
}
else if((strcmp(department[j], listDepart[2]))==0)
{
char V3[15] = "APPROVED!";
strcpy(valid, V3);
char D3[15] = "Cardiology";
strcpy(Department[j], D3);
treatmentFee = 130;
}
else if((strcmp(department[j], listDepart[3]))==0)
{
char V4[15] = "APPROVED!";
strcpy(valid, V4);
char D4[15] = "Neurology";
strcpy(Department[j], D4);
treatmentFee = 150;
}
else
{
char V5[15] = "CANCELLED!";
strcpy(valid, V5);
char D5[15] = "WRONG DEPART!";
strcpy(Department[j], D5);
treatmentFee = 0;
}
totalTreatment = totalTreatment + treatmentFee;
//calculate total treatment
}
//input for output
printf("\n\tDo you want to submit(0) or not(1) : ");
scanf("%d", &fexit);
//output 1 - if user not submit the appointment
if(fexit == 1)
{
printf("\n\n\tYOUR APPOINTMENT IS BEEN CANCELLED BY YOU");
//input for do-while looping
printf("\n\n\tDo you want to make new appointment[1-yes/0-No] : ");
scanf("%d", &proceed);
if(proceed == 0)
{
exit(0);
}
}
}while(proceed != 0);
return totalTreatment;
}
void getCalc(int citizenship, char Citizenship[], int age, float totalTreatment, char work_History[], int registrationFee, float *TotalTreat, float *totalBill)
{
float Discount1, Discount2;
if(citizenship == 1)
{
char c1[15] ="Citizen";
strcpy(Citizenship, c1);
//decision Discount1
if(age >= 50)
{
Discount1 = totalTreatment * 0.15;
//decision Discount2
if(strcmp("Yes", work_History) == 0)
{
Discount2 = totalTreatment * 0.25;
}
else if(strcmp("yes", work_History) == 0)
{
Discount2 = totalTreatment * 0.25;
}
else
{
Discount2 = totalTreatment * 0;
}
}
else if(age <= 12)
{
Discount1 = totalTreatment * 0.05;
if(strcmp("Yes", work_History) == 0)
{
Discount2 = totalTreatment * 0.15;
}
else if(strcmp("yes", work_History) == 0)
{
Discount2 = totalTreatment * 0.15;
}
else
{
Discount2 = totalTreatment * 0;
}
}
else
{
Discount1 = totalTreatment * 0;
if(strcmp("Yes", work_History) == 0)
{
Discount2 = totalTreatment * 0.25;
}
else if(strcmp("yes", work_History) == 0)
{
Discount2 = totalTreatment * 0.25;
}
else
{
Discount2 = totalTreatment * 0;
}
}
}
else //Discount1
{
char c2[15] = "Foreigner";
strcpy(Citizenship, c2);
//Discount2
if(age >= 60)
{
Discount1 = totalTreatment * 0.10;
}
else if(age <= 12)
{
Discount1 = totalTreatment * 0.05;
}
else
{
Discount1 = totalTreatment * 0;
}
}
//calculation
*TotalTreat = getcalcTotalTreat(totalTreatment, Discount1, Discount2);
*totalBill = getcalctotalBill(registrationFee, *TotalTreat);
}
float getcalcTotalTreat(float totalTreatment, float Discount1, float Discount2)
{
float totalTreat;
totalTreat = totalTreatment - Discount1 - Discount2;
return totalTreat;
}
float getcalctotalBill(int registrationFee, float TotalTreat)
{
float totalbill;
totalbill = registrationFee + TotalTreat;
return totalbill;
}
void getprint(char typ_Patient[], int numTreat, char name[], int age, char gender[], char icNum[], char phoneNum[], int citizenship, char Citizenship[], char work_History[], int registrationFee, float totalTreatment, char Department[4][15], char date[4][50], float time[50][50], char hourClock[4][4], float TotalTreat, float totalBill)
{
int j, i;
system("cls");
printf("\n\t\t\t\t\t\tAPPOINTMENT BOOKING RECEIPT\n========================================================================================================================\n");
printf("\n\t\t\t\t\t\tPatient Detail\n\t\t\t\t\t-------------------------------------\n");
//printf("\nType of patient : %s" ,typ_Patient);
printf("\n\t\t\t\t\tName : %s", name);
printf("\n\t\t\t\t\tAge : %d", age);
printf("\n\t\t\t\t\tGender : %s", gender);
printf("\n\t\t\t\t\tIC number : %s", icNum);
printf("\n\t\t\t\t\tPhone number : %s", phoneNum);
//condition for output citizenship
if(citizenship == 1)
{
char c1[15] ="Citizen";
strcpy(Citizenship, c1);
}
else
{
char c2[15] = "Foreigner";
strcpy(Citizenship, c2);
}
printf("\n\t\t\t\t\tCitizenship : %s", Citizenship);
//condition for output work history
if(strcmp("Yes", work_History) == 0)
{
printf("\n\t\t\t\t\tGovernment worker : Yes");
}
else if(strcmp("yes", work_History) == 0)
{
printf("\n\t\t\t\t\tGovernment worker : Yes");
}
else
{
printf("\n\t\t\t\t\tGovernment worker : No");
}
printf("\n\n\t\t\t\t\t\tAppointment Detail\n\t\t\t\t\t-------------------------------------\n");
for(j=0; j< numTreat; j++)
{
printf("\n\t\t\t\t\tDepartment : %s", Department[j]);
printf("\n\t\t\t\t\tDate of appointment : %s", date[j]);
for(i=0; i< 1; i++)
{
printf("\n\t\t\t\t\tTime of appointment : %.2f %s", time[j][i], hourClock[j]);
}
}
printf("\n\t\t\t\t\tRegistration fee : RM %d", registrationFee);
printf("\n\t\t\t\t\tTreatment Fee : RM %.2f", totalTreatment);
printf("\n\n\t\t\t\t\t\tPayment Detail\n\t\t\t\t\t-------------------------------------\n");
printf("\n\n\t\t\t\t\tTotal treat : RM %.2f", TotalTreat);
printf("\n\t\t\t\t\tTotal bill : RM %.2f\n", totalBill);
FILE *fpointer;
fpointer = fopen("AppointmentReceipt.txt","w");
fprintf(fpointer,"\n\t\t\t\t\t\tAPPOINTMENT BOOKING RECEIPT\n\t\t\t\t\t========================================================================================================================\n");
fprintf(fpointer,"\n\t\t\t\t\t\tPatient Detail\n\t\t\t\t\t-------------------------------------\n");
//printf("\nType of patient : %s" ,typ_Patient);
fprintf(fpointer,"\n\t\t\t\t\tName : %s", name);
fprintf(fpointer,"\n\t\t\t\t\tAge : %d", age);
fprintf(fpointer,"\n\t\t\t\t\tGender : %s", gender);
fprintf(fpointer,"\n\t\t\t\t\tIC number : %s", icNum);
fprintf(fpointer,"\n\t\t\t\t\tPhone number : %s", phoneNum);
//condition for output citizenship
if(citizenship == 1)
{
char c1[15] ="Citizen";
strcpy(Citizenship, c1);
}
else
{
char c2[15] = "Foreigner";
strcpy(Citizenship, c2);
}
fprintf(fpointer,"\n\t\t\t\t\tCitizenship : %s", Citizenship);
//condition for output work history
if(strcmp("Yes", work_History) == 0)
{
fprintf(fpointer,"\n\t\t\t\t\tGovernment worker : Yes");
}
else if(strcmp("yes", work_History) == 0)
{
fprintf(fpointer,"\n\t\t\t\t\tGovernment worker : Yes");
}
else
{
fprintf(fpointer,"\n\t\t\t\t\tGovernment worker : No");
}
fprintf(fpointer,"\n\n\t\t\t\t\t\tAppointment Detail\n\t\t\t\t\t-------------------------------------\n");
for(j=0; j< numTreat; j++)
{
fprintf(fpointer,"\n\t\t\t\t\tDepartment : %s", Department[j]);
fprintf(fpointer,"\n\t\t\t\t\tDate of appointment : %s", date[j]);
for(i=0; i< 1; i++)
{
fprintf(fpointer,"\n\t\t\t\t\tTime of appointment : %.2f %s", time[j][i], hourClock[j]);
}
}
fprintf(fpointer,"\n\t\t\t\t\tRegistration fee : RM %d", registrationFee);
fprintf(fpointer,"\n\t\t\t\t\tTreatment Fee : RM %.2f", totalTreatment);
fprintf(fpointer,"\n\n\t\t\t\t\t\tPayment Detail\n\t\t\t\t\t-------------------------------------\n");
fprintf(fpointer,"\n\n\t\t\t\t\tTotal treat : RM %.2f", TotalTreat);
fprintf(fpointer,"\n\t\t\t\t\tTotal bill : RM %.2f\n", totalBill);
}