#24 Update model

This commit is contained in:
Dorian Nemec 2024-05-20 08:15:50 +02:00 committed by SZUT-Dorian
parent 700aba10b7
commit bb63343c2f
5 changed files with 72 additions and 17 deletions

Binary file not shown.

View file

@ -67,7 +67,8 @@ 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, 2,
@ -79,7 +80,8 @@ 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, 3,
@ -89,7 +91,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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, 4,
@ -99,7 +102,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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, 8,
@ -109,7 +113,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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, 9,
@ -119,7 +124,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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, 12,
@ -129,7 +135,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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, 14,
@ -139,7 +146,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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, 16,
elisabeth, elisabeth,
@ -148,7 +156,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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)
); );
treatments.add(new Treatment( treatments.add(new Treatment(
17, 17,
@ -158,7 +167,8 @@ public class TreatmentFixture implements Fixture<Treatment> {
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)
); );
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao(); TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();

View file

@ -1,14 +1,17 @@
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;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty; 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;
/** /**
@ -16,6 +19,8 @@ import java.util.StringJoiner;
* *
* @author Bernd Heidemann * @author Bernd Heidemann
* @author Dominik Säume * @author Dominik Säume
* @author Armin Ribic
* @author Dorian Nemec
*/ */
public class Treatment { public class Treatment {
private SimpleIntegerProperty id; private SimpleIntegerProperty id;
@ -26,6 +31,8 @@ public class Treatment {
private final SimpleObjectProperty<LocalTime> end; private final SimpleObjectProperty<LocalTime> end;
private final SimpleStringProperty description; private final SimpleStringProperty description;
private final SimpleStringProperty remarks; private final SimpleStringProperty remarks;
private final SimpleBooleanProperty locked;
private final int sperrfrist = 10;
/** /**
* This constructor allows instantiating a {@link Treatment} object, * This constructor allows instantiating a {@link Treatment} object,
@ -50,6 +57,7 @@ public class Treatment {
this.end = new SimpleObjectProperty<>(end); this.end = new SimpleObjectProperty<>(end);
this.description = new SimpleStringProperty(description); this.description = new SimpleStringProperty(description);
this.remarks = new SimpleStringProperty(remarks); this.remarks = new SimpleStringProperty(remarks);
this.locked = new SimpleBooleanProperty(false);
} }
/** /**
@ -63,7 +71,8 @@ public class Treatment {
LocalTime begin, LocalTime begin,
LocalTime end, LocalTime end,
String description, String description,
String remarks String remarks,
Boolean isLocked
) { ) {
this.id = new SimpleIntegerProperty(id); this.id = new SimpleIntegerProperty(id);
this.patient = new SimpleObjectProperty<>(patient); this.patient = new SimpleObjectProperty<>(patient);
@ -73,6 +82,19 @@ public class Treatment {
this.end = new SimpleObjectProperty<>(end); this.end = new SimpleObjectProperty<>(end);
this.description = new SimpleStringProperty(description); this.description = new SimpleStringProperty(description);
this.remarks = new SimpleStringProperty(remarks); this.remarks = new SimpleStringProperty(remarks);
this.locked = new SimpleBooleanProperty(isLocked);
}
public boolean isLocked() {
return locked.get();
}
public SimpleBooleanProperty lockedProperty() {
return locked;
}
public void setLocked(boolean locked) {
this.locked.set(locked);
} }
public int getId() { public int getId() {
@ -168,4 +190,11 @@ public class Treatment {
.add("Remarks: " + this.getRemarks()) .add("Remarks: " + this.getRemarks())
.toString(); .toString();
} }
/**
* Calculates delete date of treatment.
*/
public LocalDate calculateDeleteDate() {
return DateConverter.convertStringToLocalDate(getDate()).plusYears(sperrfrist);
}
} }

View file

@ -11,6 +11,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -20,6 +21,8 @@ import java.util.List;
* *
* @author Bernd Heidemannn * @author Bernd Heidemannn
* @author Dominik Säume * @author Dominik Säume
* @author Armin Ribic
* @author Dorian Nemec
*/ */
public class TreatmentDao extends DaoImp<Treatment> { public class TreatmentDao extends DaoImp<Treatment> {
@ -31,8 +34,8 @@ public class TreatmentDao extends DaoImp<Treatment> {
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException { protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
final String SQL = """ final String SQL = """
INSERT INTO treatment INSERT INTO treatment
(patientId, nurseId, date, begin, end, description, remark) (patientId, nurseId, date, begin, end, description, remark, isLocked)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
"""; """;
PreparedStatement statement = this.connection.prepareStatement(SQL); PreparedStatement statement = this.connection.prepareStatement(SQL);
statement.setInt(1, treatment.getPatient().getId()); statement.setInt(1, treatment.getPatient().getId());
@ -42,6 +45,7 @@ public class TreatmentDao extends DaoImp<Treatment> {
statement.setString(5, treatment.getEnd()); statement.setString(5, treatment.getEnd());
statement.setString(6, treatment.getDescription()); statement.setString(6, treatment.getDescription());
statement.setString(7, treatment.getRemarks()); statement.setString(7, treatment.getRemarks());
statement.setBoolean(8,treatment.isLocked());
return statement; return statement;
} }
@ -63,13 +67,14 @@ public class TreatmentDao extends DaoImp<Treatment> {
DateConverter.convertStringToLocalTime(result.getString(5)), DateConverter.convertStringToLocalTime(result.getString(5)),
DateConverter.convertStringToLocalTime(result.getString(6)), DateConverter.convertStringToLocalTime(result.getString(6)),
result.getString(7), result.getString(7),
result.getString(8) result.getString(8),
false
); );
} }
@Override @Override
protected PreparedStatement getReadAllStatement() throws SQLException { protected PreparedStatement getReadAllStatement() throws SQLException {
final String SQL = "SELECT * FROM treatment"; final String SQL = "SELECT * FROM treatment where isLocked = false";
return this.connection.prepareStatement(SQL); return this.connection.prepareStatement(SQL);
} }
@ -120,7 +125,8 @@ public class TreatmentDao extends DaoImp<Treatment> {
begin = ?, begin = ?,
end = ?, end = ?,
description = ?, description = ?,
remark = ? remark = ?,
isLocked = ?
WHERE id = ? WHERE id = ?
"""; """;
PreparedStatement statement = this.connection.prepareStatement(SQL); PreparedStatement statement = this.connection.prepareStatement(SQL);
@ -129,7 +135,8 @@ public class TreatmentDao extends DaoImp<Treatment> {
statement.setString(3, treatment.getEnd()); statement.setString(3, treatment.getEnd());
statement.setString(4, treatment.getDescription()); statement.setString(4, treatment.getDescription());
statement.setString(5, treatment.getRemarks()); statement.setString(5, treatment.getRemarks());
statement.setInt(6, treatment.getId()); statement.setBoolean(6,treatment.isLocked());
statement.setInt(7, treatment.getId());
return statement; return statement;
} }
@ -141,4 +148,12 @@ public class TreatmentDao extends DaoImp<Treatment> {
statement.setInt(1, id); statement.setInt(1, id);
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());
}
} }

View file

@ -8,6 +8,7 @@ CREATE TABLE treatment
end TEXT NOT NULL, end TEXT NOT NULL,
description TEXT NOT NULL, description TEXT NOT NULL,
remark TEXT NOT NULL, remark TEXT NOT NULL,
isLocked BOOLEAN NOT NULL DEFAULT false,
FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE, FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE,
FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL
) )