Compare commits
No commits in common. "e17f2e44dd429268cadb923bcc71355d143d5bc9" and "817447239fa9fc3e90f79e36da9de3eae9b56236" have entirely different histories.
e17f2e44dd
...
817447239f
14 changed files with 137 additions and 212 deletions
|
@ -15,7 +15,6 @@ import java.util.*;
|
|||
|
||||
/**
|
||||
* {@link Fixture} for {@link Medication}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class MedicationFixture implements Fixture<Medication> {
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.*;
|
|||
|
||||
/**
|
||||
* {@link Fixture} for {@link Nurse}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class NurseFixture implements Fixture<Nurse> {
|
||||
|
|
|
@ -16,7 +16,6 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
|||
|
||||
/**
|
||||
* {@link Fixture} for {@link Patient}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class PatientFixture implements Fixture<Patient> {
|
||||
|
|
|
@ -18,7 +18,6 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
|
|||
|
||||
/**
|
||||
* {@link Fixture} for {@link Treatment}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class TreatmentFixture implements Fixture<Treatment> {
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.util.Objects;
|
|||
|
||||
/**
|
||||
* Controller for the main window of the application, which holds all tabs.
|
||||
*
|
||||
* @author Bernd Heideman
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
|
@ -37,6 +36,9 @@ public class MainWindowController {
|
|||
@FXML
|
||||
private Tab medicationTab;
|
||||
|
||||
/**
|
||||
* @implSpec Method that should be called from the outside to initialize the controller.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
loadPatientPage();
|
||||
|
|
|
@ -4,7 +4,7 @@ import javafx.beans.property.SimpleStringProperty;
|
|||
|
||||
/**
|
||||
* A simple base model for a {@link Person} that can be extended.
|
||||
*
|
||||
*
|
||||
* @author Bernd Heideman
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
|
|
|
@ -13,11 +13,6 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
|||
import java.sql.SQLException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Medication}s.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class AllMedicationController {
|
||||
@FXML
|
||||
private TableView<Medication> tableView;
|
||||
|
@ -39,10 +34,6 @@ public class AllMedicationController {
|
|||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||
private MedicationDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
|
||||
|
@ -50,14 +41,16 @@ public class AllMedicationController {
|
|||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
||||
this.columnIngredient.setCellValueFactory(
|
||||
cellData -> new SimpleStringProperty(
|
||||
cellData
|
||||
.getValue()
|
||||
.getIngredients()
|
||||
.stream()
|
||||
.map(ingredient -> ingredient.getName())
|
||||
.collect(Collectors.joining("\n"))
|
||||
));
|
||||
cellData -> {
|
||||
return new SimpleStringProperty(
|
||||
cellData
|
||||
.getValue()
|
||||
.getIngredients()
|
||||
.stream()
|
||||
.map(ingredient -> ingredient.getName())
|
||||
.collect(Collectors.joining("\n"))
|
||||
);
|
||||
});
|
||||
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
|
||||
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
|
||||
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
||||
|
@ -65,9 +58,6 @@ public class AllMedicationController {
|
|||
this.tableView.setItems(this.medications);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
public void readAllAndShowInTableView() {
|
||||
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
||||
try {
|
||||
|
|
|
@ -17,12 +17,6 @@ import javafx.scene.control.cell.TextFieldTableCell;
|
|||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Nurse}s.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
* @author Ole Kück
|
||||
*/
|
||||
public class AllNurseController {
|
||||
@FXML
|
||||
public TextField textFieldSurName;
|
||||
|
@ -46,10 +40,6 @@ public class AllNurseController {
|
|||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||
private NurseDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
|
@ -82,28 +72,15 @@ public class AllNurseController {
|
|||
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
private void readAllAndShowInTableView(){
|
||||
this.nurses.clear();
|
||||
this.dao = DaoFactory.getInstance().createNurseDAO();
|
||||
try {
|
||||
this.nurses.setAll(this.dao.readAll());
|
||||
this.nurses.addAll(this.dao.readAll());
|
||||
}catch (SQLException exception){
|
||||
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
|
||||
public void handleAdd(){
|
||||
String surname=this.textFieldSurName.getText();
|
||||
|
@ -119,5 +96,10 @@ public class AllNurseController {
|
|||
clearTextfields();
|
||||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldPhoneNumber.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Nurse extends Person {
|
|||
/**
|
||||
* This constructor allows instantiating a {@link Nurse} object,
|
||||
* before it is stored in the database, by omitting the {@link Nurse#id ID} value.
|
||||
*
|
||||
*
|
||||
* @implSpec Instances created with this constructor can be directly passed to
|
||||
* {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}.
|
||||
*/
|
||||
|
|
|
@ -19,13 +19,6 @@ import java.time.LocalDate;
|
|||
|
||||
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 {
|
||||
|
||||
@FXML
|
||||
|
@ -60,10 +53,6 @@ public class AllPatientController {
|
|||
private final ObservableList<Patient> patients = FXCollections.observableArrayList();
|
||||
private PatientDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
|
@ -115,41 +104,6 @@ public class AllPatientController {
|
|||
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
|
||||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newFirstName = event.getNewValue();
|
||||
|
@ -210,6 +164,25 @@ public class AllPatientController {
|
|||
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
|
||||
public void handleDelete() {
|
||||
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
|
@ -239,4 +212,12 @@ public class AllPatientController {
|
|||
readAllAndShowInTableView();
|
||||
clearTextfields();
|
||||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldDateOfBirth.clear();
|
||||
this.textFieldCareLevel.clear();
|
||||
this.textFieldRoomNumber.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ public class Patient extends Person {
|
|||
/**
|
||||
* This constructor allows instantiating a {@link Patient} object,
|
||||
* before it is stored in the database, by omitting the {@link Patient#id ID} value.
|
||||
*
|
||||
* @implSpec Instances created with this constructor can be directly passed to
|
||||
* {@link de.hitec.nhplus.patient.database.PatientDao#create PatientDao.create}.
|
||||
*/
|
||||
|
|
|
@ -20,12 +20,6 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Treatment}s.
|
||||
*
|
||||
* @author Bernd Heideman
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class AllTreatmentController {
|
||||
|
||||
@FXML
|
||||
|
@ -60,10 +54,6 @@ public class AllTreatmentController {
|
|||
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
|
||||
private ArrayList<Patient> patientList;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
comboBoxPatientSelection.setItems(patientSelection);
|
||||
|
@ -71,7 +61,7 @@ public class AllTreatmentController {
|
|||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
this.columnPatientName.setCellValueFactory(
|
||||
cellData -> {
|
||||
cellData -> {
|
||||
Patient patient = cellData.getValue().getPatient();
|
||||
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
|
||||
}
|
||||
|
@ -93,9 +83,6 @@ public class AllTreatmentController {
|
|||
this.createComboBoxData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
public void readAllAndShowInTableView() {
|
||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||
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() {
|
||||
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
|
||||
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
|
||||
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
|
||||
public void handleDelete() {
|
||||
|
@ -237,7 +157,7 @@ public class AllTreatmentController {
|
|||
try {
|
||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||
Patient patient = searchInList(selectedPatient);
|
||||
treatmentWindow(null, "NHPlus - Neue Behandlung", patient);
|
||||
newTreatmentWindow(patient);
|
||||
} catch (NullPointerException exception) {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information");
|
||||
|
@ -254,18 +174,81 @@ public class AllTreatmentController {
|
|||
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
|
||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||
Treatment treatment = this.treatments.get(index);
|
||||
try {
|
||||
treatmentWindow(
|
||||
treatment,
|
||||
"NHPlus - Behandlung",
|
||||
DaoFactory.getInstance().createPatientDAO().read(
|
||||
treatment.getPatient().getId()
|
||||
)
|
||||
);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
treatmentWindow(treatment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,6 @@ import java.time.LocalTime;
|
|||
|
||||
import static de.hitec.nhplus.utils.Validator.*;
|
||||
|
||||
/**
|
||||
* The controller for creating and editing a specific {@link Treatment}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class TreatmentModalController {
|
||||
@FXML
|
||||
private Label labelFirstName;
|
||||
|
@ -41,10 +36,6 @@ public class TreatmentModalController {
|
|||
private Treatment treatment;
|
||||
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) {
|
||||
this.controller = controller;
|
||||
this.stage = stage;
|
||||
|
@ -105,9 +96,7 @@ public class TreatmentModalController {
|
|||
});
|
||||
|
||||
}
|
||||
/**
|
||||
* Internal method to show the data in the view.
|
||||
*/
|
||||
|
||||
private void showData() {
|
||||
this.labelFirstName.setText(patient.getFirstName());
|
||||
this.labelSurName.setText(patient.getSurName());
|
||||
|
@ -147,4 +136,8 @@ public class TreatmentModalController {
|
|||
public void handleCancel() {
|
||||
stage.close();
|
||||
}
|
||||
|
||||
public Treatment getTreatment() {
|
||||
return treatment;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.time.format.DateTimeFormatter;
|
|||
|
||||
/**
|
||||
* A utility class that holds utility methods for date conversion.
|
||||
*
|
||||
* @author Bernd Heideman
|
||||
*/
|
||||
public class DateConverter {
|
||||
|
|
Loading…
Reference in a new issue