Compare commits

..

No commits in common. "54bdc210408c503c69a3cc9b7e64ca19d22c727c" and "a4e61157efa646f408635c123ea839691840634c" have entirely different histories.

10 changed files with 63 additions and 169 deletions

Binary file not shown.

View file

@ -1,7 +1,6 @@
package de.hitec.nhplus.fixtures;
import de.hitec.nhplus.datastorage.ConnectionBuilder;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.patient.Patient;
import java.sql.Connection;
@ -29,17 +28,15 @@ public class Fixtures {
patientFixture.setupTable(connection);
Map<String, Patient> patientsByName = patientFixture.load();
NurseFixture nurseFixture = new NurseFixture();
nurseFixture.dropTable(connection);
nurseFixture.setupTable(connection);
Map<String, Nurse> nursesByName = nurseFixture.load();
TreatmentFixture treatmentFixture = new TreatmentFixture(patientsByName, nursesByName);
TreatmentFixture treatmentFixture = new TreatmentFixture(patientsByName);
treatmentFixture.dropTable(connection);
treatmentFixture.setupTable(connection);
treatmentFixture.load();
NurseFixture nurseFixture = new NurseFixture();
nurseFixture.dropTable(connection);
nurseFixture.setupTable(connection);
nurseFixture.load();
MedicationFixture medicationFixture = new MedicationFixture();
medicationFixture.dropTable(connection);

View file

@ -2,7 +2,6 @@ package de.hitec.nhplus.fixtures;
import de.hitec.nhplus.Main;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.patient.Patient;
import de.hitec.nhplus.treatment.Treatment;
import de.hitec.nhplus.treatment.database.TreatmentDao;
@ -18,11 +17,9 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
public class TreatmentFixture implements Fixture<Treatment> {
private final Map<String, Patient> patientsByName;
private final Map<String, Nurse> nursesByName;
public TreatmentFixture(Map<String, Patient> patientsByName, Map<String, Nurse> nursesByName) {
public TreatmentFixture(Map<String, Patient> patientsByName) {
this.patientsByName = patientsByName;
this.nursesByName = nursesByName;
}
@Override
@ -48,13 +45,9 @@ public class TreatmentFixture implements Fixture<Treatment> {
Patient ahmet = patientsByName.get("Ahmet");
Patient elisabeth = patientsByName.get("Elisabeth");
Nurse ole = nursesByName.get("Ole");
Nurse armin = nursesByName.get("Armin");
treatments.add(new Treatment(
1,
seppl,
ole,
convertStringToLocalDate("2023-06-03"),
convertStringToLocalTime("11:00"),
convertStringToLocalTime("15:00"),
@ -66,7 +59,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
2,
seppl,
armin,
convertStringToLocalDate("2023-06-05"),
convertStringToLocalTime("11:00"),
convertStringToLocalTime("12:30"),
@ -78,7 +70,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
3,
martina,
ole,
convertStringToLocalDate("2023-06-04"),
convertStringToLocalTime("07:30"),
convertStringToLocalTime("08:00"),
@ -88,7 +79,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
4,
seppl,
armin,
convertStringToLocalDate("2023-06-06"),
convertStringToLocalTime("15:10"),
convertStringToLocalTime("16:00"),
@ -98,7 +88,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
8,
seppl,
ole,
convertStringToLocalDate("2023-06-08"),
convertStringToLocalTime("15:00"),
convertStringToLocalTime("16:00"),
@ -108,7 +97,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
9,
martina,
armin,
convertStringToLocalDate("2023-06-07"),
convertStringToLocalTime("11:00"),
convertStringToLocalTime("11:30"),
@ -118,7 +106,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
12,
hans,
armin,
convertStringToLocalDate("2023-06-08"),
convertStringToLocalTime("15:00"),
convertStringToLocalTime("15:30"),
@ -128,7 +115,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
14,
ahmet,
ole,
convertStringToLocalDate("2023-08-24"),
convertStringToLocalTime("09:30"),
convertStringToLocalTime("10:15"),
@ -137,7 +123,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
16,
elisabeth,
armin,
convertStringToLocalDate("2023-08-31"),
convertStringToLocalTime("13:30"),
convertStringToLocalTime("13:45"),
@ -147,7 +132,6 @@ public class TreatmentFixture implements Fixture<Treatment> {
treatments.add(new Treatment(
17,
elisabeth,
ole,
convertStringToLocalDate("2023-09-01"),
convertStringToLocalTime("16:00"),
convertStringToLocalTime("17:00"),

View file

@ -2,8 +2,6 @@ package de.hitec.nhplus.treatment;
import de.hitec.nhplus.Main;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.nurse.database.NurseDao;
import de.hitec.nhplus.patient.Patient;
import de.hitec.nhplus.patient.database.PatientDao;
import de.hitec.nhplus.treatment.database.TreatmentDao;
@ -33,9 +31,6 @@ public class AllTreatmentController {
@FXML
private TableColumn<Treatment, String> columnPatientName;
@FXML
private TableColumn<Treatment, String> columnNurseName;
@FXML
private TableColumn<Treatment, String> columnDate;
@ -51,9 +46,6 @@ public class AllTreatmentController {
@FXML
private ComboBox<String> comboBoxPatientSelection;
@FXML
public ComboBox<String> comboBoxNurseSelection;
@FXML
private Button buttonDelete;
@ -61,15 +53,11 @@ public class AllTreatmentController {
private TreatmentDao dao;
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
private ArrayList<Patient> patientList;
private final ObservableList<String> nurseSelection = FXCollections.observableArrayList();
private ArrayList<Nurse> nurseList;
public void initialize() {
readAllAndShowInTableView();
comboBoxPatientSelection.setItems(patientSelection);
comboBoxPatientSelection.getSelectionModel().select("alle");
comboBoxNurseSelection.setItems(nurseSelection);
comboBoxPatientSelection.getSelectionModel().select(0);
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnPatientName.setCellValueFactory(
@ -78,12 +66,6 @@ public class AllTreatmentController {
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
}
);
this.columnNurseName.setCellValueFactory(
cellData -> {
Nurse nurse = cellData.getValue().getNurse();
return new SimpleStringProperty(nurse.getSurName() + ", " + nurse.getFirstName());
}
);
this.columnDate.setCellValueFactory(new PropertyValueFactory<>("date"));
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
@ -102,6 +84,7 @@ public class AllTreatmentController {
}
public void readAllAndShowInTableView() {
comboBoxPatientSelection.getSelectionModel().select(0);
this.dao = DaoFactory.getInstance().createTreatmentDao();
try {
this.treatments.setAll(dao.readAll());
@ -111,19 +94,13 @@ public class AllTreatmentController {
}
private void createComboBoxData() {
PatientDao patientDAO = DaoFactory.getInstance().createPatientDAO();
NurseDao nurseDao = DaoFactory.getInstance().createNurseDAO();
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
try {
patientList = (ArrayList<Patient>) patientDAO.readAll();
patientList = (ArrayList<Patient>) dao.readAll();
this.patientSelection.add("alle");
for (Patient patient : patientList) {
this.patientSelection.add(patient.getSurName());
}
nurseList = (ArrayList<Nurse>) nurseDao.readAll();
for (Nurse nurse : nurseList) {
this.nurseSelection.add(nurse.getSurName());
}
} catch (SQLException exception) {
exception.printStackTrace();
}
@ -131,7 +108,7 @@ public class AllTreatmentController {
@FXML
public void handleComboBoxPatient() {
public void handleComboBox() {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
this.treatments.clear();
this.dao = DaoFactory.getInstance().createTreatmentDao();
@ -144,17 +121,17 @@ public class AllTreatmentController {
}
}
Patient patient = searchInPatientList(selectedPatient);
Patient patient = searchInList(selectedPatient);
if (patient != null) {
try {
this.treatments.setAll(this.dao.readTreatmentsByPatient(patient.getId()));
this.treatments.setAll(this.dao.readTreatmentsByPid(patient.getId()));
} catch (SQLException exception) {
exception.printStackTrace();
}
}
}
private Patient searchInPatientList(String surname) {
private Patient searchInList(String surname) {
for (Patient patient : this.patientList) {
if (patient.getSurName().equals(surname)) {
return patient;
@ -163,15 +140,6 @@ public class AllTreatmentController {
return null;
}
private Nurse searchInNurseList(String surname) {
for (Nurse nurse : this.nurseList) {
if (nurse.getSurName().equals(surname)) {
return nurse;
}
}
return null;
}
@FXML
public void handleDelete() {
int index = this.tableView.getSelectionModel().getSelectedIndex();
@ -188,12 +156,8 @@ public class AllTreatmentController {
public void handleNewTreatment() {
try {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
Patient patient = searchInPatientList(selectedPatient);
String selectedNurse = this.comboBoxNurseSelection.getSelectionModel().getSelectedItem();
Nurse nurse = searchInNurseList(selectedNurse);
newTreatmentWindow(patient, nurse);
Patient patient = searchInList(selectedPatient);
newTreatmentWindow(patient);
} catch (NullPointerException exception) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information");
@ -210,12 +174,12 @@ public class AllTreatmentController {
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
int index = this.tableView.getSelectionModel().getSelectedIndex();
Treatment treatment = this.treatments.get(index);
treatmentWindow(treatment, treatment.getNurse());
treatmentWindow(treatment);
}
});
}
public void newTreatmentWindow(Patient patient, Nurse nurse) {
public void newTreatmentWindow(Patient patient) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
@ -229,8 +193,7 @@ public class AllTreatmentController {
this,
stage,
null,
patient,
nurse
patient
);
stage.setScene(scene);
@ -243,7 +206,7 @@ public class AllTreatmentController {
}
}
public void treatmentWindow(Treatment treatment, Nurse nurse) {
public void treatmentWindow(Treatment treatment) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
@ -258,8 +221,7 @@ public class AllTreatmentController {
this,
stage,
treatment,
pDao.read(treatment.getPatient().getId()),
nurse
pDao.read(treatment.getPatient().getId())
);
stage.setScene(scene);

View file

@ -1,6 +1,5 @@
package de.hitec.nhplus.treatment;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.patient.Patient;
import de.hitec.nhplus.utils.DateConverter;
import javafx.beans.property.SimpleIntegerProperty;
@ -14,17 +13,16 @@ import java.util.StringJoiner;
public class Treatment {
private SimpleIntegerProperty id;
private final SimpleObjectProperty<Patient> patient;
private final SimpleObjectProperty<Nurse> nurse;
private final SimpleObjectProperty<LocalDate> date;
private final SimpleObjectProperty<LocalTime> begin;
private final SimpleObjectProperty<LocalTime> end;
private final SimpleStringProperty description;
private final SimpleStringProperty remarks;
//TODO: Add Nurse
public Treatment(Patient patient, Nurse nurse, LocalDate date, LocalTime begin,
public Treatment(Patient patient, LocalDate date, LocalTime begin,
LocalTime end, String description, String remarks) {
this.patient = new SimpleObjectProperty<>(patient);
this.nurse = new SimpleObjectProperty<>(nurse);
this.date = new SimpleObjectProperty<>(date);
this.begin = new SimpleObjectProperty<>(begin);
this.end = new SimpleObjectProperty<>(end);
@ -32,11 +30,10 @@ public class Treatment {
this.remarks = new SimpleStringProperty(remarks);
}
public Treatment(int id, Patient patient, Nurse nurse, LocalDate date, LocalTime begin,
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.nurse = new SimpleObjectProperty<>(nurse);
this.date = new SimpleObjectProperty<>(date);
this.begin = new SimpleObjectProperty<>(begin);
this.end = new SimpleObjectProperty<>(end);
@ -52,10 +49,6 @@ public class Treatment {
return patient.getValue();
}
public Nurse getNurse() {
return nurse.getValue();
}
public String getDate() {
return date.getValue().toString();
}
@ -96,10 +89,6 @@ public class Treatment {
return patient;
}
public SimpleObjectProperty<Nurse> nurseProperty() {
return nurse;
}
public SimpleObjectProperty<LocalDate> dateProperty() {
return date;
}
@ -129,7 +118,6 @@ public class Treatment {
.add("TREATMENT")
.add("ID: " + this.getId())
.add("Patient: " + this.getPatient().getSurName() + ", " + this.getPatient().getFirstName())
.add("Nurse: " + this.getNurse().getSurName() + ", " + this.getNurse().getFirstName())
.add("Date: " + this.getDate())
.add("Begin: " + this.getBegin())
.add("End: " + this.getEnd())

View file

@ -1,6 +1,5 @@
package de.hitec.nhplus.treatment;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.patient.Patient;
import de.hitec.nhplus.utils.DateConverter;
import javafx.beans.value.ChangeListener;
@ -15,8 +14,6 @@ import java.time.LocalTime;
import static de.hitec.nhplus.utils.Validator.*;
public class TreatmentModalController {
@FXML
private Label labelNurseName;
@FXML
private Label labelFirstName;
@FXML
@ -36,27 +33,18 @@ public class TreatmentModalController {
private AllTreatmentController controller;
private Stage stage;
private Patient patient;
private Nurse nurse;
private Treatment treatment;
private boolean isNewTreatment = false;
public void initialize(
AllTreatmentController controller,
Stage stage,
Treatment treatment,
Patient patient,
Nurse nurse
) {
public void initialize(AllTreatmentController controller, Stage stage, Treatment treatment, Patient patient) {
this.controller = controller;
this.stage = stage;
this.patient = patient;
this.nurse = nurse;
if (treatment == null) {
isNewTreatment = true;
LocalTime currentTime = LocalTime.now();
this.treatment = new Treatment(
patient,
nurse,
LocalDate.now(),
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
@ -110,7 +98,6 @@ public class TreatmentModalController {
}
private void showData() {
this.labelNurseName.setText(nurse.getSurName());
this.labelFirstName.setText(patient.getFirstName());
this.labelSurName.setText(patient.getSurName());
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());

View file

@ -2,7 +2,6 @@ package de.hitec.nhplus.treatment.database;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.datastorage.DaoImp;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.treatment.Treatment;
import de.hitec.nhplus.utils.DateConverter;
@ -13,6 +12,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
//TODO: Update Methods to use a new Nurse Field (cascade this to any class using this DAO)
public class TreatmentDao extends DaoImp<Treatment> {
public TreatmentDao(Connection connection) {
@ -23,17 +23,16 @@ public class TreatmentDao extends DaoImp<Treatment> {
protected PreparedStatement getCreateStatement(Treatment treatment) throws SQLException {
final String SQL = """
INSERT INTO treatment
(patientId, nurseId, date, begin, end, description, remark)
VALUES (?, ?, ?, ?, ?, ?, ?)
(patientId, date, begin, end, description, remark)
VALUES (?, ?, ?, ?, ?, ?)
""";
PreparedStatement statement = this.connection.prepareStatement(SQL);
statement.setInt(1, treatment.getPatient().getId());
statement.setInt(2, treatment.getNurse().getId());
statement.setString(3, treatment.getDate());
statement.setString(4, treatment.getBegin());
statement.setString(5, treatment.getEnd());
statement.setString(6, treatment.getDescription());
statement.setString(7, treatment.getRemarks());
statement.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;
}
@ -50,12 +49,11 @@ public class TreatmentDao extends DaoImp<Treatment> {
return new Treatment(
result.getInt(1),
DaoFactory.getInstance().createPatientDAO().read(result.getInt(2)),
DaoFactory.getInstance().createNurseDAO().read(result.getInt(3)),
DateConverter.convertStringToLocalDate(result.getString(4)),
DateConverter.convertStringToLocalDate(result.getString(3)),
DateConverter.convertStringToLocalTime(result.getString(4)),
DateConverter.convertStringToLocalTime(result.getString(5)),
DateConverter.convertStringToLocalTime(result.getString(6)),
result.getString(7),
result.getString(8)
result.getString(6),
result.getString(7)
);
}
@ -74,26 +72,25 @@ public class TreatmentDao extends DaoImp<Treatment> {
return list;
}
public List<Treatment> readTreatmentsByPatient(int patientId) throws SQLException {
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);
ResultSet result = statement.executeQuery();
return statement;
}
public List<Treatment> readTreatmentsByPid(int patientId) throws SQLException {
ResultSet result = getReadAllTreatmentsOfOnePatientByPid(patientId).executeQuery();
return getListFromResultSet(result);
}
public List<Treatment> readTreatmentsByNurse(int nurseId) throws SQLException {
final String SQL = "SELECT * FROM treatment WHERE nurseId = ?";
PreparedStatement statement = this.connection.prepareStatement(SQL);
statement.setInt(1, nurseId);
ResultSet result = statement.executeQuery();
return getListFromResultSet(result);
}
//TODO: readTreatmentsByNurse
@Override
protected PreparedStatement getUpdateStatement(Treatment treatment) throws SQLException {
final String SQL = """
UPDATE treatment SET
patientId = ?,
date = ?,
begin = ?,
end = ?,
@ -102,12 +99,13 @@ public class TreatmentDao extends DaoImp<Treatment> {
WHERE id = ?
""";
PreparedStatement statement = this.connection.prepareStatement(SQL);
statement.setString(1, treatment.getDate());
statement.setString(2, treatment.getBegin());
statement.setString(3, treatment.getEnd());
statement.setString(4, treatment.getDescription());
statement.setString(5, treatment.getRemarks());
statement.setInt(6, treatment.getId());
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;
}

View file

@ -28,11 +28,6 @@
minWidth="80.0"
text="Patient"
/>
<TableColumn
fx:id="columnNurseName"
minWidth="80.0"
text="Pflegekraft"
/>
<TableColumn
fx:id="columnDate"
maxWidth="-1.0"
@ -71,11 +66,7 @@
<ComboBox
fx:id="comboBoxPatientSelection"
prefWidth="200.0"
onAction="#handleComboBoxPatient"
/>
<ComboBox
fx:id="comboBoxNurseSelection"
prefWidth="200.0"
onAction="#handleComboBox"
/>
<Button
mnemonicParsing="false"

View file

@ -30,33 +30,21 @@
<Label
GridPane.rowIndex="0"
GridPane.columnIndex="0"
text="Pfleger:"
text="Vorname:"
/>
<Label
GridPane.rowIndex="0"
GridPane.columnIndex="1"
prefWidth="200"
fx:id="labelNurseName" text="Pfleger Name"
/>
<!-- Row 1 -->
<Label
GridPane.rowIndex="1"
GridPane.columnIndex="0"
text="Vorname:"
/>
<Label
GridPane.rowIndex="1"
GridPane.columnIndex="1"
prefWidth="200"
fx:id="labelFirstName" text="Vorname"
/>
<Label
GridPane.rowIndex="1"
GridPane.rowIndex="0"
GridPane.columnIndex="3"
text="Nachname:"
/>
<Label
GridPane.rowIndex="1"
GridPane.rowIndex="0"
GridPane.columnIndex="4"
prefWidth="200"
fx:id="labelSurName"

View file

@ -2,12 +2,11 @@ CREATE TABLE treatment
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
patientId INTEGER NOT NULL,
nurseId 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,
FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL
FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE
-- TODO: Add Nurse
)