Class Appointment

java.lang.Object
com.ehealthsystem.appointment.Appointment

public class Appointment extends Object
Represents an appointment with all the attributes.
  • Field Details

    • tableName

      public final String tableName
      See Also:
    • id

      private int id
    • doctor

      private int doctor
    • minutesBeforeReminder

      private int minutesBeforeReminder
    • duration

      private int duration
    • user

      private String user
    • healthProblemDescription

      private String healthProblemDescription
    • date

      private LocalDate date
    • time

      private LocalTime time
  • Constructor Details

    • Appointment

      public Appointment(boolean insertIntoDb, int id, String user, int doctor, String healthProblemDescription, LocalDate date, LocalTime time, int minutesBeforeReminder, int duration) throws SQLException, javax.activation.UnsupportedDataTypeException
      Parameters:
      insertIntoDb - true if this is a new appointment that is inserted to the database, false if the object shall solely represent an appointment that is already saved in the database
      id - ignored when insertToDb is true (to be precise, it is saved but overwritten after successful insert)
      Throws:
      SQLException
      javax.activation.UnsupportedDataTypeException
  • Method Details

    • insertIntoDb

      private void insertIntoDb() throws SQLException, javax.activation.UnsupportedDataTypeException
      Inserts this appointment into the database. Only to be used if a new appointment is created.
      Throws:
      SQLException
      javax.activation.UnsupportedDataTypeException
    • getId

      public int getId()
      Get the appointment id returned
      Returns:
      return id as integer
    • getDoctor

      public Doctor getDoctor() throws SQLException
      return the doctor selected for the appointment
      Returns:
      return doctor as object of the class Doctor
      Throws:
      SQLException - if the sql query wouldn't find a doctor in the database it throws an exception
    • getDate

      public LocalDate getDate()
      get the set date of the appointment
      Returns:
      return the date as an object of the type LocalDate
    • getTime

      public LocalTime getTime()
      get the set time of the appointment
      Returns:
      return the time as an object of the type LocalTime
    • getDateTime

      public LocalDateTime getDateTime()
      get the set date and time of the appointment
      Returns:
      return the date and time as an object of the type LocalDateTime
    • isInThePast

      public boolean isInThePast()
      get the appointment lies in the past. Used for the sorting in upcoming and past appointments
      Returns:
      return true or false depending on the date
    • getMinutesBeforeReminder

      public int getMinutesBeforeReminder()
      get the time of the reminder set in minutes
      Returns:
      return time as int
    • getDuration

      public int getDuration()
      For future use: Get the appointment's duration
      Returns:
      the duration of the appointment in minutes
    • getUser

      public String getUser()
      get the username of the that made the appointment
      Returns:
      return the username as a string
    • getHealthProblemDescription

      public String getHealthProblemDescription()
      get the health problem description that was set
      Returns:
      return the description as a String
    • update

      private void update(Object[][] newValues) throws SQLException, javax.activation.UnsupportedDataTypeException
      Updates the entry for this appointment in the database
      Parameters:
      newValues -
      Throws:
      SQLException
      javax.activation.UnsupportedDataTypeException
    • delete

      public boolean delete() throws SQLException
      Deletes an appointment from the database. Use to cancel an appointment.
      Returns:
      whether deletion succeeded
      Throws:
      SQLException
    • setDate

      public void setDate(LocalDate date) throws SQLException, javax.activation.UnsupportedDataTypeException
      Set the date appointment when shifting it.
      Parameters:
      date - the new selected date
      Throws:
      SQLException - if the datebase class throws a exception
      javax.activation.UnsupportedDataTypeException
    • setTime

      public void setTime(LocalTime time) throws SQLException, javax.activation.UnsupportedDataTypeException
      Set the time appointment when shifting it.
      Parameters:
      time - the new selected time
      Throws:
      SQLException - if the datebase class throws a exception
      javax.activation.UnsupportedDataTypeException