first
This commit is contained in:
48
src/main/java/de/hitec/nhplus/Main.java
Normal file
48
src/main/java/de/hitec/nhplus/Main.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package de.hitec.nhplus;
|
||||
|
||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main extends Application {
|
||||
|
||||
private Stage primaryStage;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
this.primaryStage = primaryStage;
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
public void mainWindow() {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/MainWindowView.fxml"));
|
||||
BorderPane pane = loader.load();
|
||||
|
||||
Scene scene = new Scene(pane);
|
||||
this.primaryStage.setTitle("NHPlus");
|
||||
this.primaryStage.setScene(scene);
|
||||
this.primaryStage.setResizable(false);
|
||||
this.primaryStage.show();
|
||||
|
||||
this.primaryStage.setOnCloseRequest(event -> {
|
||||
ConnectionBuilder.closeConnection();
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
});
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.PatientDao;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>AllPatientController</code> contains the entire logic of the patient view. It determines which data is displayed and how to react to events.
|
||||
*/
|
||||
public class AllPatientController {
|
||||
|
||||
@FXML
|
||||
private TableView<Patient> tableView;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, Integer> columnId;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnFirstName;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnSurname;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnDateOfBirth;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnCareLevel;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnRoomNumber;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Patient, String> columnAssets;
|
||||
|
||||
@FXML
|
||||
private Button buttonDelete;
|
||||
|
||||
@FXML
|
||||
private Button buttonAdd;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldSurname;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldFirstName;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldDateOfBirth;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldCareLevel;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldRoomNumber;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldAssets;
|
||||
|
||||
private final ObservableList<Patient> patients = FXCollections.observableArrayList();
|
||||
private PatientDao dao;
|
||||
|
||||
/**
|
||||
* When <code>initialize()</code> gets called, all fields are already initialized. For example from the FXMLLoader
|
||||
* after loading an FXML-File. At this point of the lifecycle of the Controller, the fields can be accessed and
|
||||
* configured.
|
||||
*/
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("pid"));
|
||||
|
||||
// CellValueFactory to show property values in TableView
|
||||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||
// CellFactory to write property values from with in the TableView
|
||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnDateOfBirth.setCellValueFactory(new PropertyValueFactory<>("dateOfBirth"));
|
||||
this.columnDateOfBirth.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnCareLevel.setCellValueFactory(new PropertyValueFactory<>("careLevel"));
|
||||
this.columnCareLevel.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnRoomNumber.setCellValueFactory(new PropertyValueFactory<>("roomNumber"));
|
||||
this.columnRoomNumber.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnAssets.setCellValueFactory(new PropertyValueFactory<>("assets"));
|
||||
this.columnAssets.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
//Anzeigen der Daten
|
||||
this.tableView.setItems(this.patients);
|
||||
|
||||
this.buttonDelete.setDisable(true);
|
||||
this.tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Patient>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Patient> observableValue, Patient oldPatient, Patient newPatient) {;
|
||||
AllPatientController.this.buttonDelete.setDisable(newPatient == null);
|
||||
}
|
||||
});
|
||||
|
||||
this.buttonAdd.setDisable(true);
|
||||
ChangeListener<String> inputNewPatientListener = (observableValue, oldText, newText) ->
|
||||
AllPatientController.this.buttonAdd.setDisable(!AllPatientController.this.areInputDataValid());
|
||||
this.textFieldSurname.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldFirstName.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldDateOfBirth.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldCareLevel.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldRoomNumber.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldAssets.textProperty().addListener(inputNewPatientListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cell of the column with first names was changed, this method will be called, to persist the change.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
@FXML
|
||||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
event.getRowValue().setFirstName(event.getNewValue());
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cell of the column with surnames was changed, this method will be called, to persist the change.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
@FXML
|
||||
public void handleOnEditSurname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
event.getRowValue().setSurname(event.getNewValue());
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cell of the column with dates of birth was changed, this method will be called, to persist the change.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
@FXML
|
||||
public void handleOnEditDateOfBirth(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
event.getRowValue().setDateOfBirth(event.getNewValue());
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cell of the column with care levels was changed, this method will be called, to persist the change.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
@FXML
|
||||
public void handleOnEditCareLevel(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
event.getRowValue().setCareLevel(event.getNewValue());
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cell of the column with room numbers was changed, this method will be called, to persist the change.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
@FXML
|
||||
public void handleOnEditRoomNumber(TableColumn.CellEditEvent<Patient, String> event){
|
||||
event.getRowValue().setRoomNumber(event.getNewValue());
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a cell of the column with assets was changed, this method will be called, to persist the change.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
@FXML
|
||||
public void handleOnEditAssets(TableColumn.CellEditEvent<Patient, String> event){
|
||||
event.getRowValue().setAssets(event.getNewValue());
|
||||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a patient by calling the method <code>update()</code> of {@link PatientDao}.
|
||||
*
|
||||
* @param event Event including the changed object and the change.
|
||||
*/
|
||||
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
try {
|
||||
this.dao.update(event.getRowValue());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads all patients to the table by clearing the list of all patients and filling it again by all persisted
|
||||
* patients, delivered by {@link PatientDao}.
|
||||
*/
|
||||
private void readAllAndShowInTableView() {
|
||||
this.patients.clear();
|
||||
this.dao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||
try {
|
||||
this.patients.addAll(this.dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method handles events fired by the button to delete patients. It calls {@link PatientDao} to delete the
|
||||
* patient from the database and removes the object from the list, which is the data source of the
|
||||
* <code>TableView</code>.
|
||||
*/
|
||||
@FXML
|
||||
public void handleDelete() {
|
||||
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null) {
|
||||
try {
|
||||
DaoFactory.getDaoFactory().createPatientDAO().deleteById(selectedItem.getPid());
|
||||
this.tableView.getItems().remove(selectedItem);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method handles the events fired by the button to add a patient. It collects the data from the
|
||||
* <code>TextField</code>s, creates an object of class <code>Patient</code> of it and passes the object to
|
||||
* {@link PatientDao} to persist the data.
|
||||
*/
|
||||
@FXML
|
||||
public void handleAdd() {
|
||||
String surname = this.textFieldSurname.getText();
|
||||
String firstName = this.textFieldFirstName.getText();
|
||||
String birthday = this.textFieldDateOfBirth.getText();
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(birthday);
|
||||
String careLevel = this.textFieldCareLevel.getText();
|
||||
String roomNumber = this.textFieldRoomNumber.getText();
|
||||
String assets = this.textFieldAssets.getText();
|
||||
try {
|
||||
this.dao.create(new Patient(firstName, surname, date, careLevel, roomNumber, assets));
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
readAllAndShowInTableView();
|
||||
clearTextfields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all contents from all <code>TextField</code>s.
|
||||
*/
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurname.clear();
|
||||
this.textFieldDateOfBirth.clear();
|
||||
this.textFieldCareLevel.clear();
|
||||
this.textFieldRoomNumber.clear();
|
||||
this.textFieldAssets.clear();
|
||||
}
|
||||
|
||||
private boolean areInputDataValid() {
|
||||
if (!this.textFieldDateOfBirth.getText().isBlank()) {
|
||||
try {
|
||||
DateConverter.convertStringToLocalDate(this.textFieldDateOfBirth.getText());
|
||||
} catch (Exception exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !this.textFieldFirstName.getText().isBlank() && !this.textFieldSurname.getText().isBlank() &&
|
||||
!this.textFieldDateOfBirth.getText().isBlank() && !this.textFieldCareLevel.getText().isBlank() &&
|
||||
!this.textFieldRoomNumber.getText().isBlank() && !this.textFieldAssets.getText().isBlank();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.PatientDao;
|
||||
import de.hitec.nhplus.datastorage.TreatmentDao;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.model.Treatment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AllTreatmentController {
|
||||
|
||||
@FXML
|
||||
private TableView<Treatment> tableView;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, Integer> columnId;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, Integer> columnPid;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, String> columnDate;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, String> columnBegin;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, String> columnEnd;
|
||||
|
||||
@FXML
|
||||
private TableColumn<Treatment, String> columnDescription;
|
||||
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxPatientSelection;
|
||||
|
||||
@FXML
|
||||
private Button buttonDelete;
|
||||
|
||||
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
||||
private TreatmentDao dao;
|
||||
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
|
||||
private ArrayList<Patient> patientList;
|
||||
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
comboBoxPatientSelection.setItems(patientSelection);
|
||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("tid"));
|
||||
this.columnPid.setCellValueFactory(new PropertyValueFactory<>("pid"));
|
||||
this.columnDate.setCellValueFactory(new PropertyValueFactory<>("date"));
|
||||
this.columnBegin.setCellValueFactory(new PropertyValueFactory<>("begin"));
|
||||
this.columnEnd.setCellValueFactory(new PropertyValueFactory<>("end"));
|
||||
this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
|
||||
this.tableView.setItems(this.treatments);
|
||||
|
||||
// Disabling the button to delete treatments as long, as no treatment was selected.
|
||||
this.buttonDelete.setDisable(true);
|
||||
this.tableView.getSelectionModel().selectedItemProperty().addListener(
|
||||
(observableValue, oldTreatment, newTreatment) ->
|
||||
AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null));
|
||||
|
||||
this.createComboBoxData();
|
||||
}
|
||||
|
||||
public void readAllAndShowInTableView() {
|
||||
this.treatments.clear();
|
||||
comboBoxPatientSelection.getSelectionModel().select(0);
|
||||
this.dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
try {
|
||||
this.treatments.addAll(dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createComboBoxData() {
|
||||
PatientDao dao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||
try {
|
||||
patientList = (ArrayList<Patient>) dao.readAll();
|
||||
this.patientSelection.add("alle");
|
||||
for (Patient patient: patientList) {
|
||||
this.patientSelection.add(patient.getSurname());
|
||||
}
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void handleComboBox() {
|
||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||
this.treatments.clear();
|
||||
this.dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
|
||||
if (selectedPatient.equals("alle")) {
|
||||
try {
|
||||
this.treatments.addAll(this.dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Patient patient = searchInList(selectedPatient);
|
||||
if (patient !=null) {
|
||||
try {
|
||||
this.treatments.addAll(this.dao.readTreatmentsByPid(patient.getPid()));
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Patient searchInList(String surname) {
|
||||
for (Patient patient : this.patientList) {
|
||||
if (patient.getSurname().equals(surname)) {
|
||||
return patient;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleDelete() {
|
||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||
Treatment t = this.treatments.remove(index);
|
||||
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
try {
|
||||
dao.deleteById(t.getTid());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleNewTreatment() {
|
||||
try{
|
||||
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
|
||||
Patient patient = searchInList(selectedPatient);
|
||||
newTreatmentWindow(patient);
|
||||
} catch (NullPointerException exception){
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information");
|
||||
alert.setHeaderText("Patient für die Behandlung fehlt!");
|
||||
alert.setContentText("Wählen Sie über die Combobox einen Patienten aus!");
|
||||
alert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleMouseClick() {
|
||||
tableView.setOnMouseClicked(event -> {
|
||||
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
|
||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||
Treatment treatment = this.treatments.get(index);
|
||||
treatmentWindow(treatment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void newTreatmentWindow(Patient patient) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/NewTreatmentView.fxml"));
|
||||
AnchorPane pane = loader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
|
||||
// the primary stage should stay in the background
|
||||
Stage stage = new Stage();
|
||||
|
||||
NewTreatmentController controller = loader.getController();
|
||||
controller.initialize(this, stage, patient);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(false);
|
||||
stage.showAndWait();
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void treatmentWindow(Treatment treatment){
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/TreatmentView.fxml"));
|
||||
AnchorPane pane = loader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
|
||||
// the primary stage should stay in the background
|
||||
Stage stage = new Stage();
|
||||
TreatmentController controller = loader.getController();
|
||||
controller.initializeController(this, stage, treatment);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setResizable(false);
|
||||
stage.showAndWait();
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.Main;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MainWindowController {
|
||||
|
||||
@FXML
|
||||
private BorderPane mainBorderPane;
|
||||
|
||||
@FXML
|
||||
private void handleShowAllPatient(ActionEvent event) {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/AllPatientView.fxml"));
|
||||
try {
|
||||
mainBorderPane.setCenter(loader.load());
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void handleShowAllTreatments(ActionEvent event) {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/AllTreatmentView.fxml"));
|
||||
try {
|
||||
mainBorderPane.setCenter(loader.load());
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.TreatmentDao;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.stage.Stage;
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.model.Treatment;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class NewTreatmentController {
|
||||
|
||||
@FXML
|
||||
private Label labelFirstName;
|
||||
|
||||
@FXML
|
||||
private Label labelSurname;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldBegin;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldEnd;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldDescription;
|
||||
|
||||
@FXML
|
||||
private TextArea textAreaRemarks;
|
||||
|
||||
@FXML
|
||||
private DatePicker datePicker;
|
||||
|
||||
@FXML
|
||||
private Button buttonAdd;
|
||||
|
||||
private AllTreatmentController controller;
|
||||
private Patient patient;
|
||||
private Stage stage;
|
||||
|
||||
public void initialize(AllTreatmentController controller, Stage stage, Patient patient) {
|
||||
this.controller= controller;
|
||||
this.patient = patient;
|
||||
this.stage = stage;
|
||||
|
||||
this.buttonAdd.setDisable(true);
|
||||
ChangeListener<String> inputNewPatientListener = (observableValue, oldText, newText) ->
|
||||
NewTreatmentController.this.buttonAdd.setDisable(NewTreatmentController.this.areInputDataInvalid());
|
||||
this.textFieldBegin.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldEnd.textProperty().addListener(inputNewPatientListener);
|
||||
this.textFieldDescription.textProperty().addListener(inputNewPatientListener);
|
||||
this.textAreaRemarks.textProperty().addListener(inputNewPatientListener);
|
||||
this.datePicker.valueProperty().addListener((observableValue, localDate, t1) -> NewTreatmentController.this.buttonAdd.setDisable(NewTreatmentController.this.areInputDataInvalid()));
|
||||
this.datePicker.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(LocalDate localDate) {
|
||||
return (localDate == null) ? "" : DateConverter.convertLocalDateToString(localDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate fromString(String localDate) {
|
||||
return DateConverter.convertStringToLocalDate(localDate);
|
||||
}
|
||||
});
|
||||
this.showPatientData();
|
||||
}
|
||||
|
||||
private void showPatientData(){
|
||||
this.labelFirstName.setText(patient.getFirstName());
|
||||
this.labelSurname.setText(patient.getSurname());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleAdd(){
|
||||
LocalDate date = this.datePicker.getValue();
|
||||
LocalTime begin = DateConverter.convertStringToLocalTime(textFieldBegin.getText());
|
||||
LocalTime end = DateConverter.convertStringToLocalTime(textFieldEnd.getText());
|
||||
String description = textFieldDescription.getText();
|
||||
String remarks = textAreaRemarks.getText();
|
||||
Treatment treatment = new Treatment(patient.getPid(), date, begin, end, description, remarks);
|
||||
createTreatment(treatment);
|
||||
controller.readAllAndShowInTableView();
|
||||
stage.close();
|
||||
}
|
||||
|
||||
private void createTreatment(Treatment treatment) {
|
||||
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
try {
|
||||
dao.create(treatment);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleCancel(){
|
||||
stage.close();
|
||||
}
|
||||
|
||||
private boolean areInputDataInvalid() {
|
||||
if (this.textFieldBegin.getText() == null || this.textFieldEnd.getText() == null) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
LocalTime begin = DateConverter.convertStringToLocalTime(this.textFieldBegin.getText());
|
||||
LocalTime end = DateConverter.convertStringToLocalTime(this.textFieldEnd.getText());
|
||||
if (!end.isAfter(begin)) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
return true;
|
||||
}
|
||||
return this.textFieldDescription.getText().isBlank() || this.datePicker.getValue() == null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package de.hitec.nhplus.controller;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.PatientDao;
|
||||
import de.hitec.nhplus.datastorage.TreatmentDao;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.stage.Stage;
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.model.Treatment;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class TreatmentController {
|
||||
|
||||
@FXML
|
||||
private Label labelPatientName;
|
||||
|
||||
@FXML
|
||||
private Label labelCareLevel;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldBegin;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldEnd;
|
||||
|
||||
@FXML
|
||||
private TextField textFieldDescription;
|
||||
|
||||
@FXML
|
||||
private TextArea textAreaRemarks;
|
||||
|
||||
@FXML
|
||||
private DatePicker datePicker;
|
||||
|
||||
private AllTreatmentController controller;
|
||||
private Stage stage;
|
||||
private Patient patient;
|
||||
private Treatment treatment;
|
||||
|
||||
public void initializeController(AllTreatmentController controller, Stage stage, Treatment treatment) {
|
||||
this.stage = stage;
|
||||
this.controller= controller;
|
||||
PatientDao pDao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||
try {
|
||||
this.patient = pDao.read((int) treatment.getPid());
|
||||
this.treatment = treatment;
|
||||
showData();
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void showData(){
|
||||
this.labelPatientName.setText(patient.getSurname()+", "+patient.getFirstName());
|
||||
this.labelCareLevel.setText(patient.getCareLevel());
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
|
||||
this.datePicker.setValue(date);
|
||||
this.textFieldBegin.setText(this.treatment.getBegin());
|
||||
this.textFieldEnd.setText(this.treatment.getEnd());
|
||||
this.textFieldDescription.setText(this.treatment.getDescription());
|
||||
this.textAreaRemarks.setText(this.treatment.getRemarks());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleChange(){
|
||||
this.treatment.setDate(this.datePicker.getValue().toString());
|
||||
this.treatment.setBegin(textFieldBegin.getText());
|
||||
this.treatment.setEnd(textFieldEnd.getText());
|
||||
this.treatment.setDescription(textFieldDescription.getText());
|
||||
this.treatment.setRemarks(textAreaRemarks.getText());
|
||||
doUpdate();
|
||||
controller.readAllAndShowInTableView();
|
||||
stage.close();
|
||||
}
|
||||
|
||||
private void doUpdate(){
|
||||
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
try {
|
||||
dao.update(treatment);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleCancel(){
|
||||
stage.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.sqlite.SQLiteConfig;
|
||||
|
||||
public class ConnectionBuilder {
|
||||
|
||||
private static final String DB_NAME = "nursingHome.db";
|
||||
private static final String URL = "jdbc:sqlite:db/" + DB_NAME;
|
||||
|
||||
private static Connection connection;
|
||||
|
||||
synchronized public static Connection getConnection() {
|
||||
try {
|
||||
if (ConnectionBuilder.connection == null) {
|
||||
SQLiteConfig configuration = new SQLiteConfig();
|
||||
configuration.enforceForeignKeys(true);
|
||||
ConnectionBuilder.connection = DriverManager.getConnection(URL, configuration.toProperties());
|
||||
}
|
||||
} catch (SQLException exception) {
|
||||
System.out.println("Verbindung zur Datenbank konnte nicht aufgebaut werden!");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return ConnectionBuilder.connection;
|
||||
}
|
||||
|
||||
synchronized public static void closeConnection() {
|
||||
try {
|
||||
if (ConnectionBuilder.connection != null) {
|
||||
ConnectionBuilder.connection.close();
|
||||
ConnectionBuilder.connection = null;
|
||||
}
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/main/java/de/hitec/nhplus/datastorage/Dao.java
Normal file
16
src/main/java/de/hitec/nhplus/datastorage/Dao.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public interface Dao<T> {
|
||||
void create(T t) throws SQLException;
|
||||
|
||||
T read(long key) throws SQLException;
|
||||
|
||||
List<T> readAll() throws SQLException;
|
||||
|
||||
void update(T t) throws SQLException;
|
||||
|
||||
void deleteById(long key) throws SQLException;
|
||||
}
|
||||
24
src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java
Normal file
24
src/main/java/de/hitec/nhplus/datastorage/DaoFactory.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
public class DaoFactory {
|
||||
|
||||
private static DaoFactory instance;
|
||||
|
||||
private DaoFactory() {
|
||||
}
|
||||
|
||||
public static DaoFactory getDaoFactory() {
|
||||
if (DaoFactory.instance == null) {
|
||||
DaoFactory.instance = new DaoFactory();
|
||||
}
|
||||
return DaoFactory.instance;
|
||||
}
|
||||
|
||||
public TreatmentDao createTreatmentDao() {
|
||||
return new TreatmentDao(ConnectionBuilder.getConnection());
|
||||
}
|
||||
|
||||
public PatientDao createPatientDAO() {
|
||||
return new PatientDao(ConnectionBuilder.getConnection());
|
||||
}
|
||||
}
|
||||
57
src/main/java/de/hitec/nhplus/datastorage/DaoImp.java
Normal file
57
src/main/java/de/hitec/nhplus/datastorage/DaoImp.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DaoImp<T> implements Dao<T> {
|
||||
protected Connection connection;
|
||||
|
||||
public DaoImp(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(T t) throws SQLException {
|
||||
getCreateStatement(t).executeUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(long key) throws SQLException {
|
||||
T object = null;
|
||||
ResultSet result = getReadByIDStatement(key).executeQuery();
|
||||
if (result.next()) {
|
||||
object = getInstanceFromResultSet(result);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> readAll() throws SQLException {
|
||||
return getListFromResultSet(getReadAllStatement().executeQuery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(T t) throws SQLException {
|
||||
getUpdateStatement(t).executeUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(long key) throws SQLException {
|
||||
getDeleteStatement(key).executeUpdate();
|
||||
}
|
||||
|
||||
protected abstract T getInstanceFromResultSet(ResultSet set) throws SQLException;
|
||||
|
||||
protected abstract ArrayList<T> getListFromResultSet(ResultSet set) throws SQLException;
|
||||
|
||||
protected abstract PreparedStatement getCreateStatement(T t);
|
||||
|
||||
protected abstract PreparedStatement getReadByIDStatement(long key);
|
||||
|
||||
protected abstract PreparedStatement getReadAllStatement();
|
||||
|
||||
protected abstract PreparedStatement getUpdateStatement(T t);
|
||||
|
||||
protected abstract PreparedStatement getDeleteStatement(long key);
|
||||
}
|
||||
176
src/main/java/de/hitec/nhplus/datastorage/PatientDao.java
Normal file
176
src/main/java/de/hitec/nhplus/datastorage/PatientDao.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Implements the Interface <code>DaoImp</code>. Overrides methods to generate specific <code>PreparedStatements</code>,
|
||||
* to execute the specific SQL Statements.
|
||||
*/
|
||||
public class PatientDao extends DaoImp<Patient> {
|
||||
|
||||
/**
|
||||
* The constructor initiates an object of <code>PatientDao</code> and passes the connection to its super class.
|
||||
*
|
||||
* @param connection Object of <code>Connection</code> to execute the SQL-statements.
|
||||
*/
|
||||
public PatientDao(Connection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to persist the given object of <code>Patient</code>.
|
||||
*
|
||||
* @param patient Object of <code>Patient</code> to persist.
|
||||
* @return <code>PreparedStatement</code> to insert the given patient.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getCreateStatement(Patient patient) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "INSERT INTO patient (firstname, surname, dateOfBirth, carelevel, roomnumber, assets) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setString(1, patient.getFirstName());
|
||||
preparedStatement.setString(2, patient.getSurname());
|
||||
preparedStatement.setString(3, patient.getDateOfBirth());
|
||||
preparedStatement.setString(4, patient.getCareLevel());
|
||||
preparedStatement.setString(5, patient.getRoomNumber());
|
||||
preparedStatement.setString(6, patient.getAssets());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to query a patient by a given patient id (pid).
|
||||
*
|
||||
* @param pid Patient id to query.
|
||||
* @return <code>PreparedStatement</code> to query the patient.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getReadByIDStatement(long pid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM patient WHERE pid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, pid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a <code>ResultSet</code> of one patient to an object of <code>Patient</code>.
|
||||
*
|
||||
* @param result ResultSet with a single row. Columns will be mapped to an object of class <code>Patient</code>.
|
||||
* @return Object of class <code>Patient</code> with the data from the resultSet.
|
||||
*/
|
||||
@Override
|
||||
protected Patient getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||
return new Patient(
|
||||
result.getInt(1),
|
||||
result.getString(2),
|
||||
result.getString(3),
|
||||
DateConverter.convertStringToLocalDate(result.getString(4)),
|
||||
result.getString(5),
|
||||
result.getString(6),
|
||||
result.getString(7));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to query all patients.
|
||||
*
|
||||
* @return <code>PreparedStatement</code> to query all patients.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getReadAllStatement() {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM patient";
|
||||
statement = this.connection.prepareStatement(SQL);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return statement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a <code>ResultSet</code> of all patients to an <code>ArrayList</code> of <code>Patient</code> objects.
|
||||
*
|
||||
* @param result ResultSet with all rows. The Columns will be mapped to objects of class <code>Patient</code>.
|
||||
* @return <code>ArrayList</code> with objects of class <code>Patient</code> of all rows in the
|
||||
* <code>ResultSet</code>.
|
||||
*/
|
||||
@Override
|
||||
protected ArrayList<Patient> getListFromResultSet(ResultSet result) throws SQLException {
|
||||
ArrayList<Patient> list = new ArrayList<>();
|
||||
while (result.next()) {
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(result.getString(4));
|
||||
Patient patient = new Patient(result.getInt(1), result.getString(2),
|
||||
result.getString(3), date,
|
||||
result.getString(5), result.getString(6), result.getString(7));
|
||||
list.add(patient);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to update the given patient, identified
|
||||
* by the id of the patient (pid).
|
||||
*
|
||||
* @param patient Patient object to update.
|
||||
* @return <code>PreparedStatement</code> to update the given patient.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getUpdateStatement(Patient patient) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL =
|
||||
"UPDATE patient SET " +
|
||||
"firstname = ?, " +
|
||||
"surname = ?, " +
|
||||
"dateOfBirth = ?, " +
|
||||
"carelevel = ?, " +
|
||||
"roomnumber = ?, " +
|
||||
"assets = ? " +
|
||||
"WHERE pid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setString(1, patient.getFirstName());
|
||||
preparedStatement.setString(2, patient.getSurname());
|
||||
preparedStatement.setString(3, patient.getDateOfBirth());
|
||||
preparedStatement.setString(4, patient.getCareLevel());
|
||||
preparedStatement.setString(5, patient.getRoomNumber());
|
||||
preparedStatement.setString(6, patient.getAssets());
|
||||
preparedStatement.setLong(7, patient.getPid());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to delete a patient with the given id.
|
||||
*
|
||||
* @param pid Id of the patient to delete.
|
||||
* @return <code>PreparedStatement</code> to delete patient with the given id.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getDeleteStatement(long pid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "DELETE FROM patient WHERE pid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, pid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
}
|
||||
209
src/main/java/de/hitec/nhplus/datastorage/TreatmentDao.java
Normal file
209
src/main/java/de/hitec/nhplus/datastorage/TreatmentDao.java
Normal file
@@ -0,0 +1,209 @@
|
||||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import de.hitec.nhplus.model.Treatment;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implements the Interface <code>DaoImp</code>. Overrides methods to generate specific <code>PreparedStatements</code>,
|
||||
* to execute the specific SQL Statements.
|
||||
*/
|
||||
public class TreatmentDao extends DaoImp<Treatment> {
|
||||
|
||||
/**
|
||||
* The constructor initiates an object of <code>TreatmentDao</code> and passes the connection to its super class.
|
||||
*
|
||||
* @param connection Object of <code>Connection</code> to execute the SQL-statements.
|
||||
*/
|
||||
public TreatmentDao(Connection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to persist the given object of <code>Treatment</code>.
|
||||
*
|
||||
* @param treatment Object of <code>Treatment</code> to persist.
|
||||
* @return <code>PreparedStatement</code> to insert the given patient.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getCreateStatement(Treatment treatment) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "INSERT INTO treatment (pid, treatment_date, begin, end, description, remark) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?)";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, treatment.getPid());
|
||||
preparedStatement.setString(2, treatment.getDate());
|
||||
preparedStatement.setString(3, treatment.getBegin());
|
||||
preparedStatement.setString(4, treatment.getEnd());
|
||||
preparedStatement.setString(5, treatment.getDescription());
|
||||
preparedStatement.setString(6, treatment.getRemarks());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to query a treatment by a given treatment id (tid).
|
||||
*
|
||||
* @param tid Treatment id to query.
|
||||
* @return <code>PreparedStatement</code> to query the treatment.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getReadByIDStatement(long tid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM treatment WHERE tid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, tid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a <code>ResultSet</code> of one treatment to an object of <code>Treatment</code>.
|
||||
*
|
||||
* @param result ResultSet with a single row. Columns will be mapped to an object of class <code>Treatment</code>.
|
||||
* @return Object of class <code>Treatment</code> with the data from the resultSet.
|
||||
*/
|
||||
@Override
|
||||
protected Treatment getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(result.getString(3));
|
||||
LocalTime begin = DateConverter.convertStringToLocalTime(result.getString(4));
|
||||
LocalTime end = DateConverter.convertStringToLocalTime(result.getString(5));
|
||||
return new Treatment(result.getLong(1), result.getLong(2),
|
||||
date, begin, end, result.getString(6), result.getString(7));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to query all treatments.
|
||||
*
|
||||
* @return <code>PreparedStatement</code> to query all treatments.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getReadAllStatement() {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM treatment";
|
||||
statement = this.connection.prepareStatement(SQL);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return statement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a <code>ResultSet</code> of all treatments to an <code>ArrayList</code> with objects of class
|
||||
* <code>Treatment</code>.
|
||||
*
|
||||
* @param result ResultSet with all rows. The columns will be mapped to objects of class <code>Treatment</code>.
|
||||
* @return <code>ArrayList</code> with objects of class <code>Treatment</code> of all rows in the
|
||||
* <code>ResultSet</code>.
|
||||
*/
|
||||
@Override
|
||||
protected ArrayList<Treatment> getListFromResultSet(ResultSet result) throws SQLException {
|
||||
ArrayList<Treatment> list = new ArrayList<Treatment>();
|
||||
while (result.next()) {
|
||||
LocalDate date = DateConverter.convertStringToLocalDate(result.getString(3));
|
||||
LocalTime begin = DateConverter.convertStringToLocalTime(result.getString(4));
|
||||
LocalTime end = DateConverter.convertStringToLocalTime(result.getString(5));
|
||||
Treatment treatment = new Treatment(result.getLong(1), result.getLong(2),
|
||||
date, begin, end, result.getString(6), result.getString(7));
|
||||
list.add(treatment);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to query all treatments of a patient with a given patient id (pid).
|
||||
*
|
||||
* @param pid Patient id to query all treatments referencing this id.
|
||||
* @return <code>PreparedStatement</code> to query all treatments of the given patient id (pid).
|
||||
*/
|
||||
private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(long pid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM treatment WHERE pid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, pid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries all treatments of a given patient id (pid) and maps the results to an <code>ArrayList</code> with
|
||||
* objects of class <code>Treatment</code>.
|
||||
*
|
||||
* @param pid Patient id to query all treatments referencing this id.
|
||||
* @return <code>ArrayList</code> with objects of class <code>Treatment</code> of all rows in the
|
||||
* <code>ResultSet</code>.
|
||||
*/
|
||||
public List<Treatment> readTreatmentsByPid(long pid) throws SQLException {
|
||||
ResultSet result = getReadAllTreatmentsOfOnePatientByPid(pid).executeQuery();
|
||||
return getListFromResultSet(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to update the given treatment, identified
|
||||
* by the id of the treatment (tid).
|
||||
*
|
||||
* @param treatment Treatment object to update.
|
||||
* @return <code>PreparedStatement</code> to update the given treatment.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getUpdateStatement(Treatment treatment) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL =
|
||||
"UPDATE treatment SET " +
|
||||
"pid = ?, " +
|
||||
"treatment_date = ?, " +
|
||||
"begin = ?, " +
|
||||
"end = ?, " +
|
||||
"description = ?, " +
|
||||
"remark = ? " +
|
||||
"WHERE tid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, treatment.getPid());
|
||||
preparedStatement.setString(2, treatment.getDate());
|
||||
preparedStatement.setString(3, treatment.getBegin());
|
||||
preparedStatement.setString(4, treatment.getEnd());
|
||||
preparedStatement.setString(5, treatment.getDescription());
|
||||
preparedStatement.setString(6, treatment.getRemarks());
|
||||
preparedStatement.setLong(7, treatment.getTid());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a <code>PreparedStatement</code> to delete a treatment with the given id.
|
||||
*
|
||||
* @param tid Id of the Treatment to delete.
|
||||
* @return <code>PreparedStatement</code> to delete treatment with the given id.
|
||||
*/
|
||||
@Override
|
||||
protected PreparedStatement getDeleteStatement(long tid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL =
|
||||
"DELETE FROM treatment WHERE tid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setLong(1, tid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
}
|
||||
148
src/main/java/de/hitec/nhplus/model/Patient.java
Normal file
148
src/main/java/de/hitec/nhplus/model/Patient.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package de.hitec.nhplus.model;
|
||||
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Patients live in a NURSING home and are treated by nurses.
|
||||
*/
|
||||
public class Patient extends Person {
|
||||
private SimpleLongProperty pid;
|
||||
private final SimpleStringProperty dateOfBirth;
|
||||
private final SimpleStringProperty careLevel;
|
||||
private final SimpleStringProperty roomNumber;
|
||||
private final SimpleStringProperty assets;
|
||||
private final List<Treatment> allTreatments = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor to initiate an object of class <code>Patient</code> with the given parameter. Use this constructor
|
||||
* to initiate objects, which are not persisted yet, because it will not have a patient id (pid).
|
||||
*
|
||||
* @param firstName First name of the patient.
|
||||
* @param surname Last name of the patient.
|
||||
* @param dateOfBirth Date of birth of the patient.
|
||||
* @param careLevel Care level of the patient.
|
||||
* @param roomNumber Room number of the patient.
|
||||
* @param assets Assets of the patient.
|
||||
*/
|
||||
public Patient(String firstName, String surname, LocalDate dateOfBirth, String careLevel, String roomNumber, String assets) {
|
||||
super(firstName, surname);
|
||||
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
||||
this.careLevel = new SimpleStringProperty(careLevel);
|
||||
this.roomNumber = new SimpleStringProperty(roomNumber);
|
||||
this.assets = new SimpleStringProperty(assets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to initiate an object of class <code>Patient</code> with the given parameter. Use this constructor
|
||||
* to initiate objects, which are already persisted and have a patient id (pid).
|
||||
*
|
||||
* @param pid Patient id.
|
||||
* @param firstName First name of the patient.
|
||||
* @param surname Last name of the patient.
|
||||
* @param dateOfBirth Date of birth of the patient.
|
||||
* @param careLevel Care level of the patient.
|
||||
* @param roomNumber Room number of the patient.
|
||||
* @param assets Assets of the patient.
|
||||
*/
|
||||
public Patient(long pid, String firstName, String surname, LocalDate dateOfBirth, String careLevel, String roomNumber, String assets) {
|
||||
super(firstName, surname);
|
||||
this.pid = new SimpleLongProperty(pid);
|
||||
this.dateOfBirth = new SimpleStringProperty(DateConverter.convertLocalDateToString(dateOfBirth));
|
||||
this.careLevel = new SimpleStringProperty(careLevel);
|
||||
this.roomNumber = new SimpleStringProperty(roomNumber);
|
||||
this.assets = new SimpleStringProperty(assets);
|
||||
}
|
||||
|
||||
public long getPid() {
|
||||
return pid.get();
|
||||
}
|
||||
|
||||
public SimpleLongProperty pidProperty() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public String getDateOfBirth() {
|
||||
return dateOfBirth.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty dateOfBirthProperty() {
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given string as new <code>birthOfDate</code>.
|
||||
*
|
||||
* @param dateOfBirth as string in the following format: YYYY-MM-DD.
|
||||
*/
|
||||
public void setDateOfBirth(String dateOfBirth) {
|
||||
this.dateOfBirth.set(dateOfBirth);
|
||||
}
|
||||
|
||||
public String getCareLevel() {
|
||||
return careLevel.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty careLevelProperty() {
|
||||
return careLevel;
|
||||
}
|
||||
|
||||
public void setCareLevel(String careLevel) {
|
||||
this.careLevel.set(careLevel);
|
||||
}
|
||||
|
||||
public String getRoomNumber() {
|
||||
return roomNumber.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty roomNumberProperty() {
|
||||
return roomNumber;
|
||||
}
|
||||
|
||||
|
||||
public void setRoomNumber(String roomNumber) {
|
||||
this.roomNumber.set(roomNumber);
|
||||
}
|
||||
|
||||
public String getAssets() {
|
||||
return assets.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty assetsProperty() {
|
||||
return assets;
|
||||
}
|
||||
|
||||
public void setAssets(String assets) {
|
||||
this.assets.set(assets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a treatment to the list of treatments, if the list does not already contain the treatment.
|
||||
*
|
||||
* @param treatment Treatment to add.
|
||||
* @return False, if the treatment was already part of the list, else true.
|
||||
*/
|
||||
public boolean add(Treatment treatment) {
|
||||
if (this.allTreatments.contains(treatment)) {
|
||||
return false;
|
||||
}
|
||||
this.allTreatments.add(treatment);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Patient" + "\nMNID: " + this.pid +
|
||||
"\nFirstname: " + this.getFirstName() +
|
||||
"\nSurname: " + this.getSurname() +
|
||||
"\nBirthday: " + this.dateOfBirth +
|
||||
"\nCarelevel: " + this.careLevel +
|
||||
"\nRoomnumber: " + this.roomNumber +
|
||||
"\nAssets: " + this.assets +
|
||||
"\n";
|
||||
}
|
||||
}
|
||||
37
src/main/java/de/hitec/nhplus/model/Person.java
Normal file
37
src/main/java/de/hitec/nhplus/model/Person.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package de.hitec.nhplus.model;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public abstract class Person {
|
||||
private final SimpleStringProperty firstName;
|
||||
private final SimpleStringProperty surname;
|
||||
|
||||
public Person(String firstName, String surname) {
|
||||
this.firstName = new SimpleStringProperty(firstName);
|
||||
this.surname = new SimpleStringProperty(surname);
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty firstNameProperty() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName.set(firstName);
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty surnameProperty() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public void setSurname(String surname) {
|
||||
this.surname.set(surname);
|
||||
}
|
||||
}
|
||||
118
src/main/java/de/hitec/nhplus/model/Treatment.java
Normal file
118
src/main/java/de/hitec/nhplus/model/Treatment.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package de.hitec.nhplus.model;
|
||||
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
public class Treatment {
|
||||
private long tid;
|
||||
private final long pid;
|
||||
private LocalDate date;
|
||||
private LocalTime begin;
|
||||
private LocalTime end;
|
||||
private String description;
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* Constructor to initiate an object of class <code>Treatment</code> with the given parameter. Use this constructor
|
||||
* to initiate objects, which are not persisted yet, because it will not have a treatment id (tid).
|
||||
*
|
||||
* @param pid Id of the treated patient.
|
||||
* @param date Date of the Treatment.
|
||||
* @param begin Time of the start of the treatment in format "hh:MM"
|
||||
* @param end Time of the end of the treatment in format "hh:MM".
|
||||
* @param description Description of the treatment.
|
||||
* @param remarks Remarks to the treatment.
|
||||
*/
|
||||
public Treatment(long pid, LocalDate date, LocalTime begin,
|
||||
LocalTime end, String description, String remarks) {
|
||||
this.pid = pid;
|
||||
this.date = date;
|
||||
this.begin = begin;
|
||||
this.end = end;
|
||||
this.description = description;
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to initiate an object of class <code>Treatment</code> with the given parameter. Use this constructor
|
||||
* to initiate objects, which are already persisted and have a treatment id (tid).
|
||||
*
|
||||
* @param tid Id of the treatment.
|
||||
* @param pid Id of the treated patient.
|
||||
* @param date Date of the Treatment.
|
||||
* @param begin Time of the start of the treatment in format "hh:MM"
|
||||
* @param end Time of the end of the treatment in format "hh:MM".
|
||||
* @param description Description of the treatment.
|
||||
* @param remarks Remarks to the treatment.
|
||||
*/
|
||||
public Treatment(long tid, long pid, LocalDate date, LocalTime begin,
|
||||
LocalTime end, String description, String remarks) {
|
||||
this.tid = tid;
|
||||
this.pid = pid;
|
||||
this.date = date;
|
||||
this.begin = begin;
|
||||
this.end = end;
|
||||
this.description = description;
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public long getTid() {
|
||||
return tid;
|
||||
}
|
||||
|
||||
public long getPid() {
|
||||
return this.pid;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date.toString();
|
||||
}
|
||||
|
||||
public String getBegin() {
|
||||
return begin.toString();
|
||||
}
|
||||
|
||||
public String getEnd() {
|
||||
return end.toString();
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = DateConverter.convertStringToLocalDate(date);
|
||||
}
|
||||
|
||||
public void setBegin(String begin) {
|
||||
this.begin = DateConverter.convertStringToLocalTime(begin);;
|
||||
}
|
||||
|
||||
public void setEnd(String end) {
|
||||
this.end = DateConverter.convertStringToLocalTime(end);;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "\nBehandlung" + "\nTID: " + this.tid +
|
||||
"\nPID: " + this.pid +
|
||||
"\nDate: " + this.date +
|
||||
"\nBegin: " + this.begin +
|
||||
"\nEnd: " + this.end +
|
||||
"\nDescription: " + this.description +
|
||||
"\nRemarks: " + this.remarks + "\n";
|
||||
}
|
||||
}
|
||||
27
src/main/java/de/hitec/nhplus/utils/DateConverter.java
Normal file
27
src/main/java/de/hitec/nhplus/utils/DateConverter.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package de.hitec.nhplus.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class DateConverter {
|
||||
|
||||
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||
private static final String TIME_FORMAT = "HH:mm";
|
||||
|
||||
public static LocalDate convertStringToLocalDate(String date) {
|
||||
return LocalDate.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT));
|
||||
}
|
||||
|
||||
public static LocalTime convertStringToLocalTime(String time) {
|
||||
return LocalTime.parse(time, DateTimeFormatter.ofPattern(TIME_FORMAT));
|
||||
}
|
||||
|
||||
public static String convertLocalDateToString(LocalDate date) {
|
||||
return date.format(DateTimeFormatter.ofPattern(DATE_FORMAT));
|
||||
}
|
||||
|
||||
public static String convertLocalTimeToString(LocalTime time) {
|
||||
return time.format(DateTimeFormatter.ofPattern(TIME_FORMAT));
|
||||
}
|
||||
}
|
||||
122
src/main/java/de/hitec/nhplus/utils/SetUpDB.java
Normal file
122
src/main/java/de/hitec/nhplus/utils/SetUpDB.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package de.hitec.nhplus.utils;
|
||||
|
||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.PatientDao;
|
||||
import de.hitec.nhplus.datastorage.TreatmentDao;
|
||||
import de.hitec.nhplus.model.Patient;
|
||||
import de.hitec.nhplus.model.Treatment;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
|
||||
|
||||
/**
|
||||
* Call static class provides to static methods to set up and wipe the database. It uses the class ConnectionBuilder
|
||||
* and its path to build up the connection to the database. The class is executable. Executing the class will build
|
||||
* up a connection to the database and calls setUpDb() to wipe the database, build up a clean database and fill the
|
||||
* database with some test data.
|
||||
*/
|
||||
public class SetUpDB {
|
||||
|
||||
/**
|
||||
* This method wipes the database by dropping the tables. Then the method calls DDL statements to build it up from
|
||||
* scratch and DML statements to fill the database with hard coded test data.
|
||||
*/
|
||||
public static void setUpDb() {
|
||||
Connection connection = ConnectionBuilder.getConnection();
|
||||
SetUpDB.wipeDb(connection);
|
||||
SetUpDB.setUpTablePatient(connection);
|
||||
SetUpDB.setUpTableTreatment(connection);
|
||||
SetUpDB.setUpPatients();
|
||||
SetUpDB.setUpTreatments();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method wipes the database by dropping the tables.
|
||||
*/
|
||||
public static void wipeDb(Connection connection) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("DROP TABLE patient");
|
||||
statement.execute("DROP TABLE treatment");
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setUpTablePatient(Connection connection) {
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS patient (" +
|
||||
" pid INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
" firstname TEXT NOT NULL, " +
|
||||
" surname TEXT NOT NULL, " +
|
||||
" dateOfBirth TEXT NOT NULL, " +
|
||||
" carelevel TEXT NOT NULL, " +
|
||||
" roomnumber TEXT NOT NULL, " +
|
||||
" assets TEXt NOT NULL" +
|
||||
");";
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute(SQL);
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setUpTableTreatment(Connection connection) {
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS treatment (" +
|
||||
" tid INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
" pid INTEGER NOT NULL, " +
|
||||
" treatment_date TEXT NOT NULL, " +
|
||||
" begin TEXT NOT NULL, " +
|
||||
" end TEXT NOT NULL, " +
|
||||
" description TEXT NOT NULL, " +
|
||||
" remark TEXT NOT NULL," +
|
||||
" FOREIGN KEY (pid) REFERENCES patient (pid) ON DELETE CASCADE " +
|
||||
");";
|
||||
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute(SQL);
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void setUpPatients() {
|
||||
try {
|
||||
PatientDao dao = DaoFactory.getDaoFactory().createPatientDAO();
|
||||
dao.create(new Patient("Seppl", "Herberger", convertStringToLocalDate("1945-12-01"), "4", "202", "vermögend"));
|
||||
dao.create(new Patient("Martina", "Gerdsen", convertStringToLocalDate("1954-08-12"), "5", "010", "arm"));
|
||||
dao.create(new Patient("Gertrud", "Franzen", convertStringToLocalDate("1949-04-16"), "3", "002", "normal"));
|
||||
dao.create(new Patient("Ahmet", "Yilmaz", convertStringToLocalDate("1941-02-22"), "3", "013", "normal"));
|
||||
dao.create(new Patient("Hans", "Neumann", convertStringToLocalDate("1955-12-12"), "2", "001", "sehr vermögend"));
|
||||
dao.create(new Patient("Elisabeth", "Müller", convertStringToLocalDate("1958-03-07"), "5", "110", "arm"));
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setUpTreatments() {
|
||||
try {
|
||||
TreatmentDao dao = DaoFactory.getDaoFactory().createTreatmentDao();
|
||||
dao.create(new Treatment(1, 1, convertStringToLocalDate("2023-06-03"), convertStringToLocalTime("11:00"), convertStringToLocalTime("15:00"), "Gespräch", "Der Patient hat enorme Angstgefühle und glaubt, er sei überfallen worden. Ihm seien alle Wertsachen gestohlen worden.\nPatient beruhigt sich erst, als alle Wertsachen im Zimmer gefunden worden sind."));
|
||||
dao.create(new Treatment(2, 1, convertStringToLocalDate("2023-06-05"), convertStringToLocalTime("11:00"), convertStringToLocalTime("12:30"), "Gespräch", "Patient irrt auf der Suche nach gestohlenen Wertsachen durch die Etage und bezichtigt andere Bewohner des Diebstahls.\nPatient wird in seinen Raum zurückbegleitet und erhält Beruhigungsmittel."));
|
||||
dao.create(new Treatment(3, 2, convertStringToLocalDate("2023-06-04"), convertStringToLocalTime("07:30"), convertStringToLocalTime("08:00"), "Waschen", "Patient mit Waschlappen gewaschen und frisch angezogen. Patient gewendet."));
|
||||
dao.create(new Treatment(4, 1, convertStringToLocalDate("2023-06-06"), convertStringToLocalTime("15:10"), convertStringToLocalTime("16:00"), "Spaziergang", "Spaziergang im Park, Patient döst im Rollstuhl ein"));
|
||||
dao.create(new Treatment(8, 1, convertStringToLocalDate("2023-06-08"), convertStringToLocalTime("15:00"), convertStringToLocalTime("16:00"), "Spaziergang", "Parkspaziergang; Patient ist heute lebhafter und hat klare Momente; erzählt von seiner Tochter"));
|
||||
dao.create(new Treatment(9, 2, convertStringToLocalDate("2023-06-07"), convertStringToLocalTime("11:00"), convertStringToLocalTime("11:30"), "Waschen", "Waschen per Dusche auf einem Stuhl; Patientin gewendet;"));
|
||||
dao.create(new Treatment(12, 5, convertStringToLocalDate("2023-06-08"), convertStringToLocalTime("15:00"), convertStringToLocalTime("15:30"), "Physiotherapie", "Übungen zur Stabilisation und Mobilisierung der Rückenmuskulatur"));
|
||||
dao.create(new Treatment(14, 4, convertStringToLocalDate("2023-08-24"), convertStringToLocalTime("09:30"), convertStringToLocalTime("10:15"), "KG", "Lympfdrainage"));
|
||||
dao.create(new Treatment(16, 6, convertStringToLocalDate("2023-08-31"), convertStringToLocalTime("13:30"), convertStringToLocalTime("13:45"), "Toilettengang", "Hilfe beim Toilettengang; Patientin klagt über Schmerzen beim Stuhlgang. Gabe von Iberogast"));
|
||||
dao.create(new Treatment(17, 6, convertStringToLocalDate("2023-09-01"), convertStringToLocalTime("16:00"), convertStringToLocalTime("17:00"), "KG", "Massage der Extremitäten zur Verbesserung der Durchblutung"));
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SetUpDB.setUpDb();
|
||||
}
|
||||
}
|
||||
16
src/main/java/module-info.java
Normal file
16
src/main/java/module-info.java
Normal file
@@ -0,0 +1,16 @@
|
||||
module de.hitec.nhplus {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
requires org.controlsfx.controls;
|
||||
requires java.sql;
|
||||
requires org.xerial.sqlitejdbc;
|
||||
|
||||
opens de.hitec.nhplus to javafx.fxml;
|
||||
opens de.hitec.nhplus.controller to javafx.fxml;
|
||||
opens de.hitec.nhplus.model to javafx.base;
|
||||
|
||||
exports de.hitec.nhplus;
|
||||
exports de.hitec.nhplus.controller;
|
||||
exports de.hitec.nhplus.model;
|
||||
}
|
||||
43
src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml
Normal file
43
src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="colID" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
|
||||
<TableColumn fx:id="colSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname" />
|
||||
<TableColumn fx:id="colFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname" />
|
||||
<TableColumn fx:id="colTelephone" maxWidth="7500.0" prefWidth="75.0" text="Telefon" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname" />
|
||||
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname" />
|
||||
<TextField fx:id="txfTelephone" prefWidth="160.0" promptText="Telefonnummer" />
|
||||
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen" />
|
||||
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
||||
80
src/main/resources/de/hitec/nhplus/AllPatientView.fxml
Normal file
80
src/main/resources/de/hitec/nhplus/AllPatientView.fxml
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.AllPatientController">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="120.0" prefHeight="287.0" prefWidth="825.0" AnchorPane.bottomAnchor="100.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="columnId" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
|
||||
<TableColumn fx:id="columnSurname" maxWidth="7500.0" minWidth="20.0" onEditCommit="#handleOnEditSurname" prefWidth="100.0" text="Nachname" />
|
||||
<TableColumn fx:id="columnFirstName" maxWidth="7500.0" onEditCommit="#handleOnEditFirstname" prefWidth="75.0" text="Vorname" />
|
||||
<TableColumn fx:id="columnDateOfBirth" maxWidth="7500.0" onEditCommit="#handleOnEditDateOfBirth" prefWidth="75.0" text="Geburtstag" />
|
||||
<TableColumn fx:id="columnCareLevel" onEditCommit="#handleOnEditCareLevel" prefWidth="75.0" text="Pflegegrad" />
|
||||
<TableColumn fx:id="columnRoomNumber" onEditCommit="#handleOnEditRoomNumber" prefWidth="75.0" text="Raum" />
|
||||
<TableColumn fx:id="columnAssets" onEditCommit="#handleOnEditAssets" prefWidth="75.0" text="Vermögensstand" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<GridPane hgap="10.0" vgap="10.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" prefWidth="200.0" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="200.0" prefWidth="200.0" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="160.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<TextField fx:id="textFieldSurname" minWidth="200.0" prefHeight="26.0" prefWidth="200.0" promptText="Nachname" GridPane.columnIndex="1" />
|
||||
<TextField fx:id="textFieldFirstName" minWidth="200.0" prefHeight="26.0" prefWidth="200.0" promptText="Vorname" />
|
||||
<TextField fx:id="textFieldDateOfBirth" minWidth="160.0" prefWidth="160.0" promptText="Geburtstag" GridPane.columnIndex="2" />
|
||||
<TextField fx:id="textFieldCareLevel" prefHeight="26.0" prefWidth="200.0" promptText="Pflegegrad" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="textFieldRoomNumber" prefHeight="26.0" prefWidth="200.0" promptText="Raum" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="textFieldAssets" minWidth="160.0" prefWidth="160.0" promptText="Vermögensstand" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets right="10.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
</GridPane>
|
||||
<HBox alignment="TOP_CENTER" prefWidth="190.0" spacing="10.0">
|
||||
<children>
|
||||
<Button fx:id="buttonAdd" mnemonicParsing="false" onAction="#handleAdd" prefWidth="90.0" text="Hinzufügen" />
|
||||
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="90.0" text="Löschen" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Patienten/innen" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
||||
70
src/main/resources/de/hitec/nhplus/AllTreatmentView.fxml
Normal file
70
src/main/resources/de/hitec/nhplus/AllTreatmentView.fxml
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.AllTreatmentController">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="35.0" onMouseClicked="#handleMouseClick" prefHeight="364.0" prefWidth="825.0" AnchorPane.bottomAnchor="75.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="columnId" maxWidth="-1.0" minWidth="40.0" prefWidth="50.0" text="ID" />
|
||||
<TableColumn fx:id="columnPid" maxWidth="-1.0" minWidth="100.0" prefWidth="120.0" text="PatientID" />
|
||||
<TableColumn fx:id="columnDate" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Datum" />
|
||||
<TableColumn fx:id="columnBegin" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Beginn" />
|
||||
<TableColumn fx:id="columnEnd" maxWidth="-1.0" minWidth="140.0" prefWidth="150.0" text="Ende" />
|
||||
<TableColumn fx:id="columnDescription" maxWidth="-1.0" minWidth="200.0" prefWidth="300.0" text="Kurzbeschreibung" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="623.0" layoutY="419.3999938964844" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<GridPane hgap="10.0" vgap="10.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" prefWidth="200.0" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="200.0" prefWidth="200.0" />
|
||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="160.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Button fx:id="buttonNewTreament" mnemonicParsing="false" onAction="#handleNewTreatment" prefWidth="200.0" text="neue Behandlung anlegen" GridPane.columnIndex="1" />
|
||||
<ComboBox fx:id="comboBoxPatientSelection" minWidth="160.0" onAction="#handleComboBox" prefWidth="200.0" />
|
||||
<Button fx:id="buttonDelete" mnemonicParsing="false" onAction="#handleDelete" prefWidth="200.0" text="Löschen" GridPane.columnIndex="2" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets right="10.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
</GridPane>
|
||||
<HBox prefWidth="190.0" spacing="10.0" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="15.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Behandlungen" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
||||
4
src/main/resources/de/hitec/nhplus/Application.css
Normal file
4
src/main/resources/de/hitec/nhplus/Application.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.vBox{
|
||||
-fx-background-color: navy;
|
||||
-fx-border-color: rgb(142, 142, 142);
|
||||
}
|
||||
25
src/main/resources/de/hitec/nhplus/MainWindowView.fxml
Normal file
25
src/main/resources/de/hitec/nhplus/MainWindowView.fxml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<BorderPane fx:id="mainBorderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="688.0" prefWidth="926.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.MainWindowController">
|
||||
<left>
|
||||
<VBox id="vBox" alignment="CENTER" spacing="50.0" styleClass="vBox" stylesheets="@Application.css" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowAllPatient" prefWidth="105.0" text="Patienten/innen">
|
||||
<VBox.margin>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
|
||||
</VBox.margin>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets></Button>
|
||||
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleShowAllTreatments" prefWidth="105.0" text="Behandlungen">
|
||||
<VBox.margin>
|
||||
<Insets bottom="50.0" left="10.0" right="10.0" top="50.0" />
|
||||
</VBox.margin></Button>
|
||||
</children>
|
||||
</VBox>
|
||||
</left>
|
||||
</BorderPane>
|
||||
79
src/main/resources/de/hitec/nhplus/NewTreatmentView.fxml
Normal file
79
src/main/resources/de/hitec/nhplus/NewTreatmentView.fxml
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<AnchorPane prefHeight="450.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.NewTreatmentController">
|
||||
<children>
|
||||
<HBox alignment="TOP_CENTER" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Neue Behandlung" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<GridPane hgap="10.0" layoutX="14.0" layoutY="14.0" AnchorPane.leftAnchor="50.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="100.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Vorname:">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Nachname:" GridPane.columnIndex="2">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Datum:" GridPane.rowIndex="3">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Beginn:" GridPane.columnIndex="2" GridPane.rowIndex="3">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Ende" GridPane.rowIndex="4">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Beschreibung:" GridPane.columnIndex="2" GridPane.rowIndex="4">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextField fx:id="textFieldBegin" promptText="hh:mm" GridPane.columnIndex="3" GridPane.rowIndex="3" />
|
||||
<TextField fx:id="textFieldEnd" maxWidth="192.0" prefWidth="150.0" promptText="hh:mm" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<TextField fx:id="textFieldDescription" GridPane.columnIndex="3" GridPane.rowIndex="4" />
|
||||
<DatePicker fx:id="datePicker" prefWidth="192.0" promptText="yyyy-mm-dd" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<Label fx:id="labelFirstName" text="Vorname" GridPane.columnIndex="1" />
|
||||
<Label fx:id="labelSurname" text="Nachname" GridPane.columnIndex="3" />
|
||||
</children>
|
||||
</GridPane>
|
||||
<HBox layoutX="298.0" layoutY="237.0" spacing="20.0" AnchorPane.bottomAnchor="20.0" AnchorPane.rightAnchor="50.0">
|
||||
<children>
|
||||
<Button fx:id="buttonAdd" mnemonicParsing="false" onAction="#handleAdd" text="Anlegen" />
|
||||
<Button fx:id="buttonCancel" layoutX="298.0" layoutY="237.0" mnemonicParsing="false" onAction="#handleCancel" text="Abbruch" />
|
||||
</children>
|
||||
</HBox>
|
||||
<TextArea fx:id="textAreaRemarks" layoutX="50.0" layoutY="252.0" prefHeight="134.0" prefWidth="700.0" AnchorPane.topAnchor="265.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
87
src/main/resources/de/hitec/nhplus/TreatmentView.fxml
Normal file
87
src/main/resources/de/hitec/nhplus/TreatmentView.fxml
Normal file
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.DatePicker?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane prefHeight="450.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.controller.TreatmentController">
|
||||
<children>
|
||||
<HBox alignment="TOP_CENTER" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Behandlung" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<GridPane hgap="10.0" layoutX="14.0" layoutY="14.0" AnchorPane.leftAnchor="50.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="100.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Patient:">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Pflegestufe:" GridPane.columnIndex="2">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Datum:" GridPane.rowIndex="3">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Beginn:" GridPane.columnIndex="2" GridPane.rowIndex="3">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Ende" GridPane.rowIndex="4">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="Beschreibung:" GridPane.columnIndex="2" GridPane.rowIndex="4">
|
||||
<font>
|
||||
<Font name="System Bold" size="13.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextField fx:id="textFieldBegin" GridPane.columnIndex="3" GridPane.rowIndex="3" />
|
||||
<TextField fx:id="textFieldEnd" maxWidth="192.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<TextField fx:id="textFieldDescription" GridPane.columnIndex="3" GridPane.rowIndex="4" />
|
||||
<DatePicker fx:id="datePicker" prefWidth="192.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<Label fx:id="labelPatientName" text="Name" GridPane.columnIndex="1" />
|
||||
<Label fx:id="labelCareLevel" text="Pflegestufe" GridPane.columnIndex="3" />
|
||||
</children>
|
||||
</GridPane>
|
||||
<HBox layoutX="298.0" layoutY="237.0" spacing="20.0" AnchorPane.bottomAnchor="20.0" AnchorPane.rightAnchor="50.0">
|
||||
<children>
|
||||
<Button fx:id="btnChange" mnemonicParsing="false" onAction="#handleChange" text="Ändern" />
|
||||
<Button fx:id="btnCancel" layoutX="298.0" layoutY="237.0" mnemonicParsing="false" onAction="#handleCancel" text="Abbruch" />
|
||||
</children>
|
||||
</HBox>
|
||||
<TextArea fx:id="textAreaRemarks" layoutX="50.0" layoutY="252.0" prefHeight="134.0" prefWidth="700.0" AnchorPane.topAnchor="265.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
Reference in New Issue
Block a user