Class Database
java.lang.Object
cz.cuni.kubinja.hospitalsystem.database.Database
Interface for communication with SQLite database from Hospital system request.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDoctor(DoctorData doctorData) Adds doctor into the database.addPatient(PatientData patientData) Adds patients into the database.voidcheckAndAddAppointment(AppointmentData appointmentData) Checks the provided appointment data and adds the new appointments into the database.voidDeletes all data from database.voiddeleteAppointment(int id) Deletes appointment from the database based on provided id.voiddeleteDoctor(int id) Deletes doctor from the database.voiddeletePatient(int id) Deletes patient from the database.Returns list of all doctors in the database.Returns all patients in the database.getAppointment(int id) Returns the appointment based on provided id.getAppointmentsForDoctor(int id) Returns list of appointments for doctor with provided id.getAppointmentsForDoctor(Connection connection, int id) Returns list of appointments for doctor with provided id.getAppointmentsForPatient(int id) Returns list of appointments for patient with provided id.getAppointmentsForPatient(Connection connection, int id) Returns list of appointments for patient with provided id.Returns calendar object representing all appointments in the database.getDoctor(int id) Returns Doctor with corresponding id.getDoctor(Connection connection, int id) Returns Doctor with corresponding id.getPatient(int id) Returns patient based on provided id.getPatient(Connection connection, int id) Returns patient based on provided id.Returns list of people with provided first name and last name.voidupdateAppointment(Appointment appointment) Updates information about existing appointment.voidupdateDoctor(Doctor doctor) Updates doctor information inside the database.voidupdatePatient(Patient patient) Updates patient data inside the database.
-
Constructor Details
-
Database
Connects to the databased located on provided url and check whether the database has correct structure. If not then creates missing tables.- Parameters:
url- Location of the database.- Throws:
DatabaseException- Errors connected to the unability to open/create database.
-
-
Method Details
-
getPerson
public List<Person> getPerson(String fistName, String lastName, String expectedType) throws DatabaseException Returns list of people with provided first name and last name.- Parameters:
fistName- First name of the person.lastName- Last name of the person.expectedType- Kind of the person which will help filter out invalid combinations.- Returns:
- List of people with provided first name and last name.
- Throws:
DatabaseException- Error connected with the failure of retrieving people from database.
-
addPatient
Adds patients into the database.- Parameters:
patientData- Patients data which will be used for entry creation.- Returns:
- Patient object matching with the patient that was stored in database.
- Throws:
DatabaseException- Errors connected with the unability of storing new patient.
-
updatePatient
Updates patient data inside the database.- Parameters:
patient- Patient that will be updated.- Throws:
DatabaseException- Errors connected with the inability of update patient's data.
-
deletePatient
Deletes patient from the database.- Parameters:
id- Identification number of patient.- Throws:
DatabaseException- Error connected with the inability of deleting patient from database. Such as ID does not exist or connection errors.
-
getPatient
Returns patient based on provided id.- Parameters:
id- Id of the patient we want to retrieve from database.- Returns:
- patient based on provided id.
- Throws:
DatabaseException- Error connected with the unability to successfully retrieve patients data from database.
-
getPatient
Returns patient based on provided id.- Parameters:
connection- Connection to the database.id- Id of the patient we want to retrieve from database.- Returns:
- patient based on provided id.
- Throws:
DatabaseException- Error connected with the unability to successfully retrieve patients data from database.
-
getAllPatients
Returns all patients in the database.- Returns:
- list of all patients in the database.
- Throws:
DatabaseException- Error connected to the failure of retrieving all patients from the database.
-
addDoctor
Adds doctor into the database.- Parameters:
doctorData- Doctor data that will be stored in the database.- Returns:
- Doctor matching with the doctor entry stored in database.
- Throws:
DatabaseException- Error connected to the failure of storing new doctor in database.
-
updateDoctor
Updates doctor information inside the database.- Parameters:
doctor- Doctor that will be updated.- Throws:
DatabaseException- Errors connected with the failure of updating doctor's data. Such as doctor was not present inside the database or connection errors.
-
deleteDoctor
Deletes doctor from the database.- Parameters:
id- Identification number of the doctor.- Throws:
DatabaseException- Error connected with the failure of deleting doctor from database. Such as doctor was not present inside the database or connection errors.
-
getAllDoctors
Returns list of all doctors in the database.- Returns:
- List of all doctors in the database.
- Throws:
DatabaseException- Error connected with the failure of retrieving all doctors from the database - connection errors.
-
getDoctor
Returns Doctor with corresponding id.- Parameters:
id- Id of the doctor.- Returns:
- Doctor with corresponding id.
- Throws:
DatabaseException- Error connected with failure of retrieving doctor from database.
-
getDoctor
Returns Doctor with corresponding id.- Parameters:
connection- Connection to the database.id- Id of the doctor.- Returns:
- Doctor with corresponding id.
- Throws:
DatabaseException- Error connected with failure of retrieving doctor from database.
-
checkAndAddAppointment
public void checkAndAddAppointment(AppointmentData appointmentData) throws DatabaseException, CalendarException Checks the provided appointment data and adds the new appointments into the database.- Parameters:
appointmentData- Information about the appointment.- Throws:
DatabaseException- Error connected to the failure of storing appointment into the database.CalendarException- Error connected to the invalid time intervals of appointment.
-
getAppointment
Returns the appointment based on provided id.- Parameters:
id- Identification number of the appointment.- Returns:
- Appointment based on provided id.
- Throws:
DatabaseException- Error connected to the failure of retrieving appointment from the database. No such appointment with id is present in the database or connection errors.
-
deleteAppointment
Deletes appointment from the database based on provided id.- Parameters:
id- Identification number of the appointment.- Throws:
DatabaseException- Error connected to the failure of deleting appointment from the database. No such appointment with id is present in the database or connection errors.
-
updateAppointment
Updates information about existing appointment.- Parameters:
appointment- Appointment data that will be used for updating.- Throws:
DatabaseException- Failure of updating data inside database. Invalid identifiers or connection errors.
-
getAppointmentsForPatient
Returns list of appointments for patient with provided id.- Parameters:
id- Identification number of the patient.- Returns:
- List of appointments for patient.
- Throws:
DatabaseException- Error connected with the connection to the database.
-
getAppointmentsForPatient
public List<Appointment> getAppointmentsForPatient(Connection connection, int id) throws DatabaseException Returns list of appointments for patient with provided id.- Parameters:
connection- Connection to the database.id- Identification number of the patient.- Returns:
- List of appointments for patient.
- Throws:
DatabaseException- Error connected with the connection to the database.
-
getAppointmentsForDoctor
Returns list of appointments for doctor with provided id.- Parameters:
id- Identification number of the doctor.- Returns:
- List of appointments for doctor with provided id.
- Throws:
DatabaseException- Error connected with the connection to the database.
-
getAppointmentsForDoctor
public List<Appointment> getAppointmentsForDoctor(Connection connection, int id) throws DatabaseException Returns list of appointments for doctor with provided id.- Parameters:
connection- Connection to the database.id- Identification number of the doctor.- Returns:
- List of appointments for doctor with provided id.
- Throws:
DatabaseException- Error connected with the connection to the database.
-
getCalendar
Returns calendar object representing all appointments in the database.- Returns:
- Calendar object representing all appointments.
- Throws:
DatabaseException- Error connected to the failure of retrieving data from database or connection errors.
-
deleteAllData
Deletes all data from database.Created for the purpose of unit tests to ensure same starting point for all tests.
- Throws:
DatabaseException- Error connected to the failure of deletion of data from database.
-