From 2856cbd13cdcb5dc6fce1914bde1d79749df8dc8 Mon Sep 17 00:00:00 2001 From: Dorian Nemec Date: Mon, 20 May 2024 08:15:50 +0200 Subject: [PATCH] #7 Update model --- db/nursingHome.db | Bin 28672 -> 28672 bytes .../nhplus/fixtures/TreatmentFixture.java | 30 +++++++++++------ .../de/hitec/nhplus/treatment/Treatment.java | 31 +++++++++++++++++- .../treatment/database/TreatmentDao.java | 27 +++++++++++---- .../nhplus/treatment/database/Treatment.sql | 1 + 5 files changed, 72 insertions(+), 17 deletions(-) diff --git a/db/nursingHome.db b/db/nursingHome.db index df596e05e2ebebaf5fb16a358f7204e2cf400f90..43fecf6d4eedeaf73da1af9b0a95d1e9cd0e4248 100644 GIT binary patch delta 642 zcmYjOPe@cj9G-D(cK*D1MIopM)uBrSK|;66$b%lFL*%J*&^&uV1HXaq`+eUxKYlZ}0p~X0gO;7> z8vr1o>)&~`xI5RP*}mFiVg3e~%m8zlJrr-qjB%CMp9eI-7E&h?Y1@W(Zm1Q$mR(4l zilOgbs(60QbNz)>A?CsrJ_6Mz*`q9RA6|H}EFcOB!|Dcf3eUkW2-F&x*6!dW zQD>}KqmQsy(@oSDt5aM{#FAY>k|^9-GDfkML?-JdQP*3C1>L~`jdDAJ(?or3y=9Cx z#v^r16Xj-#ViLtqTY*i~+e}H68?-4(vF8O*d$Q|d9L6#Be441Ny=lG%jk0dZA97tj zmGv;$c3aMxM^HN)_r}VXUB5h0#o{os;r36AdsUxRH7P#=N&l1Zh>UhgtJAe9t%`h2 zlpaE9xXmDb5Ls|i2kIuq3^!;Q!_oe+>;iI4zLbk{LY|dfVY9O(qXv>oKz^4W_RNK8N^-VR=Vg$H@dJwaUuQ%1;IBV^}>aFFTZmR+?8FpvI|#JhhrZB z0GjNBdcKx(Qt~?Cy=MAfprUo4Z?d;MNj~8YS`Q0}EK-7*ig-o7!s)P0FG1XOr!>Q| z;NxTBiS}LGM#~~cnK+7<;n_DYF%+A6?Fbk)OcQo*_;t0S_S1saIniT(GE8m+Zvmdv zPp}W{I^Cu%vQM_j6#j{~!c5{Bu9ot4DPNc@6w5`sP%7JnYBfs`fG}$qoNIB%c8Y!E zv^`n2OA%sMDmO6(5J@B%C}J-)LlKgPNHZQ>5a-Q@BtIlg`oy@{F^|&)Z2+7Mk}uK? zGOG?k%=^MiU!y~ZFhCJM7F-lx(htaN903$LjxC8>BQ@Gl29ai9iQY(q-it{^1Xx`r zoXii}f&&YyYlw`sr-vZUHwgdDclZYHg~`!Jd~G!`$0igD`kq_&=iRnX_%}e|ynClP zSNHW(O7>uGcG@b+D+X*Yd5dmb{!&N(ReFr%6caAg{igKLRIJ7%gw^Qf8jpvXz0Vnc n2NW&<|HVIZ5$e-V`7o-vi~f~H%f0J*_8F%naVva(`ReFDI~s#k diff --git a/src/main/java/de/hitec/nhplus/fixtures/TreatmentFixture.java b/src/main/java/de/hitec/nhplus/fixtures/TreatmentFixture.java index 85c13ad..f7056ff 100644 --- a/src/main/java/de/hitec/nhplus/fixtures/TreatmentFixture.java +++ b/src/main/java/de/hitec/nhplus/fixtures/TreatmentFixture.java @@ -67,7 +67,8 @@ public class TreatmentFixture implements Fixture { "Gespräch", "Der Patient hat enorme Angstgefühle und glaubt, er sei überfallen 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( 2, @@ -79,7 +80,8 @@ public class TreatmentFixture implements Fixture { "Gespräch", "Patient irrt auf der Suche nach gestohlenen Wertsachen durch die Etage " + "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( 3, @@ -89,7 +91,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("07:30"), convertStringToLocalTime("08:00"), "Waschen", - "Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet." + "Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet.", + false )); treatments.add(new Treatment( 4, @@ -99,7 +102,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("15:10"), convertStringToLocalTime("16:00"), "Spaziergang", - "Spaziergang im Park, Patient döst im Rollstuhl ein") + "Spaziergang im Park, Patient döst im Rollstuhl ein", + false) ); treatments.add(new Treatment( 8, @@ -109,7 +113,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("15:00"), convertStringToLocalTime("16:00"), "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( 9, @@ -119,7 +124,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("11:00"), convertStringToLocalTime("11:30"), "Waschen", - "Waschen per Dusche auf einem Stuhl; Patientin gewendet;") + "Waschen per Dusche auf einem Stuhl; Patientin gewendet;", + false) ); treatments.add(new Treatment( 12, @@ -129,7 +135,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("15:00"), convertStringToLocalTime("15:30"), "Physiotherapie", - "Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur") + "Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur", + false) ); treatments.add(new Treatment( 14, @@ -139,7 +146,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("09:30"), convertStringToLocalTime("10:15"), "KG", - "Lympfdrainage")); + "Lympfdrainage", + false)); treatments.add(new Treatment( 16, elisabeth, @@ -148,7 +156,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("13:30"), convertStringToLocalTime("13:45"), "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( 17, @@ -158,7 +167,8 @@ public class TreatmentFixture implements Fixture { convertStringToLocalTime("16:00"), convertStringToLocalTime("17:00"), "KG", - "Massage der Extremitäten zur Verbesserung der Durchblutung") + "Massage der Extremitäten zur Verbesserung der Durchblutung", + true) ); TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao(); diff --git a/src/main/java/de/hitec/nhplus/treatment/Treatment.java b/src/main/java/de/hitec/nhplus/treatment/Treatment.java index b5195cf..c2ce7ff 100644 --- a/src/main/java/de/hitec/nhplus/treatment/Treatment.java +++ b/src/main/java/de/hitec/nhplus/treatment/Treatment.java @@ -1,14 +1,17 @@ package de.hitec.nhplus.treatment; +import de.hitec.nhplus.datastorage.DaoFactory; import de.hitec.nhplus.nurse.Nurse; import de.hitec.nhplus.patient.Patient; import de.hitec.nhplus.utils.DateConverter; +import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import java.time.LocalDate; import java.time.LocalTime; +import java.util.List; import java.util.StringJoiner; /** @@ -16,6 +19,8 @@ import java.util.StringJoiner; * * @author Bernd Heidemann * @author Dominik Säume + * @author Armin Ribic + * @author Dorian Nemec */ public class Treatment { private SimpleIntegerProperty id; @@ -26,6 +31,8 @@ public class Treatment { private final SimpleObjectProperty end; private final SimpleStringProperty description; private final SimpleStringProperty remarks; + private final SimpleBooleanProperty locked; + private final int sperrfrist = 10; /** * This constructor allows instantiating a {@link Treatment} object, @@ -50,6 +57,7 @@ public class Treatment { this.end = new SimpleObjectProperty<>(end); this.description = new SimpleStringProperty(description); this.remarks = new SimpleStringProperty(remarks); + this.locked = new SimpleBooleanProperty(false); } /** @@ -63,7 +71,8 @@ public class Treatment { LocalTime begin, LocalTime end, String description, - String remarks + String remarks, + Boolean isLocked ) { this.id = new SimpleIntegerProperty(id); this.patient = new SimpleObjectProperty<>(patient); @@ -73,6 +82,19 @@ public class Treatment { this.end = new SimpleObjectProperty<>(end); this.description = new SimpleStringProperty(description); 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() { @@ -168,4 +190,11 @@ public class Treatment { .add("Remarks: " + this.getRemarks()) .toString(); } + + /** + * Calculates delete date of treatment. + */ + public LocalDate calculateDeleteDate() { + return DateConverter.convertStringToLocalDate(getDate()).plusYears(sperrfrist); + } } diff --git a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java index 2542f40..a02a485 100644 --- a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java +++ b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java @@ -11,6 +11,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -20,6 +21,8 @@ import java.util.List; * * @author Bernd Heidemannn * @author Dominik Säume + * @author Armin Ribic + * @author Dorian Nemec */ public class TreatmentDao extends DaoImp { @@ -31,8 +34,8 @@ public class TreatmentDao extends DaoImp { protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException { final String SQL = """ INSERT INTO treatment - (patientId, nurseId, date, begin, end, description, remark) - VALUES (?, ?, ?, ?, ?, ?, ?) + (patientId, nurseId, date, begin, end, description, remark, isLocked) + VALUES (?, ?, ?, ?, ?, ?, ?, ?) """; PreparedStatement statement = this.connection.prepareStatement(SQL); statement.setInt(1, treatment.getPatient().getId()); @@ -42,6 +45,7 @@ public class TreatmentDao extends DaoImp { statement.setString(5, treatment.getEnd()); statement.setString(6, treatment.getDescription()); statement.setString(7, treatment.getRemarks()); + statement.setBoolean(8,treatment.isLocked()); return statement; } @@ -63,13 +67,14 @@ public class TreatmentDao extends DaoImp { DateConverter.convertStringToLocalTime(result.getString(5)), DateConverter.convertStringToLocalTime(result.getString(6)), result.getString(7), - result.getString(8) + result.getString(8), + false ); } @Override 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); } @@ -120,7 +125,8 @@ public class TreatmentDao extends DaoImp { begin = ?, end = ?, description = ?, - remark = ? + remark = ?, + isLocked = ? WHERE id = ? """; PreparedStatement statement = this.connection.prepareStatement(SQL); @@ -129,7 +135,8 @@ public class TreatmentDao extends DaoImp { statement.setString(3, treatment.getEnd()); statement.setString(4, treatment.getDescription()); statement.setString(5, treatment.getRemarks()); - statement.setInt(6, treatment.getId()); + statement.setBoolean(6,treatment.isLocked()); + statement.setInt(7, treatment.getId()); return statement; } @@ -141,4 +148,12 @@ public class TreatmentDao extends DaoImp { statement.setInt(1, id); return statement; } + + /** + * Returns all locked treatments. + */ + public List readAllLocked() throws SQLException { + final String SQL = "SELECT * FROM treatment WHERE isLocked = true"; + return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery()); + } } diff --git a/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql b/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql index 75b7af1..d05436c 100644 --- a/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql +++ b/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql @@ -8,6 +8,7 @@ CREATE TABLE treatment end TEXT NOT NULL, description TEXT NOT NULL, remark TEXT NOT NULL, + isLocked BOOLEAN NOT NULL DEFAULT false, FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE, FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL ) \ No newline at end of file