Compare commits
2 commits
817447239f
...
e17f2e44dd
Author | SHA1 | Date | |
---|---|---|---|
e17f2e44dd | |||
af6ad9de15 |
14 changed files with 212 additions and 137 deletions
|
@ -15,6 +15,7 @@ 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> {
|
||||||
|
|
|
@ -14,6 +14,7 @@ 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> {
|
||||||
|
|
|
@ -16,6 +16,7 @@ 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> {
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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> {
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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
|
||||||
*/
|
*/
|
||||||
|
@ -36,9 +37,6 @@ 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();
|
||||||
|
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,6 +13,11 @@ 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;
|
||||||
|
@ -34,6 +39,10 @@ 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();
|
||||||
|
|
||||||
|
@ -41,16 +50,14 @@ 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 -> {
|
cellData -> new SimpleStringProperty(
|
||||||
return new SimpleStringProperty(
|
cellData
|
||||||
cellData
|
.getValue()
|
||||||
.getValue()
|
.getIngredients()
|
||||||
.getIngredients()
|
.stream()
|
||||||
.stream()
|
.map(ingredient -> ingredient.getName())
|
||||||
.map(ingredient -> ingredient.getName())
|
.collect(Collectors.joining("\n"))
|
||||||
.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"));
|
||||||
|
@ -58,6 +65,9 @@ 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 {
|
||||||
|
|
|
@ -17,6 +17,12 @@ 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;
|
||||||
|
@ -40,6 +46,10 @@ 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();
|
||||||
|
|
||||||
|
@ -72,15 +82,28 @@ 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.addAll(this.dao.readAll());
|
this.nurses.setAll(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();
|
||||||
|
@ -96,10 +119,5 @@ public class AllNurseController {
|
||||||
clearTextfields();
|
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,
|
* 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}.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,6 +19,13 @@ 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
|
||||||
|
@ -53,6 +60,10 @@ 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();
|
||||||
|
|
||||||
|
@ -104,6 +115,41 @@ 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();
|
||||||
|
@ -164,25 +210,6 @@ 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();
|
||||||
|
@ -212,12 +239,4 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ 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}.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,6 +20,12 @@ 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
|
||||||
|
@ -54,6 +60,10 @@ 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);
|
||||||
|
@ -61,7 +71,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());
|
||||||
}
|
}
|
||||||
|
@ -83,6 +93,9 @@ 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();
|
||||||
|
@ -93,6 +106,9 @@ 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 {
|
||||||
|
@ -106,6 +122,78 @@ 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() {
|
||||||
|
@ -131,14 +219,6 @@ 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() {
|
||||||
|
@ -157,7 +237,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);
|
||||||
newTreatmentWindow(patient);
|
treatmentWindow(null, "NHPlus - Neue Behandlung", 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");
|
||||||
|
@ -174,81 +254,18 @@ 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);
|
||||||
treatmentWindow(treatment);
|
try {
|
||||||
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,11 @@ 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;
|
||||||
|
@ -36,6 +41,10 @@ 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;
|
||||||
|
@ -96,7 +105,9 @@ 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());
|
||||||
|
@ -136,8 +147,4 @@ public class TreatmentModalController {
|
||||||
public void handleCancel() {
|
public void handleCancel() {
|
||||||
stage.close();
|
stage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treatment getTreatment() {
|
|
||||||
return treatment;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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 {
|
||||||
|
|
Loading…
Reference in a new issue