Compare commits
No commits in common. "1827e8caf6f2ef3ee9c680449b52012bfbcba450" and "c01960cfd9f154ee768bc939568aa7a043e59658" have entirely different histories.
1827e8caf6
...
c01960cfd9
28 changed files with 323 additions and 394 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<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>
|
||||
<synchronize>true</synchronize>
|
||||
<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"?>
|
||||
<project version="4">
|
||||
<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/treatment/database/TreatmentDao.java" dialect="GenericSQL" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/treatment/database/NurseDao.java" dialect="GenericSQL" />
|
||||
<file url="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/TreatmentDao.java" dialect="GenericSQL" />
|
||||
<file url="PROJECT" dialect="SQLite" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
|
@ -1,8 +1,8 @@
|
|||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
||||
import de.hitec.nhplus.patient.database.PatientDao;
|
||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||
import de.hitec.nhplus.nurse.NurseDao;
|
||||
import de.hitec.nhplus.patient.PatientDao;
|
||||
import de.hitec.nhplus.treatment.TreatmentDao;
|
||||
|
||||
public class DaoFactory {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
|||
|
||||
public interface Fixture<T>
|
||||
{
|
||||
void dropTable(Connection connection) throws SQLException;
|
||||
void setupTable(Connection connection) throws SQLException;
|
||||
void dropTable(Connection connection);
|
||||
void setupTable(Connection connection);
|
||||
Map<String, T> load() throws SQLException;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,40 @@
|
|||
package de.hitec.nhplus.fixtures;
|
||||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.nurse.NurseDao;
|
||||
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.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> {
|
||||
@Override
|
||||
public void dropTable(Connection connection) throws SQLException {
|
||||
connection.createStatement().execute("DROP TABLE nurse");
|
||||
public void dropTable(Connection connection) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("DROP TABLE nurse");
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupTable(Connection connection) throws SQLException {
|
||||
final InputStream schema = Main.class.getResourceAsStream("/de/hitec/nhplus/nurse/database/Nurse.sql");
|
||||
assert schema != null;
|
||||
final String SQL = new Scanner(schema, StandardCharsets.UTF_8).useDelimiter("\\A").next();
|
||||
connection.createStatement().execute(SQL);
|
||||
public void setupTable(Connection connection) {
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS nurse (" +
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
"firstname TEXT NOT NULL, " +
|
||||
"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
|
||||
|
@ -41,11 +53,11 @@ public class NurseFixture implements Fixture<Nurse> {
|
|||
"9876543210"
|
||||
));
|
||||
NurseDao dao = DaoFactory.getInstance().createNurseDAO();
|
||||
for (Nurse nurse : nurses) {
|
||||
for(Nurse nurse : nurses){
|
||||
dao.create(nurse);
|
||||
}
|
||||
Map<String, Nurse> nursesByName = new HashMap<>();
|
||||
for (Nurse nurse : dao.readAll()) {
|
||||
for (Nurse nurse : dao.readAll()){
|
||||
nursesByName.put(nurse.getFirstName(), nurse);
|
||||
}
|
||||
return nursesByName;
|
||||
|
|
|
@ -1,86 +1,107 @@
|
|||
package de.hitec.nhplus.fixtures;
|
||||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.patient.PatientDao;
|
||||
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.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;
|
||||
|
||||
public class PatientFixture implements Fixture<Patient> {
|
||||
public class PatientFixture implements Fixture<Patient>
|
||||
{
|
||||
@Override
|
||||
public void dropTable(Connection connection) throws SQLException {
|
||||
connection.createStatement().execute("DROP TABLE patient");
|
||||
public void dropTable(Connection connection)
|
||||
{
|
||||
try (Statement statement = connection.createStatement())
|
||||
{
|
||||
statement.execute("DROP TABLE patient");
|
||||
} catch (SQLException exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupTable(Connection connection) throws SQLException {
|
||||
// @SuppressWarnings("checkstyle:LineLength")
|
||||
final InputStream schema = Main.class.getResourceAsStream("/de/hitec/nhplus/patient/database/Patient.sql");
|
||||
assert schema != null;
|
||||
final String SQL = new Scanner(schema, StandardCharsets.UTF_8).useDelimiter("\\A").next();
|
||||
connection.createStatement().execute(SQL);
|
||||
public void setupTable(Connection connection)
|
||||
{
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS 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" +
|
||||
");";
|
||||
try (Statement statement = connection.createStatement())
|
||||
{
|
||||
statement.execute(SQL);
|
||||
} catch (SQLException exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Patient> load() throws SQLException {
|
||||
public Map<String, Patient> load() throws SQLException
|
||||
{
|
||||
List<Patient> patients = new ArrayList<>();
|
||||
|
||||
patients.add(new Patient(
|
||||
"Seppl",
|
||||
"Herberger",
|
||||
convertStringToLocalDate("1945-12-01"),
|
||||
"4",
|
||||
"202"
|
||||
"Seppl",
|
||||
"Herberger",
|
||||
convertStringToLocalDate("1945-12-01"),
|
||||
"4",
|
||||
"202"
|
||||
));
|
||||
patients.add(new Patient(
|
||||
"Martina",
|
||||
"Gerdsen",
|
||||
convertStringToLocalDate("1954-08-12"),
|
||||
"5",
|
||||
"010"
|
||||
"Martina",
|
||||
"Gerdsen",
|
||||
convertStringToLocalDate("1954-08-12"),
|
||||
"5",
|
||||
"010"
|
||||
));
|
||||
patients.add(new Patient(
|
||||
"Gertrud",
|
||||
"Franzen",
|
||||
convertStringToLocalDate("1949-04-16"),
|
||||
"3",
|
||||
"002"
|
||||
"Gertrud",
|
||||
"Franzen",
|
||||
convertStringToLocalDate("1949-04-16"),
|
||||
"3",
|
||||
"002"
|
||||
));
|
||||
patients.add(new Patient(
|
||||
"Ahmet",
|
||||
"Yilmaz",
|
||||
convertStringToLocalDate("1941-02-22"),
|
||||
"3",
|
||||
"013"
|
||||
"Ahmet",
|
||||
"Yilmaz",
|
||||
convertStringToLocalDate("1941-02-22"),
|
||||
"3",
|
||||
"013"
|
||||
));
|
||||
patients.add(new Patient(
|
||||
"Hans",
|
||||
"Neumann",
|
||||
convertStringToLocalDate("1955-12-12"),
|
||||
"2",
|
||||
"001"
|
||||
"Hans",
|
||||
"Neumann",
|
||||
convertStringToLocalDate("1955-12-12"),
|
||||
"2",
|
||||
"001"
|
||||
));
|
||||
patients.add(new Patient(
|
||||
"Elisabeth",
|
||||
"Müller",
|
||||
convertStringToLocalDate("1958-03-07"),
|
||||
"5",
|
||||
"110"
|
||||
"Elisabeth",
|
||||
"Müller",
|
||||
convertStringToLocalDate("1958-03-07"),
|
||||
"5",
|
||||
"110"
|
||||
));
|
||||
|
||||
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
|
||||
for (Patient patient : patients) {
|
||||
for (Patient patient : patients){
|
||||
dao.create(patient);
|
||||
}
|
||||
Map<String, Patient> patientsByName = new HashMap<>();
|
||||
for (Patient patient : dao.readAll()) {
|
||||
for (Patient patient : dao.readAll()){
|
||||
patientsByName.put(patient.getFirstName(), patient);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package de.hitec.nhplus.fixtures;
|
||||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
import de.hitec.nhplus.treatment.Treatment;
|
||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||
import de.hitec.nhplus.treatment.TreatmentDao;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
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.convertStringToLocalTime;
|
||||
|
@ -23,16 +24,32 @@ public class TreatmentFixture implements Fixture<Treatment> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void dropTable(Connection connection) throws SQLException {
|
||||
connection.createStatement().execute("DROP TABLE treatment");
|
||||
public void dropTable(Connection connection) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("DROP TABLE treatment");
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupTable(Connection connection) throws SQLException {
|
||||
final InputStream schema = Main.class.getResourceAsStream("/de/hitec/nhplus/treatment/database/Treatment.sql");
|
||||
assert schema != null;
|
||||
final String SQL = new Scanner(schema, StandardCharsets.UTF_8).useDelimiter("\\A").next();
|
||||
connection.createStatement().execute(SQL);
|
||||
public void setupTable(Connection connection) {
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS treatment (" +
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
" 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
|
||||
|
|
|
@ -9,7 +9,6 @@ import javafx.scene.layout.AnchorPane;
|
|||
import javafx.scene.layout.BorderPane;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MainWindowController {
|
||||
@FXML
|
||||
|
@ -41,7 +40,7 @@ public class MainWindowController {
|
|||
private void loadPatientPage() {
|
||||
try {
|
||||
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);
|
||||
AnchorPane.setTopAnchor(patientsPane, 0d);
|
||||
|
@ -56,7 +55,7 @@ public class MainWindowController {
|
|||
private void loadTreatmentsPage() {
|
||||
try {
|
||||
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);
|
||||
AnchorPane.setTopAnchor(treatmentsPane, 0d);
|
||||
|
@ -71,7 +70,7 @@ public class MainWindowController {
|
|||
private void loadNursePage() {
|
||||
try {
|
||||
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);
|
||||
AnchorPane.setTopAnchor(nursePane, 0d);
|
||||
|
|
|
@ -4,11 +4,11 @@ import javafx.beans.property.SimpleStringProperty;
|
|||
|
||||
public abstract class Person {
|
||||
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.surName = new SimpleStringProperty(surName);
|
||||
this.surname = new SimpleStringProperty(surname);
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
|
@ -23,15 +23,15 @@ public abstract class Person {
|
|||
this.firstName.set(firstName);
|
||||
}
|
||||
|
||||
public String getSurName() {
|
||||
return surName.get();
|
||||
public String getSurname() {
|
||||
return surname.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty surNameProperty() {
|
||||
return surName;
|
||||
public SimpleStringProperty surnameProperty() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public void setSurName(String surName) {
|
||||
this.surName.set(surName);
|
||||
public void setSurname(String surname) {
|
||||
this.surname.set(surname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package de.hitec.nhplus.nurse;
|
|||
import static de.hitec.nhplus.utils.Validator.*;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
@ -19,9 +18,9 @@ import java.sql.SQLException;
|
|||
|
||||
public class AllNurseController {
|
||||
@FXML
|
||||
public TextField textFieldSurName;
|
||||
public TextField textFieldSurname;
|
||||
@FXML
|
||||
public TextField textFieldFirstName;
|
||||
public TextField textFieldFirstname;
|
||||
@FXML
|
||||
public TextField textFieldPhoneNumber;
|
||||
@FXML
|
||||
|
@ -33,7 +32,7 @@ public class AllNurseController {
|
|||
@FXML
|
||||
private TableColumn<Nurse, String> columnFirstName;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnSurName;
|
||||
private TableColumn<Nurse, String> columnSurname;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnPhoneNumber;
|
||||
|
||||
|
@ -48,8 +47,8 @@ public class AllNurseController {
|
|||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName"));
|
||||
this.columnSurName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
|
||||
this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber"));
|
||||
|
@ -60,15 +59,15 @@ public class AllNurseController {
|
|||
this.buttonAdd.setDisable(true);
|
||||
ChangeListener<String> inputNewNurseValidationListener = (observableValue, oldText, newText)->
|
||||
{
|
||||
boolean isValid = isValidFirstName(this.textFieldFirstName.getText())
|
||||
&& isValidSurName(this.textFieldSurName.getText())
|
||||
boolean isValid = isValidFirstName(this.textFieldFirstname.getText())
|
||||
&& isValidSurName(this.textFieldSurname.getText())
|
||||
&& isValidPhoneNumber(this.textFieldPhoneNumber.getText());
|
||||
|
||||
AllNurseController.this.buttonAdd.setDisable(!isValid);
|
||||
};
|
||||
|
||||
this.textFieldFirstName.textProperty().addListener(inputNewNurseValidationListener);
|
||||
this.textFieldSurName.textProperty().addListener(inputNewNurseValidationListener);
|
||||
this.textFieldFirstname.textProperty().addListener(inputNewNurseValidationListener);
|
||||
this.textFieldSurname.textProperty().addListener(inputNewNurseValidationListener);
|
||||
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
||||
}
|
||||
|
||||
|
@ -83,8 +82,8 @@ public class AllNurseController {
|
|||
}
|
||||
@FXML
|
||||
public void handleAdd(){
|
||||
String surname=this.textFieldSurName.getText();
|
||||
String firstName=this.textFieldFirstName.getText();
|
||||
String surname=this.textFieldSurname.getText();
|
||||
String firstName=this.textFieldFirstname.getText();
|
||||
String phoneNumber=this.textFieldPhoneNumber.getText();
|
||||
try {
|
||||
this.dao.create(new Nurse(firstName, surname, phoneNumber));
|
||||
|
@ -97,8 +96,8 @@ public class AllNurseController {
|
|||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldFirstname.clear();
|
||||
this.textFieldSurname.clear();
|
||||
this.textFieldPhoneNumber.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,20 +12,20 @@ public class Nurse extends Person {
|
|||
|
||||
public Nurse(
|
||||
String firstName,
|
||||
String surName,
|
||||
String surname,
|
||||
String phoneNumber
|
||||
) {
|
||||
super(firstName, surName);
|
||||
super(firstName, surname);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
}
|
||||
|
||||
public Nurse(
|
||||
int id,
|
||||
String firstName,
|
||||
String surName,
|
||||
String surname,
|
||||
String phoneNumber
|
||||
) {
|
||||
super(firstName, surName);
|
||||
super(firstName, surname);
|
||||
this.id = new SimpleIntegerProperty(id);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ public class Nurse extends Person {
|
|||
return new StringJoiner(System.lineSeparator())
|
||||
.add("NURSE")
|
||||
.add("ID: " + this.getId())
|
||||
.add("FirstName: " + this.getFirstName())
|
||||
.add("SurName: " + this.getSurName())
|
||||
.add("Firstname: " + this.getFirstName())
|
||||
.add("Surname: " + this.getSurname())
|
||||
.add("PhoneNumber: " + this.getPhoneNumber())
|
||||
.toString();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.hitec.nhplus.nurse.database;
|
||||
package de.hitec.nhplus.nurse;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoImp;
|
||||
import de.hitec.nhplus.nurse.Nurse;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
|
@ -17,24 +16,21 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
|
||||
@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;
|
||||
final String SQL = "INSERT INTO nurse (firstname, surname, phoneNumber)" +
|
||||
"VALUES (?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setString(1, nurse.getFirstName());
|
||||
preparedStatement.setString(2, nurse.getSurname());
|
||||
preparedStatement.setString(3, nurse.getPhoneNumber());
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, id);
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,28 +58,28 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
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;
|
||||
final String SQL =
|
||||
"UPDATE nurse SET " +
|
||||
"firstname = ?, " +
|
||||
"surname = ?, " +
|
||||
"phoneNumber = ? " +
|
||||
"WHERE id = ?";
|
||||
PreparedStatement 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());
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, id);
|
||||
return preparedStatement;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package de.hitec.nhplus.patient;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.patient.database.PatientDao;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
|
@ -28,7 +27,7 @@ public class AllPatientController {
|
|||
@FXML
|
||||
private TableColumn<Patient, String> columnFirstName;
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnSurName;
|
||||
private TableColumn<Patient, String> columnSurname;
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnDateOfBirth;
|
||||
@FXML
|
||||
|
@ -40,7 +39,7 @@ public class AllPatientController {
|
|||
@FXML
|
||||
private Button buttonAdd;
|
||||
@FXML
|
||||
private TextField textFieldSurName;
|
||||
private TextField textFieldSurname;
|
||||
@FXML
|
||||
private TextField textFieldFirstName;
|
||||
@FXML
|
||||
|
@ -61,8 +60,8 @@ public class AllPatientController {
|
|||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName"));
|
||||
this.columnSurName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnDateOfBirth.setCellValueFactory(new PropertyValueFactory<>("dateOfBirth"));
|
||||
this.columnDateOfBirth.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
@ -89,7 +88,7 @@ public class AllPatientController {
|
|||
{
|
||||
boolean isValid = isValidDate(this.textFieldDateOfBirth.getText())
|
||||
&& isValidFirstName(this.textFieldFirstName.getText())
|
||||
&& isValidSurName(this.textFieldSurName.getText())
|
||||
&& isValidSurName(this.textFieldSurname.getText())
|
||||
&& isValidDate(this.textFieldDateOfBirth.getText())
|
||||
&& isValidCareLevel(this.textFieldCareLevel.getText())
|
||||
&& isValidRoomNumber(textFieldRoomNumber.getText());
|
||||
|
@ -97,7 +96,7 @@ public class AllPatientController {
|
|||
AllPatientController.this.buttonAdd.setDisable(!isValid);
|
||||
};
|
||||
|
||||
this.textFieldSurName.textProperty().addListener(inputNewPatientValidationListener);
|
||||
this.textFieldSurname.textProperty().addListener(inputNewPatientValidationListener);
|
||||
this.textFieldFirstName.textProperty().addListener(inputNewPatientValidationListener);
|
||||
this.textFieldDateOfBirth.textProperty().addListener(inputNewPatientValidationListener);
|
||||
this.textFieldCareLevel.textProperty().addListener(inputNewPatientValidationListener);
|
||||
|
@ -124,7 +123,7 @@ public class AllPatientController {
|
|||
event.getTableView().refresh();
|
||||
return;
|
||||
}
|
||||
event.getRowValue().setSurName(newSurName);
|
||||
event.getRowValue().setSurname(newSurName);
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
|
@ -198,7 +197,7 @@ public class AllPatientController {
|
|||
|
||||
@FXML
|
||||
public void handleAdd() {
|
||||
String surname = this.textFieldSurName.getText();
|
||||
String surname = this.textFieldSurname.getText();
|
||||
String firstName = this.textFieldFirstName.getText();
|
||||
String birthday = this.textFieldDateOfBirth.getText();
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(birthday);
|
||||
|
@ -215,7 +214,7 @@ public class AllPatientController {
|
|||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldSurname.clear();
|
||||
this.textFieldDateOfBirth.clear();
|
||||
this.textFieldCareLevel.clear();
|
||||
this.textFieldRoomNumber.clear();
|
||||
|
|
|
@ -20,12 +20,12 @@ public class Patient extends Person {
|
|||
|
||||
public Patient(
|
||||
String firstName,
|
||||
String surName,
|
||||
String surname,
|
||||
LocalDate dateOfBirth,
|
||||
String careLevel,
|
||||
String roomNumber
|
||||
) {
|
||||
super(firstName, surName);
|
||||
super(firstName, surname);
|
||||
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
||||
this.careLevel = new SimpleStringProperty(careLevel);
|
||||
this.roomNumber = new SimpleStringProperty(roomNumber);
|
||||
|
@ -34,12 +34,12 @@ public class Patient extends Person {
|
|||
public Patient(
|
||||
int id,
|
||||
String firstName,
|
||||
String surName,
|
||||
String surname,
|
||||
LocalDate dateOfBirth,
|
||||
String careLevel,
|
||||
String roomNumber
|
||||
) {
|
||||
super(firstName, surName);
|
||||
super(firstName, surname);
|
||||
this.id = new SimpleIntegerProperty(id);
|
||||
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
||||
this.careLevel = new SimpleStringProperty(careLevel);
|
||||
|
@ -103,8 +103,8 @@ public class Patient extends Person {
|
|||
return new StringJoiner(System.lineSeparator())
|
||||
.add("PATIENT")
|
||||
.add("ID: " + this.getId())
|
||||
.add("FirstName: " + this.getFirstName())
|
||||
.add("SurName: " + this.getSurName())
|
||||
.add("Firstname: " + this.getFirstName())
|
||||
.add("Surname: " + this.getSurname())
|
||||
.add("Birthday: " + this.getDateOfBirth())
|
||||
.add("Carelevel: " + this.getCareLevel())
|
||||
.add("RoomNumber: " + this.getRoomNumber())
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.hitec.nhplus.patient.database;
|
||||
package de.hitec.nhplus.patient;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoImp;
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
@ -19,26 +18,23 @@ public class PatientDao extends DaoImp<Patient> {
|
|||
|
||||
@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;
|
||||
final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber) " +
|
||||
"VALUES (?, ?, ?, ?, ?)";
|
||||
PreparedStatement 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());
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, id);
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,30 +65,29 @@ public class PatientDao extends DaoImp<Patient> {
|
|||
|
||||
@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;
|
||||
final String SQL =
|
||||
"UPDATE patient SET " +
|
||||
"firstname = ?, " +
|
||||
"surname = ?, " +
|
||||
"dateOfBirth = ?, " +
|
||||
"carelevel = ?, " +
|
||||
"roomnumber = ?, " +
|
||||
"WHERE id = ?";
|
||||
PreparedStatement 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());
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, id);
|
||||
return preparedStatement;
|
||||
}
|
||||
}
|
|
@ -3,10 +3,7 @@ package de.hitec.nhplus.treatment;
|
|||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
import de.hitec.nhplus.patient.database.PatientDao;
|
||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import de.hitec.nhplus.patient.PatientDao;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -30,7 +27,7 @@ public class AllTreatmentController {
|
|||
private TableColumn<Treatment, Integer> columnId;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, String> columnPatientName;
|
||||
private TableColumn<Treatment, Integer> columnPatientId;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, String> columnDate;
|
||||
|
@ -61,12 +58,7 @@ public class AllTreatmentController {
|
|||
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
this.columnPatientName.setCellValueFactory(
|
||||
cellData -> {
|
||||
Patient patient = cellData.getValue().getPatient();
|
||||
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
|
||||
}
|
||||
);
|
||||
this.columnPatientId.setCellValueFactory(new PropertyValueFactory<>("patientId"));
|
||||
this.columnDate.setCellValueFactory(new PropertyValueFactory<>("date"));
|
||||
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
|
||||
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
|
||||
|
@ -100,7 +92,7 @@ public class AllTreatmentController {
|
|||
patientList = (ArrayList<Patient>) dao.readAll();
|
||||
this.patientSelection.add("alle");
|
||||
for (Patient patient : patientList) {
|
||||
this.patientSelection.add(patient.getSurName());
|
||||
this.patientSelection.add(patient.getSurname());
|
||||
}
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
|
@ -134,7 +126,7 @@ public class AllTreatmentController {
|
|||
|
||||
private Patient searchInList(String surname) {
|
||||
for (Patient patient : this.patientList) {
|
||||
if (patient.getSurName().equals(surname)) {
|
||||
if (patient.getSurname().equals(surname)) {
|
||||
return patient;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,121 +2,94 @@ package de.hitec.nhplus.treatment;
|
|||
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
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.LocalTime;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class Treatment {
|
||||
private SimpleIntegerProperty id;
|
||||
private final SimpleObjectProperty<Patient> patient;
|
||||
private final SimpleObjectProperty<LocalDate> date;
|
||||
private final SimpleObjectProperty<LocalTime> begin;
|
||||
private final SimpleObjectProperty<LocalTime> end;
|
||||
private final SimpleStringProperty description;
|
||||
private final SimpleStringProperty remarks;
|
||||
private int id;
|
||||
private final Patient patient;
|
||||
private LocalDate date;
|
||||
private LocalTime begin;
|
||||
private LocalTime end;
|
||||
private String description;
|
||||
private String remarks;
|
||||
|
||||
public Treatment(Patient patient, LocalDate date, LocalTime begin,
|
||||
LocalTime end, String description, String remarks) {
|
||||
this.patient = new SimpleObjectProperty<>(patient);
|
||||
this.date = new SimpleObjectProperty<>(date);
|
||||
this.begin = new SimpleObjectProperty<>(begin);
|
||||
this.end = new SimpleObjectProperty<>(end);
|
||||
this.description = new SimpleStringProperty(description);
|
||||
this.remarks = new SimpleStringProperty(remarks);
|
||||
this.patient = patient;
|
||||
this.date = date;
|
||||
this.begin = begin;
|
||||
this.end = end;
|
||||
this.description = description;
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public Treatment(int id, Patient patient, LocalDate date, LocalTime begin,
|
||||
LocalTime end, String description, String remarks) {
|
||||
this.id = new SimpleIntegerProperty(id);
|
||||
this.patient = new SimpleObjectProperty<>(patient);
|
||||
this.date = new SimpleObjectProperty<>(date);
|
||||
this.begin = new SimpleObjectProperty<>(begin);
|
||||
this.end = new SimpleObjectProperty<>(end);
|
||||
this.description = new SimpleStringProperty(description);
|
||||
this.remarks = new SimpleStringProperty(remarks);
|
||||
this.id = id;
|
||||
this.patient = patient;
|
||||
this.date = date;
|
||||
this.begin = begin;
|
||||
this.end = end;
|
||||
this.description = description;
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id.getValue();
|
||||
return id;
|
||||
}
|
||||
|
||||
public Patient getPatient() {
|
||||
return patient.getValue();
|
||||
return this.patient;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date.getValue().toString();
|
||||
return date.toString();
|
||||
}
|
||||
|
||||
public String getBegin() {
|
||||
return begin.getValue().toString();
|
||||
return begin.toString();
|
||||
}
|
||||
|
||||
public String getEnd() {
|
||||
return end.getValue().toString();
|
||||
return end.toString();
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date.set(DateConverter.convertStringToLocalDate(date));
|
||||
this.date = DateConverter.convertStringToLocalDate(date);
|
||||
}
|
||||
|
||||
public void setBegin(LocalTime begin) {
|
||||
this.begin.set(begin);
|
||||
this.begin = begin;
|
||||
}
|
||||
|
||||
public void setEnd(LocalTime end) {
|
||||
this.end.set(end);
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public SimpleStringProperty remarksProperty() {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks.set(remarks);
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new StringJoiner(System.lineSeparator())
|
||||
.add("TREATMENT")
|
||||
.add("ID: " + this.getId())
|
||||
.add("Patient: " + this.getPatient().getSurName() + " " + this.getPatient().getFirstName())
|
||||
.add("Patient: " + this.getPatient().getSurname() + " " + this.getPatient().getFirstName())
|
||||
.add("Date: " + this.getDate())
|
||||
.add("Begin: " + this.getBegin())
|
||||
.add("End: " + this.getEnd())
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package de.hitec.nhplus.treatment.database;
|
||||
package de.hitec.nhplus.treatment;
|
||||
|
||||
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;
|
||||
|
@ -20,27 +19,24 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
|||
|
||||
@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;
|
||||
final String SQL = "INSERT INTO treatment (patientId, treatment_date, begin, end, description, remark) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, treatment.getPatient().getId());
|
||||
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());
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, id);
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,9 +69,9 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
|||
|
||||
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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, patientId);
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
public List<Treatment> readTreatmentsByPid(int patientId) throws SQLException {
|
||||
|
@ -85,33 +81,32 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
|||
|
||||
@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;
|
||||
final String SQL =
|
||||
"UPDATE treatment SET " +
|
||||
"patientId = ?, " +
|
||||
"treatment_date = ?, " +
|
||||
"begin = ?, " +
|
||||
"end = ?, " +
|
||||
"description = ?, " +
|
||||
"remark = ? " +
|
||||
"WHERE id = ?";
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, treatment.getPatient().getId());
|
||||
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());
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@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;
|
||||
PreparedStatement preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, id);
|
||||
return preparedStatement;
|
||||
}
|
||||
}
|
|
@ -99,7 +99,7 @@ public class TreatmentModalController {
|
|||
|
||||
private void showData() {
|
||||
this.labelFirstName.setText(patient.getFirstName());
|
||||
this.labelSurname.setText(patient.getSurName());
|
||||
this.labelSurname.setText(patient.getSurname());
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
|
||||
this.datePicker.setValue(date);
|
||||
this.textFieldBegin.setText(this.treatment.getBegin());
|
||||
|
|
|
@ -11,17 +11,11 @@ module de.hitec.nhplus {
|
|||
opens de.hitec.nhplus.main to javafx.base, javafx.fxml;
|
||||
|
||||
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;
|
||||
|
||||
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.database to javafx.base, javafx.fxml;
|
||||
|
||||
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.database to javafx.base, javafx.fxml;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
text="ID"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnSurName"
|
||||
fx:id="columnSurname"
|
||||
minWidth="140.0"
|
||||
text="Nachname"
|
||||
/>
|
||||
|
@ -51,12 +51,12 @@
|
|||
<Insets right="8.0"/>
|
||||
</padding>
|
||||
<TextField
|
||||
fx:id="textFieldSurName"
|
||||
fx:id="textFieldSurname"
|
||||
prefWidth="200.0"
|
||||
promptText="Nachname"
|
||||
/>
|
||||
<TextField
|
||||
fx:id="textFieldFirstName"
|
||||
fx:id="textFieldFirstname"
|
||||
prefWidth="200.0"
|
||||
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"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnSurName"
|
||||
fx:id="columnSurname"
|
||||
minWidth="140.0"
|
||||
onEditCommit="#handleOnEditSurname"
|
||||
text="Nachname"
|
||||
|
@ -90,7 +90,7 @@
|
|||
GridPane.rowIndex="0"
|
||||
GridPane.columnIndex="1"
|
||||
prefWidth="200.0"
|
||||
fx:id="textFieldSurName"
|
||||
fx:id="textFieldSurname"
|
||||
promptText="Nachname"
|
||||
/>
|
||||
<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"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnPatientName"
|
||||
minWidth="80.0"
|
||||
text="Patient"
|
||||
fx:id="columnPatientId"
|
||||
minWidth="40.0"
|
||||
text="PatientID"
|
||||
/>
|
||||
<TableColumn
|
||||
fx:id="columnDate"
|
||||
|
|
|
@ -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