Question: Hi, I need help with a Java Class question. I was wondering if anyone might be able to help solve this question here! Create a
Hi, I need help with a Java Class question. I was wondering if anyone might be able to help solve this question here!
Create a new Java project called EMR.
Use the class diagram(s) below to create a skeleton for your Java program. Start by creating classes, then add properties and then method stubs. Pay close attention to visibilities.
| EMR |
|
|
| +main():void |
| Patient |
| -patientID:String -firstName:String -lastName:String -ssn:String -gender:char -diagnoses:Diagnoses -medication:Medication -symptom:String -weight:double -height:double |
| +Patient(firstName:String, lastName:String, ssn:String, gender:char, weight:double, height:double) +calculateBMI():double |
| Doctor |
| -employeeID:String -firstName:String -lastName:String -ssn:String -specialization:String |
| +Doctor(firstName:String, lastName:String, ssn:String) +prescribe(patient:Patient):void |
| Medication |
| -medicationID:int -name:String |
| +Medication(medicationID:int, name:String) |
| Diagnoses |
| -diagnosesID:int -name:String |
| +Diagnoses(diagnosesID:int, name:String) |
DO THIS ITEM LAST! EMR class is the driver class (the class with the main method, the class the run). The main method should do several things:
Create an instance of Patient (a new variable of type Patient). You can make up the data that you pass to Patients constructor. Look at the EMR Driver class example at the end of this document.
Ask patient to enter a symptom using JOptionPane.showInputDialog();
Set Patients symptom property to provided value using appropriate setter.
Create Doctor object
Make the doctor prescribe to the patient (see classes Doctor and class Patient)
Output a "profile" of the patient, including complete name, SSN, BMI, diagnoses and prescribed medication. If patient has no diagnoses, nor prescription (see method prescribe in class Doctor), the profile should show "none".
Diagnosis class:
Diagnosis constructor will initialize corresponding properties.
Medication class:
Medication constructor will initialize corresponding properties.
Patient class:Patient constructor will:
Initialize corresponding properties
Initialize patientID property based on a social security number (ssn property) with all dashes and spaces stripped followed by first letter of first name and first letter of last name.
calculateBMI() method will:
Calculate patients BMI (https://www.cdc.gov/healthyweight/assessing/bmi/childrens_bmi/childrens_bmi_formula.html)
Return the bmi value
Doctor class:Doctor constructor will:
Initialize corresponding properties
Initialize employeeID property based on a social security number (ssn property) with all dashes and spaces stripped followed by first letter of first name and first letter of last name.
prescribe() method will complete the following actions:
Match the symptom of the patient parameter with diagnoses and medication (see table below for the match list).
If symptom matches with diagnosis:
Create Diagnosis object with appropriate parameters for the constructor.
Create Medication object with appropriate parameters for the constructor.
Set patients diagnosis and medication properties with recently created objects using corresponding setters.
Hint: use setters from the Patient object passed to the prescribe() method
If symptom does not match with diagnosis:
Set Patients diagnosis and medication properties to null using corresponding setters.
Display a message telling patient that he/she cannot be diagnosed.
| Symptom | Diagnosis |
| Medication |
|
|
| ID | Name | ID | Name |
| Headache | 1 | Dehidration | 1 | Tylenol |
| Cough | 2 | Common cold | 2 | Cough drops |
| Fever | 3 | Influenza | 3 | Tamiflu |
EMR Driver class example (the following code will go into main() method):
Note: if you are going to copy and paste this code, youll need to fix Microsofts weird quotes.
Patient patient = new Patient("John", "Doe", "111-11-1111", 'm', 170, 70);
String symptom = JOptionPane.showInputDialog("Please enter your symptom:");
patient.setSymptom(symptom);
Doctor doctor = new Doctor("Jane", "Smith", "222-22-2222");
doctor.prescribe(patient);
String patientProfile = "Name: " + patient.getLastName() + ", " + patient.getFirstName() + " ";
patientProfile = patientProfile + "SSN: " + patient.getSsn() + " ";
patientProfile = patientProfile + "BMI: " + patient.calculateBMI() + " ";
if(patient.getDiagnoses() != null){
patientProfile = patientProfile + "Diagnoses: " + patient.getDiagnoses().getName() + " ";
}
else{
patientProfile = patientProfile + "Diagnoses: none ";
}
if(patient.getMedication() != null){
patientProfile = patientProfile + "Medication: " + patient.getMedication().getName() + " ";
}
else{
patientProfile = patientProfile + "Medication: none ";
}
JOptionPane.showMessageDialog(null, patientProfile);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
