In this project we will implement the code of Hospital management system in Java. The project consist of 5 classes including one main class. The Hospital Management System allow users to add doctors, add patient and assign a doctor to a specific patient.
Source Code
Start.Java
package LEP.uzair.HMS.start; import java.util.Scanner; import LEP.uzair.HMS.Hospital.Hospital; public class Start { public static void StartHms() { int c=0; @SuppressWarnings("resource") Scanner input = new Scanner(System.in); char YesOrNo = 'Y'; while (YesOrNo =='Y'){ System.out.print("\t\t ============================\n"); System.out.print("\t\t Welcome To Hospital Managment \n"); System.out.print("\t\t Software \n"); if(c==0){ c++; }else{ System.out.print("\t\t Again\n"); } System.out.print("\t\t ============================\n"); Hospital obj_hosptl=new Hospital(); obj_hosptl.start(); System.out.println("\n\tDo u want to Continue \n\t\tY = Continue Again\n\t\tN = Exit\n"); System.out.println("You Select : "); YesOrNo =(input.next()).charAt(0); if(Character.isLowerCase(YesOrNo )){ YesOrNo =Character.toUpperCase(YesOrNo ); } }//End While } }
Doctor.Java
package LEP.uzair.HMS.Hospital; import java.util.ArrayList; public class Doctor { private String doctorName; private String doctorSpeciality; String doctorStatus; ArrayList<Patient> doctorPatientList= new ArrayList<Patient>(); Doctor(String c, String cc) { this.doctorName=c; this.doctorSpeciality=cc; } public String getDoctorName() { return doctorName; } public ArrayList<Patient> getDoctorPatientList() { return doctorPatientList; } public void addPatientsToDoctor(Patient o) { doctorPatientList.add(o); } public void clearPatientsToDoctor() { doctorPatientList.clear(); } String getDoctorspeciality() { return doctorSpeciality; } public String toString() { return (doctorName+""+doctorSpeciality); } }
Hospita.Java
package LEP.uzair.HMS.Hospital; import java.util.ArrayList; import java.util.Scanner; public class Hospital { int doctorCount = 0; int patientCount=0; ArrayList<Doctor> doctorList = new ArrayList<Doctor>(); ArrayList <Patient> patientList = new ArrayList<Patient>(); public void start() { @SuppressWarnings("resource") Scanner input = new Scanner(System.in); char YesOrNo = 'Y'; while (YesOrNo =='Y'){ System.out.print("\tQ:What do you want to do?\n\n"); System.out.print("\t\t1 : Add doctor\n\n"); System.out.print("\t\t2 : Show doctors\n\n"); System.out.print("\t\t3 : Add patient\n\n"); System.out.print("\t\t4 : Assign doctor to patients\n\n"); System.out.print("\t\t5 : Doctor and their patients\n\n"); System.out.println("\t\t\tYou Select : "); String switchChoice=input.next(); switch (Integer.parseInt(switchChoice)) { case 1: { @SuppressWarnings("resource") Scanner input1 = new Scanner(System.in); String tempName; String tempSpeciality; System.out.print("Enter Doctor Name"); tempName = input1.nextLine(); tempName = tempName + " "; System.out.print("Select Doctor Speciality\n1: Opthalmologist \n2: Surgeon \n3: ENT"); Scanner input2 = new Scanner(System.in); int tempSpecNo = input1.nextInt(); if(tempSpecNo==1){ tempSpeciality="Opthalmologist"; }else if(tempSpecNo==2){ tempSpeciality="Surgeon"; }else if(tempSpecNo==3){ tempSpeciality="ENT"; }else{ tempSpeciality=" "; } Doctor o1 = new Doctor(tempName,tempSpeciality); doctorList.add(doctorCount,o1); doctorCount++; break; } case 2: { showDoctors(); break; } case 3: { @SuppressWarnings("resource") Scanner input1 = new Scanner(System.in); String tempName,tempGender, tempDisease; int tempAge; System.out.print("Enter Patient Name"); tempName = input1.nextLine(); tempName = tempName + " "; System.out.print("Enter Patient Age"); @SuppressWarnings("resource") Scanner input2 = new Scanner(System.in); tempAge = input2.nextInt(); System.out.print("Enter Patient Gender"); @SuppressWarnings("resource") Scanner input3 = new Scanner(System.in); tempGender = input3.nextLine(); tempGender = " " + tempGender + " "; // System.out.print("Enter Patient Disease");//eye , heart patient , earnose , // @SuppressWarnings("resource") // Scanner input4 = new Scanner(System.in); // tempDisease = input4.nextLine(); System.out.print("Select Patient Disease\n1: eye \n2: heart patient \n3: earnose"); Scanner input4 = new Scanner(System.in); int tempSpecNo = input4.nextInt(); if(tempSpecNo==1){ tempDisease="eye"; }else if(tempSpecNo==2){ tempDisease="heart patient"; }else if(tempSpecNo==3){ tempDisease="earnose"; }else{ tempDisease=" "; } Patient p1 = new Patient(tempName,tempAge,tempGender, tempDisease); patientList.add(patientCount,p1); patientCount++; break; // System.out.println(showPatients()); } case 4: { assignDoctor(); break; } case 5: { System.out.print("Enter Doctor ID > 0 AND <= "+Integer.toString(doctorCount)); @SuppressWarnings("resource") Scanner in = new Scanner(System.in); int i = in.nextInt(); i=i--; System.out.println("\n \n \n "+ ""+doctorList.get(i).getDoctorName()+""+doctorList.get(i).getDoctorPatientList()); break; } default: { System.out.println("Invalid Selection"); break; } } System.out.println("\n\tDo u want to Do some thing Else \n\t\tY = yes\n\t\tN = No\n"); System.out.println("You Select : "); YesOrNo =(input.next()).charAt(0); if(Character.isLowerCase(YesOrNo )){ YesOrNo =Character.toUpperCase(YesOrNo ); } }//End While }// End Start() public void showDoctors() { for(int i = 0 ; i<doctorCount;i++ ){ System.out.println(doctorList.get(i)+"\n"); } } public ArrayList<Patient> showPatients() { return patientList; } public void assignDoctor() { for (Patient x: patientList) { for (Doctor y: doctorList) { if (x.getDisease().equals("eye")) { if (y.getDoctorspeciality().equals("Opthalmologist")) { y.addPatientsToDoctor(x); System.out.println("\n Docter(Opthalmologist) Added With Patient with Eye disease"); } } if (x.getDisease().equals("heart patient")) { if (y.getDoctorspeciality().equals("Surgeon")) { y.addPatientsToDoctor(x); System.out.println("\n Docter(Surgeon) Added With Patient with heart disease"); } } if (x.getDisease().equals("earnose")) { if (y.getDoctorspeciality().equals("ENT")) { y.addPatientsToDoctor(x); System.out.println("\n Docter(ENT) Added With Patient with earnose disease"); } } } } } }
Patient.Java
package LEP.uzair.HMS.Hospital; public class Patient { private String patientName; private int patientAge; private String patientGender; private String disease; Patient (String patientName, int patientAge,String patientGender, String disease) { this.patientName= patientName; this.patientGender= patientGender; this.patientAge=patientAge; this.disease=disease; } public String getDisease() {return disease;} public String toString() { return (patientName+""+patientAge+""+patientGender +" "+ disease); } }
main.Java
package LEP.uzair.HMS.main; import LEP.uzair.HMS.start.Start; public class MyMain { public static void main(String[] args) { //Static Function Demonstration Start.StartHms(); } }
This comment has been removed by the author.
ReplyDeleteNice Blog! Are you Looking for the best health care center in Zirakpur? We provide health treatment at an affordable price. We provide services includes back pain, joints, headache, weight loss, blood circulation, etc. With 10 years experince we become NO.1 Best Health care Center. We help to make your fit. We have expert and professional team for health care center.
ReplyDeleteI'm truly impressed by the significance of healthcare software development services in today's healthcare landscape. As technology continues to advance, these services play a pivotal role in enhancing patient care, streamlining administrative tasks, and improving overall healthcare efficiency.
ReplyDeleteAre you tired of dealing with your Hospital's growing budgetary pressure, compliance with regulatory requirements, managing operational and IT-related issues, administration staff, etc then Hospital Management Software could easily solve these issues in a matter of few clicks.
ReplyDelete