Package DatabaseItems
Class AppointmentSlot
java.lang.Object
DatabaseItems.AppointmentSlot
- All Implemented Interfaces:
DatabaseItems
The
AppointmentSlot
class represents a time slot for an appointment.
It includes details such as appointment ID, patient ID, doctor ID, date,
start time, end time, and the status of the appointment.-
Constructor Summary
ConstructorsConstructorDescriptionAppointmentSlot
(String... params) Constructs anAppointmentSlot
by deserializing from a set of parameters.AppointmentSlot
(String doctor_id, String date, String timestart, String timeend, AppointmentStatus status) Constructs anAppointmentSlot
with specified details when both patient ID and appointment ID are not provided.AppointmentSlot
(String patient_id, String doctor_id, String date, String timestart, String timeend, AppointmentStatus status) Constructs anAppointmentSlot
with specified details when only patient ID is provided.AppointmentSlot
(String appointment_id, String patient_id, String doctor_id, String date, String timestart, String timeend, AppointmentStatus status) Constructs anAppointmentSlot
with specified details when both patient ID and appointment ID are provided. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deserialise
(String... params) Deserializes appointment details from a string array.Returns the unique identifier for the appointment.getDate()
Returns the date of the appointment.Returns unique identifier for associated doctor.Returns the unique identifier for the patient associated with this slot.Returns current status of appointment.Returns end time of appointment.Returns the start time of the appointment.void
Prints the details of the appointment slot to standard output.Serializes the appointment slot into a comma-separated string.void
Sets a new date for this slot.void
setDoctorId
(String doctor_id) Sets a new doctor ID for this slot.void
setPatientId
(String patient_id) Sets a new patient ID for this slot.void
setStatus
(AppointmentStatus status) Sets a new status for this slot.void
setTimeend
(String timeend) Sets a new end time for this slot.void
setTimestart
(String timestart) Sets a new start time for this slot.static void
sortAppointments
(List<AppointmentSlot> appointments) Sorts a list of appointment slots by date and start time.
-
Constructor Details
-
AppointmentSlot
public AppointmentSlot(String doctor_id, String date, String timestart, String timeend, AppointmentStatus status) Constructs anAppointmentSlot
with specified details when both patient ID and appointment ID are not provided.- Parameters:
doctor_id
- the unique identifier for the doctordate
- the date of the appointmenttimestart
- the start time of the appointmenttimeend
- the end time of the appointmentstatus
- the status of the appointment
-
AppointmentSlot
public AppointmentSlot(String appointment_id, String patient_id, String doctor_id, String date, String timestart, String timeend, AppointmentStatus status) Constructs anAppointmentSlot
with specified details when both patient ID and appointment ID are provided.- Parameters:
appointment_id
- the unique identifier for the appointmentpatient_id
- the unique identifier for the patientdoctor_id
- the unique identifier for the doctordate
- the date of the appointmenttimestart
- the start time of the appointmenttimeend
- the end time of the appointmentstatus
- the status of the appointment
-
AppointmentSlot
public AppointmentSlot(String patient_id, String doctor_id, String date, String timestart, String timeend, AppointmentStatus status) Constructs anAppointmentSlot
with specified details when only patient ID is provided.- Parameters:
patient_id
- the unique identifier for the patientdoctor_id
- the unique identifier for the doctordate
- the date of the appointmenttimestart
- the start time of the appointmenttimeend
- the end time of the appointmentstatus
- the status of the appointment
-
AppointmentSlot
Constructs anAppointmentSlot
by deserializing from a set of parameters.- Parameters:
params
- an array of strings containing appointment details in order: appointment_id, patient_id, date, timestart, timeend, status
-
-
Method Details
-
deserialise
Deserializes appointment details from a string array.- Specified by:
deserialise
in interfaceDatabaseItems
- Parameters:
params
- an array of strings containing appointment details in order: appointment_id, patient_id, date, timestart, timeend, status
-
serialise
Serializes the appointment slot into a comma-separated string.- Specified by:
serialise
in interfaceDatabaseItems
- Returns:
- a string representation of the appointment slot
-
printItem
public void printItem()Prints the details of the appointment slot to standard output.- Specified by:
printItem
in interfaceDatabaseItems
-
sortAppointments
Sorts a list of appointment slots by date and start time.- Parameters:
appointments
- a list ofAppointmentSlot
objects to be sorted
-
getAppointmentId
Returns the unique identifier for the appointment.- Returns:
- the appointment ID
-
getPatientId
Returns the unique identifier for the patient associated with this slot.- Returns:
- the patient ID
-
getDate
Returns the date of the appointment.- Returns:
- the date of the appointment
-
getTimestart
Returns the start time of the appointment.- Returns:
- start time of appointment
-
getTimeend
Returns end time of appointment.- Returns:
- end time of appointment
-
getStatus
Returns current status of appointment.- Returns:
- current status
-
getDoctorId
Returns unique identifier for associated doctor.- Returns:
- doctor ID
-
setPatientId
Sets a new patient ID for this slot.- Parameters:
patient_id
- new patient ID
-
setDoctorId
Sets a new doctor ID for this slot.- Parameters:
doctor_id
- new doctor ID
-
setDate
Sets a new date for this slot.- Parameters:
date
- new date
-
setTimestart
Sets a new start time for this slot.- Parameters:
timestart
- new start time
-
setTimeend
Sets a new end time for this slot.- Parameters:
timeend
- new end time
-
setStatus
Sets a new status for this slot.- Parameters:
status
- new status
-