Hospital Management

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 39

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

/* PROJECT HOSPITAL MANAGEMENT


*/
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <ctype.h>

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
//THIS CLASS CONTROLS ALL THE FUNCTIONS IN THE
MENU
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
class MENU
{
public :
void INTRODUCTION(void);
void MAIN_MENU(void) ;
private :
void EDIT_MENU(void) ;
};

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS CLASS CONTROLS ALL THE FUNCTIONS
RELATED TO PATIENTS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
class PATIENT
{
public :
void ADMIT(void) ;

1
void DISCHARGE(void) ;
void MODIFY(void) ;
void LIST(void) ;
void DISPLAY(void) ;
private :
void DISPLAY_RECORD(int, int) ;
void DELETE_RECORD(int, int) ;
int roomno, bedno, age, dd, mm, yy ;
char name[26], address[36], phone[10], sex;
char disease[16], doctor[26] ;
};

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS CLASS CONTROLS ALL THE FUNCTIONS
RELATED TO ROOMS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
class ROOM
{
public :
ROOM()
{
int sta;
roomno=0;
}
void ADD_ROOMS(void) ;
int AVAILABLE(int, int) ;
void CHANGE_STATUS(int, int, char) ;
void LIST(void) ;
int ROOMNO() ;
int BEDNO(int) ;
int LAST_ROOMNO(void) ;
private :
int RECORDNO(int, int) ;
int roomno, bedno ;
char status ;
};

2
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS CLASS CONTROLS ALL THE FUNCTIONS
RELATED TO DOCTORS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
class DOCTOR
{
public :
void ADD(void) ;
void DELETE(void) ;
void LIST(void) ;
char *DOCTOR_NAME(int) ;
int RECORDS(void) ;
private :
char name[26] ;
};

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION CONTROL ALL THE FUNCTIONS IN
THE MAIN MENU
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void MENU :: MAIN_MENU(void)
{
int ch=0 ;
while (1)
{
clrscr () ;
gotoxy(30,12);
cout<<"1::INTRODUCTION";
gotoxy(30,14) ;
cout<<"2::ADD ROOM" ;
gotoxy(30,16) ;
cout<<"3::ADD DOCTOR " ;
gotoxy(30,18) ;
cout<<"4::ADMIT A PATIENT " ;
gotoxy(30,20) ;

3
cout<<"5::DISCHARGE A PATIENT " ;
gotoxy(30,22) ;
cout<<"6::ROOM STATUS " ;
gotoxy(30,24) ;
cout<<"7::PATIENT LIST " ;
gotoxy(30,26) ;
cout<<"8::PATIENT RECORD" ;
gotoxy(30,28) ;
cout<<"9::MODIFY ";
gotoxy(30,30) ;
cout<<"0::QUIT ";
gotoxy(27,4) ;
cout<<" M A I N M E N U " ;
gotoxy(28,40) ;
cout<<"Enter your choice :: " ;
ch = getche() ;
getch();
if(ch == '1')
{
INTRODUCTION();
}
else
if (ch == '2')
{ ROOM r;
r.ADD_ROOMS() ;
}
else
if (ch == '3')
{ DOCTOR d ;
d.ADD() ;
}
else
if (ch == '4')
{ PATIENT p ;
p.ADMIT() ;
}
else
if (ch == '5')
{ PATIENT p ;
p.DISCHARGE() ;

4
}
else
if (ch == '6')
{ ROOM r ;
r.LIST() ;
}
else
if (ch == '7')
{ PATIENT p ;
p.LIST() ;
}
else
if (ch == '8')
{ PATIENT p ;
p.DISPLAY() ;
}
else
if (ch == '9')
EDIT_MENU() ;
else
if (ch == '0')
{ clrscr();
gotoxy(20,13);
cout<<"BYE! TAKE CARE.WISH YOU A SPEEDY RECOVERY";
getch();
break;
}
}
}
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
//THIS FUNCTION GIVES THE INTRODUCTION
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void MENU::INTRODUCTION(void)
{
clrscr();
gotoxy(25,4);
cout<<"HOSPITAL MANAGEMENT SYSTEM";
gotoxy(15,14);

5
cout<<"\nTHIS IS A PROJECT WHICH PERFORMS ALL THE BASIC
FUNCTIONS REQUIRED IN A HOSPITAL";
gotoxy(15,16);
cout<<"\n LIKE ADDING RECORDS OF ROOMS,PATIENTS AS WELL AS
DOCTORS";
gotoxy(15,18);
cout<<"\nIT DELETES THE RECORDS OF DISCHARGED PATIENTS &
CAN MODIFY EXISTING RECORDS ";
gotoxy(1,20);
cout<<"\n\n\n\n\nPRESS ANY KEY TO GO TO MAIN MENU......";
getch();
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION CONTROLS ALL THE FUNCTIONS
IN THE EDIT MENU
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void MENU :: EDIT_MENU(void)


{ int ch=0 ;
while(1)
{ clrscr() ;
gotoxy(28,11) ;
cout<<"1::MODIFY PATIENT RECORD " ;
gotoxy(28,12) ;
cout<<"2::DELETE DOCTOR RECORD " ;
gotoxy(28,13) ;
cout<<"3::RETURN ";
gotoxy(35,8) ;
cout<<"EDIT MENU " ;
gotoxy(28,15) ;
cout<<"Enter your choice :: " ;
ch = getche() ;
if (ch == '1')
{ PATIENT m ;
m.MODIFY() ;
}
else
if (ch == '2')

6
{ DOCTOR d ;
d.DELETE() ;
}
else
if (ch == '3')
getch();
break ;
}
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS THE CODE OF LAST
ROOM NO.
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
int ROOM :: LAST_ROOMNO(void)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
if (file.fail())
{ file.close() ;
return 0 ;
}
int last=0 ;
while (file.read((char *) this, sizeof(ROOM)))
last = roomno ;
file.close() ;
return last ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION ADDS ROOMS TO THE FILE
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void ROOM :: ADD_ROOMS(void)
{
char ch ;
clrscr();

7
gotoxy(5,5) ;
cout <<"Do you want to add rooms (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == 'N')
return ;
if(ch=='y'||ch=='Y')
{ int rno = LAST_ROOMNO() + 1 ;
int bno=1 ;
fstream file ;
file.open("ROOM.DAT", ios::app) ;
for (int i=1; i<=2; i++)
{ roomno = rno ;
bedno = bno ;
status = 'A' ;
file.write((char *) this, sizeof(ROOM)) ;
bno = 2 ;
}gotoxy(10,10) ;
cout <<"Room no. : " <<rno ;
gotoxy(10,11) ;
cout <<"Total no. of beds : 2" ;
gotoxy(10,12) ;
cout <<"STATUS:" ;
gotoxy(20,13) ;
cout <<"Bed no. 1 : Available" ;
gotoxy(20,14) ;
cout <<"Bed no. 2 : Available" ;
file.close() ;
gotoxy(7,23) ;
cout <<"\nRoom Added" ;
gotoxy(5,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}
}

8
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS 0 IF GIVEN BED NO. OF
THE ROOM IS
// NOT AVAILABLE
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
int ROOM :: AVAILABLE(int rno, int bno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
int avail=0 ;
while (file.read((char *) this, sizeof(ROOM)))
{ if (roomno == rno && bedno == bno && status == 'A')
{ avail = 1 ;
break ;
}
}
file.close() ;
return avail ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS RECORD NO. OF THE
GIVEN ROOM AND
// BED NO.
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

int ROOM :: RECORDNO(int rno, int bno)


{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
int recordno=0 ;
while (file.read((char *) this, sizeof(ROOM)))
{ recordno++ ;
if (roomno == rno && bedno == bno)
break ;

9
}
file.close() ;
return recordno ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DISPLAY THE LIST OF THE ROOMS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void ROOM :: LIST(void)
{
clrscr() ;
int row = 3, flag ;
int sta = 0 ;
char ch ;
gotoxy(1,1) ;
cout<<"Room no. Bed no. Status Room no. Bed no. Status
";
fstream file ;
file.open("ROOM.DAT", ios::in|ios::app) ;
if (file.fail())
{ gotoxy(5,10) ;
cout <<"\nRecords not found" ;
getch() ;
file.close() ;
return;
}
while (file.read((char *) this, sizeof(ROOM)))
{ flag = 0 ;
gotoxy(2,row) ;
cout <<roomno ;
gotoxy(12,row) ;
cout <<bedno ;
gotoxy(23,row) ;
cout <<status ;
if (status == 'A')
sta++ ;
file.read((char *) this, sizeof(ROOM)) ;
gotoxy(41,row) ;

10
cout <<roomno ;
gotoxy(51,row) ;
cout <<bedno ;
gotoxy(62,row) ;
cout <<status ;
if (status == 'A')
sta++ ;
if (row == 22)
{ flag = 1 ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
ch = getch() ;
if (ch == 27)
break ;
row = 3 ;
}
else
row++ ;
}
if (!flag)
{ gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}
gotoxy(1,16) ;
cout <<"Total room : " <<roomno ;
gotoxy(1,17) ;
cout <<"Total occupied beds : " <<((roomno*2)-sta);
gotoxy(1,18) ;
cout <<"Total available beds : "<<sta ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS THE NUMBER OF THE
ROOMS EMPTY
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

11
int ROOM :: ROOMNO(void)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
int rno=0 ;
while (file.read((char *) this, sizeof(ROOM)))
{ if (status == 'A')
{ rno = roomno ;
break ;
}
}
file.close() ;
return rno ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS THE BED NUMBER
EMPTY IN A ROOMS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
int ROOM :: BEDNO(int rno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
int bno=0 ;
while (file.read((char *) this, sizeof(ROOM)))
{ if (rno == roomno && status == 'A')
{ bno = bedno ;
break ;
}
}
file.close() ;
return bno ;
}

12
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION CHANGES THE ROOM STATUS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void ROOM :: CHANGE_STATUS(int rno, int bno, char rstatus)


{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{ file.read((char *) this, sizeof(ROOM)) ;
if (file.eof())
break ;
if (rno == roomno && bno == bedno)
{ status = rstatus ;
temp.write((char *) this, sizeof(ROOM)) ;
}
else
temp.write((char *) this, sizeof(ROOM)) ;
}
file.close() ;
temp.close() ;
file.open("ROOM.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while (!temp.eof())
{ temp.read((char *) this, sizeof(ROOM)) ;
if (temp.eof())
break ;
file.write((char *) this, sizeof(ROOM)) ;
}
file.close() ;
temp.close() ;
}

13
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION ADD NAME OF DOCTOR IN THE
FILE
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void DOCTOR :: ADD(void)


{
clrscr() ;
if (RECORDS() >= 20)
{ gotoxy(5,10) ;
cout <<"Sorry no more records can be added!" ;
getch() ;
return ;
}
char ch ;
do
{ gotoxy(5,5) ; clreol() ;
cout <<"Do you want to add Doctors (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
LIST() ;
int valid ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the New Doctor" ;
gotoxy(5,7) ; clreol() ;
cout <<"Name : " ;
gets(name) ;
strupr(name) ;
if (strlen(name) < 1 || strlen(name) > 25)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;

14
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
fstream file ;
file.open("DOCTOR.DAT", ios::app) ;
file.write((char *) this, sizeof(DOCTOR)) ;
file.close() ;
LIST() ;
gotoxy(5,24) ;
cout <<"Doctor Name Added" ;
gotoxy(5,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DISPLAY THE LIST OF THE
DOCTORS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void DOCTOR :: LIST(void)
{
int row = 16, col=2, sno=1 ;
char ch ;
gotoxy(1,14) ; clreol() ;
cout<<"S.No. Name " ;
fstream file ;
file.open("DOCTOR.DAT", ios::in) ;
while (file.read((char *) this, sizeof(DOCTOR)))
{ gotoxy(col,row) ;
cout <<sno ;
gotoxy(col+6,row) ;
cout <<name ;
if (row == 14)
{ row = 14 ;
col = 40 ;
}else

15
{ sno++ ;
row++ ;
}
}
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS NO. OF RECORDS IN THE
DOCTOR'S FILE
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

int DOCTOR :: RECORDS(void)


{ fstream file ;
file.open("DOCTOR.DAT", ios::in) ;
int records=0 ;
while (file.read((char *) this, sizeof(DOCTOR)))
records++ ;
file.close() ;
return records ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION RETURNS NAME OF THE DOCTOR
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

char *DOCTOR :: DOCTOR_NAME(int pd)


{ fstream file ;
file.open("DOCTOR.DAT", ios::in) ;
int i=0 ;
while (file.read((char *) this, sizeof(DOCTOR)))
{ i++ ;
if (i == pd)
break ;
}
file.close() ;
return name ;
}

16
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DELETES DOCTOR RECORD IN
DOCTOR FILE
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void DOCTOR :: DELETE(void)


{ clrscr() ;
LIST() ;
char t1[5] ;
int t2, sno ;
do
{ gotoxy(5,5) ; clreol() ;
cout <<"Enter S.No. of the Doctor to be Deleted(press 0 to EXIT)
";
gets(t1) ;
t2 = atof(t1) ;
if (t1[0] == '0')
return ;
sno = t2 ;
} while (sno < 1 || sno > RECORDS()) ;
fstream file ;
file.open("DOCTOR.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
int i=0 ;
while (!file.eof())
{ file.read((char *) this, sizeof(DOCTOR)) ;
i++ ;
if (file.eof())
break ;
if (i != sno)
temp.write((char *) this, sizeof(DOCTOR)) ;
}
file.close() ;

17
temp.close() ;
file.open("DOCTOR.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while (!temp.eof())
{ temp.read((char *) this, sizeof(DOCTOR)) ;
if (temp.eof())
break ;
file.write((char *) this, sizeof(DOCTOR)) ;
}
file.close() ;
temp.close() ;
LIST() ;
gotoxy(5,7) ;
cout <<"\7Record Deleted" ;
gotoxy(5,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION TAKES THE DATA OF THE PATIENT
// AND STORES IT INTO THE FILE
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void PATIENT :: ADMIT(void)


{ int t2, rno, bno, page, pd ;char t1[5], pname[26], paddress[36],
pphone[10], psex, pdisease[16], pdoctor[26], ch ;
int d1, m1, y1, valid ;
ROOM r ;
clrscr() ;
rno = r.ROOMNO() ;
if (rno == 0)
{ gotoxy(5,10) ;
cout <<"\7Sorry no room is available for the Patient" ;
getch() ;
return ;
}

18
bno = r.BEDNO(rno) ;
date d;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
gotoxy(5,1) ;
cout<<"Date: "<<d1<<"/"<<m1<<"/"<<y1 ;
gotoxy(60,1) ;
cout<<"Room no.:"<<rno ;
gotoxy(60,2) ;
cout<<"Bed no. : "<<bno ;
gotoxy(5,3) ;
cout <<"Name : " ;
gotoxy(5,4) ;
cout <<"Address : " ;
gotoxy(5,5) ;
cout <<"Phone : " ;
gotoxy(5,6) ;
cout <<"Age : " ;
gotoxy(5,7) ;
cout <<"Sex : " ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NAME OF THE PATIENT" ;
gotoxy(60,25) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(15,3) ; clreol() ;
gets(pname) ;
strupr(pname) ;
if (pname[0] == '0')
return ;
if (strlen(pname) < 1 || strlen(pname) > 25)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;

19
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER ADDRESS OF THE PATIENT" ;
gotoxy(60,25) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(15,4) ; clreol() ;
gets(paddress) ;
strupr(paddress) ;
if (paddress[0] == '0')
return ;
if (strlen(paddress) < 1 || strlen(paddress) > 35)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..35)" ;
getch() ;
}
} while (!valid) ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER PHONE NO. OF THE PATIENT or <ENTER>
FOR NONE" ;
gotoxy(60,25) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(15,5) ; clreol() ;
gets(pphone) ;
if (pphone[0] == '0')
return ;
if ((strlen(pphone) < 7 && strlen(pphone) > 0) || (strlen(pphone)
> 9))
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;

20
cout <<"ENTER AGE OF THE PATIENT" ;
gotoxy(60,25) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(15,6) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
page = t2 ;
if (t1[0] == '0')
return ;
if (page < 1 || page > 100)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
do
{ gotoxy(5,25) ; clreol() ;
cout <<"ENTER SEX OF THE PATIENT (M/F)" ;
gotoxy(60,25) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(15,7) ; clreol() ;
psex = getche() ;
psex = toupper(psex) ;
} while (psex != 'M' && psex != 'F') ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER DISEASE OF THE PATIENT" ;
gotoxy(60,25) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(5,8) ; clreol() ;
cout <<"Disease : " ;
gets(pdisease) ;
strupr(pdisease) ;
if (pdisease[0] == '0')
return ;
if (strlen(pdisease) < 1 || strlen(pdisease) > 15)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;

21
cout <<"\7Enter correctly (Range: 1..15)" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
DOCTOR dr ;
fstream file ;
file.open("DOCTOR.DAT", ios::in) ;
if (file.eof())
{
cout<<"\n no record of doctors .if you want to enter records go to
main menu";
}
file.close() ;
dr.LIST() ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
gotoxy(5,20) ; clreol() ;
cout <<"ENTER S.No. OF THE DOCTOR: " ;
clreol();
gets(t1) ;
t2 = atof(t1) ;
pd = t2 ;
if (t1[0] == '0')
return ;
if (pd < 1 || pd > dr.RECORDS())
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
strcpy(pdoctor,dr.DOCTOR_NAME(pd)) ;
gotoxy(5,21) ;
cout <<"Doctor Assigned : Dr." <<pdoctor ;
do
{ gotoxy(5,22) ; clreol() ;
cout <<"Do you want to save (y/n) " ;

22
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
r.CHANGE_STATUS(rno,bno,'N') ;
roomno = rno ;
bedno = bno ;
strcpy(name,pname) ;
strcpy(address,paddress) ;
strcpy(phone,pphone) ;
age = page ;
sex = psex ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
strcpy(disease,pdisease) ;
strcpy(doctor,pdoctor) ;
file.open("PATIENT.DAT", ios::app) ;
file.write((char *) this, sizeof(PATIENT)) ;
file.close() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DISPLAYS THE LIST OF THE
PATIENTS
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void PATIENT :: LIST(void)
{ clrscr() ;
int row = 5 , found=0, flag=0 ;
char ch ;
gotoxy(31,1) ;
cout<<" LIST OF PATIENTS " ;
gotoxy(1,3) ; clreol() ;
gotoxy(1,3) ;
cout <<"ROOM NO. BED NO. PATIENT'S NAME" ;
fstream file ;
file.open("PATIENT.DAT", ios::in) ;

23
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(PATIENT)))
{ flag = 0 ;
found = 1 ;
gotoxy(3,row) ;
cout <<roomno ;
gotoxy(15,row) ;
cout <<bedno ;
gotoxy(28,row) ;
cout <<name ;
if ( row == 23 )
{ flag = 1 ;
row = 5 ;
gotoxy(1,25) ;
cout <<"Press any key to continue or Press <ESC> to exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(31,1) ;
cout <<" LIST OF PATIENTS " ;
gotoxy(1,3) ; clreol() ;
gotoxy(1,3) ;
cout <<"ROOM NO. BED NO. PATIENT'S NAME" ;
}
else
row++ ;
}
if (!found)
{ gotoxy(5,10) ;
cout <<"\7Records not found" ;
}
if (!flag)
{ gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
}
file.close () ;
}

24
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DISPLAY THE RECORD OF THE
PATIENT BY USING
// ROOM NO AND BED NO.
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void PATIENT :: DISPLAY_RECORD(int rno, int bno)


{ fstream file ;
file.open("PATIENT.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(PATIENT)))
{
if (rno == roomno && bno == bedno)
{ gotoxy(5,1) ;
cout<<"Date of Admit : "<<dd<<"/"<<mm<<"/"<<yy;
gotoxy(60,1) ;
cout<<"Room no.: "<<roomno ;
gotoxy(60,2) ;
cout<<"Bed no. : "<<bedno ;
gotoxy(5,3) ;
cout <<"Name : " <<name ;
gotoxy(5,4) ;
cout <<"Address : " <<address ;
gotoxy(5,5) ;
cout <<"Phone : " <<phone ;
gotoxy(5,6) ;
cout <<"Age : " <<age ;
gotoxy(5,7) ;
cout <<"Sex : " <<sex ;
gotoxy(5,8) ;
cout <<"Disease : " <<disease ;
gotoxy(5,10) ;
cout <<"Doctor Assigned : Dr." <<doctor ;

25
break ;
}
}
file.close() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DISPLAY THE RECORD OF THE
PATIENT
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void PATIENT :: DISPLAY(void)


{
clrscr() ;
char t1[5], ch ;
int rno, bno, valid, t2 ;
ROOM r ;
do
{ valid = 1 ;
gotoxy(64,1);
cout<<"<Enter 0 to EXIT>";
gotoxy(5,5) ;
cout <<"Room no. : " ;
gotoxy(5,7) ;
cout <<"Bed no. : " ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER ROOM NO. OF THE PATIENT or <ENTER>
FOR HELP" ;
gotoxy(16,5) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
rno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{ valid = 0 ;
PATIENT p ;
p.LIST() ;
clrscr() ;

26
}
if ((rno < 1 || rno > r.LAST_ROOMNO()) && valid)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
do
{ valid = 1 ;
gotoxy(64,1) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(5,5) ;
cout <<"Room no. : " <<rno ;
gotoxy(5,7) ;
cout <<"Bed no. : " ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER BED NO. OF THE PATIENT or <ENTER> FOR
HELP" ;
gotoxy(16,7) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
bno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
PATIENT p ;
p.LIST() ;
clrscr() ;
}
if ((bno < 1 || bno > 2) && valid)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;

27
if (r.AVAILABLE(rno,bno))
{ gotoxy(5,20) ;
cout <<"\7Sorry, there is no. Patient in this Room no." ;
getch() ;
return ;
}clrscr() ;
DISPLAY_RECORD(rno,bno) ;
gotoxy(5,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION DELETES THE RECORD OF THE
PATIENT BY USING THE
//ROOM NUMBER AND BED NUMBER
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void PATIENT :: DELETE_RECORD(int rno, int bno)
{ fstream file ;
file.open("PATIENT.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{
file.read((char *) this, sizeof(PATIENT)) ;
if (file.eof())
break ;
if (rno != roomno || bno != bedno)
temp.write((char *) this, sizeof(PATIENT)) ;
}
file.close() ;
temp.close() ;
file.open("PATIENT.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
file.seekp(0,ios::beg) ;
temp.seekg(0,ios::beg) ;
while (!temp.eof())

28
{
temp.read((char *) this, sizeof(PATIENT)) ;
if (temp.eof())
break ;
file.write((char *) this, sizeof(PATIENT)) ;
}
file.close() ;
temp.close() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION TAKES THE ROOM NUMBER AND
BED NUMBER
// OF THE PATIENT TO BE DISCHARGED AND PASSES
// IT TO THE FUNCTION DELETE_RECORD
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

void PATIENT :: DISCHARGE(void)


{
clrscr() ;
char t1[5], ch ;
int rno, bno, valid, t2 ;
ROOM r ;
do
{ valid = 1 ;
gotoxy(64,1);
cout<<"<Enter 0 to EXIT>";
gotoxy(5,5) ;
cout <<"Room no. : " ;
gotoxy(5,7) ;
cout <<"Bed no. : " ;
gotoxy(5,25) ;
clreol() ;
cout<<"ENTER ROOM NO. OF THE PATIENT or <ENTER>
FOR HELP" ;
gotoxy(16,5) ;
clreol() ;
gets(t1) ;

29
t2 = atof(t1) ;
rno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{ valid = 0 ;
PATIENT p ;
p.LIST() ;
clrscr() ;
}
if ((rno < 1 || rno > r.LAST_ROOMNO()) && valid)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
do
{ valid = 1 ;
gotoxy(64,1) ;
cout<<"<Enter 0 to EXIT>" ;
gotoxy(5,5) ;
cout <<"Room no. : " <<rno ;
gotoxy(5,7) ;
cout <<"Bed no. : " ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER BED NO. OF THE PATIENT or <ENTER> FOR
HELP" ;
gotoxy(16,7) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
bno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{ valid = 0 ;
PATIENT p ;
p.LIST() ;
clrscr() ;
}

30
if ((bno < 1 || bno > 2) && valid)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
if (r.AVAILABLE(rno,bno))
{
gotoxy(5,20) ;
cout <<"\7Sorry, there is no. Patient in this Room no." ;
getch() ;
return ;
}
clrscr() ;
DISPLAY_RECORD(rno,bno) ;
do
{ gotoxy(5,13) ; clreol() ;
cout <<"Discharge this Patient (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
r.CHANGE_STATUS(rno,bno,'A') ;
DELETE_RECORD(rno,bno) ;
gotoxy(5,23) ;
cout <<"\7Record Deleted" ;
gotoxy(5,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// THIS FUNCTION MODIFY THE RECORD OF THE
PATIENT BY USING
// THE ROOM NUMBER AND BED NUMBER
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ

31
void PATIENT :: MODIFY(void)
{ clrscr() ;
char t1[5], ch, pname[26], paddress[36], pphone[10];
char pdisease[16], psex, pdoctor[26] ;
int pd, d1, m1, y1, rno, bno, rno1, bno1;
int valid, t2, page, RNO, BNO ;
ROOM r ;
do
{ valid = 1 ;
gotoxy(64,1) ;
cout<<"<Enter 0 to EXIT>";
gotoxy(5,5) ;
cout <<"Room no. : " ;
gotoxy(5,7) ;
cout <<"Bed no. : " ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER ROOM NO. OF THE PATIENT or <ENTER>
FOR HELP" ;
gotoxy(16,5) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
RNO = t2 ;
rno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
PATIENT p ;
p.LIST() ;
clrscr() ;
}
if ((rno < 1 || rno > r.LAST_ROOMNO()) && valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;

32
}
} while (!valid) ;
do
{ valid = 1 ;
gotoxy(5,5) ;
cout <<"Room no. : " <<rno ;
gotoxy(5,7) ;
cout <<"Bed no. : " ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER BED NO. OF THE PATIENT or <ENTER> FOR
HELP" ;
gotoxy(16,7) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
BNO = t2 ;
bno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
PATIENT p ;
p.LIST() ;
clrscr() ;
}
if ((bno < 1 || bno > 2) && valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
if (r.AVAILABLE(rno,bno))
{
gotoxy(5,20) ;
cout <<"\7Sorry, there is no Patient!" ;
getch() ;
return ;

33
}
clrscr() ;
DISPLAY_RECORD(rno,bno) ;
do
{ gotoxy(5,13) ; clreol() ;
cout <<"Modify this Patient Record (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
do
{ valid = 1 ;
clrscr() ;
gotoxy(64,1) ;
cout<<"<Enter 0 to EXIT>";
gotoxy(29,1) ;
cout <<"MODIFY PATIENT RECORD" ;
gotoxy(29,2) ;
cout <<"~~~~~~~~~~~~~~~~~~~~~" ;
gotoxy(5,4) ;
cout <<"Room no. : " ;
gotoxy(5,6) ;
cout <<"Bed no. : " ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER ROOM NO. OF THE PATIENT" ;
gotoxy(16,4) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
rno1 = t2 ;
if (t1[0] == '0')
return ;
if (rno1 < 1 || rno1 > r.LAST_ROOMNO())
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;

34
}
} while (!valid) ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER BED NO. OF THE PATIENT" ;
gotoxy(16,6) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
bno1 = t2 ;
if (t1[0] == '0')
return ;
if (bno1 < 1 || bno > 2)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
if (!r.AVAILABLE(rno1,bno1) && (rno1 != rno || bno1 != bno))
{
valid = 0 ;
gotoxy(5,20) ;
cout <<"\7Sorry, there is already a Patient in this Room
no." ;
getch() ;
}
} while (!valid) ;
clrscr() ;
DISPLAY_RECORD(rno,bno);
if (rno == 0)
{ gotoxy(5,10) ;
cout <<"\7Sorry no. room is available for the Patient" ;
getch() ;
return ;
}
struct date d;
getdate(&d);

35
d1 = d.da_day ;

m1 = d.da_mon ;
y1 = d.da_year ;
fstream file ;
file.open("PATIENT.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(PATIENT)))
{
if (rno == roomno && bno == bedno)
{
strcpy(pname,name) ;
strcpy(paddress,address) ;
strcpy(pphone,phone) ;
page=age ;
psex=sex ;
}
}
file.close() ;
gotoxy(5,3) ;
cout <<"Name : "<<pname ;
gotoxy(5,4) ;
cout <<"Address : "<<paddress ;
gotoxy(5,5) ;
cout <<"Phone : "<<pphone ;
gotoxy(5,6) ;
cout <<"Age : "<<page ;
gotoxy(5,7) ;
cout <<"Sex : "<<psex ;
do
{
valid = 1 ;
fstream file ;
file.open("PATIENT.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(PATIENT)))
{
if (rno == roomno && bno == bedno)
{ gotoxy(5,1) ;
cout<<"Date of Admit : "<<dd<<"/"<<mm<<"/"<<yy ;

36
}
}
file.close() ;
}while (!valid) ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"ENTER DISEASE OF THE PATIENT" ;
gotoxy(5,8) ; clreol() ;
cout <<"Disease : " ;
gets(pdisease) ;
strupr(pdisease) ;
if (pdisease[0] == '0')
return ;
if (strlen(pdisease) < 1 || strlen(pdisease) > 15)
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..15)" ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
DOCTOR dr ;
file.open("DOCTOR.DAT", ios::in) ;
if (file.fail())
{
cout<<"\n no doctors .if you want to enter the name of A doctor go to
main menu";
}
file.close() ;
dr.LIST() ;
do
{ valid = 1 ;
gotoxy(5,25) ; clreol() ;
gotoxy(5,12) ; clreol() ;
cout <<"ENTER S.No. OF THE DOCTOR: " ;
gets(t1) ;
t2 = atof(t1) ;
pd = t2 ;
if (t1[0] == '0')

37
return ;
if (pd < 1 || pd > dr.RECORDS())
{ valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
strcpy(pdoctor,dr.DOCTOR_NAME(pd)) ;
gotoxy(5,10) ;
cout <<"Doctor Assigned : Dr." <<pdoctor ;
do
{ gotoxy(5,20) ; clreol() ;
cout <<"Do you want to save (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
r.CHANGE_STATUS(RNO,BNO,'A') ;
r.CHANGE_STATUS(rno1,bno1,'N') ;
DELETE_RECORD(rno,bno) ;
roomno = rno1 ;
bedno = bno1 ;
strcpy(name,pname) ;
strcpy(address,paddress) ;
strcpy(phone,pphone) ;
age = page ;
sex = psex ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
strcpy(disease,pdisease) ;
strcpy(doctor,pdoctor) ;
file.open("PATIENT.DAT", ios::app) ;
file.write((char *) this, sizeof(PATIENT)) ;
file.close() ;
gotoxy(5,23) ;
cout<<"\7Record Modified" ;
gotoxy(5,25) ;

38
cout <<"Press any key to continue..." ;
getch() ;
}

//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
// MAIN FUNCTION //
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
void main()
{
MENU menu ;
menu.MAIN_MENU() ;
}

39

You might also like