Compare commits
3 commits
917aa8275f
...
da40c4aeb7
Author | SHA1 | Date | |
---|---|---|---|
|
da40c4aeb7 | ||
|
d8a7c9a59c | ||
|
f212cfe760 |
45 changed files with 303 additions and 1576 deletions
|
@ -15,7 +15,9 @@ jobs:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
uses: "https://git.euph.dev/actions/checkout@v3"
|
uses: "https://git.euph.dev/actions/checkout@v3"
|
||||||
- name: "javadoc"
|
- name: "javadoc"
|
||||||
run: mvn package javadoc:javadoc -f pom.xml
|
run: |
|
||||||
|
mvn package
|
||||||
|
mvn javadoc:javadoc -f pom.xml
|
||||||
- name: "Deploy Javadoc"
|
- name: "Deploy Javadoc"
|
||||||
env:
|
env:
|
||||||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
||||||
|
|
|
@ -5,23 +5,13 @@ on:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linting:
|
qs:
|
||||||
name: "Linting Check"
|
name: "Qualty Check"
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
container:
|
container:
|
||||||
image: "git.euph.dev/actions/runner-java-21:latest"
|
image: "git.euph.dev/actions/runner-java-21:latest"
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
uses: "https://git.euph.dev/actions/checkout@v3"
|
uses: "https://git.euph.dev/actions/checkout@v3"
|
||||||
- name: "Checkstyle Linting"
|
- name: "CHECK"
|
||||||
run: mvn checkstyle:check -e
|
run: mvn checkstyle:check -e
|
||||||
javadoc:
|
|
||||||
name: "Javadoc Check"
|
|
||||||
runs-on: "ubuntu-latest"
|
|
||||||
container:
|
|
||||||
image: "git.euph.dev/actions/runner-java-21:latest"
|
|
||||||
steps:
|
|
||||||
- name: "Checkout"
|
|
||||||
uses: "https://git.euph.dev/actions/checkout@v3"
|
|
||||||
- name: "Generate Javadoc"
|
|
||||||
run: mvn package javadoc:javadoc -f pom.xml
|
|
|
@ -25,8 +25,6 @@
|
||||||
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/patient/database/Patient.sql" />
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/patient/database/Patient.sql" />
|
||||||
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql" />
|
<option value="file://$PROJECT_DIR$/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.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/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_Ingredient.sql" />
|
|
||||||
</array>
|
</array>
|
||||||
</option>
|
</option>
|
||||||
<option name="outLayout" value="File per object by schema.groovy" />
|
<option name="outLayout" value="File per object by schema.groovy" />
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<component name="SqlDialectMappings">
|
<component name="SqlDialectMappings">
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java" dialect="GenericSQL" />
|
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java" dialect="GenericSQL" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java" dialect="GenericSQL" />
|
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java" dialect="GenericSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/treatment/database/NurseDao.java" dialect="GenericSQL" />
|
||||||
<file url="PROJECT" dialect="SQLite" />
|
<file url="PROJECT" dialect="SQLite" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
|
||||||
|
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
|
15
pom.xml
15
pom.xml
|
@ -21,12 +21,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjfx</groupId>
|
<groupId>org.openjfx</groupId>
|
||||||
<artifactId>javafx-controls</artifactId>
|
<artifactId>javafx-controls</artifactId>
|
||||||
<version>21.0.2</version>
|
<version>20.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjfx</groupId>
|
<groupId>org.openjfx</groupId>
|
||||||
<artifactId>javafx-fxml</artifactId>
|
<artifactId>javafx-fxml</artifactId>
|
||||||
<version>21.0.2</version>
|
<version>20.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.controlsfx</groupId>
|
<groupId>org.controlsfx</groupId>
|
||||||
|
@ -112,20 +112,11 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>21</source>
|
|
||||||
<release>21</release>
|
|
||||||
<author>true</author>
|
|
||||||
<doclint>all,-missing</doclint>
|
|
||||||
<reportOutputDirectory>${project.basedir}</reportOutputDirectory>
|
<reportOutputDirectory>${project.basedir}</reportOutputDirectory>
|
||||||
<sourcepath>src/main/java</sourcepath>
|
<sourcepath>src/main/java</sourcepath>
|
||||||
<destDir>javadoc_build</destDir>
|
<destDir>javadoc_build</destDir>
|
||||||
<tags>
|
|
||||||
<tag>
|
|
||||||
<name>implSpec</name>
|
|
||||||
</tag>
|
|
||||||
</tags>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.hitec.nhplus;
|
package de.hitec.nhplus;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
@ -11,35 +12,18 @@ import javafx.stage.Stage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application main class, holding the {@link #main} entrypoint.
|
* @author dominik.saeume@hmmh.ag
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
*/
|
||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
|
||||||
private Stage primaryStage;
|
private Stage primaryStage;
|
||||||
|
|
||||||
/**
|
|
||||||
* The main entry point.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of the JavaFX start hook.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
executeMainApplication();
|
mainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void mainWindow() {
|
||||||
* Executes the main application.
|
|
||||||
*/
|
|
||||||
private void executeMainApplication() {
|
|
||||||
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();
|
||||||
|
@ -60,4 +44,7 @@ public class Main extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,9 @@ import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link DaoFactory} allows a safe connection to the database.
|
* The {@link DaoFactory} allows a safe connection to the Database.
|
||||||
*
|
*
|
||||||
* @author Bernd Heidemannn
|
* @author Bernd Heidemann
|
||||||
* @author Dominik Säume
|
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class ConnectionBuilder {
|
public class ConnectionBuilder {
|
||||||
|
@ -21,7 +20,8 @@ public class ConnectionBuilder {
|
||||||
private static Connection connection;
|
private static Connection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A thread-safe {@link Connection} to the database.
|
* @return a Thread-safe {@link Connection} to the Database.
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
synchronized public static Connection getConnection() {
|
synchronized public static Connection getConnection() {
|
||||||
try {
|
try {
|
||||||
|
@ -38,7 +38,9 @@ public class ConnectionBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the connection to the database.
|
* Closes the Connection to the Database.
|
||||||
|
*
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
synchronized public static void closeConnection() {
|
synchronized public static void closeConnection() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,48 +4,51 @@ import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Dao} is the abbreviation for Data-Access-Object.
|
* {@link Dao} is the Abbreviation of Data-Access-Object.
|
||||||
* This interface has the Basic Methods that are needed on any {@link Dao} to work as expected.
|
* This Interface has the Basic Methods which are needed on any DAO to work as expected.
|
||||||
*
|
*
|
||||||
* @param <T> The model for which that {@link Dao} is implemented.
|
* @param <T> The Model for which that DAO is implemented
|
||||||
* @author Bernd Heidemannn
|
* @author Bernd Heidemann
|
||||||
* @author Dominik Säume
|
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @implSpec The implementations should be added to the {@link DaoFactory}.
|
* @implSpec The Implementations should be added to the {@link DaoFactory}
|
||||||
*/
|
*/
|
||||||
public interface Dao<T> {
|
public interface Dao<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a database entry from a model object.
|
* Create a Database Entry from a Model object.
|
||||||
*
|
*
|
||||||
* @param t The model instance.
|
* @param t the Model instance
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
void create(T t) throws SQLException;
|
void create(T t) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a database entry to a model object.
|
* Read a Database Entry to a Model object.
|
||||||
*
|
*
|
||||||
* @param id The ID of the element in the database.
|
* @param id of the Element in the Database
|
||||||
* @return a model instance of {@link T}.
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
T read(int id) throws SQLException;
|
T read(int id) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return All database entries as a {@link List} of model instances.
|
* Read all Database Entries to a {@link List} of Model objects.
|
||||||
|
*
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
List<T> readAll() throws SQLException;
|
List<T> readAll() throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the database according to the values of the model object.
|
* Update the Database according to the Values of the Model object.
|
||||||
*
|
*
|
||||||
* @param t The model instance.
|
* @param t the Model instance.
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
void update(T t) throws SQLException;
|
void update(T t) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a database entry.
|
* Delete a Database Entry.
|
||||||
*
|
*
|
||||||
* @param id The ID of the element in the database.
|
* @param id of the Element in the Database.
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
void delete(int id) throws SQLException;
|
void delete(int id) throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package de.hitec.nhplus.datastorage;
|
package de.hitec.nhplus.datastorage;
|
||||||
|
|
||||||
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;
|
||||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link DaoFactory} is a singleton({@link #getInstance}) that should be used to get {@link Dao}s.
|
* The {@link DaoFactory} is a Singleton({@link DaoFactory#getInstance}) which should be used to get {@link Dao}s.
|
||||||
*
|
*
|
||||||
* @author Bernd Heidemannn
|
* @author Bernd Heidemann
|
||||||
* @author Dominik Säume
|
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class DaoFactory {
|
public class DaoFactory {
|
||||||
|
@ -17,13 +15,16 @@ public class DaoFactory {
|
||||||
private static DaoFactory instance;
|
private static DaoFactory instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A private constructor according to the singleton pattern.
|
* A Private Constructor according to the Singleton Pattern.
|
||||||
|
*
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
private DaoFactory() {
|
private DaoFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The singleton instance of {@link DaoFactory}.
|
* @return {@link DaoFactory}, the Singleton Instance
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
public static DaoFactory getInstance() {
|
public static DaoFactory getInstance() {
|
||||||
if (DaoFactory.instance == null) {
|
if (DaoFactory.instance == null) {
|
||||||
|
@ -33,34 +34,26 @@ public class DaoFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A new {@link TreatmentDao} instance with a database connection.
|
* @return a {@link TreatmentDao}
|
||||||
* @see de.hitec.nhplus.treatment.Treatment Treatment
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
public TreatmentDao createTreatmentDao() {
|
public TreatmentDao createTreatmentDao() {
|
||||||
return new TreatmentDao(ConnectionBuilder.getConnection());
|
return new TreatmentDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A new {@link PatientDao} instance with a database connection.
|
* @return a {@link PatientDao}
|
||||||
* @see de.hitec.nhplus.patient.Patient Patient
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
public PatientDao createPatientDAO() {
|
public PatientDao createPatientDAO() {
|
||||||
return new PatientDao(ConnectionBuilder.getConnection());
|
return new PatientDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A new {@link NurseDao} instance with a database connection.
|
* @return a {@link NurseDao}
|
||||||
* @see de.hitec.nhplus.nurse.Nurse Nurse
|
* @author Dominik Säume
|
||||||
*/
|
*/
|
||||||
public NurseDao createNurseDAO() {
|
public NurseDao createNurseDAO() {
|
||||||
return new NurseDao(ConnectionBuilder.getConnection());
|
return new NurseDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A new {@link MedicationDao} instance with a database connection.
|
|
||||||
* @see de.hitec.nhplus.medication.Medication Medication
|
|
||||||
*/
|
|
||||||
public MedicationDao createMedicationDAO() {
|
|
||||||
return new MedicationDao(ConnectionBuilder.getConnection());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,30 +7,30 @@ import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link DaoImp} is a generic base implementation of the {@link Dao},
|
* The {@link DaoImp} is a Generic Base Implementation of the {@link Dao},
|
||||||
* that should fit most use cases.
|
* which should fit most use cases.
|
||||||
*
|
*
|
||||||
* @param <T> The model for which that {@link Dao} is implemented.
|
* @param <T> The Model for which that DAO is implemented
|
||||||
* @author Bernd Heidemannn
|
* @author Bernd Heidemann
|
||||||
* @author Dominik Säume
|
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @implSpec The implementations should be added to the {@link DaoFactory}.
|
* @implSpec The Implementations should be added to the {@link DaoFactory}
|
||||||
*/
|
*/
|
||||||
public abstract class DaoImp<T> implements Dao<T> {
|
public abstract class DaoImp<T> implements Dao<T> {
|
||||||
protected final Connection connection;
|
protected final Connection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param connection The database {@link Connection} to use.
|
* @param connection a Database Connection, which should be gotten from {@link ConnectionBuilder}
|
||||||
* @implSpec The {@link Connection} should be received from the {@link ConnectionBuilder}.
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
public DaoImp(Connection connection) {
|
public DaoImp(Connection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new database entry from a model object.
|
* Creates a new Database Entry from a Model object.
|
||||||
*
|
*
|
||||||
* @param t The model instance.
|
* @param t the Model instance
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void create(T t) throws SQLException {
|
public void create(T t) throws SQLException {
|
||||||
|
@ -38,10 +38,10 @@ public abstract class DaoImp<T> implements Dao<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a database entry to a model object.
|
* Read a Database Entry to a Model object.
|
||||||
*
|
*
|
||||||
* @param id The ID of the element in the database.
|
* @param id of the Element in the Database
|
||||||
* @return the model instance of type {@link T}, which was read.
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public T read(int id) throws SQLException {
|
public T read(int id) throws SQLException {
|
||||||
|
@ -54,9 +54,9 @@ public abstract class DaoImp<T> implements Dao<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read all database entries to a {@link List} of model objects.
|
* Read all Database Entries to a {@link List} of Model objects.
|
||||||
*
|
*
|
||||||
* @return a {@link List} of type {@link T} holding all database entries as model instances.
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<T> readAll() throws SQLException {
|
public List<T> readAll() throws SQLException {
|
||||||
|
@ -64,9 +64,10 @@ public abstract class DaoImp<T> implements Dao<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the database according to the values of the model object.
|
* Update the Database according to the Values of the Model object.
|
||||||
*
|
*
|
||||||
* @param t The model instance.
|
* @param t the Model instance.
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update(T t) throws SQLException {
|
public void update(T t) throws SQLException {
|
||||||
|
@ -74,62 +75,27 @@ public abstract class DaoImp<T> implements Dao<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a database entry.
|
* Delete a Database Entry.
|
||||||
*
|
*
|
||||||
* @param id The ID of the element in the database.
|
* @param id of the Element in the Database.
|
||||||
|
* @author Bernd Heidemann
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete(int id) throws SQLException {
|
public void delete(int id) throws SQLException {
|
||||||
getDeleteStatement(id).executeUpdate();
|
getDeleteStatement(id).executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param result The {@link ResultSet} from execution of the statement received from {@link #getReadByIDStatement}.
|
|
||||||
* @return The model instance of type {@link T}.
|
|
||||||
* @implSpec This will be called in {@link #read}.
|
|
||||||
*/
|
|
||||||
protected abstract T getInstanceFromResultSet(ResultSet result) throws SQLException;
|
protected abstract T getInstanceFromResultSet(ResultSet result) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id The ID of the database entry to read.
|
|
||||||
* @return A {@link PreparedStatement} to read a specific entry by its ID.
|
|
||||||
* @implSpec This will be called in {@link #read}.
|
|
||||||
* The output of the execution will be used in {@link #getInstanceFromResultSet}.
|
|
||||||
*/
|
|
||||||
protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param result The {@link ResultSet} from execution of the statement received from {@link #getReadAllStatement}.
|
|
||||||
* @return A {@link List} of type {@link T} holding all database entries as model instances.
|
|
||||||
* @implSpec This will be called in {@link #readAll}.
|
|
||||||
*/
|
|
||||||
protected abstract List<T> getListFromResultSet(ResultSet result) throws SQLException;
|
protected abstract List<T> getListFromResultSet(ResultSet result) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A {@link PreparedStatement} to read all entries of this model.
|
|
||||||
* @implSpec This will be called in {@link #readAll}.
|
|
||||||
* The output of the execution will be used in {@link #getListFromResultSet}.
|
|
||||||
*/
|
|
||||||
protected abstract PreparedStatement getReadAllStatement() throws SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param t The model instance of type {@link T} for which an entry should be created.
|
|
||||||
* @return a {@link PreparedStatement} which can be used to create a new database entry for the model instance.
|
|
||||||
* @implSpec This will be called in {@link #create}.
|
|
||||||
*/
|
|
||||||
protected abstract PreparedStatement getCreateStatement(T t) throws SQLException;
|
protected abstract PreparedStatement getCreateStatement(T t) throws SQLException;
|
||||||
|
|
||||||
/**
|
protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException;
|
||||||
* @param t The model instance of type {@link T} for which the entry should be updated.
|
|
||||||
* @return a {@link PreparedStatement} which can be used to update the database entry for the model instance.
|
protected abstract PreparedStatement getReadAllStatement() throws SQLException;
|
||||||
* @implSpec This will be called in {@link #update}.
|
|
||||||
*/
|
|
||||||
protected abstract PreparedStatement getUpdateStatement(T t) throws SQLException;
|
protected abstract PreparedStatement getUpdateStatement(T t) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id The ID of the database entry which should be deleted.
|
|
||||||
* @return a {@link PreparedStatement} which can be used to delete the database entry.
|
|
||||||
* @implSpec This will be called in {@link #delete}.
|
|
||||||
*/
|
|
||||||
protected abstract PreparedStatement getDeleteStatement(int id) throws SQLException;
|
protected abstract PreparedStatement getDeleteStatement(int id) throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,12 @@
|
||||||
package de.hitec.nhplus.fixtures;
|
package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
public interface Fixture<T>
|
||||||
* A fixture is a class, which can be used to set up a specific set of data.
|
{
|
||||||
*
|
|
||||||
* @param <T> The model for which the {@link Fixture} is implemented.
|
|
||||||
* @author Dominik Säume
|
|
||||||
* @version 1.0
|
|
||||||
* @implSpec The implementations should be added to the {@link Fixtures#main}.
|
|
||||||
*/
|
|
||||||
public interface Fixture<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drop all dependent tables.
|
|
||||||
*
|
|
||||||
* @param connection A database {@link Connection}, which should be received from
|
|
||||||
* the {@link ConnectionBuilder#getConnection}
|
|
||||||
* @implSpec Use {@code IF EXISTS}, to ensure that it doesn't throw an {@link Exception}.
|
|
||||||
*/
|
|
||||||
void dropTable(Connection connection) throws SQLException;
|
void dropTable(Connection connection) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the empty tables with the schema.
|
|
||||||
*
|
|
||||||
* @param connection A database {@link Connection}, which should be received from
|
|
||||||
* the {@link ConnectionBuilder#getConnection}
|
|
||||||
*/
|
|
||||||
void setupTable(Connection connection) throws SQLException;
|
void setupTable(Connection connection) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads all model specific data to the database.
|
|
||||||
*
|
|
||||||
* @return A map of models with a {@link String} key, to be used by other {@link Fixture}
|
|
||||||
* @implSpec The {@link de.hitec.nhplus.datastorage.Dao Dao} should be received
|
|
||||||
* from {@link de.hitec.nhplus.datastorage.DaoFactory DaoFactory}.
|
|
||||||
*/
|
|
||||||
Map<String, T> load() throws SQLException;
|
Map<String, T> load() throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,33 @@
|
||||||
package de.hitec.nhplus.fixtures;
|
package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
public class Fixtures
|
||||||
* A class, implementing an entrypoint({@link #main}), for loading a specific set of data.
|
{
|
||||||
*
|
public static void main(String[] args)
|
||||||
* @author Dominik Säume
|
{
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class Fixtures {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An entrypoint, for loading a specific set of data.
|
|
||||||
*
|
|
||||||
* @param args unused.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Connection connection = ConnectionBuilder.getConnection();
|
Connection connection = ConnectionBuilder.getConnection();
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
PatientFixture patientFixture = new PatientFixture();
|
PatientFixture patientFixture = new PatientFixture();
|
||||||
patientFixture.dropTable(connection);
|
patientFixture.dropTable(connection);
|
||||||
patientFixture.setupTable(connection);
|
patientFixture.setupTable(connection);
|
||||||
Map<String, Patient> patientsByName = patientFixture.load();
|
Map<String, Patient> patientsByName = patientFixture.load();
|
||||||
|
|
||||||
NurseFixture nurseFixture = new NurseFixture();
|
TreatmentFixture treatmentFixture = new TreatmentFixture(patientsByName);
|
||||||
nurseFixture.dropTable(connection);
|
|
||||||
nurseFixture.setupTable(connection);
|
|
||||||
Map<String, Nurse> nursesByName = nurseFixture.load();
|
|
||||||
|
|
||||||
|
|
||||||
TreatmentFixture treatmentFixture = new TreatmentFixture(patientsByName, nursesByName);
|
|
||||||
treatmentFixture.dropTable(connection);
|
treatmentFixture.dropTable(connection);
|
||||||
treatmentFixture.setupTable(connection);
|
treatmentFixture.setupTable(connection);
|
||||||
treatmentFixture.load();
|
treatmentFixture.load();
|
||||||
|
|
||||||
|
NurseFixture nurseFixture = new NurseFixture();
|
||||||
MedicationFixture medicationFixture = new MedicationFixture();
|
nurseFixture.dropTable(connection);
|
||||||
medicationFixture.dropTable(connection);
|
nurseFixture.setupTable(connection);
|
||||||
medicationFixture.setupTable(connection);
|
nurseFixture.load();
|
||||||
medicationFixture.load();
|
|
||||||
|
|
||||||
} catch (Exception exception){
|
} catch (Exception exception){
|
||||||
System.out.println(exception.getMessage());
|
System.out.println(exception.getMessage());
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
package de.hitec.nhplus.fixtures;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
|
||||||
import de.hitec.nhplus.medication.Ingredient;
|
|
||||||
import de.hitec.nhplus.medication.Medication;
|
|
||||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Fixture} for {@link Medication}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class MedicationFixture implements Fixture<Medication> {
|
|
||||||
private static final String SCHEMA = "/de/hitec/nhplus/medication/database/Medication.sql";
|
|
||||||
private static final String INGREDIENT_SCHEMA = "/de/hitec/nhplus/medication/database/Medication_Ingredient.sql";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dropTable(Connection connection) throws SQLException {
|
|
||||||
connection.createStatement().execute("DROP TABLE IF EXISTS medication");
|
|
||||||
connection.createStatement().execute("DROP TABLE IF EXISTS medication_ingredient");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupTable(Connection connection) throws SQLException {
|
|
||||||
|
|
||||||
final InputStream schema = Main.class.getResourceAsStream(SCHEMA);
|
|
||||||
final InputStream ingredientSchema = Main.class.getResourceAsStream(INGREDIENT_SCHEMA);
|
|
||||||
assert schema != null;
|
|
||||||
assert ingredientSchema != null;
|
|
||||||
String SQL = new Scanner(schema, StandardCharsets.UTF_8)
|
|
||||||
.useDelimiter("\\A")
|
|
||||||
.next();
|
|
||||||
String ingredientSQL = ";" + new Scanner(ingredientSchema, StandardCharsets.UTF_8)
|
|
||||||
.useDelimiter("\\A")
|
|
||||||
.next();
|
|
||||||
connection.createStatement().execute(SQL);
|
|
||||||
connection.createStatement().execute(ingredientSQL);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Medication> load() throws SQLException {
|
|
||||||
List<Medication> medications = new ArrayList<>();
|
|
||||||
|
|
||||||
Ingredient metforminhydrochlorid = new Ingredient("Metforminhydrochlorid");
|
|
||||||
Ingredient cellulose = new Ingredient("Cellulose");
|
|
||||||
Ingredient povidon = new Ingredient("Povidon");
|
|
||||||
Ingredient magnesiumstearat = new Ingredient("Magnesiumstearat");
|
|
||||||
Ingredient lisinoprilDihydrat = new Ingredient("Lisinopril-Dihydrat");
|
|
||||||
Ingredient mannitol = new Ingredient("Mannitol");
|
|
||||||
Ingredient calciumphosphat = new Ingredient("Calciumphosphat");
|
|
||||||
Ingredient simvastatin = new Ingredient("Simvastatin");
|
|
||||||
Ingredient laktose = new Ingredient("Laktose");
|
|
||||||
Ingredient enoxaparinNatrium = new Ingredient("Enoxaparin-Natrium");
|
|
||||||
Ingredient benzylalkohol = new Ingredient("Benzylalkohol");
|
|
||||||
Ingredient wasser = new Ingredient("Wasser");
|
|
||||||
Ingredient levothyroxinnatrium = new Ingredient("Levothyroxinnatrium");
|
|
||||||
Ingredient staerke = new Ingredient("Stärke");
|
|
||||||
Ingredient akaziengummi = new Ingredient("Akaziengummi");
|
|
||||||
Ingredient warfarinnatrium = new Ingredient("Warfarinnatrium");
|
|
||||||
|
|
||||||
medications.add(new Medication(
|
|
||||||
1,
|
|
||||||
"Metformin",
|
|
||||||
"AstraZeneca",
|
|
||||||
List.of(
|
|
||||||
metforminhydrochlorid,
|
|
||||||
cellulose,
|
|
||||||
povidon,
|
|
||||||
magnesiumstearat
|
|
||||||
),
|
|
||||||
"Übelkeit, Durchfall, Laktatazidose (selten)",
|
|
||||||
"Oral",
|
|
||||||
100
|
|
||||||
));
|
|
||||||
medications.add(new Medication(
|
|
||||||
2,
|
|
||||||
"Lisinopril",
|
|
||||||
"Teva Pharmaceuticals",
|
|
||||||
List.of(
|
|
||||||
lisinoprilDihydrat,
|
|
||||||
mannitol,
|
|
||||||
calciumphosphat,
|
|
||||||
magnesiumstearat
|
|
||||||
),
|
|
||||||
"Schwindel, trockener Husten",
|
|
||||||
"Oral",
|
|
||||||
150
|
|
||||||
));
|
|
||||||
medications.add(new Medication(
|
|
||||||
3,
|
|
||||||
"Simvastatin",
|
|
||||||
"Mylan",
|
|
||||||
List.of(
|
|
||||||
simvastatin,
|
|
||||||
laktose,
|
|
||||||
cellulose,
|
|
||||||
magnesiumstearat
|
|
||||||
),
|
|
||||||
"Muskelschmerzen, Leberprobleme(selten)",
|
|
||||||
"Oral",
|
|
||||||
80
|
|
||||||
));
|
|
||||||
medications.add(new Medication(
|
|
||||||
4,
|
|
||||||
"Enoxaparin",
|
|
||||||
"Sanofi",
|
|
||||||
List.of(
|
|
||||||
enoxaparinNatrium,
|
|
||||||
benzylalkohol,
|
|
||||||
wasser
|
|
||||||
),
|
|
||||||
"Blutungen, Reaktionen an der Injektionsstelle",
|
|
||||||
"Unterhautinjektion",
|
|
||||||
120
|
|
||||||
));
|
|
||||||
medications.add(new Medication(
|
|
||||||
5,
|
|
||||||
"Levothyroxin",
|
|
||||||
"Sandoz",
|
|
||||||
List.of(
|
|
||||||
levothyroxinnatrium,
|
|
||||||
laktose,
|
|
||||||
staerke,
|
|
||||||
akaziengummi
|
|
||||||
),
|
|
||||||
"Herzrasen, Gewichtsverlust",
|
|
||||||
"Oral",
|
|
||||||
90
|
|
||||||
));
|
|
||||||
medications.add(new Medication(
|
|
||||||
6,
|
|
||||||
"Warfarin",
|
|
||||||
"Apotex Inc.",
|
|
||||||
List.of(
|
|
||||||
warfarinnatrium,
|
|
||||||
laktose,
|
|
||||||
staerke,
|
|
||||||
magnesiumstearat
|
|
||||||
),
|
|
||||||
"Blutungen, Blutergüsse",
|
|
||||||
"Oral",
|
|
||||||
110
|
|
||||||
));
|
|
||||||
MedicationDao dao = DaoFactory.getInstance().createMedicationDAO();
|
|
||||||
Map<String, Medication> medicationsByName = new HashMap<>();
|
|
||||||
for (Medication medication : medications) {
|
|
||||||
dao.create(medication);
|
|
||||||
medicationsByName.put(medication.getName(), medication);
|
|
||||||
}
|
|
||||||
return medicationsByName;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@ import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
import de.hitec.nhplus.nurse.database.NurseDao;
|
||||||
import de.hitec.nhplus.treatment.Treatment;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -12,15 +11,10 @@ import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Fixture} for {@link Nurse}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class NurseFixture implements Fixture<Nurse> {
|
public class NurseFixture implements Fixture<Nurse> {
|
||||||
@Override
|
@Override
|
||||||
public void dropTable(Connection connection) throws SQLException {
|
public void dropTable(Connection connection) throws SQLException {
|
||||||
connection.createStatement().execute("DROP TABLE IF EXISTS nurse");
|
connection.createStatement().execute("DROP TABLE nurse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,15 +13,10 @@ import java.util.*;
|
||||||
|
|
||||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Fixture} for {@link Patient}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class PatientFixture implements Fixture<Patient> {
|
public class PatientFixture implements Fixture<Patient> {
|
||||||
@Override
|
@Override
|
||||||
public void dropTable(Connection connection) throws SQLException {
|
public void dropTable(Connection connection) throws SQLException {
|
||||||
connection.createStatement().execute("DROP TABLE IF EXISTS patient");
|
connection.createStatement().execute("DROP TABLE patient");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
import de.hitec.nhplus.treatment.Treatment;
|
import de.hitec.nhplus.treatment.Treatment;
|
||||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||||
|
@ -16,24 +15,16 @@ import java.util.*;
|
||||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
||||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
|
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Fixture} for {@link Treatment}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class TreatmentFixture implements Fixture<Treatment> {
|
public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
private final Map<String, Patient> patientsByName;
|
private final Map<String, Patient> patientsByName;
|
||||||
private final Map<String, Nurse> nursesByName;
|
|
||||||
|
|
||||||
public TreatmentFixture(Map<String, Patient> patientsByName, Map<String, Nurse> nursesByName) {
|
public TreatmentFixture(Map<String, Patient> patientsByName) {
|
||||||
this.patientsByName = patientsByName;
|
this.patientsByName = patientsByName;
|
||||||
this.nursesByName = nursesByName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropTable(Connection connection) throws SQLException {
|
public void dropTable(Connection connection) throws SQLException {
|
||||||
connection.createStatement().execute("DROP TABLE IF EXISTS treatment");
|
connection.createStatement().execute("DROP TABLE treatment");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,13 +45,9 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
Patient ahmet = patientsByName.get("Ahmet");
|
Patient ahmet = patientsByName.get("Ahmet");
|
||||||
Patient elisabeth = patientsByName.get("Elisabeth");
|
Patient elisabeth = patientsByName.get("Elisabeth");
|
||||||
|
|
||||||
Nurse ole = nursesByName.get("Ole");
|
|
||||||
Nurse armin = nursesByName.get("Armin");
|
|
||||||
|
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
1,
|
1,
|
||||||
seppl,
|
seppl,
|
||||||
ole,
|
|
||||||
convertStringToLocalDate("2023-06-03"),
|
convertStringToLocalDate("2023-06-03"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
|
@ -72,7 +59,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
2,
|
2,
|
||||||
seppl,
|
seppl,
|
||||||
armin,
|
|
||||||
convertStringToLocalDate("2023-06-05"),
|
convertStringToLocalDate("2023-06-05"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("12:30"),
|
convertStringToLocalTime("12:30"),
|
||||||
|
@ -84,7 +70,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
3,
|
3,
|
||||||
martina,
|
martina,
|
||||||
ole,
|
|
||||||
convertStringToLocalDate("2023-06-04"),
|
convertStringToLocalDate("2023-06-04"),
|
||||||
convertStringToLocalTime("07:30"),
|
convertStringToLocalTime("07:30"),
|
||||||
convertStringToLocalTime("08:00"),
|
convertStringToLocalTime("08:00"),
|
||||||
|
@ -94,7 +79,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
4,
|
4,
|
||||||
seppl,
|
seppl,
|
||||||
armin,
|
|
||||||
convertStringToLocalDate("2023-06-06"),
|
convertStringToLocalDate("2023-06-06"),
|
||||||
convertStringToLocalTime("15:10"),
|
convertStringToLocalTime("15:10"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
|
@ -104,7 +88,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
8,
|
8,
|
||||||
seppl,
|
seppl,
|
||||||
ole,
|
|
||||||
convertStringToLocalDate("2023-06-08"),
|
convertStringToLocalDate("2023-06-08"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
|
@ -114,7 +97,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
9,
|
9,
|
||||||
martina,
|
martina,
|
||||||
armin,
|
|
||||||
convertStringToLocalDate("2023-06-07"),
|
convertStringToLocalDate("2023-06-07"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("11:30"),
|
convertStringToLocalTime("11:30"),
|
||||||
|
@ -124,7 +106,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
12,
|
12,
|
||||||
hans,
|
hans,
|
||||||
armin,
|
|
||||||
convertStringToLocalDate("2023-06-08"),
|
convertStringToLocalDate("2023-06-08"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
convertStringToLocalTime("15:30"),
|
convertStringToLocalTime("15:30"),
|
||||||
|
@ -134,7 +115,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
14,
|
14,
|
||||||
ahmet,
|
ahmet,
|
||||||
ole,
|
|
||||||
convertStringToLocalDate("2023-08-24"),
|
convertStringToLocalDate("2023-08-24"),
|
||||||
convertStringToLocalTime("09:30"),
|
convertStringToLocalTime("09:30"),
|
||||||
convertStringToLocalTime("10:15"),
|
convertStringToLocalTime("10:15"),
|
||||||
|
@ -143,7 +123,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
16,
|
16,
|
||||||
elisabeth,
|
elisabeth,
|
||||||
armin,
|
|
||||||
convertStringToLocalDate("2023-08-31"),
|
convertStringToLocalDate("2023-08-31"),
|
||||||
convertStringToLocalTime("13:30"),
|
convertStringToLocalTime("13:30"),
|
||||||
convertStringToLocalTime("13:45"),
|
convertStringToLocalTime("13:45"),
|
||||||
|
@ -153,7 +132,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
17,
|
17,
|
||||||
elisabeth,
|
elisabeth,
|
||||||
ole,
|
|
||||||
convertStringToLocalDate("2023-09-01"),
|
convertStringToLocalDate("2023-09-01"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
convertStringToLocalTime("17:00"),
|
convertStringToLocalTime("17:00"),
|
||||||
|
|
|
@ -12,12 +12,6 @@ import javafx.scene.layout.BorderPane;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller for the main window of the application, which holds all tabs.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class MainWindowController {
|
public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
private TabPane mainTabPane;
|
private TabPane mainTabPane;
|
||||||
|
@ -41,10 +35,6 @@ public class MainWindowController {
|
||||||
private AnchorPane lockedNursePage;
|
private AnchorPane lockedNursePage;
|
||||||
@FXML
|
@FXML
|
||||||
private Tab lockedNurseTab;
|
private Tab lockedNurseTab;
|
||||||
@FXML
|
|
||||||
private AnchorPane medicationPage;
|
|
||||||
@FXML
|
|
||||||
private Tab medicationTab;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
@ -54,7 +44,6 @@ public class MainWindowController {
|
||||||
patientTab.setOnSelectionChanged(event -> loadPatientPage());
|
patientTab.setOnSelectionChanged(event -> loadPatientPage());
|
||||||
treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage());
|
treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage());
|
||||||
nurseTab.setOnSelectionChanged(event -> loadNursePage());
|
nurseTab.setOnSelectionChanged(event -> loadNursePage());
|
||||||
medicationTab.setOnSelectionChanged(event -> loadMedicationPage());
|
|
||||||
|
|
||||||
|
|
||||||
nurseTabPane.getSelectionModel().select(activeNurseTab);
|
nurseTabPane.getSelectionModel().select(activeNurseTab);
|
||||||
|
@ -63,9 +52,6 @@ public class MainWindowController {
|
||||||
lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage());
|
lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the patient page into its tab.
|
|
||||||
*/
|
|
||||||
private void loadPatientPage() {
|
private void loadPatientPage() {
|
||||||
try {
|
try {
|
||||||
BorderPane patientsPane = FXMLLoader.load(
|
BorderPane patientsPane = FXMLLoader.load(
|
||||||
|
@ -81,9 +67,6 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the treatment page into its tab.
|
|
||||||
*/
|
|
||||||
private void loadTreatmentsPage() {
|
private void loadTreatmentsPage() {
|
||||||
try {
|
try {
|
||||||
BorderPane treatmentsPane = FXMLLoader.load(
|
BorderPane treatmentsPane = FXMLLoader.load(
|
||||||
|
@ -99,9 +82,6 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the nurse page into its tab.
|
|
||||||
*/
|
|
||||||
private void loadNursePage() {
|
private void loadNursePage() {
|
||||||
SelectionModel<Tab> selectionModel = nurseTabPane.getSelectionModel();
|
SelectionModel<Tab> selectionModel = nurseTabPane.getSelectionModel();
|
||||||
Tab selectedTab = selectionModel.getSelectedItem();
|
Tab selectedTab = selectionModel.getSelectedItem();
|
||||||
|
@ -142,22 +122,4 @@ public class MainWindowController {
|
||||||
exception.printStackTrace();
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,6 @@ package de.hitec.nhplus.main;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple base model for a {@link Person} that can be extended.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public abstract class Person {
|
public abstract class Person {
|
||||||
private final SimpleStringProperty firstName;
|
private final SimpleStringProperty firstName;
|
||||||
private final SimpleStringProperty surName;
|
private final SimpleStringProperty surName;
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
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.TableColumn;
|
|
||||||
import javafx.scene.control.TableView;
|
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The controller for viewing all {@link Medication}s.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class AllMedicationController {
|
|
||||||
@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;
|
|
||||||
|
|
||||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
|
||||||
private MedicationDao dao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization method that is called after the binding of all the fields.
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
|
||||||
readAllAndShowInTableView();
|
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
|
||||||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
|
||||||
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
|
||||||
this.columnIngredient.setCellValueFactory(
|
|
||||||
cellData -> new SimpleStringProperty(
|
|
||||||
cellData
|
|
||||||
.getValue()
|
|
||||||
.getIngredients()
|
|
||||||
.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.dao = DaoFactory.getInstance().createMedicationDAO();
|
|
||||||
try {
|
|
||||||
this.medications.setAll(dao.readAll());
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package de.hitec.nhplus.medication;
|
|
||||||
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The simple model for an {@link Ingredient}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
* @implSpec This isn't a conventional model, because it isn't directly stored in the database,
|
|
||||||
* but it can be changed to do that, in the case that its complexity rises in the future.
|
|
||||||
*/
|
|
||||||
public class Ingredient {
|
|
||||||
private final SimpleStringProperty name;
|
|
||||||
|
|
||||||
public Ingredient(String name) {
|
|
||||||
this.name = new SimpleStringProperty(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleStringProperty nameProperty() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name.set(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
package de.hitec.nhplus.medication;
|
|
||||||
|
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
|
||||||
import javafx.beans.property.SimpleListProperty;
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.collections.ObservableList;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The model for a {@link Medication}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class Medication {
|
|
||||||
private SimpleIntegerProperty id;
|
|
||||||
private final SimpleStringProperty name;
|
|
||||||
private final SimpleStringProperty manufacturer;
|
|
||||||
private final SimpleListProperty<Ingredient> ingredients;
|
|
||||||
private final SimpleStringProperty possibleSideEffects;
|
|
||||||
private final SimpleStringProperty administrationMethod;
|
|
||||||
private final SimpleIntegerProperty currentStock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This constructor allows instantiating a {@link Medication} object,
|
|
||||||
* before it is stored in the database, by omitting the {@link Medication#id ID} value.
|
|
||||||
*
|
|
||||||
* @implSpec Instances created with this constructor can be directly passed to
|
|
||||||
* {@link de.hitec.nhplus.medication.database.MedicationDao#create MedicationDao.create}.
|
|
||||||
*/
|
|
||||||
public Medication(
|
|
||||||
String name,
|
|
||||||
String manufacturer,
|
|
||||||
List<Ingredient> ingredients,
|
|
||||||
String possibleSideEffects,
|
|
||||||
String administrationMethod,
|
|
||||||
int currentStock
|
|
||||||
) {
|
|
||||||
this.name = new SimpleStringProperty(name);
|
|
||||||
this.manufacturer = new SimpleStringProperty(manufacturer);
|
|
||||||
this.ingredients = new SimpleListProperty<>(FXCollections.observableArrayList(ingredients));
|
|
||||||
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
|
|
||||||
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
|
||||||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This constructor allows instantiating a {@link Medication} object with all existing fields.
|
|
||||||
*/
|
|
||||||
public Medication(
|
|
||||||
int id,
|
|
||||||
String name,
|
|
||||||
String manufacturer,
|
|
||||||
List<Ingredient> ingredients,
|
|
||||||
String possibleSideEffects,
|
|
||||||
String administrationMethod,
|
|
||||||
int currentStock
|
|
||||||
) {
|
|
||||||
this.id = new SimpleIntegerProperty(id);
|
|
||||||
this.name = new SimpleStringProperty(name);
|
|
||||||
this.manufacturer = new SimpleStringProperty(manufacturer);
|
|
||||||
this.ingredients = new SimpleListProperty<>(FXCollections.observableArrayList(ingredients));
|
|
||||||
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
|
|
||||||
this.administrationMethod = new SimpleStringProperty(administrationMethod);
|
|
||||||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleIntegerProperty idProperty() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleStringProperty nameProperty() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name.set(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getManufacturer() {
|
|
||||||
return manufacturer.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleStringProperty manufacturerProperty() {
|
|
||||||
return manufacturer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setManufacturer(String manufacturer) {
|
|
||||||
this.manufacturer.set(manufacturer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObservableList<Ingredient> getIngredients() {
|
|
||||||
return ingredients.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleListProperty<Ingredient> ingredientsProperty() {
|
|
||||||
return ingredients;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIngredients(List<Ingredient> ingredients) {
|
|
||||||
this.ingredients.set(FXCollections.observableArrayList(ingredients));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPossibleSideEffects() {
|
|
||||||
return possibleSideEffects.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleStringProperty possibleSideEffectsProperty() {
|
|
||||||
return possibleSideEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPossibleSideEffects(String possibleSideEffects) {
|
|
||||||
this.possibleSideEffects.set(possibleSideEffects);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAdministrationMethod() {
|
|
||||||
return administrationMethod.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleStringProperty administrationMethodProperty() {
|
|
||||||
return administrationMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAdministrationMethod(String administrationMethod) {
|
|
||||||
this.administrationMethod.set(administrationMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrentStock() {
|
|
||||||
return currentStock.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleIntegerProperty currentStockProperty() {
|
|
||||||
return currentStock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentStock(int currentStock) {
|
|
||||||
this.currentStock.set(currentStock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new StringJoiner(System.lineSeparator())
|
|
||||||
.add("MEDICATION")
|
|
||||||
.add("ID: " + this.getId())
|
|
||||||
.add("Name: " + this.getName())
|
|
||||||
.add("Manufacturer: " + this.getManufacturer())
|
|
||||||
.add("Ingredients: " + this.getIngredients()
|
|
||||||
.stream()
|
|
||||||
.map(Ingredient::getName)
|
|
||||||
.collect(Collectors.joining(", ", "[", "]")))
|
|
||||||
.add("Possible Side Effects: " + this.getPossibleSideEffects())
|
|
||||||
.add("Administration Method: " + this.getAdministrationMethod())
|
|
||||||
.add("Current Stock: " + this.getCurrentStock())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,189 +0,0 @@
|
||||||
package de.hitec.nhplus.medication.database;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.Dao;
|
|
||||||
import de.hitec.nhplus.medication.Ingredient;
|
|
||||||
import de.hitec.nhplus.medication.Medication;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link MedicationDao} is an implementation of the{@link de.hitec.nhplus.datastorage.Dao Dao}
|
|
||||||
* for the {@link Medication} model.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemannn
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class MedicationDao implements Dao<Medication> {
|
|
||||||
protected final Connection connection;
|
|
||||||
|
|
||||||
public MedicationDao(Connection connection) {
|
|
||||||
this.connection = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void create(Medication medication) throws SQLException {
|
|
||||||
final String medicationSQL = """
|
|
||||||
INSERT INTO medication
|
|
||||||
(name, manufacturer, possibleSideEffects, administrationMethod, currentStock)
|
|
||||||
VALUES (?, ?, ?, ?, ?);
|
|
||||||
""";
|
|
||||||
PreparedStatement medicationStatement = this.connection.prepareStatement(medicationSQL);
|
|
||||||
medicationStatement.setString(1, medication.getName());
|
|
||||||
medicationStatement.setString(2, medication.getManufacturer());
|
|
||||||
medicationStatement.setString(3, medication.getPossibleSideEffects());
|
|
||||||
medicationStatement.setString(4, medication.getAdministrationMethod());
|
|
||||||
medicationStatement.setInt(5, medication.getCurrentStock());
|
|
||||||
medicationStatement.execute();
|
|
||||||
|
|
||||||
final String ingredientSQL = """
|
|
||||||
INSERT INTO medication_ingredient
|
|
||||||
(id, name)
|
|
||||||
VALUES (?, ?);
|
|
||||||
""";
|
|
||||||
for (Ingredient ingredient : medication.getIngredients()) {
|
|
||||||
PreparedStatement ingredientStatement = this.connection.prepareStatement(ingredientSQL);
|
|
||||||
ingredientStatement.setInt(1, medication.getId());
|
|
||||||
ingredientStatement.setString(2, ingredient.getName());
|
|
||||||
ingredientStatement.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Medication read(int id) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
SELECT medication.*, medication_ingredient.id
|
|
||||||
FROM medication
|
|
||||||
LEFT JOIN medication_ingredient ON medication.id = medication_ingredient.id
|
|
||||||
WHERE medication.id = ?
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
ResultSet result = statement.executeQuery();
|
|
||||||
return getInstanceFromResultSet(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Medication> readAll() throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
SELECT medication.*, medication_ingredient.name
|
|
||||||
FROM medication LEFT JOIN
|
|
||||||
medication_ingredient ON medication.id = medication_ingredient.id
|
|
||||||
""";
|
|
||||||
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),
|
|
||||||
List.of(),
|
|
||||||
result.getString(4),
|
|
||||||
result.getString(5),
|
|
||||||
result.getInt(6)
|
|
||||||
);
|
|
||||||
medications.add(medication);
|
|
||||||
lastMedicationId = currentMedicationId;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<Ingredient> ingredients = ingredientMap.computeIfAbsent(currentMedicationId, k -> new ArrayList<>());
|
|
||||||
ingredients.add(new Ingredient(result.getString(7)));
|
|
||||||
lastMedicationId = currentMedicationId;
|
|
||||||
}
|
|
||||||
for (Medication medication : medications) {
|
|
||||||
medication.setIngredients(ingredientMap.get(medication.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return medications;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Medication medication) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
UPDATE medication SET
|
|
||||||
name = ?,
|
|
||||||
manufacturer = ?,
|
|
||||||
possibleSideEffects = ?,
|
|
||||||
administrationMethod = ?,
|
|
||||||
currentStock = ?
|
|
||||||
WHERE id = ?
|
|
||||||
""";
|
|
||||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
|
||||||
preparedStatement.setString(1, medication.getName());
|
|
||||||
preparedStatement.setString(2, medication.getManufacturer());
|
|
||||||
preparedStatement.setString(3, medication.getPossibleSideEffects());
|
|
||||||
preparedStatement.setString(4, medication.getAdministrationMethod());
|
|
||||||
preparedStatement.setInt(5, medication.getCurrentStock());
|
|
||||||
preparedStatement.setInt(6, medication.getId());
|
|
||||||
preparedStatement.executeUpdate();
|
|
||||||
|
|
||||||
final String ingredientDeleteSQL = """
|
|
||||||
DELETE FROM medication_ingredient WHERE id = ?
|
|
||||||
""";
|
|
||||||
PreparedStatement ingredientStatement = this.connection.prepareStatement(ingredientDeleteSQL);
|
|
||||||
ingredientStatement.setInt(1, medication.getId());
|
|
||||||
ingredientStatement.executeUpdate();
|
|
||||||
|
|
||||||
final String ingredientCreateSQL = """
|
|
||||||
INSERT INTO medication_ingredient
|
|
||||||
(id, name)
|
|
||||||
VALUES (?, ?);
|
|
||||||
""";
|
|
||||||
for (Ingredient ingredient : medication.getIngredients()) {
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(ingredientCreateSQL);
|
|
||||||
statement.setInt(1, medication.getId());
|
|
||||||
statement.setString(2, ingredient.getName());
|
|
||||||
statement.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(int id) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
DELETE FROM medication WHERE medication.id = ?;
|
|
||||||
""";
|
|
||||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
|
||||||
preparedStatement.setInt(1, id);
|
|
||||||
preparedStatement.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@link Medication} object from the {@link ResultSet} obtained after executing a database query.
|
|
||||||
* This method is used internally to map the {@link ResultSet} data to a {@link Medication} object.
|
|
||||||
*
|
|
||||||
* @param result The {@link ResultSet} containing the data retrieved from the database.
|
|
||||||
* @return A {@link Medication} object constructed from the {@link ResultSet} data.
|
|
||||||
*/
|
|
||||||
private Medication getInstanceFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
Medication medication = new Medication(
|
|
||||||
result.getInt(1),
|
|
||||||
result.getString(2),
|
|
||||||
result.getString(3),
|
|
||||||
List.of(),
|
|
||||||
result.getString(4),
|
|
||||||
result.getString(5),
|
|
||||||
result.getInt(6)
|
|
||||||
);
|
|
||||||
|
|
||||||
List<Ingredient> ingredients = new ArrayList<>();
|
|
||||||
while (result.next()) {
|
|
||||||
ingredients.add(new Ingredient(result.getString(2)));
|
|
||||||
|
|
||||||
}
|
|
||||||
medication.setIngredients(ingredients);
|
|
||||||
return medication;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,12 +17,6 @@ import javafx.scene.control.cell.TextFieldTableCell;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* The controller for viewing all {@link Nurse}s.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
* @author Ole Kück
|
|
||||||
*/
|
|
||||||
public class AllNurseController {
|
public class AllNurseController {
|
||||||
@FXML
|
@FXML
|
||||||
public TextField textFieldSurName;
|
public TextField textFieldSurName;
|
||||||
|
@ -48,10 +42,6 @@ public class AllNurseController {
|
||||||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||||
private NurseDao dao;
|
private NurseDao dao;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization method that is called after the binding of all the fields.
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
this.readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
|
@ -84,28 +74,15 @@ public class AllNurseController {
|
||||||
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.addAll(this.dao.readAllActive());
|
||||||
}catch (SQLException exception){
|
}catch (SQLException exception){
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method that clears the text fields used for creating a new {@link Nurse}.
|
|
||||||
*/
|
|
||||||
private void clearTextfields() {
|
|
||||||
this.textFieldFirstName.clear();
|
|
||||||
this.textFieldSurName.clear();
|
|
||||||
this.textFieldPhoneNumber.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleAdd(){
|
public void handleAdd(){
|
||||||
String surname=this.textFieldSurName.getText();
|
String surname=this.textFieldSurName.getText();
|
||||||
|
@ -120,7 +97,6 @@ public class AllNurseController {
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
clearTextfields();
|
clearTextfields();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleLock(){
|
public void handleLock(){
|
||||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
@ -137,4 +113,11 @@ public class AllNurseController {
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearTextfields() {
|
||||||
|
this.textFieldFirstName.clear();
|
||||||
|
this.textFieldSurName.clear();
|
||||||
|
this.textFieldPhoneNumber.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,23 +7,11 @@ import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
/**
|
|
||||||
* The model for a {@link Nurse}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class Nurse extends Person {
|
public class Nurse extends Person {
|
||||||
private SimpleIntegerProperty id;
|
private SimpleIntegerProperty id;
|
||||||
private final SimpleStringProperty phoneNumber;
|
private final SimpleStringProperty phoneNumber;
|
||||||
private final SimpleBooleanProperty locked;
|
private final SimpleBooleanProperty locked;
|
||||||
|
|
||||||
/**
|
|
||||||
* This constructor allows instantiating a {@link Nurse} object,
|
|
||||||
* before it is stored in the database, by omitting the {@link Nurse#id ID} value.
|
|
||||||
*
|
|
||||||
* @implSpec Instances created with this constructor can be directly passed to
|
|
||||||
* {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}.
|
|
||||||
*/
|
|
||||||
public Nurse(
|
public Nurse(
|
||||||
String firstName,
|
String firstName,
|
||||||
String surName,
|
String surName,
|
||||||
|
@ -44,9 +32,6 @@ public class Nurse extends Person {
|
||||||
this.locked = new SimpleBooleanProperty(isLocked);
|
this.locked = new SimpleBooleanProperty(isLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This constructor allows instantiating a {@link Nurse} object with all existing fields.
|
|
||||||
*/
|
|
||||||
public Nurse(
|
public Nurse(
|
||||||
int id,
|
int id,
|
||||||
String firstName,
|
String firstName,
|
||||||
|
@ -59,7 +44,6 @@ public class Nurse extends Person {
|
||||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||||
this.locked = new SimpleBooleanProperty(isLocked);
|
this.locked = new SimpleBooleanProperty(isLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String calculateDeleteDate() {
|
public String calculateDeleteDate() {
|
||||||
//TODO: Lese alle Behandlungen die Dieser Pfleger Durchgefürt hat & brechene mit ihnen das Datum
|
//TODO: Lese alle Behandlungen die Dieser Pfleger Durchgefürt hat & brechene mit ihnen das Datum
|
||||||
return "Comming soon";
|
return "Comming soon";
|
||||||
|
|
|
@ -10,12 +10,6 @@ import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link NurseDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao}
|
|
||||||
* for the {@link Nurse} model.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class NurseDao extends DaoImp<Nurse> {
|
public class NurseDao extends DaoImp<Nurse> {
|
||||||
public NurseDao(Connection connection) {
|
public NurseDao(Connection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
|
|
|
@ -19,13 +19,6 @@ import java.time.LocalDate;
|
||||||
|
|
||||||
import static de.hitec.nhplus.utils.Validator.*;
|
import static de.hitec.nhplus.utils.Validator.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* The controller for viewing all {@link Patient}s.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
* @author Armin Ribic
|
|
||||||
*/
|
|
||||||
public class AllPatientController {
|
public class AllPatientController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -60,10 +53,6 @@ public class AllPatientController {
|
||||||
private final ObservableList<Patient> patients = FXCollections.observableArrayList();
|
private final ObservableList<Patient> patients = FXCollections.observableArrayList();
|
||||||
private PatientDao dao;
|
private PatientDao dao;
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization method that is called after the binding of all the fields.
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
this.readAllAndShowInTableView();
|
this.readAllAndShowInTableView();
|
||||||
|
|
||||||
|
@ -115,41 +104,6 @@ public class AllPatientController {
|
||||||
this.textFieldRoomNumber.textProperty().addListener(inputNewPatientValidationListener);
|
this.textFieldRoomNumber.textProperty().addListener(inputNewPatientValidationListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method to read all data and set it to the table view.
|
|
||||||
*/
|
|
||||||
private void readAllAndShowInTableView() {
|
|
||||||
this.patients.clear();
|
|
||||||
this.dao = DaoFactory.getInstance().createPatientDAO();
|
|
||||||
try {
|
|
||||||
this.patients.setAll(this.dao.readAll());
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method that stores the changes in the database.
|
|
||||||
*/
|
|
||||||
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
|
|
||||||
try {
|
|
||||||
this.dao.update(event.getRowValue());
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method that clears the text fields used for creating a new {@link Patient}.
|
|
||||||
*/
|
|
||||||
private void clearTextfields() {
|
|
||||||
this.textFieldFirstName.clear();
|
|
||||||
this.textFieldSurName.clear();
|
|
||||||
this.textFieldDateOfBirth.clear();
|
|
||||||
this.textFieldCareLevel.clear();
|
|
||||||
this.textFieldRoomNumber.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
String newFirstName = event.getNewValue();
|
String newFirstName = event.getNewValue();
|
||||||
|
@ -210,6 +164,25 @@ public class AllPatientController {
|
||||||
this.doUpdate(event);
|
this.doUpdate(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
|
||||||
|
try {
|
||||||
|
this.dao.update(event.getRowValue());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readAllAndShowInTableView() {
|
||||||
|
this.patients.clear();
|
||||||
|
this.dao = DaoFactory.getInstance().createPatientDAO();
|
||||||
|
try {
|
||||||
|
this.patients.addAll(this.dao.readAll());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleDelete() {
|
public void handleDelete() {
|
||||||
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
@ -239,4 +212,12 @@ public class AllPatientController {
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
clearTextfields();
|
clearTextfields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearTextfields() {
|
||||||
|
this.textFieldFirstName.clear();
|
||||||
|
this.textFieldSurName.clear();
|
||||||
|
this.textFieldDateOfBirth.clear();
|
||||||
|
this.textFieldCareLevel.clear();
|
||||||
|
this.textFieldRoomNumber.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
/**
|
|
||||||
* The model for a {@link Patient}.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
* @author Armin Ribic
|
|
||||||
*/
|
|
||||||
public class Patient extends Person {
|
public class Patient extends Person {
|
||||||
private SimpleIntegerProperty id;
|
private SimpleIntegerProperty id;
|
||||||
private final SimpleStringProperty dateOfBirth;
|
private final SimpleStringProperty dateOfBirth;
|
||||||
|
@ -25,13 +18,6 @@ public class Patient extends Person {
|
||||||
private final SimpleStringProperty roomNumber;
|
private final SimpleStringProperty roomNumber;
|
||||||
private final List<Treatment> allTreatments = new ArrayList<>();
|
private final List<Treatment> allTreatments = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* This constructor allows instantiating a {@link Patient} object,
|
|
||||||
* before it is stored in the database, by omitting the {@link Patient#id ID} value.
|
|
||||||
*
|
|
||||||
* @implSpec Instances created with this constructor can be directly passed to
|
|
||||||
* {@link de.hitec.nhplus.patient.database.PatientDao#create PatientDao.create}.
|
|
||||||
*/
|
|
||||||
public Patient(
|
public Patient(
|
||||||
String firstName,
|
String firstName,
|
||||||
String surName,
|
String surName,
|
||||||
|
@ -45,9 +31,6 @@ public class Patient extends Person {
|
||||||
this.roomNumber = new SimpleStringProperty(roomNumber);
|
this.roomNumber = new SimpleStringProperty(roomNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This constructor allows instantiating a {@link Patient} object with all existing fields.
|
|
||||||
*/
|
|
||||||
public Patient(
|
public Patient(
|
||||||
int id,
|
int id,
|
||||||
String firstName,
|
String firstName,
|
||||||
|
|
|
@ -11,13 +11,6 @@ import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link PatientDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao}
|
|
||||||
* for the {@link Patient} model.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemannn
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class PatientDao extends DaoImp<Patient> {
|
public class PatientDao extends DaoImp<Patient> {
|
||||||
|
|
||||||
public PatientDao(Connection connection) {
|
public PatientDao(Connection connection) {
|
||||||
|
|
|
@ -2,8 +2,6 @@ package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
import de.hitec.nhplus.patient.database.PatientDao;
|
||||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||||
|
@ -22,12 +20,6 @@ import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
|
||||||
* The controller for viewing all {@link Treatment}s.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class AllTreatmentController {
|
public class AllTreatmentController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -39,9 +31,6 @@ public class AllTreatmentController {
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Treatment, String> columnPatientName;
|
private TableColumn<Treatment, String> columnPatientName;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TableColumn<Treatment, String> columnNurseName;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Treatment, String> columnDate;
|
private TableColumn<Treatment, String> columnDate;
|
||||||
|
|
||||||
|
@ -57,9 +46,6 @@ public class AllTreatmentController {
|
||||||
@FXML
|
@FXML
|
||||||
private ComboBox<String> comboBoxPatientSelection;
|
private ComboBox<String> comboBoxPatientSelection;
|
||||||
|
|
||||||
@FXML
|
|
||||||
public ComboBox<String> comboBoxNurseSelection;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button buttonDelete;
|
private Button buttonDelete;
|
||||||
|
|
||||||
|
@ -67,19 +53,11 @@ public class AllTreatmentController {
|
||||||
private TreatmentDao dao;
|
private TreatmentDao dao;
|
||||||
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
|
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
|
||||||
private ArrayList<Patient> patientList;
|
private ArrayList<Patient> patientList;
|
||||||
private final ObservableList<String> nurseSelection = FXCollections.observableArrayList();
|
|
||||||
private ArrayList<Nurse> nurseList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization method that is called after the binding of all the fields.
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
comboBoxPatientSelection.setItems(patientSelection);
|
comboBoxPatientSelection.setItems(patientSelection);
|
||||||
comboBoxPatientSelection.getSelectionModel().select("alle");
|
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||||
|
|
||||||
comboBoxNurseSelection.setItems(nurseSelection);
|
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
this.columnPatientName.setCellValueFactory(
|
this.columnPatientName.setCellValueFactory(
|
||||||
|
@ -88,12 +66,6 @@ public class AllTreatmentController {
|
||||||
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
|
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.columnNurseName.setCellValueFactory(
|
|
||||||
cellData -> {
|
|
||||||
Nurse nurse = cellData.getValue().getNurse();
|
|
||||||
return new SimpleStringProperty(nurse.getSurName() + ", " + nurse.getFirstName());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.columnDate.setCellValueFactory(new PropertyValueFactory<>("date"));
|
this.columnDate.setCellValueFactory(new PropertyValueFactory<>("date"));
|
||||||
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
|
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
|
||||||
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
|
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
|
||||||
|
@ -111,10 +83,8 @@ public class AllTreatmentController {
|
||||||
this.createComboBoxData();
|
this.createComboBoxData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method to read all data and set it to the table view.
|
|
||||||
*/
|
|
||||||
public void readAllAndShowInTableView() {
|
public void readAllAndShowInTableView() {
|
||||||
|
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
this.treatments.setAll(dao.readAll());
|
this.treatments.setAll(dao.readAll());
|
||||||
|
@ -123,83 +93,22 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method to create the data set for the combobox that is used for creating a new {@link Treatment}.
|
|
||||||
*/
|
|
||||||
private void createComboBoxData() {
|
private void createComboBoxData() {
|
||||||
PatientDao patientDAO = DaoFactory.getInstance().createPatientDAO();
|
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
|
||||||
NurseDao nurseDao = DaoFactory.getInstance().createNurseDAO();
|
|
||||||
try {
|
try {
|
||||||
patientList = (ArrayList<Patient>) patientDAO.readAll();
|
patientList = (ArrayList<Patient>) dao.readAll();
|
||||||
this.patientSelection.add("alle");
|
this.patientSelection.add("alle");
|
||||||
for (Patient patient : patientList) {
|
for (Patient patient : patientList) {
|
||||||
this.patientSelection.add(patient.getSurName());
|
this.patientSelection.add(patient.getSurName());
|
||||||
}
|
}
|
||||||
|
|
||||||
nurseList = (ArrayList<Nurse>) nurseDao.readAll();
|
|
||||||
for (Nurse nurse : nurseList) {
|
|
||||||
this.nurseSelection.add(nurse.getSurName());
|
|
||||||
}
|
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method to get the {@link Patient} object by its surname.
|
|
||||||
*
|
|
||||||
* @see AllTreatmentController#handleComboBoxPatient
|
|
||||||
* @see AllTreatmentController#handleNewTreatment
|
|
||||||
*/
|
|
||||||
private Patient searchInPatientList(String surname) {
|
|
||||||
for (Patient patient : this.patientList) {
|
|
||||||
if (patient.getSurName().equals(surname)) {
|
|
||||||
return patient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method to get the {@link Nurse} object by its surname.
|
|
||||||
*
|
|
||||||
* @see AllTreatmentController#handleNewTreatment
|
|
||||||
*/
|
|
||||||
private Nurse searchInNurseList(String surname) {
|
|
||||||
for (Nurse nurse : this.nurseList) {
|
|
||||||
if (nurse.getSurName().equals(surname)) {
|
|
||||||
return nurse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to save the changes to a {@link Treatment}.
|
|
||||||
*/
|
|
||||||
protected void updateTreatment(Treatment treatment) {
|
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
|
||||||
try {
|
|
||||||
dao.update(treatment);
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create a new {@link Treatment}.
|
|
||||||
*/
|
|
||||||
public void createTreatment(Treatment treatment) {
|
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
|
||||||
try {
|
|
||||||
dao.create(treatment);
|
|
||||||
} catch (SQLException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleComboBoxPatient() {
|
public void handleComboBox() {
|
||||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||||
this.treatments.clear();
|
this.treatments.clear();
|
||||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
|
@ -212,51 +121,24 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Patient patient = searchInPatientList(selectedPatient);
|
Patient patient = searchInList(selectedPatient);
|
||||||
if (patient != null) {
|
if (patient != null) {
|
||||||
try {
|
try {
|
||||||
this.treatments.setAll(this.dao.readTreatmentsByPatient(patient.getId()));
|
this.treatments.setAll(this.dao.readTreatmentsByPid(patient.getId()));
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Patient searchInList(String surname) {
|
||||||
* Internal method to create a {@link TreatmentModalController TreatmentModal}.
|
for (Patient patient : this.patientList) {
|
||||||
*
|
if (patient.getSurName().equals(surname)) {
|
||||||
* @param treatment The {@link Treatment} which should be edited. Set null to create a new one.
|
return patient;
|
||||||
* @param title The Title of the created modal.
|
|
||||||
* @param patient The {@link Patient} whose {@link Treatment} this is.
|
|
||||||
* @param nurse The {@link Nurse} who did the {@link Treatment}.
|
|
||||||
*/
|
|
||||||
public void treatmentWindow(Treatment treatment, String title, Patient patient, Nurse nurse) {
|
|
||||||
try {
|
|
||||||
FXMLLoader loader = new FXMLLoader(
|
|
||||||
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
|
||||||
);
|
|
||||||
BorderPane pane = loader.load();
|
|
||||||
Scene scene = new Scene(pane);
|
|
||||||
Stage stage = new Stage();
|
|
||||||
|
|
||||||
TreatmentModalController controller = loader.getController();
|
|
||||||
controller.initialize(
|
|
||||||
this,
|
|
||||||
stage,
|
|
||||||
treatment,
|
|
||||||
patient,
|
|
||||||
nurse
|
|
||||||
);
|
|
||||||
|
|
||||||
stage.setScene(scene);
|
|
||||||
stage.setTitle(title);
|
|
||||||
stage.setResizable(true);
|
|
||||||
stage.setAlwaysOnTop(true);
|
|
||||||
stage.showAndWait();
|
|
||||||
} catch (IOException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleDelete() {
|
public void handleDelete() {
|
||||||
|
@ -272,31 +154,17 @@ public class AllTreatmentController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleNewTreatment() {
|
public void handleNewTreatment() {
|
||||||
|
try {
|
||||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||||
Patient patient = searchInPatientList(selectedPatient);
|
Patient patient = searchInList(selectedPatient);
|
||||||
|
newTreatmentWindow(patient);
|
||||||
if(patient == null) {
|
} catch (NullPointerException exception) {
|
||||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
alert.setTitle("Information");
|
alert.setTitle("Information");
|
||||||
alert.setHeaderText("Patient für die Behandlung fehlt!");
|
alert.setHeaderText("Patient für die Behandlung fehlt!");
|
||||||
alert.setContentText("Wählen Sie über die Combobox einen Patienten aus!");
|
alert.setContentText("Wählen Sie über die Combobox einen Patienten aus!");
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedNurse = this.comboBoxNurseSelection.getSelectionModel().getSelectedItem();
|
|
||||||
Nurse nurse = searchInNurseList(selectedNurse);
|
|
||||||
|
|
||||||
if(nurse == null) {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
|
||||||
alert.setTitle("Information");
|
|
||||||
alert.setHeaderText("Pfleger für die Behandlung fehlt!");
|
|
||||||
alert.setContentText("Wählen Sie über die Combobox einen Pfleger aus!");
|
|
||||||
alert.showAndWait();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
treatmentWindow(null, "NHPlus - Neue Behandlung", patient, nurse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -306,14 +174,81 @@ public class AllTreatmentController {
|
||||||
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
|
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
|
||||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||||
Treatment treatment = this.treatments.get(index);
|
Treatment treatment = this.treatments.get(index);
|
||||||
treatmentWindow(
|
treatmentWindow(treatment);
|
||||||
treatment,
|
|
||||||
"NHPlus - Behandlung",
|
|
||||||
treatment.getPatient(),
|
|
||||||
treatment.getNurse()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void newTreatmentWindow(Patient patient) {
|
||||||
|
try {
|
||||||
|
FXMLLoader loader = new FXMLLoader(
|
||||||
|
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||||
|
);
|
||||||
|
BorderPane pane = loader.load();
|
||||||
|
Scene scene = new Scene(pane);
|
||||||
|
Stage stage = new Stage();
|
||||||
|
|
||||||
|
TreatmentModalController controller = loader.getController();
|
||||||
|
controller.initialize(
|
||||||
|
this,
|
||||||
|
stage,
|
||||||
|
null,
|
||||||
|
patient
|
||||||
|
);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("NHPlus - Neue Behandlung");
|
||||||
|
stage.setResizable(true);
|
||||||
|
stage.setAlwaysOnTop(true);
|
||||||
|
stage.showAndWait();
|
||||||
|
} catch (IOException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void treatmentWindow(Treatment treatment) {
|
||||||
|
try {
|
||||||
|
FXMLLoader loader = new FXMLLoader(
|
||||||
|
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||||
|
);
|
||||||
|
BorderPane pane = loader.load();
|
||||||
|
Scene scene = new Scene(pane);
|
||||||
|
Stage stage = new Stage();
|
||||||
|
|
||||||
|
TreatmentModalController controller = loader.getController();
|
||||||
|
PatientDao pDao = DaoFactory.getInstance().createPatientDAO();
|
||||||
|
controller.initialize(
|
||||||
|
this,
|
||||||
|
stage,
|
||||||
|
treatment,
|
||||||
|
pDao.read(treatment.getPatient().getId())
|
||||||
|
);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("NHPlus - Behandlung");
|
||||||
|
stage.setResizable(true);
|
||||||
|
stage.setAlwaysOnTop(true);
|
||||||
|
stage.showAndWait();
|
||||||
|
} catch (IOException | SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createTreatment(Treatment treatment) {
|
||||||
|
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
|
try {
|
||||||
|
dao.create(treatment);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTreatment(Treatment treatment) {
|
||||||
|
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
|
try {
|
||||||
|
dao.update(treatment);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.hitec.nhplus.treatment;
|
package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
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.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
@ -11,40 +10,18 @@ import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
/**
|
|
||||||
* The model for a {@link Treatment}.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class Treatment {
|
public class Treatment {
|
||||||
private SimpleIntegerProperty id;
|
private SimpleIntegerProperty id;
|
||||||
private final SimpleObjectProperty<Patient> patient;
|
private final SimpleObjectProperty<Patient> patient;
|
||||||
private final SimpleObjectProperty<Nurse> nurse;
|
|
||||||
private final SimpleObjectProperty<LocalDate> date;
|
private final SimpleObjectProperty<LocalDate> date;
|
||||||
private final SimpleObjectProperty<LocalTime> begin;
|
private final SimpleObjectProperty<LocalTime> begin;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
public Treatment(Patient patient, LocalDate date, LocalTime begin,
|
||||||
* This constructor allows instantiating a {@link Treatment} object,
|
LocalTime end, String description, String remarks) {
|
||||||
* before it is stored in the database, by omitting the {@link Treatment#id ID} value.
|
|
||||||
*
|
|
||||||
* @implSpec Instances created with this constructor can be directly passed to
|
|
||||||
* {@link de.hitec.nhplus.treatment.database.TreatmentDao#create TreatmentDao.create}.
|
|
||||||
*/
|
|
||||||
public Treatment(
|
|
||||||
Patient patient,
|
|
||||||
Nurse nurse,
|
|
||||||
LocalDate date,
|
|
||||||
LocalTime begin,
|
|
||||||
LocalTime end,
|
|
||||||
String description,
|
|
||||||
String remarks
|
|
||||||
) {
|
|
||||||
this.patient = new SimpleObjectProperty<>(patient);
|
this.patient = new SimpleObjectProperty<>(patient);
|
||||||
this.nurse = new SimpleObjectProperty<>(nurse);
|
|
||||||
this.date = new SimpleObjectProperty<>(date);
|
this.date = new SimpleObjectProperty<>(date);
|
||||||
this.begin = new SimpleObjectProperty<>(begin);
|
this.begin = new SimpleObjectProperty<>(begin);
|
||||||
this.end = new SimpleObjectProperty<>(end);
|
this.end = new SimpleObjectProperty<>(end);
|
||||||
|
@ -52,22 +29,10 @@ public class Treatment {
|
||||||
this.remarks = new SimpleStringProperty(remarks);
|
this.remarks = new SimpleStringProperty(remarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Treatment(int id, Patient patient, LocalDate date, LocalTime begin,
|
||||||
* This constructor allows instantiating a {@link Treatment} object with all existing fields.
|
LocalTime end, String description, String remarks) {
|
||||||
*/
|
|
||||||
public Treatment(
|
|
||||||
int id,
|
|
||||||
Patient patient,
|
|
||||||
Nurse nurse,
|
|
||||||
LocalDate date,
|
|
||||||
LocalTime begin,
|
|
||||||
LocalTime end,
|
|
||||||
String description,
|
|
||||||
String remarks
|
|
||||||
) {
|
|
||||||
this.id = new SimpleIntegerProperty(id);
|
this.id = new SimpleIntegerProperty(id);
|
||||||
this.patient = new SimpleObjectProperty<>(patient);
|
this.patient = new SimpleObjectProperty<>(patient);
|
||||||
this.nurse = new SimpleObjectProperty<>(nurse);
|
|
||||||
this.date = new SimpleObjectProperty<>(date);
|
this.date = new SimpleObjectProperty<>(date);
|
||||||
this.begin = new SimpleObjectProperty<>(begin);
|
this.begin = new SimpleObjectProperty<>(begin);
|
||||||
this.end = new SimpleObjectProperty<>(end);
|
this.end = new SimpleObjectProperty<>(end);
|
||||||
|
@ -83,10 +48,6 @@ public class Treatment {
|
||||||
return patient.getValue();
|
return patient.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Nurse getNurse() {
|
|
||||||
return nurse.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDate() {
|
public String getDate() {
|
||||||
return date.getValue().toString();
|
return date.getValue().toString();
|
||||||
}
|
}
|
||||||
|
@ -127,10 +88,6 @@ public class Treatment {
|
||||||
return patient;
|
return patient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleObjectProperty<Nurse> nurseProperty() {
|
|
||||||
return nurse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<LocalDate> dateProperty() {
|
public SimpleObjectProperty<LocalDate> dateProperty() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +117,6 @@ public class Treatment {
|
||||||
.add("TREATMENT")
|
.add("TREATMENT")
|
||||||
.add("ID: " + this.getId())
|
.add("ID: " + this.getId())
|
||||||
.add("Patient: " + this.getPatient().getSurName() + ", " + this.getPatient().getFirstName())
|
.add("Patient: " + this.getPatient().getSurName() + ", " + this.getPatient().getFirstName())
|
||||||
.add("Nurse: " + this.getNurse().getSurName() + ", " + this.getNurse().getFirstName())
|
|
||||||
.add("Date: " + this.getDate())
|
.add("Date: " + this.getDate())
|
||||||
.add("Begin: " + this.getBegin())
|
.add("Begin: " + this.getBegin())
|
||||||
.add("End: " + this.getEnd())
|
.add("End: " + this.getEnd())
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.hitec.nhplus.treatment;
|
package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
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.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
|
@ -14,14 +13,7 @@ import java.time.LocalTime;
|
||||||
|
|
||||||
import static de.hitec.nhplus.utils.Validator.*;
|
import static de.hitec.nhplus.utils.Validator.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* The controller for creating and editing a specific {@link Treatment}.
|
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class TreatmentModalController {
|
public class TreatmentModalController {
|
||||||
@FXML
|
|
||||||
private Label labelNurseName;
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label labelFirstName;
|
private Label labelFirstName;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -41,30 +33,18 @@ public class TreatmentModalController {
|
||||||
private AllTreatmentController controller;
|
private AllTreatmentController controller;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Patient patient;
|
private Patient patient;
|
||||||
private Nurse nurse;
|
|
||||||
private Treatment treatment;
|
private Treatment treatment;
|
||||||
private boolean isNewTreatment = false;
|
private boolean isNewTreatment = false;
|
||||||
|
|
||||||
/**
|
public void initialize(AllTreatmentController controller, Stage stage, Treatment treatment, Patient patient) {
|
||||||
* Initialization method that is called after the binding of all the fields.
|
|
||||||
*/
|
|
||||||
public void initialize(
|
|
||||||
AllTreatmentController controller,
|
|
||||||
Stage stage,
|
|
||||||
Treatment treatment,
|
|
||||||
Patient patient,
|
|
||||||
Nurse nurse
|
|
||||||
) {
|
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.patient = patient;
|
this.patient = patient;
|
||||||
this.nurse = nurse;
|
|
||||||
if (treatment == null) {
|
if (treatment == null) {
|
||||||
isNewTreatment = true;
|
isNewTreatment = true;
|
||||||
LocalTime currentTime = LocalTime.now();
|
LocalTime currentTime = LocalTime.now();
|
||||||
this.treatment = new Treatment(
|
this.treatment = new Treatment(
|
||||||
patient,
|
patient,
|
||||||
nurse,
|
|
||||||
LocalDate.now(),
|
LocalDate.now(),
|
||||||
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
||||||
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
||||||
|
@ -117,11 +97,7 @@ public class TreatmentModalController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal method to show the data in the view.
|
|
||||||
*/
|
|
||||||
private void showData() {
|
private void showData() {
|
||||||
this.labelNurseName.setText(nurse.getSurName());
|
|
||||||
this.labelFirstName.setText(patient.getFirstName());
|
this.labelFirstName.setText(patient.getFirstName());
|
||||||
this.labelSurName.setText(patient.getSurName());
|
this.labelSurName.setText(patient.getSurName());
|
||||||
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
|
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
|
||||||
|
@ -160,4 +136,8 @@ public class TreatmentModalController {
|
||||||
public void handleCancel() {
|
public void handleCancel() {
|
||||||
stage.close();
|
stage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Treatment getTreatment() {
|
||||||
|
return treatment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package de.hitec.nhplus.treatment.database;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.datastorage.DaoImp;
|
import de.hitec.nhplus.datastorage.DaoImp;
|
||||||
import de.hitec.nhplus.patient.Patient;
|
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
|
||||||
import de.hitec.nhplus.treatment.Treatment;
|
import de.hitec.nhplus.treatment.Treatment;
|
||||||
import de.hitec.nhplus.utils.DateConverter;
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
|
|
||||||
|
@ -14,13 +12,6 @@ import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link TreatmentDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao}
|
|
||||||
* for the {@link Treatment} model.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemannn
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public class TreatmentDao extends DaoImp<Treatment> {
|
public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
|
|
||||||
public TreatmentDao(Connection connection) {
|
public TreatmentDao(Connection connection) {
|
||||||
|
@ -31,17 +22,16 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
INSERT INTO treatment
|
INSERT INTO treatment
|
||||||
(patientId, nurseId, date, begin, end, description, remark)
|
(patientId, date, begin, end, description, remark)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
""";
|
""";
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
statement.setInt(1, treatment.getPatient().getId());
|
statement.setInt(1, treatment.getPatient().getId());
|
||||||
statement.setInt(2, treatment.getNurse().getId());
|
statement.setString(2, treatment.getDate());
|
||||||
statement.setString(3, treatment.getDate());
|
statement.setString(3, treatment.getBegin());
|
||||||
statement.setString(4, treatment.getBegin());
|
statement.setString(4, treatment.getEnd());
|
||||||
statement.setString(5, treatment.getEnd());
|
statement.setString(5, treatment.getDescription());
|
||||||
statement.setString(6, treatment.getDescription());
|
statement.setString(6, treatment.getRemarks());
|
||||||
statement.setString(7, treatment.getRemarks());
|
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +48,11 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
return new Treatment(
|
return new Treatment(
|
||||||
result.getInt(1),
|
result.getInt(1),
|
||||||
DaoFactory.getInstance().createPatientDAO().read(result.getInt(2)),
|
DaoFactory.getInstance().createPatientDAO().read(result.getInt(2)),
|
||||||
DaoFactory.getInstance().createNurseDAO().read(result.getInt(3)),
|
DateConverter.convertStringToLocalDate(result.getString(3)),
|
||||||
DateConverter.convertStringToLocalDate(result.getString(4)),
|
DateConverter.convertStringToLocalTime(result.getString(4)),
|
||||||
DateConverter.convertStringToLocalTime(result.getString(5)),
|
DateConverter.convertStringToLocalTime(result.getString(5)),
|
||||||
DateConverter.convertStringToLocalTime(result.getString(6)),
|
result.getString(6),
|
||||||
result.getString(7),
|
result.getString(7)
|
||||||
result.getString(8)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,33 +71,15 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(int patientId) throws SQLException {
|
||||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
|
||||||
* {@link Patient#id patient ID} from the database.
|
|
||||||
*
|
|
||||||
* @param patientId The {@link Patient#id ID} of the {@link Patient} whose {@link Treatment}s are to be retrieved.
|
|
||||||
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Patient} ID.
|
|
||||||
*/
|
|
||||||
public List<Treatment> readTreatmentsByPatient(int patientId) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
statement.setInt(1, patientId);
|
statement.setInt(1, patientId);
|
||||||
ResultSet result = statement.executeQuery();
|
return statement;
|
||||||
return getListFromResultSet(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public List<Treatment> readTreatmentsByPid(int patientId) throws SQLException {
|
||||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
ResultSet result = getReadAllTreatmentsOfOnePatientByPid(patientId).executeQuery();
|
||||||
* {@link Nurse#id patient ID} from the database.
|
|
||||||
*
|
|
||||||
* @param nurseId The {@link Nurse#id ID} of the {@link Nurse} whose {@link Treatment}s are to be retrieved.
|
|
||||||
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Nurse} ID.
|
|
||||||
*/
|
|
||||||
public List<Treatment> readTreatmentsByNurse(int nurseId) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE nurseId = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, nurseId);
|
|
||||||
ResultSet result = statement.executeQuery();
|
|
||||||
return getListFromResultSet(result);
|
return getListFromResultSet(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +87,7 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
UPDATE treatment SET
|
UPDATE treatment SET
|
||||||
|
patientId = ?,
|
||||||
date = ?,
|
date = ?,
|
||||||
begin = ?,
|
begin = ?,
|
||||||
end = ?,
|
end = ?,
|
||||||
|
@ -124,12 +96,13 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
""";
|
""";
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||||
statement.setString(1, treatment.getDate());
|
statement.setInt(1, treatment.getPatient().getId());
|
||||||
statement.setString(2, treatment.getBegin());
|
statement.setString(2, treatment.getDate());
|
||||||
statement.setString(3, treatment.getEnd());
|
statement.setString(3, treatment.getBegin());
|
||||||
statement.setString(4, treatment.getDescription());
|
statement.setString(4, treatment.getEnd());
|
||||||
statement.setString(5, treatment.getRemarks());
|
statement.setString(5, treatment.getDescription());
|
||||||
statement.setInt(6, treatment.getId());
|
statement.setString(6, treatment.getRemarks());
|
||||||
|
statement.setInt(7, treatment.getId());
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,44 +4,23 @@ import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
/**
|
|
||||||
* A utility class that holds utility methods for date conversion.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
public class DateConverter {
|
public class DateConverter {
|
||||||
|
|
||||||
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||||
private static final String TIME_FORMAT = "HH:mm";
|
private static final String TIME_FORMAT = "HH:mm";
|
||||||
|
|
||||||
/**
|
|
||||||
* @param date A date {@link String} in the format: yyyy-MM-dd.
|
|
||||||
* @return The converted date {@link String} as {@link LocalDate}.
|
|
||||||
*/
|
|
||||||
public static LocalDate convertStringToLocalDate(String date) {
|
public static LocalDate convertStringToLocalDate(String date) {
|
||||||
return LocalDate.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT));
|
return LocalDate.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param time A time {@link String} in the format: HH:mm.
|
|
||||||
* @return The converted time {@link String} as {@link LocalTime}.
|
|
||||||
*/
|
|
||||||
public static LocalTime convertStringToLocalTime(String time) {
|
public static LocalTime convertStringToLocalTime(String time) {
|
||||||
return LocalTime.parse(time, DateTimeFormatter.ofPattern(TIME_FORMAT));
|
return LocalTime.parse(time, DateTimeFormatter.ofPattern(TIME_FORMAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param date A {@link LocalDate} which should be converted to a {@link String}.
|
|
||||||
* @return The converted {@link LocalDate} in the format: yyy-MM-dd.
|
|
||||||
*/
|
|
||||||
public static String convertLocalDateToString(LocalDate date) {
|
public static String convertLocalDateToString(LocalDate date) {
|
||||||
return date.format(DateTimeFormatter.ofPattern(DATE_FORMAT));
|
return date.format(DateTimeFormatter.ofPattern(DATE_FORMAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param time A {@link LocalTime} which should be converted to a {@link String}.
|
|
||||||
* @return The converted {@link LocalTime} in the format: HH:mm.
|
|
||||||
*/
|
|
||||||
public static String convertLocalTimeToString(LocalTime time) {
|
public static String convertLocalTimeToString(LocalTime time) {
|
||||||
return time.format(DateTimeFormatter.ofPattern(TIME_FORMAT));
|
return time.format(DateTimeFormatter.ofPattern(TIME_FORMAT));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,19 +5,8 @@ import javafx.scene.control.Alert;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
/**
|
public class Validator
|
||||||
* A utility class for validating all kinds of data.
|
{
|
||||||
*
|
|
||||||
* @author Dominik Säume
|
|
||||||
* @author Ole Kück
|
|
||||||
*/
|
|
||||||
public class Validator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows a modal with a specific validation error.
|
|
||||||
*
|
|
||||||
* @param type The type for which a validation error should be shown as {@link String}.
|
|
||||||
*/
|
|
||||||
public static void showValidationError(String type){
|
public static void showValidationError(String type){
|
||||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||||
alert.setTitle("Error");
|
alert.setTitle("Error");
|
||||||
|
@ -25,12 +14,6 @@ public class Validator {
|
||||||
alert.setContentText("Invalid " + type + " !");
|
alert.setContentText("Invalid " + type + " !");
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid date.
|
|
||||||
*
|
|
||||||
* @param text The date {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidDate(String text) {
|
public static boolean isValidDate(String text) {
|
||||||
if(text.isBlank()){
|
if(text.isBlank()){
|
||||||
return false;
|
return false;
|
||||||
|
@ -42,12 +25,6 @@ public class Validator {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link LocalDate} is a valid date for storage in the database.
|
|
||||||
*
|
|
||||||
* @param date The {@link LocalDate} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidDate(LocalDate date) {
|
public static boolean isValidDate(LocalDate date) {
|
||||||
if(date == null){
|
if(date == null){
|
||||||
return false;
|
return false;
|
||||||
|
@ -59,12 +36,6 @@ public class Validator {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid time.
|
|
||||||
*
|
|
||||||
* @param text The time {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidTime(String text){
|
public static boolean isValidTime(String text){
|
||||||
if(text.isBlank()){
|
if(text.isBlank()){
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,13 +47,6 @@ public class Validator {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that two time {@link String}s are a valid time range.
|
|
||||||
*
|
|
||||||
* @param start The starting time {@link String}.
|
|
||||||
* @param end The ending time {@link String}.
|
|
||||||
*/
|
|
||||||
public static boolean isValidTimeRange(String start, String end){
|
public static boolean isValidTimeRange(String start, String end){
|
||||||
if(
|
if(
|
||||||
!isValidTime(start) || !isValidTime(end)
|
!isValidTime(start) || !isValidTime(end)
|
||||||
|
@ -95,57 +59,24 @@ public class Validator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid description.
|
|
||||||
*
|
|
||||||
* @param text The {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidDescription(String text) {
|
public static boolean isValidDescription(String text) {
|
||||||
return !text.isBlank();
|
return !text.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid first name.
|
|
||||||
*
|
|
||||||
* @param text The {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidFirstName(String text){
|
public static boolean isValidFirstName(String text){
|
||||||
return !text.isBlank();
|
return !text.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid surname.
|
|
||||||
*
|
|
||||||
* @param text The {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidSurName(String text){
|
public static boolean isValidSurName(String text){
|
||||||
return !text.isBlank();
|
return !text.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid phone number.
|
|
||||||
*
|
|
||||||
* @param text The {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidPhoneNumber(String text){
|
public static boolean isValidPhoneNumber(String text){
|
||||||
return !text.isBlank();
|
return !text.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid care level.
|
|
||||||
*
|
|
||||||
* @param text The {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidCareLevel(String text){
|
public static boolean isValidCareLevel(String text){
|
||||||
return !text.isBlank();
|
return !text.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that a {@link String} is a valid room number.
|
|
||||||
*
|
|
||||||
* @param text The {@link String} to validate.
|
|
||||||
*/
|
|
||||||
public static boolean isValidRoomNumber(String text){
|
public static boolean isValidRoomNumber(String text){
|
||||||
return !text.isBlank();
|
return !text.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,4 @@ module de.hitec.nhplus {
|
||||||
exports de.hitec.nhplus.nurse.database;
|
exports de.hitec.nhplus.nurse.database;
|
||||||
opens de.hitec.nhplus.nurse to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.nurse to javafx.base, javafx.fxml;
|
||||||
opens de.hitec.nhplus.nurse.database to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.nurse.database to javafx.base, javafx.fxml;
|
||||||
|
|
||||||
exports de.hitec.nhplus.medication;
|
|
||||||
exports de.hitec.nhplus.medication.database;
|
|
||||||
opens de.hitec.nhplus.medication to javafx.base, javafx.fxml;
|
|
||||||
opens de.hitec.nhplus.medication.database to javafx.base, javafx.fxml;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.Tab?>
|
||||||
|
<?import javafx.scene.control.TabPane?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<TabPane
|
<TabPane
|
||||||
fx:id="mainTabPane"
|
fx:id="mainTabPane"
|
||||||
|
@ -25,7 +26,4 @@
|
||||||
</Tab>
|
</Tab>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab fx:id="medicationTab" text="Medikamente">
|
|
||||||
<AnchorPane fx:id="medicationPage"/>
|
|
||||||
</Tab>
|
|
||||||
</TabPane>
|
</TabPane>
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
<?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.AllMedicationController"
|
|
||||||
>
|
|
||||||
<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="buttonAdd"
|
|
||||||
mnemonicParsing="false"
|
|
||||||
prefWidth="90.0"
|
|
||||||
text="Hinzufügen"
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
fx:id="buttonDelete"
|
|
||||||
mnemonicParsing="false"
|
|
||||||
prefWidth="90.0"
|
|
||||||
text="Löschen"
|
|
||||||
/>
|
|
||||||
</HBox>
|
|
||||||
</right>
|
|
||||||
</BorderPane>
|
|
||||||
</bottom>
|
|
||||||
</BorderPane>
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE TABLE medication
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
name TEXT NOT NULL,
|
|
||||||
manufacturer TEXT NOT NULL,
|
|
||||||
possibleSideEffects TEXT NOT NULL,
|
|
||||||
administrationMethod TEXT NOT NULL,
|
|
||||||
currentStock INTEGER NOT NULL
|
|
||||||
)
|
|
|
@ -1,6 +0,0 @@
|
||||||
CREATE TABLE medication_ingredient
|
|
||||||
(
|
|
||||||
id INTEGER NOT NULL ,
|
|
||||||
name TEXT NOT NULL,
|
|
||||||
FOREIGN KEY (id) REFERENCES medication (id) ON DELETE CASCADE
|
|
||||||
)
|
|
|
@ -12,7 +12,7 @@
|
||||||
<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" editable="true">
|
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnId"
|
fx:id="columnId"
|
||||||
|
|
|
@ -28,11 +28,6 @@
|
||||||
minWidth="80.0"
|
minWidth="80.0"
|
||||||
text="Patient"
|
text="Patient"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
|
||||||
fx:id="columnNurseName"
|
|
||||||
minWidth="80.0"
|
|
||||||
text="Pflegekraft"
|
|
||||||
/>
|
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnDate"
|
fx:id="columnDate"
|
||||||
maxWidth="-1.0"
|
maxWidth="-1.0"
|
||||||
|
@ -71,11 +66,7 @@
|
||||||
<ComboBox
|
<ComboBox
|
||||||
fx:id="comboBoxPatientSelection"
|
fx:id="comboBoxPatientSelection"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
onAction="#handleComboBoxPatient"
|
onAction="#handleComboBox"
|
||||||
/>
|
|
||||||
<ComboBox
|
|
||||||
fx:id="comboBoxNurseSelection"
|
|
||||||
prefWidth="200.0"
|
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
mnemonicParsing="false"
|
mnemonicParsing="false"
|
||||||
|
|
|
@ -30,33 +30,21 @@
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="0"
|
GridPane.columnIndex="0"
|
||||||
text="Pfleger:"
|
text="Vorname:"
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
prefWidth="200"
|
prefWidth="200"
|
||||||
fx:id="labelNurseName" text="Pfleger Name"
|
|
||||||
/>
|
|
||||||
<!-- Row 1 -->
|
|
||||||
<Label
|
|
||||||
GridPane.rowIndex="1"
|
|
||||||
GridPane.columnIndex="0"
|
|
||||||
text="Vorname:"
|
|
||||||
/>
|
|
||||||
<Label
|
|
||||||
GridPane.rowIndex="1"
|
|
||||||
GridPane.columnIndex="1"
|
|
||||||
prefWidth="200"
|
|
||||||
fx:id="labelFirstName" text="Vorname"
|
fx:id="labelFirstName" text="Vorname"
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="1"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="3"
|
GridPane.columnIndex="3"
|
||||||
text="Nachname:"
|
text="Nachname:"
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="1"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
prefWidth="200"
|
prefWidth="200"
|
||||||
fx:id="labelSurName"
|
fx:id="labelSurName"
|
||||||
|
|
|
@ -2,12 +2,10 @@ CREATE TABLE treatment
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
patientId INTEGER NOT NULL,
|
patientId INTEGER NOT NULL,
|
||||||
nurseId INTEGER NOT NULL ,
|
|
||||||
date TEXT NOT NULL,
|
date TEXT NOT NULL,
|
||||||
begin TEXT NOT NULL,
|
begin TEXT NOT NULL,
|
||||||
end TEXT NOT NULL,
|
end TEXT NOT NULL,
|
||||||
description TEXT NOT NULL,
|
description TEXT NOT NULL,
|
||||||
remark TEXT NOT NULL,
|
remark TEXT NOT NULL,
|
||||||
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
|
|
||||||
)
|
)
|
Loading…
Reference in a new issue