Compare commits
22 commits
cc5af63b0e
...
f713717d58
Author | SHA1 | Date | |
---|---|---|---|
|
f713717d58 | ||
|
02232cd27f | ||
|
e584e220a5 | ||
|
9fac5b34a3 | ||
|
6300509873 | ||
e9aa98d63a | |||
0df409e775 | |||
7db1c83a08 | |||
ae7fc3ab64 | |||
069465c4ca | |||
fb6fc923ac | |||
03ef4a235a | |||
092b436247 | |||
fb26756309 | |||
6e58574909 | |||
|
449f3ade06 | ||
970f167bc3 | |||
|
f77072ab70 | ||
|
efe10a72a3 | ||
|
2856cbd13c | ||
1cbafa2fe9 | |||
30120f3709 |
46 changed files with 1735 additions and 310 deletions
|
@ -27,9 +27,12 @@
|
||||||
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/nurse/database/Nurse.sql" />
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/nurse/database/Nurse.sql" />
|
||||||
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/medication/database/Medication.sql" />
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/medication/database/Medication.sql" />
|
||||||
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/medication/database/Medication_Ingredient.sql" />
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/medication/database/Medication_Ingredient.sql" />
|
||||||
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/login/database/User.sql" />
|
||||||
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/login/database/UserPermission.sql" />
|
||||||
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/login/database/UserToNurse.sql" />
|
||||||
</array>
|
</array>
|
||||||
</option>
|
</option>
|
||||||
<option name="outLayout" value="File per object by schema.groovy" />
|
<option name="outLayout" value="File per object.groovy" />
|
||||||
</State>
|
</State>
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
[![Static Badge](https://img.shields.io/badge/Wiki-Wiki?style=for-the-badge&logo=wikipedia&color=slategray)](https://git.euph.dev/SZUT/nhplus/wiki)
|
[![Static Badge](https://img.shields.io/badge/Wiki-Wiki?style=for-the-badge&logo=wikipedia&color=slategray)](https://git.euph.dev/SZUT/nhplus/wiki)
|
||||||
[![Static Badge](https://img.shields.io/badge/Tests-Tests?style=for-the-badge&logo=textpattern&logoColor=cyan&color=blue)](https://git.euph.dev/SZUT/nhplus/wiki/Tests)
|
[![Static Badge](https://img.shields.io/badge/Tests-Tests?style=for-the-badge&logo=textpattern&logoColor=cyan&color=blue)](https://git.euph.dev/SZUT/nhplus/wiki/Tests)
|
||||||
[![Static Badge](https://img.shields.io/badge/Javadoc-Javadoc?style=for-the-badge&logo=readthedocs&logoColor=orange&color=beige)](https://nhplus.euph.dev)
|
[![Static Badge](https://img.shields.io/badge/Javadoc-Javadoc?style=for-the-badge&logo=readthedocs&logoColor=orange&color=beige)](https://nhplus.euph.dev)
|
||||||
|
[![Static Badge](https://img.shields.io/badge/Credentails-Credentails?style=for-the-badge&logo=keepassxc&logoColor=lime&color=darkgreen)](https://git.euph.dev/SZUT/nhplus/wiki/Test-Anmelde-Daten)
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,11 +1,15 @@
|
||||||
package de.hitec.nhplus;
|
package de.hitec.nhplus;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
||||||
|
import de.hitec.nhplus.login.LoginController;
|
||||||
|
import de.hitec.nhplus.login.User;
|
||||||
|
import de.hitec.nhplus.main.MainWindowController;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.TabPane;
|
import javafx.scene.control.TabPane;
|
||||||
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -33,13 +37,43 @@ public class Main extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
executeMainApplication();
|
User user = executeLogin();
|
||||||
|
if(user != null){
|
||||||
|
executeMainApplication(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the login.
|
||||||
|
* @return User The {@link User} object for the logged-in {@link User}.
|
||||||
|
* Is {@code null}, if the login was not successful,
|
||||||
|
*/
|
||||||
|
private User executeLogin() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/login/LoginView.fxml"));
|
||||||
|
BorderPane pane = loader.load();
|
||||||
|
Scene scene = new Scene(pane);
|
||||||
|
Stage loginStage = new Stage();
|
||||||
|
loginStage.setTitle("NHPlus");
|
||||||
|
loginStage.setScene(scene);
|
||||||
|
loginStage.setResizable(false);
|
||||||
|
|
||||||
|
LoginController controller = loader.getController();
|
||||||
|
controller.initialize(loginStage);
|
||||||
|
|
||||||
|
loginStage.showAndWait();
|
||||||
|
return controller.user;
|
||||||
|
} catch (IOException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the main application.
|
* Executes the main application.
|
||||||
*/
|
*/
|
||||||
private void executeMainApplication() {
|
private void executeMainApplication(User user) {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/main/MainWindowView.fxml"));
|
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/main/MainWindowView.fxml"));
|
||||||
TabPane pane = loader.load();
|
TabPane pane = loader.load();
|
||||||
|
@ -48,6 +82,10 @@ public class Main extends Application {
|
||||||
this.primaryStage.setTitle("NHPlus");
|
this.primaryStage.setTitle("NHPlus");
|
||||||
this.primaryStage.setScene(scene);
|
this.primaryStage.setScene(scene);
|
||||||
this.primaryStage.setResizable(true);
|
this.primaryStage.setResizable(true);
|
||||||
|
|
||||||
|
MainWindowController controller = loader.getController();
|
||||||
|
controller.initialize(user);
|
||||||
|
|
||||||
this.primaryStage.show();
|
this.primaryStage.show();
|
||||||
|
|
||||||
this.primaryStage.setOnCloseRequest(event -> {
|
this.primaryStage.setOnCloseRequest(event -> {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.hitec.nhplus.datastorage;
|
package de.hitec.nhplus.datastorage;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.login.database.UserDao;
|
||||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
import de.hitec.nhplus.nurse.database.NurseDao;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
import de.hitec.nhplus.patient.database.PatientDao;
|
||||||
|
@ -63,4 +64,12 @@ public class DaoFactory {
|
||||||
public MedicationDao createMedicationDAO() {
|
public MedicationDao createMedicationDAO() {
|
||||||
return new MedicationDao(ConnectionBuilder.getConnection());
|
return new MedicationDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A new {@link UserDao} instance with a database connection.
|
||||||
|
* @see de.hitec.nhplus.login.User User
|
||||||
|
*/
|
||||||
|
public UserDao createUserDAO() {
|
||||||
|
return new UserDao(ConnectionBuilder.getConnection());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,11 @@ public class Fixtures {
|
||||||
medicationFixture.setupTable(connection);
|
medicationFixture.setupTable(connection);
|
||||||
medicationFixture.load();
|
medicationFixture.load();
|
||||||
|
|
||||||
|
UserFixture userFixture = new UserFixture(nursesByName);
|
||||||
|
userFixture.dropTable(connection);
|
||||||
|
userFixture.setupTable(connection);
|
||||||
|
userFixture.load();
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
System.out.println(exception.getMessage());
|
System.out.println(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class MedicationFixture implements Fixture<Medication> {
|
||||||
"Unterhautinjektion",
|
"Unterhautinjektion",
|
||||||
120
|
120
|
||||||
));
|
));
|
||||||
medications.add(new Medication(
|
Medication deprecatedMedication = new Medication(
|
||||||
"Levothyroxin",
|
"Levothyroxin",
|
||||||
"Sandoz",
|
"Sandoz",
|
||||||
List.of(
|
List.of(
|
||||||
|
@ -129,7 +129,9 @@ public class MedicationFixture implements Fixture<Medication> {
|
||||||
"Herzrasen, Gewichtsverlust",
|
"Herzrasen, Gewichtsverlust",
|
||||||
"Oral",
|
"Oral",
|
||||||
90
|
90
|
||||||
));
|
);
|
||||||
|
deprecatedMedication.setIsDeprecated(true);
|
||||||
|
medications.add(deprecatedMedication);
|
||||||
medications.add(new Medication(
|
medications.add(new Medication(
|
||||||
"Warfarin",
|
"Warfarin",
|
||||||
"Apotex Inc.",
|
"Apotex Inc.",
|
||||||
|
|
|
@ -54,6 +54,12 @@ public class NurseFixture implements Fixture<Nurse> {
|
||||||
true
|
true
|
||||||
));
|
));
|
||||||
|
|
||||||
|
nurses.add(new Nurse(
|
||||||
|
"Maria",
|
||||||
|
"Höller",
|
||||||
|
"666"
|
||||||
|
));
|
||||||
|
|
||||||
NurseDao dao = DaoFactory.getInstance().createNurseDAO();
|
NurseDao dao = DaoFactory.getInstance().createNurseDAO();
|
||||||
for (Nurse nurse : nurses) {
|
for (Nurse nurse : nurses) {
|
||||||
dao.create(nurse);
|
dao.create(nurse);
|
||||||
|
|
|
@ -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"),
|
||||||
|
@ -70,7 +69,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
+ "Patient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind."
|
+ "Patient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind."
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
2,
|
|
||||||
seppl,
|
seppl,
|
||||||
armin,
|
armin,
|
||||||
convertStringToLocalDate("2023-06-05"),
|
convertStringToLocalDate("2023-06-05"),
|
||||||
|
@ -82,7 +80,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
+ "Patient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel."
|
+ "Patient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel."
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
3,
|
|
||||||
martina,
|
martina,
|
||||||
ole,
|
ole,
|
||||||
convertStringToLocalDate("2023-06-04"),
|
convertStringToLocalDate("2023-06-04"),
|
||||||
|
@ -92,80 +89,80 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
"Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet."
|
"Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet."
|
||||||
));
|
));
|
||||||
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"
|
||||||
);
|
|
||||||
|
));
|
||||||
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"
|
||||||
);
|
));
|
||||||
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;"
|
||||||
);
|
));
|
||||||
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"
|
||||||
);
|
));
|
||||||
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"
|
||||||
|
));
|
||||||
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"
|
||||||
);
|
));
|
||||||
treatments.add(new Treatment(
|
Treatment lockedTreatment = 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"
|
||||||
);
|
);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
108
src/main/java/de/hitec/nhplus/fixtures/UserFixture.java
Normal file
108
src/main/java/de/hitec/nhplus/fixtures/UserFixture.java
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.Main;
|
||||||
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.login.Permissions;
|
||||||
|
import de.hitec.nhplus.login.User;
|
||||||
|
import de.hitec.nhplus.login.database.UserDao;
|
||||||
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link Fixture} for {@link User}.
|
||||||
|
*
|
||||||
|
* @author Dominik Säume
|
||||||
|
*/
|
||||||
|
public class UserFixture implements Fixture<User> {
|
||||||
|
private static final String SCHEMA = "/de/hitec/nhplus/login/database/User.sql";
|
||||||
|
private static final String PERMISSION_SCHEMA = "/de/hitec/nhplus/login/database/UserPermission.sql";
|
||||||
|
private static final String TO_NURSE_SCHEMA = "/de/hitec/nhplus/login/database/UserToNurse.sql";
|
||||||
|
|
||||||
|
private final Map<String, Nurse> nursesByName;
|
||||||
|
|
||||||
|
public UserFixture(Map<String, Nurse> nursesByName) {
|
||||||
|
this.nursesByName = nursesByName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dropTable(Connection connection) throws SQLException {
|
||||||
|
connection.createStatement().execute("DROP TABLE IF EXISTS user");
|
||||||
|
connection.createStatement().execute("DROP TABLE IF EXISTS user__permissions");
|
||||||
|
connection.createStatement().execute("DROP TABLE IF EXISTS user__nurse");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setupTable(Connection connection) throws SQLException {
|
||||||
|
final InputStream schema = Main.class.getResourceAsStream(SCHEMA);
|
||||||
|
final InputStream permissionSchema = Main.class.getResourceAsStream(PERMISSION_SCHEMA);
|
||||||
|
final InputStream toNurseSchema = Main.class.getResourceAsStream(TO_NURSE_SCHEMA);
|
||||||
|
|
||||||
|
assert schema != null;
|
||||||
|
assert permissionSchema != null;
|
||||||
|
assert toNurseSchema != null;
|
||||||
|
|
||||||
|
String SQL = new Scanner(schema, StandardCharsets.UTF_8)
|
||||||
|
.useDelimiter("\\A")
|
||||||
|
.next();
|
||||||
|
String permissionSQL = new Scanner(permissionSchema, StandardCharsets.UTF_8)
|
||||||
|
.useDelimiter("\\A")
|
||||||
|
.next();
|
||||||
|
String toNurseSQL = new Scanner(toNurseSchema, StandardCharsets.UTF_8)
|
||||||
|
.useDelimiter("\\A")
|
||||||
|
.next();
|
||||||
|
|
||||||
|
connection.createStatement().execute(SQL);
|
||||||
|
connection.createStatement().execute(permissionSQL);
|
||||||
|
connection.createStatement().execute(toNurseSQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, User> load() throws SQLException {
|
||||||
|
List<User> users = new ArrayList<>();
|
||||||
|
|
||||||
|
User udo = new User(
|
||||||
|
"udo",
|
||||||
|
Permissions.OWNER,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
udo.setPassword("uD0_187!");
|
||||||
|
users.add(udo);
|
||||||
|
|
||||||
|
User maria = new User(
|
||||||
|
"maria",
|
||||||
|
Permissions.NURSE,
|
||||||
|
nursesByName.get("Maria")
|
||||||
|
);
|
||||||
|
maria.setPassword("H!mm3lf4hrt");
|
||||||
|
users.add(maria);
|
||||||
|
|
||||||
|
User werner = new User(
|
||||||
|
"werner",
|
||||||
|
Permissions.MANAGEMENT,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
werner.setPassword("TurboSchraube42!");
|
||||||
|
users.add(werner);
|
||||||
|
|
||||||
|
User fullPermissionsTestUser = new User(
|
||||||
|
"test",
|
||||||
|
-1,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
fullPermissionsTestUser.setPassword("");
|
||||||
|
users.add(fullPermissionsTestUser);
|
||||||
|
|
||||||
|
UserDao dao = DaoFactory.getInstance().createUserDAO();
|
||||||
|
Map<String, User> usersByUsername = new HashMap<>();
|
||||||
|
for (User user : users) {
|
||||||
|
dao.create(user);
|
||||||
|
usersByUsername.put(user.getUsername(), user);
|
||||||
|
}
|
||||||
|
return usersByUsername;
|
||||||
|
}
|
||||||
|
}
|
104
src/main/java/de/hitec/nhplus/login/LoginController.java
Normal file
104
src/main/java/de/hitec/nhplus/login/LoginController.java
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
package de.hitec.nhplus.login;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.login.database.UserDao;
|
||||||
|
import javafx.animation.PauseTransition;
|
||||||
|
import javafx.animation.TranslateTransition;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.PasswordField;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.util.Duration;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for handling the login of {@link User}s.
|
||||||
|
*
|
||||||
|
* @author Dominik Säume
|
||||||
|
*/
|
||||||
|
public class LoginController {
|
||||||
|
|
||||||
|
public User user;
|
||||||
|
@FXML
|
||||||
|
public TextField textFieldUsername;
|
||||||
|
@FXML
|
||||||
|
public PasswordField passwordField;
|
||||||
|
@FXML
|
||||||
|
public Button buttonSubmit;
|
||||||
|
private Stage stage;
|
||||||
|
private int loginTries = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JavaFX Initialization method that is called after the binding of all the fields.
|
||||||
|
*
|
||||||
|
* @param stage The {@link Stage}, so the modal can close itself, when finished.
|
||||||
|
*/
|
||||||
|
public void initialize(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method to handle actions on wrong logins, like a shake, timout and total tries.
|
||||||
|
*/
|
||||||
|
private void handleWrongPasswordOrUsername() {
|
||||||
|
loginTries++;
|
||||||
|
|
||||||
|
// Shake
|
||||||
|
TranslateTransition ttUsername = new TranslateTransition(Duration.millis(50), textFieldUsername);
|
||||||
|
ttUsername.setByX(10);
|
||||||
|
ttUsername.setAutoReverse(true);
|
||||||
|
ttUsername.setCycleCount(6);
|
||||||
|
|
||||||
|
TranslateTransition ttPassword = new TranslateTransition(Duration.millis(50), passwordField);
|
||||||
|
ttPassword.setByX(10);
|
||||||
|
ttPassword.setAutoReverse(true);
|
||||||
|
ttPassword.setCycleCount(6);
|
||||||
|
|
||||||
|
ttUsername.play();
|
||||||
|
ttPassword.play();
|
||||||
|
|
||||||
|
// Timout
|
||||||
|
PauseTransition pause = new PauseTransition(Duration.seconds(3));
|
||||||
|
pause.setOnFinished(event -> {
|
||||||
|
if (loginTries == 3) {
|
||||||
|
stage.close();
|
||||||
|
}
|
||||||
|
buttonSubmit.setDisable(false);
|
||||||
|
});
|
||||||
|
pause.play();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleSubmit() {
|
||||||
|
buttonSubmit.setDisable(true);
|
||||||
|
|
||||||
|
UserDao dao = DaoFactory.getInstance().createUserDAO();
|
||||||
|
try {
|
||||||
|
int id = dao.readUserId(textFieldUsername.getText());
|
||||||
|
if (id == 0) {
|
||||||
|
handleWrongPasswordOrUsername();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
byte[] salt = dao.readPasswordSalt(id);
|
||||||
|
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
|
md.update(salt);
|
||||||
|
byte[] hash = md.digest(passwordField.getText().getBytes(StandardCharsets.UTF_8));
|
||||||
|
byte[] requiredHash = dao.readPasswordHash(id);
|
||||||
|
if (!Arrays.equals(hash, requiredHash)) {
|
||||||
|
handleWrongPasswordOrUsername();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user = dao.read(id);
|
||||||
|
stage.close();
|
||||||
|
} catch (SQLException | NoSuchAlgorithmException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
src/main/java/de/hitec/nhplus/login/Permissions.java
Normal file
14
src/main/java/de/hitec/nhplus/login/Permissions.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package de.hitec.nhplus.login;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple class holding the bitmasks for all permissions.
|
||||||
|
* This is a class instead of an enum, for ease of use.
|
||||||
|
*
|
||||||
|
* @author Dominiok Säume
|
||||||
|
*/
|
||||||
|
public class Permissions {
|
||||||
|
public final static int EVERYBODY = 0b0;
|
||||||
|
public final static int NURSE = 0b1;
|
||||||
|
public final static int MANAGEMENT = 0b10;
|
||||||
|
public final static int OWNER = 0b100;
|
||||||
|
}
|
120
src/main/java/de/hitec/nhplus/login/User.java
Normal file
120
src/main/java/de/hitec/nhplus/login/User.java
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
package de.hitec.nhplus.login;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The model for a {@link User}.
|
||||||
|
*
|
||||||
|
* @author Dominik Säume
|
||||||
|
*/
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String username;
|
||||||
|
private byte[] passwordSalt;
|
||||||
|
private byte[] passwordHash;
|
||||||
|
private int permissions = 0;
|
||||||
|
private Nurse nurse;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor allows instantiating a {@link User} object with all existing fields.
|
||||||
|
*/
|
||||||
|
public User(
|
||||||
|
int id,
|
||||||
|
String username,
|
||||||
|
byte[] passwordSalt,
|
||||||
|
byte[] passwordHash,
|
||||||
|
int permissions,
|
||||||
|
Nurse nurse
|
||||||
|
) {
|
||||||
|
this.id = id;
|
||||||
|
this.username = username;
|
||||||
|
this.passwordSalt = passwordSalt;
|
||||||
|
this.passwordHash = passwordHash;
|
||||||
|
this.permissions = permissions;
|
||||||
|
this.nurse = nurse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor allows instantiating a {@link User} object.
|
||||||
|
*/
|
||||||
|
public User(
|
||||||
|
String username,
|
||||||
|
int permissions,
|
||||||
|
Nurse nurse
|
||||||
|
) {
|
||||||
|
this.username = username;
|
||||||
|
this.permissions = permissions;
|
||||||
|
this.nurse = nurse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link User} password. The {@link User} will need to be manually stored with the
|
||||||
|
* {@link de.hitec.nhplus.login.database.UserDao UserDao}, for changes to persists.
|
||||||
|
* @param password The new Password
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
try {
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
byte[] salt = new byte[32];
|
||||||
|
random.nextBytes(salt);
|
||||||
|
this.passwordSalt = salt;
|
||||||
|
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
|
md.update(salt);
|
||||||
|
this.passwordHash = md.digest(password.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}catch (NoSuchAlgorithmException exception){
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNursePermissions(){
|
||||||
|
return (permissions & Permissions.NURSE) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasAdminPermissions(){
|
||||||
|
return (permissions & Permissions.MANAGEMENT) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getPasswordSalt() {
|
||||||
|
return passwordSalt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getPasswordHash() {
|
||||||
|
return passwordHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPermissions() {
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermissions(int permissions) {
|
||||||
|
this.permissions = permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Nurse getNurse() {
|
||||||
|
return nurse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNurse(Nurse nurse) {
|
||||||
|
this.nurse = nurse;
|
||||||
|
}
|
||||||
|
}
|
232
src/main/java/de/hitec/nhplus/login/database/UserDao.java
Normal file
232
src/main/java/de/hitec/nhplus/login/database/UserDao.java
Normal file
|
@ -0,0 +1,232 @@
|
||||||
|
package de.hitec.nhplus.login.database;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.datastorage.Dao;
|
||||||
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.login.User;
|
||||||
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link UserDao} is an implementation of the{@link de.hitec.nhplus.datastorage.Dao Dao}
|
||||||
|
* for the {@link User} model.
|
||||||
|
*
|
||||||
|
* @author Dominik Säume
|
||||||
|
*/
|
||||||
|
public class UserDao implements Dao<User> {
|
||||||
|
protected final Connection connection;
|
||||||
|
|
||||||
|
public UserDao(Connection connection) {
|
||||||
|
this.connection = connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try reading a {@link User#id} by its {@link User#username}.
|
||||||
|
* @param username The {@link User#username username} to try reading the {@link User#id id} of.
|
||||||
|
* @return The {@link User#id}. {@code 0} if the {@link User} doesn't exist.
|
||||||
|
*/
|
||||||
|
public int readUserId(String username) throws SQLException {
|
||||||
|
final String SQL = "SELECT id FROM user WHERE username = ?";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setString(1, username);
|
||||||
|
return statement.executeQuery().getInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a {@link User}s {@link User#passwordSalt password salt}.
|
||||||
|
* @param id The {@link User#id} of which the {@link User#passwordSalt password salt} should be read.
|
||||||
|
* @return The {@link User#passwordSalt password salt} as a{@code byte[]}.
|
||||||
|
*/
|
||||||
|
public byte[] readPasswordSalt(int id) throws SQLException {
|
||||||
|
final String SQL = "SELECT passwordSalt FROM user WHERE id = ?";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, id);
|
||||||
|
return statement.executeQuery().getBytes(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a {@link User}s {@link User#passwordHash password hash} for authentication purposes.
|
||||||
|
* @param id The {@link User#id} of which the {@link User#passwordHash password hash} should be read.
|
||||||
|
* @return The {@link User#passwordHash password hash} as a{@code byte[]}.
|
||||||
|
*/
|
||||||
|
public byte[] readPasswordHash(int id) throws SQLException {
|
||||||
|
final String SQL = "SELECT passwordHash FROM user WHERE id = ?";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, id);
|
||||||
|
return statement.executeQuery().getBytes(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User read(int id) throws SQLException {
|
||||||
|
final String SQL = """
|
||||||
|
SELECT
|
||||||
|
user.username,
|
||||||
|
user.passwordSalt,
|
||||||
|
user.passwordHash,
|
||||||
|
user__permissions.permissions,
|
||||||
|
user__nurse.nurseId
|
||||||
|
FROM user
|
||||||
|
LEFT JOIN user__permissions ON user.id = user__permissions.userId
|
||||||
|
LEFT JOIN user__nurse ON user.id = user__nurse.userId
|
||||||
|
WHERE user.id = ?;
|
||||||
|
""";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, id);
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
int nurseId = result.getInt(5);
|
||||||
|
Nurse nurse = null;
|
||||||
|
if (!result.wasNull()) {
|
||||||
|
nurse = DaoFactory.getInstance().createNurseDAO().read(nurseId);
|
||||||
|
}
|
||||||
|
return new User(
|
||||||
|
id,
|
||||||
|
result.getString(1),
|
||||||
|
result.getBytes(2),
|
||||||
|
result.getBytes(3),
|
||||||
|
result.getInt(4),
|
||||||
|
nurse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(User user) throws SQLException {
|
||||||
|
connection.setAutoCommit(false); //Switch to Manual Commit, to do an SQL Transaction
|
||||||
|
final String userSQL = """
|
||||||
|
INSERT INTO user
|
||||||
|
(username, passwordSalt, passwordHash)
|
||||||
|
VALUES (?, ?, ?);
|
||||||
|
""";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(userSQL);
|
||||||
|
statement.setString(1, user.getUsername());
|
||||||
|
statement.setBytes(2, user.getPasswordSalt());
|
||||||
|
statement.setBytes(3, user.getPasswordHash());
|
||||||
|
statement.execute();
|
||||||
|
|
||||||
|
ResultSet generatedKeys = connection.createStatement().executeQuery("SELECT last_insert_rowid()");
|
||||||
|
connection.commit(); //Finish SQL Transaction
|
||||||
|
connection.setAutoCommit(true); //Switch back Mode
|
||||||
|
|
||||||
|
if (!generatedKeys.next()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int newId = generatedKeys.getInt(1);
|
||||||
|
|
||||||
|
final String permissionSQL = """
|
||||||
|
INSERT INTO user__permissions
|
||||||
|
(userId, permissions)
|
||||||
|
VALUES (?, ?);
|
||||||
|
""";
|
||||||
|
PreparedStatement permissionStatement = this.connection.prepareStatement(permissionSQL);
|
||||||
|
permissionStatement.setInt(1, newId);
|
||||||
|
permissionStatement.setInt(2, user.getPermissions());
|
||||||
|
permissionStatement.execute();
|
||||||
|
|
||||||
|
if (user.getNurse() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String nurseSQL = """
|
||||||
|
INSERT INTO user__nurse
|
||||||
|
(userId, nurseId)
|
||||||
|
VALUES (?, ?);
|
||||||
|
""";
|
||||||
|
PreparedStatement nurseStatement = this.connection.prepareStatement(nurseSQL);
|
||||||
|
nurseStatement.setInt(1, newId);
|
||||||
|
nurseStatement.setInt(2, user.getNurse().getId());
|
||||||
|
nurseStatement.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(User user) throws SQLException {
|
||||||
|
final String userSQL = """
|
||||||
|
UPDATE user SET
|
||||||
|
username = ?,
|
||||||
|
passwordSalt = ?,
|
||||||
|
passwordHash = ?
|
||||||
|
WHERE id = ?
|
||||||
|
""";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(userSQL);
|
||||||
|
statement.setString(1, user.getUsername());
|
||||||
|
statement.setBytes(2, user.getPasswordSalt());
|
||||||
|
statement.setBytes(3, user.getPasswordHash());
|
||||||
|
statement.setInt(3, user.getId());
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
final String permissionSQL = """
|
||||||
|
UPDATE user__permissions SET
|
||||||
|
permissions = ?
|
||||||
|
WHERE userId = ?
|
||||||
|
""";
|
||||||
|
PreparedStatement permissionStatement = this.connection.prepareStatement(permissionSQL);
|
||||||
|
permissionStatement.setInt(1, user.getPermissions());
|
||||||
|
permissionStatement.setInt(2, user.getId());
|
||||||
|
permissionStatement.executeUpdate();
|
||||||
|
|
||||||
|
if (user.getNurse() == null) {
|
||||||
|
final String nurseSQL = """
|
||||||
|
DELETE FROM user__nurse WHERE userId = ?
|
||||||
|
""";
|
||||||
|
this.connection.prepareStatement(nurseSQL).executeUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String nurseSQL = """
|
||||||
|
UPDATE user__nurse set
|
||||||
|
nurseId = ?
|
||||||
|
WHERE userId = ?
|
||||||
|
""";
|
||||||
|
PreparedStatement nurseStatement = this.connection.prepareStatement(nurseSQL);
|
||||||
|
nurseStatement.setInt(1, user.getNurse().getId());
|
||||||
|
nurseStatement.setInt(2, user.getId());
|
||||||
|
permissionStatement.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(int id) throws SQLException {
|
||||||
|
final String SQL = """
|
||||||
|
DELETE FROM user WHERE user.id = ?;
|
||||||
|
""";
|
||||||
|
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> readAll() throws SQLException {
|
||||||
|
final String SQL = """
|
||||||
|
SELECT
|
||||||
|
user.id,
|
||||||
|
user.username,
|
||||||
|
user.passwordSalt,
|
||||||
|
user.passwordHash,
|
||||||
|
user__permissions.permissions,
|
||||||
|
user__nurse.nurseId
|
||||||
|
FROM user
|
||||||
|
LEFT JOIN user__permissions ON user.id = user__permissions.userId
|
||||||
|
LEFT JOIN user__nurse ON user.id = user__nurse.userId
|
||||||
|
""";
|
||||||
|
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||||
|
|
||||||
|
List<User> users = new ArrayList<>();
|
||||||
|
while (result.next()) {
|
||||||
|
int nurseId = result.getInt(6);
|
||||||
|
Nurse nurse = null;
|
||||||
|
if (!result.wasNull()) {
|
||||||
|
nurse = DaoFactory.getInstance().createNurseDAO().read(nurseId);
|
||||||
|
}
|
||||||
|
users.add(new User(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getBytes(3),
|
||||||
|
result.getBytes(4),
|
||||||
|
result.getInt(5),
|
||||||
|
nurse
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,175 +1,104 @@
|
||||||
package de.hitec.nhplus.main;
|
package de.hitec.nhplus.main;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.login.Permissions;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
import de.hitec.nhplus.login.User;
|
||||||
|
import de.hitec.nhplus.utils.tab.TabManager;
|
||||||
|
import de.hitec.nhplus.utils.tab.TabStruct;
|
||||||
|
import javafx.event.Event;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.control.SelectionModel;
|
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
import javafx.scene.control.TabPane;
|
import javafx.scene.control.TabPane;
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.scene.layout.BorderPane;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the main window of the application, which holds all tabs.
|
* Controller for the main window of the application, which holds all tabs.
|
||||||
*
|
*
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
* @author Dominik Säume
|
||||||
* @author Armin Ribic
|
|
||||||
* @author Dorian Nemec
|
|
||||||
*/
|
*/
|
||||||
public class MainWindowController {
|
public class MainWindowController {
|
||||||
|
private static MainWindowController instace;
|
||||||
@FXML
|
@FXML
|
||||||
private TabPane mainTabPane;
|
public TabPane mainTabPane;
|
||||||
@FXML
|
private User user;
|
||||||
private AnchorPane patientPage;
|
private TabManager tabManager;
|
||||||
@FXML
|
|
||||||
private Tab patientTab;
|
|
||||||
@FXML
|
|
||||||
private AnchorPane treatmentPage;
|
|
||||||
@FXML
|
|
||||||
private Tab treatmentTab;
|
|
||||||
@FXML
|
|
||||||
private Tab nurseTab;
|
|
||||||
@FXML
|
|
||||||
private TabPane nurseTabPane;
|
|
||||||
@FXML
|
|
||||||
private AnchorPane activeNursePage;
|
|
||||||
@FXML
|
|
||||||
private Tab activeNurseTab;
|
|
||||||
@FXML
|
|
||||||
private AnchorPane lockedNursePage;
|
|
||||||
@FXML
|
|
||||||
private Tab lockedNurseTab;
|
|
||||||
@FXML
|
|
||||||
private AnchorPane medicationPage;
|
|
||||||
@FXML
|
|
||||||
private Tab medicationTab;
|
|
||||||
|
|
||||||
/**
|
public MainWindowController() {
|
||||||
* Initialization method that is called after the binding of all the fields.
|
instace = this;
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
|
||||||
loadPatientPage();
|
|
||||||
mainTabPane.getSelectionModel().select(patientTab);
|
|
||||||
|
|
||||||
patientTab.setOnSelectionChanged(event -> loadPatientPage());
|
|
||||||
treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage());
|
|
||||||
nurseTab.setOnSelectionChanged(event -> loadNursePage());
|
|
||||||
medicationTab.setOnSelectionChanged(event -> loadMedicationPage());
|
|
||||||
|
|
||||||
|
|
||||||
nurseTabPane.getSelectionModel().select(activeNurseTab);
|
|
||||||
|
|
||||||
activeNurseTab.setOnSelectionChanged(event -> loadActiveNursePage());
|
|
||||||
lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the patient page into its tab.
|
* Method copying the idea of a singleton, to allow getting the current {@link User}.
|
||||||
*/
|
*/
|
||||||
private void loadPatientPage() {
|
public static MainWindowController getInstance() {
|
||||||
try {
|
return instace;
|
||||||
BorderPane patientsPane = FXMLLoader.load(
|
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/patient/AllPatientView.fxml"))
|
|
||||||
);
|
|
||||||
patientPage.getChildren().setAll(patientsPane);
|
|
||||||
AnchorPane.setTopAnchor(patientsPane, 0d);
|
|
||||||
AnchorPane.setBottomAnchor(patientsPane, 0d);
|
|
||||||
AnchorPane.setLeftAnchor(patientsPane, 0d);
|
|
||||||
AnchorPane.setRightAnchor(patientsPane, 0d);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the {@link } page into its tab.
|
* JavaFX Initialization method that is called after the binding of all the fields.
|
||||||
|
*
|
||||||
|
* @param user The logged in {@link User}.
|
||||||
*/
|
*/
|
||||||
private void loadTreatmentsPage() {
|
@FXML
|
||||||
try {
|
public void initialize(User user) {
|
||||||
BorderPane treatmentsPane = FXMLLoader.load(
|
instace = this;
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/treatment/AllTreatmentView.fxml"))
|
this.user = user;
|
||||||
);
|
this.tabManager = new TabManager(user);
|
||||||
treatmentPage.getChildren().setAll(treatmentsPane);
|
setupTabs();
|
||||||
AnchorPane.setTopAnchor(treatmentsPane, 0d);
|
|
||||||
AnchorPane.setBottomAnchor(treatmentsPane, 0d);
|
|
||||||
AnchorPane.setLeftAnchor(treatmentsPane, 0d);
|
|
||||||
AnchorPane.setRightAnchor(treatmentsPane, 0d);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the nurse page into its tab.
|
* Sets up all Tabs Accessible, with help of the {@link TabManager}.
|
||||||
*/
|
*/
|
||||||
private void loadNursePage() {
|
private void setupTabs() {
|
||||||
SelectionModel<Tab> selectionModel = nurseTabPane.getSelectionModel();
|
tabManager.setupTab(mainTabPane, new TabStruct(
|
||||||
Tab selectedTab = selectionModel.getSelectedItem();
|
"Patienten",
|
||||||
if(selectedTab == activeNurseTab){
|
"/de/hitec/nhplus/patient/AllPatientView.fxml",
|
||||||
loadActiveNursePage();
|
Permissions.NURSE
|
||||||
}
|
));
|
||||||
if(selectedTab == lockedNurseTab){
|
tabManager.setupSubTabPane(mainTabPane, "Behandlungen", Permissions.NURSE, List.of(
|
||||||
loadLockedNursePage();
|
new TabStruct(
|
||||||
}
|
"Behandlungen",
|
||||||
|
"/de/hitec/nhplus/treatment/AllTreatmentView.fxml",
|
||||||
|
Permissions.NURSE
|
||||||
|
),
|
||||||
|
new TabStruct(
|
||||||
|
"Gesperrte Behandlungen",
|
||||||
|
"/de/hitec/nhplus/treatment/LockedTreatmentView.fxml",
|
||||||
|
Permissions.NURSE
|
||||||
|
)
|
||||||
|
));
|
||||||
|
tabManager.setupSubTabPane(mainTabPane, "Pfleger", Permissions.EVERYBODY, List.of(
|
||||||
|
new TabStruct(
|
||||||
|
"Pfleger",
|
||||||
|
"/de/hitec/nhplus/nurse/AllNurseView.fxml",
|
||||||
|
Permissions.NURSE | Permissions.MANAGEMENT | Permissions.OWNER
|
||||||
|
),
|
||||||
|
new TabStruct(
|
||||||
|
"Gesperrte Pfleger",
|
||||||
|
"/de/hitec/nhplus/nurse/LockedNurseView.fxml",
|
||||||
|
Permissions.MANAGEMENT | Permissions.OWNER
|
||||||
|
)
|
||||||
|
));
|
||||||
|
tabManager.setupSubTabPane(mainTabPane, "Medikamente", Permissions.MANAGEMENT, List.of(
|
||||||
|
new TabStruct(
|
||||||
|
"Medikamente",
|
||||||
|
"/de/hitec/nhplus/medication/AllMedicationView.fxml",
|
||||||
|
Permissions.MANAGEMENT
|
||||||
|
), new TabStruct(
|
||||||
|
"Veraltete Medikamente",
|
||||||
|
"/de/hitec/nhplus/medication/DeprecatedMedicationView.fxml",
|
||||||
|
Permissions.MANAGEMENT
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
Tab defaultTab = mainTabPane.getTabs().get(0);
|
||||||
|
mainTabPane.getSelectionModel().select(defaultTab);
|
||||||
|
defaultTab.getOnSelectionChanged().handle(new Event(Event.ANY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public User getUser() {
|
||||||
* Loads the active {@link Nurse} page into its tab.
|
return user;
|
||||||
*/
|
|
||||||
private void loadActiveNursePage() {
|
|
||||||
try {
|
|
||||||
BorderPane activeNursePane = FXMLLoader.load(
|
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/AllNurseView.fxml"))
|
|
||||||
);
|
|
||||||
activeNursePage.getChildren().setAll(activeNursePane);
|
|
||||||
AnchorPane.setTopAnchor(activeNursePane, 0d);
|
|
||||||
AnchorPane.setBottomAnchor(activeNursePane, 0d);
|
|
||||||
AnchorPane.setLeftAnchor(activeNursePane, 0d);
|
|
||||||
AnchorPane.setRightAnchor(activeNursePane, 0d);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the locked {@link Nurse} page into its tab.
|
|
||||||
*/
|
|
||||||
private void loadLockedNursePage() {
|
|
||||||
try {
|
|
||||||
BorderPane lockedNursePane = FXMLLoader.load(
|
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/LockedNurseView.fxml"))
|
|
||||||
);
|
|
||||||
lockedNursePage.getChildren().setAll(lockedNursePane);
|
|
||||||
AnchorPane.setTopAnchor(lockedNursePane, 0d);
|
|
||||||
AnchorPane.setBottomAnchor(lockedNursePane, 0d);
|
|
||||||
AnchorPane.setLeftAnchor(lockedNursePane, 0d);
|
|
||||||
AnchorPane.setRightAnchor(lockedNursePane, 0d);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the medication page into its tab.
|
|
||||||
*/
|
|
||||||
private void loadMedicationPage() {
|
|
||||||
try {
|
|
||||||
BorderPane medicationPane = FXMLLoader.load(
|
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/medication/AllMedicationView.fxml"))
|
|
||||||
);
|
|
||||||
medicationPage.getChildren().setAll(medicationPane);
|
|
||||||
AnchorPane.setTopAnchor(medicationPane, 0d);
|
|
||||||
AnchorPane.setBottomAnchor(medicationPane, 0d);
|
|
||||||
AnchorPane.setLeftAnchor(medicationPane, 0d);
|
|
||||||
AnchorPane.setRightAnchor(medicationPane, 0d);
|
|
||||||
} catch (IOException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.SelectionModel;
|
import javafx.scene.control.SelectionModel;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
|
@ -48,6 +49,8 @@ public class AllMedicationController {
|
||||||
private TableColumn<Medication, String> columnAdministrationMethod;
|
private TableColumn<Medication, String> columnAdministrationMethod;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Medication, Integer> columnCurrentStock;
|
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||||
|
@FXML
|
||||||
|
public Button buttonChangeAvailable;
|
||||||
|
|
||||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||||
private MedicationDao dao;
|
private MedicationDao dao;
|
||||||
|
@ -57,7 +60,7 @@ public class AllMedicationController {
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||||
|
@ -82,6 +85,7 @@ public class AllMedicationController {
|
||||||
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
||||||
|
|
||||||
this.tableView.setItems(this.medications);
|
this.tableView.setItems(this.medications);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +94,7 @@ public class AllMedicationController {
|
||||||
public void readAllAndShowInTableView() {
|
public void readAllAndShowInTableView() {
|
||||||
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
||||||
try {
|
try {
|
||||||
this.medications.setAll(dao.readAll());
|
this.medications.setAll(dao.readAllAvailable());
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -120,6 +124,22 @@ public class AllMedicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleChangeAvailable() {
|
||||||
|
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
selectedItem.setIsDeprecated(true);
|
||||||
|
this.dao.update(selectedItem);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
this.readAllAndShowInTableView();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
package de.hitec.nhplus.medication;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class DeprecatedMedicationController {
|
||||||
|
@FXML
|
||||||
|
private TableView<Medication> tableView;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, Integer> columnId;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, String> columnName;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, String> columnManufacturer;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, String> columnIngredient;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, String> columnPossibleSideEffects;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, String> columnAdministrationMethod;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||||
|
@FXML
|
||||||
|
public Button buttonChangeAvailable;
|
||||||
|
|
||||||
|
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||||
|
private MedicationDao dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialization method that is called after the binding of all the fields.
|
||||||
|
*/
|
||||||
|
public void initialize() {
|
||||||
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
|
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||||
|
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
||||||
|
this.columnIngredient.setCellValueFactory(
|
||||||
|
cellData -> {
|
||||||
|
Medication medication = cellData.getValue();
|
||||||
|
List<Ingredient> ingredients = medication.getIngredients();
|
||||||
|
if (ingredients.isEmpty()) {
|
||||||
|
return new SimpleStringProperty("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SimpleStringProperty(
|
||||||
|
ingredients
|
||||||
|
.stream()
|
||||||
|
.map(ingredient -> ingredient.getName())
|
||||||
|
.collect(Collectors.joining("\n"))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
|
||||||
|
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
|
||||||
|
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
||||||
|
|
||||||
|
this.tableView.setItems(this.medications);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method to read all data and set it to the table view.
|
||||||
|
*/
|
||||||
|
public void readAllAndShowInTableView() {
|
||||||
|
this.medications.clear();
|
||||||
|
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
||||||
|
try {
|
||||||
|
this.medications.setAll(this.dao.readAllDeprecated());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@FXML
|
||||||
|
public void handleChangeAvailable(){
|
||||||
|
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
selectedItem.setIsDeprecated(false);
|
||||||
|
this.dao.update(selectedItem);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
this.readAllAndShowInTableView();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -40,7 +40,7 @@ public class IngredientListCell extends ListCell<Ingredient> {
|
||||||
BUTTON_PADDING_Y,
|
BUTTON_PADDING_Y,
|
||||||
BUTTON_PADDING_X
|
BUTTON_PADDING_X
|
||||||
));
|
));
|
||||||
deleteButton.setOnAction(event -> getListView().getItems().remove(this));
|
deleteButton.setOnAction(event -> getListView().getItems().remove(getItem()));
|
||||||
|
|
||||||
// Calculate Delete Button Width
|
// Calculate Delete Button Width
|
||||||
Text textNode = new Text(deleteButton.getText());
|
Text textNode = new Text(deleteButton.getText());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.hitec.nhplus.medication;
|
package de.hitec.nhplus.medication;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleListProperty;
|
import javafx.beans.property.SimpleListProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
@ -23,6 +24,7 @@ public class Medication {
|
||||||
private final SimpleStringProperty possibleSideEffects;
|
private final SimpleStringProperty possibleSideEffects;
|
||||||
private final SimpleStringProperty administrationMethod;
|
private final SimpleStringProperty administrationMethod;
|
||||||
private final SimpleIntegerProperty currentStock;
|
private final SimpleIntegerProperty currentStock;
|
||||||
|
private final SimpleBooleanProperty isDeprecated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor allows instantiating a {@link Medication} object,
|
* This constructor allows instantiating a {@link Medication} object,
|
||||||
|
@ -45,6 +47,7 @@ public class Medication {
|
||||||
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
|
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
|
||||||
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
||||||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
this.currentStock = new SimpleIntegerProperty(currentStock);
|
||||||
|
this.isDeprecated = new SimpleBooleanProperty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +60,8 @@ public class Medication {
|
||||||
List<Ingredient> ingredients,
|
List<Ingredient> ingredients,
|
||||||
String possibleSideEffects,
|
String possibleSideEffects,
|
||||||
String administrationMethod,
|
String administrationMethod,
|
||||||
int currentStock
|
int currentStock,
|
||||||
|
boolean isDeprecated
|
||||||
) {
|
) {
|
||||||
this.id = new SimpleIntegerProperty(id);
|
this.id = new SimpleIntegerProperty(id);
|
||||||
this.name = new SimpleStringProperty(name);
|
this.name = new SimpleStringProperty(name);
|
||||||
|
@ -66,6 +70,7 @@ public class Medication {
|
||||||
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
|
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
|
||||||
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
||||||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
this.currentStock = new SimpleIntegerProperty(currentStock);
|
||||||
|
this.isDeprecated = new SimpleBooleanProperty(isDeprecated);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -84,6 +89,18 @@ public class Medication {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeprecated() {
|
||||||
|
return isDeprecated.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleBooleanProperty isDeprecatedProperty() {
|
||||||
|
return isDeprecated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDeprecated(boolean isDeprecated) {
|
||||||
|
this.isDeprecated.set(isDeprecated);
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name.set(name);
|
this.name.set(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class MedicationModalController {
|
||||||
@FXML
|
@FXML
|
||||||
public Button buttonSave;
|
public Button buttonSave;
|
||||||
|
|
||||||
|
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Medication medication;
|
private Medication medication;
|
||||||
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
connection.setAutoCommit(false); //Switch to Manual Commit, to do an SQL Transaction
|
connection.setAutoCommit(false); //Switch to Manual Commit, to do an SQL Transaction
|
||||||
final String medicationSQL = """
|
final String medicationSQL = """
|
||||||
INSERT INTO medication
|
INSERT INTO medication
|
||||||
(name, manufacturer, possibleSideEffects, administrationMethod, currentStock)
|
(name, manufacturer, possibleSideEffects, administrationMethod, currentStock, isDeprecated)
|
||||||
VALUES (?, ?, ?, ?, ?);
|
VALUES (?, ?, ?, ?, ?, ?);
|
||||||
""";
|
""";
|
||||||
PreparedStatement medicationStatement = this.connection.prepareStatement(medicationSQL);
|
PreparedStatement medicationStatement = this.connection.prepareStatement(medicationSQL);
|
||||||
medicationStatement.setString(1, medication.getName());
|
medicationStatement.setString(1, medication.getName());
|
||||||
|
@ -41,6 +41,7 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
medicationStatement.setString(3, medication.getPossibleSideEffects());
|
medicationStatement.setString(3, medication.getPossibleSideEffects());
|
||||||
medicationStatement.setString(4, medication.getAdministrationMethod());
|
medicationStatement.setString(4, medication.getAdministrationMethod());
|
||||||
medicationStatement.setInt(5, medication.getCurrentStock());
|
medicationStatement.setInt(5, medication.getCurrentStock());
|
||||||
|
medicationStatement.setBoolean(6, medication.isDeprecated());
|
||||||
medicationStatement.execute();
|
medicationStatement.execute();
|
||||||
|
|
||||||
ResultSet generatedKeys = connection.createStatement().executeQuery("SELECT last_insert_rowid()");
|
ResultSet generatedKeys = connection.createStatement().executeQuery("SELECT last_insert_rowid()");
|
||||||
|
@ -103,12 +104,111 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
new ArrayList<>(),
|
new ArrayList<>(),
|
||||||
result.getString(4),
|
result.getString(4),
|
||||||
result.getString(5),
|
result.getString(5),
|
||||||
result.getInt(6)
|
result.getInt(6),
|
||||||
|
result.getBoolean(7)
|
||||||
);
|
);
|
||||||
medications.add(medication);
|
medications.add(medication);
|
||||||
}
|
}
|
||||||
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
||||||
String ingredientName = result.getString(7);
|
String ingredientName = result.getString(8);
|
||||||
|
if(ingredientName == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ingredients.add(new Ingredient(ingredientName));
|
||||||
|
lastMedicationId = currentMedicationId;
|
||||||
|
}
|
||||||
|
for (Medication medication : medications) {
|
||||||
|
List<Ingredient> ingredients = ingredientMap.get(medication.getId());
|
||||||
|
if(ingredients.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
medication.setIngredients(ingredientMap.get(medication.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return medications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Medication> readAllDeprecated() throws SQLException {
|
||||||
|
final String SQL = """
|
||||||
|
SELECT medication.*, medication_ingredient.name
|
||||||
|
FROM medication LEFT JOIN
|
||||||
|
medication_ingredient
|
||||||
|
ON medication.id = medication_ingredient.id
|
||||||
|
WHERE medication.isDeprecated = true
|
||||||
|
""";
|
||||||
|
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||||
|
|
||||||
|
List<Medication> medications = new ArrayList<>();
|
||||||
|
Map<Integer, List<Ingredient>> ingredientMap = new HashMap<>();
|
||||||
|
|
||||||
|
int currentMedicationId;
|
||||||
|
int lastMedicationId = -1;
|
||||||
|
while (result.next()) {
|
||||||
|
currentMedicationId = result.getInt(1);
|
||||||
|
if (currentMedicationId != lastMedicationId) {
|
||||||
|
Medication medication = new Medication(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getString(3),
|
||||||
|
new ArrayList<>(),
|
||||||
|
result.getString(4),
|
||||||
|
result.getString(5),
|
||||||
|
result.getInt(6),
|
||||||
|
result.getBoolean(7)
|
||||||
|
);
|
||||||
|
medications.add(medication);
|
||||||
|
}
|
||||||
|
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
||||||
|
String ingredientName = result.getString(8);
|
||||||
|
if(ingredientName == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ingredients.add(new Ingredient(ingredientName));
|
||||||
|
lastMedicationId = currentMedicationId;
|
||||||
|
}
|
||||||
|
for (Medication medication : medications) {
|
||||||
|
List<Ingredient> ingredients = ingredientMap.get(medication.getId());
|
||||||
|
if(ingredients.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
medication.setIngredients(ingredientMap.get(medication.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return medications;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Medication> readAllAvailable() throws SQLException {
|
||||||
|
final String SQL = """
|
||||||
|
SELECT medication.*, medication_ingredient.name
|
||||||
|
FROM medication LEFT JOIN
|
||||||
|
medication_ingredient
|
||||||
|
ON medication.id = medication_ingredient.id
|
||||||
|
WHERE medication.isDeprecated = false
|
||||||
|
""";
|
||||||
|
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||||
|
|
||||||
|
List<Medication> medications = new ArrayList<>();
|
||||||
|
Map<Integer, List<Ingredient>> ingredientMap = new HashMap<>();
|
||||||
|
|
||||||
|
int currentMedicationId;
|
||||||
|
int lastMedicationId = -1;
|
||||||
|
while (result.next()) {
|
||||||
|
currentMedicationId = result.getInt(1);
|
||||||
|
if (currentMedicationId != lastMedicationId) {
|
||||||
|
Medication medication = new Medication(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getString(3),
|
||||||
|
new ArrayList<>(),
|
||||||
|
result.getString(4),
|
||||||
|
result.getString(5),
|
||||||
|
result.getInt(6),
|
||||||
|
result.getBoolean(7)
|
||||||
|
);
|
||||||
|
medications.add(medication);
|
||||||
|
}
|
||||||
|
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
||||||
|
String ingredientName = result.getString(8);
|
||||||
if(ingredientName == null){
|
if(ingredientName == null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +234,8 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
manufacturer = ?,
|
manufacturer = ?,
|
||||||
possibleSideEffects = ?,
|
possibleSideEffects = ?,
|
||||||
administrationMethod = ?,
|
administrationMethod = ?,
|
||||||
currentStock = ?
|
currentStock = ?,
|
||||||
|
isDeprecated = ?
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
""";
|
""";
|
||||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
@ -143,7 +244,8 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
preparedStatement.setString(3, medication.getPossibleSideEffects());
|
preparedStatement.setString(3, medication.getPossibleSideEffects());
|
||||||
preparedStatement.setString(4, medication.getAdministrationMethod());
|
preparedStatement.setString(4, medication.getAdministrationMethod());
|
||||||
preparedStatement.setInt(5, medication.getCurrentStock());
|
preparedStatement.setInt(5, medication.getCurrentStock());
|
||||||
preparedStatement.setInt(6, medication.getId());
|
preparedStatement.setBoolean(6, medication.isDeprecated());
|
||||||
|
preparedStatement.setInt(7, medication.getId());
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
|
|
||||||
final String ingredientDeleteSQL = """
|
final String ingredientDeleteSQL = """
|
||||||
|
@ -191,7 +293,8 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
List.of(),
|
List.of(),
|
||||||
result.getString(4),
|
result.getString(4),
|
||||||
result.getString(5),
|
result.getString(5),
|
||||||
result.getInt(6)
|
result.getInt(6),
|
||||||
|
result.getBoolean(7)
|
||||||
);
|
);
|
||||||
|
|
||||||
List<Ingredient> ingredients = new ArrayList<>();
|
List<Ingredient> ingredients = new ArrayList<>();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package de.hitec.nhplus.nurse;
|
package de.hitec.nhplus.nurse;
|
||||||
|
|
||||||
import static de.hitec.nhplus.utils.Validator.*;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.login.Permissions;
|
||||||
|
import de.hitec.nhplus.main.MainWindowController;
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
import de.hitec.nhplus.nurse.database.NurseDao;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -17,11 +17,15 @@ import javafx.scene.control.cell.TextFieldTableCell;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static de.hitec.nhplus.utils.Validator.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller for viewing all {@link Nurse}s.
|
* The controller for viewing all {@link Nurse}s.
|
||||||
*
|
*
|
||||||
* @author Dominik Säume
|
* @author Dominik Säume
|
||||||
* @author Ole Kück
|
* @author Ole Kück
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
*/
|
*/
|
||||||
public class AllNurseController {
|
public class AllNurseController {
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -47,12 +51,17 @@ public class AllNurseController {
|
||||||
|
|
||||||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||||
private NurseDao dao;
|
private NurseDao dao;
|
||||||
|
private boolean hasEditPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization method that is called after the binding of all the fields.
|
* Initialization method that is called after the binding of all the fields.
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
int editPermissions = Permissions.MANAGEMENT | Permissions.OWNER;
|
||||||
|
int userPermissions = MainWindowController.getInstance().getUser().getPermissions();
|
||||||
|
hasEditPermissions = (userPermissions & editPermissions) != 0;
|
||||||
|
|
||||||
this.readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
|
@ -69,8 +78,14 @@ public class AllNurseController {
|
||||||
|
|
||||||
this.tableView.setItems(this.nurses);
|
this.tableView.setItems(this.nurses);
|
||||||
|
|
||||||
|
|
||||||
this.buttonAdd.setDisable(true);
|
this.buttonAdd.setDisable(true);
|
||||||
ChangeListener<String> inputNewNurseValidationListener = (observableValue, oldText, newText)->
|
if (!hasEditPermissions) {
|
||||||
|
this.buttonLock.setDisable(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangeListener<String> inputNewNurseValidationListener = (observableValue, oldText, newText) ->
|
||||||
{
|
{
|
||||||
boolean isValid = isValidFirstName(this.textFieldFirstName.getText())
|
boolean isValid = isValidFirstName(this.textFieldFirstName.getText())
|
||||||
&& isValidSurName(this.textFieldSurName.getText())
|
&& isValidSurName(this.textFieldSurName.getText())
|
||||||
|
@ -87,12 +102,12 @@ public class AllNurseController {
|
||||||
/**
|
/**
|
||||||
* Internal method to read all data and set it to the table view.
|
* Internal method to read all data and set it to the table view.
|
||||||
*/
|
*/
|
||||||
private void readAllAndShowInTableView(){
|
private void readAllAndShowInTableView() {
|
||||||
this.nurses.clear();
|
this.nurses.clear();
|
||||||
this.dao = DaoFactory.getInstance().createNurseDAO();
|
this.dao = DaoFactory.getInstance().createNurseDAO();
|
||||||
try {
|
try {
|
||||||
this.nurses.setAll(this.dao.readAllActive());
|
this.nurses.setAll(this.dao.readAllActive());
|
||||||
}catch (SQLException exception){
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,15 +121,25 @@ public class AllNurseController {
|
||||||
this.textFieldPhoneNumber.clear();
|
this.textFieldPhoneNumber.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method that stores the changes in the database.
|
||||||
|
*/
|
||||||
|
private void doUpdate(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||||
|
try {
|
||||||
|
this.dao.update(event.getRowValue());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleAdd(){
|
public void handleAdd() {
|
||||||
String surname=this.textFieldSurName.getText();
|
String surname = this.textFieldSurName.getText();
|
||||||
String firstName=this.textFieldFirstName.getText();
|
String firstName = this.textFieldFirstName.getText();
|
||||||
String phoneNumber=this.textFieldPhoneNumber.getText();
|
String phoneNumber = this.textFieldPhoneNumber.getText();
|
||||||
try {
|
try {
|
||||||
this.dao.create(new Nurse(firstName, surname, phoneNumber));
|
this.dao.create(new Nurse(firstName, surname, phoneNumber));
|
||||||
}
|
} catch (SQLException exception) {
|
||||||
catch (SQLException exception){
|
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
|
@ -122,19 +147,66 @@ public class AllNurseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleLock(){
|
public void handleLock() {
|
||||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
if (selectedItem == null){
|
if (selectedItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
selectedItem.setLocked(true);
|
selectedItem.setLocked(true);
|
||||||
this.dao.update(selectedItem);
|
this.dao.update(selectedItem);
|
||||||
}catch (SQLException exception){
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleOnEditSurname(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||||
|
if(!hasEditPermissions){
|
||||||
|
event.getTableView().refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String newSurName = event.getNewValue();
|
||||||
|
if (!isValidSurName(newSurName)) {
|
||||||
|
showValidationError("Nachname");
|
||||||
|
event.getTableView().refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.getRowValue().setSurName(newSurName);
|
||||||
|
this.doUpdate(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleOnEditFirstname(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||||
|
if(!hasEditPermissions){
|
||||||
|
event.getTableView().refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String newFirstName = event.getNewValue();
|
||||||
|
if (!isValidFirstName(newFirstName)) {
|
||||||
|
showValidationError("Vorname");
|
||||||
|
event.getTableView().refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.getRowValue().setFirstName(newFirstName);
|
||||||
|
this.doUpdate(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleOnEditPhoneNumber(TableColumn.CellEditEvent<Nurse, String> event) {
|
||||||
|
if(!hasEditPermissions){
|
||||||
|
event.getTableView().refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String newPhoneNumber = event.getNewValue();
|
||||||
|
if (!isValidPhoneNumber(newPhoneNumber)) {
|
||||||
|
showValidationError("Telefonnummer");
|
||||||
|
event.getTableView().refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.getRowValue().setPhoneNumber(newPhoneNumber);
|
||||||
|
this.doUpdate(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,11 @@ public class LockedNurseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void handleMouseClick() {
|
public void handleMouseClick() {
|
||||||
Nurse nurse = tableView.getSelectionModel().getSelectedItem();
|
Nurse nurse = tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if(nurse == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean canBeDeleted = nurse.calculateDeleteDate().isBefore(LocalDate.now());
|
boolean canBeDeleted = nurse.calculateDeleteDate().isBefore(LocalDate.now());
|
||||||
buttonDelete.setDisable(!canBeDeleted);
|
buttonDelete.setDisable(!canBeDeleted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Nurse extends Person {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor allows instantiating a {@link Nurse} object with
|
* This constructor allows instantiating a {@link Nurse} object with
|
||||||
* specifying if the nurse is locked or not.
|
* specifying whether the {@link Nurse} is locked or not.
|
||||||
*/
|
*/
|
||||||
public Nurse(
|
public Nurse(
|
||||||
String firstName,
|
String firstName,
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
* Read all database entries of active {@link Nurse}s into a {@link List} of model instances.
|
* Read all database entries of active {@link Nurse}s into a {@link List} of model instances.
|
||||||
*/
|
*/
|
||||||
public List<Nurse> readAllActive() throws SQLException {
|
public List<Nurse> readAllActive() throws SQLException {
|
||||||
final String SQL = "SELECT * FROM nurse WHERE isLocked=false";
|
final String SQL = "SELECT * FROM nurse WHERE isLocked = false";
|
||||||
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
* Read all database entries of locked {@link Nurse}s into a {@link List} of model instances.
|
* Read all database entries of locked {@link Nurse}s into a {@link List} of model instances.
|
||||||
*/
|
*/
|
||||||
public List<Nurse> readAllLocked() throws SQLException {
|
public List<Nurse> readAllLocked() throws SQLException {
|
||||||
final String SQL = "SELECT * FROM nurse WHERE isLocked=true";
|
final String SQL = "SELECT * FROM nurse WHERE isLocked = true";
|
||||||
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,4 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
statement.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class AllPatientController {
|
||||||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
String newFirstName = event.getNewValue();
|
String newFirstName = event.getNewValue();
|
||||||
if (!isValidFirstName(newFirstName)) {
|
if (!isValidFirstName(newFirstName)) {
|
||||||
showValidationError("First Name");
|
showValidationError("Vorname");
|
||||||
event.getTableView().refresh();
|
event.getTableView().refresh();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ public class AllPatientController {
|
||||||
public void handleOnEditSurname(TableColumn.CellEditEvent<Patient, String> event) {
|
public void handleOnEditSurname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
String newSurName = event.getNewValue();
|
String newSurName = event.getNewValue();
|
||||||
if (!isValidSurName(newSurName)) {
|
if (!isValidSurName(newSurName)) {
|
||||||
showValidationError("Sur Name");
|
showValidationError("Nachname");
|
||||||
event.getTableView().refresh();
|
event.getTableView().refresh();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ public class AllPatientController {
|
||||||
public void handleOnEditDateOfBirth(TableColumn.CellEditEvent<Patient, String> event) {
|
public void handleOnEditDateOfBirth(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
String newDateString = event.getNewValue();
|
String newDateString = event.getNewValue();
|
||||||
if (!isValidDate(newDateString)) {
|
if (!isValidDate(newDateString)) {
|
||||||
showValidationError("Date");
|
showValidationError("Geburtstag");
|
||||||
event.getTableView().refresh();
|
event.getTableView().refresh();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class AllPatientController {
|
||||||
public void handleOnEditCareLevel(TableColumn.CellEditEvent<Patient, String> event) {
|
public void handleOnEditCareLevel(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
String newCareLevel = event.getNewValue();
|
String newCareLevel = event.getNewValue();
|
||||||
if (!isValidCareLevel(newCareLevel)) {
|
if (!isValidCareLevel(newCareLevel)) {
|
||||||
showValidationError("Care Level");
|
showValidationError("Pflegegrad");
|
||||||
event.getTableView().refresh();
|
event.getTableView().refresh();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ public class AllPatientController {
|
||||||
public void handleOnEditRoomNumber(TableColumn.CellEditEvent<Patient, String> event) {
|
public void handleOnEditRoomNumber(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
String newRoomNumber = event.getNewValue();
|
String newRoomNumber = event.getNewValue();
|
||||||
if (!isValidRoomNumber(newRoomNumber)) {
|
if (!isValidRoomNumber(newRoomNumber)) {
|
||||||
showValidationError("Room Number");
|
showValidationError("Raum");
|
||||||
event.getTableView().refresh();
|
event.getTableView().refresh();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +28,8 @@ import java.util.ArrayList;
|
||||||
*
|
*
|
||||||
* @author Bernd Heidemann
|
* @author Bernd Heidemann
|
||||||
* @author Dominik Säume
|
* @author Dominik Säume
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
*/
|
*/
|
||||||
public class AllTreatmentController {
|
public class AllTreatmentController {
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ public class AllTreatmentController {
|
||||||
public ComboBox<String> comboBoxNurseSelection;
|
public ComboBox<String> comboBoxNurseSelection;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button buttonDelete;
|
private Button buttonLock;
|
||||||
|
|
||||||
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
||||||
private TreatmentDao dao;
|
private TreatmentDao dao;
|
||||||
|
@ -75,7 +78,7 @@ public class AllTreatmentController {
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
readAllAndShowInTableView();
|
|
||||||
comboBoxPatientSelection.setItems(patientSelection);
|
comboBoxPatientSelection.setItems(patientSelection);
|
||||||
comboBoxPatientSelection.getSelectionModel().select("alle");
|
comboBoxPatientSelection.getSelectionModel().select("alle");
|
||||||
|
|
||||||
|
@ -100,15 +103,16 @@ public class AllTreatmentController {
|
||||||
this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
|
this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
|
||||||
this.tableView.setItems(this.treatments);
|
this.tableView.setItems(this.treatments);
|
||||||
|
|
||||||
this.buttonDelete.setDisable(true);
|
this.buttonLock.setDisable(true);
|
||||||
this.tableView
|
this.tableView
|
||||||
.getSelectionModel()
|
.getSelectionModel()
|
||||||
.selectedItemProperty()
|
.selectedItemProperty()
|
||||||
.addListener((observableValue, oldTreatment, newTreatment) ->
|
.addListener((observableValue, oldTreatment, newTreatment) ->
|
||||||
AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null)
|
AllTreatmentController.this.buttonLock.setDisable(newTreatment == null)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.createComboBoxData();
|
this.createComboBoxData();
|
||||||
|
readAllAndShowInTableView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,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();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +140,7 @@ public class AllTreatmentController {
|
||||||
this.patientSelection.add(patient.getSurName());
|
this.patientSelection.add(patient.getSurName());
|
||||||
}
|
}
|
||||||
|
|
||||||
nurseList = (ArrayList<Nurse>) nurseDao.readAll();
|
nurseList = (ArrayList<Nurse>) nurseDao.readAllActive();
|
||||||
for (Nurse nurse : nurseList) {
|
for (Nurse nurse : nurseList) {
|
||||||
this.nurseSelection.add(nurse.getSurName());
|
this.nurseSelection.add(nurse.getSurName());
|
||||||
}
|
}
|
||||||
|
@ -258,18 +262,6 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void handleDelete() {
|
|
||||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
|
||||||
Treatment t = this.treatments.remove(index);
|
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
|
||||||
try {
|
|
||||||
dao.delete(t.getId());
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleNewTreatment() {
|
public void handleNewTreatment() {
|
||||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||||
|
@ -316,4 +308,22 @@ public class AllTreatmentController {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleLock(){
|
||||||
|
Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
selectedItem.setLocked(true);
|
||||||
|
this.dao.update(selectedItem);
|
||||||
|
}catch (SQLException exception){
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
readAllAndShowInTableView();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
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.treatment.database.TreatmentDao;
|
||||||
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for all locked treatments.
|
||||||
|
*
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
|
*/
|
||||||
|
public class LockedTreatmentController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public Button buttonUnlock;
|
||||||
|
@FXML
|
||||||
|
public TableView<Treatment> tableView;
|
||||||
|
@FXML
|
||||||
|
public TableColumn<Treatment, Long> columnId;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Treatment, String> columnPatient;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Treatment, String> columnNurse;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Treatment, String> columnDeleteDate;
|
||||||
|
|
||||||
|
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
||||||
|
private TreatmentDao treatmentDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method allows initializing a {@link LockedTreatmentController} object
|
||||||
|
* that is called after the binding of all the fields.
|
||||||
|
*/
|
||||||
|
public void initialize() {
|
||||||
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
|
|
||||||
|
this.columnPatient.setCellValueFactory(
|
||||||
|
cellData -> {
|
||||||
|
Patient patient = cellData.getValue().getPatient();
|
||||||
|
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.columnNurse.setCellValueFactory(
|
||||||
|
cellData -> {
|
||||||
|
Nurse nurse = cellData.getValue().getNurse();
|
||||||
|
return new SimpleStringProperty(nurse.getSurName() + ", " + nurse.getFirstName());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.columnDeleteDate.setCellValueFactory(cellData -> new SimpleStringProperty(
|
||||||
|
DateConverter.convertLocalDateToString(cellData.getValue().calculateDeleteDate())));
|
||||||
|
|
||||||
|
|
||||||
|
this.tableView.setItems(this.treatments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads all locked {@link Treatment} data and shows it in the table.
|
||||||
|
*/
|
||||||
|
private void readAllAndShowInTableView() {
|
||||||
|
this.treatments.clear();
|
||||||
|
|
||||||
|
this.treatmentDao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
|
try {
|
||||||
|
this.treatments.addAll(this.treatmentDao.readAllLocked());
|
||||||
|
deleteOldTreatments();
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all {@link Treatment}s which are older than allowed.
|
||||||
|
*/
|
||||||
|
private void deleteOldTreatments() {
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
for (Treatment treatment : treatments) {
|
||||||
|
LocalDate deleteDate = treatment.calculateDeleteDate();
|
||||||
|
if (today.isEqual(deleteDate) || today.isAfter(deleteDate)) {
|
||||||
|
try {
|
||||||
|
treatmentDao.delete(treatment.getId());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void unlockTreatment() {
|
||||||
|
Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
selectedItem.setLocked(false);
|
||||||
|
this.treatmentDao.update(selectedItem);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
readAllAndShowInTableView();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package de.hitec.nhplus.treatment;
|
||||||
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;
|
||||||
|
@ -16,6 +17,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 +29,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 static int BLOCKED_YEARS = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor allows instantiating a {@link Treatment} object,
|
* This constructor allows instantiating a {@link Treatment} object,
|
||||||
|
@ -50,6 +55,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 +69,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 +80,26 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates delete date of treatment.
|
||||||
|
*/
|
||||||
|
public LocalDate calculateDeleteDate() {
|
||||||
|
return DateConverter.convertStringToLocalDate(getDate()).plusYears(BLOCKED_YEARS);
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
@ -166,6 +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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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> {
|
||||||
|
|
||||||
|
@ -27,60 +30,22 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
super(connection);
|
super(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
* Read all database entries of active {@link Treatment}s into a {@link List} of model instances.
|
||||||
final String SQL = """
|
*/
|
||||||
INSERT INTO treatment
|
public List<Treatment> readAllActive() throws SQLException {
|
||||||
(patientId, nurseId, date, begin, end, description, remark)
|
final String SQL = "SELECT * FROM treatment WHERE isLocked = false";
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, treatment.getPatient().getId());
|
|
||||||
statement.setInt(2, treatment.getNurse().getId());
|
|
||||||
statement.setString(3, treatment.getDate());
|
|
||||||
statement.setString(4, treatment.getBegin());
|
|
||||||
statement.setString(5, treatment.getEnd());
|
|
||||||
statement.setString(6, treatment.getDescription());
|
|
||||||
statement.setString(7, treatment.getRemarks());
|
|
||||||
return statement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
* Read all database entries of locked {@link Treatment}s into a {@link Treatment} of model instances.
|
||||||
final String SQL = "SELECT * FROM treatment WHERE id = ?";
|
*/
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
public List<Treatment> readAllLocked() throws SQLException {
|
||||||
statement.setInt(1, id);
|
final String SQL = "SELECT * FROM treatment WHERE isLocked = true";
|
||||||
return statement;
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Treatment getInstanceFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
return new Treatment(
|
|
||||||
result.getInt(1),
|
|
||||||
DaoFactory.getInstance().createPatientDAO().read(result.getInt(2)),
|
|
||||||
DaoFactory.getInstance().createNurseDAO().read(result.getInt(3)),
|
|
||||||
DateConverter.convertStringToLocalDate(result.getString(4)),
|
|
||||||
DateConverter.convertStringToLocalTime(result.getString(5)),
|
|
||||||
DateConverter.convertStringToLocalTime(result.getString(6)),
|
|
||||||
result.getString(7),
|
|
||||||
result.getString(8)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment";
|
|
||||||
return this.connection.prepareStatement(SQL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<Treatment> getListFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
ArrayList<Treatment> list = new ArrayList<>();
|
|
||||||
while (result.next()) {
|
|
||||||
list.add(getInstanceFromResultSet(result));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
* Retrieves a list of {@link Treatment}s associated with a specific
|
||||||
|
@ -112,6 +77,63 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
return getListFromResultSet(result);
|
return getListFromResultSet(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
||||||
|
final String SQL = """
|
||||||
|
INSERT INTO treatment
|
||||||
|
(patientId, nurseId, date, begin, end, description, remark, isLocked)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
""";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, treatment.getPatient().getId());
|
||||||
|
statement.setInt(2, treatment.getNurse().getId());
|
||||||
|
statement.setString(3, treatment.getDate());
|
||||||
|
statement.setString(4, treatment.getBegin());
|
||||||
|
statement.setString(5, treatment.getEnd());
|
||||||
|
statement.setString(6, treatment.getDescription());
|
||||||
|
statement.setString(7, treatment.getRemarks());
|
||||||
|
statement.setBoolean(8, treatment.isLocked());
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE id = ?";
|
||||||
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
|
statement.setInt(1, id);
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Treatment getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
return new Treatment(
|
||||||
|
result.getInt(1),
|
||||||
|
DaoFactory.getInstance().createPatientDAO().read(result.getInt(2)),
|
||||||
|
DaoFactory.getInstance().createNurseDAO().read(result.getInt(3)),
|
||||||
|
DateConverter.convertStringToLocalDate(result.getString(4)),
|
||||||
|
DateConverter.convertStringToLocalTime(result.getString(5)),
|
||||||
|
DateConverter.convertStringToLocalTime(result.getString(6)),
|
||||||
|
result.getString(7),
|
||||||
|
result.getString(8),
|
||||||
|
result.getBoolean(9)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadAllStatement() throws SQLException {
|
||||||
|
final String SQL = "SELECT * FROM treatment";
|
||||||
|
return this.connection.prepareStatement(SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Treatment> getListFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
ArrayList<Treatment> list = new ArrayList<>();
|
||||||
|
while (result.next()) {
|
||||||
|
list.add(getInstanceFromResultSet(result));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
|
@ -120,7 +142,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 +152,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 +165,5 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
statement.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
114
src/main/java/de/hitec/nhplus/utils/tab/TabManager.java
Normal file
114
src/main/java/de/hitec/nhplus/utils/tab/TabManager.java
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
package de.hitec.nhplus.utils.tab;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.Main;
|
||||||
|
import de.hitec.nhplus.login.Permissions;
|
||||||
|
import de.hitec.nhplus.login.User;
|
||||||
|
import javafx.event.Event;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.control.Tab;
|
||||||
|
import javafx.scene.control.TabPane;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.scene.layout.BorderPane;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A utility class to construct {@link Tab}s from views. This also supports sub {@link Tab}s.
|
||||||
|
*
|
||||||
|
* @author Dominiok Säume
|
||||||
|
* @see TabManager
|
||||||
|
*/
|
||||||
|
public class TabManager {
|
||||||
|
private final User user;
|
||||||
|
|
||||||
|
public TabManager(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal method to check permissions
|
||||||
|
* @param requiredPermissions The permissions the {@link User} requires.
|
||||||
|
* @param permissions The permissions the {@link User} has.
|
||||||
|
*/
|
||||||
|
private boolean hasPermissions(int requiredPermissions, int permissions) {
|
||||||
|
return requiredPermissions == Permissions.EVERYBODY
|
||||||
|
|| (permissions & requiredPermissions) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to set up a single tab and register it to its {@link TabPane}.
|
||||||
|
* @param tabPane The {@link TabPane} to register to.
|
||||||
|
* @param tabStruct The data needed to construct the new tab.
|
||||||
|
*/
|
||||||
|
public void setupTab(TabPane tabPane, TabStruct tabStruct) {
|
||||||
|
if (!hasPermissions(tabStruct.requiredPermissions, user.getPermissions())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Tab tab = new Tab();
|
||||||
|
tab.setText(tabStruct.title);
|
||||||
|
AnchorPane pane = new AnchorPane();
|
||||||
|
tab.setContent(pane);
|
||||||
|
tab.setOnSelectionChanged(loadTabEventHandler(tabStruct, pane));
|
||||||
|
tabPane.getTabs().add(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link EventHandler} to handle the loading of a {@link Tab}.
|
||||||
|
* @param tabStruct The {@link TabStruct} holding the path of the view.
|
||||||
|
* @param pane The main pane of the {@link Tab}.
|
||||||
|
*/
|
||||||
|
private EventHandler<Event> loadTabEventHandler(TabStruct tabStruct, AnchorPane pane) {
|
||||||
|
return event -> {
|
||||||
|
try {
|
||||||
|
BorderPane patientsPane = FXMLLoader.load(
|
||||||
|
Objects.requireNonNull(Main.class.getResource(tabStruct.view))
|
||||||
|
);
|
||||||
|
pane.getChildren().setAll(patientsPane);
|
||||||
|
AnchorPane.setTopAnchor(patientsPane, 0d);
|
||||||
|
AnchorPane.setBottomAnchor(patientsPane, 0d);
|
||||||
|
AnchorPane.setLeftAnchor(patientsPane, 0d);
|
||||||
|
AnchorPane.setRightAnchor(patientsPane, 0d);
|
||||||
|
} catch (IOException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to set up a sub tab and register it to its parent {@link TabPane}.
|
||||||
|
* @param parentTabPane The {@link TabPane} to register to.
|
||||||
|
* @param title The title of the {@link Tab}.
|
||||||
|
* @param requiredPermissions The permissions required to see the sub {@link Tab}.
|
||||||
|
* @param subTabs A {@link List} of {@link TabStruct}s to create in the sub {@link Tab}.
|
||||||
|
*/
|
||||||
|
public void setupSubTabPane(TabPane parentTabPane, String title, int requiredPermissions, List<TabStruct> subTabs) {
|
||||||
|
if (!hasPermissions(requiredPermissions, user.getPermissions())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Tab tab = new Tab();
|
||||||
|
tab.setText(title);
|
||||||
|
TabPane subTabPane = new TabPane();
|
||||||
|
subTabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
|
||||||
|
tab.setContent(subTabPane);
|
||||||
|
subTabs.forEach(tabStruct -> setupTab(subTabPane, tabStruct));
|
||||||
|
if (subTabPane.getTabs().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tab.setOnSelectionChanged(loadSubTabPaneEventHandler(subTabPane));
|
||||||
|
parentTabPane.getTabs().add(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link EventHandler} to handle the loading of a sub {@link TabPane}.
|
||||||
|
* @param tabPane The {@link TabPane} of the sub {@link Tab} to handle loading.
|
||||||
|
*/
|
||||||
|
private EventHandler<Event> loadSubTabPaneEventHandler(TabPane tabPane) {
|
||||||
|
return event -> {
|
||||||
|
Tab tab = tabPane.getSelectionModel().getSelectedItem();
|
||||||
|
tab.getOnSelectionChanged().handle(new Event(Event.ANY));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
19
src/main/java/de/hitec/nhplus/utils/tab/TabStruct.java
Normal file
19
src/main/java/de/hitec/nhplus/utils/tab/TabStruct.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package de.hitec.nhplus.utils.tab;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple class holding the data needed for constructing a {@link javafx.scene.control.Tab Tab}.
|
||||||
|
*
|
||||||
|
* @author Dominiok Säume
|
||||||
|
* @see TabManager
|
||||||
|
*/
|
||||||
|
public class TabStruct {
|
||||||
|
public String title;
|
||||||
|
public String view;
|
||||||
|
public int requiredPermissions;
|
||||||
|
|
||||||
|
public TabStruct(String title, String view, int requiredPermissions) {
|
||||||
|
this.title = title;
|
||||||
|
this.view = view;
|
||||||
|
this.requiredPermissions = requiredPermissions;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,9 @@ module de.hitec.nhplus {
|
||||||
exports de.hitec.nhplus.main;
|
exports de.hitec.nhplus.main;
|
||||||
opens de.hitec.nhplus.main to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.main to javafx.base, javafx.fxml;
|
||||||
|
|
||||||
|
exports de.hitec.nhplus.login;
|
||||||
|
opens de.hitec.nhplus.login to javafx.base, javafx.fxml;
|
||||||
|
|
||||||
exports de.hitec.nhplus.patient;
|
exports de.hitec.nhplus.patient;
|
||||||
exports de.hitec.nhplus.patient.database;
|
exports de.hitec.nhplus.patient.database;
|
||||||
opens de.hitec.nhplus.patient.database to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.patient.database to javafx.base, javafx.fxml;
|
||||||
|
|
47
src/main/resources/de/hitec/nhplus/login/LoginView.fxml
Normal file
47
src/main/resources/de/hitec/nhplus/login/LoginView.fxml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.PasswordField?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<BorderPane
|
||||||
|
xmlns="http://javafx.com/javafx/17.0.2-ea"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="de.hitec.nhplus.login.LoginController"
|
||||||
|
minWidth="240"
|
||||||
|
maxWidth="240"
|
||||||
|
>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="8" left="8" right="8" top="8"/>
|
||||||
|
</padding>
|
||||||
|
<top>
|
||||||
|
<Label text="Anmeldung" BorderPane.alignment="CENTER"/>
|
||||||
|
</top>
|
||||||
|
<center>
|
||||||
|
<VBox spacing="8">
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets bottom="8.0" top="8.0"/>
|
||||||
|
</BorderPane.margin>
|
||||||
|
<TextField
|
||||||
|
fx:id="textFieldUsername"
|
||||||
|
promptText="nutzername"
|
||||||
|
VBox.vgrow="ALWAYS"
|
||||||
|
/>
|
||||||
|
<PasswordField
|
||||||
|
fx:id="passwordField"
|
||||||
|
promptText="password"
|
||||||
|
VBox.vgrow="ALWAYS"
|
||||||
|
/>
|
||||||
|
</VBox>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<Button
|
||||||
|
fx:id="buttonSubmit"
|
||||||
|
text="Bestätigen"
|
||||||
|
BorderPane.alignment="CENTER"
|
||||||
|
onAction="#handleSubmit"
|
||||||
|
/>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
|
@ -0,0 +1,7 @@
|
||||||
|
CREATE TABLE user
|
||||||
|
(
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT NOT NULL UNIQUE,
|
||||||
|
passwordSalt BLOB NOT NULL,
|
||||||
|
passwordHash BLOB NOT NULL
|
||||||
|
)
|
|
@ -0,0 +1,6 @@
|
||||||
|
CREATE TABLE user__permissions
|
||||||
|
(
|
||||||
|
userId INTEGER NOT NULL UNIQUE,
|
||||||
|
permissions INTEGER NOT NULL, -- Binary Bitmask for Permissions
|
||||||
|
FOREIGN KEY (userId) REFERENCES user (id) ON DELETE CASCADE
|
||||||
|
)
|
|
@ -0,0 +1,7 @@
|
||||||
|
CREATE TABLE user__nurse
|
||||||
|
(
|
||||||
|
userId INTEGER NOT NULL UNIQUE,
|
||||||
|
nurseId INTEGER NOT NULL UNIQUE,
|
||||||
|
FOREIGN KEY (userId) REFERENCES user (id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE CASCADE
|
||||||
|
)
|
|
@ -1,31 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<TabPane
|
<TabPane
|
||||||
fx:id="mainTabPane"
|
fx:id="mainTabPane"
|
||||||
tabClosingPolicy="UNAVAILABLE"
|
tabClosingPolicy="UNAVAILABLE"
|
||||||
xmlns="http://javafx.com/javafx/17.0.2-ea"
|
xmlns="http://javafx.com/javafx/17.0.2-ea"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="de.hitec.nhplus.main.MainWindowController"
|
fx:controller="de.hitec.nhplus.main.MainWindowController"
|
||||||
>
|
/>
|
||||||
<Tab fx:id="patientTab" text="Patienten">
|
|
||||||
<AnchorPane fx:id="patientPage"/>
|
|
||||||
</Tab>
|
|
||||||
<Tab fx:id="treatmentTab" text="Behandlungen">
|
|
||||||
<AnchorPane fx:id="treatmentPage"/>
|
|
||||||
</Tab>
|
|
||||||
<Tab fx:id="nurseTab" text="Pfleger">
|
|
||||||
<TabPane fx:id="nurseTabPane" tabClosingPolicy="UNAVAILABLE">
|
|
||||||
<Tab fx:id="activeNurseTab" text="Pfleger">
|
|
||||||
<AnchorPane fx:id="activeNursePage"/>
|
|
||||||
</Tab>
|
|
||||||
<Tab fx:id="lockedNurseTab" text="Gesperrte Pfleger">
|
|
||||||
<AnchorPane fx:id="lockedNursePage"/>
|
|
||||||
</Tab>
|
|
||||||
</TabPane>
|
|
||||||
</Tab>
|
|
||||||
<Tab fx:id="medicationTab" text="Medikamente">
|
|
||||||
<AnchorPane fx:id="medicationPage"/>
|
|
||||||
</Tab>
|
|
||||||
</TabPane>
|
|
|
@ -75,6 +75,13 @@
|
||||||
prefWidth="90.0"
|
prefWidth="90.0"
|
||||||
text="Löschen"
|
text="Löschen"
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
fx:id="buttonChangeAvailable"
|
||||||
|
mnemonicParsing="false"
|
||||||
|
onAction="#handleChangeAvailable"
|
||||||
|
prefWidth="155.0"
|
||||||
|
text="Veraltet-Status ändern"
|
||||||
|
/>
|
||||||
</HBox>
|
</HBox>
|
||||||
</right>
|
</right>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<BorderPane xmlns="http://javafx.com/javafx"
|
||||||
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
|
fx:controller="de.hitec.nhplus.medication.DeprecatedMedicationController"
|
||||||
|
>
|
||||||
|
<padding>
|
||||||
|
<Insets top="8" left="8" right="8" bottom="8"/>
|
||||||
|
</padding>
|
||||||
|
<center>
|
||||||
|
<TableView fx:id="tableView">
|
||||||
|
<columns>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnId"
|
||||||
|
minWidth="40.0"
|
||||||
|
text="ID"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnName"
|
||||||
|
minWidth="140.0"
|
||||||
|
text="Name"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnManufacturer"
|
||||||
|
minWidth="140.0"
|
||||||
|
text="Hersteller"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnIngredient"
|
||||||
|
minWidth="140.0"
|
||||||
|
text="Inhaltsstoffe"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnPossibleSideEffects"
|
||||||
|
minWidth="200.0"
|
||||||
|
text="Mögliche Nebenwirkungen"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnAdministrationMethod"
|
||||||
|
minWidth="180.0"
|
||||||
|
text="Verabreichungsmethode"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnCurrentStock"
|
||||||
|
minWidth="100.0"
|
||||||
|
text="Lagerbestand"
|
||||||
|
/>
|
||||||
|
</columns>
|
||||||
|
<columnResizePolicy>
|
||||||
|
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||||
|
</columnResizePolicy>
|
||||||
|
</TableView>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<BorderPane>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets top="8.0"/>
|
||||||
|
</BorderPane.margin>
|
||||||
|
<right>
|
||||||
|
<HBox spacing="8.0">
|
||||||
|
<Button
|
||||||
|
fx:id="buttonChangeAvailable"
|
||||||
|
mnemonicParsing="false"
|
||||||
|
prefWidth="155.0"
|
||||||
|
onAction="#handleChangeAvailable"
|
||||||
|
text="Veraltet-Status ändern"
|
||||||
|
/>
|
||||||
|
</HBox>
|
||||||
|
</right>
|
||||||
|
</BorderPane>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
|
@ -5,5 +5,6 @@ CREATE TABLE medication
|
||||||
manufacturer TEXT NOT NULL,
|
manufacturer TEXT NOT NULL,
|
||||||
possibleSideEffects TEXT NOT NULL,
|
possibleSideEffects TEXT NOT NULL,
|
||||||
administrationMethod TEXT NOT NULL,
|
administrationMethod TEXT NOT NULL,
|
||||||
currentStock INTEGER NOT NULL
|
currentStock INTEGER NOT NULL,
|
||||||
|
isDeprecated BOOLEAN NOT NULL DEFAULT false
|
||||||
)
|
)
|
|
@ -22,16 +22,19 @@
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnSurName"
|
fx:id="columnSurName"
|
||||||
minWidth="140.0"
|
minWidth="140.0"
|
||||||
|
onEditCommit="#handleOnEditSurname"
|
||||||
text="Nachname"
|
text="Nachname"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnFirstName"
|
fx:id="columnFirstName"
|
||||||
minWidth="140.0"
|
minWidth="140.0"
|
||||||
|
onEditCommit="#handleOnEditFirstname"
|
||||||
text="Vorname"
|
text="Vorname"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnPhoneNumber"
|
fx:id="columnPhoneNumber"
|
||||||
minWidth="140.0"
|
minWidth="140.0"
|
||||||
|
onEditCommit="#handleOnEditPhoneNumber"
|
||||||
text="Telefonnummer"
|
text="Telefonnummer"
|
||||||
/>
|
/>
|
||||||
</columns>
|
</columns>
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
<Insets top="8" left="8" right="8" bottom="8"/>
|
<Insets top="8" left="8" right="8" bottom="8"/>
|
||||||
</padding>
|
</padding>
|
||||||
<center>
|
<center>
|
||||||
<TableView fx:id="tableView" layoutX="31.0" layoutY="40" onMouseClicked="#handleMouseClick" >
|
<TableView
|
||||||
|
fx:id="tableView"
|
||||||
|
layoutX="31.0"
|
||||||
|
layoutY="40"
|
||||||
|
onMouseClicked="#handleMouseClick" >
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnId"
|
fx:id="columnId"
|
||||||
|
@ -74,7 +78,6 @@
|
||||||
onAction="#handleDelete"
|
onAction="#handleDelete"
|
||||||
prefWidth="90.0"
|
prefWidth="90.0"
|
||||||
text="Löschen"
|
text="Löschen"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</HBox>
|
</HBox>
|
||||||
</right>
|
</right>
|
||||||
|
|
|
@ -88,11 +88,11 @@
|
||||||
</center>
|
</center>
|
||||||
<right>
|
<right>
|
||||||
<Button
|
<Button
|
||||||
fx:id="buttonDelete"
|
fx:id="buttonLock"
|
||||||
mnemonicParsing="false"
|
mnemonicParsing="false"
|
||||||
onAction="#handleDelete"
|
onAction="#handleLock"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
text="Löschen"
|
text="Sperren"
|
||||||
GridPane.columnIndex="2"
|
GridPane.columnIndex="2"
|
||||||
/>
|
/>
|
||||||
</right>
|
</right>
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<BorderPane prefHeight="400.0"
|
||||||
|
prefWidth="600.0"
|
||||||
|
xmlns="http://javafx.com/javafx/17.0.2-ea"
|
||||||
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="de.hitec.nhplus.treatment.LockedTreatmentController">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="8" left="8" right="8" top="8" />
|
||||||
|
</padding>
|
||||||
|
<center>
|
||||||
|
<TableView
|
||||||
|
fx:id="tableView"
|
||||||
|
layoutX="31.0"
|
||||||
|
layoutY="40">
|
||||||
|
<columns>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnId"
|
||||||
|
minWidth="40.0"
|
||||||
|
prefWidth="102.0"
|
||||||
|
text="ID"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnPatient"
|
||||||
|
minWidth="40.0"
|
||||||
|
prefWidth="102.0"
|
||||||
|
text="Patient"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnNurse"
|
||||||
|
minWidth="40.0"
|
||||||
|
prefWidth="102.0"
|
||||||
|
text="Pflegekraft"
|
||||||
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnDeleteDate"
|
||||||
|
minWidth="40.0"
|
||||||
|
prefWidth="102.0"
|
||||||
|
text="Löschung am"
|
||||||
|
/>
|
||||||
|
</columns>
|
||||||
|
<columnResizePolicy>
|
||||||
|
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||||
|
</columnResizePolicy>
|
||||||
|
</TableView>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<BorderPane>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets top="8.0"/>
|
||||||
|
</BorderPane.margin>
|
||||||
|
<center>
|
||||||
|
<HBox spacing="8.0">
|
||||||
|
<padding>
|
||||||
|
<Insets right="8.0"/>
|
||||||
|
</padding>
|
||||||
|
</HBox>
|
||||||
|
</center>
|
||||||
|
<right>
|
||||||
|
<HBox>
|
||||||
|
<spacing>8.0</spacing>
|
||||||
|
<Button
|
||||||
|
fx:id="buttonUnlock"
|
||||||
|
mnemonicParsing="false"
|
||||||
|
onAction="#unlockTreatment"
|
||||||
|
prefWidth="90.0"
|
||||||
|
text="Entsperren"
|
||||||
|
/>
|
||||||
|
</HBox>
|
||||||
|
</right>
|
||||||
|
</BorderPane>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
|
@ -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 CASCADE
|
||||||
)
|
)
|
Loading…
Reference in a new issue