Compare commits

..

No commits in common. "e17f2e44dd429268cadb923bcc71355d143d5bc9" and "817447239fa9fc3e90f79e36da9de3eae9b56236" have entirely different histories.

14 changed files with 137 additions and 212 deletions

View file

@ -15,7 +15,6 @@ import java.util.*;
/** /**
* {@link Fixture} for {@link Medication}. * {@link Fixture} for {@link Medication}.
*
* @author Dominik Säume * @author Dominik Säume
*/ */
public class MedicationFixture implements Fixture<Medication> { public class MedicationFixture implements Fixture<Medication> {

View file

@ -14,7 +14,6 @@ import java.util.*;
/** /**
* {@link Fixture} for {@link Nurse}. * {@link Fixture} for {@link Nurse}.
*
* @author Dominik Säume * @author Dominik Säume
*/ */
public class NurseFixture implements Fixture<Nurse> { public class NurseFixture implements Fixture<Nurse> {

View file

@ -16,7 +16,6 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
/** /**
* {@link Fixture} for {@link Patient}. * {@link Fixture} for {@link Patient}.
*
* @author Dominik Säume * @author Dominik Säume
*/ */
public class PatientFixture implements Fixture<Patient> { public class PatientFixture implements Fixture<Patient> {

View file

@ -18,7 +18,6 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
/** /**
* {@link Fixture} for {@link Treatment}. * {@link Fixture} for {@link Treatment}.
*
* @author Dominik Säume * @author Dominik Säume
*/ */
public class TreatmentFixture implements Fixture<Treatment> { public class TreatmentFixture implements Fixture<Treatment> {

View file

@ -13,7 +13,6 @@ import java.util.Objects;
/** /**
* Controller for the main window of the application, which holds all tabs. * Controller for the main window of the application, which holds all tabs.
*
* @author Bernd Heideman * @author Bernd Heideman
* @author Dominik Säume * @author Dominik Säume
*/ */
@ -37,6 +36,9 @@ public class MainWindowController {
@FXML @FXML
private Tab medicationTab; private Tab medicationTab;
/**
* @implSpec Method that should be called from the outside to initialize the controller.
*/
@FXML @FXML
public void initialize() { public void initialize() {
loadPatientPage(); loadPatientPage();

View file

@ -4,7 +4,7 @@ import javafx.beans.property.SimpleStringProperty;
/** /**
* A simple base model for a {@link Person} that can be extended. * A simple base model for a {@link Person} that can be extended.
* *
* @author Bernd Heideman * @author Bernd Heideman
* @author Dominik Säume * @author Dominik Säume
*/ */

View file

@ -13,11 +13,6 @@ import javafx.scene.control.cell.PropertyValueFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/**
* The controller for viewing all {@link Medication}s.
*
* @author Dominik Säume
*/
public class AllMedicationController { public class AllMedicationController {
@FXML @FXML
private TableView<Medication> tableView; private TableView<Medication> tableView;
@ -39,10 +34,6 @@ public class AllMedicationController {
private final ObservableList<Medication> medications = FXCollections.observableArrayList(); private final ObservableList<Medication> medications = FXCollections.observableArrayList();
private MedicationDao dao; private MedicationDao dao;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() { public void initialize() {
readAllAndShowInTableView(); readAllAndShowInTableView();
@ -50,14 +41,16 @@ public class AllMedicationController {
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name")); this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer")); this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
this.columnIngredient.setCellValueFactory( this.columnIngredient.setCellValueFactory(
cellData -> new SimpleStringProperty( cellData -> {
cellData return new SimpleStringProperty(
.getValue() cellData
.getIngredients() .getValue()
.stream() .getIngredients()
.map(ingredient -> ingredient.getName()) .stream()
.collect(Collectors.joining("\n")) .map(ingredient -> ingredient.getName())
)); .collect(Collectors.joining("\n"))
);
});
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects")); this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod")); this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock")); this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
@ -65,9 +58,6 @@ public class AllMedicationController {
this.tableView.setItems(this.medications); this.tableView.setItems(this.medications);
} }
/**
* Internal method to read all data and set it to the table view.
*/
public void readAllAndShowInTableView() { public void readAllAndShowInTableView() {
this.dao = DaoFactory.getInstance().createMedicationDAO(); this.dao = DaoFactory.getInstance().createMedicationDAO();
try { try {

View file

@ -17,12 +17,6 @@ import javafx.scene.control.cell.TextFieldTableCell;
import java.sql.SQLException; import java.sql.SQLException;
/**
* The controller for viewing all {@link Nurse}s.
*
* @author Dominik Säume
* @author Ole Kück
*/
public class AllNurseController { public class AllNurseController {
@FXML @FXML
public TextField textFieldSurName; public TextField textFieldSurName;
@ -46,10 +40,6 @@ public class AllNurseController {
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList(); private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
private NurseDao dao; private NurseDao dao;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() { public void initialize() {
this.readAllAndShowInTableView(); this.readAllAndShowInTableView();
@ -82,28 +72,15 @@ public class AllNurseController {
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener); this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
} }
/**
* Internal method to read all data and set it to the table view.
*/
private void readAllAndShowInTableView(){ private void readAllAndShowInTableView(){
this.nurses.clear(); this.nurses.clear();
this.dao = DaoFactory.getInstance().createNurseDAO(); this.dao = DaoFactory.getInstance().createNurseDAO();
try { try {
this.nurses.setAll(this.dao.readAll()); this.nurses.addAll(this.dao.readAll());
}catch (SQLException exception){ }catch (SQLException exception){
exception.printStackTrace(); exception.printStackTrace();
} }
} }
/**
* Internal method that clears the text fields used for creating a new {@link Nurse}.
*/
private void clearTextfields() {
this.textFieldFirstName.clear();
this.textFieldSurName.clear();
this.textFieldPhoneNumber.clear();
}
@FXML @FXML
public void handleAdd(){ public void handleAdd(){
String surname=this.textFieldSurName.getText(); String surname=this.textFieldSurName.getText();
@ -119,5 +96,10 @@ public class AllNurseController {
clearTextfields(); clearTextfields();
} }
private void clearTextfields() {
this.textFieldFirstName.clear();
this.textFieldSurName.clear();
this.textFieldPhoneNumber.clear();
}
} }

View file

@ -18,7 +18,7 @@ public class Nurse extends Person {
/** /**
* This constructor allows instantiating a {@link Nurse} object, * This constructor allows instantiating a {@link Nurse} object,
* before it is stored in the database, by omitting the {@link Nurse#id ID} value. * before it is stored in the database, by omitting the {@link Nurse#id ID} value.
* *
* @implSpec Instances created with this constructor can be directly passed to * @implSpec Instances created with this constructor can be directly passed to
* {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}. * {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}.
*/ */

View file

@ -19,13 +19,6 @@ import java.time.LocalDate;
import static de.hitec.nhplus.utils.Validator.*; import static de.hitec.nhplus.utils.Validator.*;
/**
* The controller for viewing all {@link Patient}s.
*
* @author Bernd Heideman
* @author Dominik Säume
* @author Armin Ribic
*/
public class AllPatientController { public class AllPatientController {
@FXML @FXML
@ -60,10 +53,6 @@ public class AllPatientController {
private final ObservableList<Patient> patients = FXCollections.observableArrayList(); private final ObservableList<Patient> patients = FXCollections.observableArrayList();
private PatientDao dao; private PatientDao dao;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() { public void initialize() {
this.readAllAndShowInTableView(); this.readAllAndShowInTableView();
@ -115,41 +104,6 @@ public class AllPatientController {
this.textFieldRoomNumber.textProperty().addListener(inputNewPatientValidationListener); this.textFieldRoomNumber.textProperty().addListener(inputNewPatientValidationListener);
} }
/**
* Internal method to read all data and set it to the table view.
*/
private void readAllAndShowInTableView() {
this.patients.clear();
this.dao = DaoFactory.getInstance().createPatientDAO();
try {
this.patients.setAll(this.dao.readAll());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
/**
* Internal method that stores the changes in the database.
*/
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
try {
this.dao.update(event.getRowValue());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
/**
* Internal method that clears the text fields used for creating a new {@link Patient}.
*/
private void clearTextfields() {
this.textFieldFirstName.clear();
this.textFieldSurName.clear();
this.textFieldDateOfBirth.clear();
this.textFieldCareLevel.clear();
this.textFieldRoomNumber.clear();
}
@FXML @FXML
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) { public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
String newFirstName = event.getNewValue(); String newFirstName = event.getNewValue();
@ -210,6 +164,25 @@ public class AllPatientController {
this.doUpdate(event); this.doUpdate(event);
} }
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
try {
this.dao.update(event.getRowValue());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
private void readAllAndShowInTableView() {
this.patients.clear();
this.dao = DaoFactory.getInstance().createPatientDAO();
try {
this.patients.addAll(this.dao.readAll());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML @FXML
public void handleDelete() { public void handleDelete() {
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem(); Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
@ -239,4 +212,12 @@ public class AllPatientController {
readAllAndShowInTableView(); readAllAndShowInTableView();
clearTextfields(); clearTextfields();
} }
private void clearTextfields() {
this.textFieldFirstName.clear();
this.textFieldSurName.clear();
this.textFieldDateOfBirth.clear();
this.textFieldCareLevel.clear();
this.textFieldRoomNumber.clear();
}
} }

View file

@ -28,7 +28,6 @@ public class Patient extends Person {
/** /**
* This constructor allows instantiating a {@link Patient} object, * This constructor allows instantiating a {@link Patient} object,
* before it is stored in the database, by omitting the {@link Patient#id ID} value. * before it is stored in the database, by omitting the {@link Patient#id ID} value.
*
* @implSpec Instances created with this constructor can be directly passed to * @implSpec Instances created with this constructor can be directly passed to
* {@link de.hitec.nhplus.patient.database.PatientDao#create PatientDao.create}. * {@link de.hitec.nhplus.patient.database.PatientDao#create PatientDao.create}.
*/ */

View file

@ -20,12 +20,6 @@ import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
/**
* The controller for viewing all {@link Treatment}s.
*
* @author Bernd Heideman
* @author Dominik Säume
*/
public class AllTreatmentController { public class AllTreatmentController {
@FXML @FXML
@ -60,10 +54,6 @@ public class AllTreatmentController {
private final ObservableList<String> patientSelection = FXCollections.observableArrayList(); private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
private ArrayList<Patient> patientList; private ArrayList<Patient> patientList;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() { public void initialize() {
readAllAndShowInTableView(); readAllAndShowInTableView();
comboBoxPatientSelection.setItems(patientSelection); comboBoxPatientSelection.setItems(patientSelection);
@ -71,7 +61,7 @@ public class AllTreatmentController {
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id")); this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnPatientName.setCellValueFactory( this.columnPatientName.setCellValueFactory(
cellData -> { cellData -> {
Patient patient = cellData.getValue().getPatient(); Patient patient = cellData.getValue().getPatient();
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName()); return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
} }
@ -93,9 +83,6 @@ public class AllTreatmentController {
this.createComboBoxData(); this.createComboBoxData();
} }
/**
* Internal method to read all data and set it to the table view.
*/
public void readAllAndShowInTableView() { public void readAllAndShowInTableView() {
comboBoxPatientSelection.getSelectionModel().select(0); comboBoxPatientSelection.getSelectionModel().select(0);
this.dao = DaoFactory.getInstance().createTreatmentDao(); this.dao = DaoFactory.getInstance().createTreatmentDao();
@ -106,9 +93,6 @@ public class AllTreatmentController {
} }
} }
/**
* Internal method to create the data set for the combobox that is used for creating a new {@link Treatment}.
*/
private void createComboBoxData() { private void createComboBoxData() {
PatientDao dao = DaoFactory.getInstance().createPatientDAO(); PatientDao dao = DaoFactory.getInstance().createPatientDAO();
try { try {
@ -122,78 +106,6 @@ public class AllTreatmentController {
} }
} }
/**
* Internal method to get the {@link Patient} object by its surname.
*
* @see AllTreatmentController#handleComboBox
* @see AllTreatmentController#handleNewTreatment
*/
private Patient searchInList(String surname) {
for (Patient patient : this.patientList) {
if (patient.getSurName().equals(surname)) {
return patient;
}
}
return null;
}
/**
* Internal method to create a {@link TreatmentModalController TreatmentModal}.
*
* @param treatment The {@link Treatment} which should be edited. Set null to create a new one.
* @param title The Title of the created modal.
* @param patient The {@link Patient} whose {@link Treatment} this is.
*/
public void treatmentWindow(Treatment treatment, String title, Patient patient) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
Stage stage = new Stage();
TreatmentModalController controller = loader.getController();
controller.initialize(
this,
stage,
treatment,
patient
);
stage.setScene(scene);
stage.setTitle(title);
stage.setResizable(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
} catch (IOException exception) {
exception.printStackTrace();
}
}
/**
* Method to create a new {@link Treatment}.
*/
protected void createTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.create(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
/**
* Method to save the changes to a {@link Treatment}.
*/
protected void updateTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.update(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML @FXML
public void handleComboBox() { public void handleComboBox() {
@ -219,6 +131,14 @@ public class AllTreatmentController {
} }
} }
private Patient searchInList(String surname) {
for (Patient patient : this.patientList) {
if (patient.getSurName().equals(surname)) {
return patient;
}
}
return null;
}
@FXML @FXML
public void handleDelete() { public void handleDelete() {
@ -237,7 +157,7 @@ public class AllTreatmentController {
try { try {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem(); String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
Patient patient = searchInList(selectedPatient); Patient patient = searchInList(selectedPatient);
treatmentWindow(null, "NHPlus - Neue Behandlung", patient); newTreatmentWindow(patient);
} catch (NullPointerException exception) { } catch (NullPointerException exception) {
Alert alert = new Alert(Alert.AlertType.INFORMATION); Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information"); alert.setTitle("Information");
@ -254,18 +174,81 @@ public class AllTreatmentController {
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) { if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
int index = this.tableView.getSelectionModel().getSelectedIndex(); int index = this.tableView.getSelectionModel().getSelectedIndex();
Treatment treatment = this.treatments.get(index); Treatment treatment = this.treatments.get(index);
try { treatmentWindow(treatment);
treatmentWindow(
treatment,
"NHPlus - Behandlung",
DaoFactory.getInstance().createPatientDAO().read(
treatment.getPatient().getId()
)
);
} catch (SQLException e) {
throw new RuntimeException(e);
}
} }
}); });
} }
public void newTreatmentWindow(Patient patient) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
Stage stage = new Stage();
TreatmentModalController controller = loader.getController();
controller.initialize(
this,
stage,
null,
patient
);
stage.setScene(scene);
stage.setTitle("NHPlus - Neue Behandlung");
stage.setResizable(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
} catch (IOException exception) {
exception.printStackTrace();
}
}
public void treatmentWindow(Treatment treatment) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
Stage stage = new Stage();
TreatmentModalController controller = loader.getController();
PatientDao pDao = DaoFactory.getInstance().createPatientDAO();
controller.initialize(
this,
stage,
treatment,
pDao.read(treatment.getPatient().getId())
);
stage.setScene(scene);
stage.setTitle("NHPlus - Behandlung");
stage.setResizable(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
} catch (IOException | SQLException exception) {
exception.printStackTrace();
}
}
public void createTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.create(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
public void updateTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.update(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
} }

View file

@ -13,11 +13,6 @@ import java.time.LocalTime;
import static de.hitec.nhplus.utils.Validator.*; import static de.hitec.nhplus.utils.Validator.*;
/**
* The controller for creating and editing a specific {@link Treatment}.
*
* @author Dominik Säume
*/
public class TreatmentModalController { public class TreatmentModalController {
@FXML @FXML
private Label labelFirstName; private Label labelFirstName;
@ -41,10 +36,6 @@ public class TreatmentModalController {
private Treatment treatment; private Treatment treatment;
private boolean isNewTreatment = false; private boolean isNewTreatment = false;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize(AllTreatmentController controller, Stage stage, Treatment treatment, Patient patient) { public void initialize(AllTreatmentController controller, Stage stage, Treatment treatment, Patient patient) {
this.controller = controller; this.controller = controller;
this.stage = stage; this.stage = stage;
@ -105,9 +96,7 @@ public class TreatmentModalController {
}); });
} }
/**
* Internal method to show the data in the view.
*/
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());
@ -147,4 +136,8 @@ public class TreatmentModalController {
public void handleCancel() { public void handleCancel() {
stage.close(); stage.close();
} }
public Treatment getTreatment() {
return treatment;
}
} }

View file

@ -6,7 +6,6 @@ import java.time.format.DateTimeFormatter;
/** /**
* A utility class that holds utility methods for date conversion. * A utility class that holds utility methods for date conversion.
*
* @author Bernd Heideman * @author Bernd Heideman
*/ */
public class DateConverter { public class DateConverter {