#7 Cleanup
This commit is contained in:
parent
3c1445f430
commit
9bd654d4e4
6 changed files with 105 additions and 108 deletions
Binary file not shown.
|
@ -58,7 +58,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
Nurse armin = nursesByName.get("Armin");
|
Nurse armin = nursesByName.get("Armin");
|
||||||
|
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
1,
|
|
||||||
seppl,
|
seppl,
|
||||||
ole,
|
ole,
|
||||||
convertStringToLocalDate("2023-06-03"),
|
convertStringToLocalDate("2023-06-03"),
|
||||||
|
@ -67,11 +66,9 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
"Gespräch",
|
"Gespräch",
|
||||||
"Der Patient hat enorme Angstgefühle und glaubt, er sei überfallen worden."
|
"Der Patient hat enorme Angstgefühle und glaubt, er sei überfallen worden."
|
||||||
+ "Ihm seien alle Wertsachen gestohlen worden."
|
+ "Ihm seien alle Wertsachen gestohlen worden."
|
||||||
+ "Patient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind.",
|
+ "Patient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind."
|
||||||
false
|
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
2,
|
|
||||||
seppl,
|
seppl,
|
||||||
armin,
|
armin,
|
||||||
convertStringToLocalDate("2023-06-05"),
|
convertStringToLocalDate("2023-06-05"),
|
||||||
|
@ -80,102 +77,92 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
"Gespräch",
|
"Gespräch",
|
||||||
"Patient irrt auf der Suche nach gestohlenen Wertsachen durch die Etage "
|
"Patient irrt auf der Suche nach gestohlenen Wertsachen durch die Etage "
|
||||||
+ "und bezichtigt andere Bewohner des Diebstahls."
|
+ "und bezichtigt andere Bewohner des Diebstahls."
|
||||||
+ "Patient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel.",
|
+ "Patient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel."
|
||||||
false
|
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
3,
|
|
||||||
martina,
|
martina,
|
||||||
ole,
|
ole,
|
||||||
convertStringToLocalDate("2023-06-04"),
|
convertStringToLocalDate("2023-06-04"),
|
||||||
convertStringToLocalTime("07:30"),
|
convertStringToLocalTime("07:30"),
|
||||||
convertStringToLocalTime("08:00"),
|
convertStringToLocalTime("08:00"),
|
||||||
"Waschen",
|
"Waschen",
|
||||||
"Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet.",
|
"Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet."
|
||||||
false
|
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
4,
|
|
||||||
seppl,
|
seppl,
|
||||||
armin,
|
armin,
|
||||||
convertStringToLocalDate("2023-06-06"),
|
convertStringToLocalDate("2023-06-06"),
|
||||||
convertStringToLocalTime("15:10"),
|
convertStringToLocalTime("15:10"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
"Spaziergang",
|
"Spaziergang",
|
||||||
"Spaziergang im Park, Patient döst im Rollstuhl ein",
|
"Spaziergang im Park, Patient döst im Rollstuhl ein"
|
||||||
false)
|
|
||||||
);
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
8,
|
|
||||||
seppl,
|
seppl,
|
||||||
ole,
|
ole,
|
||||||
convertStringToLocalDate("2023-06-08"),
|
convertStringToLocalDate("2023-06-08"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
"Spaziergang",
|
"Spaziergang",
|
||||||
"Parkspaziergang; Patient ist heute lebhafter und hat klare Momente; erzählt von seiner Tochter",
|
"Parkspaziergang; Patient ist heute lebhafter und hat klare Momente; erzählt von seiner Tochter"
|
||||||
false)
|
));
|
||||||
);
|
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
9,
|
|
||||||
martina,
|
martina,
|
||||||
armin,
|
armin,
|
||||||
convertStringToLocalDate("2023-06-07"),
|
convertStringToLocalDate("2023-06-07"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("11:30"),
|
convertStringToLocalTime("11:30"),
|
||||||
"Waschen",
|
"Waschen",
|
||||||
"Waschen per Dusche auf einem Stuhl; Patientin gewendet;",
|
"Waschen per Dusche auf einem Stuhl; Patientin gewendet;"
|
||||||
false)
|
));
|
||||||
);
|
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
12,
|
|
||||||
hans,
|
hans,
|
||||||
armin,
|
armin,
|
||||||
convertStringToLocalDate("2023-06-08"),
|
convertStringToLocalDate("2023-06-08"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
convertStringToLocalTime("15:30"),
|
convertStringToLocalTime("15:30"),
|
||||||
"Physiotherapie",
|
"Physiotherapie",
|
||||||
"Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur",
|
"Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur"
|
||||||
false)
|
));
|
||||||
);
|
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
14,
|
|
||||||
ahmet,
|
ahmet,
|
||||||
ole,
|
ole,
|
||||||
convertStringToLocalDate("2023-08-24"),
|
convertStringToLocalDate("2023-08-24"),
|
||||||
convertStringToLocalTime("09:30"),
|
convertStringToLocalTime("09:30"),
|
||||||
convertStringToLocalTime("10:15"),
|
convertStringToLocalTime("10:15"),
|
||||||
"KG",
|
"KG",
|
||||||
"Lympfdrainage",
|
"Lympfdrainage"
|
||||||
false));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
16,
|
|
||||||
elisabeth,
|
elisabeth,
|
||||||
armin,
|
armin,
|
||||||
convertStringToLocalDate("2023-08-31"),
|
convertStringToLocalDate("2023-08-31"),
|
||||||
convertStringToLocalTime("13:30"),
|
convertStringToLocalTime("13:30"),
|
||||||
convertStringToLocalTime("13:45"),
|
convertStringToLocalTime("13:45"),
|
||||||
"Toilettengang",
|
"Toilettengang",
|
||||||
"Hilfe beim Toilettengang; Patientin klagt über Schmerzen beim Stuhlgang. Gabe von Iberogast",
|
"Hilfe beim Toilettengang; Patientin klagt über Schmerzen beim Stuhlgang. Gabe von Iberogast"
|
||||||
false)
|
));
|
||||||
);
|
Treatment lockedTreatment = new Treatment(
|
||||||
treatments.add(new Treatment(
|
|
||||||
17,
|
|
||||||
elisabeth,
|
elisabeth,
|
||||||
ole,
|
ole,
|
||||||
convertStringToLocalDate("2023-09-01"),
|
convertStringToLocalDate("2023-09-01"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
convertStringToLocalTime("17:00"),
|
convertStringToLocalTime("17:00"),
|
||||||
"KG",
|
"KG",
|
||||||
"Massage der Extremitäten zur Verbesserung der Durchblutung",
|
"Massage der Extremitäten zur Verbesserung der Durchblutung"
|
||||||
true)
|
|
||||||
);
|
);
|
||||||
|
lockedTreatment.setLocked(true);
|
||||||
|
treatments.add(lockedTreatment);
|
||||||
|
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
Map<String, Treatment> treatmentsById = new HashMap<>();
|
Map<String, Treatment> treatmentsById = new HashMap<>();
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
dao.create(treatment);
|
dao.create(treatment);
|
||||||
|
}
|
||||||
|
for (Treatment treatment : dao.readAll()) {
|
||||||
treatmentsById.put(String.valueOf(treatment.getId()), treatment);
|
treatmentsById.put(String.valueOf(treatment.getId()), treatment);
|
||||||
|
|
||||||
}
|
}
|
||||||
return treatmentsById;
|
return treatmentsById;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class AllTreatmentController {
|
||||||
public void readAllAndShowInTableView() {
|
public void readAllAndShowInTableView() {
|
||||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
this.treatments.setAll(dao.readAll());
|
this.treatments.setAll(dao.readAllActive());
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.hitec.nhplus.treatment;
|
package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
import de.hitec.nhplus.utils.DateConverter;
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
|
@ -11,7 +10,6 @@ import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +30,7 @@ public class Treatment {
|
||||||
private final SimpleStringProperty description;
|
private final SimpleStringProperty description;
|
||||||
private final SimpleStringProperty remarks;
|
private final SimpleStringProperty remarks;
|
||||||
private final SimpleBooleanProperty locked;
|
private final SimpleBooleanProperty locked;
|
||||||
private final int sperrfrist = 10;
|
private final static int BLOCKED_YEARS = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor allows instantiating a {@link Treatment} object,
|
* This constructor allows instantiating a {@link Treatment} object,
|
||||||
|
@ -85,6 +83,13 @@ public class Treatment {
|
||||||
this.locked = new SimpleBooleanProperty(isLocked);
|
this.locked = new SimpleBooleanProperty(isLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates delete date of treatment.
|
||||||
|
*/
|
||||||
|
public LocalDate calculateDeleteDate() {
|
||||||
|
return DateConverter.convertStringToLocalDate(getDate()).plusYears(BLOCKED_YEARS);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLocked() {
|
public boolean isLocked() {
|
||||||
return locked.get();
|
return locked.get();
|
||||||
}
|
}
|
||||||
|
@ -188,13 +193,8 @@ public class Treatment {
|
||||||
.add("End: " + this.getEnd())
|
.add("End: " + this.getEnd())
|
||||||
.add("Description: " + this.getDescription())
|
.add("Description: " + this.getDescription())
|
||||||
.add("Remarks: " + this.getRemarks())
|
.add("Remarks: " + this.getRemarks())
|
||||||
|
.add("isLocked: " + this.isLocked())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates delete date of treatment.
|
|
||||||
*/
|
|
||||||
public LocalDate calculateDeleteDate() {
|
|
||||||
return DateConverter.convertStringToLocalDate(getDate()).plusYears(sperrfrist);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,53 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
super(connection);
|
super(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read all database entries of active {@link Treatment}s into a {@link List} of model instances.
|
||||||
|
*/
|
||||||
|
public List<Treatment> readAllActive() throws SQLException {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE isLocked = false";
|
||||||
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read all database entries of locked {@link Treatment}s into a {@link Treatment} of model instances.
|
||||||
|
*/
|
||||||
|
public List<Treatment> readAllLocked() throws SQLException {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE isLocked = true";
|
||||||
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of {@link Treatment}s associated with a specific
|
||||||
|
* {@link Patient#id patient ID} from the database.
|
||||||
|
*
|
||||||
|
* @param patientId The {@link Patient#id ID} of the {@link Patient} whose {@link Treatment}s are to be retrieved.
|
||||||
|
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Patient} ID.
|
||||||
|
*/
|
||||||
|
public List<Treatment> readTreatmentsByPatient(int patientId) throws SQLException {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, patientId);
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return getListFromResultSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of {@link Treatment}s associated with a specific
|
||||||
|
* {@link Nurse#id patient ID} from the database.
|
||||||
|
*
|
||||||
|
* @param nurseId The {@link Nurse#id ID} of the {@link Nurse} whose {@link Treatment}s are to be retrieved.
|
||||||
|
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Nurse} ID.
|
||||||
|
*/
|
||||||
|
public List<Treatment> readTreatmentsByNurse(int nurseId) throws SQLException {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE nurseId = ?";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, nurseId);
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return getListFromResultSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
|
@ -68,13 +115,13 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
DateConverter.convertStringToLocalTime(result.getString(6)),
|
DateConverter.convertStringToLocalTime(result.getString(6)),
|
||||||
result.getString(7),
|
result.getString(7),
|
||||||
result.getString(8),
|
result.getString(8),
|
||||||
false
|
result.getBoolean(9)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
protected PreparedStatement getReadAllStatement() throws SQLException {
|
||||||
final String SQL = "SELECT * FROM treatment where isLocked = false";
|
final String SQL = "SELECT * FROM treatment";
|
||||||
return this.connection.prepareStatement(SQL);
|
return this.connection.prepareStatement(SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,36 +134,6 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
|
||||||
* {@link Patient#id patient ID} from the database.
|
|
||||||
*
|
|
||||||
* @param patientId The {@link Patient#id ID} of the {@link Patient} whose {@link Treatment}s are to be retrieved.
|
|
||||||
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Patient} ID.
|
|
||||||
*/
|
|
||||||
public List<Treatment> readTreatmentsByPatient(int patientId) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, patientId);
|
|
||||||
ResultSet result = statement.executeQuery();
|
|
||||||
return getListFromResultSet(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
|
||||||
* {@link Nurse#id patient ID} from the database.
|
|
||||||
*
|
|
||||||
* @param nurseId The {@link Nurse#id ID} of the {@link Nurse} whose {@link Treatment}s are to be retrieved.
|
|
||||||
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Nurse} ID.
|
|
||||||
*/
|
|
||||||
public List<Treatment> readTreatmentsByNurse(int nurseId) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE nurseId = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, nurseId);
|
|
||||||
ResultSet result = statement.executeQuery();
|
|
||||||
return getListFromResultSet(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
|
@ -149,11 +166,4 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all locked treatments.
|
|
||||||
*/
|
|
||||||
public List<Treatment> readAllLocked() throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE isLocked = true";
|
|
||||||
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue