C needs language
C needs language
HISTORY OF C
C seems strange name for a programming language. But this strange
sounding language is one of the most popular computer languages
today because it is a structured, high level machine independent
language. It allows software deposers program without worrying
about the hardware platform where they will be implemented.
Advantages of C
Introduction
Hospital Management is a new theory in management faculty.
Earlier a senior doctor used to perform the role of a hospital
manager. However, nowadays everything demands a specialist.
Almost all the things related to hospital have changed. Many
categories concerning medical sciences and hospital have altered
totally. There are various types of hospitals today, including ordinary
hospitals, specialty hospitals and super specialty hospitals. The
categories are regarding to the types of facilities they offer to the
people. Eligible professionals are needed for the smooth operating
of a hospital. Various courses and training programs have been
developed to find out eligible hospital managers. Such professionals
are well trained to solve the rising challenges and specific necessities
of modern day hospitals. The Hospital Management courses are
open to non-medical background graduates also.
A number of potentials are required for a candidate for this field. The
candidate must have rapid judgment capability related to upto-date
management doctrines and techniques. Friendly attitude, ability to
handle public and pressure, ability of handling deadlines, brilliant
communication skills and leadership skills are required to an
efficient hospital manager.
//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <ctype.h>
#include <process.h>
#include <math.h>
struct MENU
{
int st1, st2;
};
struct ROOM
{ int roomno, bedno ; char status ;
};
struct PATIENT
{ int roomno, bedno, dd, mm, yy,age; char name[26],address[36], phone[10],
disease[15], doctor[26],sex;
};
struct DOCTOR
{
char name[26] ;
};
{ gotoxy(col,row) ;
printf("%c",c) ;
}
}
//**********************************************************
// THIS FUNCTION DRAWS THE VERTICAL LINE
//**********************************************************
//********************************************************** // THIS
FUNCTION DRAWS THE BOX
//**********************************************************
void BOX(int column1, int row1, int column2, int row2, char c)
{ char ch=218 ; char c1, c2,
c3, c4 ; char l1=196,
l2=179 ; if (c == ch)
{ c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}
else
{ c1=c ; c2=c
; c3=c
; c4=c
; l1 = c
; l2 = c
;
}
gotoxy(column1,row1) ;
printf("%c",c1) ;
gotoxy(column2,row1) ;
printf("%c",c2) ;
gotoxy(column1,row2) ;
printf("%c",c3) ;
gotoxy(column2,row2) ;
printf("%c",c4) ;
column1++ ; column2--
;
LINE_HOR(column1,column2,row1,l1) ;
LINE_HOR(column1,column2,row2,l1) ;
column1-- ; column2++ ; row1++ ;
row2-- ;
LINE_VER(row1,row2,column1,l2) ;
LINE_VER(row1,row2,column2,l2) ;
}
//**********************************************************
// THIS FUNCTION CLEAR THE SCREEN LINE BY LINE UPWARD
//**********************************************************
//**********************************************************
// THIS FUNCTION CONTROL ALL THE FUNCTIONS IN THE MAIN MENU
//**********************************************************
void MAIN_MENU()
{
switch(ch)
{
case 0: ADMIT() ;
break;
case 1:
DISCHARGE() ;
break;
case 2:
ROOM_LIST() ;
break;
case 3:
PAT_LIST() ;
break;
case 4:
DISPLAY() ;
break;
case 5:
EDIT_MENU() ;
break;
case 6:
return;
}
}
}
//**********************************************************
// THIS FUNCTION CONTROL ALL THE FUNCTIONS IN THE EDIT MENU
//**********************************************************
void EDIT_MENU()
{
textmode(C40) ;
clrscr() ;
textbackground(WHITE) ;
textcolor(BLACK) ; gotoxy(13,8) ;
cprintf(" EDIT MENU ") ;
textbackground(BLACK) ;
textcolor(LIGHTGRAY) ; ch =
CREATE_MENU(options,5,10,11) ;
textmode(C80) ;
clrscr() ; if
(ch == 0)
{
ADD_ROOMS() ;
}
else if (ch
== 1)
{
MODIFY() ;
}
else if (ch
== 2)
{
ADD_DOC() ;
}
else
if (ch == 3)
{
DELETE() ;
}
else if (ch ==
4) break ;
}
}
//**********************************************************
// THIS FUNCTION CREATE MENU FOR THE GIVEN OPTIONS
//**********************************************************
printf("%c",chr1) ; t
= x ; for (i=0;
i<size; i++)
{
gotoxy(y,t) ; printf("%s",options[i]) ; t++ ; }
textbackground(WHITE) ; textcolor(BLACK) ;
gotoxy(y,x) ; cprintf("%s",options[n]) ;
textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
gotoxy(mnu.st1,mnu.st2) ; do
{ do
{ do
{
ch1 = getch() ; if ( ch1 == 27 )
return(size-1) ; } while (( ch1 != 0 )
&& ( ch1 != 13 )) ; if ( ch1 != 13 )
{ do
{
ch2 = getch() ; if (
ch2 == 27 )
return(size-1) ;
} while ((ch2 != 72) && (ch2 != 80) && (ch2 != 13)) ;
}
} while (((ch1 != 0) || ((ch2 != 72) && (ch2 != 80))) && ((ch1 != 13) &&
(ch2 != 13))) ;
if ((ch1 == 0) && (ch2 == 80))
{ textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
gotoxy(y,x) ; cprintf("%s",options[n]) ; if (n == size-
1)
{
n=0;x=x-
(size-1) ;
}
else
{ n++ ; x++ ; } textbackground(WHITE) ;
textcolor(BLACK) ; gotoxy(y,x) ;
cprintf("%s",options[n]) ; textbackground(BLACK) ;
textcolor(LIGHTGRAY) ; gotoxy(mnu.st1,mnu.st2) ;
} if ((ch1 == 0) && (ch2 ==
72))
{ textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
gotoxy(y,x) ; cprintf("%s",options[n]) ; if ( n == 0 )
{
n = size-1 ; x =
x + (size-1) ;
}
else
{
n-- ; x-
-;
} textbackground(WHITE) ; textcolor(BLACK) ;
gotoxy(y,x) ; cprintf("%s",options[n]) ;
textbackground(BLACK) ; textcolor(LIGHTGRAY)
; gotoxy(mnu.st1,mnu.st2) ;
}
} while (( ch1 != 13 ) && ( ch2 != 13 )) ;
return n ;
}
//**********************************************************
// THIS FUNCTION RETURNS THE CODE OF LAST ROOM NO.
//**********************************************************
int LAST_ROOMNO()
{
FILE *fp ;
int last,n;
struct ROOM r;
fp=fopen("RNO.DAT", "r+") ;
if (fp==NULL)
{
fclose(fp) ;
return 0 ;
}
last=0 ;
while(fread(&r, sizeof(r),1,fp)!=NULL)
last++ ;
fclose(fp);
return (last/2) ;
}
//**********************************************************
// THIS FUNCTION ADDS ROOMS TO THE FILE
//**********************************************************
void ADD_ROOMS()
{
char ch ; char
p1,p2,p3; int
rno,bno,i; FILE *fp;
struct ROOM room;
clrscr() ;
gotoxy(5,5) ; clreol() ;
printf("Enter
Password:"); p1=getch();
printf("*"); p2=getch();
printf("*");
do {
fp=fopen("RNO.dat","ab");
if(fp==NULL)
{ printf("\n\t\tFile Not
Found\n"); return;
}
rno = LAST_ROOMNO() + 1 ;
bno=1 ; for (i=1; i<=2; i++) {
room.roomno = rno ;
room.bedno = bno ; room.status
= 'A' ;
fwrite(&room,sizeof(room),1,fp);
bno = 2 ;
}
fclose(fp);
BOX(8,9,42,15,218) ;
gotoxy(10,10) ;
printf("Room no. :%d ",rno)
; gotoxy(10,11) ;
printf("Total no. of beds : 2" );
gotoxy(10,12) ; printf("STATUS:");
gotoxy(20,13) ; printf("Bed no. 1 :
Available"); gotoxy(20,14) ;
printf("Bed no. 2 : Available");
gotoxy(5,24) ; printf("\7Room
Added") ; gotoxy(5,25) ;
printf("Press any key to
continue..."); getch() ;
//**********************************************************
// THIS FUNCTION RETURNS 0 IF GIVEN ROOM IS NOT EMPTY
//**********************************************************
while(fread(&r, sizeof(r),1,fp)!=NULL)
{ if (r.roomno == rno && r.status == 'N')
{ empty = 0 ;
break ;
}
}
fclose(fp);
return empty ; }
//**********************************************************
// THIS FUNCTION RETURNS 0 IF GIVEN BED NO. OF THE ROOM IS
// NOT AVAILABLE
//**********************************************************
if (fp==NULL)
fp=fopen("RNO.DAT", "r+") ;
{
fclose(fp) ;
return 0 ;
}
while(fread(&r, sizeof(r),1,fp)!=NULL)
{ if (r.roomno == rno && r.bedno == bno && r.status == 'A')
{
avail = 1 ;
break ;
}
}
fclose(fp);
return avail ;
}
//********************************************************** //
THIS FUNCTION RETURNS RECORD NO. OF THE GIVEN ROOM AND
// BED NO.
//**********************************************************
if (fp==NULL)
{
fclose(fp) ;
return 0 ; }
while(fread(&r, sizeof(r),1,fp)!=NULL)
{ recordno++ ; if (r.roomno == rno && r.bedno
== bno) break ;
}
fclose(fp); return
recordno ;
}
//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE ROOMS
//**********************************************************
void ROOM_LIST()
{
int row = 3, flag ;
int sta = 0 ;
int room=0,bed=0;
char ch ; FILE *fp
;
struct ROOM r;
clrscr() ;
textbackground(WHITE) ; textcolor(BLACK) ; gotoxy(1,1) ;
cprintf("Room no. Bed no. Status Room no. Bed no. Status
") ;
textbackground(BLACK) ;
textcolor(LIGHTGRAY) ;
fp=fopen("RNO.DAT", "r+") ;
if (fp==NULL)
{
fclose(fp) ;
return; }
while(fread(&r, sizeof(r),1,fp)!=NULL)
{
flag = 0 ; delay(20) ;
gotoxy(2,row) ;
printf("%d",r.roomno)
; gotoxy(12,row) ;
printf("%d",r.bedno) ;
gotoxy(23,row) ;
printf("%c",r.status) ;
if (r.status == 'A')
sta++ ;
if(fread(&r, sizeof(r),1,fp)!=NULL)
{
gotoxy(41,row) ;
printf("%d",r.roomno)
; gotoxy(51,row) ;
printf("%d",r.bedno) ;
gotoxy(62,row) ;
printf("%c",r.status) ;
if (r.status == 'A')
sta++ ; } if (row ==
22)
{
flag = 1 ; gotoxy(1,25) ; printf("Press
any key to continue..." ); ch = getch()
; if (ch == 27) break ;
row = 3 ;
}
else row++ ;
room++;bed+=2
;
}
if (!flag)
{ gotoxy(1,25) ; printf("Press any key to
continue..."); getch() ;
}
CLEARDOWN(3,25) ;
gotoxy(1,16) ;
printf("Total room :%d " ,room) ;
gotoxy(1,17) ; printf("Total occupied beds
:%d ",bed-sta) ; textbackground(WHITE) ;
textcolor(BLACK) ; gotoxy(1,18) ;
cprintf("Total available beds : %d",sta) ;
textbackground(BLACK) ;
textcolor(LIGHTGRAY) ; gotoxy(1,25) ;
printf("Press any key to continue...") ;
getch() ;
CLEARUP(25,1) ;
}
int ROOMNO()
{
int rno=0 ; FILE *fp ; struct
ROOM r;
fp=fopen("RNO.DAT", "r+") ;
if (fp==NULL)
{
fclose(fp) ;
return 0 ; }
while(fread(&r, sizeof(r),1,fp)!=NULL)
{
if (r.status == 'A')
{ rno = r.roomno ;
break ;
}
}
fclose(fp);
return rno ; }
while(fread(&r, sizeof(r),1,fp)!=NULL)
{ if (rno == r.roomno && r.status == 'A')
{ bno = r.bedno ;
break ;
}
}
fclose(fp);
return bno ;
}
while(fread(&r, sizeof(r),1,fp)!=NULL)
while(fread(&r, sizeof(r),1,temp)!=NULL)
fwrite(&r,sizeof(r),1,fp) ;
fclose(fp) ;
fclose(temp) ;
//**********************************************************
// THIS FUNCTION ADD NAME OF DOCTOR IN THE FILE
//**********************************************************
void ADD_DOC()
{
char ch ;
int valid ;
struct DOCTOR doc;
FILE *fp ; while(1)
{ do
{
clrscr() ; gotoxy(5,5) ; clreol() ; printf("Do
you want to add Doctors (y/n) " ); ch =
getche() ; ch = toupper(ch) ; } while (ch !=
'Y' && ch != 'N') ; if (ch == 'N') return ;
clrscr() ;
DOC_LIST() ;
do
{
valid = 1 ; gotoxy(5,25) ; clreol() ; printf("Enter
the name of the New Doctor" ); gotoxy(5,7) ;
clreol() ; printf("Name : " ); gets(doc.name) ;
strupr(doc.name) ; if (strlen(doc.name) < 1 ||
strlen(doc.name) > 25)
{
valid = 0 ; gotoxy(5,25) ; clreol() ;
printf("\7Enter correctly (Range: 1..25)"
); getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
fp=fopen("DT.dat", "a") ;
if (fp==NULL)
{
fclose(fp) ;
return;
}
fwrite(&doc,sizeof(doc),1,fp);
fclose(fp);
DOC_LIST() ; gotoxy(5,24) ;
printf("Doctor Name Added" );
gotoxy(5,25) ; printf("Press any key
to continue...") ; getch() ;
}
}
//**********************************************************
// THIS FUNCTION ADD A NAME OF DOCTOR AS A DEFAULT RECORD
//**********************************************************
void DEFAULT()
{ struct DOCTOR doc; FILE *fp ;
strcpy(doc.name,"KUMAR
PUSHKAR"); fp=fopen("DT.dat", "a+") ;
fwrite(&doc,sizeof(doc),1,fp); fclose(fp);
}
//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE DOCTORS
//**********************************************************
void DOC_LIST()
{ int row = 13, col=2, sno=1 ; char
ch ; struct DOCTOR r;
FILE *fp ;
textbackground(WHITE) ;
textcolor(BLACK) ;
gotoxy(1,11) ; clreol() ;
cprintf("S.No. Name ") ;
textbackground(BLACK) ;
textcolor(LIGHTGRAY) ;
fp=fopen("DT.dat", "r+") ;
if (fp==NULL)
{
fclose(fp) ;
return; }
while(fread(&r, sizeof(r),1,fp)!=NULL)
{
delay(20) ;
gotoxy(col,row) ;
printf("%d",sno) ;
gotoxy(col+6,row) ;
printf("%s",r.name) ;
sno++ ; if (row == 22)
{ row = 14 ; col
= 40 ;
}
else
{ row++ ;
}
}
fclose(fp);
}
//**********************************************************
// THIS FUNCTION RETURNS NO. OF RECORDS IN THE DOCTOR'S FILE
//**********************************************************
int RECORDS()
{
while(fread(&r, sizeof(r),1,fp)!=NULL)
records++ ;
fclose(fp); return
records ;
}
//**********************************************************
// THIS FUNCTION RETURNS NAME OF THE DOCTOR
//**********************************************************
while(fread(&r, sizeof(r),1,fp)!=NULL)
{
i++ ; if (i ==
pd) break ;
}
fclose(fp); return
r.name ;
//**********************************************************
// THIS FUNCTION DELETES DOCTOR RECORD IN DOCTOR FILE
//**********************************************************
void DELETE()
{
char t1[5] ; int t2,
sno=1 ; FILE
*fp,*temp ; struct
DOCTOR r;
clrscr() ;
DOC_LIST() ;
do
{
gotoxy(5,5) ; clreol() ; printf("Enter S.No. of the Doctor to be
Deleted(press 0 to EXIT) ") ; gets(t1) ; t2 = atof(t1) ; if (t1[0] == '0')
return ;
} while (sno < 1 || sno > RECORDS()) ;
fp=fopen("DT.dat", "r+") ;
temp=fopen("TEMP.DAT", "w+") ;
while(fread(&r, sizeof(r),1,fp)!=NULL)
{
if (t2 != sno)
fwrite(&r,sizeof(r),1,temp) ;
sno++;
}
fclose(fp) ;
fclose(temp) ;
fp=fopen("DT.dat", "w+") ;
temp=fopen("TEMP.DAT", "r+") ;
while(fread(&r, sizeof(r),1,temp)!=NULL)
fwrite(&r,sizeof(r),1,fp) ;
fclose(fp) ;
fclose(temp) ;
CLEARDOWN(13,23) ;
DOC_LIST() ; gotoxy(5,7) ;
printf("\7Record Deleted") ;
gotoxy(5,25) ; printf("Press any key
to continue...") ; getch() ;
}
void ADMIT()
{
int t2, rno, bno, page, pd; char t1[5], pname[26], paddress[36], psex,pphone[10],
pdisease[15], pdoctor[26],
ch ; int d1, m1, y1, valid ;
struct ROOM r ;
struct date d; struct
PATIENT pat; FILE
*fp;
rno = ROOMNO() ;
if (rno == 0)
{ gotoxy(5,10) ; printf("\7Sorry no. room is available for the
Patient" ); getch() ; return ;
} bno = BEDNO(rno) ; getdate(&d); d1 =
d.da_day ; m1 = d.da_mon ; y1 = d.da_year ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(5,1) ; cprintf("Date:
%d/%d/%d",d1,m1,y1) ; gotoxy(60,1) ;
cprintf("Room no.: %d",rno) ; gotoxy(60,2) ;
cprintf("Bed no. : %d",bno) ;
textcolor(LIGHTGRAY) ;
textbackground(BLACK) ; gotoxy(5,3) ;
printf("Name : " ); gotoxy(5,4) ;
printf("Address : " ); gotoxy(5,5) ;
printf("Phone : " ); gotoxy(5,6) ; printf("Age
: " ); gotoxy(5,7) ; printf("Sex : " );
do
{
valid = 1 ;
gotoxy(5,25) ; clreol()
;
printf("ENTER NAME OF THE PATIENT" );
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() ;
printf("\7Enter correctly (Range: 1..25)"
); getch() ;
}
} while (!valid) ;
do {
valid = 1 ;
gotoxy(5,25) ; clreol()
;
printf("ENTER ADDRESS OF THE PATIENT") ;
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() ;
printf("\7Enter correctly (Range: 1..35)")
; getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol()
;
printf("ENTER PHONE NO. OF THE PATIENT or <ENTER> FOR
NONE" );
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() ; printf("\7Enter
correctly") ; getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol()
;
printf("ENTER AGE OF THE PATIENT") ;
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()
;
printf("\7ENTER CORRECTLY") ;
getch() ;
}
} while (!valid) ;
do
{
gotoxy(5,25) ; clreol() ;
printf("ENTER SEX OF THE PATIENT (M/F)");
gotoxy(15,7) ; clreol() ; psex
= getche() ; psex = toupper(psex) ; }
while (psex != 'M' && psex != 'F') ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol()
;
printf("ENTER DISEASE OF THE PATIENT") ;
gotoxy(5,8) ; clreol()
; printf("Disease : ") ;
gets(pdisease) ;
strupr(pdisease) ; if
(pdisease[0] == '0')
return ;
if (strlen(pdisease) < 1 || strlen(pdisease) > 15)
{
valid = 0 ; gotoxy(5,25) ; clreol() ;
printf("\7Enter correctly (Range: 1..15)")
; getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ;
DOC_LIST() ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol()
; gotoxy(5,24) ;
clreol() ;
printf("ENTER S.No. OF THE DOCTOR ");
gets(t1) ; t2 =
atof(t1) ; pd =
t2 ; if (t1[0]
== '0') return ;
pat.mm = m1 ; pat.yy = y1 ;
strcpy(pat.disease,pdisease) ;
strcpy(pat.doctor,pdoctor) ;
fp=fopen("PT.DAT","r+");
fwrite(&pat,sizeof(pat),1,fp);
fclose(fp);
//**********************************************************
// THIS FUNCTION DISPLAYS THE LIST OF THE PATIENTS
//**********************************************************
void PAT_LIST()
{
int row = 5 , found=0, flag=0 ;
char ch ; FILE *fp; struct
PATIENT pat; clrscr() ;
textcolor(BLACK+BLINK) ; textbackground(WHITE) ;
gotoxy(31,1) ; cprintf(" LIST OF PATIENTS ") ;
textcolor(BLACK) ;
gotoxy(1,3) ; clreol() ; gotoxy(1,3) ; printf("ROOM NO.
BED NO. PATIENT'S NAME") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
fp=fopen("PT.DAT", "r+") ; while
(fread(&pat,sizeof(pat),1,fp))
{
flag = 0 ; delay(20) ;
found = 1 ;
gotoxy(3,row) ;
printf("%d",pat.roomno)
; gotoxy(15,row) ;
printf("%d",pat.bedno) ;
gotoxy(28,row) ;
printf("%s",pat.name) ; if
( row == 23 )
{
flag = 1 ; row = 5 ; gotoxy(1,25) ; printf("Press any key to
continue or Press <ESC> to exit") ; ch = getch() ; if (ch ==
27) break ;
clrscr() ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(31,1) ; printf(" LIST OF PATIENTS ") ;
gotoxy(1,3) ; clreol() ; gotoxy(1,3) ; printf("ROOM NO.
BED NO. PATIENT'S NAME" );
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
}
else row++ ;
}
if (!found)
{ gotoxy(5,10) ; printf("\7Records not
found") ;
}
if (!flag)
{ gotoxy(1,25) ; printf("Press any key to
continue..." ); getche() ;
}
fclose (fp) ;
}
void DISPLAY()
{
char t1[5], ch ; int rno,
bno, valid=0, t2 ; clrscr()
;
do
{
valid = 1 ; gotoxy(5,5)
; printf("Room no. : ")
; gotoxy(5,7) ;
printf("Bed no. : ") ;
gotoxy(5,25) ; clreol()
;
printf("ENTER BED 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 ;
ROOM_LIST() ;
clrscr() ;
}
if (rno < 1 && valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY") ;
getch() ;
}
} while (!valid) ;
do {
valid = 1 ; gotoxy(5,5) ;
printf("Room no. :%d ",rno)
; gotoxy(5,7) ; printf("Bed
no. : ") ; gotoxy(5,25) ;
clreol() ;
printf("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 ;
ROOM_LIST() ;
clrscr() ;
}
if ((bno < 1 || bno > 2) && valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY") ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ; if
(AVAILABLE(rno,bno))
{
gotoxy(5,20) ; printf("\7Sorry, there is no. Patient in
this Room no.") ; getch() ; return ;
}
clrscr() ;
DISPLAY_RECORD(rno,bno) ;
gotoxy(5,25) ; printf("Press any key
to continue...") ; getch() ; }
while(fread(&r, sizeof(r),1,fp)!=NULL)
{
if (rno != r.roomno || bno != r.bedno)
fwrite(&r,sizeof(r),1,temp) ;
}
fclose(fp) ;
fclose(temp) ;
fp=fopen("PT.DAT",
"r+") ;
temp=fopen("TEMP.D
AT", "r+") ;
while(fread(&r, sizeof(r),1,temp)!=NULL)
fwrite(&r,sizeof(r),1,fp) ;
fclose(fp) ;
fclose(temp) ;
}
void DISCHARGE()
{
char t1[5], ch ; int
rno, bno, valid, t2 ;
clrscr() ;
do
{
valid = 1 ; gotoxy(5,5)
; printf("Room no. : "
); gotoxy(5,7) ;
printf("Bed no. : " );
gotoxy(5,25) ; clreol()
;
printf("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 ;
ROOM_LIST() ;
clrscr() ;
} if ((rno < 1 || rno > LAST_ROOMNO()) &&
valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY" );
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ; gotoxy(5,5) ;
printf("Room no. : ",rno)
; gotoxy(5,7) ;
printf("Bed no. : ") ;
gotoxy(5,25) ; clreol() ;
printf("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 ;
ROOM_LIST() ;
clrscr() ;
}
if ((bno < 1 || bno > 2) && valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY" );
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ; if
(AVAILABLE(rno,bno))
{ gotoxy(5,20) ; printf("\7Sorry, there is no. Patient in this
Room no.") ; getch() ; return ;
}
clrscr() ;
DISPLAY_RECORD(rno,bno) ;
do
{
gotoxy(5,13) ; clreol() ;
printf("Discharge this Patient (y/n) ")
; ch = getche() ; ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
CHANGE_STATUS(rno,bno,'A') ;
DELETE_RECORD(rno,bno) ;
CLEARDOWN(1,22) ;
gotoxy(5,23) ; printf("\7Record
Deleted") ; gotoxy(5,25) ; printf("Press any
key to continue...") ; getch() ; }
void MODIFY()
{
char t1[5], ch ,doctor[35];
int rno, bno, rno1,bno1,valid, t2 ;
int pd;
FILE *fp,*temp ;
struct PATIENT pat;
clrscr() ;
do
{
valid = 1 ; gotoxy(5,5)
; printf("Room no. : ")
; gotoxy(5,7) ;
printf("Bed no. : ") ;
gotoxy(5,25) ; clreol()
; printf("ENTER
ROOM NO. OF THE
PATIENT or
<ENTER> FOR
clrscr() ;
} if ((rno < 1 || rno > LAST_ROOMNO()) &&
valid)
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY") ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ; gotoxy(5,5) ;
printf("Room no. :%d ",rno)
; gotoxy(5,7) ; printf("Bed
no. : ") ; gotoxy(5,25) ;
clreol() ; printf("ENTER
BED NO. OF THE
PATIENT or <ENTER> FOR
if (t1[0] == '0')
return ;
if (rno1 < 1 || rno1 > LAST_ROOMNO())
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY" );
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol()
;
printf("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 || bno1 > 2)
{
valid = 0 ;
gotoxy(5,25) ; clreol()
;
printf("\7ENTER CORRECTLY") ;
getch() ;
}
} while (!valid) ;
gotoxy(5,25) ; clreol() ; if
(!AVAILABLE(rno1,bno1)) {
fp=fopen("PT.DAT", "r+") ;
temp=fopen("TEMP.DAT", "w+") ;
while(fread(&pat, sizeof(pat),1,fp)!=NULL)
{ if (rno == pat.roomno && bno == pat.bedno)
{ pat.roomno = rno1 ; pat.bedno
= bno1 ;
strcpy(pat.doctor,doctor)
;
fwrite(&pat,sizeof(pat),1,temp) ;
}
else fwrite(&pat,sizeof(pat),1,temp) ;
}
fclose(fp) ;
fclose(temp) ;
fp=fopen("PT.DAT", "r+") ;
temp=fopen("TEMP.DAT", "r+") ;
while(fread(&pat, sizeof(pat),1,temp)!=NULL)
fwrite(&pat,sizeof(pat),1,fp) ;
fclose(fp) ;
fclose(temp) ;
clrscr();
DISPLAY_RECORD
(rno1,bno1);
gotoxy(5,23) ; printf("\7Record
Modified") ; gotoxy(5,25) ;
printf("Press any key to continue...") ;
getch() ;
}
OUTPUT OF THE PROJECT
ADMISSION
DISCHARGE
ROOM STATUS
PATIENT LIST
PATIENT RECORD
EDIT MENU
ADD ROOMS
MODIFY PATIENT RECORD
ADD DOCTOR