-
Notifications
You must be signed in to change notification settings - Fork 1
/
hospital_management_system.cpp
280 lines (256 loc) · 12 KB
/
hospital_management_system.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
//LEYLA ABDULLAYEVA - 1904010038
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<conio.h>
#include<time.h>
#include<iomanip>
using namespace std;
int main()
//NOTE: RUN THE PROGRAM IN FULL SCREEN ONLY
{
char fname[20];
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
//printing the welcome note
re:
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
cout<<"\t\t\t\t\t@@ _______________________________________________________________________________________ @@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| WELCOME TO |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| HOSPITAL MANAGEMENT SYSTEM |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@|_______________________________________________________________________________________|@@\n";
cout<<"\t\t\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n\n\t\t\t\t\t";
system("pause");
system("cls");
int i;
int login();
login();
//giving option to the user for their choice
b:
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t HOSPITAL MANAGEMENT SYSTEM \n\n";
cout<<"\n\n\t\t\t\t\t\tPlease, Choose from the following Options: \n\n";
cout<<"\t\t\t\t\t\t _________________________________________________________________ \n";
cout<<"\t\t\t\t\t\t| |\n";
cout<<"\t\t\t\t\t\t| 1 >> Add New Patient Record |\n";
cout<<"\t\t\t\t\t\t| 2 >> Add Diagnosis Information |\n";
cout<<"\t\t\t\t\t\t| 3 >> Full History of the Patient |\n";
cout<<"\t\t\t\t\t\t| 4 >> Information About the Hospital |\n";
cout<<"\t\t\t\t\t\t| 5 >> Exit the Program |\n";
cout<<"\t\t\t\t\t\t|_________________________________________________________________|\n\n";
a:cout<<"\t\t\t\t\t\tEnter your choice: ";cin>>i;
if(i>5||i<1){cout<<"\n\n\t\t\t\t\t\tInvalid Choice\n";cout<<"\t\t\t\t\t\tTry again...........\n\n";goto a;} //if inputed choice is other than given choice
system("cls");
//displaying the information about the hospital........option 4
if(i==4)
{
ifstream file;
file.open("hos.txt");
if(!file)
{
cout<<"\nError while opening the file\n";goto b;
}
else
{
cout<<"\n\n\n\n\n\n\n\t\t\t\t\t ...........................Information about the Hospital.............................\n\n";
string line;
while(file.good())
{
getline(file,line);
cout<<line<<"\n\t\t";
}
cout<<"\n\n\t\t";
system("pause");
system("cls");
goto b;
}
}
//Adding the record of the new patient..................option 3
if(i==1)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
cout<<"\n\n\t\t\t\t\t\t\t\t"<< asctime (timeinfo);
ofstream pat_file;
char fname[20];
cout<<"\n\n\n\nEnter the patient's file name : ";
cin.ignore();
gets(fname);
pat_file.open(fname);
if(!fname)
{
cout<<"\nError while opening the file\n";goto b;
}
else
{
struct patient_info
{
char name[20];
char address[100];
char contact[10];
char age[5];
char sex[8];
char blood_gp[5];
char disease_past[50];
char id[15];
};
patient_info ak;
cout<<"\n********************************************************************\n";pat_file<<"\n********************************************************************\n\n";//fn1353 st
cout<<"\nName : ";pat_file<<"Name : ";gets(ak.name);pat_file<<ak.name<<"\n";
cout<<"\nAddress : ";pat_file<<"Address : ";gets(ak.address);pat_file<<ak.address<<"\n";
cout<<"\nContact Number : ";pat_file<<"Contact Number : ";gets(ak.contact);pat_file<<ak.contact<<"\n";
cout<<"\nAge : ";pat_file<<"Age : ";gets(ak.age);pat_file<<ak.age<<"\n";
cout<<"\nSex : ";pat_file<<"Sex : ";gets(ak.sex);pat_file<<ak.sex<<"\n";
cout<<"\nBlood Group : ";pat_file<<"Blood Group : ";gets(ak.blood_gp);pat_file<<ak.blood_gp<<"\n";
cout<<"\nAny Major disease suffered earlier : ";pat_file<<"Any Major disease suffered earlier : ";gets(ak.disease_past);pat_file<<ak.disease_past<<"\n";
cout<<"\nPatient ID : ";pat_file<<"Patient ID : ";gets(ak.id);pat_file<<ak.id<<"\n";
cout<<"\n********************************************************************\n";pat_file<<"\n********************************************************************\n\n";
cout<<"\nInformation Saved Successfully\n";
}
system("pause");
system("cls");
goto b;
}
//Appending diagnosis information of patient datewise.................option 2
if(i==2)
{
fstream pat_file;
cout<<"\n\nEnter the patient's file name to be opened : ";
cin.ignore();
gets(fname);
system("cls");
pat_file.open(fname, ios::in);
if(!pat_file)
{
cout<<"\nError while opening the file\n";goto b;
}
else
{
cout<<"\n\n\n\n\t\t\t\t........................................ Information about "<<fname<<" ........................................\n\n\n\n";
string info;
while(pat_file.good())
{
getline(pat_file,info);
cout<<info<<"\n";
}
cout<<"\n";
pat_file.close();
pat_file.open(fname, ios::out | ios::app);
cout<<"\n";
cout<<"Adding more information in patient's file................on : "<<asctime (timeinfo);pat_file<<"Description of "<<asctime (timeinfo)<<"\n";
struct app
{
char symptom[500];
char diagnosis[500];
char medicine[500];
char addmission[30];
char ward[15];
};
app add;
cout<<"\nSymptoms : "; pat_file<<"Symptoms : ";gets(add.symptom); pat_file<<add.symptom<<"\n";
cout<<"\nDiagnosis : "; pat_file<<"Diagnosis : ";gets(add.diagnosis); pat_file<<add.diagnosis<<"\n";
cout<<"\nMedicines : "; pat_file<<"Medicines : ";gets(add.medicine); pat_file<<add.medicine<<"\n";
cout<<"\nAddmission Required? : "; pat_file<<"Addmission Required? : ";gets(add.addmission); pat_file<<add.addmission<<"\n";
cout<<"\nType of ward : "; pat_file<<"Type of ward : ";gets(add.ward); pat_file<<add.ward<<"\n";pat_file<<"\n*************************************************************************\n";
cout<<"\n\n"<<add.ward<<" ward is alloted Successfully\n";
pat_file.close();
cout<<"\n\n";
system("pause");
system("cls");
goto b;
}
}
//For displaying the full medical history of patient in that hospital............option 3
if(i==3)
{
fstream pat_file;
cout<<"\n\nEnter the patient's file name to be opened : ";
cin.ignore();
gets(fname);
system("cls");
pat_file.open(fname, ios::in);
if(!pat_file)
{
cout<<"\nError while opening the file\n";goto b;
}
else
{
cout<<"\n\n\n\n\t\t\t\t........................................ Full Medical History of "<<fname<<" ........................................\n\n\n\n";
string info;
while(pat_file.good())
{
getline(pat_file,info);
cout<<info<<"\n";
}
cout<<"\n";
}
system("pause");
system("cls");
goto b;
}
//Exiting Through the system with a Thank You note........................option 5
if(i==5)
{
system("cls");
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
cout<<"\t\t\t\t\t@@ _______________________________________________________________________________________ @@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| THANK YOU FOR USING |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| HOSPITAL MANAGEMENT SYSTEM |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@| |@@\n";
cout<<"\t\t\t\t\t@@|_______________________________________________________________________________________|@@\n";
cout<<"\t\t\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n\n\t\t\t\t\t";
}
cout<<"\n";
}
int login(){
string pass ="";
char ch;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t HOSPITAL MANAGEMENT SYSTEM \n\n";
cout<<"\t\t\t\t\t\t\t\t------------------------------";
cout<<"\n\t\t\t\t\t\t\t\t\t LOGIN \n";
cout<<"\t\t\t\t\t\t\t\t------------------------------\n\n";
cout << "\t\t\t\t\t\t\t\tEnter Password: ";
ch = _getch();
while(ch != 13){//character 13 is enter
pass.push_back(ch);
cout << '*';
ch = _getch();
}
if(pass == "pass"){
cout << "\n\n\t\t\t\t\t\t\t\tAccess Granted! \n";
system("PAUSE");
system ("CLS");
}else{
cout << "\n\n\t\t\t\t\t\t\t\tAccess Aborted...\n\t\t\t\t\t\t\t\tPlease Try Again\n\n";
system("PAUSE");
system("CLS");
login();
}
}