Anda di halaman 1dari 28

1

CONTENTS
CERTIFICATE………….. I
ACKNOWLEDGEMENT…………..
II
PREFACE…………………….
III
1.HOSPITAL MANAGEMENT……… 2
2.SOURCE CODE………… 5
3.OUTPUT……….. 21
4.BIBILIOGRAPHY…………………… 28
2

PREFACE
We are moving into an information age.More and more,day by
day,we are getting influenced by technology.Infact,today’s
technology is shaping our work pattern.
Till now we had used manual records to maintain the
details.But now according to the changing technology we have
to use computerized records for more safety and security.
My project on HOSPITAL MANAGEMENT will help the
hospitals to maintain their patient and doctor records.It will
definitely satisfies the need of an user.
This program needs Turbo c++ and windows operating system
to execute.
This project includes “DATA FILE HANDLING”concept.
I had used two files to maintain the records of patients and
doctors.
It will carry out several operations which are helpful to a
hospital.
I hope this project will meet your expectations and prove more
useful and helpful to the hospitals.
3

HOSPITAL MANAGEMENT

THIS IS THE PROGRAM ON HOSPITAL MANGAMENT.


THIS PROGRAM WILL HANDLE DETAILS OF ALL THE
DOCTORS AND THE PATIENTS.
THE DETAILS OF THE PATIENT WILL BE WRITTEN INTO
THE PATIENT FILE.
THE DETAILS OF THE DOCTOR WILL BE WRITTEN INTO
THE DOCTOR FILE.
THIS PROGRAM CONTAINS THREE CLASSES:
1.HOSPITAL
2.PATIENT
3.DOCTOR
THIS PROGRAM CONTAINS TEN FUNCTIONS.NAMELY:
1.VOID D_INPUT();
2.VOID D_OUTPUT();
4

3.VOID P_INPUT();
4.VOID P_OUTPUT();
5.VOID MODIFY(INT);
6.VOID INFO(INT);
7.VOID DETAILS1(INT);
8.VOID DETAILS2(INT);
9.VOID DELETE(INT);
10.VOID BILLING(INT);

THIS PROGRAM WILL CARRY OUT NINE OPERATIONS.


1.TAKES DETAILS OF THE DOCTOR
2.PRINTS THE DOCTOR’S LIST
3.TAKES THE DETAILS OF A PATIENT
4.PRINTS PATIENTS LIST
5.MODIFIES THE DETAILS OF A PATIENT
6.CALCULATES THE BILL
7.GIVES NO OF PATIENTS TREATED BY A DOCTOR
8.GIVES THE DETAILS OF A PATIENT AND THE CONSULT
DOCTOR
5

9.DELETES A PATIENT RECORD FROM THE PATIENT’S LIST


//**************HOSPITAL MANAGEMENT************
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<math.h>

voidp_input();
voidp_output();
voidD_input();
voidD_output();
void modify(int);
void info(int);
void billing(int);
void details1(int);
void details2(int);
void Delete(int);

class doctor
{
private:
char name[30];
intdocid;
float fees;
charspecialisation[30];

public:

voidgetdoctor() //to get the details of the


doctor
{
cout<<"enter name of the doctor";
6

gets(name);
cout<<"enter ID number of the doctor";
cin>>docid;
cout<<"enter specialisation of the doctor";
gets(specialisation);
cout<<"enter fees per consultation";
cin>>fees;
}

intreturn_docid() //returns docid


{
returndocid;
}

voidputdoctor() //prints the details of


thepatient
{
cout<<"\n**************************\n";
cout<<"\n NAME:"<<name;
cout<<"\n ID NUMBER:"<<docid;
cout<<"\n SPECIALISATION:"<<specialisation;
cout<<"\n FEES:"<<fees;
cout<<"\n***************************\n";
}
floatreturn_fees()
{
return fees;
}

};

doctor d;

class patient
7

{
private:

char name[30];
char ailment[20];
int age;
inti,j;
intdate,month,year;
char gender;
introomno,noofdays;
char ward[20];
char medicines[30][10];
float cost[30];
float bill;

public:

intdocid,adno;

voidgetpatient() //to get details of the


patient
{
cout<<"enter name of the patient";
gets(name);
cout<<"enter age";
cin>>age;
cout<<"enter adno";
cin>>adno;
cout<<"enter docid";
cin>>docid;
cout<<"enter inpatient/outpatient 1/0";
cin>>i;
if(i==1)
{
cout<<"enter how many days you have to stay";
8

cin>>noofdays;
if(age>11)
{
cout<<"enter gender";
cin>>gender;
if(gender=='f'||gender=='F')
{
strcpy(ward,"female ward");
}
if(gender=='m'||gender=='M')
{
strcpy(ward,"male ward");
}
}
else
{
strcpy(ward,"children ward");
}
}
cout<<"enter ailment";
gets(ailment);
cout<<"enter date(dd/mm/yy)";
cin>>date>>month>>year;
cout<<"enter no of medicines to buy";
cin>>j;
int a;
for(a=0;a<j;a++)
{
cout<<"enter the name of the medicine";
cin>>medicines[a];
cout<<"enter cost of the medicine";
cin>>cost[a];
bill+=cost[a];
} //end of for
9

} //end of function

voidshowpatient()//to print details of


thepatient
{
cout<<"\n*******************\n";
cout<<"\nNAME:"<<name;
cout<<"\nAGE :"<<age;
cout<<"\nADNO:"<<adno;
cout<<"\nCAUSE :"<<ailment;
cout<<"\nDATE OF
JOINING:"<<date<<"/"<<month<<"/"<<year;
cout<<"\nWARD ALLOTED TO THE
PATIENT:"<<ward;
cout<<"\nMEDICINE:\t"<<"COST\n";

int b;

for(b=0;b<j;b++)
{
cout<<medicines[b]<<"\t\t"<<cost[b]<<"\n";
}//end of for
cout<<"\n**********************\n";
} //end of function

float bills() //calculates the bill


{
float fees=d.return_fees();
if(i==1)
{
bill+=fees*noofdays;
return bill;
}
else if(i==0)
{
10

bill+=fees;
return bill;
}
else
{
return bill;
}

} //end of function

intreturn_adno() //returns adno


{
returnadno;
}

}; //end of class patient

class hospital
{
private:

charhname[35];
char address[80];

public:

void show() //prints the hospital details


{
strcpy(hname,"COSMOS MULTI SPECALITY HOSPITAL");
strcpy(address,"jnvvennelavalasasarubujjilisrika
kulam");
cout<<"\t\t"<<hname<<"\n";
cout<<"\t "<<address<<"\n";
cout<<"\t\t\tregd no:389";
11

} //end of function

}; //end of class hospital

patient p;
hospital h;

//**********************************************
*

voidp_input()//to take the details of the


patient
{
ofstream out;
out.open("patient.dat",ios::out|ios::app|ios::bi
nary);
p.getpatient();
out.write((char*)&p,sizeof(p));
cout<<"\nDATA SAVED\n " ;
out.close();
} //end of function

//**********************************************
***

voidp_output() //DISPLAYS PATIENTS LIST


{
ifstream in("patient.dat",ios::in|ios::binary);
while(in.read((char*)&p,sizeof(p)))
{
p.showpatient();
}
in.close();
} //end of function
12

//**********************************************
**

voidD_input()//takes doctor details


{
ofstream out;
out.open("doctor.dat",ios::out|ios::app|ios::bin
ary);
d.getdoctor();
out.write((char*)&d,sizeof(d));
cout<<"\n DATA SAVED\n";
out.close();
} //end of function

//**********************************************

voidD_output() //DISPLAYS DOCTORS LIST


{
ifstream in;
in.open("doctor.dat",ios::in|ios::binary);
while(in.read((char*)&d,sizeof(d)))
{
d.putdoctor();
}
in.close();
} //end of function

//**********************************************

void modify(int n)//modifies the details of


patient
{
fstreaminout;
inout.open("patient.dat",ios::in|ios::out|ios::b
inary);
13

while(inout.read((char*)&p,sizeof(p)))
{
if(p.return_adno()==n)
{
p.showpatient();
intpos=-1*sizeof(p);
inout.seekp(pos,ios::cur);
cout<<"enter new details of the patient";
p.getpatient();
inout.write((char*)&p,sizeof(p));
cout<<"new details of the patient are:";
p.showpatient();
}//end of if
} //end of while
inout.close();

} //end of function

//*******************************************

void billing(int n) //to update and calculates


the bill
{
intpos;
float bill;
ifstream in;
in.open("patient.dat",ios::in|ios::binary);
while(in.read((char*)&p,sizeof(p)))
{
if(p.return_adno()==n)
{
pos=-1*sizeof(p);
in.seekg(pos,ios::cur);
p.showpatient();
14

bill=p.bills();
cout<<"bill of the patient:"<<bill;
break;
}//end of if
} //end of while
in.close();
} //END OF FUNCTION

//******************************************

void info(int n) //NO OF PATIENTS TREATED BY A


DOCTOR
{
int count=0;
ifstream in;
in.open("doctor.dat",ios::in|ios::binary);
ifstream fin;
fin.open("patient.dat",ios::in|ios::binary);
while(in.read((char*)&d,sizeof(d)))
{
if(d.return_docid()==n)
{
while(fin.read((char*)&p,sizeof(p)))
{
p.showpatient();
count++;
} //end of while
} //end of if
} //end of while
cout<<"\n no of patients getting treatment
from the doctor "<<count;
in.close();
fin.close();
} //end of function
15

//**********************************************
******

void details1(int n) //to display the details of


the specific patient
{
intpos;
ifstream fin;
fin.open("patient.dat",ios::in|ios::binary);
while(fin.read((char*)&p,sizeof(p)))
{
if(p.return_adno()==n)
{
cout<<"\ndetails of the patient\n";
p.showpatient();
details2(p.docid);
break;
} //end of if
} //end of while
fin.close();
} //end of the function

//**********************************************
*****

void details2(intdocid) //matches the docidand


displays doctor details
{
ifstream in;
in.open("doctor.dat",ios::in|ios::binary);

while(in.read((char*)&d,sizeof(d)))
{
if(d.return_docid()==docid)
{
16

cout<<"\nconsult doctor details:";


d.putdoctor();
break;
}//end of if
} //end of while
in.close();
} //end of function

//**********************************************
*************

void Delete(int n)
{
ifstream in;
in.open("patient.dat",ios::in|ios::binary);
ofstream out;
out.open("pat.dat",ios::out|ios::binary);
fstreaminout;
inout.open("DELETEd_rec.dat",ios::in|ios::ou
t|ios::binary|ios::app);
intpos,flag=0;
while(in.read((char*)&p,sizeof(p)))
{
if(p.return_adno()==n)
{
inout.write((char*)&p,sizeof(p));
flag=1;
}
else
{
out.write((char*)&p,sizeof(p));
}
}
in.close();
out.close();
17

remove("patient.dat");
rename("pat.dat","patient.dat");
cout<<"\nRECORD DELETED\n";
ifstream fin;
in.open("PATIENT.dat",ios::in|ios::binary);
int rec=0;
while(fin.read((char*)&p,sizeof(p)))
{
rec++;
}
cout<<"\nno.of records in the present file";
cout<<rec;
in.close();

if(flag==1)
cout<<"record found";
else
cout<<"\nnot found";
inout.close();
} //end of function

//**********************************************
************

void main()
{
clrscr();
inti,n;
h.show();
char a='y';
int j;
while(a=='y'||a=='Y')
{
cout<<"enter your choice";
cout<<"\n1.TO ENTER DETAILS OF THE DOCTOR";
18

cout<<"\n2.DISPLAYS DOCTORS LIST";


cout<<"\n3.TO ENTER THE DETAILS OF THEPATIENT";
cout<<"\n4.DISPLAYS THE PATIENTS LIST ";
cout<<"\n5.MODIFY THE DETAILS OF THE PATIENT";
cout<<"\n6.UPDATE AND DISPLAY THE BILL";
cout<<"\n7.DISPLAYS THE PATIENTS OF SAMEDOCID";
cout<<"\n8.DETAILS OF PATIENT&CONSULT DOCTOR";
cout<<"\n9.TO DELETE A RECORD";
cin>>i;
switch(i)
{
case 1:
clrscr();
D_input();
break;

case 2:
clrscr();
D_output();
break;

case 3:
clrscr();
p_input();
break;

case 4:
clrscr();
p_output();
break;

case 5:
clrscr();
cout<<"enter adno of the patient";
cin>>n;
19

modify(n);
break;

case 6:
clrscr();
cout<<"enter adno of the patient";
cin>>n;
billing(n);
break;

case 7:
clrscr();
cout<<"enter docid";
cin>>n;
info(n);
break;

case 8:
clrscr();
cout<<"enter adno of the patient";
cin>>n;
details1(n);
break;

case 9:
clrscr();
cout<<"enter adno of the patient";
cin>>n;
Delete(n);
break;

default:
clrscr();
cout<<"enter correct choice";
main();
20

}
cout<<"\n\nyou want to continue(y/n)\n";
cin>>a;
}
getch();
}
//*********************THE END*****************

OUTPUT:-
21
22
23
24
25
26
27
28

BIBILLIOGRAPHY

1.COMPUTER SCIENCE WITH C++

2.MOVE FAST WITH C++

3.WIKIPEDIA –FREE ENCYCLOPEDIA

Anda mungkin juga menyukai