Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement a Java program to create a list of patients’ records in a m

ID: 3792272 • Letter: D

Question

Design and implement a Java program to create a list of patients’ records in a medical practice. The program will maintain a current list of patients records within a given multi-disciplinary practice. Patient data for the program includes a patient's ID, first name, last name, e-mail address (valid emails contain an @ and .), age, gender, weight, height and an array of doctors used by the patient and their specialty (the maximum number of specialists should be five). Error checking of all data is required. The program should allow entry of patient information via the keyboard with the maximum number of patients being 30, but the list can contain less. Once the data is entered the program should then allow the user to retrieve the entire list of patients' or an individual patient’s information via the patient’s ID number.

The program in both instances should display all of the information listed above plus the program should calculate the patient’s Body Mass Index (BMI = (weight in pounds/(height in inches X height in inches) X 703) and display it along with the category the patient falls under.

The categories are based upon the following: Below 18.5 - Underweight 18.5 – 24.9 - Normal 25 – 29.9 - Overweight 30 and above - Obese Make sure to submit the following: documentation code screen shots or files of I/O executable file (JAR file)

Completely confused about this assignment..hints will help too.

Explanation / Answer

public class Patient {

   protected int patientId;
   protected String fname;
   protected String lname;
   protected String emailAddress;
   protected int age;
   protected String gender;
   protected double height;
   protected double weight;

   public Patient(int patientId, String fname, String lname,
           String emailAddress, int age,String gender, double height, double weight) {
       this.patientId = patientId;
       this.fname = fname;
       this.lname = lname;
       this.emailAddress = emailAddress;
       this.age = age;
       this.height = height;
       this.weight = weight;
       this.gender = gender;
   }

   public int getPatientId() {
       return patientId;
   }

   public void setPatientId(int patientId) {
       this.patientId = patientId;
   }

   public String getFname() {
       return fname;
   }

   public void setFname(String fname) {
       this.fname = fname;
   }

   public String getLname() {
       return lname;
   }

   public void setLname(String lname) {
       this.lname = lname;
   }

   public String getEmailAddress() {
       return emailAddress;
   }

   public void setEmailAddress(String emailAddress) {
       this.emailAddress = emailAddress;
   }

   public int getAge() {
       return age;
   }

   public void setAge(int age) {
       this.age = age;
   }

   public double getHeight() {
       return height;
   }

   public void setHeight(double height) {
       this.height = height;
   }

   public double getWeight() {
       return weight;
   }

   public void setWeight(double weight) {
       this.weight = weight;
   }

   public int hashCode() {
       final int prime = 31;
       int result = 1;
       result = prime * result + age;
       result = prime * result
               + ((emailAddress == null) ? 0 : emailAddress.hashCode());
       result = prime * result + ((fname == null) ? 0 : fname.hashCode());
       long temp;
       temp = Double.doubleToLongBits(height);
       result = prime * result + (int) (temp ^ (temp >>> 32));
       result = prime * result + ((lname == null) ? 0 : lname.hashCode());
       result = prime * result + patientId;
       temp = Double.doubleToLongBits(weight);
       result = prime * result + (int) (temp ^ (temp >>> 32));
       return result;
   }

   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       Patient other = (Patient) obj;
       if (age != other.age)
           return false;
       if (emailAddress == null) {
           if (other.emailAddress != null)
               return false;
       } else if (!emailAddress.equals(other.emailAddress))
           return false;
       if (fname == null) {
           if (other.fname != null)
               return false;
       } else if (!fname.equals(other.fname))
           return false;
       if (Double.doubleToLongBits(height) != Double
               .doubleToLongBits(other.height))
           return false;
       if (lname == null) {
           if (other.lname != null)
               return false;
       } else if (!lname.equals(other.lname))
           return false;
       if (patientId != other.patientId)
           return false;
       if (Double.doubleToLongBits(weight) != Double
               .doubleToLongBits(other.weight))
           return false;
       return true;
   }

   public String toString() {
       return "Patient [patientId=" + patientId + ", fname=" + fname
               + ", lname=" + lname + ", emailAddress=" + emailAddress
               + ", age=" + age + ", height=" + height + ", weight=" + weight
               + "]";
   }

}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class DoctorDemo {

   public static void main(String[] args) {
       List<Patient> patientlist=new ArrayList<Patient>();
       Scanner scanner=new Scanner(System.in);
       for(int i=0;i<2;i++)
       {
       System.out.println("enter the patient id");
       int patientId = scanner.nextInt();
       System.out.println("enter the first name");
       String fname = scanner.next();
       System.out.println("enter the last name");
       String lname = scanner.next();
       System.out.println("enter the email address");
       String emailAddress = scanner.next();
       System.out.println("enter the age ");
       int age =scanner.nextInt();
       System.out.println("enter the height in inches");
       double height = scanner.nextDouble();
       System.out.println("enter the weight in pounds");
       double weight = scanner.nextDouble();
       System.out.println("enter the gender ");
       String gender=scanner.next();
      
Patient patient=new Patient(patientId, fname, lname, emailAddress, age, gender, height, weight);
patientlist.add(patient);
       }  
      
       //display and check the condition for patient id
       System.out.println("enter the patient id to check whether it is in list or not");
       int pno=scanner.nextInt();
       int count=0;
       for(Patient patient:patientlist)
       {
           if(pno==patient.patientId)
           {
               count++;
               System.out.println(patient);
              
               System.out.println("");
               System.out.println("");
           }
       }
       if(count==0)
       {
           System.out.println("your given patient is not found in patient list");
       }
      
       //to calculate bmi for all patient and display
      
       for(Patient patient:patientlist)
       {
           System.out.println(patient);
           double weight=patient.getWeight();
           double height=patient.getHeight();
           double bmi=(weight/(height * height) *703);
           if(bmi<18.5)
           {
               System.out.println("bmi is below ");
              
           }else if(bmi>18.5 || bmi<24.9)
           {
               System.out.println("bmi underweight");
           }else if(bmi>25 ||bmi<29.9)
               System.out.println("bmi normal");
           else
               System.out.println("bmi overWeight");
          
           System.out.println("");
           System.out.println("");
          
       }
   }
}

output

enter the patient id
25
enter the first name
mark
enter the last name
smith
enter the email address
mark .com
enter the age
36
enter the height in inches
120
enter the weight in pounds
36
enter the gender
male
enter the patient id
36
enter the first name
michel
enter the last name
smith
enter the email address
michel .com
enter the age
69
enter the height in inches
145
enter the weight in pounds
45
enter the gender
male
enter the patient id to check whether it is in list or not
25
Patient [patientId=25, fname=mark, lname=smith, emailAddress=mark .com, age=36, height=120.0, weight=36.0]
Patient [patientId=25, fname=mark, lname=smith, emailAddress=mark .com, age=36, height=120.0, weight=36.0]
bmi is below


Patient [patientId=36, fname=michel, lname=smith, emailAddress=michel .com, age=69, height=145.0, weight=45.0]
bmi is below

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote