Page

Laboratory Management System in C,C++

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
struct lab
 {
   char name[20];
   char sex;
   char add[50];
   long int mob;
   int id;
   int age;
   int tsh,t4,t3,cbc,tlc,dlc;
   int rbc,wbc,plat,hemo,hemoto;
   int neutro,lymo,baso,eosino,mono,poly;
 }l;
  class lab_mgt
   {
     public:
     void insert();
     void gen();
     void mainmenu();
//     void quit();
    };
    void lab_mgt::mainmenu()
    {
      int  ch;
      clrscr();
      cout<<"----------------------------------------------------------------";
      cout<<"\n \t\t LABAROTORY MANAGEMENT SYSTEM";
      cout<<"\n";
      cout<<"----------------------------------------------------------------";

      cout<<"\n\n\n\n\t 1. Insert a new record";
      cout<<"\n\n\t 2. Generate Report";
      cout<<"\n\n\t 3. Exit";
      cout<<"\n\n\n\t ENTER YOUR CHOICE= ";
      cin>>ch;
      clrscr();

      switch(ch)
      {
       case 1:
       insert();
       break;
       case 2:
       gen();
       break;
       case 3:
       exit(0);
       break;
       default:
       cout<<"\n Input correct choice=";
       getch();
       mainmenu();
       //break;
      }
    }
    void lab_mgt::insert()
    {
      int a;
      clrscr();
      cout<<"\n SELECT TEST IN THE LIST";
      cout<<"\n\n\n1. TSH TEST";
      cout<<"\n\n2. T4 TEST";
      cout<<"\n\n3. T3 TEST";
      cout<<"\n\n4. CBC TEST";
      cout<<"\n\n5. TLC TEST";
      cout<<"\n\n6. DLC TEST";
      cout <<"\n\n\n ENTER YOUR CHOICE:";
      cin>>a;
      clrscr();
      switch(a)
      {
       case 1:
       {
       FILE *fp;
       fp=fopen("tsh.txt","a");
       if(fp!=NULL)
       {
       cout<<"\n YOU SELECT TSH TEST";
       cout<<"\n\n Input Patient Id=";
       cin>>l.id;
       cout<<"\n Input Name of Patient=";
       fflush(stdin);
       gets(l.name);
       cout<<"\n Input Age=";
       cin>>l.age;
       cout<<"\n Input Sex [M/F]=";
       cin>>l.sex;
       cout<<"\n Input Address=";
       fflush(stdin);
       gets(l.add);
       cout<<"\n Input Mobile No.=";
       cin>>l.mob;

       cout<<"\n Input TSH=";
       cin>>l.tsh;
       fwrite(&l,sizeof(l),1,fp);
       }
       else
       {
cout<<"\n Error In opening File";
       }
       fclose(fp);
     getch();
     mainmenu();
      break;
     }

     case 2:
       {
       FILE *fp;
       fp=fopen("t4.txt","a");
       if(fp!=NULL)
       {
       cout<<"\n YOU SELECT T4 TEST";
       cout<<"\n\n Input Patient Id=";
       cin>>l.id;
       cout<<"\n Input Name of Patient=";
       fflush(stdin);
       gets(l.name);
       cout<<"\n Input Age=";
       fflush(stdin);
       cin>>l.age;
       cout<<"\n Input Sex [M/F]=";
fflush(stdin);
       cin>>l.sex;
       cout<<"\n Input Address=";
       fflush(stdin);
       gets(l.add);
       cout<<"\n Input Mobile No.=";
fflush(stdin);
       cin>>l.mob;
       cout<<"\n Input T4=";
fflush(stdin);
       cin>>l.t4;
       cout<<"\n Input TSH=";
fflush(stdin);
       cin>>l.tsh;

       fwrite(&l,sizeof(l),1,fp);
       }
       else
       {
cout<<"\n Error In opening File";
       }
       fclose(fp);
     getch();
     mainmenu();
      break;
     }
     case 3:
       {
       FILE *fp;
       fp=fopen("t3.txt","a");
       if(fp!=NULL)
       {
       cout<<"\n YOU SELECT T3 TEST";
       cout<<"\n\n Input Patient Id=";
       cin>>l.id;
       cout<<"\n Input Name of Patient=";
       fflush(stdin);
       gets(l.name);
       cout<<"\n Input Age=";
       cin>>l.age;
       cout<<"\n Input Sex [M/F]=";
       cin>>l.sex;
       cout<<"\n Input Address=";
       fflush(stdin);
       gets(l.add);
       cout<<"\n Input Mobile No.=";
       cin>>l.mob;
       cout<<"\n Input T3=";
       cin>>l.t3;

       fwrite(&l,sizeof(l),1,fp);
       }
       else
       {
cout<<"\n Error In opening File";
       }
       fclose(fp);
     getch();

     mainmenu();
      break;
     }
     case 4:
       {
       FILE *fp;
       fp=fopen("cbc.txt","a");
       if(fp!=NULL)
       {
       cout<<"\n YOU SELECT CBC TEST";
       cout<<"\n\n Input Patient Id=";
       cin>>l.id;
       cout<<"\n Input Name of Patient=";
       fflush(stdin);
       gets(l.name);
       cout<<"\n Input Age=";
       cin>>l.age;
       cout<<"\n Input Sex [M/F]=";
       cin>>l.sex;
       cout<<"\n Input Address=";
       fflush(stdin);
       gets(l.add);
       cout<<"\n Input Mobile No.=";
       cin>>l.mob;
       cout<<"\n Input RBC=";
       cin>>l.rbc;
       cout<<"\n Input WBC=";
       cin>>l.wbc;
       cout<<"\n Input PLATLETS=";
       cin>>l.plat;
       cout<<"\n Input HEMOGLOBIN=";
       cin>>l.hemo;
       cout<<"\n Input HEMOTOCRIT=";
       cin>>l.hemoto;

       fwrite(&l,sizeof(l),1,fp);
       }
       else
       {
cout<<"\n Error In opening File";
       }
       fclose(fp);
     getch();
     mainmenu();
      break;
     }
     case 5:
       {
       FILE *fp;
       fp=fopen("tlc.txt","a");
       if(fp!=NULL)
       {
       cout<<"\n YOU SELECT TLC TEST";
       cout<<"\n\n Input Patient Id=";
       cin>>l.id;
       cout<<"\n Input Name of Patient=";
       fflush(stdin);
       gets(l.name);
       cout<<"\n Input Age=";
       cin>>l.age;
       cout<<"\n Input Sex [M/F]=";
       cin>>l.sex;
       cout<<"\n Input Address=";
       fflush(stdin);
       gets(l.add);
       cout<<"\n Input Mobile No.=";
       fflush(stdin);
       cin>>l.mob;
       cout<<"\n Input WBC=";
       fflush(stdin);
       cin>>l.wbc;
       cout<<"\n Input NEUTROPHILS=";
       fflush(stdin);
       cin>>l.neutro;
       cout<<"\n Input LYMOCYTES=";
       fflush(stdin);
       cin>>l.lymo;

       cout<<"\n Input BASOPHILS=";
       fflush(stdin);
       cin>>l.baso;
       cout<<"\n Input EOSINOPHILS=";
       fflush(stdin);
       cin>>l.eosino;
       cout<<"\n Input MONOCYTES=";
       fflush(stdin);
       cin>>l.mono;
       fwrite(&l,sizeof(l),1,fp);
       }
       else
       {
cout<<"\n Error In opening File";
       }
       fclose(fp);
     getch();
     mainmenu();
     break;
     }
     case 6:
       {
       FILE *fp;
       fp=fopen("dlc.txt","a");
       if(fp!=NULL)
       {
       cout<<"\n YOU SELECT DLC TEST";
       cout<<"\n\n Input Patient Id=";
       cin>>l.id;
       cout<<"\n Input Name of Patient=";
       fflush(stdin);
       gets(l.name);
       cout<<"\n Input Age=";
       fflush(stdin);
       cin>>l.age;
       cout<<"\n Input Sex [M/F]=";
       fflush(stdin);
       cin>>l.sex;
       cout<<"\n Input Address=";
       fflush(stdin);
       gets(l.add);
       cout<<"\n Input Mobile No.=";
       cin>>l.mob;
       cout<<"\n Input POLYMORPHS=";
       fflush(stdin);
       cin>>l.poly;
cout<<"\n Input LYMOCYTES=";
fflush(stdin);
       cin>>l.lymo;

 cout<<"\n Input BASOPHILS=";
 fflush(stdin);
       cin>>l.baso;
 cout<<"\n Input EOSINOPHILS=";
 fflush(stdin);
       cin>>l.eosino;
 cout<<"\n Input MONOCYTES="; fflush(stdin);
       cin>>l.mono;

       fwrite(&l,sizeof(l),1,fp);
       }
       else
       {
cout<<"\n Error In opening File";
       }
       fclose(fp);
     getch();
     mainmenu();
      break;
     }

   default:
   cout<<"\n input correct choice=";
   getch();
   mainmenu();
  }
  }
  void lab_mgt::gen()
  {
      int a;
      clrscr();
      cout<<"\n SELECT TEST IN THE LIST";
      cout<<"\n\n\n1. TSH TEST";
      cout<<"\n\n2. T4 TEST";
      cout<<"\n\n3. T3 TEST";
      cout<<"\n\n4. CBC TEST";
      cout<<"\n\n5. TLC TEST";
      cout<<"\n\n6. DLC TEST";
      cout<<"\n\n\n ENTER YOUR CHOICE:";
      cin>>a;
      clrscr();
      switch(a)
      {
       case 1:
{
  int ch;
    cout<<"\n      ******************************************************";
    cout<<"\n\t \t\tSONI LABORATARIES";
    cout<<"\n      ******************************************************";
  cout<<"\n\n\t\t\tREPORT GENERATE";
  cout<<"\n\t\t\t---------------";
   cout<<"\n\n\nInput Patient Id=";
  // fflush(stdin);
   cin>>ch;
   FILE *fp;
   fp=fopen("tsh.txt","r");
   rewind(fp);
   while(fread(&l,sizeof(l),1,fp)==1)
      {
       if(ch==l.id)
{
cout<<"\n\n\t PATIENT ID= "<<l.id;
cout<<"\n\n\t PATIENT NAME= "<<l.name;
cout<<"\n\n\t PATIENT AGE= "<<l.age;
cout<<"\n\n\t PATIENT SEX= "<<l.sex;
cout<<"\n\n\t PATIENT ADDRESS= "<<l.add;
cout<<"\n\n\t PATIENT MOBILE= "<<l.mob;
cout<<"\n\n\t PATIENT TSH= "<<l.tsh;
if(l.tsh<0.3)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t\tYOU HAVE HYPERTHYRIOD";
cout<<"\n\t\t-------------------------------------------------";
}
if(l.tsh>=3)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t YOU HAVE HYPOTHYRIOD";
cout<<"\n\t\t-------------------------------------------------";
}
if(l.tsh>0.3 && l.tsh<3)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t YOU ARE NORMAL";
cout<<"\n\t\t-------------------------------------------------";
 }
getch();
mainmenu();
}

      }
      fclose(fp);

 break;
 }
      case 2:
{
  int ch;
cout<<"\n      ******************************************************";
cout<<"\n\t \t\tSONI LABORATARIES";
cout<<"\n      ******************************************************";
cout<<"\n\n\t\t\tREPORT GENERATE";
cout<<"\n\t\t\t---------------";
cout<<"\n\n\n Input Patient Id=";
cin>>ch;
   FILE *fp;
   fp=fopen("t4.txt","r");
   rewind(fp);
   while(fread(&l,sizeof(l),1,fp)==1)
      {
       if(l.id==ch)
{
cout<<"\n\n\t PATIENT ID= "<<l.id;
cout<<"\n\n\t PATIENT NAME= "<<l.name;
cout<<"\n\n\t PATIENT AGE= "<<l.age;
cout<<"\n\n\t PATIENT SEX= "<<l.sex;
cout<<"\n\n\t PATIENT ADDRESS= "<<l.add;
cout<<"\n\n\t PATIENT MOBILE ="<<l.mob;
cout<<"\n\n\t PATIENT TSH ="<<l.tsh;
cout<<"\n\n\t PATIENT T4= "<<l.t4;

if(l.t4<4.5 && l.tsh>=3)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t\tYOU HAVE HYPOTHYRIODISM";
cout<<"\n\t\t-------------------------------------------------";

}
if(l.t4<4.5 &&l.tsh<0.3)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\tYOU HAVE PITUITARY PROBLEM";
cout<<"\n\t\t-------------------------------------------------";

}
if(l.t4>4.5 && l.t4<12.5)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t\tYOU ARE NORMAL";
cout<<"\n\t\t-------------------------------------------------";


 }

getch();
mainmenu();
}
      }
      fclose(fp);

 break;
 }
      case 3:
{
  int ch;
cout<<"\n      ******************************************************";
cout<<"\n\t \t\tSONI LABORATARIES";
cout<<"\n      ******************************************************";
cout<<"\n\n\t\t\tREPORT GENERATE";
cout<<"\n\t\t\t---------------";
cout<<"\n\n\n Input Patient Id=";
cin>>ch;
   FILE *fp;
   fp=fopen("t3.txt","r");
   rewind(fp);
   while(fread(&l,sizeof(l),1,fp)==1)
      {
       if(l.id==ch)
{
cout<<"\n\n\t PATIENT ID= "<<l.id;
cout<<"\n\n\t PATIENT NAME= "<<l.name;
cout<<"\n\n\t PATIENT AGE= "<<l.age;
cout<<"\n\n\t PATIENT SEX= "<<l.sex;
cout<<"\n\n\t PATIENT ADDRESS= "<<l.add;
cout<<"\n\n\t PATIENT MOBILE= "<<l.mob;
cout<<"\n\n\t PATIENT T3= "<<l.t3;
if(l.t3<=80)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\tYOU HAVE HYPOTHYRIODISM";
cout<<"\n\t\t-------------------------------------------------";


}
if(l.t4>=220)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\tYOU HAVE PITUITARY PROBLEM";
cout<<"\n\t\t-------------------------------------------------";


}
if(l.t3>80 && l.t3<220)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t\tYOU ARE NORMAL";
cout<<"\n\t\t-------------------------------------------------";
 }
getch();
mainmenu();
}
      }
      fclose(fp);

 break;
 }
      case 4:
{
  int ch;
cout<<"\n      ******************************************************";
cout<<"\n\t \t\tSONI LABORATARIES";
cout<<"\n      ******************************************************";
cout<<"\n\n\t\t\tREPORT GENERATE";
cout<<"\n\t\t\t---------------";
cout<<"\n\n\n Input Patient Id=";
cin>>ch;

   FILE *fp;
   fp=fopen("cbc.txt","r");
   rewind(fp);
   while(fread(&l,sizeof(l),1,fp)==1)
      {
       if(l.id==ch)
{
cout<<"\n\n\t PATIENT ID= "<<l.id;
cout<<"\n\n\t PATIENT NAME= "<<l.name;
cout<<"\n\n\t PATIENT AGE="<<l.age;
cout<<"\n\n\t PATIENT SEX= "<<l.sex;
cout<<"\n\n\t PATIENT ADDRESS= "<<l.add;
cout<<"\n\n\t PATIENT MOBILE ="<<l.mob;
cout<<"\n\n\t PATIENT RBC= "<<l.rbc;
cout<<"\n\n\t PATIENT WBC= "<<l.wbc;
cout<<"\n\n\t PATIENT PLATLATES= "<<l.plat;
cout<<"\n\n\t PATIENT HEMOGLOBIN= "<<l.hemo;
cout<<"\n\n\t PATIENT HEMOTOCRIT= "<<l.hemoto;
long int s=150000;
if(l.hemo<13 && l.plat<s && l.wbc<4300)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\tYOU HAVE LESS BLOOD";
cout<<"\n\t\t-------------------------------------------------";


}
if(l.hemo>=13 && l.plat>=s && l.wbc>=4300)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\t\t\t\tYOU ARE NORMAL";
cout<<"\n\t\t-------------------------------------------------";
}
getch();
mainmenu();
}
      }
      fclose(fp);

 break;
 }
      case 5:
{
  int ch;
cout<<"\n      ******************************************************";
cout<<"\n\t \t\tSONI LABORATARIES";
cout<<"\n      ******************************************************";
cout<<"\n\n\t\t\tREPORT GENERATE";
cout<<"\n\t\t\t---------------";
cout<<"\n\n\n Input Patient Id=";
cin>>ch;

   FILE *fp;
   fp=fopen("tlc.txt","r");
   rewind(fp);
   while(fread(&l,sizeof(l),1,fp)==1)
      {
       if(l.id==ch)
{
cout<<"\n\n\t PATIENT ID= "<<l.id;
cout<<"\n\n\t PATIENT NAME= "<<l.name;
cout<<"\n\n\t PATIENT AGE= "<<l.age;
cout<<"\n\n\t PATIENT SEX= "<<l.sex;
cout<<"\n\n\t PATIENT ADDRESS= "<<l.add;
cout<<"\n\n\t PATIENT MOBILE= "<<l.mob;
cout<<"\n\n\t PATIENT WBC= "<<l.wbc;
cout<<"\n\n\t PATIENT NEUTROPHILS= "<<l.neutro;
cout<<"\n\n\t PATIENT LYMPHOCYTES= "<<l.lymo;
cout<<"\n\n\t PATIENT BASOPHILS= "<<l.baso;
cout<<"\n\n\t PATIENT EOSINOPHILS= "<<l.eosino;
cout<<"\n\n\t PATIENT MONOCYTES= "<<l.mono;
if(l.wbc>30000)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\n\t\tYOU HAVE INFECTION OR ALLERGY OR LEUKEMIA";
cout<<"\n\t\t-------------------------------------------------";


}
getch();
mainmenu();
}
      }
      fclose(fp);

 break;
 }
      case 6:
{
  int ch;
cout<<"\n      ******************************************************";
cout<<"\n\t \t\tSONI LABORATARIES";
cout<<"\n      ******************************************************";
cout<<"\n\n\t\t\tREPORT GENERATE";
cout<<"\n\t\t\t---------------";
cout<<"\n\n\n Input Patient Id=";
cin>>ch;

   FILE *fp;
   fp=fopen("dlc.txt","r");
   rewind(fp);
   while(fread(&l,sizeof(l),1,fp)==1)
      {
       if(l.id==ch)
{
cout<<"\n\n\t PATIENT ID= "<<l.id;
cout<<"\n\n\t PATIENT NAME= "<<l.name;
cout<<"\n\n\t PATIENT AGE= "<<l.age;
cout<<"\n\n\t PATIENT SEX= "<<l.sex;
cout<<"\n\n\t PATIENT ADDRESS= "<<l.add;
cout<<"\n\n\t PATIENT MOBILE= "<<l.mob;
cout<<"\n\n\t PATIENT POLYMORPHS= "<<l.poly;
 cout<<"\n\n\t PATIENT LYMPHOCYTES= "<<l.lymo;
cout<<"\n\n\t PATIENT BASOPHILS= "<<l.baso;
cout<<"\n\n\t PATIENT EOSINOPHILS= "<<l.eosino;
cout<<"\n\n\t PATIENT MONOCYTES= "<<l.mono;

if(l.poly<40)
{
cout<<"\n\n\t\t-------------------------------------------------";
cout<<"\n\n\t\t\tYOU HAVE LOW BLOOD CELLS";
cout<<"\n\t\t-------------------------------------------------";

}
getch();
mainmenu();
}
      }
      fclose(fp);
 break;
 }
default:
cout<<"\n\n\nyou enter wrong choice";
}
}

 void main()
  {
   lab_mgt lb;
   clrscr();
   lb.mainmenu();
   getch();
   }

No comments:

Post a Comment