task/#17 Treatement -> Nurse Relation #36
4 changed files with 97 additions and 25 deletions
|
@ -2,6 +2,8 @@ package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
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.Patient;
|
||||||
import de.hitec.nhplus.patient.database.PatientDao;
|
import de.hitec.nhplus.patient.database.PatientDao;
|
||||||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||||
|
@ -31,6 +33,9 @@ public class AllTreatmentController {
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Treatment, String> columnPatientName;
|
private TableColumn<Treatment, String> columnPatientName;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TableColumn<Treatment, String> columnNurseName;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Treatment, String> columnDate;
|
private TableColumn<Treatment, String> columnDate;
|
||||||
|
|
||||||
|
@ -46,6 +51,9 @@ public class AllTreatmentController {
|
||||||
@FXML
|
@FXML
|
||||||
private ComboBox<String> comboBoxPatientSelection;
|
private ComboBox<String> comboBoxPatientSelection;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public ComboBox<String> comboBoxNurseSelection;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button buttonDelete;
|
private Button buttonDelete;
|
||||||
|
|
||||||
|
@ -53,11 +61,15 @@ public class AllTreatmentController {
|
||||||
private TreatmentDao dao;
|
private TreatmentDao dao;
|
||||||
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
|
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
|
||||||
private ArrayList<Patient> patientList;
|
private ArrayList<Patient> patientList;
|
||||||
|
private final ObservableList<String> nurseSelection = FXCollections.observableArrayList();
|
||||||
|
private ArrayList<Nurse> nurseList;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
readAllAndShowInTableView();
|
readAllAndShowInTableView();
|
||||||
comboBoxPatientSelection.setItems(patientSelection);
|
comboBoxPatientSelection.setItems(patientSelection);
|
||||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
comboBoxPatientSelection.getSelectionModel().select("alle");
|
||||||
|
|
||||||
|
comboBoxNurseSelection.setItems(nurseSelection);
|
||||||
|
|
||||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
this.columnPatientName.setCellValueFactory(
|
this.columnPatientName.setCellValueFactory(
|
||||||
|
@ -66,6 +78,12 @@ public class AllTreatmentController {
|
||||||
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
|
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.columnDate.setCellValueFactory(new PropertyValueFactory<>("date"));
|
||||||
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
|
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
|
||||||
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
|
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
|
||||||
|
@ -84,7 +102,6 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readAllAndShowInTableView() {
|
public void readAllAndShowInTableView() {
|
||||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
|
||||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
try {
|
try {
|
||||||
this.treatments.setAll(dao.readAll());
|
this.treatments.setAll(dao.readAll());
|
||||||
|
@ -94,13 +111,19 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createComboBoxData() {
|
private void createComboBoxData() {
|
||||||
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
|
PatientDao patientDAO = DaoFactory.getInstance().createPatientDAO();
|
||||||
|
NurseDao nurseDao = DaoFactory.getInstance().createNurseDAO();
|
||||||
try {
|
try {
|
||||||
patientList = (ArrayList<Patient>) dao.readAll();
|
patientList = (ArrayList<Patient>) patientDAO.readAll();
|
||||||
this.patientSelection.add("alle");
|
this.patientSelection.add("alle");
|
||||||
for (Patient patient : patientList) {
|
for (Patient patient : patientList) {
|
||||||
this.patientSelection.add(patient.getSurName());
|
this.patientSelection.add(patient.getSurName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nurseList = (ArrayList<Nurse>) nurseDao.readAll();
|
||||||
|
for (Nurse nurse : nurseList) {
|
||||||
|
this.nurseSelection.add(nurse.getSurName());
|
||||||
|
}
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -108,7 +131,7 @@ public class AllTreatmentController {
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleComboBox() {
|
public void handleComboBoxPatient() {
|
||||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||||
this.treatments.clear();
|
this.treatments.clear();
|
||||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
||||||
|
@ -121,17 +144,17 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Patient patient = searchInList(selectedPatient);
|
Patient patient = searchInPatientList(selectedPatient);
|
||||||
if (patient != null) {
|
if (patient != null) {
|
||||||
try {
|
try {
|
||||||
this.treatments.setAll(this.dao.readTreatmentsByPid(patient.getId()));
|
this.treatments.setAll(this.dao.readTreatmentsByPatient(patient.getId()));
|
||||||
} catch (SQLException exception) {
|
} catch (SQLException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Patient searchInList(String surname) {
|
private Patient searchInPatientList(String surname) {
|
||||||
for (Patient patient : this.patientList) {
|
for (Patient patient : this.patientList) {
|
||||||
if (patient.getSurName().equals(surname)) {
|
if (patient.getSurName().equals(surname)) {
|
||||||
return patient;
|
return patient;
|
||||||
|
@ -140,6 +163,15 @@ public class AllTreatmentController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Nurse searchInNurseList(String surname) {
|
||||||
|
for (Nurse nurse : this.nurseList) {
|
||||||
|
if (nurse.getSurName().equals(surname)) {
|
||||||
|
return nurse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleDelete() {
|
public void handleDelete() {
|
||||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||||
|
@ -156,8 +188,12 @@ public class AllTreatmentController {
|
||||||
public void handleNewTreatment() {
|
public void handleNewTreatment() {
|
||||||
try {
|
try {
|
||||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||||
Patient patient = searchInList(selectedPatient);
|
Patient patient = searchInPatientList(selectedPatient);
|
||||||
newTreatmentWindow(patient);
|
|
||||||
|
String selectedNurse = this.comboBoxNurseSelection.getSelectionModel().getSelectedItem();
|
||||||
|
Nurse nurse = searchInNurseList(selectedNurse);
|
||||||
|
|
||||||
|
newTreatmentWindow(patient, nurse);
|
||||||
} 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,12 +210,12 @@ 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);
|
treatmentWindow(treatment, treatment.getNurse());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void newTreatmentWindow(Patient patient) {
|
public void newTreatmentWindow(Patient patient, Nurse nurse) {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(
|
FXMLLoader loader = new FXMLLoader(
|
||||||
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||||
|
@ -193,7 +229,8 @@ public class AllTreatmentController {
|
||||||
this,
|
this,
|
||||||
stage,
|
stage,
|
||||||
null,
|
null,
|
||||||
patient
|
patient,
|
||||||
|
nurse
|
||||||
);
|
);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
@ -206,7 +243,7 @@ public class AllTreatmentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void treatmentWindow(Treatment treatment) {
|
public void treatmentWindow(Treatment treatment, Nurse nurse) {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(
|
FXMLLoader loader = new FXMLLoader(
|
||||||
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||||
|
@ -221,7 +258,8 @@ public class AllTreatmentController {
|
||||||
this,
|
this,
|
||||||
stage,
|
stage,
|
||||||
treatment,
|
treatment,
|
||||||
pDao.read(treatment.getPatient().getId())
|
pDao.read(treatment.getPatient().getId()),
|
||||||
|
nurse
|
||||||
);
|
);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.hitec.nhplus.treatment;
|
package de.hitec.nhplus.treatment;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.nurse.Nurse;
|
||||||
import de.hitec.nhplus.patient.Patient;
|
import de.hitec.nhplus.patient.Patient;
|
||||||
import de.hitec.nhplus.utils.DateConverter;
|
import de.hitec.nhplus.utils.DateConverter;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
|
@ -14,6 +15,8 @@ import java.time.LocalTime;
|
||||||
import static de.hitec.nhplus.utils.Validator.*;
|
import static de.hitec.nhplus.utils.Validator.*;
|
||||||
|
|
||||||
public class TreatmentModalController {
|
public class TreatmentModalController {
|
||||||
|
@FXML
|
||||||
|
private Label labelNurseName;
|
||||||
@FXML
|
@FXML
|
||||||
private Label labelFirstName;
|
private Label labelFirstName;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -33,18 +36,27 @@ public class TreatmentModalController {
|
||||||
private AllTreatmentController controller;
|
private AllTreatmentController controller;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Patient patient;
|
private Patient patient;
|
||||||
|
private Nurse nurse;
|
||||||
private Treatment treatment;
|
private Treatment treatment;
|
||||||
private boolean isNewTreatment = false;
|
private boolean isNewTreatment = false;
|
||||||
|
|
||||||
public void initialize(AllTreatmentController controller, Stage stage, Treatment treatment, Patient patient) {
|
public void initialize(
|
||||||
|
AllTreatmentController controller,
|
||||||
|
Stage stage,
|
||||||
|
Treatment treatment,
|
||||||
|
Patient patient,
|
||||||
|
Nurse nurse
|
||||||
|
) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.patient = patient;
|
this.patient = patient;
|
||||||
|
this.nurse = nurse;
|
||||||
if (treatment == null) {
|
if (treatment == null) {
|
||||||
isNewTreatment = true;
|
isNewTreatment = true;
|
||||||
LocalTime currentTime = LocalTime.now();
|
LocalTime currentTime = LocalTime.now();
|
||||||
this.treatment = new Treatment(
|
this.treatment = new Treatment(
|
||||||
patient,
|
patient,
|
||||||
|
nurse,
|
||||||
LocalDate.now(),
|
LocalDate.now(),
|
||||||
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
||||||
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
LocalTime.of(currentTime.getHour(), currentTime.getMinute()),
|
||||||
|
@ -98,6 +110,7 @@ public class TreatmentModalController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showData() {
|
private void showData() {
|
||||||
|
this.labelNurseName.setText(nurse.getSurName());
|
||||||
this.labelFirstName.setText(patient.getFirstName());
|
this.labelFirstName.setText(patient.getFirstName());
|
||||||
this.labelSurName.setText(patient.getSurName());
|
this.labelSurName.setText(patient.getSurName());
|
||||||
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
|
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
minWidth="80.0"
|
minWidth="80.0"
|
||||||
text="Patient"
|
text="Patient"
|
||||||
/>
|
/>
|
||||||
|
<TableColumn
|
||||||
|
fx:id="columnNurseName"
|
||||||
|
minWidth="80.0"
|
||||||
|
text="Pflegekraft"
|
||||||
|
/>
|
||||||
<TableColumn
|
<TableColumn
|
||||||
fx:id="columnDate"
|
fx:id="columnDate"
|
||||||
maxWidth="-1.0"
|
maxWidth="-1.0"
|
||||||
|
@ -66,7 +71,11 @@
|
||||||
<ComboBox
|
<ComboBox
|
||||||
fx:id="comboBoxPatientSelection"
|
fx:id="comboBoxPatientSelection"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
onAction="#handleComboBox"
|
onAction="#handleComboBoxPatient"
|
||||||
|
/>
|
||||||
|
<ComboBox
|
||||||
|
fx:id="comboBoxNurseSelection"
|
||||||
|
prefWidth="200.0"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
mnemonicParsing="false"
|
mnemonicParsing="false"
|
||||||
|
|
|
@ -30,21 +30,33 @@
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="0"
|
GridPane.columnIndex="0"
|
||||||
text="Vorname:"
|
text="Pfleger:"
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
prefWidth="200"
|
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"
|
fx:id="labelFirstName" text="Vorname"
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="1"
|
||||||
GridPane.columnIndex="3"
|
GridPane.columnIndex="3"
|
||||||
text="Nachname:"
|
text="Nachname:"
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="1"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
prefWidth="200"
|
prefWidth="200"
|
||||||
fx:id="labelSurName"
|
fx:id="labelSurName"
|
||||||
|
|
Loading…
Reference in a new issue