#32: Cleanup Useless Line
All checks were successful
Quality Check / Qualty Check (push) Successful in 9s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-05-05 11:59:15 +02:00
parent c71d3e128b
commit c01960cfd9
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
6 changed files with 216 additions and 318 deletions

View file

@ -1,7 +1,9 @@
package de.hitec.nhplus.datastorage; package de.hitec.nhplus.datastorage;
import java.sql.*; import java.sql.Connection;
import java.util.ArrayList; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List; import java.util.List;
public abstract class DaoImp<T> implements Dao<T> { public abstract class DaoImp<T> implements Dao<T> {
@ -45,13 +47,13 @@ public abstract class DaoImp<T> implements Dao<T> {
protected abstract List<T> getListFromResultSet(ResultSet result) throws SQLException; protected abstract List<T> getListFromResultSet(ResultSet result) throws SQLException;
protected abstract PreparedStatement getCreateStatement(T t); protected abstract PreparedStatement getCreateStatement(T t) throws SQLException;
protected abstract PreparedStatement getReadByIDStatement(int id); protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException;
protected abstract PreparedStatement getReadAllStatement(); protected abstract PreparedStatement getReadAllStatement() throws SQLException;
protected abstract PreparedStatement getUpdateStatement(T t); protected abstract PreparedStatement getUpdateStatement(T t) throws SQLException;
protected abstract PreparedStatement getDeleteStatement(int id); protected abstract PreparedStatement getDeleteStatement(int id) throws SQLException;
} }

View file

@ -1,9 +1,9 @@
package de.hitec.nhplus.fixtures; package de.hitec.nhplus.fixtures;
import de.hitec.nhplus.datastorage.DaoFactory; import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.treatment.TreatmentDao;
import de.hitec.nhplus.patient.Patient; import de.hitec.nhplus.patient.Patient;
import de.hitec.nhplus.treatment.Treatment; import de.hitec.nhplus.treatment.Treatment;
import de.hitec.nhplus.treatment.TreatmentDao;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
@ -16,30 +16,24 @@ import java.util.Map;
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate; import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime; import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
public class TreatmentFixture implements Fixture<Treatment> public class TreatmentFixture implements Fixture<Treatment> {
{
private final Map<String, Patient> patientsByName; private final Map<String, Patient> patientsByName;
public TreatmentFixture(Map<String, Patient> patientsByName) public TreatmentFixture(Map<String, Patient> patientsByName) {
{
this.patientsByName = patientsByName; this.patientsByName = patientsByName;
} }
@Override @Override
public void dropTable(Connection connection) public void dropTable(Connection connection) {
{ try (Statement statement = connection.createStatement()) {
try (Statement statement = connection.createStatement())
{
statement.execute("DROP TABLE treatment"); statement.execute("DROP TABLE treatment");
} catch (SQLException exception) } catch (SQLException exception) {
{
System.out.println(exception.getMessage()); System.out.println(exception.getMessage());
} }
} }
@Override @Override
public void setupTable(Connection connection) public void setupTable(Connection connection) {
{
final String SQL = "CREATE TABLE IF NOT EXISTS treatment (" + final String SQL = "CREATE TABLE IF NOT EXISTS treatment (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT, " + " id INTEGER PRIMARY KEY AUTOINCREMENT, " +
" patientId INTEGER NOT NULL, " + " patientId INTEGER NOT NULL, " +
@ -51,18 +45,15 @@ public class TreatmentFixture implements Fixture<Treatment>
" FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE " + " FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE " +
");"; ");";
try (Statement statement = connection.createStatement()) try (Statement statement = connection.createStatement()) {
{
statement.execute(SQL); statement.execute(SQL);
} catch (SQLException exception) } catch (SQLException exception) {
{
System.out.println(exception.getMessage()); System.out.println(exception.getMessage());
} }
} }
@Override @Override
public Map<String, Treatment> load() throws SQLException public Map<String, Treatment> load() throws SQLException {
{
List<Treatment> treatments = new ArrayList<>(); List<Treatment> treatments = new ArrayList<>();
Patient seppl = patientsByName.get("Seppl"); Patient seppl = patientsByName.get("Seppl");
@ -73,7 +64,7 @@ public class TreatmentFixture implements Fixture<Treatment>
treatments.add(new Treatment( treatments.add(new Treatment(
1, 1,
seppl.getId(), seppl,
convertStringToLocalDate("2023-06-03"), convertStringToLocalDate("2023-06-03"),
convertStringToLocalTime("11:00"), convertStringToLocalTime("11:00"),
convertStringToLocalTime("15:00"), convertStringToLocalTime("15:00"),
@ -84,7 +75,7 @@ public class TreatmentFixture implements Fixture<Treatment>
)); ));
treatments.add(new Treatment( treatments.add(new Treatment(
2, 2,
seppl.getId(), seppl,
convertStringToLocalDate("2023-06-05"), convertStringToLocalDate("2023-06-05"),
convertStringToLocalTime("11:00"), convertStringToLocalTime("11:00"),
convertStringToLocalTime("12:30"), convertStringToLocalTime("12:30"),
@ -95,7 +86,7 @@ public class TreatmentFixture implements Fixture<Treatment>
)); ));
treatments.add(new Treatment( treatments.add(new Treatment(
3, 3,
martina.getId(), martina,
convertStringToLocalDate("2023-06-04"), convertStringToLocalDate("2023-06-04"),
convertStringToLocalTime("07:30"), convertStringToLocalTime("07:30"),
convertStringToLocalTime("08:00"), convertStringToLocalTime("08:00"),
@ -104,7 +95,7 @@ public class TreatmentFixture implements Fixture<Treatment>
)); ));
treatments.add(new Treatment( treatments.add(new Treatment(
4, 4,
seppl.getId(), seppl,
convertStringToLocalDate("2023-06-06"), convertStringToLocalDate("2023-06-06"),
convertStringToLocalTime("15:10"), convertStringToLocalTime("15:10"),
convertStringToLocalTime("16:00"), convertStringToLocalTime("16:00"),
@ -113,7 +104,7 @@ public class TreatmentFixture implements Fixture<Treatment>
); );
treatments.add(new Treatment( treatments.add(new Treatment(
8, 8,
seppl.getId(), seppl,
convertStringToLocalDate("2023-06-08"), convertStringToLocalDate("2023-06-08"),
convertStringToLocalTime("15:00"), convertStringToLocalTime("15:00"),
convertStringToLocalTime("16:00"), convertStringToLocalTime("16:00"),
@ -122,7 +113,7 @@ public class TreatmentFixture implements Fixture<Treatment>
); );
treatments.add(new Treatment( treatments.add(new Treatment(
9, 9,
martina.getId(), martina,
convertStringToLocalDate("2023-06-07"), convertStringToLocalDate("2023-06-07"),
convertStringToLocalTime("11:00"), convertStringToLocalTime("11:00"),
convertStringToLocalTime("11:30"), convertStringToLocalTime("11:30"),
@ -131,7 +122,7 @@ public class TreatmentFixture implements Fixture<Treatment>
); );
treatments.add(new Treatment( treatments.add(new Treatment(
12, 12,
hans.getId(), hans,
convertStringToLocalDate("2023-06-08"), convertStringToLocalDate("2023-06-08"),
convertStringToLocalTime("15:00"), convertStringToLocalTime("15:00"),
convertStringToLocalTime("15:30"), convertStringToLocalTime("15:30"),
@ -140,7 +131,7 @@ public class TreatmentFixture implements Fixture<Treatment>
); );
treatments.add(new Treatment( treatments.add(new Treatment(
14, 14,
ahmet.getId(), ahmet,
convertStringToLocalDate("2023-08-24"), convertStringToLocalDate("2023-08-24"),
convertStringToLocalTime("09:30"), convertStringToLocalTime("09:30"),
convertStringToLocalTime("10:15"), convertStringToLocalTime("10:15"),
@ -148,7 +139,7 @@ public class TreatmentFixture implements Fixture<Treatment>
"Lympfdrainage")); "Lympfdrainage"));
treatments.add(new Treatment( treatments.add(new Treatment(
16, 16,
elisabeth.getId(), elisabeth,
convertStringToLocalDate("2023-08-31"), convertStringToLocalDate("2023-08-31"),
convertStringToLocalTime("13:30"), convertStringToLocalTime("13:30"),
convertStringToLocalTime("13:45"), convertStringToLocalTime("13:45"),
@ -157,7 +148,7 @@ public class TreatmentFixture implements Fixture<Treatment>
); );
treatments.add(new Treatment( treatments.add(new Treatment(
17, 17,
elisabeth.getId(), elisabeth,
convertStringToLocalDate("2023-09-01"), convertStringToLocalDate("2023-09-01"),
convertStringToLocalTime("16:00"), convertStringToLocalTime("16:00"),
convertStringToLocalTime("17:00"), convertStringToLocalTime("17:00"),

View file

@ -15,31 +15,21 @@ public class NurseDao extends DaoImp<Nurse> {
} }
@Override @Override
protected PreparedStatement getCreateStatement(Nurse nurse) { protected PreparedStatement getCreateStatement(Nurse nurse) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "INSERT INTO nurse (firstname, surname, phoneNumber)" + final String SQL = "INSERT INTO nurse (firstname, surname, phoneNumber)" +
"VALUES (?, ?, ?)"; "VALUES (?, ?, ?)";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setString(1, nurse.getFirstName()); preparedStatement.setString(1, nurse.getFirstName());
preparedStatement.setString(2, nurse.getSurname()); preparedStatement.setString(2, nurse.getSurname());
preparedStatement.setString(3, nurse.getPhoneNumber()); preparedStatement.setString(3, nurse.getPhoneNumber());
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@Override @Override
protected PreparedStatement getReadByIDStatement(int id) { protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "SELECT * FROM nurse WHERE id = ?"; final String SQL = "SELECT * FROM nurse WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, id); preparedStatement.setInt(1, id);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@ -54,63 +44,42 @@ public class NurseDao extends DaoImp<Nurse> {
} }
@Override @Override
protected PreparedStatement getReadAllStatement() { protected PreparedStatement getReadAllStatement() throws SQLException {
PreparedStatement statement = null;
try {
final String SQL = "SELECT * FROM nurse"; final String SQL = "SELECT * FROM nurse";
statement = this.connection.prepareStatement(SQL); return this.connection.prepareStatement(SQL);
} catch (SQLException exception) {
exception.printStackTrace();
}
return statement;
} }
@Override @Override
protected List<Nurse> getListFromResultSet(ResultSet result) throws SQLException { protected List<Nurse> getListFromResultSet(ResultSet result) throws SQLException {
ArrayList<Nurse> list = new ArrayList<>(); ArrayList<Nurse> list = new ArrayList<>();
while (result.next()) { while (result.next()) {
list.add(new Nurse( list.add(getInstanceFromResultSet(result));
result.getInt(1),
result.getString(2),
result.getString(3),
result.getString(4)
));
} }
return list; return list;
} }
@Override @Override
protected PreparedStatement getUpdateStatement(Nurse nurse) { protected PreparedStatement getUpdateStatement(Nurse nurse) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = final String SQL =
"UPDATE nurse SET " + "UPDATE nurse SET " +
"firstname = ?, " + "firstname = ?, " +
"surname = ?, " + "surname = ?, " +
"phoneNumber = ?, " + "phoneNumber = ? " +
"WHERE id = ?"; "WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setString(1, nurse.getFirstName()); preparedStatement.setString(1, nurse.getFirstName());
preparedStatement.setString(2, nurse.getSurname()); preparedStatement.setString(2, nurse.getSurname());
preparedStatement.setString(3, nurse.getPhoneNumber()); preparedStatement.setString(3, nurse.getPhoneNumber());
preparedStatement.setInt(4, nurse.getId()); preparedStatement.setInt(4, nurse.getId());
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@Override @Override
protected PreparedStatement getDeleteStatement(int id) { protected PreparedStatement getDeleteStatement(int id) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "DELETE FROM nurse WHERE id = ?"; final String SQL = "DELETE FROM nurse WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, id); preparedStatement.setInt(1, id);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
} }

View file

@ -17,33 +17,23 @@ public class PatientDao extends DaoImp<Patient> {
} }
@Override @Override
protected PreparedStatement getCreateStatement(Patient patient) { protected PreparedStatement getCreateStatement(Patient patient) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber) " + final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber) " +
"VALUES (?, ?, ?, ?, ?)"; "VALUES (?, ?, ?, ?, ?)";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setString(1, patient.getFirstName()); preparedStatement.setString(1, patient.getFirstName());
preparedStatement.setString(2, patient.getSurname()); preparedStatement.setString(2, patient.getSurname());
preparedStatement.setString(3, patient.getDateOfBirth()); preparedStatement.setString(3, patient.getDateOfBirth());
preparedStatement.setString(4, patient.getCareLevel()); preparedStatement.setString(4, patient.getCareLevel());
preparedStatement.setString(5, patient.getRoomNumber()); preparedStatement.setString(5, patient.getRoomNumber());
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@Override @Override
protected PreparedStatement getReadByIDStatement(int id) { protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "SELECT * FROM patient WHERE id = ?"; final String SQL = "SELECT * FROM patient WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, id); preparedStatement.setInt(1, id);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@ -59,37 +49,22 @@ public class PatientDao extends DaoImp<Patient> {
} }
@Override @Override
protected PreparedStatement getReadAllStatement() { protected PreparedStatement getReadAllStatement() throws SQLException {
PreparedStatement statement = null;
try {
final String SQL = "SELECT * FROM patient"; final String SQL = "SELECT * FROM patient";
statement = this.connection.prepareStatement(SQL); return this.connection.prepareStatement(SQL);
} catch (SQLException exception) {
exception.printStackTrace();
}
return statement;
} }
@Override @Override
protected List<Patient> getListFromResultSet(ResultSet result) throws SQLException { protected List<Patient> getListFromResultSet(ResultSet result) throws SQLException {
ArrayList<Patient> list = new ArrayList<>(); ArrayList<Patient> list = new ArrayList<>();
while (result.next()) { while (result.next()) {
Patient patient = new Patient( list.add(getInstanceFromResultSet(result));
result.getInt(1),
result.getString(2),
result.getString(3),
DateConverter.convertStringToLocalDate(result.getString(4)),
result.getString(5),
result.getString(6));
list.add(patient);
} }
return list; return list;
} }
@Override @Override
protected PreparedStatement getUpdateStatement(Patient patient) { protected PreparedStatement getUpdateStatement(Patient patient) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = final String SQL =
"UPDATE patient SET " + "UPDATE patient SET " +
"firstname = ?, " + "firstname = ?, " +
@ -98,29 +73,21 @@ public class PatientDao extends DaoImp<Patient> {
"carelevel = ?, " + "carelevel = ?, " +
"roomnumber = ?, " + "roomnumber = ?, " +
"WHERE id = ?"; "WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setString(1, patient.getFirstName()); preparedStatement.setString(1, patient.getFirstName());
preparedStatement.setString(2, patient.getSurname()); preparedStatement.setString(2, patient.getSurname());
preparedStatement.setString(3, patient.getDateOfBirth()); preparedStatement.setString(3, patient.getDateOfBirth());
preparedStatement.setString(4, patient.getCareLevel()); preparedStatement.setString(4, patient.getCareLevel());
preparedStatement.setString(5, patient.getRoomNumber()); preparedStatement.setString(5, patient.getRoomNumber());
preparedStatement.setInt(6, patient.getId()); preparedStatement.setInt(6, patient.getId());
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@Override @Override
protected PreparedStatement getDeleteStatement(int id) { protected PreparedStatement getDeleteStatement(int id) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "DELETE FROM patient WHERE id = ?"; final String SQL = "DELETE FROM patient WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, id); preparedStatement.setInt(1, id);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
} }

View file

@ -18,34 +18,24 @@ public class TreatmentDao extends DaoImp<Treatment> {
} }
@Override @Override
protected PreparedStatement getCreateStatement(Treatment treatment) { protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "INSERT INTO treatment (patientId, treatment_date, begin, end, description, remark) " + final String SQL = "INSERT INTO treatment (patientId, treatment_date, begin, end, description, remark) " +
"VALUES (?, ?, ?, ?, ?, ?)"; "VALUES (?, ?, ?, ?, ?, ?)";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, treatment.getPatient().getId()); preparedStatement.setInt(1, treatment.getPatient().getId());
preparedStatement.setString(2, treatment.getDate()); preparedStatement.setString(2, treatment.getDate());
preparedStatement.setString(3, treatment.getBegin()); preparedStatement.setString(3, treatment.getBegin());
preparedStatement.setString(4, treatment.getEnd()); preparedStatement.setString(4, treatment.getEnd());
preparedStatement.setString(5, treatment.getDescription()); preparedStatement.setString(5, treatment.getDescription());
preparedStatement.setString(6, treatment.getRemarks()); preparedStatement.setString(6, treatment.getRemarks());
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@Override @Override
protected PreparedStatement getReadByIDStatement(int id) { protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "SELECT * FROM treatment WHERE id = ?"; final String SQL = "SELECT * FROM treatment WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, id); preparedStatement.setInt(1, id);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@ -63,15 +53,9 @@ public class TreatmentDao extends DaoImp<Treatment> {
} }
@Override @Override
protected PreparedStatement getReadAllStatement() { protected PreparedStatement getReadAllStatement() throws SQLException {
PreparedStatement statement = null;
try {
final String SQL = "SELECT * FROM treatment"; final String SQL = "SELECT * FROM treatment";
statement = this.connection.prepareStatement(SQL); return this.connection.prepareStatement(SQL);
} catch (SQLException exception) {
exception.printStackTrace();
}
return statement;
} }
@Override @Override
@ -83,15 +67,10 @@ public class TreatmentDao extends DaoImp<Treatment> {
return list; return list;
} }
private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(int patientId) { private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(int patientId) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = "SELECT * FROM treatment WHERE patientId = ?"; final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, patientId); preparedStatement.setInt(1, patientId);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@ -101,9 +80,7 @@ public class TreatmentDao extends DaoImp<Treatment> {
} }
@Override @Override
protected PreparedStatement getUpdateStatement(Treatment treatment) { protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = final String SQL =
"UPDATE treatment SET " + "UPDATE treatment SET " +
"patientId = ?, " + "patientId = ?, " +
@ -113,7 +90,7 @@ public class TreatmentDao extends DaoImp<Treatment> {
"description = ?, " + "description = ?, " +
"remark = ? " + "remark = ? " +
"WHERE id = ?"; "WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, treatment.getPatient().getId()); preparedStatement.setInt(1, treatment.getPatient().getId());
preparedStatement.setString(2, treatment.getDate()); preparedStatement.setString(2, treatment.getDate());
preparedStatement.setString(3, treatment.getBegin()); preparedStatement.setString(3, treatment.getBegin());
@ -121,23 +98,15 @@ public class TreatmentDao extends DaoImp<Treatment> {
preparedStatement.setString(5, treatment.getDescription()); preparedStatement.setString(5, treatment.getDescription());
preparedStatement.setString(6, treatment.getRemarks()); preparedStatement.setString(6, treatment.getRemarks());
preparedStatement.setInt(7, treatment.getId()); preparedStatement.setInt(7, treatment.getId());
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
@Override @Override
protected PreparedStatement getDeleteStatement(int id) { protected PreparedStatement getDeleteStatement(int id) throws SQLException {
PreparedStatement preparedStatement = null;
try {
final String SQL = final String SQL =
"DELETE FROM treatment WHERE id = ?"; "DELETE FROM treatment WHERE id = ?";
preparedStatement = this.connection.prepareStatement(SQL); PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
preparedStatement.setInt(1, id); preparedStatement.setInt(1, id);
} catch (SQLException exception) {
exception.printStackTrace();
}
return preparedStatement; return preparedStatement;
} }
} }

View file

@ -44,7 +44,7 @@ public class TreatmentModalController {
isNewTreatment = true; isNewTreatment = true;
LocalTime currentTime = LocalTime.now(); LocalTime currentTime = LocalTime.now();
this.treatment = new Treatment( this.treatment = new Treatment(
patient.getId(), patient,
LocalDate.now(), LocalDate.now(),
LocalTime.of(currentTime.getHour(), currentTime.getMinute()), LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
LocalTime.of(currentTime.getHour(), currentTime.getMinute()), LocalTime.of(currentTime.getHour(), currentTime.getMinute()),