Compare commits
3 commits
6411b15a37
...
ab6892bddd
Author | SHA1 | Date | |
---|---|---|---|
ab6892bddd | |||
cbecf482b8 | |||
60b3d587ea |
35 changed files with 742 additions and 827 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
<data-source source="LOCAL" name="Database" uuid="5a5b8be1-080b-4129-b89d-42f1ea832b90">
|
<data-source source="LOCAL" name="nursingHome.db" uuid="5a5b8be1-080b-4129-b89d-42f1ea832b90">
|
||||||
<driver-ref>sqlite.xerial</driver-ref>
|
<driver-ref>sqlite.xerial</driver-ref>
|
||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DdlMappings">
|
|
||||||
<mapping uuid="6de31afe-6f51-4d57-ac29-b95200cc6a68" name="Database Mapping">
|
|
||||||
<data-sources db="5a5b8be1-080b-4129-b89d-42f1ea832b90" ddl="82842a6c-e549-4bc0-9743-9bdb8b472dfc" />
|
|
||||||
<scope>
|
|
||||||
<node negative="1">
|
|
||||||
<node kind="database" negative="1">
|
|
||||||
<node kind="schema" negative="1" />
|
|
||||||
</node>
|
|
||||||
<node kind="schema" qname="main" />
|
|
||||||
</node>
|
|
||||||
</scope>
|
|
||||||
</mapping>
|
|
||||||
</component>
|
|
||||||
<component name="SqlDataSourceStorage">
|
|
||||||
<option name="dataSources">
|
|
||||||
<list>
|
|
||||||
<State>
|
|
||||||
<option name="id" value="82842a6c-e549-4bc0-9743-9bdb8b472dfc" />
|
|
||||||
<option name="name" value="NHPlus DDL" />
|
|
||||||
<option name="dbmsName" value="SQLITE" />
|
|
||||||
<option name="urls">
|
|
||||||
<array>
|
|
||||||
<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/nurse/database/Nurse.sql" />
|
|
||||||
</array>
|
|
||||||
</option>
|
|
||||||
<option name="outLayout" value="File per object by schema.groovy" />
|
|
||||||
</State>
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<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/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/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>
|
Binary file not shown.
|
@ -1,17 +1,11 @@
|
||||||
package de.hitec.nhplus.datastorage;
|
package de.hitec.nhplus.datastorage;
|
||||||
|
|
||||||
import org.sqlite.SQLiteConfig;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
/**
|
import org.sqlite.SQLiteConfig;
|
||||||
* The {@link DaoFactory} allows a safe connection to the Database.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class ConnectionBuilder {
|
public class ConnectionBuilder {
|
||||||
|
|
||||||
private static final String DB_NAME = "nursingHome.db";
|
private static final String DB_NAME = "nursingHome.db";
|
||||||
|
@ -19,10 +13,6 @@ public class ConnectionBuilder {
|
||||||
|
|
||||||
private static Connection connection;
|
private static Connection connection;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a Thread-safe {@link Connection} to the Database.
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
synchronized public static Connection getConnection() {
|
synchronized public static Connection getConnection() {
|
||||||
try {
|
try {
|
||||||
if (ConnectionBuilder.connection == null) {
|
if (ConnectionBuilder.connection == null) {
|
||||||
|
@ -37,11 +27,6 @@ public class ConnectionBuilder {
|
||||||
return ConnectionBuilder.connection;
|
return ConnectionBuilder.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the Connection to the Database.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
synchronized public static void closeConnection() {
|
synchronized public static void closeConnection() {
|
||||||
try {
|
try {
|
||||||
if (ConnectionBuilder.connection != null) {
|
if (ConnectionBuilder.connection != null) {
|
||||||
|
|
|
@ -3,52 +3,14 @@ package de.hitec.nhplus.datastorage;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link Dao} is the Abbreviation of Data-Access-Object.
|
|
||||||
* This Interface has the Basic Methods which are needed on any DAO to work as expected.
|
|
||||||
*
|
|
||||||
* @param <T> The Model for which that DAO is implemented
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @version 1.0
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* @param id of the Element in the Database
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
T read(int id) throws SQLException;
|
T read(int id) throws SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @param t the Model instance.
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
void update(T t) throws SQLException;
|
void update(T t) throws SQLException;
|
||||||
|
|
||||||
/**
|
void deleteById(int id) throws SQLException;
|
||||||
* Delete a Database Entry.
|
|
||||||
*
|
|
||||||
* @param id of the Element in the Database.
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
void delete(int id) throws SQLException;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +1,31 @@
|
||||||
package de.hitec.nhplus.datastorage;
|
package de.hitec.nhplus.datastorage;
|
||||||
|
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
import de.hitec.nhplus.nurse.NurseDao;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
import de.hitec.nhplus.patient.PatientDao;
|
||||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
import de.hitec.nhplus.treatment.TreatmentDao;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link DaoFactory} is a Singleton({@link DaoFactory#getInstance}) which should be used to get {@link Dao}s.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class DaoFactory {
|
public class DaoFactory {
|
||||||
|
|
||||||
private static DaoFactory instance;
|
private static DaoFactory instance;
|
||||||
|
|
||||||
/**
|
|
||||||
* A Private Constructor according to the Singleton Pattern.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
private DaoFactory() {
|
private DaoFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static DaoFactory getDaoFactory() {
|
||||||
* @return {@link DaoFactory}, the Singleton Instance
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
public static DaoFactory getInstance() {
|
|
||||||
if (DaoFactory.instance == null) {
|
if (DaoFactory.instance == null) {
|
||||||
DaoFactory.instance = new DaoFactory();
|
DaoFactory.instance = new DaoFactory();
|
||||||
}
|
}
|
||||||
return DaoFactory.instance;
|
return DaoFactory.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a {@link TreatmentDao}
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
public TreatmentDao createTreatmentDao() {
|
public TreatmentDao createTreatmentDao() {
|
||||||
return new TreatmentDao(ConnectionBuilder.getConnection());
|
return new TreatmentDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a {@link PatientDao}
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
public PatientDao createPatientDAO() {
|
public PatientDao createPatientDAO() {
|
||||||
return new PatientDao(ConnectionBuilder.getConnection());
|
return new PatientDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a {@link NurseDao}
|
|
||||||
* @author Dominik Säume
|
|
||||||
*/
|
|
||||||
public NurseDao createNurseDAO() {
|
public NurseDao createNurseDAO() {
|
||||||
return new NurseDao(ConnectionBuilder.getConnection());
|
return new NurseDao(ConnectionBuilder.getConnection());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +1,57 @@
|
||||||
package de.hitec.nhplus.datastorage;
|
package de.hitec.nhplus.datastorage;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.PreparedStatement;
|
import java.util.ArrayList;
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link DaoImp} is a Generic Base Implementation of the {@link Dao},
|
|
||||||
* which should fit most use cases.
|
|
||||||
*
|
|
||||||
* @param <T> The Model for which that DAO is implemented
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
* @version 1.0
|
|
||||||
* @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 a Database Connection, which should be gotten from {@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.
|
|
||||||
*
|
|
||||||
* @param t the Model instance
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void create(T t) throws SQLException {
|
public void create(T t) throws SQLException {
|
||||||
getCreateStatement(t).executeUpdate();
|
getCreateStatement(t).executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read a Database Entry to a Model object.
|
|
||||||
*
|
|
||||||
* @param id of the Element in the Database
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public T read(int id) throws SQLException {
|
public T read(int key) throws SQLException {
|
||||||
T object = null;
|
T object = null;
|
||||||
ResultSet result = getReadByIDStatement(id).executeQuery();
|
ResultSet result = getReadByIDStatement(key).executeQuery();
|
||||||
if (result.next()) {
|
if (result.next()) {
|
||||||
object = getInstanceFromResultSet(result);
|
object = getInstanceFromResultSet(result);
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Read all Database Entries to a {@link List} of Model objects.
|
|
||||||
*
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> readAll() throws SQLException {
|
public List<T> readAll() throws SQLException {
|
||||||
return getListFromResultSet(getReadAllStatement().executeQuery());
|
return getListFromResultSet(getReadAllStatement().executeQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the Database according to the Values of the Model object.
|
|
||||||
*
|
|
||||||
* @param t the Model instance.
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void update(T t) throws SQLException {
|
public void update(T t) throws SQLException {
|
||||||
getUpdateStatement(t).executeUpdate();
|
getUpdateStatement(t).executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a Database Entry.
|
|
||||||
*
|
|
||||||
* @param id of the Element in the Database.
|
|
||||||
* @author Bernd Heidemann
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(int id) throws SQLException {
|
public void deleteById(int key) throws SQLException {
|
||||||
getDeleteStatement(id).executeUpdate();
|
getDeleteStatement(key).executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract T getInstanceFromResultSet(ResultSet result) throws SQLException;
|
protected abstract T getInstanceFromResultSet(ResultSet set) throws SQLException;
|
||||||
|
|
||||||
protected abstract List<T> getListFromResultSet(ResultSet result) throws SQLException;
|
protected abstract ArrayList<T> getListFromResultSet(ResultSet set) throws SQLException;
|
||||||
|
|
||||||
protected abstract PreparedStatement getCreateStatement(T t) throws SQLException;
|
protected abstract PreparedStatement getCreateStatement(T t);
|
||||||
|
|
||||||
protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException;
|
protected abstract PreparedStatement getReadByIDStatement(int key);
|
||||||
|
|
||||||
protected abstract PreparedStatement getReadAllStatement() throws SQLException;
|
protected abstract PreparedStatement getReadAllStatement();
|
||||||
|
|
||||||
protected abstract PreparedStatement getUpdateStatement(T t) throws SQLException;
|
protected abstract PreparedStatement getUpdateStatement(T t);
|
||||||
|
|
||||||
protected abstract PreparedStatement getDeleteStatement(int id) throws SQLException;
|
protected abstract PreparedStatement getDeleteStatement(int key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public interface Fixture<T>
|
public interface Fixture<T>
|
||||||
{
|
{
|
||||||
void dropTable(Connection connection) throws SQLException;
|
void dropTable(Connection connection);
|
||||||
void setupTable(Connection connection) throws SQLException;
|
void setupTable(Connection connection);
|
||||||
Map<String, T> load() throws SQLException;
|
Map<String, T> load() throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,40 @@
|
||||||
package de.hitec.nhplus.fixtures;
|
package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.nurse.NurseDao;
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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) {
|
||||||
connection.createStatement().execute("DROP TABLE nurse");
|
try (Statement statement = connection.createStatement()) {
|
||||||
|
statement.execute("DROP TABLE nurse");
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
System.out.println(exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupTable(Connection connection) throws SQLException {
|
public void setupTable(Connection connection) {
|
||||||
final InputStream schema = Main.class.getResourceAsStream("/de/hitec/nhplus/nurse/database/Nurse.sql");
|
final String SQL = "CREATE TABLE IF NOT EXISTS nurse (" +
|
||||||
assert schema != null;
|
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||||
final String SQL = new Scanner(schema, StandardCharsets.UTF_8).useDelimiter("\\A").next();
|
"firstname TEXT NOT NULL, " +
|
||||||
connection.createStatement().execute(SQL);
|
"surname TEXT NOT NULL, " +
|
||||||
|
"phoneNumber TEXT NOT NULL" +
|
||||||
|
");";
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
|
statement.execute(SQL);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
System.out.println(exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,12 +52,12 @@ public class NurseFixture implements Fixture<Nurse> {
|
||||||
"Armout",
|
"Armout",
|
||||||
"9876543210"
|
"9876543210"
|
||||||
));
|
));
|
||||||
NurseDao dao = DaoFactory.getInstance().createNurseDAO();
|
NurseDao dao = DaoFactory.getDaoFactory().createNurseDAO();
|
||||||
for (Nurse nurse : nurses) {
|
for(Nurse nurse : nurses){
|
||||||
dao.create(nurse);
|
dao.create(nurse);
|
||||||
}
|
}
|
||||||
Map<String, Nurse> nursesByName = new HashMap<>();
|
Map<String, Nurse> nursesByName = new HashMap<>();
|
||||||
for (Nurse nurse : dao.readAll()) {
|
for (Nurse nurse : dao.readAll()){
|
||||||
nursesByName.put(nurse.getFirstName(), nurse);
|
nursesByName.put(nurse.getFirstName(), nurse);
|
||||||
}
|
}
|
||||||
return nursesByName;
|
return nursesByName;
|
||||||
|
|
|
@ -1,86 +1,107 @@
|
||||||
package de.hitec.nhplus.fixtures;
|
package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.patient.PatientDao;
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
||||||
|
|
||||||
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)
|
||||||
connection.createStatement().execute("DROP TABLE patient");
|
{
|
||||||
|
try (Statement statement = connection.createStatement())
|
||||||
|
{
|
||||||
|
statement.execute("DROP TABLE patient");
|
||||||
|
} catch (SQLException exception)
|
||||||
|
{
|
||||||
|
System.out.println(exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupTable(Connection connection) throws SQLException {
|
public void setupTable(Connection connection)
|
||||||
// @SuppressWarnings("checkstyle:LineLength")
|
{
|
||||||
final InputStream schema = Main.class.getResourceAsStream("/de/hitec/nhplus/patient/database/Patient.sql");
|
final String SQL = "CREATE TABLE IF NOT EXISTS patient (" +
|
||||||
assert schema != null;
|
" id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||||
final String SQL = new Scanner(schema, StandardCharsets.UTF_8).useDelimiter("\\A").next();
|
" firstname TEXT NOT NULL, " +
|
||||||
connection.createStatement().execute(SQL);
|
" surname TEXT NOT NULL, " +
|
||||||
|
" dateOfBirth TEXT NOT NULL, " +
|
||||||
|
" carelevel TEXT NOT NULL, " +
|
||||||
|
" roomnumber TEXT NOT NULL" +
|
||||||
|
");";
|
||||||
|
try (Statement statement = connection.createStatement())
|
||||||
|
{
|
||||||
|
statement.execute(SQL);
|
||||||
|
} catch (SQLException exception)
|
||||||
|
{
|
||||||
|
System.out.println(exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Patient> load() throws SQLException {
|
public Map<String, Patient> load() throws SQLException
|
||||||
|
{
|
||||||
List<Patient> patients = new ArrayList<>();
|
List<Patient> patients = new ArrayList<>();
|
||||||
|
|
||||||
patients.add(new Patient(
|
patients.add(new Patient(
|
||||||
"Seppl",
|
"Seppl",
|
||||||
"Herberger",
|
"Herberger",
|
||||||
convertStringToLocalDate("1945-12-01"),
|
convertStringToLocalDate("1945-12-01"),
|
||||||
"4",
|
"4",
|
||||||
"202"
|
"202"
|
||||||
));
|
));
|
||||||
patients.add(new Patient(
|
patients.add(new Patient(
|
||||||
"Martina",
|
"Martina",
|
||||||
"Gerdsen",
|
"Gerdsen",
|
||||||
convertStringToLocalDate("1954-08-12"),
|
convertStringToLocalDate("1954-08-12"),
|
||||||
"5",
|
"5",
|
||||||
"010"
|
"010"
|
||||||
));
|
));
|
||||||
patients.add(new Patient(
|
patients.add(new Patient(
|
||||||
"Gertrud",
|
"Gertrud",
|
||||||
"Franzen",
|
"Franzen",
|
||||||
convertStringToLocalDate("1949-04-16"),
|
convertStringToLocalDate("1949-04-16"),
|
||||||
"3",
|
"3",
|
||||||
"002"
|
"002"
|
||||||
));
|
));
|
||||||
patients.add(new Patient(
|
patients.add(new Patient(
|
||||||
"Ahmet",
|
"Ahmet",
|
||||||
"Yilmaz",
|
"Yilmaz",
|
||||||
convertStringToLocalDate("1941-02-22"),
|
convertStringToLocalDate("1941-02-22"),
|
||||||
"3",
|
"3",
|
||||||
"013"
|
"013"
|
||||||
));
|
));
|
||||||
patients.add(new Patient(
|
patients.add(new Patient(
|
||||||
"Hans",
|
"Hans",
|
||||||
"Neumann",
|
"Neumann",
|
||||||
convertStringToLocalDate("1955-12-12"),
|
convertStringToLocalDate("1955-12-12"),
|
||||||
"2",
|
"2",
|
||||||
"001"
|
"001"
|
||||||
));
|
));
|
||||||
patients.add(new Patient(
|
patients.add(new Patient(
|
||||||
"Elisabeth",
|
"Elisabeth",
|
||||||
"Müller",
|
"Müller",
|
||||||
convertStringToLocalDate("1958-03-07"),
|
convertStringToLocalDate("1958-03-07"),
|
||||||
"5",
|
"5",
|
||||||
"110"
|
"110"
|
||||||
));
|
));
|
||||||
|
|
||||||
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
|
PatientDao dao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||||
for (Patient patient : patients) {
|
for (Patient patient : patients){
|
||||||
dao.create(patient);
|
dao.create(patient);
|
||||||
}
|
}
|
||||||
Map<String, Patient> patientsByName = new HashMap<>();
|
Map<String, Patient> patientsByName = new HashMap<>();
|
||||||
for (Patient patient : dao.readAll()) {
|
for (Patient patient : dao.readAll()){
|
||||||
patientsByName.put(patient.getFirstName(), patient);
|
patientsByName.put(patient.getFirstName(), patient);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,68 @@
|
||||||
package de.hitec.nhplus.fixtures;
|
package de.hitec.nhplus.fixtures;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
|
import de.hitec.nhplus.treatment.TreatmentDao;
|
||||||
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 java.io.InputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
public class TreatmentFixture implements Fixture<Treatment> {
|
public class TreatmentFixture implements Fixture<Treatment>
|
||||||
|
{
|
||||||
private final Map<String, Patient> patientsByName;
|
private final Map<String, Patient> patientsByName;
|
||||||
|
|
||||||
public TreatmentFixture(Map<String, Patient> patientsByName) {
|
public TreatmentFixture(Map<String, Patient> patientsByName)
|
||||||
|
{
|
||||||
this.patientsByName = patientsByName;
|
this.patientsByName = patientsByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropTable(Connection connection) throws SQLException {
|
public void dropTable(Connection connection)
|
||||||
connection.createStatement().execute("DROP TABLE treatment");
|
{
|
||||||
|
try (Statement statement = connection.createStatement())
|
||||||
|
{
|
||||||
|
statement.execute("DROP TABLE treatment");
|
||||||
|
} catch (SQLException exception)
|
||||||
|
{
|
||||||
|
System.out.println(exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupTable(Connection connection) throws SQLException {
|
public void setupTable(Connection connection)
|
||||||
final InputStream schema = Main.class.getResourceAsStream("/de/hitec/nhplus/treatment/database/Treatment.sql");
|
{
|
||||||
assert schema != null;
|
final String SQL = "CREATE TABLE IF NOT EXISTS treatment (" +
|
||||||
final String SQL = new Scanner(schema, StandardCharsets.UTF_8).useDelimiter("\\A").next();
|
" id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||||
connection.createStatement().execute(SQL);
|
" patientId INTEGER NOT NULL, " +
|
||||||
|
" treatment_date TEXT NOT NULL, " +
|
||||||
|
" begin TEXT NOT NULL, " +
|
||||||
|
" end TEXT NOT NULL, " +
|
||||||
|
" description TEXT NOT NULL, " +
|
||||||
|
" remark TEXT NOT NULL," +
|
||||||
|
" FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE " +
|
||||||
|
");";
|
||||||
|
|
||||||
|
try (Statement statement = connection.createStatement())
|
||||||
|
{
|
||||||
|
statement.execute(SQL);
|
||||||
|
} catch (SQLException exception)
|
||||||
|
{
|
||||||
|
System.out.println(exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Treatment> load() throws SQLException {
|
public Map<String, Treatment> load() throws SQLException
|
||||||
|
{
|
||||||
List<Treatment> treatments = new ArrayList<>();
|
List<Treatment> treatments = new ArrayList<>();
|
||||||
|
|
||||||
Patient seppl = patientsByName.get("Seppl");
|
Patient seppl = patientsByName.get("Seppl");
|
||||||
|
@ -46,102 +72,102 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
||||||
Patient elisabeth = patientsByName.get("Elisabeth");
|
Patient elisabeth = patientsByName.get("Elisabeth");
|
||||||
|
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
1,
|
1,
|
||||||
seppl,
|
seppl.getId(),
|
||||||
convertStringToLocalDate("2023-06-03"),
|
convertStringToLocalDate("2023-06-03"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
"Gespräch",
|
"Gespräch",
|
||||||
"Der Patient hat enorme Angstgefühle und glaubt, er sei überfallen worden."
|
"Der Patient hat enorme Angstgefühle und glaubt, er sei überfallen worden."
|
||||||
+ "Ihm seien alle Wertsachen gestohlen worden."
|
+ "Ihm seien alle Wertsachen gestohlen worden."
|
||||||
+ "Patient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind."
|
+ "Patient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind."
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
2,
|
2,
|
||||||
seppl,
|
seppl.getId(),
|
||||||
convertStringToLocalDate("2023-06-05"),
|
convertStringToLocalDate("2023-06-05"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("12:30"),
|
convertStringToLocalTime("12:30"),
|
||||||
"Gespräch",
|
"Gespräch",
|
||||||
"Patient irrt auf der Suche nach gestohlenen Wertsachen durch die Etage "
|
"Patient irrt auf der Suche nach gestohlenen Wertsachen durch die Etage "
|
||||||
+ "und bezichtigt andere Bewohner des Diebstahls."
|
+ "und bezichtigt andere Bewohner des Diebstahls."
|
||||||
+ "Patient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel."
|
+ "Patient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel."
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
3,
|
3,
|
||||||
martina,
|
martina.getId(),
|
||||||
convertStringToLocalDate("2023-06-04"),
|
convertStringToLocalDate("2023-06-04"),
|
||||||
convertStringToLocalTime("07:30"),
|
convertStringToLocalTime("07:30"),
|
||||||
convertStringToLocalTime("08:00"),
|
convertStringToLocalTime("08:00"),
|
||||||
"Waschen",
|
"Waschen",
|
||||||
"Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet."
|
"Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet."
|
||||||
));
|
));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
4,
|
4,
|
||||||
seppl,
|
seppl.getId(),
|
||||||
convertStringToLocalDate("2023-06-06"),
|
convertStringToLocalDate("2023-06-06"),
|
||||||
convertStringToLocalTime("15:10"),
|
convertStringToLocalTime("15:10"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
"Spaziergang",
|
"Spaziergang",
|
||||||
"Spaziergang im Park, Patient döst im Rollstuhl ein")
|
"Spaziergang im Park, Patient döst im Rollstuhl ein")
|
||||||
);
|
);
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
8,
|
8,
|
||||||
seppl,
|
seppl.getId(),
|
||||||
convertStringToLocalDate("2023-06-08"),
|
convertStringToLocalDate("2023-06-08"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
"Spaziergang",
|
"Spaziergang",
|
||||||
"Parkspaziergang; Patient ist heute lebhafter und hat klare Momente; erzählt von seiner Tochter")
|
"Parkspaziergang; Patient ist heute lebhafter und hat klare Momente; erzählt von seiner Tochter")
|
||||||
);
|
);
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
9,
|
9,
|
||||||
martina,
|
martina.getId(),
|
||||||
convertStringToLocalDate("2023-06-07"),
|
convertStringToLocalDate("2023-06-07"),
|
||||||
convertStringToLocalTime("11:00"),
|
convertStringToLocalTime("11:00"),
|
||||||
convertStringToLocalTime("11:30"),
|
convertStringToLocalTime("11:30"),
|
||||||
"Waschen",
|
"Waschen",
|
||||||
"Waschen per Dusche auf einem Stuhl; Patientin gewendet;")
|
"Waschen per Dusche auf einem Stuhl; Patientin gewendet;")
|
||||||
);
|
);
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
12,
|
12,
|
||||||
hans,
|
hans.getId(),
|
||||||
convertStringToLocalDate("2023-06-08"),
|
convertStringToLocalDate("2023-06-08"),
|
||||||
convertStringToLocalTime("15:00"),
|
convertStringToLocalTime("15:00"),
|
||||||
convertStringToLocalTime("15:30"),
|
convertStringToLocalTime("15:30"),
|
||||||
"Physiotherapie",
|
"Physiotherapie",
|
||||||
"Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur")
|
"Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur")
|
||||||
);
|
);
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
14,
|
14,
|
||||||
ahmet,
|
ahmet.getId(),
|
||||||
convertStringToLocalDate("2023-08-24"),
|
convertStringToLocalDate("2023-08-24"),
|
||||||
convertStringToLocalTime("09:30"),
|
convertStringToLocalTime("09:30"),
|
||||||
convertStringToLocalTime("10:15"),
|
convertStringToLocalTime("10:15"),
|
||||||
"KG",
|
"KG",
|
||||||
"Lympfdrainage"));
|
"Lympfdrainage"));
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
16,
|
16,
|
||||||
elisabeth,
|
elisabeth.getId(),
|
||||||
convertStringToLocalDate("2023-08-31"),
|
convertStringToLocalDate("2023-08-31"),
|
||||||
convertStringToLocalTime("13:30"),
|
convertStringToLocalTime("13:30"),
|
||||||
convertStringToLocalTime("13:45"),
|
convertStringToLocalTime("13:45"),
|
||||||
"Toilettengang",
|
"Toilettengang",
|
||||||
"Hilfe beim Toilettengang; Patientin klagt über Schmerzen beim Stuhlgang. Gabe von Iberogast")
|
"Hilfe beim Toilettengang; Patientin klagt über Schmerzen beim Stuhlgang. Gabe von Iberogast")
|
||||||
);
|
);
|
||||||
treatments.add(new Treatment(
|
treatments.add(new Treatment(
|
||||||
17,
|
17,
|
||||||
elisabeth,
|
elisabeth.getId(),
|
||||||
convertStringToLocalDate("2023-09-01"),
|
convertStringToLocalDate("2023-09-01"),
|
||||||
convertStringToLocalTime("16:00"),
|
convertStringToLocalTime("16:00"),
|
||||||
convertStringToLocalTime("17:00"),
|
convertStringToLocalTime("17:00"),
|
||||||
"KG",
|
"KG",
|
||||||
"Massage der Extremitäten zur Verbesserung der Durchblutung")
|
"Massage der Extremitäten zur Verbesserung der Durchblutung")
|
||||||
);
|
);
|
||||||
|
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||||
Map<String, Treatment> treatmentsById = new HashMap<>();
|
Map<String, Treatment> treatmentsById = new HashMap<>();
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments){
|
||||||
dao.create(treatment);
|
dao.create(treatment);
|
||||||
treatmentsById.put(String.valueOf(treatment.getId()), treatment);
|
treatmentsById.put(String.valueOf(treatment.getId()), treatment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class MainWindowController {
|
public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -41,7 +40,7 @@ public class MainWindowController {
|
||||||
private void loadPatientPage() {
|
private void loadPatientPage() {
|
||||||
try {
|
try {
|
||||||
BorderPane patientsPane = FXMLLoader.load(
|
BorderPane patientsPane = FXMLLoader.load(
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/patient/AllPatientView.fxml"))
|
Main.class.getResource("/de/hitec/nhplus/patient/AllPatientView.fxml")
|
||||||
);
|
);
|
||||||
patientPage.getChildren().setAll(patientsPane);
|
patientPage.getChildren().setAll(patientsPane);
|
||||||
AnchorPane.setTopAnchor(patientsPane, 0d);
|
AnchorPane.setTopAnchor(patientsPane, 0d);
|
||||||
|
@ -56,7 +55,7 @@ public class MainWindowController {
|
||||||
private void loadTreatmentsPage() {
|
private void loadTreatmentsPage() {
|
||||||
try {
|
try {
|
||||||
BorderPane treatmentsPane = FXMLLoader.load(
|
BorderPane treatmentsPane = FXMLLoader.load(
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/treatment/AllTreatmentView.fxml"))
|
Main.class.getResource("/de/hitec/nhplus/treatment/AllTreatmentView.fxml")
|
||||||
);
|
);
|
||||||
treatmentPage.getChildren().setAll(treatmentsPane);
|
treatmentPage.getChildren().setAll(treatmentsPane);
|
||||||
AnchorPane.setTopAnchor(treatmentsPane, 0d);
|
AnchorPane.setTopAnchor(treatmentsPane, 0d);
|
||||||
|
@ -71,7 +70,7 @@ public class MainWindowController {
|
||||||
private void loadNursePage() {
|
private void loadNursePage() {
|
||||||
try {
|
try {
|
||||||
BorderPane nursePane = FXMLLoader.load(
|
BorderPane nursePane = FXMLLoader.load(
|
||||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/AllNurseView.fxml"))
|
Main.class.getResource("/de/hitec/nhplus/nurse/AllNurseView.fxml")
|
||||||
);
|
);
|
||||||
nursePage.getChildren().setAll(nursePane);
|
nursePage.getChildren().setAll(nursePane);
|
||||||
AnchorPane.setTopAnchor(nursePane, 0d);
|
AnchorPane.setTopAnchor(nursePane, 0d);
|
||||||
|
|
|
@ -4,11 +4,11 @@ import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
public abstract class Person {
|
public abstract class Person {
|
||||||
private final SimpleStringProperty firstName;
|
private final SimpleStringProperty firstName;
|
||||||
private final SimpleStringProperty surName;
|
private final SimpleStringProperty surname;
|
||||||
|
|
||||||
public Person(String firstName, String surName) {
|
public Person(String firstName, String surname) {
|
||||||
this.firstName = new SimpleStringProperty(firstName);
|
this.firstName = new SimpleStringProperty(firstName);
|
||||||
this.surName = new SimpleStringProperty(surName);
|
this.surname = new SimpleStringProperty(surname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getFirstName() {
|
||||||
|
@ -23,15 +23,15 @@ public abstract class Person {
|
||||||
this.firstName.set(firstName);
|
this.firstName.set(firstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSurName() {
|
public String getSurname() {
|
||||||
return surName.get();
|
return surname.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleStringProperty surNameProperty() {
|
public SimpleStringProperty surnameProperty() {
|
||||||
return surName;
|
return surname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSurName(String surName) {
|
public void setSurname(String surname) {
|
||||||
this.surName.set(surName);
|
this.surname.set(surname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package de.hitec.nhplus.nurse;
|
||||||
import static de.hitec.nhplus.utils.Validator.*;
|
import static de.hitec.nhplus.utils.Validator.*;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
@ -19,9 +18,9 @@ import java.sql.SQLException;
|
||||||
|
|
||||||
public class AllNurseController {
|
public class AllNurseController {
|
||||||
@FXML
|
@FXML
|
||||||
public TextField textFieldSurName;
|
public TextField textFieldSurname;
|
||||||
@FXML
|
@FXML
|
||||||
public TextField textFieldFirstName;
|
public TextField textFieldFirstname;
|
||||||
@FXML
|
@FXML
|
||||||
public TextField textFieldPhoneNumber;
|
public TextField textFieldPhoneNumber;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -33,7 +32,7 @@ public class AllNurseController {
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Nurse, String> columnFirstName;
|
private TableColumn<Nurse, String> columnFirstName;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Nurse, String> columnSurName;
|
private TableColumn<Nurse, String> columnSurname;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Nurse, String> columnPhoneNumber;
|
private TableColumn<Nurse, String> columnPhoneNumber;
|
||||||
|
|
||||||
|
@ -48,8 +47,8 @@ public class AllNurseController {
|
||||||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||||
|
|
||||||
this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName"));
|
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||||
this.columnSurName.setCellFactory(TextFieldTableCell.forTableColumn());
|
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||||
|
|
||||||
|
|
||||||
this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber"));
|
this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber"));
|
||||||
|
@ -60,21 +59,21 @@ public class AllNurseController {
|
||||||
this.buttonAdd.setDisable(true);
|
this.buttonAdd.setDisable(true);
|
||||||
ChangeListener<String> inputNewNurseValidationListener = (observableValue, oldText, newText)->
|
ChangeListener<String> inputNewNurseValidationListener = (observableValue, oldText, newText)->
|
||||||
{
|
{
|
||||||
boolean isValid = isValidFirstName(this.textFieldFirstName.getText())
|
boolean isValid = isValidFirstName(this.textFieldFirstname.getText())
|
||||||
&& isValidSurName(this.textFieldSurName.getText())
|
&& isValidSurName(this.textFieldSurname.getText())
|
||||||
&& isValidPhoneNumber(this.textFieldPhoneNumber.getText());
|
&& isValidPhoneNumber(this.textFieldPhoneNumber.getText());
|
||||||
|
|
||||||
AllNurseController.this.buttonAdd.setDisable(!isValid);
|
AllNurseController.this.buttonAdd.setDisable(!isValid);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.textFieldFirstName.textProperty().addListener(inputNewNurseValidationListener);
|
this.textFieldFirstname.textProperty().addListener(inputNewNurseValidationListener);
|
||||||
this.textFieldSurName.textProperty().addListener(inputNewNurseValidationListener);
|
this.textFieldSurname.textProperty().addListener(inputNewNurseValidationListener);
|
||||||
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readAllAndShowInTableView(){
|
private void readAllAndShowInTableView(){
|
||||||
this.nurses.clear();
|
this.nurses.clear();
|
||||||
this.dao = DaoFactory.getInstance().createNurseDAO();
|
this.dao = DaoFactory.getDaoFactory().createNurseDAO();
|
||||||
try {
|
try {
|
||||||
this.nurses.addAll(this.dao.readAll());
|
this.nurses.addAll(this.dao.readAll());
|
||||||
}catch (SQLException exception){
|
}catch (SQLException exception){
|
||||||
|
@ -83,8 +82,8 @@ public class AllNurseController {
|
||||||
}
|
}
|
||||||
@FXML
|
@FXML
|
||||||
public void handleAdd(){
|
public void handleAdd(){
|
||||||
String surname=this.textFieldSurName.getText();
|
String surname=this.textFieldSurname.getText();
|
||||||
String firstName=this.textFieldFirstName.getText();
|
String firstName=this.textFieldFirstname.getText();
|
||||||
String phoneNumber=this.textFieldPhoneNumber.getText();
|
String phoneNumber=this.textFieldPhoneNumber.getText();
|
||||||
try {
|
try {
|
||||||
this.dao.create(new Nurse(firstName, surname, phoneNumber));
|
this.dao.create(new Nurse(firstName, surname, phoneNumber));
|
||||||
|
@ -97,8 +96,8 @@ public class AllNurseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearTextfields() {
|
private void clearTextfields() {
|
||||||
this.textFieldFirstName.clear();
|
this.textFieldFirstname.clear();
|
||||||
this.textFieldSurName.clear();
|
this.textFieldSurname.clear();
|
||||||
this.textFieldPhoneNumber.clear();
|
this.textFieldPhoneNumber.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,20 @@ public class Nurse extends Person {
|
||||||
|
|
||||||
public Nurse(
|
public Nurse(
|
||||||
String firstName,
|
String firstName,
|
||||||
String surName,
|
String surname,
|
||||||
String phoneNumber
|
String phoneNumber
|
||||||
) {
|
) {
|
||||||
super(firstName, surName);
|
super(firstName, surname);
|
||||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Nurse(
|
public Nurse(
|
||||||
int id,
|
int id,
|
||||||
String firstName,
|
String firstName,
|
||||||
String surName,
|
String surname,
|
||||||
String phoneNumber
|
String phoneNumber
|
||||||
) {
|
) {
|
||||||
super(firstName, surName);
|
super(firstName, surname);
|
||||||
this.id = new SimpleIntegerProperty(id);
|
this.id = new SimpleIntegerProperty(id);
|
||||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ public class Nurse extends Person {
|
||||||
return new StringJoiner(System.lineSeparator())
|
return new StringJoiner(System.lineSeparator())
|
||||||
.add("NURSE")
|
.add("NURSE")
|
||||||
.add("ID: " + this.getId())
|
.add("ID: " + this.getId())
|
||||||
.add("FirstName: " + this.getFirstName())
|
.add("Firstname: " + this.getFirstName())
|
||||||
.add("SurName: " + this.getSurName())
|
.add("Surname: " + this.getSurname())
|
||||||
.add("PhoneNumber: " + this.getPhoneNumber())
|
.add("PhoneNumber: " + this.getPhoneNumber())
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
|
|
115
src/main/java/de/hitec/nhplus/nurse/NurseDao.java
Normal file
115
src/main/java/de/hitec/nhplus/nurse/NurseDao.java
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
package de.hitec.nhplus.nurse;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.datastorage.DaoImp;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class NurseDao extends DaoImp<Nurse> {
|
||||||
|
public NurseDao(Connection connection) {
|
||||||
|
super(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getCreateStatement(Nurse nurse) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "INSERT INTO nurse (firstname, surname, phoneNumber)" +
|
||||||
|
"VALUES (?, ?, ?)";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setString(1, nurse.getFirstName());
|
||||||
|
preparedStatement.setString(2, nurse.getSurname());
|
||||||
|
preparedStatement.setString(3, nurse.getPhoneNumber());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadByIDStatement(int id) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM nurse WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Nurse getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
return new Nurse(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getString(3),
|
||||||
|
result.getString(4)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadAllStatement() {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM nurse";
|
||||||
|
statement = this.connection.prepareStatement(SQL);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ArrayList<Nurse> getListFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
ArrayList<Nurse> list = new ArrayList<>();
|
||||||
|
while (result.next()) {
|
||||||
|
list.add(new Nurse(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getString(3),
|
||||||
|
result.getString(4)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getUpdateStatement(Nurse nurse) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL =
|
||||||
|
"UPDATE nurse SET " +
|
||||||
|
"firstname = ?, " +
|
||||||
|
"surname = ?, " +
|
||||||
|
"phoneNumber = ?, " +
|
||||||
|
"WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setString(1, nurse.getFirstName());
|
||||||
|
preparedStatement.setString(2, nurse.getSurname());
|
||||||
|
preparedStatement.setString(3, nurse.getPhoneNumber());
|
||||||
|
preparedStatement.setInt(4, nurse.getId());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getDeleteStatement(int id) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "DELETE FROM nurse WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,89 +0,0 @@
|
||||||
package de.hitec.nhplus.nurse.database;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoImp;
|
|
||||||
import de.hitec.nhplus.nurse.Nurse;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NurseDao extends DaoImp<Nurse> {
|
|
||||||
public NurseDao(Connection connection) {
|
|
||||||
super(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getCreateStatement(Nurse nurse) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
INSERT INTO nurse
|
|
||||||
(firstName, surName, phoneNumber)
|
|
||||||
VALUES (?, ?, ?)
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setString(1, nurse.getFirstName());
|
|
||||||
statement.setString(2, nurse.getSurName());
|
|
||||||
statement.setString(3, nurse.getPhoneNumber());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM nurse WHERE id = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Nurse getInstanceFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
return new Nurse(
|
|
||||||
result.getInt(1),
|
|
||||||
result.getString(2),
|
|
||||||
result.getString(3),
|
|
||||||
result.getString(4)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM nurse";
|
|
||||||
return this.connection.prepareStatement(SQL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<Nurse> getListFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
ArrayList<Nurse> list = new ArrayList<>();
|
|
||||||
while (result.next()) {
|
|
||||||
list.add(getInstanceFromResultSet(result));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getUpdateStatement(Nurse nurse) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
UPDATE nurse SET
|
|
||||||
firstName = ?,
|
|
||||||
surName = ?,
|
|
||||||
phoneNumber = ?
|
|
||||||
WHERE id = ?
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setString(1, nurse.getFirstName());
|
|
||||||
statement.setString(2, nurse.getSurName());
|
|
||||||
statement.setString(3, nurse.getPhoneNumber());
|
|
||||||
statement.setInt(4, nurse.getId());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getDeleteStatement(int id) throws SQLException {
|
|
||||||
final String SQL = "DELETE FROM nurse WHERE id = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package de.hitec.nhplus.patient;
|
package de.hitec.nhplus.patient;
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
|
||||||
import de.hitec.nhplus.utils.DateConverter;
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -28,7 +27,7 @@ public class AllPatientController {
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Patient, String> columnFirstName;
|
private TableColumn<Patient, String> columnFirstName;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Patient, String> columnSurName;
|
private TableColumn<Patient, String> columnSurname;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Patient, String> columnDateOfBirth;
|
private TableColumn<Patient, String> columnDateOfBirth;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -40,7 +39,7 @@ public class AllPatientController {
|
||||||
@FXML
|
@FXML
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField textFieldSurName;
|
private TextField textFieldSurname;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField textFieldFirstName;
|
private TextField textFieldFirstName;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -61,8 +60,8 @@ public class AllPatientController {
|
||||||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||||
|
|
||||||
this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName"));
|
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||||
this.columnSurName.setCellFactory(TextFieldTableCell.forTableColumn());
|
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||||
|
|
||||||
this.columnDateOfBirth.setCellValueFactory(new PropertyValueFactory<>("dateOfBirth"));
|
this.columnDateOfBirth.setCellValueFactory(new PropertyValueFactory<>("dateOfBirth"));
|
||||||
this.columnDateOfBirth.setCellFactory(TextFieldTableCell.forTableColumn());
|
this.columnDateOfBirth.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||||
|
@ -89,7 +88,7 @@ public class AllPatientController {
|
||||||
{
|
{
|
||||||
boolean isValid = isValidDate(this.textFieldDateOfBirth.getText())
|
boolean isValid = isValidDate(this.textFieldDateOfBirth.getText())
|
||||||
&& isValidFirstName(this.textFieldFirstName.getText())
|
&& isValidFirstName(this.textFieldFirstName.getText())
|
||||||
&& isValidSurName(this.textFieldSurName.getText())
|
&& isValidSurName(this.textFieldSurname.getText())
|
||||||
&& isValidDate(this.textFieldDateOfBirth.getText())
|
&& isValidDate(this.textFieldDateOfBirth.getText())
|
||||||
&& isValidCareLevel(this.textFieldCareLevel.getText())
|
&& isValidCareLevel(this.textFieldCareLevel.getText())
|
||||||
&& isValidRoomNumber(textFieldRoomNumber.getText());
|
&& isValidRoomNumber(textFieldRoomNumber.getText());
|
||||||
|
@ -97,7 +96,7 @@ public class AllPatientController {
|
||||||
AllPatientController.this.buttonAdd.setDisable(!isValid);
|
AllPatientController.this.buttonAdd.setDisable(!isValid);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.textFieldSurName.textProperty().addListener(inputNewPatientValidationListener);
|
this.textFieldSurname.textProperty().addListener(inputNewPatientValidationListener);
|
||||||
this.textFieldFirstName.textProperty().addListener(inputNewPatientValidationListener);
|
this.textFieldFirstName.textProperty().addListener(inputNewPatientValidationListener);
|
||||||
this.textFieldDateOfBirth.textProperty().addListener(inputNewPatientValidationListener);
|
this.textFieldDateOfBirth.textProperty().addListener(inputNewPatientValidationListener);
|
||||||
this.textFieldCareLevel.textProperty().addListener(inputNewPatientValidationListener);
|
this.textFieldCareLevel.textProperty().addListener(inputNewPatientValidationListener);
|
||||||
|
@ -124,7 +123,7 @@ public class AllPatientController {
|
||||||
event.getTableView().refresh();
|
event.getTableView().refresh();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.getRowValue().setSurName(newSurName);
|
event.getRowValue().setSurname(newSurName);
|
||||||
this.doUpdate(event);
|
this.doUpdate(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +174,7 @@ public class AllPatientController {
|
||||||
|
|
||||||
private void readAllAndShowInTableView() {
|
private void readAllAndShowInTableView() {
|
||||||
this.patients.clear();
|
this.patients.clear();
|
||||||
this.dao = DaoFactory.getInstance().createPatientDAO();
|
this.dao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||||
try {
|
try {
|
||||||
this.patients.addAll(this.dao.readAll());
|
this.patients.addAll(this.dao.readAll());
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
|
@ -188,7 +187,7 @@ public class AllPatientController {
|
||||||
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
if (selectedItem != null) {
|
if (selectedItem != null) {
|
||||||
try {
|
try {
|
||||||
DaoFactory.getInstance().createPatientDAO().delete(selectedItem.getId());
|
DaoFactory.getDaoFactory().createPatientDAO().deleteById(selectedItem.getId());
|
||||||
this.tableView.getItems().remove(selectedItem);
|
this.tableView.getItems().remove(selectedItem);
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
|
@ -198,7 +197,7 @@ public class AllPatientController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleAdd() {
|
public void handleAdd() {
|
||||||
String surname = this.textFieldSurName.getText();
|
String surname = this.textFieldSurname.getText();
|
||||||
String firstName = this.textFieldFirstName.getText();
|
String firstName = this.textFieldFirstName.getText();
|
||||||
String birthday = this.textFieldDateOfBirth.getText();
|
String birthday = this.textFieldDateOfBirth.getText();
|
||||||
LocalDate date = DateConverter.convertStringToLocalDate(birthday);
|
LocalDate date = DateConverter.convertStringToLocalDate(birthday);
|
||||||
|
@ -215,7 +214,7 @@ public class AllPatientController {
|
||||||
|
|
||||||
private void clearTextfields() {
|
private void clearTextfields() {
|
||||||
this.textFieldFirstName.clear();
|
this.textFieldFirstName.clear();
|
||||||
this.textFieldSurName.clear();
|
this.textFieldSurname.clear();
|
||||||
this.textFieldDateOfBirth.clear();
|
this.textFieldDateOfBirth.clear();
|
||||||
this.textFieldCareLevel.clear();
|
this.textFieldCareLevel.clear();
|
||||||
this.textFieldRoomNumber.clear();
|
this.textFieldRoomNumber.clear();
|
||||||
|
|
|
@ -20,12 +20,12 @@ public class Patient extends Person {
|
||||||
|
|
||||||
public Patient(
|
public Patient(
|
||||||
String firstName,
|
String firstName,
|
||||||
String surName,
|
String surname,
|
||||||
LocalDate dateOfBirth,
|
LocalDate dateOfBirth,
|
||||||
String careLevel,
|
String careLevel,
|
||||||
String roomNumber
|
String roomNumber
|
||||||
) {
|
) {
|
||||||
super(firstName, surName);
|
super(firstName, surname);
|
||||||
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
||||||
this.careLevel = new SimpleStringProperty(careLevel);
|
this.careLevel = new SimpleStringProperty(careLevel);
|
||||||
this.roomNumber = new SimpleStringProperty(roomNumber);
|
this.roomNumber = new SimpleStringProperty(roomNumber);
|
||||||
|
@ -34,12 +34,12 @@ public class Patient extends Person {
|
||||||
public Patient(
|
public Patient(
|
||||||
int id,
|
int id,
|
||||||
String firstName,
|
String firstName,
|
||||||
String surName,
|
String surname,
|
||||||
LocalDate dateOfBirth,
|
LocalDate dateOfBirth,
|
||||||
String careLevel,
|
String careLevel,
|
||||||
String roomNumber
|
String roomNumber
|
||||||
) {
|
) {
|
||||||
super(firstName, surName);
|
super(firstName, surname);
|
||||||
this.id = new SimpleIntegerProperty(id);
|
this.id = new SimpleIntegerProperty(id);
|
||||||
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
||||||
this.careLevel = new SimpleStringProperty(careLevel);
|
this.careLevel = new SimpleStringProperty(careLevel);
|
||||||
|
@ -103,8 +103,8 @@ public class Patient extends Person {
|
||||||
return new StringJoiner(System.lineSeparator())
|
return new StringJoiner(System.lineSeparator())
|
||||||
.add("PATIENT")
|
.add("PATIENT")
|
||||||
.add("ID: " + this.getId())
|
.add("ID: " + this.getId())
|
||||||
.add("FirstName: " + this.getFirstName())
|
.add("Firstname: " + this.getFirstName())
|
||||||
.add("SurName: " + this.getSurName())
|
.add("Surname: " + this.getSurname())
|
||||||
.add("Birthday: " + this.getDateOfBirth())
|
.add("Birthday: " + this.getDateOfBirth())
|
||||||
.add("Carelevel: " + this.getCareLevel())
|
.add("Carelevel: " + this.getCareLevel())
|
||||||
.add("RoomNumber: " + this.getRoomNumber())
|
.add("RoomNumber: " + this.getRoomNumber())
|
||||||
|
|
125
src/main/java/de/hitec/nhplus/patient/PatientDao.java
Normal file
125
src/main/java/de/hitec/nhplus/patient/PatientDao.java
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
package de.hitec.nhplus.patient;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.datastorage.DaoImp;
|
||||||
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class PatientDao extends DaoImp<Patient> {
|
||||||
|
|
||||||
|
public PatientDao(Connection connection) {
|
||||||
|
super(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getCreateStatement(Patient patient) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber) " +
|
||||||
|
"VALUES (?, ?, ?, ?, ?)";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setString(1, patient.getFirstName());
|
||||||
|
preparedStatement.setString(2, patient.getSurname());
|
||||||
|
preparedStatement.setString(3, patient.getDateOfBirth());
|
||||||
|
preparedStatement.setString(4, patient.getCareLevel());
|
||||||
|
preparedStatement.setString(5, patient.getRoomNumber());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadByIDStatement(int id) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM patient WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Patient getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
return new Patient(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getString(3),
|
||||||
|
DateConverter.convertStringToLocalDate(result.getString(4)),
|
||||||
|
result.getString(5),
|
||||||
|
result.getString(6));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadAllStatement() {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM patient";
|
||||||
|
statement = this.connection.prepareStatement(SQL);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ArrayList<Patient> getListFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
ArrayList<Patient> list = new ArrayList<>();
|
||||||
|
while (result.next()) {
|
||||||
|
Patient patient = new Patient(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getString(2),
|
||||||
|
result.getString(3),
|
||||||
|
DateConverter.convertStringToLocalDate(result.getString(4)),
|
||||||
|
result.getString(5),
|
||||||
|
result.getString(6));
|
||||||
|
list.add(patient);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getUpdateStatement(Patient patient) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL =
|
||||||
|
"UPDATE patient SET " +
|
||||||
|
"firstname = ?, " +
|
||||||
|
"surname = ?, " +
|
||||||
|
"dateOfBirth = ?, " +
|
||||||
|
"carelevel = ?, " +
|
||||||
|
"roomnumber = ?, " +
|
||||||
|
"WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setString(1, patient.getFirstName());
|
||||||
|
preparedStatement.setString(2, patient.getSurname());
|
||||||
|
preparedStatement.setString(3, patient.getDateOfBirth());
|
||||||
|
preparedStatement.setString(4, patient.getCareLevel());
|
||||||
|
preparedStatement.setString(5, patient.getRoomNumber());
|
||||||
|
preparedStatement.setInt(6, patient.getId());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getDeleteStatement(int id) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "DELETE FROM patient WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,98 +0,0 @@
|
||||||
package de.hitec.nhplus.patient.database;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoImp;
|
|
||||||
import de.hitec.nhplus.patient.Patient;
|
|
||||||
import de.hitec.nhplus.utils.DateConverter;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PatientDao extends DaoImp<Patient> {
|
|
||||||
|
|
||||||
public PatientDao(Connection connection) {
|
|
||||||
super(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getCreateStatement(Patient patient) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
INSERT INTO patient
|
|
||||||
(firstName, surName, dateOfBirth, careLevel, roomNumber)
|
|
||||||
VALUES (?, ?, ?, ?, ?)
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setString(1, patient.getFirstName());
|
|
||||||
statement.setString(2, patient.getSurName());
|
|
||||||
statement.setString(3, patient.getDateOfBirth());
|
|
||||||
statement.setString(4, patient.getCareLevel());
|
|
||||||
statement.setString(5, patient.getRoomNumber());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM patient WHERE id = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Patient getInstanceFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
return new Patient(
|
|
||||||
result.getInt(1),
|
|
||||||
result.getString(2),
|
|
||||||
result.getString(3),
|
|
||||||
DateConverter.convertStringToLocalDate(result.getString(4)),
|
|
||||||
result.getString(5),
|
|
||||||
result.getString(6));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM patient";
|
|
||||||
return this.connection.prepareStatement(SQL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<Patient> getListFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
ArrayList<Patient> list = new ArrayList<>();
|
|
||||||
while (result.next()) {
|
|
||||||
list.add(getInstanceFromResultSet(result));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getUpdateStatement(Patient patient) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
UPDATE patient SET
|
|
||||||
firstName = ?,
|
|
||||||
surName = ?,
|
|
||||||
dateOfBirth = ?,
|
|
||||||
careLevel = ?,
|
|
||||||
roomNumber = ?,
|
|
||||||
WHERE id = ?
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setString(1, patient.getFirstName());
|
|
||||||
statement.setString(2, patient.getSurName());
|
|
||||||
statement.setString(3, patient.getDateOfBirth());
|
|
||||||
statement.setString(4, patient.getCareLevel());
|
|
||||||
statement.setString(5, patient.getRoomNumber());
|
|
||||||
statement.setInt(6, patient.getId());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getDeleteStatement(int id) throws SQLException {
|
|
||||||
final String SQL = "DELETE FROM patient WHERE id = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,9 +3,7 @@ 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.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
import de.hitec.nhplus.patient.PatientDao;
|
||||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -29,7 +27,7 @@ public class AllTreatmentController {
|
||||||
private TableColumn<Treatment, Integer> columnId;
|
private TableColumn<Treatment, Integer> columnId;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Treatment, String> columnPatientName;
|
private TableColumn<Treatment, Integer> columnPatientId;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Treatment, String> columnDate;
|
private TableColumn<Treatment, String> columnDate;
|
||||||
|
@ -60,12 +58,7 @@ public class AllTreatmentController {
|
||||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
this.columnPatientName.setCellValueFactory(
|
this.columnPatientId.setCellValueFactory(new PropertyValueFactory<>("patientId"));
|
||||||
cellData -> {
|
|
||||||
Patient patient = cellData.getValue().getPatient();
|
|
||||||
return new SimpleStringProperty(patient.getSurName() + ", " + patient.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"));
|
||||||
|
@ -85,7 +78,7 @@ public class AllTreatmentController {
|
||||||
|
|
||||||
public void readAllAndShowInTableView() {
|
public void readAllAndShowInTableView() {
|
||||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
this.dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
this.treatments.setAll(dao.readAll());
|
this.treatments.setAll(dao.readAll());
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
|
@ -94,12 +87,12 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createComboBoxData() {
|
private void createComboBoxData() {
|
||||||
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
|
PatientDao dao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||||
try {
|
try {
|
||||||
patientList = (ArrayList<Patient>) dao.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());
|
||||||
}
|
}
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
|
@ -111,7 +104,7 @@ public class AllTreatmentController {
|
||||||
public void handleComboBox() {
|
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.getDaoFactory().createTreatmentDao();
|
||||||
|
|
||||||
if (selectedPatient.equals("alle")) {
|
if (selectedPatient.equals("alle")) {
|
||||||
try {
|
try {
|
||||||
|
@ -133,7 +126,7 @@ public class AllTreatmentController {
|
||||||
|
|
||||||
private Patient searchInList(String surname) {
|
private Patient searchInList(String surname) {
|
||||||
for (Patient patient : this.patientList) {
|
for (Patient patient : this.patientList) {
|
||||||
if (patient.getSurName().equals(surname)) {
|
if (patient.getSurname().equals(surname)) {
|
||||||
return patient;
|
return patient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,9 +137,9 @@ public class AllTreatmentController {
|
||||||
public void handleDelete() {
|
public void handleDelete() {
|
||||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||||
Treatment t = this.treatments.remove(index);
|
Treatment t = this.treatments.remove(index);
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
dao.delete(t.getId());
|
dao.deleteById(t.getId());
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -216,12 +209,12 @@ public class AllTreatmentController {
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
|
|
||||||
TreatmentModalController controller = loader.getController();
|
TreatmentModalController controller = loader.getController();
|
||||||
PatientDao pDao = DaoFactory.getInstance().createPatientDAO();
|
PatientDao pDao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||||
controller.initialize(
|
controller.initialize(
|
||||||
this,
|
this,
|
||||||
stage,
|
stage,
|
||||||
treatment,
|
treatment,
|
||||||
pDao.read(treatment.getPatient().getId())
|
pDao.read(treatment.getPatientId())
|
||||||
);
|
);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
@ -235,7 +228,7 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTreatment(Treatment treatment) {
|
public void createTreatment(Treatment treatment) {
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
dao.create(treatment);
|
dao.create(treatment);
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
|
@ -244,7 +237,7 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTreatment(Treatment treatment) {
|
public void updateTreatment(Treatment treatment) {
|
||||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
dao.update(treatment);
|
dao.update(treatment);
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
|
|
|
@ -1,122 +1,94 @@
|
||||||
package de.hitec.nhplus.treatment;
|
package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
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.SimpleObjectProperty;
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
public class Treatment {
|
public class Treatment {
|
||||||
private SimpleIntegerProperty id;
|
private int id;
|
||||||
private final SimpleObjectProperty<Patient> patient;
|
private final int patientId;
|
||||||
private final SimpleObjectProperty<LocalDate> date;
|
private LocalDate date;
|
||||||
private final SimpleObjectProperty<LocalTime> begin;
|
private LocalTime begin;
|
||||||
private final SimpleObjectProperty<LocalTime> end;
|
private LocalTime end;
|
||||||
private final SimpleStringProperty description;
|
private String description;
|
||||||
private final SimpleStringProperty remarks;
|
private String remarks;
|
||||||
|
|
||||||
public Treatment(Patient patient, LocalDate date, LocalTime begin,
|
public Treatment(int patientId, LocalDate date, LocalTime begin,
|
||||||
LocalTime end, String description, String remarks) {
|
LocalTime end, String description, String remarks) {
|
||||||
this.patient = new SimpleObjectProperty<>(patient);
|
this.patientId = patientId;
|
||||||
this.date = new SimpleObjectProperty<>(date);
|
this.date = date;
|
||||||
this.begin = new SimpleObjectProperty<>(begin);
|
this.begin = begin;
|
||||||
this.end = new SimpleObjectProperty<>(end);
|
this.end = end;
|
||||||
this.description = new SimpleStringProperty(description);
|
this.description = description;
|
||||||
this.remarks = new SimpleStringProperty(remarks);
|
this.remarks = remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treatment(int id, Patient patient, LocalDate date, LocalTime begin,
|
public Treatment(int id, int patientId, LocalDate date, LocalTime begin,
|
||||||
LocalTime end, String description, String remarks) {
|
LocalTime end, String description, String remarks) {
|
||||||
this.id = new SimpleIntegerProperty(id);
|
this.id = id;
|
||||||
this.patient = new SimpleObjectProperty<>(patient);
|
this.patientId = patientId;
|
||||||
this.date = new SimpleObjectProperty<>(date);
|
this.date = date;
|
||||||
this.begin = new SimpleObjectProperty<>(begin);
|
this.begin = begin;
|
||||||
this.end = new SimpleObjectProperty<>(end);
|
this.end = end;
|
||||||
this.description = new SimpleStringProperty(description);
|
this.description = description;
|
||||||
this.remarks = new SimpleStringProperty(remarks);
|
this.remarks = remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id.getValue();
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Patient getPatient() {
|
public int getPatientId() {
|
||||||
return patient.getValue();
|
return this.patientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDate() {
|
public String getDate() {
|
||||||
return date.getValue().toString();
|
return date.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBegin() {
|
public String getBegin() {
|
||||||
return begin.getValue().toString();
|
return begin.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnd() {
|
public String getEnd() {
|
||||||
return end.getValue().toString();
|
return end.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDate(String date) {
|
public void setDate(String date) {
|
||||||
this.date.set(DateConverter.convertStringToLocalDate(date));
|
this.date = DateConverter.convertStringToLocalDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBegin(LocalTime begin) {
|
public void setBegin(LocalTime begin) {
|
||||||
this.begin.set(begin);
|
this.begin = begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnd(LocalTime end) {
|
public void setEnd(LocalTime end) {
|
||||||
this.end.set(end);
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description.set(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemarks() {
|
|
||||||
return remarks.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<Patient> patientProperty() {
|
|
||||||
return patient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<LocalDate> dateProperty() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<LocalTime> beginProperty() {
|
|
||||||
return begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<LocalTime> endProperty() {
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleStringProperty descriptionProperty() {
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleStringProperty remarksProperty() {
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemarks() {
|
||||||
return remarks;
|
return remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemarks(String remarks) {
|
public void setRemarks(String remarks) {
|
||||||
this.remarks.set(remarks);
|
this.remarks = remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringJoiner(System.lineSeparator())
|
return new StringJoiner(System.lineSeparator())
|
||||||
.add("TREATMENT")
|
.add("TREATMENT")
|
||||||
.add("ID: " + this.getId())
|
.add("ID: " + this.getId())
|
||||||
.add("Patient: " + this.getPatient().getSurName() + ", " + this.getPatient().getFirstName())
|
.add("PatientID: " + this.getPatientId())
|
||||||
.add("Date: " + this.getDate())
|
.add("Date: " + this.getDate())
|
||||||
.add("Begin: " + this.getBegin())
|
.add("Begin: " + this.getBegin())
|
||||||
.add("End: " + this.getEnd())
|
.add("End: " + this.getEnd())
|
||||||
|
|
151
src/main/java/de/hitec/nhplus/treatment/TreatmentDao.java
Normal file
151
src/main/java/de/hitec/nhplus/treatment/TreatmentDao.java
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.datastorage.DaoImp;
|
||||||
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
|
|
||||||
|
public TreatmentDao(Connection connection) {
|
||||||
|
super(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getCreateStatement(Treatment treatment) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "INSERT INTO treatment (patientId, treatment_date, begin, end, description, remark) " +
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, treatment.getPatientId());
|
||||||
|
preparedStatement.setString(2, treatment.getDate());
|
||||||
|
preparedStatement.setString(3, treatment.getBegin());
|
||||||
|
preparedStatement.setString(4, treatment.getEnd());
|
||||||
|
preparedStatement.setString(5, treatment.getDescription());
|
||||||
|
preparedStatement.setString(6, treatment.getRemarks());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadByIDStatement(int id) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Treatment getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
return new Treatment(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getInt(2),
|
||||||
|
DateConverter.convertStringToLocalDate(result.getString(3)),
|
||||||
|
DateConverter.convertStringToLocalTime(result.getString(4)),
|
||||||
|
DateConverter.convertStringToLocalTime(result.getString(5)),
|
||||||
|
result.getString(6),
|
||||||
|
result.getString(7)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getReadAllStatement() {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM treatment";
|
||||||
|
statement = this.connection.prepareStatement(SQL);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ArrayList<Treatment> getListFromResultSet(ResultSet result) throws SQLException {
|
||||||
|
ArrayList<Treatment> list = new ArrayList<>();
|
||||||
|
while (result.next()) {
|
||||||
|
Treatment treatment = new Treatment(
|
||||||
|
result.getInt(1),
|
||||||
|
result.getInt(2),
|
||||||
|
DateConverter.convertStringToLocalDate(result.getString(3)),
|
||||||
|
DateConverter.convertStringToLocalTime(result.getString(4)),
|
||||||
|
DateConverter.convertStringToLocalTime(result.getString(5)),
|
||||||
|
result.getString(6),
|
||||||
|
result.getString(7)
|
||||||
|
);
|
||||||
|
list.add(treatment);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(int patientId) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, patientId);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Treatment> readTreatmentsByPid(int patientId) throws SQLException {
|
||||||
|
ResultSet result = getReadAllTreatmentsOfOnePatientByPid(patientId).executeQuery();
|
||||||
|
return getListFromResultSet(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getUpdateStatement(Treatment treatment) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL =
|
||||||
|
"UPDATE treatment SET " +
|
||||||
|
"patientId = ?, " +
|
||||||
|
"treatment_date = ?, " +
|
||||||
|
"begin = ?, " +
|
||||||
|
"end = ?, " +
|
||||||
|
"description = ?, " +
|
||||||
|
"remark = ? " +
|
||||||
|
"WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, treatment.getPatientId());
|
||||||
|
preparedStatement.setString(2, treatment.getDate());
|
||||||
|
preparedStatement.setString(3, treatment.getBegin());
|
||||||
|
preparedStatement.setString(4, treatment.getEnd());
|
||||||
|
preparedStatement.setString(5, treatment.getDescription());
|
||||||
|
preparedStatement.setString(6, treatment.getRemarks());
|
||||||
|
preparedStatement.setInt(7, treatment.getId());
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PreparedStatement getDeleteStatement(int id) {
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
try {
|
||||||
|
final String SQL =
|
||||||
|
"DELETE FROM treatment WHERE id = ?";
|
||||||
|
preparedStatement = this.connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setInt(1, id);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
return preparedStatement;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ public class TreatmentModalController {
|
||||||
@FXML
|
@FXML
|
||||||
private Label labelFirstName;
|
private Label labelFirstName;
|
||||||
@FXML
|
@FXML
|
||||||
private Label labelSurName;
|
private Label labelSurname;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField textFieldBegin;
|
private TextField textFieldBegin;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -44,7 +44,7 @@ public class TreatmentModalController {
|
||||||
isNewTreatment = true;
|
isNewTreatment = true;
|
||||||
LocalTime currentTime = LocalTime.now();
|
LocalTime currentTime = LocalTime.now();
|
||||||
this.treatment = new Treatment(
|
this.treatment = new Treatment(
|
||||||
patient,
|
patient.getId(),
|
||||||
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()),
|
||||||
|
@ -99,7 +99,7 @@ public class TreatmentModalController {
|
||||||
|
|
||||||
private void showData() {
|
private void showData() {
|
||||||
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());
|
||||||
this.datePicker.setValue(date);
|
this.datePicker.setValue(date);
|
||||||
this.textFieldBegin.setText(this.treatment.getBegin());
|
this.textFieldBegin.setText(this.treatment.getBegin());
|
||||||
|
|
|
@ -1,117 +0,0 @@
|
||||||
package de.hitec.nhplus.treatment.database;
|
|
||||||
|
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
|
||||||
import de.hitec.nhplus.datastorage.DaoImp;
|
|
||||||
import de.hitec.nhplus.treatment.Treatment;
|
|
||||||
import de.hitec.nhplus.utils.DateConverter;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TreatmentDao extends DaoImp<Treatment> {
|
|
||||||
|
|
||||||
public TreatmentDao(Connection connection) {
|
|
||||||
super(connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
INSERT INTO treatment
|
|
||||||
(patientId, date, begin, end, description, remark)
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, treatment.getPatient().getId());
|
|
||||||
statement.setString(2, treatment.getDate());
|
|
||||||
statement.setString(3, treatment.getBegin());
|
|
||||||
statement.setString(4, treatment.getEnd());
|
|
||||||
statement.setString(5, treatment.getDescription());
|
|
||||||
statement.setString(6, treatment.getRemarks());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE id = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Treatment getInstanceFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
return new Treatment(
|
|
||||||
result.getInt(1),
|
|
||||||
DaoFactory.getInstance().createPatientDAO().read(result.getInt(2)),
|
|
||||||
DateConverter.convertStringToLocalDate(result.getString(3)),
|
|
||||||
DateConverter.convertStringToLocalTime(result.getString(4)),
|
|
||||||
DateConverter.convertStringToLocalTime(result.getString(5)),
|
|
||||||
result.getString(6),
|
|
||||||
result.getString(7)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment";
|
|
||||||
return this.connection.prepareStatement(SQL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<Treatment> getListFromResultSet(ResultSet result) throws SQLException {
|
|
||||||
ArrayList<Treatment> list = new ArrayList<>();
|
|
||||||
while (result.next()) {
|
|
||||||
list.add(getInstanceFromResultSet(result));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(int patientId) throws SQLException {
|
|
||||||
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, patientId);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Treatment> readTreatmentsByPid(int patientId) throws SQLException {
|
|
||||||
ResultSet result = getReadAllTreatmentsOfOnePatientByPid(patientId).executeQuery();
|
|
||||||
return getListFromResultSet(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
|
|
||||||
final String SQL = """
|
|
||||||
UPDATE treatment SET
|
|
||||||
patientId = ?,
|
|
||||||
date = ?,
|
|
||||||
begin = ?,
|
|
||||||
end = ?,
|
|
||||||
description = ?,
|
|
||||||
remark = ?
|
|
||||||
WHERE id = ?
|
|
||||||
""";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, treatment.getPatient().getId());
|
|
||||||
statement.setString(2, treatment.getDate());
|
|
||||||
statement.setString(3, treatment.getBegin());
|
|
||||||
statement.setString(4, treatment.getEnd());
|
|
||||||
statement.setString(5, treatment.getDescription());
|
|
||||||
statement.setString(6, treatment.getRemarks());
|
|
||||||
statement.setInt(7, treatment.getId());
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PreparedStatement getDeleteStatement(int id) throws SQLException {
|
|
||||||
final String SQL =
|
|
||||||
"DELETE FROM treatment WHERE id = ?";
|
|
||||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
|
||||||
statement.setInt(1, id);
|
|
||||||
return statement;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,17 +11,11 @@ module de.hitec.nhplus {
|
||||||
opens de.hitec.nhplus.main to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.main to javafx.base, javafx.fxml;
|
||||||
|
|
||||||
exports de.hitec.nhplus.patient;
|
exports de.hitec.nhplus.patient;
|
||||||
exports de.hitec.nhplus.patient.database;
|
|
||||||
opens de.hitec.nhplus.patient.database to javafx.base, javafx.fxml;
|
|
||||||
opens de.hitec.nhplus.patient to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.patient to javafx.base, javafx.fxml;
|
||||||
|
|
||||||
exports de.hitec.nhplus.treatment;
|
exports de.hitec.nhplus.treatment;
|
||||||
exports de.hitec.nhplus.treatment.database;
|
|
||||||
opens de.hitec.nhplus.treatment to javafx.base, javafx.fxml;
|
opens de.hitec.nhplus.treatment to javafx.base, javafx.fxml;
|
||||||
opens de.hitec.nhplus.treatment.database to javafx.base, javafx.fxml;
|
|
||||||
|
|
||||||
exports de.hitec.nhplus.nurse;
|
exports de.hitec.nhplus.nurse;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
text="ID"
|
text="ID"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnSurName"
|
fx:id="columnSurname"
|
||||||
minWidth="140.0"
|
minWidth="140.0"
|
||||||
text="Nachname"
|
text="Nachname"
|
||||||
/>
|
/>
|
||||||
|
@ -51,12 +51,12 @@
|
||||||
<Insets right="8.0"/>
|
<Insets right="8.0"/>
|
||||||
</padding>
|
</padding>
|
||||||
<TextField
|
<TextField
|
||||||
fx:id="textFieldSurName"
|
fx:id="textFieldSurname"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
promptText="Nachname"
|
promptText="Nachname"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fx:id="textFieldFirstName"
|
fx:id="textFieldFirstname"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
promptText="Vorname"
|
promptText="Vorname"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
CREATE TABLE nurse
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
firstName TEXT NOT NULL,
|
|
||||||
surName TEXT NOT NULL,
|
|
||||||
phoneNumber TEXT NOT NULL
|
|
||||||
)
|
|
|
@ -23,7 +23,7 @@
|
||||||
text="ID"
|
text="ID"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnSurName"
|
fx:id="columnSurname"
|
||||||
minWidth="140.0"
|
minWidth="140.0"
|
||||||
onEditCommit="#handleOnEditSurname"
|
onEditCommit="#handleOnEditSurname"
|
||||||
text="Nachname"
|
text="Nachname"
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
fx:id="textFieldSurName"
|
fx:id="textFieldSurname"
|
||||||
promptText="Nachname"
|
promptText="Nachname"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE TABLE patient
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
firstName TEXT NOT NULL,
|
|
||||||
surName TEXT NOT NULL,
|
|
||||||
dateOfBirth TEXT NOT NULL,
|
|
||||||
careLevel TEXT NOT NULL,
|
|
||||||
roomNumber TEXT NOT NULL
|
|
||||||
);
|
|
|
@ -24,9 +24,9 @@
|
||||||
text="ID"
|
text="ID"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnPatientName"
|
fx:id="columnPatientId"
|
||||||
minWidth="80.0"
|
minWidth="40.0"
|
||||||
text="Patient"
|
text="PatientID"
|
||||||
/>
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnDate"
|
fx:id="columnDate"
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
prefWidth="200"
|
prefWidth="200"
|
||||||
fx:id="labelSurName"
|
fx:id="labelSurname"
|
||||||
text="Nachname"
|
text="Nachname"
|
||||||
/>
|
/>
|
||||||
<!-- Row 2 -->
|
<!-- Row 2 -->
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
CREATE TABLE treatment
|
|
||||||
(
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
patientId INTEGER NOT NULL,
|
|
||||||
date TEXT NOT NULL,
|
|
||||||
begin TEXT NOT NULL,
|
|
||||||
end TEXT NOT NULL,
|
|
||||||
description TEXT NOT NULL,
|
|
||||||
remark TEXT NOT NULL,
|
|
||||||
FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE
|
|
||||||
)
|
|
Loading…
Reference in a new issue