Compare commits
3 Commits
4942312e8a
...
featureNHP
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0277dafc5e | ||
|
|
31ee074b02 | ||
|
|
4d2d048b11 |
1
.idea/sqldialects.xml
generated
1
.idea/sqldialects.xml
generated
@@ -2,6 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/datastorage/TreatmentDao.java" dialect="GenericSQL" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/utils/SetUpDB.java" dialect="SQLite" />
|
||||
<file url="PROJECT" dialect="SQLite" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
@@ -23,9 +23,10 @@ Die Auswahl soll automatisch mit der Behandlung gespeichert werden, sodass ich (
|
||||
|
||||
# **Tasks**
|
||||
|
||||
- **T_1:** Vorbedingung: Mario ist eingeloggt. Mehrere aktive Pflegekräfte sind im System vorhanden.
|
||||
- **T_2:** Ablauf: Mario öffnet die Maske zum Anlegen einer neuen Behandlung.
|
||||
- **T_3:** Erwartung: Eine ComboBox mit allen aktiven Pflegekräften wird angezeigt.
|
||||
- **T_1:** Auswahl der Pflegekräfte durch ComboBox
|
||||
- **T_2:** Nur aktive Pflegekräfte in der ComboBox anzeigen
|
||||
- **T_3:** Pflegekraft nach 10 Jahren Inaktivität aus dem System löschen
|
||||
- **T_4:** Benachrichtigung der Pflegekräfte über das Löschen aus dem System
|
||||
|
||||
---
|
||||
|
||||
@@ -35,14 +36,14 @@ TF_1: Auswahl einer Pflegekraft bei neuer Behandlung
|
||||
|
||||
- **Vorbedingung:** Mario ist eingeloggt. Mehrere aktive Pflegekräfte sind im System vorhanden.
|
||||
- **Ablauf:**
|
||||
1. Mario öffnet die Maske zum Anlegen einer neuen Behandlung.
|
||||
1. Mario öffnet die Maske zum Anlegen einer neuen Behandlung.
|
||||
- **Erwartet:** Eine ComboBox mit allen aktiven Pflegekräften wird angezeigt.
|
||||
|
||||
|
||||
TF_2: Speicherung der Auswahl
|
||||
- **Vorbedingung:** Mario hat eine Pflegekraft aus der Liste gewählt.
|
||||
- **Ablauf:**
|
||||
1. Er speichert die Behandlung.
|
||||
1. Er speichert die Behandlung.
|
||||
- **Erwartet:** Die gewählte Pflegekraft ist korrekt mit der Behandlung verknüpft.
|
||||
|
||||
TF3: Keine Auswahl – Fehlermeldung
|
||||
@@ -64,13 +65,3 @@ TF 5: Anzeige der zugeordneten Pflegekraft in bestehender Behandlung
|
||||
- **Erwartet:** In der ComboBox ist „Müller, Anna“ vorausgewählt.
|
||||
|
||||
|
||||
|
||||
Testschritte:
|
||||
|
||||
Keine Auswahl treffen
|
||||
|
||||
Auf „Speichern“ klicken
|
||||
|
||||
Erwartetes Ergebnis: Fehlermeldung erscheint, Speicherung wird verhindert.
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.LockedPatientDao;
|
||||
import de.hitec.nhplus.datastorage.PatientDao;
|
||||
import de.hitec.nhplus.model.LockedPatient;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
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.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
@@ -15,9 +20,20 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.ReadOnlyStringWrapper;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,6 +44,8 @@ public class AllPatientController {
|
||||
@FXML
|
||||
private TableView<Patient> tableView;
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, Integer> 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<Patient>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Patient> observableValue, Patient oldPatient, Patient newPatient) {;
|
||||
public void changed(ObservableValue<? extends Patient> 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();
|
||||
}
|
||||
|
||||
@@ -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<Patient> lockedTableView;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, Integer> lockedColumnId;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> lockedColumnFirstName;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> lockedColumnSurname;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> lockedColumnDateOfBirth;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> lockedColumnCareLevel;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> lockedColumnRoomNumber;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> lockedColumnAssets;
|
||||
|
||||
@FXML
|
||||
private Button buttonUnlock;
|
||||
|
||||
private final ObservableList<Patient> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> implements Dao<T> {
|
||||
@Override
|
||||
public void create(T t) throws SQLException {
|
||||
getCreateStatement(t).executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,4 +57,5 @@ public abstract class DaoImp<T> implements Dao<T> {
|
||||
protected abstract PreparedStatement getUpdateStatement(T t);
|
||||
|
||||
protected abstract PreparedStatement getDeleteStatement(long key);
|
||||
|
||||
}
|
||||
110
src/main/java/de/hitec/nhplus/datastorage/LockedPatientDao.java
Normal file
110
src/main/java/de/hitec/nhplus/datastorage/LockedPatientDao.java
Normal file
@@ -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<Patient>{
|
||||
|
||||
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<Patient> getListFromResultSet(ResultSet set) throws SQLException {
|
||||
ArrayList<Patient> 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;
|
||||
}
|
||||
}
|
||||
@@ -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 <code>DaoImp</code>. Overrides methods to generate specific <code>PreparedStatements</code>,
|
||||
@@ -13,6 +14,8 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class PatientDao extends DaoImp<Patient> {
|
||||
|
||||
private static PatientDao instance;
|
||||
|
||||
/**
|
||||
* The constructor initiates an object of <code>PatientDao</code> and passes the connection to its super class.
|
||||
*
|
||||
@@ -32,8 +35,7 @@ public class PatientDao extends DaoImp<Patient> {
|
||||
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<Patient> {
|
||||
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<Patient> {
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
public static PatientDao getInstance(Connection connection) {
|
||||
if (instance == null) {
|
||||
instance = new PatientDao(connection);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a <code>ResultSet</code> of one patient to an object of <code>Patient</code>.
|
||||
*
|
||||
@@ -73,8 +83,8 @@ public class PatientDao extends DaoImp<Patient> {
|
||||
* @return Object of class <code>Patient</code> 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<Patient> {
|
||||
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<Patient> {
|
||||
"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<Patient> {
|
||||
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<Patient> {
|
||||
}
|
||||
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<Patient> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
123
src/main/java/de/hitec/nhplus/model/LockedPatient.java
Normal file
123
src/main/java/de/hitec/nhplus/model/LockedPatient.java
Normal file
@@ -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 <code>Patient</code> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.hitec.nhplus.utils;
|
||||
|
||||
public class CheckBeforeStart {
|
||||
|
||||
public void checkExpiredPatient () {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -77,4 +77,4 @@
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
||||
</AnchorPane>
|
||||
|
||||
73
src/main/resources/de/hitec/nhplus/LockedPatientView.fxml
Normal file
73
src/main/resources/de/hitec/nhplus/LockedPatientView.fxml
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="de.hitec.nhplus.controller.LockedPatientController" prefHeight="500.0" prefWidth="855.0">
|
||||
<children>
|
||||
<TableView fx:id="lockedTableView" layoutX="31.0" layoutY="120.0" prefHeight="287.0" prefWidth="825.0" AnchorPane.bottomAnchor="100.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="lockedColumnId" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
|
||||
<TableColumn fx:id="lockedColumnSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname" />
|
||||
<TableColumn fx:id="lockedColumnFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname" />
|
||||
<TableColumn fx:id="lockedColumnDateOfBirth" maxWidth="7500.0" prefWidth="75.0" text="Geburtstag" />
|
||||
<TableColumn fx:id="lockedColumnCareLevel" prefWidth="75.0" text="Pflegegrad" />
|
||||
<TableColumn fx:id="lockedColumnRoomNumber" prefWidth="75.0" text="Raum" />
|
||||
<TableColumn fx:id="lockedColumnAssets" prefWidth="75.0" text="Vermögensstand" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<GridPane hgap="10.0" vgap="10.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" prefWidth="200.0" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="200.0" prefWidth="200.0" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="160.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<padding>
|
||||
<Insets right="10.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
</GridPane>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Gesperrte Patienten/innen" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<Button fx:id="buttonUnlock" text="Entsperren" onAction="#handleUnlock" AnchorPane.rightAnchor="10" AnchorPane.bottomAnchor="15" prefWidth="90"/>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
||||
@@ -19,6 +19,9 @@
|
||||
<VBox.margin>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
|
||||
</VBox.margin></Button>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowLockedPatient" prefWidth="105.0" text="Gesperrte Patienten/innen">
|
||||
<Insets bottom="50" left="10" right="10" top="100"/>
|
||||
</Button>
|
||||
</children>
|
||||
</VBox>
|
||||
</left>
|
||||
|
||||
Reference in New Issue
Block a user