0% found this document useful (0 votes)
128 views20 pages

Hospital Management System in Java

This document defines classes for a hospital management system including classes for doctors, patients, medical supplies, labs, facilities, and staff. It includes methods to add new records and display information for each class. The main method initializes arrays of each class type and adds sample data. It then runs a menu loop allowing the user to view and add data for doctors, patients, and other classes.

Uploaded by

Magesh Mani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views20 pages

Hospital Management System in Java

This document defines classes for a hospital management system including classes for doctors, patients, medical supplies, labs, facilities, and staff. It includes methods to add new records and display information for each class. The main method initializes arrays of each class type and adds sample data. It then runs a menu loop allowing the user to view and add data for doctors, patients, and other classes.

Uploaded by

Magesh Mani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

*;

import [Link].*;

import [Link];

class staff

 String sid, sname, desg, sex;

 int salary;

 void new_staff()

 {

  Scanner input = new Scanner([Link]);

  [Link]("id:-");
  sid = [Link]();

  [Link]("name:-");
  sname = [Link]();

  [Link]("desigination:-");
  desg = [Link]();

  [Link]("sex:-");
  sex = [Link]();

  [Link]("salary:-");
  salary = [Link]();

 }

 void staff_info()

 {

  [Link](sid + "\t" + sname + "\t" + sex + "\t" + salary);

 }

}
class doctor

 String did, dname, specilist, appoint, doc_qual;

 int droom;

 void new_doctor()

 {

  Scanner input = new Scanner([Link]);

  [Link]("id:-");
  did = [Link]();

  [Link]("name:-");
  dname = [Link]();

  [Link]("specilization:-");
  specilist = [Link]();

  [Link]("work time:-");
  appoint = [Link]();

  [Link]("qualification:-");
  doc_qual = [Link]();

  [Link]("room no.:-");
  droom = [Link]();

 }

 void doctor_info()

 {

  [Link](did + "\t" + dname + "  \t" + specilist + "     \t" + appoint + "    \t" +
doc_qual + "       \t" + droom);

 }

}
class patient

 String pid, pname, disease, sex, admit_status;

 int age;

 void new_patient()

 {

  Scanner input = new Scanner([Link]);

  [Link]("id:-");
  pid = [Link]();

  [Link]("name:-");
  pname = [Link]();

  [Link]("disease:-");
  disease = [Link]();

  [Link]("sex:-");
  sex = [Link]();

  [Link]("admit_status:-");
  admit_status = [Link]();

  [Link]("age:-");
  age = [Link]();

 }

 void patient_info()

 {

  [Link](pid + "\t" + pname + " \t" + disease + "     \t" + sex + "      \t" +
admit_status + "\t" + age);

 }

}
class medical

 String med_name, med_comp, exp_date;

 int med_cost, count;

 void new_medi()

 {

  Scanner input = new Scanner([Link]);

  [Link]("name:-");
  med_name = [Link]();

  [Link]("comp:-");
  med_comp = [Link]();

  [Link]("exp_date:-");
  exp_date = [Link]();

  [Link]("cost:-");
  med_cost = [Link]();

  [Link]("no of unit:-");
  count = [Link]();

 }

 void find_medi()

 {

  [Link](med_name + "  \t" + med_comp + "    \t" + exp_date + "     \t" +


med_cost);

 }

class lab

 String fecility;
 int lab_cost;

 void new_feci()

 {

  Scanner input = new Scanner([Link]);

  [Link]("fecility:-");
  fecility = [Link]();

  [Link]("cost:-");
  lab_cost = [Link]();

 }

 void feci_list()

 {

  [Link](fecility + "\t\t" + lab_cost);

 }

class fecility //Sorry Facility but do not change the name 

 String fec_name;

 void add_feci()

 {

  Scanner input = new Scanner([Link]);

  [Link]("fecility:-");
  fec_name = [Link]();

 }

 void show_feci()
 {

  [Link](fec_name);

 }

public class HOSPITALMGT

 public static void main(String args[])

 {

  String months[] = {

   "Jan",
   "Feb",
   "Mar",
   "Apr",

   "May",
   "Jun",
   "Jul",
   "Aug",

   "Sep",
   "Oct",
   "Nov",
   "Dec"
  };

  Calendar calendar = [Link]();

  //[Link]("--------------------------------------------------------------------------------");

  int count1 = 4, count2 = 4, count3 = 4, count4 = 4, count5 = 4, count6 = 4;

  [Link]("--------------------------------------------------------------------------------");

  [Link]("                          ***HOSPITAL MANAGEMENT SYATEM***");

  [Link]("--------------------------------------------------------------------------------");
  [Link]("Date: " + months[[Link]([Link])] + " " +
[Link]([Link]) + " " + [Link]([Link]));

  [Link]("\t\t\t\t\t\tTime: " + [Link]([Link]) + ":" +


[Link]([Link]) + ":" + [Link]([Link]));

  doctor[] d = new doctor[25];

  patient[] p = new patient[100];

  lab[] l = new lab[20];

  fecility[] f = new fecility[20];

  medical[] m = new medical[100];

  staff[] s = new staff[100];

  int i;

  for (i = 0; i < 25; i++)

   d[i] = new doctor();

  for (i = 0; i < 100; i++)

   p[i] = new patient();

  for (i = 0; i < 20; i++)

   l[i] = new lab();

  for (i = 0; i < 20; i++)

   f[i] = new fecility();

  for (i = 0; i < 100; i++)

   m[i] = new medical();

  for (i = 0; i < 100; i++)

   s[i] = new staff();

  d[0].did = "21";
  d[0].dname = "[Link]";
  d[0].specilist = "ENT";
  d[0].appoint = "10-4";
  d[0].doc_qual = "mbbs,Md";
  d[0].droom = 17;

  d[1].did = "32";
  d[1].dname = "[Link]";
  d[1].specilist = "medi.";
  d[1].appoint = "10-4";
  d[1].doc_qual = "mbbs,md";
  d[1].droom = 45;

  d[2].did = "17";
  d[2].dname = "[Link]";
  d[2].specilist = "Child spl";
  d[2].appoint = "10-4";
  d[2].doc_qual = "bdm";
  d[2].droom = 8;

  d[3].did = "33";
  d[3].dname = "[Link]";
  d[3].specilist = "Artho";
  d[3].appoint = "10-4";
  d[3].doc_qual = "mbbs,ms";
  d[3].droom = 40;

  p[0].pid = "12";
  p[0].pname = "pankaj";
  p[0].disease = "cancer";
  p[0].sex = "male";
  p[0].admit_status = "y";
  p[0].age = 30;

  p[1].pid = "13";
  p[1].pname = "kuli";
  p[1].disease = "cold";
  p[1].sex = "male";
  p[1].admit_status = "y";
  p[1].age = 23;

  p[2].pid = "14";
  p[2].pname = "Gaurav";
  p[2].disease = "maleriya";
  p[2].sex = "male";
  p[2].admit_status = "y";
  p[2].age = 45;

  p[3].pid = "15";
  p[3].pname = "ravi";
  p[3].disease = "sugar";
  p[3].sex = "male";
  p[3].admit_status = "y";
  p[3].age = 25;

  m[0].med_name = "corex";
  m[0].med_comp = "cino pvt";
  m[0].exp_date = "9-5-16";
  m[0].med_cost = 55;
  m[0].count = 8;

  m[1].med_name = "nytra";
  m[1].med_comp = "ace pvt";
  m[1].exp_date = "4-4-15";
  m[1].med_cost = 500;
  m[1].count = 5;

  m[2].med_name = "brufa";
  m[2].med_comp = "reckitt";
  m[2].exp_date = "12-7-17";
  m[2].med_cost = 50;
  m[2].count = 56;

  m[3].med_name = "pride";
  m[3].med_comp = "ddf pvt";
  m[3].exp_date = "12-4-12";
  m[3].med_cost = 1100;
  m[3].count = 100;

  l[0].fecility = "x-ray     ";


  l[0].lab_cost = 800;

  l[1].fecility = "ct scan   ";


  l[1].lab_cost = 1200;

  l[2].fecility = "or scan   ";


  l[2].lab_cost = 500;

  l[3].fecility = "blood bank";


  l[3].lab_cost = 50;

  f[0].fec_name = "ambulane";

  f[1].fec_name = "admit fec";

  f[2].fec_name = "canteen";

  f[3].fec_name = "free camp";


  s[0].sid = "22";
  s[0].sname = "ravi";
  s[0].desg = "worker";
  s[0].sex = "male";
  s[0].salary = 5000;

  s[1].sid = "23";
  s[1].sname = "komal";
  s[1].desg = "nurse";
  s[1].sex = "female";
  s[1].salary = 2000;

  s[2].sid = "24";
  s[2].sname = "raju";
  s[2].desg = "worker";
  s[2].sex = "male";
  s[2].salary = 5000;

  s[3].sid = "25";
  s[3].sname = "rani";
  s[3].desg = "nurse";
  s[3].sex = "female";
  s[3].salary = 20000;

  Scanner input = new Scanner([Link]);

  int choice, j, c1, status = 1, s1 = 1, s2 = 1, s3 = 1, s4 = 1, s5 = 1, s6 = 1;

  while (status == 1)

 {

   [Link]("\n                                    MAIN MENU");

   [Link]("--------------------------------------------------------------------------------");

   [Link]("[Link]  2. PATIENT  [Link]  [Link]  5. FACILITY 


[Link] [Link]");

   [Link]("--------------------------------------------------------------------------------");

   choice = [Link]();

   switch (choice)

   {
    case 1:

     {

      [Link]("--------------------------------------------------------------------------------");

      [Link]("                      **DOCTOR SECTION**");

      [Link]("--------------------------------------------------------------------------------");

      s1 = 1;

      while (s1 == 1)

   {

       [Link]("[Link] entry\[Link] list");

       c1 = [Link]();

       switch (c1)

       {

        case 1:

         {

          d[count1].new_doctor();count1++;

          break;

         }

        case 2:

         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("id \t name\t specilist \t timing \t qualification \t room no");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count1; j++)

     {
           d[j].doctor_info();

     }

          break;

         }

       }

       [Link]("RETURN BACK press (1/0) for more");

       s1 = [Link]();

   }

      break;

     }

    case 2:

     {

      [Link]("--------------------------------------------------------------------------------");

      [Link]("                     **PATIENT SECTION**");

      [Link]("--------------------------------------------------------------------------------");

      s2 = 1;

      while (s2 == 1)

   {

       [Link]("[Link] entry\[Link] list");

       c1 = [Link]();

       switch (c1)

       {

        case 1:
         {
          p[count2].new_patient();count2++;
          break;
         }

        case 2:

         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("id \t name \t disease \t sex \t admit_status \t age");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count2; j++) {


           p[j].patient_info();
     }
          break;
         }

       }

       [Link]("RETURN BACK press (1/0) for more");

       s2 = [Link]();

   }

      break;

     }

    case 3:

     {

      s3 = 1;

      [Link]("--------------------------------------------------------------------------------");

      [Link]("                     **MEDICAL SECTION**");

      [Link]("--------------------------------------------------------------------------------");

      while (s3 == 1)

   {

       [Link]("[Link] entry\[Link] list");


       c1 = [Link]();

       switch (c1)

       {

        case 1:
         {
          m[count3].new_medi();count3++;
          break;
         }

        case 2:

         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("name \t company \t expirity date \t cost");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count3; j++) {


           m[j].find_medi();
     }
          break;
         }

       }

       [Link]("RETURN BACK press (1/0) for more");

       s3 = [Link]();

   }

      break;

     }

    case 4:

     {

      s4 = 1;

      [Link]("--------------------------------------------------------------------------------");
      [Link]("                    **LABORATRY SECTION**");

      [Link]("--------------------------------------------------------------------------------");

      while (s4 == 1)

   {

       [Link]("[Link] entry \[Link] list");

       c1 = [Link]();

       switch (c1)

       {

        case 1:
         {
          l[count4].new_feci();count4++;
          break;
         }

        case 2:

         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("fecility\t\tcost");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count4; j++) {


           l[j].feci_list();

     }

          break;

         }

       }

       [Link]("RETURN BACK press (1/0) for more");

       s4 = [Link]();
   }

      break;

     }

    case 5:

     {

      s5 = 1;

      [Link]("--------------------------------------------------------------------------------");

      [Link]("          **HOSPILITY FACILITY SECTION**");

      [Link]("--------------------------------------------------------------------------------");

      while (s5 == 1)

   {

       [Link]("[Link] entry\[Link] list");

       c1 = [Link]();

       switch (c1)

       {

        case 1:
         {
          f[count5].add_feci();count5++;
          break;
         }

        case 2:
         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("hospility facility are:-");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count5; j++) {


           f[j].show_feci();
     }
          break;
         }

       }

       [Link]("RETURN BACK press (1/0) for more");

       s5 = [Link]();

   }

      break;

     }

    case 6:

     {

      s6 = 1;

      [Link]("--------------------------------------------------------------------------------");

      [Link]("                       **STAFF SECTION**");

      [Link]("--------------------------------------------------------------------------------");

      while (s6 == 1)

   {

       String a = "nurse", b = "worker", c = "security";

       [Link]("[Link] entry\[Link] list\[Link] list \[Link] list");

       c1 = [Link]();

       switch (c1)

       {

        case 1:
         {
          s[count6].new_staff();count6++;
          break;
         }

        case 2:
         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("id \t name \t sex \t salary");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count6; j++)

     {

           if ([Link](s[j].desg))

            s[j].staff_info();

     }

          break;

         }

        case 3:

         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("id \t name \t sex \t salary");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count6; j++)

     {

           if ([Link](s[j].desg))

            s[j].staff_info();

     }

          break;

         }
        case 4:

         {

     
[Link]("--------------------------------------------------------------------------------");

          [Link]("id \t name \t sex \t salary");

     
[Link]("--------------------------------------------------------------------------------");

          for (j = 0; j < count6; j++)

     {

           if ([Link](s[j].desg))

            s[j].staff_info();

     }

          break;

         }

       }

       [Link]("RETURN BACK press (1/0) for more");

       s6 = [Link]();

   }

      break;

     }

    case 7:

     {

      break;

     }

    default:

     {
      [Link]("enter wrong choice!");

     }

   }

   [Link]("RETURN MAIN MENU press (1/0) for more");

   status = [Link]();

 }

 }

Common questions

Powered by AI

The main control structure employs a while loop for continuous user interaction and section navigation. Users choose from main menu options to access sections: Doctor, Patient, Medical, Lab, Facility, and Staff. Each section further provides options for new entries or listings (e.g., new doctor, doctor list). A switch-case ensures appropriate actions based on user input, and nested loops allow repeated tasks within sections, enhancing flexibility and user-driven interaction flow .

Hospility facilities are managed through the 'fecility' class (misspelled in the source). Facilities are added using the 'add_feci' method, which asks for user input to store facility names. These can then be displayed with the 'show_feci' method. The misspelling of 'facility' as 'fecility' could be an oversight or typographical error, which seems consistent across the system's code, indicating a potential lack of thorough proofreading or a non-native English error .

The hospital management system differentiates doctors from other staff by using a separate class called 'doctor'. Information about each doctor, such as their ID (did), name (dname), specialization (specilist), working hours (appoint), qualification (doc_qual), and room number (droom) is stored via the 'new_doctor' method. This method captures input from the user and stores it in a 'doctor' array. The stored information can be retrieved and displayed using the 'doctor_info' method, which outputs the relevant details of each doctor .

The use of predefined array sizes for storing doctors (25) and patients (100) imposes limitations on scalability. If these limits are reached, no additional entries can be made without modifying the code to increase the array size. This static allocation can lead to increased maintenance overhead and potential data overflow errors, requiring dynamic data structures like ArrayLists or linked lists for a more flexible and efficient approach in real-world applications .

The system manages patient information using the 'patient' class. It captures details such as patient ID (pid), name (pname), disease, sex, admit status, and age through the 'new_patient' method. This method prompts the user to enter the information, which is then stored in the system. For displaying patient data, the 'patient_info' method is utilized, which presents the previously recorded details in a tabular form. This allows for efficient data retrieval and management within the hospital .

The laboratory section is managed using the 'lab' class, which handles information about laboratory services (fecility) and their associated costs (lab_cost). The 'new_feci' method captures user input regarding new lab services and their costs, storing these in the system. This facilitates the addition of new services to the existing list. For retrieval, the 'feci_list' method is utilized, which displays the current services and their costs. This structure ensures efficient management and updating of laboratory services within the hospital .

Medical supplies and inventory are handled by the 'medical' class in the system. Key information tracked for each medicine includes the medicine name (med_name), company (med_comp), expiration date (exp_date), cost (med_cost), and count (number of units available). These details are captured using the 'new_medi' method, which gathers user input to store in the system. The 'find_medi' method is then used to display the stored information, aiding in the inventory management and ensuring that medicines are tracked effectively .

The hospital management system allows new staff members to be added through the 'new_staff' method in the 'staff' class. This method prompts for and records several details of the staff member, including their ID (sid), name (sname), designation (desg), sex, and salary. The information is inputted by the user through a console interface, ensuring that all necessary details are stored for future reference .

Handling incorrect input types can cause runtime errors and system instability. For instance, in the 'staff' or 'patient' classes, when the system prompts for integer input like salary or age, entering a non-integer value results in a mismatch exception, causing the application to crash. A robust error handling mechanism, such as exception handling with 'try-catch' blocks, should be implemented to validate inputs and prevent incorrect type submissions, ensuring system reliability and user-friendly interaction .

The 'new_patient' method captures patient-specific data such as ID, name, disease, sex, admit status, and age, focusing on biological and personal information. In contrast, the 'new_doctor' method collects professional data such as ID, name, specialization, appointment timings, qualifications, and room number, emphasizing credentials and availability. These differences reflect the tailored approach for managing diverse data necessary for patients' care logistics and doctors' professional activities .

You might also like