|
| 1 | +//Hospital Management System .....Brought to you by Tayyaba 2nd Semester, Section 'C' |
| 2 | +#include<iostream> |
| 3 | +#include<fstream> |
| 4 | +#include<cstdlib> |
| 5 | +#include<conio.h> |
| 6 | + |
| 7 | +using namespace std; |
| 8 | +int main() |
| 9 | + |
| 10 | +//NOTE: RUN THE PROGRAM IN FULL SCREEN ONLY |
| 11 | + |
| 12 | +{ |
| 13 | +char fname[20]; |
| 14 | + |
| 15 | +//printing the welcome note |
| 16 | + |
| 17 | +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"; |
| 18 | +cout<<"\t\t\t\t\t*********************************************************************************************\n"; |
| 19 | +cout<<"\t\t\t\t\t** _______________________________________________________________________________________ **\n"; |
| 20 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 21 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 22 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 23 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 24 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 25 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 26 | +cout<<"\t\t\t\t\t**| WELCOME TO |**\n"; |
| 27 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 28 | +cout<<"\t\t\t\t\t**| HOSPITAL MANAGEMENT SYSTEM |**\n"; |
| 29 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 30 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 31 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 32 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 33 | +cout<<"\t\t\t\t\t**| |**\n"; |
| 34 | +cout<<"\t\t\t\t\t**| -Brought To You by Tayyaba 2nd Semester, Section 'C' |**\n"; |
| 35 | +cout<<"\t\t\t\t\t**|_______________________________________________________________________________________|**\n"; |
| 36 | +cout<<"\t\t\t\t\t*********************************************************************************************\n"; |
| 37 | +cout<<"\t\t\t\t\t*********************************************************************************************\n"; |
| 38 | +system("pause"); |
| 39 | +system("cls"); |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +int i; |
| 44 | +int login(); |
| 45 | +login(); |
| 46 | +//giving option to the user for their choice |
| 47 | +b: |
| 48 | +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"; |
| 49 | +cout<<"\n\n\t\t\t\t\t\tPlease, Choose from the following Options: \n\n"; |
| 50 | +cout<<"\t\t\t\t\t\t _________________________________________________________________ \n"; |
| 51 | +cout<<"\t\t\t\t\t\t| |\n"; |
| 52 | +cout<<"\t\t\t\t\t\t| 1 >> Add New Patient Record |\n"; |
| 53 | +cout<<"\t\t\t\t\t\t| 2 >> Add Diagnosis Information |\n"; |
| 54 | +cout<<"\t\t\t\t\t\t| 3 >> Full History of the Patient |\n"; |
| 55 | +cout<<"\t\t\t\t\t\t| 4 >> Information About the Hospital |\n"; |
| 56 | +cout<<"\t\t\t\t\t\t| 5 >> Exit the Program |\n"; |
| 57 | +cout<<"\t\t\t\t\t\t|_________________________________________________________________|\n\n"; |
| 58 | +a:cout<<"\t\t\t\t\t\tEnter your choice: ";cin>>i; |
| 59 | +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 |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +system("cls"); |
| 64 | + |
| 65 | +//displaying the information about the hospital........option 4 |
| 66 | +if(i==4) |
| 67 | +{ |
| 68 | + ifstream file; |
| 69 | + file.open("hos.txt"); |
| 70 | + if(!file) |
| 71 | + { |
| 72 | + cout<<"\nError while opening the file\n";goto b; |
| 73 | + } |
| 74 | + else |
| 75 | + { |
| 76 | + cout<<"\n\n\n\n\n\n\n\t\t\t\t\t ...........................Information about the Hospital.............................\n\n"; |
| 77 | + string line; |
| 78 | + while(file.good()) |
| 79 | + { |
| 80 | + getline(file,line); |
| 81 | + cout<<line<<"\n\t\t"; |
| 82 | + } |
| 83 | + cout<<"\n\n\t\t"; |
| 84 | + system("pause"); |
| 85 | + system("cls"); |
| 86 | + goto b; |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +//Adding the record of the new patient..................option 3 |
| 91 | +if(i==1) |
| 92 | +{ |
| 93 | + ofstream pat_file; |
| 94 | + char fname[20]; |
| 95 | + cout<<"\n\n\n\nEnter the patient's file name : "; |
| 96 | + cin.ignore(); |
| 97 | + gets(fname); |
| 98 | + pat_file.open(fname); |
| 99 | + if(!fname) |
| 100 | + { |
| 101 | + cout<<"\nError while opening the file\n";goto b; |
| 102 | + } |
| 103 | + else |
| 104 | + { |
| 105 | + struct patient_info |
| 106 | + { |
| 107 | + char id[15]; |
| 108 | + char name[20]; |
| 109 | + char address[100]; |
| 110 | + char contact[10]; |
| 111 | + char age[5]; |
| 112 | + char sex[8]; |
| 113 | + char blood_gp[5]; |
| 114 | + char disease_past[50]; |
| 115 | + }; |
| 116 | + |
| 117 | + patient_info ak; |
| 118 | + cout<<"\n********************************************************************\n";pat_file<<"\n********************************************************************\n\n"; |
| 119 | + cout<<"\nPatient ID : ";pat_file<<"Patient ID : ";gets(ak.id);pat_file<<ak.id<<"\n"; |
| 120 | + cout<<"\nName : ";pat_file<<"Name : ";gets(ak.name);pat_file<<ak.name<<"\n"; |
| 121 | + cout<<"\nAddress : ";pat_file<<"Address : ";gets(ak.address);pat_file<<ak.address<<"\n"; |
| 122 | + cout<<"\nContact Number : ";pat_file<<"Contact Number : ";gets(ak.contact);pat_file<<ak.contact<<"\n"; |
| 123 | + cout<<"\nAge : ";pat_file<<"Age : ";gets(ak.age);pat_file<<ak.age<<"\n"; |
| 124 | + cout<<"\nSex : ";pat_file<<"Sex : ";gets(ak.sex);pat_file<<ak.sex<<"\n"; |
| 125 | + cout<<"\nBlood Group : ";pat_file<<"Blood Group : ";gets(ak.blood_gp);pat_file<<ak.blood_gp<<"\n"; |
| 126 | + cout<<"\nAny Major disease suffered earlier : ";pat_file<<"Any Major disease suffered earlier : ";gets(ak.disease_past);pat_file<<ak.disease_past<<"\n"; |
| 127 | + cout<<"\n********************************************************************\n";pat_file<<"\n********************************************************************\n\n"; |
| 128 | + cout<<"\nInformation Saved Successfully\n"; |
| 129 | + } |
| 130 | + system("pause"); |
| 131 | + system("cls"); |
| 132 | + goto b; |
| 133 | + |
| 134 | +} |
| 135 | + |
| 136 | +//Appending diagnosis information of patient datewise.................option 2 |
| 137 | +if(i==2) |
| 138 | +{ |
| 139 | + fstream pat_file; |
| 140 | + cout<<"\n\nEnter the patient's file name to be opened : "; |
| 141 | + cin.ignore(); |
| 142 | + gets(fname); |
| 143 | + system("cls"); |
| 144 | + pat_file.open(fname, ios::in); |
| 145 | + if(!pat_file) |
| 146 | + { |
| 147 | + cout<<"\nError while opening the file\n";goto b; |
| 148 | + } |
| 149 | + else |
| 150 | + { |
| 151 | + cout<<"\n\n\n\n\t\t\t\t........................................ Information about "<<fname<<" ........................................\n\n\n\n"; |
| 152 | + string info; |
| 153 | + while(pat_file.good()) |
| 154 | + { |
| 155 | + getline(pat_file,info); |
| 156 | + cout<<info<<"\n"; |
| 157 | + } |
| 158 | + cout<<"\n"; |
| 159 | + pat_file.close(); |
| 160 | + pat_file.open(fname, ios::out | ios::app); |
| 161 | + cout<<"\n"; |
| 162 | + cout<<"Adding more information in patient's file................ : "<<"\n"; |
| 163 | + struct app |
| 164 | + { |
| 165 | + char symptom[500]; |
| 166 | + char diagnosis[500]; |
| 167 | + char medicine[500]; |
| 168 | + char addmission[2]; |
| 169 | + char ward[15]; |
| 170 | + }; |
| 171 | + app add; |
| 172 | + cout<<"\nSymptoms : "; pat_file<<"Symptoms : ";gets(add.symptom); pat_file<<add.symptom<<"\n"; |
| 173 | + cout<<"\nDiagnosis : "; pat_file<<"Diagnosis : ";gets(add.diagnosis); pat_file<<add.diagnosis<<"\n"; |
| 174 | + cout<<"\nMedicines : "; pat_file<<"Medicines : ";gets(add.medicine); pat_file<<add.medicine<<"\n"; |
| 175 | + cout<<"\nAddmission Required? : "; pat_file<<"Addmission Required? : ";gets(add.addmission); pat_file<<add.addmission<<"\n"; |
| 176 | + if(add.addmission != "no") |
| 177 | + { |
| 178 | + cout<<"\nType of ward : "; pat_file<<"Type of ward : ";gets(add.ward); pat_file<<add.ward<<"\n";pat_file<<"\n*************************************************************************\n"; |
| 179 | + cout<<"\n\n"<<add.ward<<" ward is alloted Successfully\n"; |
| 180 | + } |
| 181 | + |
| 182 | + pat_file.close(); |
| 183 | + cout<<"\n\n"; |
| 184 | + system("pause"); |
| 185 | + system("cls"); |
| 186 | + goto b; |
| 187 | + } |
| 188 | +} |
| 189 | + |
| 190 | +//For displaying the full medical history of patient in that hospital............option 3 |
| 191 | +if(i==3) |
| 192 | +{ |
| 193 | + fstream pat_file; |
| 194 | + cout<<"\n\nEnter the patient's file name to be opened : "; |
| 195 | + cin.ignore(); |
| 196 | + gets(fname); |
| 197 | + system("cls"); |
| 198 | + pat_file.open(fname, ios::in); |
| 199 | + if(!pat_file) |
| 200 | + { |
| 201 | + cout<<"\nError while opening the file\n";goto b; |
| 202 | + } |
| 203 | + else |
| 204 | + { |
| 205 | + cout<<"\n\n\n\n\t\t\t\t........................................ Full Medical History of "<<fname<<" ........................................\n\n\n\n"; |
| 206 | + string info; |
| 207 | + while(pat_file.good()) |
| 208 | + { |
| 209 | + getline(pat_file,info); |
| 210 | + cout<<info<<"\n"; |
| 211 | + } |
| 212 | + cout<<"\n"; |
| 213 | + } |
| 214 | + system("pause"); |
| 215 | + system("cls"); |
| 216 | + goto b; |
| 217 | +} |
| 218 | + |
| 219 | +//Exiting Through the system with a Thank You note........................option 5 |
| 220 | +if(i==5) |
| 221 | +{ |
| 222 | +system("cls"); |
| 223 | +cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"; |
| 224 | +cout<<"\t\t\t\t\t@@ _______________________________________________________________________________________ @@\n"; |
| 225 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 226 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 227 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 228 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 229 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 230 | +cout<<"\t\t\t\t\t@@| THANK YOU FOR USING |@@\n"; |
| 231 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 232 | +cout<<"\t\t\t\t\t@@| HOSPITAL MANAGEMENT SYSTEM |@@\n"; |
| 233 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 234 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 235 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 236 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 237 | +cout<<"\t\t\t\t\t@@| |@@\n"; |
| 238 | +cout<<"\t\t\t\t\t@@| -Brought To You by Tayyaba 2nd Semester, Section 'C' |@@\n"; |
| 239 | +cout<<"\t\t\t\t\t@@|_______________________________________________________________________________________|@@\n"; |
| 240 | +cout<<"\t\t\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n\n\n\t\t\t\t\t"; |
| 241 | +} |
| 242 | + |
| 243 | + |
| 244 | +cout<<"\n"; |
| 245 | + |
| 246 | +} |
| 247 | + |
| 248 | +int login(){ |
| 249 | + string pass = ""; |
| 250 | + char ch; |
| 251 | + 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"; |
| 252 | + cout<<"\t\t\t\t\t\t\t\t------------------------------"; |
| 253 | + cout<<"\n\t\t\t\t\t\t\t\t\t LOGIN \n"; |
| 254 | + cout<<"\t\t\t\t\t\t\t\t------------------------------\n\n"; |
| 255 | + cout << "\t\t\t\t\tEnter Password: "; |
| 256 | + ch = _getch(); |
| 257 | + int i = 0; |
| 258 | + while(ch != 13){ //character 13 is enter |
| 259 | + if(ch!=8) { |
| 260 | + pass.push_back(ch); |
| 261 | + cout<<"*"; |
| 262 | + i++; |
| 263 | + } |
| 264 | + else { |
| 265 | + if(i!=0) { |
| 266 | + i--; |
| 267 | + pass.erase(i); |
| 268 | + cout<<"\b \b"; |
| 269 | + } |
| 270 | + } |
| 271 | + ch = _getch(); |
| 272 | + } |
| 273 | + ifstream f; |
| 274 | + f.open("password.txt", ios::in); |
| 275 | + string passOfFile; |
| 276 | + getline(f, passOfFile); |
| 277 | + f.close(); |
| 278 | + if(pass == passOfFile){ |
| 279 | + cout << "\n\n\t\t\t\t\t\t\t\tAccess Granted! \n"; |
| 280 | + system("PAUSE"); |
| 281 | + system ("CLS"); |
| 282 | + }else{ |
| 283 | + 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"; |
| 284 | + system("PAUSE"); |
| 285 | + system("CLS"); |
| 286 | + login(); |
| 287 | + } |
| 288 | +} |
| 289 | + |
| 290 | + |
0 commit comments