Class for java. Named appointment. You are required to write a class named Appoi
ID: 3713316 • Letter: C
Question
Class for java. Named appointment.
You are required to write a class named Appointment to model the details of a appointment made to see a specialist at the Child Health Clinic.
The design and functionality for this Appointment class will be discussed below and you must adhere to this class design / functional specification - no changes to this design are permitted unless a specific clarification or correction is made by the instructor, as part of this task is being able to understand and follow a design specification that you have been given.
A) Declare private instance variables to store the details required for a single Appointment in the system: appointment ID, clinic name, appointment time, appointment status, room number, patient name, consultation notes, bulk billin (boolean), and consultation fee (int). Note: The type for each instance variable listed above is String, unless otherwise stated
B) Provide a constructor for the class that accepts the information shown below as parameters for the Appointment to be created: public Appointment(String appointmentID, String appointmentTime, String patientName, boolean bulkBilling) This constructor should begin by initialising the corresponding instance variables to the values passed in via in the supplied parameters. The appointment status should be initialised to 'scheduled' (ie. "SCH"), after which the clinic name should be recorded by invoking the getClinicName() method of the ClinicDetails class in an appropriate manner, passing the appointment ID as a parameter, and storing the result in the clinic name instance variable.
C) Implement accessors for the appointment ID, clinic name, appointment time, appointment status and patient name instance variables.
D) Implement a method public boolean checkIn (), which handles the checking in of a patient for their clinic Appointment. If the appointment status for the current Appointment is not currently 'scheduled' (ie. "SCH") then the method should immediately return the value false, otherwise it should proceed to update the appointment status to 'checked in' (ie. "CHK") and return the value true.
E) Implement a method public boolean callPatient (String roomNumber), which handles the calling of a patient to the assigned consultation room for their clinic Appointment. If the appointment status for the current Appointment is not currently 'checked in' (ie. "CHK") then the method should immediately return the value false, otherwise it should proceed to store the room number that was passed in as a parameter in the corresponding room number instance variable, update the appointment status to 'called' (ie. "CLD") and return the value true.
F) Implement a method public int recordConsultation (String notes), which records details of a consultation that has been delivered to a patient at the clinic. If the appointment status for the current Appointment is not currently 'called' (ie. "CLD") then the method should immediately return the value -1. Otherwise the method should proceed to store the notes that were passed in as a parameter to the corresponding consultation notes instance, after which it should proceed to update the appointment status and determine the applicable consultation fee, based on the bulk billing status as follows: If the appointment is being bulk billed (ie. bulk billing is set to true) then the appointment status should be set to "bulk billed" (ie. "BBL") and the method should return the value zero (0). Otherwise the method should proceed to determine the applicable consultation fee, by invoking the getClinicFee() method from the ClinicDetails class in an appropriate manner (passing in the appointment ID as a parameter), and store the result that is returned in the consultation fee instance variable, after which it should update the appointment status to "payment pending" (ie. "PPE") and return the consultation fee that was stored earlier.
G) Implement a method public void printDetails() , which displays all of the details of an appointment to the screen in a neat, formatted manner - this summary should include the following details: • the appointment ID and clinic name • the appointment time and appointment status • the room number, patient name and their bulk billing status • the consultation notes and consultation fee Sample output demonstrating the structure and content required in the record for an appointment is shown below.
Appointment immediately after creation:
Appointment ID: AUD001, Clinic: AUDITORY Appointment Time: 05/04/2018 14:00, Status: SCH Room: null, Patient: Jill Smith, Bulk Billing: false Consultation Notes: null Consultation fee: $0 Same appointment after recording of consultation: Appointment ID: AUD005, Clinic: AUDITORY Appointment Time: 05/04/2018 14:00, Status: PPE Room: B-212, Patient: Jill Smith, Bulk Billing: false Consultation Notes: LHS Test 95% complete - response at all levels RHS 100% complete - response at all levels Assessment - hearing within normal ranges (both sides) Consultation fee: $120
Note that you do not need to match this formatting exactly, but it is expected that the details your printDetails() method displays to the screen will be neat and easy to read and all details for the Appointment should be labeled appropriately, so that the user can work out what they represent.
Explanation / Answer
package pregnancydiary.models;
import java.sql.Date;
public class Appointment {
private Mother mother;
private Date date;
private String purpose;
private String hospital;
private String doctor;
private String time;
private int month;
private int id;
public static final String MORNING_TIME_STRING = "Morning";
public static final String AFTERNOON_TIME_STRING = "Afternoon";
public static final String EVENING_TIME_STRING = "Evening";
/**
* A constructor method for the Appointment class
* @param mother Mother object who the appointment will be assigned to
* @param date The date for the appointment
* @param purpose A description of the purpose of the appointment
* @param hospital The hospital location of the appointment
* @param doctor The doctor who the appointment is with
* @param time The time of the appointment
* @param month The month of the appointment
* @param id The appointment id
*/
public Appointment(Mother mother, Date date, String purpose, String hospital, String doctor, String time, int month, int id){
this.mother = mother;
this.date = date;
this.purpose = purpose;
this.hospital = hospital;
this.doctor = doctor;
this.time = time;
this.month = month;
this.id = id;
}
/**
* A constructor method for the Appointment class
* @param mother Mother object who the appointment will be assigned to
* @param date The date for the appointment
* @param purpose A description of the purpose of the appointment
* @param hospital The hospital location of the appointment
* @param doctor The doctor who the appointment is with
* @param time The time of the appointment
*/
public Appointment(Mother mother, Date date, String purpose, String hospital, String doctor, String time){
this.mother = mother;
this.date = date;
this.purpose = purpose;
this.hospital = hospital;
this.doctor = doctor;
this.time = time;
}
//accessors: getters:
/**
* An accessor method for the Appointment class
* @return The date of the appointment
*/
public Date getDate(){
return date;
}
/**
* An accessor method for the Appointment class
* @return The month of the appointment
*/
public int getMonth(){
return month;
}
/**
* An accessor method for the Appointment class
* @return The id of the appointment
*/
public int getID(){
return id;
}
/**
* An accessor method for the Appointment class
* @return Mother object who the appointment will be assigned to
*/
public Mother getMother(){
return mother;
}
/**
* An accessor method for the Appointment class
* @return The purpose of the appointment
*/
public String getPurpose(){
return purpose;
}
/**
* An accessor method for the Appointment class
* @return The hospital of the appointment
*/
public String getHospital(){
return hospital;
}
/**
* An accessor method for the Appointment class
* @return The doctor the appointment is with
*/
public String getDoctor(){
return doctor;
}
/**
* An accessor method for the Appointment class
* @return The time of the appointment
*/
public String getTime(){
return time;
}
//mutators: setters
/**
* A mutator method for the Appointment class
* @param date The date of the appointment
*/
public void setDate(Date date){
this.date = date;
}
/**
* A mutator method for the Appointment class
* @param mother The mother object who the appointment will be assigned to
*/
public void setMother(Mother mother){
this.mother = mother;
}
/**
* A mutator method for the Appointment class
* @param month The month of the appointment
*/
public void setMonth(int month){
this.month = month;
}
/**
* A mutator method for the Appointment class
* @param id The id of the appointment
*/
public void setID(int id){
this.id = id;
}
/**
* A mutator method for the Appointment class
* @param purpose The purpose of the appointment
*/
public void setPurpose(String purpose){
this.purpose = purpose;
}
/**
* A mutator method for the Appointment class
* @param hospital The hospital of the appointment
*/
public void setHospital(String hospital){
this.hospital = hospital;
}
/**
* A mutator method for the Appointment class
* @param doctor The doctor the appointment is with
*/
public void setDoctor(String doctor){
this.doctor = doctor;
}
/**
* A mutator method for the Appointment class
* @param time The time of the appointment
*/
public void setTime(String time){
this.time = time;
}
}