Class Calendar

java.lang.Object
cz.cuni.kubinja.hospitalsystem.calendar.Calendar

public class Calendar extends Object
Manager of appointments for hospital system.
  • Field Details

    • minimumLengthOfAppointment

      public static final int minimumLengthOfAppointment
      Minimum length of appointment
      See Also:
    • alignmentOfAppointment

      public static final int alignmentOfAppointment
      Requirement that all appointments have to start and end at *.30 or *.00 (so at half or whole hours)
      See Also:
    • minStartingTime

      public static final int minStartingTime
      First appointment can start after hour
      See Also:
    • maxEndingTime

      public static final int maxEndingTime
      Every appointment have to end before this hour
      See Also:
  • Constructor Details

    • Calendar

      public Calendar()
      Creates empty calendar.
  • Method Details

    • importData

      public void importData(ResultSet resultSet) throws SQLException
      Imports appointments from SQL resultSet.
      Parameters:
      resultSet - SQL result containing appointment entries.
      Throws:
      SQLException - Errors occurs while reading SQL results: invalid columns, reading failure.
    • timeIsValid

      public static boolean timeIsValid(LocalDateTime start, LocalDateTime end) throws CalendarException
      Decided whether the starting and ending time of appointment satisfy requirements such as: minimal length, opening hours, correct aligning etc.
      Parameters:
      start - Starting time.
      end - Ending time.
      Returns:
      Whether the interval satisfy requirements for being appointment.
      Throws:
      CalendarException - Errors occurs when time interval do not satisfy any of the requirements.
    • startAtHalves

      public static boolean startAtHalves(LocalDateTime time) throws CalendarException
      Checks whether the time is in the opening hours and if satisfy alignment (*:30, *:00).
      Parameters:
      time - Time we want to process.
      Returns:
      Whether the time satisfy requirements.
      Throws:
      CalendarException - Error occurs when time does not satisfy requirements.
    • isWithinValidDates

      public static boolean isWithinValidDates(LocalDate date)
      Checks whether the date is between 1990-01-01 and present.
      Parameters:
      date - Date that will be checked.
      Returns:
      Whether the date is between 1990-01-01 and present.
    • isAppointmentWithinValidDateTime

      public static boolean isAppointmentWithinValidDateTime(LocalDateTime dateTime)
      Checks whether the date is between 2000-01-01 00:00 and 3000-01-01 00:00
      Parameters:
      dateTime - Date and time that will be checked.
      Returns:
      Whether the date is between 2000-01-01 00:00 and 3000-01-01 00:00
    • getDepartmentCalendar

      public String getDepartmentCalendar(String department, boolean fromToday) throws CalendarException
      Returns string representing calendar for the provided department.
      Parameters:
      department - Name of department.
      fromToday - Denotes whether calendar will be exported whole or only appointments in the present and future.
      Returns:
      String representing calendar for the provided department.
      Throws:
      CalendarException - Department with the provided name does not exist.
    • getCalendar

      public List<String> getCalendar(boolean fromToday)
      Returns list of strings representing graphical version of calendar.
      Parameters:
      fromToday - Denotes whether calendar will be exported whole or only appointments in the present and future.
      Returns:
      List of strings representing graphical version of calendar.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • export

      public void export(File destination) throws IOException
      Exports calendar in CSV format into provided file.
      Parameters:
      destination - File where the data should be exported.
      Throws:
      IOException - Errors occurs when occurs problem with opening and writing into files.
    • size

      public int size()
      Returns number of appointments in the calendar.
      Returns:
      Number of appointments in the calendar.
    • numberOfAppearances

      public int numberOfAppearances(Person person)
      Returns how many appointments does the provided person had or will have in the future.
      Parameters:
      person - Person for which we want to know number of appointments.
      Returns:
      How many appointments does the provided person had or will have in the future.
    • haveTime

      public static boolean haveTime(List<Appointment> appointments, LocalDateTime start, LocalDateTime end)
      Decides whether the time interval [start, end] is in the conflict (have overlap) with some appointment.
      Parameters:
      appointments - List of appointments that we want to check.
      start - Start of the time interval.
      end - End of the time interval.
      Returns:
      Whether the time interval is not in the conflict with the appointments.
    • haveTime

      public static boolean haveTime(List<Appointment> appointments, LocalDateTime start, LocalDateTime end, Integer excludedId)
      Decides whether the time interval [start, end] is in the conflict (have overlap) with some appointment.
      Parameters:
      appointments - List of appointments that we want to check.
      start - Start of the time interval.
      end - End of the time interval.
      excludedId - Identification number of the appointment that will not be checked against the time intervals.
      Returns:
      Whether the time interval is not in the conflict with the appointments.