Class Hospital

java.lang.Object
cz.cuni.kubinja.hospitalsystem.Hospital

public class Hospital extends Object
Hospital system for managing patients, doctors and appointments.
  • Constructor Details

    • Hospital

      public Hospital(String databasePath) throws DatabaseException
      Creates Hospital which content is based on the data in provided database.
      Parameters:
      databasePath - Path to the database.
      Throws:
      DatabaseException - Errors connected to the unability to open/create database.
  • Method Details

    • addPatient

      public DataPacket<Patient> addPatient(PatientData patientData)
      Adds new patient into hospital system.
      Parameters:
      patientData - Patients data which describes new patient.
      Returns:
      Data packet providing caller with information about successfulness of the query. And also contains object of the patient with provided ID.
    • getPatient

      public DataPacket<Patient> getPatient(int id)
      Returns info about patient with provided id.
      Parameters:
      id - Id that identifies patient.
      Returns:
      Data packet providing caller with information about successfulness of the query. And also contains object of the patient with provided ID.
    • getAllPatientWithName

      public DataPacket<List<Patient>> getAllPatientWithName(String firstName, String lastName)
      Returns list of patients with the provided first name and last name.
      Parameters:
      firstName - First name of the patient.
      lastName - Last name of the patient.
      Returns:
      List of patients with the provided first and last name.
    • updatePatient

      public GeneralPacket updatePatient(Patient patient)
      Updates information about patient with provided id and based on provided new data.
      Parameters:
      patient - State to which will be patient changed.
      Returns:
      General packet which provide caller with information about successfulness of the update.
    • deletePatient

      public GeneralPacket deletePatient(int id)
      Deletes patient with provided id.
      Parameters:
      id - Identifier of the patient that will be removed from the system.
      Returns:
      General packet which provide caller with information about successfulness of delete.
    • allPatients

      public DataPacket<List<Patient>> allPatients()
      Returns list of information about every patient in the system.
      Returns:
      Data packet that provide caller with information about successfulness of the query and provides array of data strings about every patient.
    • addDoctor

      public DataPacket<Doctor> addDoctor(DoctorData doctorData)
      Adds new doctor into the system.
      Parameters:
      doctorData - Doctor data that describes the new doctor.
      Returns:
      Data packet that provide caller with information about successfulness of the addition of doctor into the system. And also provides doctor object representing the same doctor.
    • getDoctor

      public DataPacket<Doctor> getDoctor(int id)
      Returns object representing doctor with provided id.
      Parameters:
      id - Identification number of the required doctor.
      Returns:
      Data packet that provide caller with information about successfulness of the query of doctor. And also provides doctor object.
    • getAllDoctorsWithName

      public DataPacket<List<Doctor>> getAllDoctorsWithName(String firstName, String lastName)
      Returns list of doctors with provided first name and last name.
      Parameters:
      firstName - First name of the doctor.
      lastName - Last name of the doctor.
      Returns:
      List of doctors with provided first name and last name.
    • updateDoctor

      public GeneralPacket updateDoctor(Doctor doctor)
      Updates information about doctor with provided id and based on provided new data.
      Parameters:
      doctor - State to which will be doctor changed.
      Returns:
      General packet which provide caller with information about successfulness of the update.
    • deleteDoctor

      public GeneralPacket deleteDoctor(int id)
      Deletes doctor with provided id.
      Parameters:
      id - Identifier of the doctor that will be removed from the system.
      Returns:
      General packet which provide caller with information about successfulness of delete.
    • allDoctors

      public DataPacket<List<Doctor>> allDoctors()
      Returns list of information about every doctor in the system.
      Returns:
      Data packet that provide caller with information about successfulness of the query and provides array of data strings about every doctor.
    • addAppointment

      public GeneralPacket addAppointment(AppointmentData appointmentData)
      Adds new appointment into the system.
      Parameters:
      appointmentData - Calendar Entry data that describes the new appointment.
      Returns:
      General packet that provide caller with the information whether the addition of the appointment into the system was successful.
    • getAppointment

      public DataPacket<Appointment> getAppointment(int id)
      Returns appointment with the provided id.
      Parameters:
      id - Identifier of the appointment.
      Returns:
      General packet which provides caller with the information about successfulness of the query. And provides the object of the appointment.
    • updateAppointment

      public GeneralPacket updateAppointment(Appointment appointment)
      Updates information about appointment with provided id and based on provided new data.
      Parameters:
      appointment - State to which will be appointment changed.
      Returns:
      General packet which provide caller with information about successfulness of the update.
    • deleteAppointment

      public GeneralPacket deleteAppointment(int id)
      Deletes appointment with provided id.
      Parameters:
      id - Identifier of the appointment that will be removed from the system.
      Returns:
      General packet which provide caller with information about successfulness of delete.
    • getAppointmentsForPersonnel

      public DataPacket<List<String>> getAppointmentsForPersonnel(int id, PersonKinds kind)
      Returns list of all appointments connected to the person with provided id and kind.
      Parameters:
      id - Identification number of the person.
      kind - Kind of person.
      Returns:
      List of all appointment connected to the person with provided id and kind.
    • getCalendarForDepartment

      public DataPacket<String> getCalendarForDepartment(String department, boolean fromToday)
      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.
    • getCalendarRepresentation

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

      public DataPacket<Calendar> getCalendar()
      Returns calendar for the hospital.
      Returns:
      Calendar for the hospital.
    • exportPatients

      public GeneralPacket exportPatients()
      Exports patients into file in CSV format
      Returns:
      General packet providing caller with the information about successfulness of the export.
    • exportDoctors

      public GeneralPacket exportDoctors()
      Exports doctors into file in CSV format.
      Returns:
      General packet providing caller with the information about successfulness of the export.
    • exportAppointments

      public GeneralPacket exportAppointments()
      Exports appointments into file in CSV format.
      Returns:
      General packet providing caller with the information about successfulness of the export.
    • export

      public GeneralPacket export()
      Exports all hospital system into CSV files (patients, doctors, appointments - one file for each)
      Returns:
      General packet providing caller with the information about successfulness of the export.
    • delete

      public GeneralPacket delete()
      Deletes all data from hospital system.

      For the purpose of the unit testing to ensure same database for tests.

      Returns:
      General packet providing caller with the information about successfulness of the cleanup.