0% found this document useful (0 votes)
180 views6 pages

Hospital Management System Code

The document contains C++ code for a hospital management system program. It includes functions for logging in, displaying a menu with options to add patient records, view diagnosis information, see a patient's full history, view information about the hospital, and exit. It handles input/output to files for storing and retrieving patient records and diagnosis information. When the user selects an option, the corresponding code is executed to either add/view data or display hospital information. The program ends by thanking the user for using the system.

Uploaded by

awais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views6 pages

Hospital Management System Code

The document contains C++ code for a hospital management system program. It includes functions for logging in, displaying a menu with options to add patient records, view diagnosis information, see a patient's full history, view information about the hospital, and exit. It handles input/output to files for storing and retrieving patient records and diagnosis information. When the user selects an option, the corresponding code is executed to either add/view data or display hospital information. The program ends by thanking the user for using the system.

Uploaded by

awais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

#include<iostream>

#include<fstream>
#include<cstdlib>
#include<conio.h>
#include<time.h>
#include<iomanip>

using namespace std;


int main()

{
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@@| -Brought To
You by code-projects.org |@@\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;
}
}

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";pa
t_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";pa
t_file<<"\n********************************************************************\n\n
";
cout<<"\nInformation Saved Successfully\n";
}
system("pause");
system("cls");
goto b;

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;
}
}

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@@| -Brought To
You by code-projects.org |@@\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();
}
}

You might also like