Monday, September 1, 2014

MEDICAL LAB MANAGEMENT SYSTEM Code in C++

Read Also:  


MEDICAL LAB MANAGEMENT SYSTEM Code in C++

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<dos.h>
#include<fstream.h>
#include<iomanip.h>
/*
 PATIENT CLASS
 */
class patient{
private:
char f_name[10],m_test[20],c_report[30];
int id;
public:
char name[10];
/*
CONSTRUCTOR
*/
patient()
{
strcpy(name,NULL);
strcpy(f_name,NULL);
strcpy(m_test,NULL);
strcpy(c_report,NULL);
id=0;
}
/*
EDITING FUNTION
*/
void edit(int i)
{              id=i;
cout<<"\t\tEnter Data About Patient\n";
cout<<"\nPatient ID number is: "<<id;
cout<<"\nEnter the name of patient: ";
cin>>name;
cout<<"\nEnter father name of patient: ";
cin>>f_name;

cout<<"\nEnter name of medical test: ";
cin>>m_test;
cout<<"\nEnter patient complete report: ";
cin>>c_report;
}
/*
DISPLAY FUNTION
*/
void show(int i)
{                  id=i;
cout<<"\n\t\tPatient Detail\n";
cout<<"\nPatient ID no is: "<<i;
cout<<"\nPatient name is: "<<name;
cout<<"\nPatient father name is: "<<f_name;
cout<<"\nPatient Medical test name is: "<<m_test;
cout<<"\nPatient Complete report: "<<c_report;
}
/*
DELETE FUNTION
*/
void delet(int i)
{
id=i;
strcpy(name,"deleted...");
strcpy(f_name,"deleted...");
strcpy(m_test,"deleted...");
strcpy(c_report,"deleted...");
cout<<"\n\nRecord of patient with ID no "<<id<<" has ben deleted.";
cout<<"\n\nName:   "<<name;
cout<<"\nFather name: "<<f_name;
cout<<"\nMedical test: "<<m_test;
cout<<"\nComplete Report: "<<c_report;
strcpy(name,NULL);
strcpy(f_name,NULL);
strcpy(m_test,NULL);
strcpy(c_report,NULL);
id=0;
     }
};
void delete_patient();
void creat_data();
void pass();
void intro();
/*
MAIN FUNTION
*/
void main()
{
intro();
pass();
int choice,i1;
char m,q;
patient a[500];
a:clrscr();
 cout<<"\t\tSELECT A MODE\n\n";
 cout<<"\nEdit   01\nSearch       02\nDelete 03\nExit 04\n";
 cin>>choice;
 switch(choice) {
 /*
CASE 1 EDIT
*/
 case 1:
s:clrscr();
cout<<"\nEnter ID no Of Patient: ";
 cin>>i1;
 a[i1].edit(i1);
 cout<<"\nEnter another Patient data ?   Press A";
 cin>>q;
 if(q=='a'||q=='A')
 goto s;
 else{
a1: cout<<"\n\n\t\tBack to main menu press M\n";
 cin>>m;
 if(m=='m'||m=='M')
 goto a;
 else
 clrscr();
 goto a1; }

 /*
CAES 2 SEARCH
*/
 case 2:  char s;
z: clrscr();
 cout<<"\n\tSearch by  name:  Press N";
 cout<<"\n\tSearch by ID no:  Press I";
 cin>>s;
 /*
MULTI OPTION SEARCH
*/
 if(s=='i')               //BY ID NO..
 {
 cout<<"\nEnter ID no Of Patient: ";
 cin>>i1;
 a[i1].show(i1);
 a2: cout<<"\n\n\t\tBack to main menu press M\n";
 cin>>m;
 if(m=='m'||m=='M')
 goto a;
 else
 clrscr();
 goto a2; }
 else if(s=='n')                      //BY NAME
 {
 char name1[10];
 cout<<"\nEnter Patient name: ";
 cin>>name1;
 cout<<"\nSearching for Patient Name: =>  "<<name1<<"   > > > Wait....";
 for(int x=1;x<=500;x++)
{
 if(strcmp(name1,a[x].name)==0)
 a[x].show(x);

 }
 cout<<"\nRecord not found...";
 }
 else
 goto z;


    break;
    /*
  CASE 3  DELETE DATA
*/
 case 3:
 cout<<"\nEnter ID no Of Patient: ";
 cin>>i1;
 a[i1].delet(i1);
 a3: cout<<"\n\n\t\tBack to main menu press M\n";
 cin>>m;
 if(m=='m'||m=='M')
 goto a;
 else
 clrscr();
 goto a3;

 /*
 CASE 4 EXIT
 */
 case 4:
 exit(0);

 default:
 clrscr();
 goto a;

}
 }
////////////////////////
fstream file1,file2;
patient bk;

void creat_data()
{


char ch;
file1.open("patient.dat",ios::out|ios::app);
do
{
clrscr();
bk.edit(0);
file1.write((char*)&bk,sizeof(patient));
cout<<"\n\nDo you want to add more record..(y/n?)";
cin>>ch;
}while(ch=='y'||ch=='Y');
file1.close();
}

void delete_patient()
{
char n[6];
int flag=0;
clrscr();
cout<<"\n\n\n\tDELETE Patient...";
cout<<"\n\nEnter The ID no. of the Patient You Want To Delete : ";
cin>>n;
file1.open("patient.dat",ios::in|ios::out);
fstream file2;
file2.open("Temp.dat",ios::out);
file1.seekg(0,ios::beg);
while(file1.read((char*)&bk,sizeof(patient)))
{
if(strcmp(n,n)==0)
file2.write((char*)&bk,sizeof(patient));
else
flag=1;
}

file2.close();
file1.close();
remove("patient.dat");
rename("Temp.dat","patient.dat");
    if(flag==1)
      cout<<"\n\n\tRecord Deleted ..";
    else
      cout<<"\n\nRecord not found";
    getch();
}
//////////////////////
void pass()
{
char u[]={"usman"},pass[20],awe[20];
f:clrscr();
gotoxy(30,15);
cout<<char(3)<<char(3)<<"  AUTHENTICATION REQUIRED  "<<char(3)<<char(3);
gotoxy(26,17);
cout<<"User Name= ";
cin>>awe;
gotoxy(26,19);
cout<<"Pass Word= ";
cin>>pass;
cout<<"\n\nChecking for Username and Password...........\n\n";
{
if(strcmp(pass,u)==0)
h:{
delay(1500);
cout<<"\n\n\t\t\t"<<char(1)<<" LOGIN SUCCESFULY "<<char(1);
cout<<"\n\n\n\n\n\n\t\t\" PRESS ANY KEY TO CONTINUE\"";
getch();
}

else {

cout<<"\n\n\n\n\n\n\n\n\n\t\t\"SORY WORNG USERNAME OR PASSWORD\"\n\n\t\t TRY AGIAN ";
delay(1800);
goto f;}
}}
////////////////////////// INTRO//
void intro()
{
clrscr();
gotoxy(20,10);
cout<<"MADICAL  LAB   MANEGMENT  SYSTEM";
gotoxy(5,20);
cout<<"\n Usman Siddique from Comsats wah";
getch();
}

Share this

0 Comment to "MEDICAL LAB MANAGEMENT SYSTEM Code in C++"