From 0277dafc5ef7d2a0da7348e44f42d753d1e37656 Mon Sep 17 00:00:00 2001 From: ftraue Date: Tue, 27 May 2025 12:11:01 +0200 Subject: [PATCH] commit 27/05 --- .idea/sqldialects.xml | 1 + db/nursingHome.db | Bin 16384 -> 20480 bytes .../controller/AllPatientController.java | 37 +++++- .../controller/LockedPatientController.java | 117 +++++++++++++++++ .../controller/MainWindowController.java | 9 ++ .../hitec/nhplus/datastorage/DaoFactory.java | 13 ++ .../de/hitec/nhplus/datastorage/DaoImp.java | 6 +- .../nhplus/datastorage/LockedPatientDao.java | 110 ++++++++++++++++ .../hitec/nhplus/datastorage/PatientDao.java | 43 +++++- .../de/hitec/nhplus/model/LockedPatient.java | 123 ++++++++++++++++++ .../java/de/hitec/nhplus/model/Patient.java | 18 +++ .../hitec/nhplus/utils/CheckBeforeStart.java | 8 ++ .../java/de/hitec/nhplus/utils/SetUpDB.java | 18 ++- .../de/hitec/nhplus/AllPatientView.fxml | 2 +- .../de/hitec/nhplus/LockedPatientView.fxml | 73 +++++++++++ .../de/hitec/nhplus/MainWindowView.fxml | 3 + 16 files changed, 565 insertions(+), 16 deletions(-) create mode 100644 src/main/java/de/hitec/nhplus/controller/LockedPatientController.java create mode 100644 src/main/java/de/hitec/nhplus/datastorage/LockedPatientDao.java create mode 100644 src/main/java/de/hitec/nhplus/model/LockedPatient.java create mode 100644 src/main/java/de/hitec/nhplus/utils/CheckBeforeStart.java create mode 100644 src/main/resources/de/hitec/nhplus/LockedPatientView.fxml diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml index d7fb0ad..0b32eec 100644 --- a/.idea/sqldialects.xml +++ b/.idea/sqldialects.xml @@ -2,6 +2,7 @@ + \ No newline at end of file diff --git a/db/nursingHome.db b/db/nursingHome.db index c3696b835772e8cd9917759693a7968f576437cf..f453b72f51ccfa238b86b7ecbcbb4d1dcdda3122 100644 GIT binary patch delta 1382 zcmah|TSyd97(QpOGkfODSsm9&M|WpRW4xuaVQECV=1Rq;kS0ZmY$_REie*E3@`6DK zfiV#ER!@OF$vg}M3kz`J8C6efskHbd>ZLqY7d6xh6cD?pU>Wyo|wKp zHZ?ImdMBH|H8Goaqu|*~>C{kK9ZL0N(rPhg>f}RRv#J)c+A}baNvHbN-gIB;a%M>F zOJxSr4NKi&a|*{{z*@l?j4!F7u&gL>S+Wnb*4#h*CWC;4u&GbYsxC9~(g)#1zWc z#F>ph z_{kO|Z^;j`MVqq7H5~LOU_LjI&CgKPP`TgV0NvWvP#Tfn+Y&(mzXFQ`k772vC;;T6 z@Wx&_At(6Ic4RlQyT14?V(wOt&{=~Ot6xDr`sRCKj?`XdFBh!M+F{6o-^_}{>znn6 z15lIYSS*@sOSZSP(aSK}PSIBA`eaa**+$KsrL zMeGm-{1v~#Pw*`6#nr+WVN+NYMum0(q0eYzeQ^#Uy~dG}x24n-53cs$DmQLDL~(*j zqw(gauA@ko9cg%Tom!)*(vgm5(jg<}NX^?)>lJQ3UGm^^4=(fIqWDskU4K)Y@IaC^ zLI}Ul2`BfQ&?xdC!K@_l=ASd#e4JWYifLtZKeY~X4>e9{yHP9HamH7QmyA`5XgiXf zj)kfBTz^+0JSZ!K9aEOL6Fd**V})8-;)6Tl9A%F=><8moxG;=Dar-Ft6&U(w{rz!v u^z0PQ;c<7M1!$brC~PF~Fy#L~pT%s!cs|NCTF9(GwxkR~p!w+#FOd}_Sgcq4hv^Azzg zabMx~;(7}-;v(1Nw^p$%jqIG9oBgc0nOLG(I2b0!+D5YEF>^9(-enuc$kLe0$T?ZW z{-|+Dabj{tYMw%7u0m91Zf tableView; + + @FXML private TableColumn columnId; @@ -55,6 +73,9 @@ public class AllPatientController { @FXML private Button buttonAdd; + @FXML + private Button buttonLock; + @FXML private TextField textFieldSurname; @@ -81,8 +102,11 @@ public class AllPatientController { * after loading an FXML-File. At this point of the lifecycle of the Controller, the fields can be accessed and * configured. */ + @FXML public void initialize() { this.readAllAndShowInTableView(); + this.dao = DaoFactory.getDaoFactory().createPatientDAO(); + this.columnId.setCellValueFactory(new PropertyValueFactory<>("pid")); @@ -106,14 +130,15 @@ public class AllPatientController { this.columnAssets.setCellValueFactory(new PropertyValueFactory<>("assets")); this.columnAssets.setCellFactory(TextFieldTableCell.forTableColumn()); - //Anzeigen der Daten this.tableView.setItems(this.patients); + this.buttonDelete.setDisable(true); this.tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override - public void changed(ObservableValue observableValue, Patient oldPatient, Patient newPatient) {; + public void changed(ObservableValue observableValue, Patient oldPatient, Patient newPatient) { AllPatientController.this.buttonDelete.setDisable(newPatient == null); + } }); @@ -126,6 +151,7 @@ public class AllPatientController { this.textFieldCareLevel.textProperty().addListener(inputNewPatientListener); this.textFieldRoomNumber.textProperty().addListener(inputNewPatientListener); this.textFieldAssets.textProperty().addListener(inputNewPatientListener); + } /** @@ -231,8 +257,11 @@ public class AllPatientController { Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem(); if (selectedItem != null) { try { + LockedPatientDao lockedPatientDao = DaoFactory.getDaoFactory().createLockedPatientDAO(); + lockedPatientDao.insertIntoLockedPatient(selectedItem); DaoFactory.getDaoFactory().createPatientDAO().deleteById(selectedItem.getPid()); this.tableView.getItems().remove(selectedItem); + } catch (SQLException exception) { exception.printStackTrace(); } @@ -253,8 +282,10 @@ public class AllPatientController { String careLevel = this.textFieldCareLevel.getText(); String roomNumber = this.textFieldRoomNumber.getText(); String assets = this.textFieldAssets.getText(); + + Patient newPatient = new Patient(firstName, surname, date, careLevel, roomNumber, assets); try { - this.dao.create(new Patient(firstName, surname, date, careLevel, roomNumber, assets)); + this.dao.create(newPatient); } catch (SQLException exception) { exception.printStackTrace(); } diff --git a/src/main/java/de/hitec/nhplus/controller/LockedPatientController.java b/src/main/java/de/hitec/nhplus/controller/LockedPatientController.java new file mode 100644 index 0000000..6cfc0e4 --- /dev/null +++ b/src/main/java/de/hitec/nhplus/controller/LockedPatientController.java @@ -0,0 +1,117 @@ +package de.hitec.nhplus.controller; + +import de.hitec.nhplus.Main; +import de.hitec.nhplus.datastorage.LockedPatientDao; +import de.hitec.nhplus.model.LockedPatient; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.TableView; +import de.hitec.nhplus.datastorage.DaoFactory; +import de.hitec.nhplus.datastorage.PatientDao; +import de.hitec.nhplus.model.Patient; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + +public class LockedPatientController { + + @FXML + private TableView lockedTableView; + + @FXML + private TableColumn lockedColumnId; + + @FXML + private TableColumn lockedColumnFirstName; + + @FXML + private TableColumn lockedColumnSurname; + + @FXML + private TableColumn lockedColumnDateOfBirth; + + @FXML + private TableColumn lockedColumnCareLevel; + + @FXML + private TableColumn lockedColumnRoomNumber; + + @FXML + private TableColumn lockedColumnAssets; + + @FXML + private Button buttonUnlock; + + private final ObservableList lockedPatients = FXCollections.observableArrayList(); + private PatientDao dao; + + public void initialize() { + + + this.dao = DaoFactory.getDaoFactory().createPatientDAO(); + + + this.lockedColumnId.setCellValueFactory(new PropertyValueFactory<>("pid")); + + this.lockedColumnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName")); + this.lockedColumnFirstName.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.lockedColumnSurname.setCellValueFactory(new PropertyValueFactory<>("surname")); + this.lockedColumnSurname.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.lockedColumnDateOfBirth.setCellValueFactory(new PropertyValueFactory<>("dateOfBirth")); + this.lockedColumnDateOfBirth.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.lockedColumnCareLevel.setCellValueFactory(new PropertyValueFactory<>("careLevel")); + this.lockedColumnCareLevel.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.lockedColumnRoomNumber.setCellValueFactory(new PropertyValueFactory<>("roomNumber")); + this.lockedColumnRoomNumber.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.lockedColumnAssets.setCellValueFactory(new PropertyValueFactory<>("assets")); + this.lockedColumnAssets.setCellFactory(TextFieldTableCell.forTableColumn()); + + lockedTableView.setItems(this.lockedPatients); + + + lockedTableView.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { + if (newSelection != null) { + buttonUnlock.setDisable(false); + } else { + buttonUnlock.setDisable(true); + } + }); + } + + @FXML + public void handleUnlock() { + Patient selectedPatient = lockedTableView.getSelectionModel().getSelectedItem(); + + PatientDao patientDao = DaoFactory.getDaoFactory().createPatientDAO(); + LockedPatientDao lockedPatientDao = DaoFactory.getDaoFactory().createLockedPatientDAO(); + + if (selectedPatient != null) { + try { + patientDao.create(selectedPatient); + lockedPatientDao.deleteById(selectedPatient.getPid()); + + lockedPatients.remove(selectedPatient); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/de/hitec/nhplus/controller/MainWindowController.java b/src/main/java/de/hitec/nhplus/controller/MainWindowController.java index d561a7e..44afc86 100644 --- a/src/main/java/de/hitec/nhplus/controller/MainWindowController.java +++ b/src/main/java/de/hitec/nhplus/controller/MainWindowController.java @@ -32,4 +32,13 @@ public class MainWindowController { exception.printStackTrace(); } } + @FXML + private void handleShowLockedPatient(ActionEvent event) { + FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/LockedPatientView.fxml")); + try { + mainBorderPane.setCenter(loader.load()); + } catch (IOException exception) { + exception.printStackTrace(); + } + } } diff --git a/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java b/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java index 063e29f..9210447 100644 --- a/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java +++ b/src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java @@ -1,7 +1,13 @@ package de.hitec.nhplus.datastorage; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + public class DaoFactory { + private static final String DB_URL = "jdbc:sqlite:nhplus.db"; + private static DaoFactory instance; private DaoFactory() { @@ -14,6 +20,10 @@ public class DaoFactory { return DaoFactory.instance; } + public Connection getConnection() throws SQLException { + return DriverManager.getConnection(DB_URL); + } + public TreatmentDao createTreatmentDao() { return new TreatmentDao(ConnectionBuilder.getConnection()); } @@ -21,4 +31,7 @@ public class DaoFactory { public PatientDao createPatientDAO() { return new PatientDao(ConnectionBuilder.getConnection()); } + public LockedPatientDao createLockedPatientDAO() { + return new LockedPatientDao(ConnectionBuilder.getConnection()); + } } diff --git a/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java b/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java index be502bd..af7c85a 100644 --- a/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java +++ b/src/main/java/de/hitec/nhplus/datastorage/DaoImp.java @@ -1,5 +1,7 @@ package de.hitec.nhplus.datastorage; +import de.hitec.nhplus.model.Patient; + import java.sql.*; import java.util.ArrayList; import java.util.List; @@ -14,6 +16,7 @@ public abstract class DaoImp implements Dao { @Override public void create(T t) throws SQLException { getCreateStatement(t).executeUpdate(); + } @Override @@ -54,4 +57,5 @@ public abstract class DaoImp implements Dao { protected abstract PreparedStatement getUpdateStatement(T t); protected abstract PreparedStatement getDeleteStatement(long key); -} + +} \ No newline at end of file diff --git a/src/main/java/de/hitec/nhplus/datastorage/LockedPatientDao.java b/src/main/java/de/hitec/nhplus/datastorage/LockedPatientDao.java new file mode 100644 index 0000000..a804ed7 --- /dev/null +++ b/src/main/java/de/hitec/nhplus/datastorage/LockedPatientDao.java @@ -0,0 +1,110 @@ +package de.hitec.nhplus.datastorage; + +import de.hitec.nhplus.model.LockedPatient; +import de.hitec.nhplus.model.Patient; +import de.hitec.nhplus.utils.DateConverter; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +public class LockedPatientDao extends DaoImp{ + + public LockedPatientDao(Connection connection) { + super(connection); + } + + @Override + protected Patient getInstanceFromResultSet(ResultSet resultSet) throws SQLException { + long pid = resultSet.getLong("pid"); + String firstname = resultSet.getString("firstname"); + String surname = resultSet.getString("surname"); + String dob = resultSet.getString("dateOfBirth"); + String carelevel = resultSet.getString("carelevel"); + String roomnumber = resultSet.getString("roomnumber"); + String assets = resultSet.getString("assets"); + boolean locked = resultSet.getBoolean("locked"); + + Patient patient = new Patient( + pid, + firstname, + surname, + DateConverter.convertStringToLocalDate(dob), + carelevel, + roomnumber, + assets + ); + patient.setLocked(locked); + return patient; + } + + + @Override + protected ArrayList getListFromResultSet(ResultSet set) throws SQLException { + ArrayList list = new ArrayList<>(); + while (set.next()) { + list.add(getInstanceFromResultSet(set)); + } + return list; + } + + + public void insertIntoLockedPatient(Patient lockedPatient) { + final String SQL = "INSERT INTO locked_patient (firstname, surname, dateOfBirth, carelevel, roomnumber, assets, locked) VALUES (?, ?, ?, ?, ?, ?, ?)"; + try { + PreparedStatement stmt = this.connection.prepareStatement(SQL); + stmt.setString(1, lockedPatient.getFirstName()); + stmt.setString(2, lockedPatient.getSurname()); + stmt.setString(3, lockedPatient.getDateOfBirth()); + stmt.setString(4, lockedPatient.getCareLevel()); + stmt.setString(5, lockedPatient.getRoomNumber()); + stmt.setString(6, lockedPatient.getAssets()); + stmt.setBoolean(7, true); + stmt.executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Override + protected PreparedStatement getCreateStatement(Patient lockedPatient) { + PreparedStatement stmt = null; + return stmt; + } + + @Override + protected PreparedStatement getReadByIDStatement(long key) { + return null; + } + + @Override + protected PreparedStatement getReadAllStatement() { + try { + final String SQL = "SELECT * FROM locked_patient"; + return this.connection.prepareStatement(SQL); + } catch (SQLException e) { + e.printStackTrace(); + return null; + } + } + + @Override + protected PreparedStatement getUpdateStatement(Patient patient) { + return null; + } + + @Override + protected PreparedStatement getDeleteStatement(long key) { + PreparedStatement preparedStatement = null; + try { + final String SQL = "DELETE FROM patient WHERE pid = ?"; + preparedStatement = this.connection.prepareStatement(SQL); + preparedStatement.setLong(1, key); + } catch (SQLException exception) { + exception.printStackTrace(); + } + return preparedStatement; + } +} diff --git a/src/main/java/de/hitec/nhplus/datastorage/PatientDao.java b/src/main/java/de/hitec/nhplus/datastorage/PatientDao.java index 7ce270c..2ce4a1b 100644 --- a/src/main/java/de/hitec/nhplus/datastorage/PatientDao.java +++ b/src/main/java/de/hitec/nhplus/datastorage/PatientDao.java @@ -6,6 +6,7 @@ import de.hitec.nhplus.utils.DateConverter; import java.sql.*; import java.time.LocalDate; import java.util.ArrayList; +import java.util.List; /** * Implements the Interface DaoImp. Overrides methods to generate specific PreparedStatements, @@ -13,6 +14,8 @@ import java.util.ArrayList; */ public class PatientDao extends DaoImp { + private static PatientDao instance; + /** * The constructor initiates an object of PatientDao and passes the connection to its super class. * @@ -32,8 +35,7 @@ public class PatientDao extends DaoImp { protected PreparedStatement getCreateStatement(Patient patient) { PreparedStatement preparedStatement = null; try { - final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber, assets) " + - "VALUES (?, ?, ?, ?, ?, ?)"; + final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber, assets, locked) VALUES (?, ?, ?, ?, ?, ?, ?)"; preparedStatement = this.connection.prepareStatement(SQL); preparedStatement.setString(1, patient.getFirstName()); preparedStatement.setString(2, patient.getSurname()); @@ -41,6 +43,7 @@ public class PatientDao extends DaoImp { preparedStatement.setString(4, patient.getCareLevel()); preparedStatement.setString(5, patient.getRoomNumber()); preparedStatement.setString(6, patient.getAssets()); + preparedStatement.setBoolean(7, patient.isLocked()); } catch (SQLException exception) { exception.printStackTrace(); } @@ -66,6 +69,13 @@ public class PatientDao extends DaoImp { return preparedStatement; } + public static PatientDao getInstance(Connection connection) { + if (instance == null) { + instance = new PatientDao(connection); + } + return instance; + } + /** * Maps a ResultSet of one patient to an object of Patient. * @@ -73,8 +83,8 @@ public class PatientDao extends DaoImp { * @return Object of class Patient with the data from the resultSet. */ @Override - protected Patient getInstanceFromResultSet(ResultSet result) throws SQLException { - return new Patient( + public Patient getInstanceFromResultSet(ResultSet result) throws SQLException { + Patient patient = new Patient( result.getInt(1), result.getString(2), result.getString(3), @@ -82,6 +92,8 @@ public class PatientDao extends DaoImp { result.getString(5), result.getString(6), result.getString(7)); + patient.setLocked(result.getBoolean("buttonLock")); + return patient; } /** @@ -139,7 +151,8 @@ public class PatientDao extends DaoImp { "dateOfBirth = ?, " + "carelevel = ?, " + "roomnumber = ?, " + - "assets = ? " + + "assets = ?, " + + "locked = ? " + "WHERE pid = ?"; preparedStatement = this.connection.prepareStatement(SQL); preparedStatement.setString(1, patient.getFirstName()); @@ -148,7 +161,8 @@ public class PatientDao extends DaoImp { preparedStatement.setString(4, patient.getCareLevel()); preparedStatement.setString(5, patient.getRoomNumber()); preparedStatement.setString(6, patient.getAssets()); - preparedStatement.setLong(7, patient.getPid()); + preparedStatement.setBoolean(7, patient.isLocked()); + preparedStatement.setLong(8, patient.getPid()); } catch (SQLException exception) { exception.printStackTrace(); } @@ -173,4 +187,21 @@ public class PatientDao extends DaoImp { } return preparedStatement; } + public void lockPatient(long pid, boolean locked) throws SQLException { + final String SQL = "UPDATE patient SET locked = ? WHERE pid = ?"; + PreparedStatement stmt = this.connection.prepareStatement(SQL); + stmt.setBoolean(1, locked); + stmt.setLong(2, pid); + stmt.executeUpdate(); + } + + public List readAllLocked() throws SQLException { + String sql = "SELECT * FROM locked_patient WHERE locked = 1"; + + PreparedStatement statement = this.connection.prepareStatement(sql); + ResultSet resultSet = statement.executeQuery(); + + return getListFromResultSet(resultSet); + } + } diff --git a/src/main/java/de/hitec/nhplus/model/LockedPatient.java b/src/main/java/de/hitec/nhplus/model/LockedPatient.java new file mode 100644 index 0000000..e7daf8e --- /dev/null +++ b/src/main/java/de/hitec/nhplus/model/LockedPatient.java @@ -0,0 +1,123 @@ +package de.hitec.nhplus.model; + +import de.hitec.nhplus.utils.DateConverter; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleLongProperty; +import javafx.beans.property.SimpleStringProperty; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +public class LockedPatient extends Person { + + private SimpleLongProperty pid; + private final SimpleStringProperty dateOfBirth; + private final SimpleStringProperty careLevel; + private final SimpleStringProperty roomNumber; + private final SimpleStringProperty assets; + + /** + * Constructor to initiate an object of class Patient with the given parameter. Use this constructor + * to initiate objects, which are not persisted yet, because it will not have a patient id (pid). + * + * @param firstName First name of the patient. + * @param surname Last name of the patient. + * @param dateOfBirth Date of birth of the patient. + * @param careLevel Care level of the patient. + * @param roomNumber Room number of the patient. + * @param assets Assets of the patient. + */ + + public LockedPatient(String firstName, String surname, LocalDate dateOfBirth, String careLevel, String roomNumber, String assets) { + super(firstName, surname); + this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth)); + this.careLevel = new SimpleStringProperty(careLevel); + this.roomNumber = new SimpleStringProperty(roomNumber); + this.assets = new SimpleStringProperty(assets); + this.locked = new SimpleBooleanProperty(); + } + + public LockedPatient(long pid, String firstName, String surname, LocalDate dateOfBirth, String careLevel, String roomNumber, String assets) { + super(firstName, surname); + this.pid = new SimpleLongProperty(pid); + this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth)); + this.careLevel = new SimpleStringProperty(careLevel); + this.roomNumber = new SimpleStringProperty(roomNumber); + this.assets = new SimpleStringProperty(assets); + this.locked.set(false); + } + + public long getPid() { + return pid.get(); + } + + public SimpleLongProperty pidProperty() { + return pid; + } + + public String getDateOfBirth() { + return dateOfBirth.get(); + } + + public SimpleStringProperty dateOfBirthProperty() { + return dateOfBirth; + } + + public void setDateOfBirth(String dateOfBirth) { + this.dateOfBirth.set(dateOfBirth); + } + + public String getCareLevel() { + return careLevel.get(); + } + + public SimpleStringProperty careLevelProperty() { + return careLevel; + } + + public void setCareLevel(String careLevel) { + this.careLevel.set(careLevel); + } + + public String getRoomNumber() { + return roomNumber.get(); + } + + public SimpleStringProperty roomNumberProperty() { + return roomNumber; + } + + private SimpleBooleanProperty locked = new SimpleBooleanProperty(false); + + public boolean isLocked() { + return locked.get(); + } + + public void setLocked(boolean value) { + this.locked.set(value); + } + + public BooleanProperty lockedProperty() { + return locked; + } + + public void setRoomNumber(String roomNumber) { + this.roomNumber.set(roomNumber); + } + + public String getAssets() { + return assets.get(); + } + + public SimpleStringProperty assetsProperty() { + return assets; + } + + public void setAssets(String assets) { + this.assets.set(assets); + } + + +} diff --git a/src/main/java/de/hitec/nhplus/model/Patient.java b/src/main/java/de/hitec/nhplus/model/Patient.java index ffea8ce..39f9d7e 100644 --- a/src/main/java/de/hitec/nhplus/model/Patient.java +++ b/src/main/java/de/hitec/nhplus/model/Patient.java @@ -3,6 +3,8 @@ package de.hitec.nhplus.model; import de.hitec.nhplus.utils.DateConverter; import javafx.beans.property.SimpleLongProperty; import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.BooleanProperty; import java.time.LocalDate; import java.util.ArrayList; @@ -36,6 +38,7 @@ public class Patient extends Person { this.careLevel = new SimpleStringProperty(careLevel); this.roomNumber = new SimpleStringProperty(roomNumber); this.assets = new SimpleStringProperty(assets); + this.locked = new SimpleBooleanProperty(); } /** @@ -57,6 +60,7 @@ public class Patient extends Person { this.careLevel = new SimpleStringProperty(careLevel); this.roomNumber = new SimpleStringProperty(roomNumber); this.assets = new SimpleStringProperty(assets); + this.locked.set(false); } public long getPid() { @@ -104,6 +108,20 @@ public class Patient extends Person { return roomNumber; } + private SimpleBooleanProperty locked = new SimpleBooleanProperty(false); + + public boolean isLocked() { + return locked.get(); + } + + public void setLocked(boolean value) { + this.locked.set(value); + } + + public BooleanProperty lockedProperty() { + return locked; + } + public void setRoomNumber(String roomNumber) { this.roomNumber.set(roomNumber); diff --git a/src/main/java/de/hitec/nhplus/utils/CheckBeforeStart.java b/src/main/java/de/hitec/nhplus/utils/CheckBeforeStart.java new file mode 100644 index 0000000..bc745d2 --- /dev/null +++ b/src/main/java/de/hitec/nhplus/utils/CheckBeforeStart.java @@ -0,0 +1,8 @@ +package de.hitec.nhplus.utils; + +public class CheckBeforeStart { + + public void checkExpiredPatient () { + + } +} diff --git a/src/main/java/de/hitec/nhplus/utils/SetUpDB.java b/src/main/java/de/hitec/nhplus/utils/SetUpDB.java index 7596348..4c08e70 100644 --- a/src/main/java/de/hitec/nhplus/utils/SetUpDB.java +++ b/src/main/java/de/hitec/nhplus/utils/SetUpDB.java @@ -1,9 +1,6 @@ package de.hitec.nhplus.utils; -import de.hitec.nhplus.datastorage.ConnectionBuilder; -import de.hitec.nhplus.datastorage.DaoFactory; -import de.hitec.nhplus.datastorage.PatientDao; -import de.hitec.nhplus.datastorage.TreatmentDao; +import de.hitec.nhplus.datastorage.*; import de.hitec.nhplus.model.Patient; import de.hitec.nhplus.model.Treatment; @@ -33,6 +30,7 @@ public class SetUpDB { SetUpDB.setUpTableTreatment(connection); SetUpDB.setUpPatients(); SetUpDB.setUpTreatments(); + SetUpDB.setUpLockedPatient(); } /** @@ -55,7 +53,8 @@ public class SetUpDB { " dateOfBirth TEXT NOT NULL, " + " carelevel TEXT NOT NULL, " + " roomnumber TEXT NOT NULL, " + - " assets TEXt NOT NULL" + + " assets TEXt NOT NULL," + + " locked BOOLEAN DEFAULT FALSE" + ");"; try (Statement statement = connection.createStatement()) { statement.execute(SQL); @@ -98,6 +97,15 @@ public class SetUpDB { } } + private static void setUpLockedPatient() { + try { + LockedPatientDao dao = DaoFactory.getDaoFactory().createLockedPatientDAO(); + dao.readAll(); + } catch (SQLException exception){ + exception.printStackTrace(); + } + } + private static void setUpTreatments() { try { TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao(); diff --git a/src/main/resources/de/hitec/nhplus/AllPatientView.fxml b/src/main/resources/de/hitec/nhplus/AllPatientView.fxml index 32b4710..b4cf924 100644 --- a/src/main/resources/de/hitec/nhplus/AllPatientView.fxml +++ b/src/main/resources/de/hitec/nhplus/AllPatientView.fxml @@ -77,4 +77,4 @@ - + diff --git a/src/main/resources/de/hitec/nhplus/LockedPatientView.fxml b/src/main/resources/de/hitec/nhplus/LockedPatientView.fxml new file mode 100644 index 0000000..a39df04 --- /dev/null +++ b/src/main/resources/de/hitec/nhplus/LockedPatientView.fxml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +