forked from ansh8tu/Project-META
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddPatientDetails.h
More file actions
107 lines (75 loc) · 4.04 KB
/
addPatientDetails.h
File metadata and controls
107 lines (75 loc) · 4.04 KB
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
#ifndef ADDPATIENTDETAILS_H
#define ADDPATIENTDETAILS_H
typedef struct Patients{
int pId;
char pFirstName[30];
char pLastName[30];
int pAge;
char pDiesase[30];
int pCovidStatus;
} Patient;
int displayTemporaryNumberOfRecords();
int flag = 0;
int autoPId;
void addPatientDetails(){
int tempVar = displayTemporaryNumberOfRecords();
int numberOfPatients;
printf("\nEnter the number of patients to add : "); //do update the printf statement in original project
scanf("%d", &numberOfPatients);
fflush(stdin);
int capacityOfHospital = 8;
if(tempVar + numberOfPatients >= capacityOfHospital){
printf("Hospital is Overcrowded, Sorry for the inconvinience!");
printf("\n");
printf("Max Patients allowed to enter : %d", (capacityOfHospital - tempVar));
return;
}
Patient* pat = (Patient*)calloc(numberOfPatients, sizeof(Patient));
FILE* patientLog;
FILE* tempLog;
patientLog = fopen("HospitalRecord.txt", "a");
tempLog = fopen("TemporaryRecord.txt", "a");
int previousEntry = autoPId - 1000;
int i;
for(i=previousEntry; i<numberOfPatients + previousEntry; i++){
//assigning the patient ID
pat[i - previousEntry].pId = autoPId;
autoPId++;
printf("\n\n///////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ");
printf("\n\n Enter the patient's first name : ");
scanf("%s", pat[i - previousEntry].pFirstName);
fflush(stdin);
printf("\n Enter the patient's last name : ");
scanf("%s", pat[i - previousEntry].pLastName);
fflush(stdin);
printf("\n Enter the patient's age : ");
scanf("%d", &pat[i - previousEntry].pAge);
fflush(stdin);
printf("\n Enter the patient's disease/Symptoms : ");
scanf("%s", pat[i - previousEntry].pDiesase);
fflush(stdin);
printf("\n Enter the patient's covid status(1-Positive 0-Negative) : ");
scanf("%d", &pat[i - previousEntry].pCovidStatus);
fflush(stdin);
fprintf(patientLog, "%d %s %s %d %s %d %s", pat[i - previousEntry].pId, pat[i - previousEntry].pFirstName, pat[i - previousEntry].pLastName, pat[i - previousEntry].pAge, pat[i - previousEntry].pDiesase, pat[i - previousEntry].pCovidStatus, "\n");
fprintf(tempLog, "%d %s %s %d %s %d %s", pat[i - previousEntry].pId, pat[i - previousEntry].pFirstName, pat[i - previousEntry].pLastName, pat[i - previousEntry].pAge, pat[i - previousEntry].pDiesase, pat[i - previousEntry].pCovidStatus, "\n");
printf("\n Hello %s %s, your Patient-ID is : %d \n", pat[i - previousEntry].pFirstName, pat[i - previousEntry].pLastName, pat[i - previousEntry].pId);
if((strcmp(pat[i - previousEntry].pDiesase, "Cold") == 0) || (strcmp(pat[i - previousEntry].pDiesase, "Cough") == 0) || (strcmp(pat[i - previousEntry].pDiesase, "Diarrhea") == 0)){
printf("\n Please refer to %s specialist in Ward-101\n", pat[i - previousEntry].pDiesase);
}else if(strcmp(pat[i - previousEntry].pDiesase, "Fatigue") == 0 || strcmp(pat[i - previousEntry].pDiesase, "Fever") == 0 || strcmp(pat[i - previousEntry].pDiesase, "Headache") == 0){
printf("\n Please refer to %s specialist in Ward-102\n", pat[i - previousEntry].pDiesase);
}else if(strcmp(pat[i - previousEntry].pDiesase, "Nausea") == 0 || strcmp(pat[i - previousEntry].pDiesase, "SoreThroat") == 0 || strcmp(pat[i - previousEntry].pDiesase, "Tastelessness") == 0){
printf("\n Please refer to %s specialist in Ward-103\n", pat[i - previousEntry].pDiesase);
}else{
printf("\n Please refer to General Ward!\n");
}
printf("\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ///////////////////////////////// \n");
}
FILE* writeAutoPId;
writeAutoPId = fopen("autoPIdStatus.txt", "w");
fprintf(writeAutoPId, "%d", autoPId);
fclose(writeAutoPId);
fclose(patientLog);
fclose(tempLog);
}
#endif