Minggu, 16 Oktober 2016

Responsibility and Collaboration Diagram of Hospital Management System

1. Use Case Diagram
Keterangan untuk Use Case berada di postingan ini


2. Class Diagram
Keterangan untuk Class Diagram dan CRC bisa dilihat di link berikut


3. CRC


4. Check Realization
Dari CRC dan Use case diagram diatas kita bisa membuat check realization sebagai berikut.


5. Sequence Diagram
Sequence diagram adalah suatu diagram yang menggambarkan interaksi antar obyek dan mengindikasikan komunikasi diantara obyek-obyek tersebut. Diagram ini juga menunjukkan serangkaian pesan yang dipertukarkan oleh obyek-obyek yang melakukan suatu tugas atau aksi tertentu. Berdasarakan cara kerja dan Use case diagram. Dapat dinggambarkan Sequence diagramnya.

6. Source Code

#include<iostream>
#include<iomanip>
#include<conio.h>
#include<string>
#include<windows.h>
#include<fstream>
#include<process.h>

using namespace std;

class pat
{
 private:
  struct address
  {
   int house;
   char street[30];
   char city[30];
   char state[30];
   char country[30];
  };
  struct age
  {
   int day;
   int month;
   int year;
  };
  struct patient_info
  {
   char name[50];
   address AD1;   //nested structure implemented
   age A1;        //nested structure inplemented
   int martial_status;
   int reg_no;
   int bld_group;
   int sex;
   char doctor[50];
   char medrep[1000];
  }PI[100];
  int task;
 protected:
  void enter_patient_info();
  void show_patient_detail();
 public:
  //void software_detail();
  void tasks();
  char answer;
  char answer1;
  //char ch;
  int serial;
};

class date
{
 private:
  int date;
  int month;
  int year;
 public:
  void enter_date();
  void show_date();
};

class dob
{
 private:
  struct dob1
  {
   int date;
   int month;
   int year;
   int rem;
  }DOB11[100];
 public:
  void enter_date();
  void show_date();
};

int i=0;
int rem;
int count;
int regis=0;
int attempt;
int temp;
int show_count=0;

pat A1;           //object declared
date D1;          //object declared
dob DOB1;         //object declared

int main(void)
{
 count=0;
 cout<<"**********Welcome to....**********"<<"\n";
 cout<<"***HOSPITAL MANAGEMENT SOFTWARE***"<<"\n";
 D1.enter_date();
 A1.tasks();
}

void pat::tasks()
{
 attempt=0;
 D1.show_date();
 cout<<"**********************************"<<"\n";
 cout<<"***HOSPITAL MANAGEMENT SOFTWARE***"<<"\n";
 cout<<"*** Hospital Management Tasks ****"<<"\n";
 cout<<"**********************************"<<"\n";
 cout<<"   Please  select a task to do..  "<<"\n";
 cout<<"1. Enter a new patient information."<<"\n";
 cout<<"2. View detail of existing patient."<<"\n";
 //cout<<"3. View detail about the program ."<<"\n";
 cout<<"3. Exit from the program."<<"\n";
 //other function remain
 cout<<"Enter your task :";
 scanf("%d", &task);
 getchar();
 switch(task)
 {
  case 1:
  {
   A1.enter_patient_info();
   break;
  }
  case 2:
  {
   A1.show_patient_detail();
   break;
  }
  /*case 3:
  {
   A1.software_detail();
   break;
  }*/
  case 3:
  {
   
   cout<<"Thank You for using this program !!!"<<"\n";
   cout<<" This is the end of program...."<<"\n";
   cout<<" Press any key to exit....."<<"\n";
   getch();
   exit(0);
   break;
  }
  default:
  {
   
   //printf("%d", task);
   cout<<"Invalid task."<<"\n";
   cout<<"Press any key to continue...."<<"\n";
   getch();
   
   A1.tasks();
  }
 }
}

void pat::enter_patient_info()
{
 
 answer='y';
 if(count==0)
 {
  serial=1;
 }
 else
 {
  i=serial;
 }
 for(i=serial;answer=='y'||answer=='Y';i++)
 {
  PI[i].reg_no=i;
  temp=serial;
  cout<<"***ENTERING INFORMATION FOR PATIENT SERIAL NUMBER "<<i<<"***"<<"\n";
  //cin.get(ch);
  cout<<"Registration Number : "<<PI[i].reg_no<<"\n";
  cout<<"Enter the name of patient :"<<"\n";
  
  gets(PI[i].name);
  cout<<"Sex (1-Male 2-Female) :"<<"\n";
  
  scanf("%d", &PI[i].sex);
  getchar();
  while(PI[i].sex!=1&&PI[i].sex!=2)
  {
   cout<<"Invalid input for sex of patient!!!"<<"\n";
   cout<<"Sex (1-Male 2-Female) :"<<"\n";
   scanf("%d", &PI[i].sex);
   getchar();
   //break;
   
  }
  cout<<"***ENTERING ADDRESS**"<<"\n";
  cout<<"House number :"<<"\n";
  cin>>PI[i].AD1.house;
  getchar();
  while(PI[i].AD1.house<=0)
  {
   cout<<"Invalid input for house number ."<<"\n";
   cout<<"Again enter the house number: "<<"\n";
   cin>>PI[i].AD1.house;
   //printf("%d", PI[i].AD1.house);
   getchar();
  }
  //cin.get(ch);
  cout<<"Street :"<<"\n";
  cin.getline(PI[i].AD1.street,30);
  cout<<"City :"<<"\n";
  cin.getline(PI[i].AD1.city,30);
  cout<<"State :"<<"\n";
  cin.getline(PI[i].AD1.state,30);
  cout<<"Country :"<<"\n";
  cin.getline(PI[i].AD1.country,30);
  DOB1.enter_date();
  //to calculate age
  cout<<"Martial status(1-Married,2-Not Married ):"<<"\n";
  cin>>PI[i].martial_status;
  getchar();
  while(PI[i].martial_status<1||PI[i].martial_status>2)
  {
   cout<<"Invalid input for martial status ."<<"\n";
   cout<<"Enter a valid martial status :"<<"\n";
   cin>>PI[i].martial_status;
   getchar();
  }
  cout<<"Blood group :"<<"\n";
  cout<<"1. A+ "<<"\n";
  cout<<"2. A- "<<"\n";
  cout<<"3. B+ "<<"\n";
  cout<<"4. B- "<<"\n";
  cout<<"5. AB+ "<<"\n";
  cout<<"6. AB- "<<"\n";
  cout<<"7. O+ "<<"\n";
  cout<<"8. O- "<<"\n";
  cout<<"Enter :"<<"\n";
  cin>>PI[i].bld_group;
  getchar();
  switch(PI[i].bld_group)
  {
   case 1:
   case 2:
   case 3:
   case 4:
   case 5:
   case 6:
   case 7:
   case 8:
   {
       break;
   }
   default:
   {
    while(PI[i].bld_group!=1&&PI[i].bld_group!=2&&PI[i].bld_group!=3&&PI[i].bld_group!=4&&PI[i].bld_group!=5&&PI[i].bld_group!=6&&PI[i].bld_group!=7&&PI[i].bld_group!=8)
    {
     
     cout<<"Invalid input !"<<"\n";
     cout<<"Blood Group :"<<"\n";
     
     cin>>PI[i].bld_group;
     getchar();
    }
    break;
   }
  }
  //cin.get(ch);
  cout<<"Enter medical report for patient: "<<"\n";
  gets(PI[i].medrep);
  printf("Enter doctor name: \n");
  gets(PI[i].doctor);
  cout<<"Enter another patient? (Y/N) "<<"\n";
  cin>>answer;
  getchar();
  count++;
  serial++;
  regis++;
 }
 
 A1.tasks();
}

void dob::enter_date()
{
 
 cout<<"Date of birth"<<"\n";
 
 cout<<"Year :";
 
 
 cin>>DOB11[temp].year;
 getchar();
 if(DOB11[temp].year<=0||DOB11[temp].year>10000)
 {
  do
  {
   
   cout<<"Invalid input for year !"<<"\n";
   cout<<"Please enter the year correctly :"<<"\n";
   cin>>DOB11[temp].year;
   getchar();
  }while(DOB11[temp].year<0||DOB11[temp].year>10000);
 }
 
 cout<<"Month :";
 cin>>DOB11[temp].month;
 getchar();
 if(DOB11[temp].month<=0||DOB11[temp].month>12)
 {
  do
  {
   
   cout<<"Invalid input for month !"<<"\n";
   cout<<"Again enter the month :"<<"\n";
   cin>>DOB11[temp].month;
   getchar();
  }while(DOB11[temp].month<0||DOB11[temp].month>12);
 }
 cout<<"Date :";
 switch(DOB11[temp].month)
 {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:
  {
   cin>>DOB11[temp].date;
   getchar();
   while(DOB11[temp].date<1||DOB11[temp].date>31)
   {
    
    cout<<"Invalid date !"<<"\n";
    cout<<"Again enter the date :"<<"\n";
    
    cin>>DOB11[temp].date;
    getchar();
   }
   break;
  }
  case 2:
  {
   cin>>DOB11[temp].date;
   getchar();
   if(DOB11[temp].year%4==0)
   {
    while(DOB11[temp].date<0||DOB11[temp].date>29) 
    //for leap year
    {
     
     cout<<"Invalid date !"<<"\n";
     cout<<"Again enter the date :"<<"\n";
     
     cin>>DOB11[temp].date;
     getchar();
    }
   }
   else
   {
    while(DOB11[temp].date<0||DOB11[temp].date>28) 
    //for non-leap year
    {
     
     cout<<"Invalid date !"<<"\n";
     cout<<"Again enter the date :"<<"\n";
     
     cin>>DOB11[temp].date;
     getchar();
    }
   }
   break;
  }
  default:
  {
    cin>>DOB11[temp].date;
    getchar();
    while(DOB11[temp].date<1||DOB11[temp].date>30)
    {
     
     cout<<"Invalid date !"<<"\n";
     cout<<"Again enter the date :"<<"\n";
     
     cin>>DOB11[temp].date;
     getchar();
    }
    break;
  }
 }
 //end of switch
 
}

void date::enter_date()
{
 cout<<"Enter the current date ..."<<"\n";
 cout<<"Year :";
 cin>>year;
 getchar();
 if(year<=0||year>10000)
 {
  do
  {
   cout<<"Invalid input for year !"<<"\n";
   cout<<"Please enter the year correctly :"<<"\n";
   cin>>year;
   getchar();
  }while(year<0||year>10000);
 }
 cout<<"Month :";
 cin>>month;
 getchar();
 if(month<=0||month>12)
 {
  do
  {
   cout<<"Invalid input for month !"<<"\n";
   cout<<"Again enter the month :"<<"\n";
   cin>>month;
   getchar();
  }while(month<0||month>12);
 }
 cout<<"Date :";
 switch(month)
 {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:
  {
   cin>>date;
   while(date<1||date>31)
   {
    cout<<"Invalid date !"<<"\n";
    cout<<"Again enter the date :"<<"\n";
    cin>>date;
    getchar();
   }
   break;
  }
  case 2:
  {
   cin>>date;
   getchar();
   if(year%4==0)
   {
    while(date<0||date>29) //for leap year
    {
     cout<<"Invalid date !"<<"\n";
     cout<<"Again enter the date :"<<"\n";
     cin>>date;
     getchar();
    }
   }
   else
   {
    while(date<0||date>28) //for non-leap year
    {
     cout<<"Invalid date !"<<"\n";
     cout<<"Again enter the date :"<<"\n";
     cin>>date;
     getchar();
    }
   }
   break;
  }
  default:
  {
   cin>>date;
   getchar();
   while(date<1||date>30)
   {
    cout<<"Invalid date !"<<"\n";
    cout<<"Again enter the date :"<<"\n";
    cin>>date;
    getchar();
   }
   break;
  }
 }  //end of switch
}

void date::show_date()  //remove the goto ststements in this function
{
 
 cout<<"Hello....It's ";
 cout<<date;
 rem=date%10;
 switch(date)
 {
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
  case 16:
  case 17:
  case 18:
  case 19:
  case 20:
  {
   cout<<"th ";
   goto over;
  }
 }
 switch(rem)
 {
  case 1:
  {
   cout<<"st ";
   break;
  }
  case 2:
  {
   cout<<"nd ";
   break;
  }
  case 3:
  {
   cout<<"rd ";
   break;
  }
  default:
  {
   cout<<"th ";
   break;
  }
 }
 over:
 switch(month)
 {
  case 1:
  {
   cout<<"January , ";
   break;
  }
  case 2:
  {
   cout<<"February , ";
   break;
  }
  case 3:
  {
   cout<<"March , ";
   break;
  }
  case 4:
  {
   cout<<"April , ";
   break;
  }
  case 5:
  {
   cout<<"May , ";
   break;
  }
  case 6:
  {
   cout<<"June , ";
   break;
  }
  case 7:
  {
   cout<<"July , ";
   break;
  }
  case 8:
  {
   cout<<"August , ";
   break;
  }
  case 9:
  {
   cout<<"September , ";
   break;
  }
  case 10:
  {
   cout<<"October , ";
   break;
  }
  
  case 11:
  {
   cout<<"November , ";
   break;
  }
  case 12:
  {
   cout<<"December , ";
   break;
  }
 }
 cout<<year<<"\n";
}

void pat::show_patient_detail()
{
 do
 {
  if(count==0)
  {
   cout<<"Database is empty !!!"<<"\n";
   cout<<"Press any key to exit to main task menu..."<<"\n";
   getch();
   
   A1.tasks();
  }
  
  cout<<"Enter registration number :"<<"\n";
  cin>>regis;
  getchar();
  //cin.get(ch);
  show_count++;
  if(regis>0 && regis<serial)
  {
   
   cout<<"***INFORMATION FOR PATIENT REGISTRATION NUMBER"<<regis<<"***\n";
   
   cout<<"Name           : "<<PI[regis].name<<"\n";
   
   cout<<"Sex            : ";
   
   if(PI[regis].sex==1)
   {
    cout<<"Male "<<"\n";
    
   }
   if(PI[regis].sex==2)
   {
    cout<<"Female "<<"\n";
    
   }
   cout<<"Blood Group    : ";
   
   switch(PI[regis].bld_group)
   {
    case 1:
    {
        
        cout<<"A+";
        break;
    }
    case 2:
    {
        
        cout<<"A-";
        break;
    }
    case 3:
    {
        
        cout<<"B+";
        break;
    }
    case 4:
    {
        
        cout<<"B-";
        break;
    }
    case 5:
    {
           
           cout<<"AB+";
           break;
    }
    case 6:
    {
           
           cout<<"AB-";
           break;
    }
    case 7:
    {
           
           cout<<"O+";
           break;
    }
    case 8:
    {
           
           cout<<"O-";
           break;
    }
   }
   
   //printf("\n")
   cout<<"\nDate of birth  : ";
   
   DOB1.show_date();
   cout<<"Martial Status : ";
   
   if(PI[i].martial_status==1)
   {
    cout<<"Married "<<"\n";
    
   }
   else
   {
    cout<<"Not married "<<"\n";
    
   }
   
   cout<<"**ADDRESS**";
   
   cout<<"\nHouse no.      : "<<PI[regis].AD1.house;
   
   cout<<"\nStreet         : "<<PI[regis].AD1.street;
   
   cout<<"\nCity           : "<<PI[regis].AD1.city;
   
   cout<<"\nState          : "<<PI[regis].AD1.state;
   
   cout<<"\nCountry        : "<<PI[regis].AD1.country;
   
   cout<<"\n**MEDICAL**";
   
   cout<<"\nMedical Report : "<<PI[regis].medrep;
   
   cout<<"\nDoctor         : "<<PI[regis].doctor;   
  }
  else
  {
   attempt++;
   if(attempt==3)
   {
    cout<<"You have entered wrong registration number 3 times ."<<"\n";
    cout<<"Access Denied!!! "<<"\n";
    cout<<"Please try again later. "<<"\n";
    cout<<"Press any key to exit to main task menu..."<<"\n";
    getch();
    
    A1.tasks();
   }
   
   cout<<"Sorry, the registration number is invalid ."<<"\n";
   cout<<"Press any key to continue...."<<"\n";
   getch();
   
   A1.show_patient_detail();
  }
  
  cout<<"\nWant to see information of another patient? (Y/N): "<<"\n";
  
  cin>>answer1;
 }while(answer1=='y'||answer1=='Y');
 
 
 A1.tasks();
}

void dob::show_date()
{
 cout<<DOB11[regis].date;
 rem=DOB11[regis].date%10;
 switch(DOB11[regis].date)
 {
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
  case 16:
  case 17:
  case 18:
  case 19:
  case 20:
  {
   cout<<"th ";
   goto over;
  }
 }
 switch(rem)
 {
  case 1:
  {
   cout<<"st ";
   break;
  }
  case 2:
  {
   cout<<"nd ";
   break;
  }
  case 3:
  {
   cout<<"rd ";
   break;
  }
  default:
  {
   cout<<"th ";
   break;
  }
 }
 over:
 switch(DOB11[regis].month)
 {
  case 1:
  {
   cout<<"January , ";
   break;
  }
  case 2:
  {
   cout<<"February , ";
   break;
  }
  case 3:
  {
   cout<<"March , ";
   break;
  }
  case 4:
  {
   cout<<"April , ";
   break;
  }
  case 5:
  {
   cout<<"May , ";
   break;
  }
  case 6:
  {
   cout<<"June , ";
   break;
  }
  case 7:
  {
   cout<<"July , ";
   break;
  }
  case 8:
  {
   cout<<"August , ";
   break;
  }
  case 9:
  {
   cout<<"September , ";
   break;
  }
  case 10:
  {
   cout<<"October , ";
   break;
  }
  
  case 11:
  {
   cout<<"November , ";
   break;
  }
  case 12:
  {
   cout<<"December , ";
   break;
  }
 }
 cout<<DOB11[regis].year<<"\n";
}

/*void all::software_detail()
{
 //clrscr();
 cout<<"***SOFTWARE DETAILS***\n";
 cout<<" Developer                : Mustafizur Rohman "<<"\n";
 cout<<" Programming Language     : C++ "<<"\n";
 cout<<" Aim                      : Simulation of the software used in Hospital"<<"\n";
 cout<<" Hope you like it..."<<"\n";
 cout<<" Send your comments to : mustafizur_04@sify.com ."<<"\n";
 cout<<" Thank You for trying this program. "<<"\n";
 cout<<"Press any key to return to the main task menu......."<<"\n";
 getch();
 A1.tasks();
}*/



/* END OF THE PROGRAM */
Sumber:
http://basiccodings.blogspot.co.id/2013/04/hospital-mangement-system-in-c_1055.html 
http://fajarbaskoro.blogspot.co.id/

Tidak ada komentar:

Posting Komentar