Vous êtes sur la page 1sur 83

#include<conio.

h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
#include<password.c>
#include<load1.c>
////////////////////////////prototype//////////////////////
void patient_billform();
void bill_s_work();
void patient_mform();
void patient_dform();
void doctor_mform();
void doctor_dform();
void ward_mform();
void ward_dform();
void test_mform();
void test_dform();
void patient_search();
void doctor_search();
void ward_search();
void test_search();
///////////////////////////structure///////////////////////////////
typedef struct patt
{
char p_id[5];
char p_name[30];
char p_address[30];
char p_age[6];
char p_sex[6];
char p_city[20];
char p_disease[20];
char p_contactno[12];
char p_d_of_admission[14];
char p_d_of_discharge[15];
char p_referby[10];
char p_wardno[10];
char p_bedno[10];
char p_testno[10];
char p_country[12];
}patt;

29

typedef struct docc


{
char d_regnno[5];
char d_name[30];
char d_address[30];
char d_age[4];
char d_sex[7];
char d_city[20];
char d_deptt[15];
char d_d_of_join[15];
char d_d_of_leave[15];
char d_contactno[15];
char d_desig[15];
char d_specility[15];
char d_quali[15];
char d_salary[15];
char d_marital[15];
}docc;
typedef struct warr
{
char w_wardno[10];
char w_wardname[20];
float w_wardcharge;
char w_wardtype[20];
char p_id[10];
}warr;
typedef struct tess
{
char t_testno[10];
char t_testname[20];
float t_testcharge;
}tess;

30

//////////////////////////mouse//////////////////////////
int click,x,y;
int maxx,maxy;
union REGS i,o;
int initmouse()//Function to initialize mouse pointer
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
void hidemouse()//Function to Hide mouse pointer
{
i.x.ax=2;
int86(0x33,&i,&o);
}
void showmouse()//Function to Display mouse pointer
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void getmousepos(int *button,int *x,int *y)//Function to get current mouse pointer
{
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
void usr_line(int x1,int y1,int x2,int y2)
{
hidemouse();
line(x1,y1,x2,y2);
showmouse();
}

31

void Button1(int x1,int y1,int x2,int y2,char *str)


{
hidemouse();
setfillstyle(1,7);
bar(x1,y1,x2,y2);
setcolor(15);
line(x1,y1,x2,y1);
line(x1,y1,x1,y2);
setcolor(0);
line(x1,y2,x2,y2);
line(x2,y2,x2,y1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(0);
outtextxy((x1+x2)/2,(y1+y2)/2+1,str);
showmouse();
}
void Button2(int x1,int y1,int x2,int y2,char *str)
{
hidemouse();
setfillstyle(1,7);
bar(x1,y1,x2,y2);
setcolor(15);
line(x1,y2,x2,y2);
line(x2,y2,x2,y1);
setcolor(0);
line(x1,y1,x2,y1);
line(x1,y1,x1,y2);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(0);
outtextxy((x1+x2)/2+1,(y1+y2)/2+2,str);
showmouse();
}
void Button3(int x1,int y1,int x2,int y2,int color,char *str)
{
hidemouse();
setfillstyle(1,color);
bar(x1,y1,x2,y2);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(0);
outtextxy((x1+x2)/2,(y1+y2)/2+1,str);
showmouse();
}

32

int getstring(int x1,int y1,int x2,int y2,char *str,int n)


{
int i=0,j,k;
char ch,s[80]="";
Button3(x1+1,y1+1,x2-1,y2-1,3,"");
settextjustify(0,0);
str[0]='\0';
outtextxy(x1+2,y2-2,str);
ch=getch();
while(ch!=13 && ch!=27 && i<n)
{
if(ch==8)
{
if(i>0)
i--;
s[i]=0;
}
else
{
s[i]=ch;
s[i+1]=0;
i++;
}
Button3(x1+1,y1+1,x2-1,y2-1,3,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,s);
ch=getch();
}
str[i]='\0';
if(ch==13)
{
for(i=0;s[i];i++);
if(i!=0)
for(i=0;str[i]=s[i];i++);
Button2(x1,y1,x2,y2,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,str);
return(i);
}
Button2(x1,y1,x2,y2,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,str);
return(-1);
}

33

int getstringm(int x1,int y1,int x2,int y2,char *str,int n)


{
int i=0,j,k;
char ch,s[80]="";
Button3(x1+1,y1+1,x2-1,y2-1,3,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,str);
ch=getch();
while(ch!=13 && ch!=27 && i<n)
{
if(ch==8)
{
if(i>0)
i--;
s[i]=0;
}
else
{
s[i]=ch;
s[i+1]=0;
i++;
}
Button3(x1+1,y1+1,x2-1,y2-1,3,"");
//Button2(x1,y1,x2,y2,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,s);
ch=getch();
}
if(ch==13)
{
for(i=0;s[i];i++);
if(i!=0)
for(i=0;str[i]=s[i];i++);
Button2(x1,y1,x2,y2,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,str);
return(i);
}
Button2(x1,y1,x2,y2,"");
settextjustify(0,0);
outtextxy(x1+2,y2-2,str);
return(-1);
}

34

int check_button(int x1,int y1,int x2,int y2,char *str)


{
int flag=0;
getmousepos(&click,&x,&y);
if((click&1)&& (x>=x1)&& (x<=x2)&&(y>=y1)&& (y<=y2))
{
do
{
if((x>=x1)&& (x<=x2)&&(y>=y1)&& (y<=y2))
{
if(flag==0)
{
Button2(x1,y1,x2,y2,str);
flag=1;
}
}
else
{
if(flag==1)
{
Button1(x1,y1,x2,y2,str);
flag=0;
}
}
getmousepos(&click,&x,&y);
}while(click&1);
Button1(x1,y1,x2,y2,str);
delay(250);
if((x>=x1)&& (x<=x2)&&(y>=y1)&& (y<=y2))
return 1;
}
return 0;
}
int check_menu()//int x1,int y1,int x2,int y2,char *str)
{
return 1;
}
void screen1(int x1,int y1,int x2,int y2,int col1 ,int col2 ,char *str)
{
Button1(x1,y1,x2,y2,"");
Button3(x1+4,y1+4,x2-5,y1+20,col1,str);
Button3(x1+5,y1+40,x2-5,y2-5,col2,"");
setcolor(0);
usr_line(x1+4,y1+40,x2-5,y1+40);
usr_line(x1+4,y1+40,x1+4,y2-5);

35

Button1(x2-22,y1+5,x2-6,y1+19,"X");}
///////////////////////////output screen////////////////////////
void screen2(int x1,int y1,int x2,int y2,int col1 ,int col2 ,char *str)
{
Button1(x1,y1,x2,y2,"");
Button3(x1+4,y1+4,x2-5,y1+20,col1,str);
Button3(x1+5,y1+24,x2-5,y2-5,col2,"");
setcolor(0);
usr_line(x1+4,y1+24,x2-5,y1+24);
usr_line(x1+4,y1+24,x1+4,y2-5);
Button1(x2-22,y1+5,x2-6,y1+19,"X");
}
void screen3(int x1,int y1,int x2,int y2,int col1 ,int col2 ,char *str)
{
Button1(x1,y1,x2,y2,"");
Button3(x1+4,y1+4,x2-5,y1+20,col1,str);
Button3(x1+5,y1+24,x2-5,y2-5,col2,"");
setcolor(0);
usr_line(x1+4,y1+24,x2-5,y1+24);
usr_line(x1+4,y1+24,x1+4,y2-5);
}
void clear_screen(int x1,int y1,int x2,int y2,int col1)
{
Button3(x1,y1,x2,y2,col1,"");
}
void error(char *ch)
{
int click,x,y,exet=0,i,wid;
for(i=0;ch[i];i++);
wid=i*10+20;
Button1(maxx/2-wid/2,maxy/2-50,maxx/2+wid/2,maxy/2+50,"");
Button3(maxx/2-wid/2+4,maxy/2-46,maxx/2+wid/2-4,maxy/2-26,10,"ERROR");
Button3(maxx/2-wid/2+4,maxy/2-25,maxx/2+wid/2-4,maxy/2+20,7,ch);
Button1(maxx/2-30,maxy/2+20,maxx/2+30,maxy/2+40,"OK");
do{
if(check_button(maxx/2-30,maxy/2+20,maxx/2+30,maxy/2+40,"OK"))
{
//clear_screen(maxx/2-30,maxy/2+20,maxx/2+30,maxy/2+40);
exet=1;
}
}while(exet!=1);
}

36

int check_alpha(char str[])


{
int f=1,i;
for(i=0;str[i]!='\0';i++)
{
if(!isalpha(str[i]) && str[i]!=' ')
{
f=0;
break;
}
}
return f;
}
int check_digit(char str[])
{
int f=1,i;
for(i=0;str[i]!='\0';i++)
{
if(!isdigit(str[i]))
{
f=0;
break;
}
}
return f;
}
int check_float(char str[])
{
int f=1,i;
for(i=0;str[i]!='\0';i++)
{
if(!isdigit(str[i]) && str[i]!='.')
{
f=0;
break;
}
}
return f;
}

37

int check_date(char str[])


{
int f=1,i;
for(i=0;str[i]!='\0';i++)
{
if(!isdigit(str[i])&&str[i]!='/')
{
f=0;
break;
}
}
return f;
}
void ftoa(float a,char *s)
{
long int l,l1;
char s1[10];
l=a;
ltoa(l,s,10);
a=a-l;
a=a*100;
l1=a;
ltoa(l1,s1,10);
strcat(s,".");
strcat(s,s1);
}
////////////////////////////////////////////////////////////
void screen_newinformation()
{
screen1(6,42,maxx-6,maxy-6,4,8,"NEW INFORMATION" );
Button1(22,65,90,79,"Patient");
Button1(92,65,160,79,"Doctor");
Button1(162,65,230,79,"Ward");
Button1(232,65,300,79,"Test");
}
//////////////////////////////////////////////////////////
void screen_bill()
{
screen1(6,42,maxx-6,maxy-6,4,8,"BILL" );
Button1(15,65,120,79,"Patient Bill");
}

38

//////////////////////////////////////////////////////////
void screen_search()
{
screen1(6,42,maxx-6,maxy-6,4,8,"SEARCH");
Button1(22,65,90,79,"Patient");
Button1(92,65,160,79,"Doctor");
Button1(162,65,230,79,"Ward");
Button1(232,65,300,79,"Test");
}
//////////////////////////////////////////////////////////
void screen_report()
{
screen1(6,42,maxx-6,maxy-6,4,8,"REPORT" );
Button1(10,65,125,79,"Patient Report");
Button1(129,65,240,79,"Doctor Report");
Button1(244,65,340,79,"Ward Report");
Button1(344,65,440,79,"Test Report");
}
//////////////////////////////////////////////////////////
void screen_help1()
{
screen1(6,42,maxx-6,maxy-6,4,8,"HELP" );
Button1(22,65,100,79,"User Help");
}
/////////////////////////PATIENT//////////////////////////////
void patient()
{
screen3(12,84,maxx-546,maxy-12,3,8,"PATIENT");
Button1(20,150,85,180,"Add");
Button1(20,190,85,220,"Modify");
Button1(20,230,85,260,"Delete");
setlinestyle(0,1,3);
line(18,350,88,350);
setlinestyle(0,0,0);
Button1(20,maxy-110,85,maxy-90,"Exit");
}

39

void patient_add_form()
{
screen3(95,84,maxx-12,maxy-12,3,8,"PATIENT ADD FORM");
Button3(150,120,200,140,8,"Patient id:-");
Button2(240,120,400,140,"");
Button3(150,150,200,170,8,"Name:-");
Button2(240,150,400,170,"");
Button3(150,180,200,200,8,"Address:-");
Button2(240,180,400,200,"");
Button3(150,210,200,230,8,"Age:-");
Button2(240,210,400,230,"");
Button3(150,240,200,260,8,"Sex:-");
Button2(240,240,400,260,"");
Button3(150,270,200,290,8,"City:-");
Button2(240,270,400,290,"");
Button3(150,300,200,320,8,"Disease:-");
Button2(240,300,400,320,"");
Button3(150,330,200,350,8,"D_of_admission:-");
Button2(240,330,400,350,"");
Button3(150,360,200,380,8,"D_of_discharge:-");
Button2(240,360,400,380,"");
Button3(150,390,200,410,8,"Contact no:-");
Button2(240,390,400,410,"");
Button3(410,120,500,140,8,"Refer by:-");
Button2(500,120,610,140,"");
Button3(410,150,500,170,8,"Ward no:-");
Button2(500,150,610,170,"");
Button3(410,180,500,200,8,"Bed no:-");
Button2(500,180,610,200,"");
Button3(410,210,500,230,8,"Test no:-");
Button2(500,210,610,230,"");
Button3(410,240,500,260,8,"Country:-");
Button2(500,240,610,260,"");
Button1(220,maxy-40,280,maxy-20,"Save");
Button1(320,maxy-40,400,maxy-20,"Add More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}

40

void pat_a_write(patt s)
{
FILE *fp;
fp=fopen("patient.dat","ab");
fwrite(&s,sizeof(s),1,fp);
fclose(fp);
}
int id_search(char id[])
{
FILE *fp;
int f=0; //Not Exist
patt s;
fp=fopen("patient.dat","rb");
while(fread(&s,sizeof(s),1,fp))
{
if((strcmp(s.p_id,id))==0)
{
f=1;
break;
}
}
fclose(fp);
return(f);
}
void entry_pat(patt *t)
{
char s[50]="";
int f;
getstring(240,120,400,140,s,9);
while(id_search(s))
{
setcolor(0);
outtextxy(430,320,"This P_id already exist");
getstring(240,120,400,140,s,9);
setcolor(8);
outtextxy(430,320,"This P_id already exist");
}
strcpy(t->p_id,s);
while(1)
{
getstring(240,150,400,170,s,30);
if(!check_alpha(s))
{
setcolor(0);

41

outtextxy(430,320,"enter char value");


}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->p_name,s);
getstring(240,180,400,200,s,30);
strcpy(t->p_address,s);
while(1)
{
getstring(240,210,400,230,s,6);
if(!check_digit(s))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_age,s);
while(1)
{
getstring(240,240,400,260,s,6);
if(!check_alpha(s))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;

42

}
}
strcpy(t->p_sex,s);
while(1)
{
getstring(240,270,400,290,s,20);
if(!check_alpha(s))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->p_city,s);
while(1)
{
getstring(240,300,400,320,s,20);
if(!check_alpha(s))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->p_disease,s);
while(1)
{
getstring(240,330,400,350,s,14);
if(!check_date(s))

43

{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_d_of_admission,s);
while(1)
{
getstring(240,360,400,380,s,15);
if(!check_date(s))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_d_of_discharge,s);
while(1)
{
getstring(240,390,400,410,s,10);
if(!check_digit(s))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{

44

setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_contactno,s);
while(1)
{
getstring(500,120,610,140,s,10);
if(!check_alpha(s))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->p_referby,s);
while(1)
{
getstring(500,150,610,170,s,10);
if(!check_digit(s))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_wardno,s);

45

while(1)
{
getstring(500,180,610,200,s,10);
if(!check_digit(s))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_bedno,s);
while(1)
{
getstring(500,210,610,230,s,10);
if(!check_digit(s))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->p_testno,s);
while(1)
{
getstring(500,240,610,260,s,10);
if(!check_alpha(s))
{
setcolor(0);
outtextxy(430,320,"enter char value");

46

}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->p_country,s);
}
void patient_a_form()
{
patt s;
int exet=0,exet1=0;
patient_add_form();
do{
exet1=0;
hidemouse();
entry_pat(&s);
showmouse();
do{
if(check_button(320,maxy-40,400,maxy-20,"Add More"))
{
patient_add_form();
exet1=1;
}
if(check_button(220,maxy-40,280,maxy-20,"Save"))
{
pat_a_write(s);
patient_add_form();
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
void patient_awork()
{
patient_a_form();

47

}
////////////////patient modify//////////////////////////////////
void edit_patt(patt *t)
{
Button3(150,150,200,170,8,"Name:-");
Button2(240,150,400,170,"");
Button3(150,180,200,200,8,"Address:-");
Button2(240,180,400,200,"");
Button3(150,210,200,230,8,"Age:-");
Button2(240,210,400,230,"");
Button3(150,240,200,260,8,"Sex:-");
Button2(240,240,400,260,"");
Button3(150,270,200,290,8,"City:-");
Button2(240,270,400,290,"");
Button3(150,300,200,320,8,"Diagnosis:-");
Button2(240,300,400,320,"");
Button3(150,330,200,350,8,"D_of_admission:-");
Button2(240,330,400,350,"");
Button3(150,360,200,380,8,"D_of_discharge:-");
Button2(240,360,400,380,"");
Button3(150,390,200,410,8,"Contact no:-");
Button2(240,390,400,410,"");
Button3(410,120,500,140,8,"referby:-");
Button2(500,120,610,140,"");
Button3(410,150,500,170,8,"Ward no:-");
Button2(500,150,610,170,"");
Button3(410,180,500,200,8,"Bed no:-");
Button2(500,180,610,200,"");
Button3(410,210,500,230,8,"Test no:-");
Button2(500,210,610,230,"");
Button3(410,240,500,260,8,"Country:-");
Button2(500,240,610,260,"");
setcolor(BLACK);
hidemouse();
outtextxy(320,160,t->p_name);
outtextxy(305,190,t->p_address);
outtextxy(250,220,t->p_age);
outtextxy(260,250,t->p_sex);
outtextxy(295,280,t->p_city);
outtextxy(278,310,t->p_disease);
outtextxy(275,340,t->p_d_of_admission);
outtextxy(275,370,t->p_d_of_discharge);
outtextxy(285,400,t->p_contactno);
outtextxy(529,132,t->p_referby);
outtextxy(510,160,t->p_wardno);

48

outtextxy(510,190,t->p_bedno);
outtextxy(510,220,t->p_testno);
outtextxy(520,250,t->p_country);
showmouse();
getstringm(240,150,400,170,t->p_name,20);
getstringm(240,180,400,200,t->p_address,20);
getstringm(240,210,400,230,t->p_age,20);
getstringm(240,240,400,260,t->p_sex,20);
getstringm(240,270,400,290,t->p_city,20);
getstringm(240,300,400,320,t->p_disease,20);
getstringm(240,330,400,350,t->p_d_of_admission,20);
getstringm(240,360,400,380,t->p_d_of_discharge,20);
getstringm(240,390,400,410,t->p_contactno,20);
getstringm(500,120,610,140,t->p_referby,20);
getstringm(500,150,610,170,t->p_wardno,20);
getstringm(500,180,610,200,t->p_bedno,20);
getstringm(500,210,610,230,t->p_testno,10);
getstringm(500,240,610,260,t->p_country,20);
}
void patient_modify()
{
char id[10];
FILE *fp;
int p;
int f=0;
patt s;
getstring(240,120,400,140,id,20);
fp=fopen("patient.dat","rb+");
p=ftell(fp);
while(fread(&s,sizeof(s),1,fp))
{
if((strcmp(s.p_id,id))==0)
{
f=1;
break;
}
p=ftell(fp);
}
if(f==1)
{
fseek(fp,p,0);
edit_patt(&s);
fwrite(&s,sizeof(s),1,fp);

49

setcolor(14);
outtextxy(460,320,"RECORD IS MODIFIED");
}
else
{
error("RECORD NOT FOUND");
patient_mform();
}
fclose(fp);
}
void patient_mform()
{
screen3(95,84,maxx-12,maxy-12,3,8,"PATIENT MODIFY FORM");
Button3(150,120,200,140,8,"Patient id:-");
Button2(240,120,400,140,"");
Button1(320,maxy-40,420,maxy-20,"Modify More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void patientmclose()
{
int exet=0,exet1;
patient_mform();
patient_modify();
do{
exet1=0;
do{
if(check_button(320,maxy-40,420,maxy-20,"Modify More"))
{
patient_mform();
patient_modify();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}

50

//////////////////patient delete////////////////////////////////////
void patient_delete()
{
patt s;
int x1=181,y1=251,x2=200,y2=289,i;
FILE *f1,*f2;
int f=0;
char id[10];
getstring(310,115,500,135,id,10);
f1=fopen("patient.dat","rb");
f2=fopen("temp.dat","wb");
while(fread(&s,sizeof(s),1,f1))
{
if((strcmp(s.p_id,id))!=0)
{
fwrite(&s,sizeof(s),1,f2);
}
else
f=1;
}
fclose(f1);
fclose(f2);
remove("patient.dat");
rename("temp.dat","patient.dat");
if(f==1)
{
settextstyle(1,0,1);
setcolor(0);
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait.......");// bar
bar(180,250,480,290);
for(i=0;i<29;i++)
{
setfillstyle(SOLID_FILL,BLUE);
bar(x1,y1,x2,y2);
delay(50);
x1=x1+10;
x2=x2+10;
}
setcolor(8);
//8 for dark_gray
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait........");
setfillstyle(SOLID_FILL,8);
bar(180,250,480,290);

51

setcolor(BLACK);
outtextxy(210,240,"RECORD IS DELETED SUCCESSFULLY.......");
settextstyle(0,0,0);
}
else
{
error("RECORD IS NOT FOUND");
patient_dform();
}
}
void patient_dform()
{
char opdno[10];
screen3(95,84,maxx-12,maxy-12,3,8,"PATIENT DELETE FORM");
Button3(160,115,300,135,8,"Patient id:-");
Button2(310,115,500,135,"");
Button1(320,maxy-40,420,maxy-20,"Delete More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void patientdclose()
{
int exet=0,exet1;
patient_dform();
patient_delete();
do{
exet1=0;
do{
if(check_button(320,maxy-40,420,maxy-20,"Delete More"))
{
patient_dform();
patient_delete();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}

52

void patient_work()
{
int exet=0;
patient();
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
exet=1;
if(check_button(20,150,85,180,"Add"))
{
patient_awork();
patient();
}
if(check_button(20,190,85,220,"Modify"))
{
patientmclose();
patient();
}
if(check_button(20,230,85,260,"Delete"))
{
patientdclose();
patient();
}
if(check_button(20,maxy-110,85,maxy-90,"Exit"))
exet=1;
}while(exet!=1);
}
////////////////////////////////PATIENT END////////////////////////////

////////////////////////////////DOCTOR/////////////////////////////////
void doctor()
{
screen3(12,84,maxx-546,maxy-12,3,8,"DOCTOR");
Button1(20,150,85,180,"Add");
Button1(20,190,85,220,"Modify");
Button1(20,230,85,260,"Delete");
setlinestyle(0,1,3);
line(18,350,88,350);
setlinestyle(0,0,0);
Button1(20,maxy-110,85,maxy-90,"Exit");
}

53

void doctor_add_form()
{
screen3(95,84,maxx-12,maxy-12,3,8,"DOCTOR ADD FORM");
Button3(150,120,200,140,8,"Doctor Regn no:-");
Button2(240,120,400,140,"");
Button3(150,150,200,170,8,"Name:-");
Button2(240,150,400,170,"");
Button3(150,180,200,200,8,"Address:-");
Button2(240,180,400,200,"");
Button3(150,210,200,230,8,"Age:-");
Button2(240,210,400,230,"");
Button3(150,240,200,260,8,"Sex:-");
Button2(240,240,400,260,"");
Button3(150,270,200,290,8,"City:-");
Button2(240,270,400,290,"");
Button3(150,300,200,320,8,"D_of_join:-");
Button2(240,300,400,320,"");
Button3(150,330,200,350,8,"Department");
Button2(240,330,400,350,"");
Button3(150,360,200,380,8,"D_of_Leave:-");
Button2(240,360,400,380,"");
Button3(150,390,200,410,8,"Contact no:-");
Button2(240,390,400,410,"");
Button3(410,120,500,140,8,"Specility:-");
Button2(500,120,610,140,"");
Button3(410,150,500,170,8,"Desig:-");
Button2(500,150,610,170,"");
Button3(410,180,500,200,8,"Quali:-");
Button2(500,180,610,200,"");
Button3(410,210,500,230,8,"Salary:-");
Button2(500,210,610,230,"");
Button3(410,240,500,260,8,"M_status:-");
Button2(500,240,610,260,"");
Button1(220,maxy-40,280,maxy-20,"Save");
Button1(320,maxy-40,400,maxy-20,"Add More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void doc_a_write(docc r)
{
FILE *fp;
fp=fopen("doctor.dat","ab");
fwrite(&r,sizeof(r),1,fp);
fclose(fp);
}

54

int regnno_search(char regnno[])


{
FILE *fp;
int f=0; //Not Exist
docc r;
fp=fopen("doctor.dat","rb");
while(fread(&r,sizeof(r),1,fp))
{
if((strcmp(r.d_regnno,regnno))==0)
{
f=1;
break;
}
}
fclose(fp);
return(f);
}
void entry_doc(docc *t)
{
char r[50]="";
int f;
getstring(240,120,400,140,r,9);
while(regnno_search(r))
{
setcolor(0);
outtextxy(410,320,"This D_regno already exist");
getstring(240,120,400,140,r,9);
setcolor(8);
outtextxy(410,320,"This D_regno already exist");
}
strcpy(t->d_regnno,r);
while(1)
{
getstring(240,150,400,170,r,30);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");

55

break;
}
}
strcpy(t->d_name,r);
getstring(240,180,400,200,r,30);
strcpy(t->d_address,r);
while(1)
{
getstring(240,210,400,230,r,2);
if(!check_digit(r))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->d_age,r);
while(1)
{
getstring(240,240,400,260,r,7);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->d_sex,r);
while(1)

56

{
getstring(240,270,400,290,r,20);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->d_city,r);
while(1)
{
getstring(240,300,400,320,r,15);
if(!check_date(r))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->d_d_of_join,r);
while(1)
{
getstring(240,330,400,350,r,15);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}

57

Else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->d_deptt,r);
while(1)
{
getstring(240,360,400,380,r,15);
if(!check_date(r))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->d_d_of_leave,r);
while(1)
{
getstring(240,390,400,410,r,10);
if(!check_digit(r))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}

58

}
strcpy(t->d_contactno,r);
while(1)
{
getstring(500,120,610,140,r,15);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->d_specility,r);
while(1)
{
getstring(500,150,610,170,r,15);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->d_desig,r);
while(1)
{
getstring(500,180,610,200,r,15);
if(!check_alpha(r))
{
setcolor(0);

59

outtextxy(430,320,"enter char value");


}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;
}
}
strcpy(t->d_quali,r);
while(1)
{
getstring(500,210,610,230,r,15);
if(!check_digit(r))
{
setcolor(0);
outtextxy(430,320,"enter numeric value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter numeric value");
break;
}
}
strcpy(t->d_salary,r);
while(1)
{
getstring(500,240,610,260,r,15);
if(!check_alpha(r))
{
setcolor(0);
outtextxy(430,320,"enter char value");
}
else
{
setcolor(8);
outtextxy(430,320,"enter char value");
break;

60

}
}
strcpy(t->d_marital,r);
}
void doctor_a_form()
{
docc r;
int exet=0,exet1=0;
doctor_add_form();
do{
exet1=0;
hidemouse();
entry_doc(&r);
showmouse();
do{
if(check_button(320,maxy-40,400,maxy-20,"Add More"))
{
doctor_add_form();
exet1=1;
}
if(check_button(220,maxy-40,280,maxy-20,"Save"))
{
doc_a_write(r);
doctor_add_form();
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
void doctor_awork()
{
doctor_a_form();

61

}
//////////////////doctor modify/////////////////////////////
void edit_docc(docc *t)
{
Button3(150,150,200,170,8,"Name:-");
Button2(240,150,400,170,"");
Button3(150,180,200,200,8,"Address:-");
Button2(240,180,400,200,"");
Button3(150,210,200,230,8,"Age:-");
Button2(240,210,400,230,"");
Button3(150,240,200,260,8,"Sex:-");
Button2(240,240,400,260,"");
Button3(150,270,200,290,8,"City:-");
Button2(240,270,400,290,"");
Button3(150,300,200,320,8,"D_of_join:-");
Button2(240,300,400,320,"");
Button3(150,330,200,350,8,"Department:-");
Button2(240,330,400,350,"");
Button3(150,360,200,380,8,"D_of_Leave:-");
Button2(240,360,400,380,"");
Button3(150,390,200,410,8,"Contact no:-");
Button2(240,390,400,410,"");
Button3(410,120,500,140,8,"Specility:-");
Button2(500,120,610,140,"");
Button3(410,150,500,170,8,"Desig:-");
Button2(500,150,610,170,"");
Button3(410,180,500,200,8,"Quali:-");
Button2(500,180,610,200,"");
Button3(410,210,500,230,8,"Salary:-");
Button2(500,210,610,230,"");
Button3(410,240,500,260,8,"M_status:-");
Button2(500,240,610,260,"");
setcolor(BLACK);
hidemouse();
outtextxy(320,160,t->d_name);
outtextxy(310,190,t->d_address);
outtextxy(250,220,t->d_age);
outtextxy(262,250,t->d_sex);
outtextxy(285,280,t->d_city);
outtextxy(275,310,t->d_d_of_join);
outtextxy(260,340,t->d_deptt);
outtextxy(275,370,t->d_d_of_leave);
outtextxy(285,400,t->d_contactno);
outtextxy(530,132,t->d_specility);
outtextxy(548,160,t->d_desig);

62

outtextxy(537,190,t->d_quali);
outtextxy(530,220,t->d_salary);
outtextxy(530,250,t->d_marital);
showmouse();
getstringm(240,150,400,170,t->d_name,18);
getstringm(240,180,400,200,t->d_address,15);
getstringm(240,210,400,230,t->d_age,2);
getstringm(240,240,400,260,t->d_sex,7);
getstringm(240,270,400,290,t->d_city,10);
getstringm(240,300,400,320,t->d_d_of_join,15);
getstringm(240,330,400,350,t->d_deptt,15);
getstringm(240,360,400,380,t->d_d_of_leave,15);
getstringm(240,390,400,410,t->d_contactno,10);
getstringm(500,120,610,140,t->d_specility,15);
getstringm(500,150,610,170,t->d_desig,15);
getstringm(500,180,610,200,t->d_quali,15);
getstringm(500,210,610,230,t->d_salary,15);
getstringm(500,240,610,260,t->d_marital,15);
}
void docc_modify()
{
char regnno[10];
FILE *fp;
int p;
int f=0;
docc r;
getstring(240,120,400,140,regnno,20);
fp=fopen("doctor.dat","rb+");
p=ftell(fp);
while(fread(&r,sizeof(r),1,fp))
{
if((strcmp(r.d_regnno,regnno))==0)
{
f=1;
break;
}
p=ftell(fp);
}
if(f==1)
{
fseek(fp,p,0);
edit_docc(&r);
fwrite(&r,sizeof(r),1,fp);
setcolor(14);
outtextxy(460,320,"RECORD IS MODIFIED");

63

}
else
{
error("RECORD NOT FOUND");
doctor_mform();
}
fclose(fp);
}
void doctor_mform()
{
screen3(95,84,maxx-12,maxy-12,3,8,"DOCTOR MODIFY FORM");
Button3(150,120,200,140,8,"Doctor Regn no:-");
Button2(240,120,400,140,"");
Button1(320,maxy-40,420,maxy-20,"Modify More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void doctormclose()
{
int exet=0,exet1;
doctor_mform();
docc_modify();
do{
exet1=0;
do{
if(check_button(320,maxy-40,420,maxy-20,"Modify More"))
{
doctor_mform();
docc_modify();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}

64

///////////////////doctor delete////////////////////////////////////
void doctor_delete()
{
docc r;
char regnno[10];
int x1=181,y1=251,x2=200,y2=289,i;
FILE *f1,*f2;
int f=0;
getstring(310,115,500,135,regnno,10);
f1=fopen("doctor.dat","rb");
f2=fopen("temp.dat","wb");
while(fread(&r,sizeof(r),1,f1))
{
if((strcmp(r.d_regnno,regnno))!=0)
{
fwrite(&r,sizeof(r),1,f2);
}
else
f=1;
}
fclose(f1);
fclose(f2);
remove("doctor.dat");
rename("temp.dat","doctor.dat");
if(f==1)
{
settextstyle(1,0,1);
setcolor(0);
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait.....");// bar
bar(180,250,480,290);
for(i=0;i<29;i++)
{
setfillstyle(SOLID_FILL,BLUE);
bar(x1,y1,x2,y2);
delay(50);
x1=x1+10;
x2=x2+10;
}
setcolor(8);
//8 for dark_gray
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait.....");// bar
setfillstyle(SOLID_FILL,8);
bar(180,250,480,290);

65

setcolor(BLACK);
outtextxy(210,240,"RECORD IS DELETED SUCCESSFULLY.........");
settextstyle(0,0,0);
}
else
{
error("RECORD IS NOT FOUND");
doctor_dform();
}
}
void doctor_dform()
{
int regnno[10];
screen3(95,84,maxx-12,maxy-12,3,8,"DOCTOR DELETE FORM");
Button3(160,115,300,135,8,"Doctor Regn no:-");
Button2(310,115,500,135,"");
Button1(320,maxy-40,420,maxy-20,"Delete More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void doctordclose()
{
int exet=0,exet1;
doctor_dform();
doctor_delete();
do{
exet1=0;
do{
if(check_button(320,maxy-40,420,maxy-20,"DeleteMore"))
{
doctor_dform();
doctor_delete();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}

66

void doctor_work()
{
int exet=0;
doctor();
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
exet=1;
if(check_button(20,150,85,180,"Add"))
{
doctor_awork();
doctor();
}
if(check_button(20,190,85,220,"Modify"))
{
doctormclose();
doctor();
}
if(check_button(20,230,85,260,"Delete"))
{
doctordclose();
doctor();
}
if(check_button(20,maxy-110,85,maxy-90,"Exit"))
exet=1;
}while(exet!=1);
}
/////////////////////// DOCTOR END/////////////////////////////////
////////////////////////////Ward/////////////////////////////////////
void ward()
{
screen3(12,84,maxx-546,maxy-12,3,8,"WARD");
Button1(20,150,85,180,"Add");
Button1(20,190,85,220,"Modify");
Button1(20,230,85,260,"Delete");
setlinestyle(0,1,3);
line(18,350,88,350);
setlinestyle(0,0,0);
Button1(20,maxy-110,85,maxy-90,"Exit");
}

67

void ward_add_form()
{
screen3(95,84,maxx-12,maxy-12,3,8,"WARD ADD FORM");
Button3(160,115,300,135,8,"Ward no:-");
Button2(310,115,500,135,"");
Button3(160,145,300,165,8,"Ward name:-");
Button2(310,145,500,165,"");
Button3(160,175,300,195,8,"Ward charge :-");
Button2(310,175,500,195,"");
Button3(160,205,300,225,8,"Ward type:-");
Button2(310,205,500,225,"");
Button3(160,235,300,255,8,"Patient id:-");
Button2(310,235,500,255,"");
Button1(220,maxy-40,280,maxy-20,"Save");
Button1(320,maxy-40,400,maxy-20,"Add More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void war_a_write(warr a)
{
FILE *fp;
fp=fopen("ward.dat","ab");
fwrite(&a,sizeof(a),1,fp);
fclose(fp);
}
void entry_war(warr *t)
{
char a[50]="";
getstring(310,115,500,135,a,9);
strcpy(t->w_wardno,a);
while(1)
{
getstring(310,145,500,165,a,20);
if(!check_alpha(a))
{
setcolor(0);
outtextxy(250,320,"Please enter char value");
}
else
{
setcolor(8);
outtextxy(250,320,"Please enter char value");
break;
}

68

}
strcpy(t->w_wardname,a);
while(1)
{
getstring(310,175,500,195,a,20);
if(!check_float(a))
{
setcolor(0);
outtextxy(250,320,"Please enter numeric/float value");
}
else
{
setcolor(8);
outtextxy(250,320,"Please enter numeric/float value");
break;
}
}
t->w_wardcharge=atof(a);
while(1)
{
getstring(310,205,500,225,a,20);
if(!check_alpha(a))
{
setcolor(0);
outtextxy(250,320,"Please enter char value");
}
else
{
setcolor(8);
outtextxy(250,320,"Please enter char value");
break;
}
}
strcpy(t->w_wardtype,a);
while(1)
{
getstring(310,235,500,255,a,20);
if(!check_digit(a))
{

69

setcolor(0);
outtextxy(250,320,"Please enter numeric value");
}
else
{
setcolor(8);
outtextxy(250,320," Please enter numeric value");
break;
}
}
strcpy(t->w_id,a);
}
void ward_a_form()
{
warr a;
int exet=0,exet1=0;
ward_add_form();
do{
exet1=0;
hidemouse();
entry_war(&a);
showmouse();
do{
if(check_button(320,maxy-40,400,maxy-20,"Add More"))
{
ward_add_form();
exet1=1;
}
if(check_button(220,maxy-40,280,maxy-20,"Save"))
{
war_a_write(a);
ward_add_form();
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}

70

}while(exet1!=1);
}while(exet!=1);
}
void ward_awork()
{
ward_a_form();
}
///////////////////ward modify///////////////////////////////////
void edit_warr(warr *t)
{
char a[25]="";
Button3(160,145,300,165,8,"Ward name:-");
Button2(310,145,500,165,"");
Button3(160,175,300,195,8,"Ward charge:-");
Button2(310,175,500,195,"");
Button3(160,205,300,225,8,"Ward type:-");
Button2(310,205,500,225,"");
Button3(160,235,300,255,8,"Patient id:-");
Button2(310,235,500,255,"");
setcolor(BLACK);
hidemouse();
outtextxy(380,150,t->w_wardname);
ftoa(t->w_wardcharge,a);
outtextxy(380,190,a);
outtextxy(350,220,t->w_wardtype);
outtextxy(350,250,t->w_id);
showmouse();
getstringm(310,145,500,165,t->w_wardname,20);
getstringm(310,175,500,195,a,20);
t->w_wardcharge=atof(a);
getstringm(310,205,500,225,t->w_wardtype,20);
getstringm(310,235,500,255,t->w_id,20);
}
void warr_modify()
{
char wardno[10];
FILE *fp;
int p;
int f=0;
warr a;
getstring(310,115,500,135,wardno,20);
fp=fopen("ward.dat","rb+");
p=ftell(fp);

71

while(fread(&a,sizeof(a),1,fp))
{
if((strcmp(a.w_wardno,wardno))==0)
{
f=1;
break;
}
p=ftell(fp);
}
if(f==1)
{
fseek(fp,p,0);
edit_warr(&a);
fwrite(&a,sizeof(a),1,fp);
setcolor(14);
outtextxy(200,300,"RECORD IS MODIFIED SUCCESSFULLY.........");
}
else
{
error("RECORD NOT FOUND");
ward_mform();
}
fclose(fp);
}
void ward_mform()
{
screen3(95,84,maxx-12,maxy-12,3,8,"WARD MODIFY FORM");
Button3(160,115,300,135,8,"Ward no:-");
Button2(310,115,500,135,"");
Button1(320,maxy-40,420,maxy-20,"Modify More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void wardmclose()
{
int exet=0,exet1;
ward_mform();
warr_modify();
do{
exet1=0;
do{
if(check_button(320,maxy-40,420,maxy-20,"Modify More"))

72

{
ward_mform();
warr_modify();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
////////////////////////ward delete////////////////////////
void ward_delete()
{
warr a;
char wardno[13];
int x1=181,y1=251,x2=200,y2=289,i;
FILE *f1,*f2;
int f=0;
getstring(310,115,500,135,wardno,10);
f1=fopen("ward.dat","rb");
f2=fopen("temp.dat","wb");
while(fread(&a,sizeof(a),1,f1))
{
if((strcmp(a.w_wardno,wardno))!=0)
{
fwrite(&a,sizeof(a),1,f2);
}
else
f=1;
}
fclose(f1);
fclose(f2);
remove("L:2495\\project\\ward.dat");
rename("L:2495\\project\\temp.dat","L:2495\\project\\ward.dat");
if(f==1)
{
settextstyle(1,0,1);
setcolor(0);
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait......");// bar
bar(180,250,480,290);

73

for(i=0;i<29;i++)
{
setfillstyle(SOLID_FILL,BLUE);
bar(x1,y1,x2,y2);
delay(50);
x1=x1+10;
x2=x2+10;
}
setcolor(8);
//8 for dark_gray
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait.....");// bar
setfillstyle(SOLID_FILL,8);
bar(180,250,480,290);
setcolor(BLACK);
outtextxy(210,240,"RECORD IS DELETED SUCCESSFULLY.........");
settextstyle(0,0,0);
}
else
{
error("RECORD IS NOT FOUND");
ward_dform();
}
}
void ward_dform()
{
int wardno[10];
screen3(95,84,maxx-12,maxy-12,3,8,"WARD DELETE FORM");
Button3(160,115,300,135,8,"Ward no:-");
Button2(310,115,500,135,"");
Button1(320,maxy-40,420,maxy-20,"Delete More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void warddclose()
{
int exet=0,exet1;
ward_dform();
ward_delete();
do{
exet1=0;
do{
if(check_button(320,maxy-40,420,maxy-20,"Delete More"))

74

{
ward_dform();
ward_delete();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
void ward_work()
{
int exet=0;
ward();
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
exet=1;
if(check_button(20,150,85,180,"Add"))
{
ward_awork();
ward();
}
if(check_button(20,190,85,220,"Modify"))
{
wardmclose();
ward();
}
if(check_button(20,230,85,260,"Delete"))
{
warddclose();
ward();
}
if(check_button(20,maxy-110,85,maxy-90,"Exit"))
exet=1;
}while(exet!=1);
}
//////////////////////////////WARD END////////////////////////////////////

75

/////////////////////////TEST///////////////////////////////////////////
void test()
{
screen3(12,84,maxx-546,maxy-12,3,8,"TEST");
Button1(20,150,85,180,"Add");
Button1(20,190,85,220,"Modify");
Button1(20,230,85,260,"Delete");
setlinestyle(0,1,3);
line(18,350,88,350);
setlinestyle(0,0,0);
Button1(20,maxy-110,85,maxy-90,"Exit");
}
void test_add_form()
{
screen3(95,84,maxx-12,maxy-12,3,8,"TEST ADD FORM");
Button3(160,115,300,135,8,"Test no :-");
Button2(310,115,500,135,"");
Button3(160,145,300,165,8,"Test name:-");
Button2(310,145,500,165,"");
Button3(160,175,300,195,8,"Test charge:-");
Button2(310,175,500,195,"");
Button1(220,maxy-40,280,maxy-20,"Save");
Button1(320,maxy-40,400,maxy-20,"Add More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void tes_a_write(tess w)
{
FILE *fp;
fp=fopen("test.dat","ab");
fwrite(&w,sizeof(w),1,fp);
fclose(fp);
}
void entry_tes(tess *t)
{
char w[50]="";
getstring(310,115,500,135,w,20);
strcpy(t->t_testno,w);
while(1)
{
getstring(310,145,500,165,w,20);
if(!check_alpha(w))
{
setcolor(0);
outtextxy(250,320,"Please enter char value");

76

}
else
{
setcolor(8);
outtextxy(250,320,"Please enter char value");
break;
}
}
strcpy(t->t_testname,w);
while(1)
{
getstring(310,175,500,195,w,20);
if(!check_float(w))
{
setcolor(0);
outtextxy(250,320,"Please enter numeric/float value");
}
else
{
setcolor(8);
outtextxy(250,320,"Please enter numeric/float value");
break;
}
}
t->t_testcharge=atof(w);
}
void test_a_form()
{
tess w;
int exet=0,exet1=0;
test_add_form();
do{
exet1=0;
hidemouse();
entry_tes(&w);
showmouse();
do{
if(check_button(320,maxy-40,400,maxy-20,"Add More"))
{
test_add_form();
exet1=1;

77

}
if(check_button(220,maxy-40,280,maxy-20,"Save"))
{
tes_a_write(w);
test_add_form();
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
void test_awork()
{
test_a_form();
}
//////////////////////test modify/////////////////////////////
void edit_tess(tess *t)
{
char w[25]="";
Button3(160,145,300,165,8,"Test name:-");
Button2(310,145,500,165,"");
Button3(160,175,300,195,8,"Test charge:-");
Button2(310,175,500,195,"");
setcolor(BLACK);
hidemouse();
outtextxy(380,150,t->t_testname);
ftoa(t->t_testcharge,w);
outtextxy(380,190,w);
showmouse();
getstringm(310,145,500,165,t->t_testname,20);
t->t_testcharge=atof(w);
getstringm(310,175,500,195,w,20);
}

78

void tess_modify()
{
char testno[10];
FILE *fp;
int p;
int f=0;
tess w;
getstring(310,115,500,135,testno,5);
fp=fopen("test.dat","rb+");
p=ftell(fp);
while(fread(&w,sizeof(w),1,fp))
{
if((strcmp(w.t_testno,testno))==0)
{
f=1;
break;
}
p=ftell(fp);
}
if(f==1)
{
fseek(fp,p,0);
edit_tess(&w);
fwrite(&w,sizeof(w),1,fp);
setcolor(14);
outtextxy(200,300,"RECORD IS MODIFIED SUCCESSFULLY.....");
}
else
{
error("RECORD NOT FOUND");
test_mform();
}
fclose(fp);
}
void test_mform()
{
char str[20],testcodeno[20];
screen3(95,84,maxx-12,maxy-12,3,8,"TEST MODIFY FORM");
Button3(160,115,300,135,8,"Test no:-");
Button2(310,115,500,135,"");
Button1(320,maxy-40,420,maxy-20,"Modify More");
Button1(450,maxy-40,520,maxy-20,"Cancel");

79

}
void testmclose()
{
int exet=0,exet1;
test_mform();
tess_modify();
do{
exet1=0;
do
{
if(check_button(320,maxy-40,420,maxy-20,"Modify More"))
{
test_mform();
tess_modify();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
//////////////////////test delete////////////////////////////////
void test_delete()
{
tess w;
char testno[20];
int x1=181,y1=251,x2=200,y2=289,i;
FILE *f1,*f2;
int f=0;
getstring(310,115,500,135,testno,5);
f1=fopen("test.dat","rb");
f2=fopen("temp.dat","wb");
while(fread(&w,sizeof(w),1,f1))
{
if((strcmp(w.t_testno,testno))!=0)
{
fwrite(&w,sizeof(w),1,f2);
}
else
f=1;
}

80

fclose(f1);
fclose(f2);
remove("test.dat");
rename("temp.dat","test.dat");
if(f==1)
{
settextstyle(1,0,1);
setcolor(0);
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait......");// bar
bar(180,250,480,290);
for(i=0;i<29;i++)
{
setfillstyle(SOLID_FILL,BLUE);
bar(x1,y1,x2,y2);
delay(50);
x1=x1+10;
x2=x2+10;
}
setcolor(8);
//8 for dark_gray
outtextxy(250,225,"Record is deleting");
outtextxy(230,320,"please wait.....");// bar
setfillstyle(SOLID_FILL,8);
bar(180,250,480,290);
setcolor(BLACK);
outtextxy(210,240,"RECORD IS DELETED SUCCESSFULLY.......");
settextstyle(0,0,0);
}
else
{
error("RECORD IS NOT FOUND");
test_dform();
}
}
void test_dform()
{
screen3(95,84,maxx-12,maxy-12,3,8,"TEST DELETE FORM");
Button3(160,115,300,135,8,"Test no:-");
Button2(310,115,500,135,"");
Button1(320,maxy-40,420,maxy-20,"Delete More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}

81

void testdclose()
{
int exet=0,exet1;
test_dform();
test_delete();
do{
do{
exet1=0;
if(check_button(320,maxy-40,420,maxy-20,"Delete More"))
{
test_dform();
test_delete();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
clear_screen(95,84,maxx-12,maxy-12,8);
}
}while(exet1!=1);
}while(exet!=1);
}
void test_work()
{
int exet=0;
test();
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
exet=1;
if(check_button(20,150,85,180,"Add"))
{
test_awork();
test();
}
if(check_button(20,190,85,220,"Modify"))
{
testmclose();
test();
}
if(check_button(20,230,85,260,"Delete"))
{
testdclose();

82

test();
}
if(check_button(20,maxy-110,85,maxy-90,"Exit"))
exet=1;
}while(exet!=1);
}
//////////////////////TEST END/////////////////////
///////////////////////////BILL START////////////////////////////
void patient_bill1()
{
screen1(12,84,maxx-12,maxy-12,2,8,"PATIENT BILL DETAILS");
Button3(40,130,126,150,8,"Patient id:-");
Button2(140,130,226,150,"");
}
int search_p_id(char id[])
{
int f=0;
FILE *fp;
patt a1;
fp=fopen("patient.dat","rb");
while(fread(&a1,sizeof(a1),1,fp))
{
if((strcmp(id,a1.p_id))==0)
{
f=1;
break;
}
}
fclose(fp);
return(f);
}
void patient_s_work1()
{
int exet=0,flag=0;
char id[10];
FILE *fp;
FILE *fp1;
FILE *fp2;
int i,j;
char s[25];
char a[10];
patt a1;
warr b1;
tess c1;

83

int f1,f2,f3;
float amt;
patient_bill1();
getstring(140,130,226,150,id,5);
if(search_p_id(id))
{
hidemouse();
outtextxy(280,192,"BILL DETAILS");
line(23,213,maxx-25,213);
line(23,243,maxx-25,243);
outtextxy(25,228,"TEST NO");
outtextxy(95,228,"TEST NAME");
outtextxy(195,228,"PATIENT NAME");
outtextxy(315,228,"REFER BY");
outtextxy(392,228,"WARD NO");
outtextxy(455,228,"WARD CHRG");
outtextxy(535,228,"TEST CHRG");
line(22,213,22,277);
line(83,213,83,277);
line(180,213,180,277);
line(300,213,300,277);
line(387,213,387,277);
line(450,213,450,277);
line(530,213,530,277);
line(614,213,614,277);
line(23,277,maxx-25,277);
outtextxy(410,300,"TOTAL AMOUNT:-");
f1=f2=f3=0;
fp=fopen("patient.dat","rb");
i=10;
j=258;
while(fread(&a1,sizeof(a1),1,fp))
{
if((strcmp(id,a1.p_id))==0)
{
f1=1;
break;
}
}
if(f1==1)
{
fp1=fopen("ward.dat","rb");
while(fread(&b1,sizeof(b1),1,fp1))
{
if((strcmp(a1.p_wardno,b1.w_wardno))==0)
{

84

f2=1;
break;
}
}
fp2=fopen("test.dat","rb");
while(fread(&c1,sizeof(c1),1,fp2))
{
if((strcmp(a1.p_testno,c1.t_testno))==0)
{
f3=1;
break;
}
}
}
if(f2==1||f3==1)
{
flag=1;
outtextxy(i+25,j,c1.t_testno);
outtextxy(i+95,j,c1.t_testname);
outtextxy(i+190,j,a1.p_name);
outtextxy(i+315,j,a1.p_referby);
outtextxy(i+392,j,b1.w_wardno);
ftoa(b1.w_wardcharge,a);
outtextxy(i+455,j,a);
ftoa(c1.t_testcharge,s);
outtextxy(i+535,j,s);
amt=(b1.w_wardcharge)+(c1.t_testcharge);
j+=20;
}
if(flag==1)
{
ftoa(amt,s);
outtextxy(530,300,s);
}
showmouse();
}
else
{
error("Record not found");
patient_bill1();
}
do{
if(check_button(maxx-34,89,maxx-18,103,"X"))

85

{
exet=1;
}
}while(exet!=1);
}
void bill_mnu()
{
int exet=0;
screen_bill();
do{
if(check_button(maxx-28,47,maxx-12,61,"X"))
{
exet=1;
}
if(check_button(15,65,120,79,"Patient Bill"))
{
patient_s_work1();
screen_bill();
}
}while(exet!=1);
}
///////////////////////////////BILL END/////////////////////
/////////////////////SEARCH/////////////////////////////////////////
void patt_search()
{
FILE *fp;
patt s;
int f=0;
char id[10];
getstring(240,120,400,140,id,5);
fp=fopen("patient.dat","rb");
while(fread(&s,sizeof(s),1,fp))
{
if((strcmp(s.p_id,id))==0)
{
f=1;
break;
}
}
fclose(fp);

86

if(f==1)
{
Button3(150,150,200,170,8,"Name:-");
Button2(240,150,400,170,"");
Button3(150,180,200,200,8,"Address:-");
Button2(240,180,400,200,"");
Button3(150,210,200,230,8,"Age:-");
Button2(240,210,400,230,"");
Button3(150,240,200,260,8,"Sex:-");
Button2(240,240,400,260,"");
Button3(150,270,200,290,8,"City:-");
Button2(240,270,400,290,"");
Button3(150,300,200,320,8,"Disease:-");
Button2(240,300,400,320,"");
Button3(150,330,200,350,8,"D_of_admission:-");
Button2(240,330,400,350,"");
Button3(150,360,200,380,8,"D_of_discharge:-");
Button2(240,360,400,380,"");
Button3(150,390,200,410,8,"Contact no:-");
Button2(240,390,400,410,"");
Button3(410,120,500,140,8,"Refer by:-");
Button2(500,120,610,140,"");
Button3(410,150,500,170,8,"Ward no:-");
Button2(500,150,610,170,"");
Button3(410,180,500,200,8,"Bed no:-");
Button2(500,180,610,200,"");
Button3(410,210,500,230,8,"Test no:-");
Button2(500,210,610,230,"");
Button3(410,240,500,260,8,"Country:-");
Button2(500,240,610,260,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
outtextxy(295,160,s.p_name);
outtextxy(305,190,s.p_address);
outtextxy(255,220,s.p_age);
outtextxy(260,250,s.p_sex);
outtextxy(298,280,s.p_city);
outtextxy(280,310,s.p_disease);
outtextxy(276,340,s.p_d_of_admission);
outtextxy(275,370,s.p_d_of_discharge);
outtextxy(290,400,s.p_contactno);
outtextxy(540,132,s.p_referby);
outtextxy(526,160,s.p_wardno);
outtextxy(527,190,s.p_bedno);
outtextxy(525,220,s.p_testno);
outtextxy(525,250,s.p_country);

87

}
else
{
error("RECORD NOT FOUND");
patient_search();
}
}
void patient_search()
{
screen3(12,84,maxx-12,maxy-12,3,8,"PATIENT SEARCHING");
Button3(150,120,200,140,8,"Patient id:-");
Button2(240,120,400,140,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void patient_s_work()
{
int exet=0,exet1;
patient_search();
patt_search();
do{
exet1=0;
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
{
exet1=1;
exet=1;
}
if(check_button(300,maxy-40,400,maxy-20,"Search More"))
{
patient_search();
patt_search();
exet=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
}
}while(exet1!=1);
}while(exet!=1);
}

88

//////////////////////DOCTOR SEARCH/////////////////////////////////////////
void docc_search()
{
FILE *fp;
docc r;
int f=0;
char regnno[10];
getstring(240,120,400,140,regnno,5);
fp=fopen("doctor.dat","rb");
while(fread(&r,sizeof(r),1,fp))
{
if((strcmp(r.d_regnno,regnno))==0)
{
f=1;
break;
}
}
fclose(fp);
if(f==1)
{
Button3(150,150,200,170,8,"Name:-");
Button2(240,150,400,170,"");
Button3(150,180,200,200,8,"Address:-");
Button2(240,180,400,200,"");
Button3(150,210,200,230,8,"Age:-");
Button2(240,210,400,230,"");
Button3(150,240,200,260,8,"Sex:-");
Button2(240,240,400,260,"");
Button3(150,270,200,290,8,"City:-");
Button2(240,270,400,290,"");
Button3(150,300,200,320,8,"D_of_join:-");
Button2(240,300,400,320,"");
Button3(150,330,200,350,8,"Department:-");
Button2(240,330,400,350,"");
Button3(150,360,200,380,8,"D_of_Leave:-");
Button2(240,360,400,380,"");
Button3(150,390,200,410,8,"Contact no:-");
Button2(240,390,400,410,"");
Button3(410,120,500,140,8,"Specility:-");
Button2(500,120,610,140,"");
Button3(410,150,500,170,8,"Desig:-");
Button2(500,150,610,170,"");
Button3(410,180,500,200,8,"Quali:-");
Button2(500,180,610,200,"");
Button3(410,210,500,230,8,"Salary:-");

89

Button2(500,210,610,230,"");
Button3(410,240,500,260,8,"M_status:-");
Button2(500,240,610,260,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
outtextxy(300,160,r.d_name);
outtextxy(310,190,r.d_address);
outtextxy(255,220,r.d_age);
outtextxy(260,250,r.d_sex);
outtextxy(300,280,r.d_city);
outtextxy(275,310,r.d_d_of_join);
outtextxy(295,340,r.d_deptt);
outtextxy(275,370,r.d_d_of_leave);
outtextxy(290,400,r.d_contactno);
outtextxy(545,132,r.d_specility);
outtextxy(545,160,r.d_desig);
outtextxy(535,190,r.d_quali);
outtextxy(530,220,r.d_salary);
outtextxy(530,250,r.d_marital);
}
else
{
error("RECORD NOT FOUND");
doctor_search();
}
}
void doctor_search()
{
screen3(12,84,maxx-12,maxy-12,3,8,"DOCTOR SEARCHING");
Button3(150,120,200,140,8,"Doctor Regn no:-");
Button2(240,120,400,140,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void doctor_s_work()
{
int exet=0,exet1;
doctor_search();
docc_search();
do{
exet1=0;
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))

90

{
exet1=1;
exet=1;
}
if(check_button(300,maxy-40,400,maxy-20,"Search More"))
{
doctor_search();
docc_search();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
}
}while(exet1!=1);
}while(exet!=1);
}
//////////////////////////////////////////////////////////////////////
/////////////////////ward search//////////////////////////////////////
void warr_search()
{
FILE *fp;
warr a;
char d[10]="";
int f=0;
char wardno[10];
getstring(310,150,500,170,wardno,5);
fp=fopen("ward.dat","rb");
while(fread(&a,sizeof(a),1,fp))
{
if((strcmp(a.w_wardno,wardno))==0)
{
f=1;
break;
}
}
fclose(fp);
if(f==1)
{
Button3(100,180,300,200,8,"Ward name:-");
Button2(310,180,500,200,"");
Button3(100,210,300,230,8,"Ward charge:-");
Button2(310,210,500,230,"");
Button3(100,240,300,260,8,"Ward type:-");

91

Button2(310,240,500,260,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
outtextxy(380,190,a.w_wardname);
ftoa(a.w_wardcharge,d);
outtextxy(380,220,d);
outtextxy(390,250,a.w_wardtype);
}
else
{
error("RECORD NOT FOUND");
ward_search();
}
}
void ward_search()
{
screen3(12,84,maxx-12,maxy-12,3,8,"WARD SEARCHING");
Button3(100,150,300,170,8,"Ward No:-");
Button2(310,150,500,170,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void ward_s_work()
{
int exet=0,exet1;
ward_search();
warr_search();
do{
exet=0;
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
{
exet1=1;
exet=1;
}
if(check_button(300,maxy-40,400,maxy-20,"Search More"))
{
ward_search();
warr_search();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))

92

{
exet1=1;
exet=1;
}
}while(exet1!=1);
}while(exet!=1);
}
//////////////////////////////////////////////////////////////
////////////////////////test search///////////////////////////
void tess_search()
{
FILE *fp;
tess w;
int f=0;
char e[10]="";
char testno[10];
getstring(310,150,500,170,testno,5);
fp=fopen("test.dat","rb");
while(fread(&w,sizeof(w),1,fp))
{
if((strcmp(w.t_testno,testno))==0)
{
f=1;
break;
}
}
fclose(fp);
if(f==1)
{
Button3(100,180,300,200,8,"Test name:-");
Button2(310,180,500,200,"");
Button3(100,210,300,230,8,"Test charge:-");
Button2(310,210,500,230,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
outtextxy(390,190,w.t_testname);
ftoa(w.t_testcharge,e);
outtextxy(400,220,e);
}
else
{
error("RECORD NOT FOUND");
test_search();
}
}

93

void test_search()
{
screen3(12,84,maxx-12,maxy-12,3,8,"TEST SEARCHING");
Button3(100,150,300,170,8,"Test no:-");
Button2(310,150,500,170,"");
Button1(300,maxy-40,400,maxy-20,"Search More");
Button1(450,maxy-40,520,maxy-20,"Cancel");
}
void test_s_work()
{
int exet=0,exet1;
test_search();
tess_search();
do{
exet1=0;
do{
if(check_button(maxx-72,105,maxx-56,119,"X"))
{
exet1=1;
exet=1;
}
if(check_button(300,maxy-40,400,maxy-20,"Search More"))
{
test_search();
tess_search();
exet1=1;
}
if(check_button(450,maxy-40,520,maxy-20,"Cancel"))
{
exet1=1;
exet=1;
}
}while(exet1!=1);
}while(exet!=1);
}
void search_mnu()
{
int exet=0;
screen_search();
do{
if(check_button(maxx-28,47,maxx-12,61,"X"))
exet=1;
if(check_button(22,65,90,79,"Patient"))
{
patient_s_work();

94

screen_search();
}
if(check_button(92,65,160,79,"Doctor"))
{
doctor_s_work();
screen_search();
}
if(check_button(162,65,230,79,"Ward"))
{
ward_s_work();
screen_search();
}
if(check_button(232,65,300,79,"Test"))
{
test_s_work();
screen_search();
}
if(check_button(maxx-72,105,maxx-56,119,"X"))
{
exet=1;
}
}while(exet!=1);
}
////////////////////////SEARCH END////////////////////////////////////
////////////////////////////REPORT//////////////////////////////
void patient_report()
{
screen1(12,84,maxx-12,maxy-12,14,0,"PATIENT REPORT" );
Button1(472,107,530,122,"Next");
setcolor(WHITE);
line(18,155,maxx-20,155);
outtextxy(50,140,"PAT_ID");
outtextxy(140,140,"NAME");
outtextxy(240,140,"AGE");
outtextxy(290,140,"SEX");
outtextxy(370,140,"D_OF_ADM");
outtextxy(455,140,"D_OF_DISG");
outtextxy(550,140,"CITY");
setcolor(WHITE);
line(80,125,80,maxy-18);
line(223,125,223,maxy-18);
line(256,125,256,maxy-18);
line(325,125,325,maxy-18);
line(410,125,410,maxy-18);
line(500,125,500,maxy-18);
}

95

void patient_r_print()
{
FILE *fp;
int i,j,c=0,exet=0;
patt s;
char str[30];
fp=fopen("patient.dat","rb");
i=40;
j=170;
while((fread(&s,sizeof(s),1,fp)))
{
c++;
if(c%15==0)
{
showmouse();
do{
if(check_button(472,107,530,122,"Next"))
{
patient_report();
j=170;
exet=1;
}
}while(exet!=1);
}
exet=0;
outtextxy(i,j,s.p_id);
outtextxy(i+100,j,s.p_name);
outtextxy(i+200,j,s.p_age);
outtextxy(i+256,j,s.p_sex);
outtextxy(i+320,j,s.p_d_of_admission);
outtextxy(i+410,j,s.p_d_of_discharge);
outtextxy(i+530,j,s.p_city);
j+=20;
}
fclose(fp);
}

96

void patient_r_work()
{
int exet=0;
patient_report();
patient_r_print();
do{
if(check_button(maxx-34,89,maxx-18,103,"X"))
exet=1;
}while(exet!=1);
}
//////////////////////////////////////////////////////////////
void doctor_report()
{
screen1(12,84,maxx-12,maxy-12,14,0,"Doctor Report" );
Button1(472,107,530,122,"Next");
setcolor(WHITE);
line(18,155,maxx-20,155);
outtextxy(50,140,"REGN_NO");
outtextxy(140,140,"NAME");
outtextxy(270,140,"DESIG");
outtextxy(380,140,"SPECILITY");
outtextxy(475,140,"D_OF_JOIN");
outtextxy(570,140,"CONTACT_NO");
setcolor(WHITE);
line(80,125,80,maxy-18);
line(230,125,230,maxy-18);
line(330,125,330,maxy-18);
line(435,125,435,maxy-18);
line(515,125,515,maxy-18);
line(618,125,618,maxy-18);
}
void doctor_r_print()
{
FILE *fp;
int i,j,c=0,exet=0;
docc r;
char str[30];
fp=fopen("doctor.dat","rb");
i=50;
j=170;
while((fread(&r,sizeof(r),1,fp)))
{
c++;

97

if(c%15==0)
{
showmouse();
do{
if(check_button(472,107,530,122,"Next"))
{
doctor_report();
j=170;
exet=1;
}
}while(exet!=1);
}
exet=0;
outtextxy(i,j,r.d_regnno);
outtextxy(i+100,j,r.d_name);
outtextxy(i+230,j,r.d_desig);
outtextxy(i+330,j,r.d_specility);
outtextxy(i+420,j,r.d_d_of_join);
outtextxy(i+520,j,r.d_contactno);
j+=20;
}
fclose(fp);
}
void doctor_r_work()
{
int exet=0;
doctor_report();
doctor_r_print();
do{
if(check_button(maxx-34,89,maxx-18,103,"X"))
exet=1;
}while(exet!=1);
}
////////////////////////////////////////////////////////////////////////
/////////////////////////////WARD REPORT///////////////////////////////
void ward_report()
{
screen1(12,84,maxx-12,maxy-12,14,0,"WARD REPORT" );
Button1(472,107,530,122,"Next");
setcolor(WHITE);
line(18,155,maxx-20,155);

98

outtextxy(65,140,"WARD NO");
outtextxy(170,140,"WARD NAME");
outtextxy(300,140,"WARD CHARGE");
outtextxy(430,140,"WARD TYPE");
outtextxy(560,140,"PATIENT ID");
line(110,125,110,maxy-18);
line(240,125,240,maxy-18);
line(370,125,370,maxy-18);
line(500,125,500,maxy-18);
line(715,125,715,maxy-18);
setcolor(WHITE);
}
void ward_r_print()
{
FILE *fp;
int i,j,c=0,exet=0;
warr a;
char str[30];
char d[10];
fp=fopen("ward.dat","rb");
i=60;
j=170;
while((fread(&a,sizeof(a),1,fp)))
{
c++;
if(c%15==0)
{
showmouse();
do{
if(check_button(472,107,530,122,"Next"))
{
ward_report();
j=170;
exet=1;
}
}while(exet!=1);
}
exet=0;
outtextxy(i,j,a.w_wardno);
outtextxy(i+110,j,a.w_wardname);
ftoa(a.w_wardcharge,d);
outtextxy(i+230,j,d);
outtextxy(i+360,j,a.w_wardtype);

99

outtextxy(i+490,j,a.w_id);
j+=20;
}
fclose(fp);
}
void ward_r_work()
{
int exet=0;
ward_report();
ward_r_print();
do{
if(check_button(maxx-34,89,maxx-18,103,"X"))
exet=1;
}while(exet!=1);
}
void test_report()
{
screen1(12,84,maxx-12,maxy-12,14,0,"TEST REPORT" );
Button1(472,107,530,122,"Next");
setcolor(WHITE);
line(18,155,maxx-20,155);
outtextxy(90,140,"TEST NO");
outtextxy(280,140,"TEST NAME");
outtextxy(500,140,"TEST CHARGE");
line(180,125,180,maxy-18);
line(400,125,400,maxy-18);
line(610,125,610,maxy-18);
setcolor(WHITE);
}
void test_r_print()
{
FILE *fp;
int i,j,c=0,exet=0;
tess w;
char str[30];
char e[10];
fp=fopen("test.dat","rb");
i=80;
j=170;
while((fread(&w,sizeof(w),1,fp)))
{

100

c++;
if(c%15==0)
{
showmouse();
do{
if(check_button(472,107,530,122,"Next"))
{
test_report();
j=170;
exet=1;
}
}while(exet!=1);
}
exet=0;
outtextxy(i,j,w.t_testno);
outtextxy(i+210,j,w.t_testname);
ftoa(w.t_testcharge,e);
outtextxy(i+400,j,e);
j+=20;
}
fclose(fp);
}
void test_r_work()
{
int exet=0;
test_report();
test_r_print();
do{
if(check_button(maxx-34,89,maxx-18,103,"X"))
exet=1;
}while(exet!=1);
}
//////////////////////////REPORT MENU/////////////////////////
void report_mnu()
{
int exet=0;
int i,j;
screen_report();
do{
if(check_button(10,65,125,79,"Patient Report"))
{

101

patient_r_work();
screen_report();
}
if(check_button(129,65,240,79,"Doctor Report"))
{
doctor_r_work();
screen_report();
}
if(check_button(244,65,340,79,"Ward Report"))
{
ward_r_work();
screen_report();
}
if(check_button(344,65,440,79,"Test Report"))
{
test_r_work();
screen_report();
}
if(check_button(maxx-28,47,maxx-12,61,"X"))
exet=1;
}while(exet!=1);
}
////////////////////////NEWINFORMATION MENU//////////////////////////////////
void newinformation_mnu()
{
int exet=0;
int i,j;
screen_newinformation();
do{
if(check_button(maxx-28,47,maxx-12,61,"X"))
exet=1;
if(check_button(22,65,90,79,"Patient"))
{
patient_work();
screen_newinformation();
}
if(check_button(92,65,160,79,"Doctor"))
{
doctor_work();
screen_newinformation();
}
if(check_button(162,65,230,79,"Ward"))
{
ward_work();
screen_newinformation();

102

}
if(check_button(232,65,300,79,"Test"))
{
test_work();
screen_newinformation();
}
}while(exet!=1);
}
/////////////////////////////////////////////////////
void help()
{
screen3(12,84,maxx-520,maxy-12,3,8,"USER HELP" );
Button1(32,120,100,140,"NEWINFO");
Button1(32,160,100,180,"BILL");
Button1(32,200,100,220,"SEARCH");
Button1(32,240,100,260,"REPORT");
Button1(32,280,100,300,"HELP");
setlinestyle(0,1,3);
line(18,360,113,360);
setlinestyle(0,0,0);
Button1(32,380,100,400,"Clear");
Button1(32,420,100,440,"Exit");
}
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////NEWINFORAMTION PRINT//////////////////
void newinformation_print()
{
FILE *fp;
int i,j;
char s[2];
fp=fopen("newinfo4.txt","r");
if(fp==NULL)
{
printf("\nfile cant open");
return;
}
s[1]=0;
i=140;
j=120;
while(!feof(fp))
{
s[0]=fgetc(fp);
if(s[0]==10)
{
j+=10;

103

i=140;
}
else
if(s[0]==9)
{
i+=30;
}
else
{
outtextxy(i,j,s);
i+=10;
if(i>600)
{
j+=10;
i=140;
}
}
}
}
//////////////////NEWINFORMATION END///////////////////////
//////////////////////BILL PRINT///////////////////////////////
void bill_print()
{
FILE *fp;
int i,j;
char s[2];
fp=fopen("bill4.txt","r");
if(fp==NULL)
{
printf("\nfile can't open");
return;
}
s[1]=0;
i=140;
j=130;
while(!feof(fp))
{
s[0]=fgetc(fp);
if(s[0]==10)
{
j+=10;
i=140;
}
else
if(s[0]==9)

104

{
i+=30;
}
else
{
outtextxy(i,j,s);
i+=10;
if(i>600)
{
j+=10;
i=140;
}
}
}
}
///////////////////////BILL END/////////////////////////
//////////////////SEARCH PRINT///////////////////////////
void search_print()
{
FILE *fp;
int i,j;
char s[2];
fp=fopen("search1.txt","r");
if(fp==NULL)
{
printf("\nfile cant open");
return;
}
s[1]=0;
i=140;
j=140;
while(!feof(fp))
{
s[0]=fgetc(fp);
if(s[0]==10)
{
j+=10;
i=140;
}
else
if(s[0]==9)
{
i+=30;
}
else

105

{
outtextxy(i,j,s);
i+=10;
if(i>600)
{
j+=10;
i=140;
}
}
}
}
/////////////////////SEARCH PRINT END//////////////////////////
/////////////////////REPORT PRINT///////////////////////////////
void report_print()
{
FILE *fp;
int i,j;
char s[2];
fp=fopen("report1.txt","r");
if(fp==NULL)
{
printf("\nfile cant open");
return;
}
s[1]=0;
i=140;
j=140;
while(!feof(fp))
{
s[0]=fgetc(fp);
if(s[0]==10)
{
j+=10;
i=140;
}
else
if(s[0]==9)
{
i+=30;
}
else
{
outtextxy(i,j,s);
i+=10;
if(i>600)

106

{
j+=10;
i=140;
}
}
}
}
////////////////////////REPORT PRINT END////////////////////////
///////////////////////HELP PRINT ///////////////////////////
void help_print()
{
FILE *fp;
int i,j;
char s[2];
fp=fopen("help4.txt","r");
if(fp==NULL)
{
printf("\nfile cant open");
return;
}
s[1]=0;
i=140;
j=140;
while(!feof(fp))
{
s[0]=fgetc(fp);
if(s[0]==10)
{
j+=10;
i=140;
}
else
if(s[0]==9)
{
i+=30;
}
else
{
outtextxy(i,j,s);
i+=10;
if(i>600)
{
j+=10;

107

i=140;
}
}
}
}
/////////////////////////HELP PRINT END///////////////////////
void information_screen(char *str)//for about
{
screen3(121,84,maxx-12,maxy-12,3,8,str);
}
void help_work()
{
int exet=0;
help();
do{
if(check_button(32,120,100,140,"NEWINFO"))
{
information_screen("NEW INFORMATION");
newinformation_print();
help();
}
if(check_button(32,160,100,180,"BILL"))
{
information_screen("BILL INFORMATION");
bill_print();
help();
}
if(check_button(32,200,100,220,"SEARCH"))
{
information_screen("SEARCH");
search_print();
help();
}
if(check_button(32,240,100,260,"REPORT"))
{
information_screen("REPORT");
report_print();
help();
}
if(check_button(32,280,100,300,"HELP"))
{
information_screen("HELP");
help_print();
help();
}

108

if(check_button(32,420,100,440,"Exit"))
exet=1;
if(check_button(32,380,100,400,"Clear"))
{
clear_screen(121,84,maxx-12,maxy-12,8);
}
}while(exet!=1);
}
void help_mnu()
{
int exet=0;
int i,j;
screen_help1();
do{
if(check_button(maxx-28,47,maxx-12,61,"X"))
exet=1;
if(check_button(22,65,100,79,"User Help"))
{
help_work();
screen_help1();
}
}while(exet!=1);
}
//////////////////////////SCREEN FIRST////////////////////////
void screen_first()
{
setcolor(RED);
screen1(0,0,maxx,maxy,5,8,"HOSPITAL MANAGEMENT SYSTEM" );
Button1(10,23,140,37,"NEW INFORMATION");
Button1(142,23,205,37,"BILL");
Button1(207,23,275,37,"SEARCH");
Button1(277,23,340,37,"REPORT");
Button1(342,23,398,37,"HELP");
Button1(400,23,455,37,"CLOSE");
}
void screen()
{
int exet=0;
screen_first();
do{
if(check_button(maxx-22,5,maxx-6,19,"X"))
exet=1;
if(check_button(10,23,140,37,"NEW INFORMATION"))

109

{
newinformation_mnu();
screen_first();
}
if(check_button(142,23,205,37,"BILL"))
{
bill_mnu();
screen_first();
}
if(check_button(207,23,275,37,"SEARCH"))
{
search_mnu();
screen_first();
}
if(check_button(277,23,340,37,"REPORT"))
{
report_mnu();
screen_first();
}
if(check_button(342,23,398,37,"HELP"))
{
help_mnu();
screen_first();
}
if(check_button(400,23,455,37,"CLOSE"))
{
screen_first();
exet=1;
}
}while(exet!=1);
}
void main(void)
{
int gdriver = DETECT, gmode,errorcode;
int x1,y1;
clrscr();
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)

110

{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
getch();
return;
}
cleardevice();
setcolor(15);
maxx=getmaxx();
maxy=getmaxy();
initmouse();
if(pass())
{
Cleardevice();
load();
cleardevice();
grap();
cleardevice();
showmouse();
screen();
closegraph();
}
Else
Exit(0);
}

111

Vous aimerez peut-être aussi