Program Description: In this assignment you will develop a simplified version of
ID: 3767083 • Letter: P
Question
Program Description:
In this assignment you will develop a simplified version of a patient health record management system, for which you need to write two Java classes: EMR.java and StudentHealthServices.java. As always, include comments in your program wherever appropriate. Also, you don’t need to make this program interactive (So no need of Scanner class), simply hard-code all the patient information into the program. Same for simulating patient visit.
• Please Name your project StudentHealthServices.
• After creating your project please add another file to the project called EMR by right-clicking on the package named ”studenthealthservices” in the project browser. You can also left-click on the same package. Then in the top menu bar, go to File > New File. The select Java In the categories window and Java Class in the File Types window.
1. In the EMR.java Class
(a) (14 points) Create the following PRIVATE data-fields:
• Name (String)
• Date-of-birth (String)
• Reason for visit (String)
• Body-temperature (double)
• Heart-rate (double)
• Diagnosis (String)
• Prescribed medicine (String)
(b) (5 points) Declare a static variable that keeps count of how many patients objects have been created.
(c) (5 points) Create a default no-arg constructor. Also, increment the patient counter static variable.
(d) (5 points) Create a constructor that initializes ONLY the name and date-of-birth data-fields(i.e. takes two arguments). Also, increment the patient counter static variable.
(e) (8 points) Create a constructor that initializes ALL data-fields. Also, increment the patient counter static variable.
(f) (14 points) Create getters/setters for ALL the above data-fields. Should be 14 in total.
(g) (3 points) Create a getter method for the static variables that keeps tracks of how many patient objects are created.
(h) (5 points) Implement an instance method called redFlags. This method should return a boolean value. The method will return true if either the heart rate is less than 60 or greater than 100 OR if the body-temp is either less than 97.3 or greater than 99.1 .
(i) (5 points) Implement a toString method that will build a String of all the data- fields of the EMR class. YOU CAN NOT PRINT IN THIS METHOD.
2. StudentHealthServices.java
(a) (3 points) Print the number of created patien records. This is the number of EMR instances. At this point this should print 0.
(b) (5 points) Create 5 new patient records, that is, 5 new objects of the EMR class (described above).
(c) (3 points) Print the number of patient records after the above step. Use the appropriate data field (not a local variable) of the EMR class above. 2
(d) (10 points) Simulate a visit to the Student Health services for 3 of the 5 patients.
This involves two steps: i. Display(Print) the current values for:
• patient name
• date of birth ii. Record the summary of todays visit, that is, update the below data fields, and also display(print) them. you can simply print the EMR objects after the simulated visit.:
• reason for visit.
• vitals (body temperature, heart rate)
• diagnosis.
• prescribed medicine.
(e) (10 Points) Please document/comment your code.
Explanation / Answer
import java.util.*;
class EMR
{
private String name;
private String dob;
private String reason;
private double temp;
private double heart_rate;
private String diagnosis;
private String prescribed_medicine;
public static int count=0;
public EMR()
{
count++;
}
public EMR(String Name, String DOB)
{
name = Name;
dob = DOB;
count++;
}
public EMR(String Name, String DOB,String Reason, double Temp, double Heart_rate, String Diagnosis, String Prescribed_medicine)
{
name = Name;
dob = DOB;
reason = Reason;
temp = Temp;
heart_rate = Heart_rate;
diagnosis = Diagnosis;
prescribed_medicine = Prescribed_medicine;
count++;
}
public void setName(String Name)
{
name = Name;
}
public void setDOB(String DOB)
{
dob = DOB;
}
public void setReason(String Reason)
{
reason = Reason;
}
public void setDiagnosis(String Diagnosis)
{
diagnosis = Diagnosis;
}
public void setPrescribed_medicine(String Prescribed_medicine)
{
prescribed_medicine = Prescribed_medicine;
}
public void setTemp(double Temp)
{
temp = Temp;
}
public void setHeart_rate(double Heart_rate)
{
heart_rate = Heart_rate;
}
public String getName()
{
return name;
}
public String getDOB()
{
return dob;
}
public String getReason()
{
return reason;
}
public double getTemp()
{
return temp;
}
public double getHeart_rate()
{
return heart_rate;
}
public String getDiagnosis()
{
return diagnosis;
}
public String getPrescribed_medicine()
{
return prescribed_medicine;
}
public int getCount()
{
return count;
}
public boolean redFlags()
{
if(heart_rate < 60 || heart_rate > 100 || temp <97.3 || temp > 99.1)
return true;
return false;
}
public String toString()
{
return name+" "+dob+" "+reason+" "+temp+" "+heart_rate+" "+diagnosis+" "+prescribed_medicine;
}
}
class TestClass {
public static void main(String args[] ) throws Exception {
String name, dob,reason,diag,presc;
double temp,rate;
Scanner in = new Scanner(System.in);
System.out.println("number of record = "+EMR.count);
EMR[] e = new EMR[5];
for(int i=0;i<5;i++)
{
System.out.println("enter name of student "+(i+1));
name = in.nextLine();
System.out.println("enter dob of student "+(i+1));
dob = in.nextLine();
e[i] = new EMR(name,dob);
}
System.out.println("number of record = "+EMR.count);
System.out.println("Hello World!");
for(int i=0;i<3;i++)
{
System.out.println(e[i].getName()+ " "+e[i].getDOB());
System.out.println("enter reason of visit");
reason = in.nextLine();
e[i].setReason(reason);
System.out.println("enter temperature");
temp = in.nextDouble();
e[i].setTemp(temp);
System.out.println("enter heartrate");
rate = in.nextDouble();
e[i].setHeart_rate(rate);
System.out.println("enter diagnosis");
diag = in.nextLine();
e[i].setDiagnosis(diag);
System.out.println("enter prescription");
presc= in.nextLine();
e[i].setPrescribed_medicine(presc);
System.out.println(e[i].toString());
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.