Im Rahmen der Veranstaltung "CS3330 - Projektpraktikum MedizinischeInformatik" an der Universität zu Lübeck entstandenes Krankenhausinformationssystem (KIS).
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

236 行
7.7 KiB

  1. package de.uniluebeck.mi.projmi6.controller;
  2. /**
  3. * Created by Johannes on 12.11.15.
  4. */
  5. import de.uniluebeck.mi.projmi6.db.DBHandler;
  6. import de.uniluebeck.mi.projmi6.model.Patient;
  7. import de.uniluebeck.mi.projmi6.model.Station;
  8. import de.uniluebeck.mi.projmi6.model.StationsUebersichtsItem;
  9. import javafx.beans.binding.Bindings;
  10. import javafx.beans.binding.ObjectBinding;
  11. import javafx.beans.property.ObjectProperty;
  12. import javafx.beans.property.ReadOnlyObjectProperty;
  13. import javafx.beans.property.SimpleObjectProperty;
  14. import javafx.collections.FXCollections;
  15. import javafx.collections.ObservableList;
  16. import javafx.fxml.FXML;
  17. import javafx.fxml.FXMLLoader;
  18. import javafx.scene.Parent;
  19. import javafx.scene.Scene;
  20. import javafx.scene.control.*;
  21. import javafx.scene.control.cell.PropertyValueFactory;
  22. import javafx.scene.image.Image;
  23. import javafx.stage.Modality;
  24. import javafx.stage.Stage;
  25. import java.io.IOException;
  26. import java.rmi.server.ExportException;
  27. import java.sql.SQLException;
  28. import java.time.LocalDate;
  29. /**
  30. * Controller class.
  31. */
  32. public class PatientTablesController{
  33. private MainController mainController;
  34. @FXML
  35. private Label lblTablePatientEmpty;
  36. @FXML
  37. private Label lblTableStationEmpty;
  38. @FXML
  39. private Button btnPatCreate;
  40. @FXML
  41. private Button btnPatEdit;
  42. @FXML
  43. private TableView<Patient> tblPatientOverview;
  44. @FXML
  45. private TableColumn<Patient, String> colPatPatId;
  46. @FXML
  47. private TableColumn<Patient, String> colPatGeburtsname;
  48. @FXML
  49. private TableColumn<Patient, String> colPatNachname;
  50. @FXML
  51. private TableColumn<Patient, String> colPatVorname;
  52. @FXML
  53. private TableColumn<Patient, LocalDate> colPatGebDatum;
  54. @FXML
  55. private TableColumn<Patient, String> colPatStrasse;
  56. @FXML
  57. private TableColumn<Patient, String> colPatPlz;
  58. @FXML
  59. private TableColumn<Patient, String> colPatOrt;
  60. @FXML
  61. private TableColumn<Patient, String> colPatCave;
  62. @FXML
  63. private ToggleButton btnEntlassenePatientenZeigen;
  64. @FXML
  65. private ComboBox<Station> cmbStationenFilter;
  66. @FXML
  67. private TableView<StationsUebersichtsItem> tblStationOverview;
  68. @FXML
  69. private TableColumn<StationsUebersichtsItem, String> colStatPatId;
  70. @FXML
  71. private TableColumn<StationsUebersichtsItem, String> colStatFullName;
  72. @FXML
  73. private TableColumn<StationsUebersichtsItem, String> colStatGebDatum;
  74. @FXML
  75. private TableColumn<StationsUebersichtsItem, String> colStatAlter;
  76. @FXML
  77. private TableColumn<StationsUebersichtsItem, String> colStatAufnahmedatum;
  78. @FXML
  79. private TableColumn<StationsUebersichtsItem, String> colStatEntlassungsdatum;
  80. @FXML
  81. private Tab stationOverviewTab, patientOverviewTab;
  82. @FXML
  83. private TabPane patientOverviewTabPane;
  84. public PatientTablesController(MainController mainController){
  85. this.mainController = mainController;
  86. }
  87. @FXML
  88. public void initialize() {
  89. btnPatEdit.disableProperty().bind(tblPatientOverview.getSelectionModel().selectedItemProperty().isNull());
  90. tblPatientOverview.setRowFactory(tableView -> {
  91. TableRow<Patient> tableRow = new TableRow<>();
  92. tableRow.setOnMouseClicked(event -> {
  93. if(event.getClickCount()==2 && (!tableRow.isEmpty())){
  94. Patient patient = tableRow.getItem();
  95. showEditWindow(patient);
  96. }
  97. });
  98. return tableRow;
  99. });
  100. lblTablePatientEmpty.setText("Liste ist leer.");
  101. lblTableStationEmpty.setText("Daten werden geladen...");
  102. cmbStationenFilter.itemsProperty().bind(mainController.stationenProperty());
  103. ObservableList<Patient> patientList = null;
  104. try {
  105. patientList = FXCollections.<Patient>observableArrayList(DBHandler.getAllPatients());
  106. } catch (SQLException e) {
  107. e.printStackTrace();
  108. }
  109. tblPatientOverview.setItems(patientList);
  110. initColumnsPatient();
  111. initColumnsStation();
  112. }
  113. private void initColumnsPatient(){
  114. colPatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIDProperty().asString());
  115. colPatGeburtsname.setCellValueFactory(new PropertyValueFactory<>("geburtsname"));
  116. colPatNachname.setCellValueFactory(new PropertyValueFactory<>("nachname"));
  117. colPatVorname.setCellValueFactory(new PropertyValueFactory<>("vorname"));
  118. colPatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().geburtsdatumProperty());
  119. colPatStrasse.setCellValueFactory(cellDataFeatures -> {
  120. Patient patient = cellDataFeatures.getValue();
  121. return Bindings.concat(patient.strasseProperty(), " ", patient.hausnummerProperty());
  122. });
  123. colPatPlz.setCellValueFactory(new PropertyValueFactory<>("plz"));
  124. colPatOrt.setCellValueFactory(new PropertyValueFactory<>("ort"));
  125. colPatCave.setCellValueFactory(new PropertyValueFactory<>("cave"));
  126. }
  127. private void initColumnsStation(){
  128. colStatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIdProperty().asString());
  129. colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty());
  130. colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty().asString());
  131. colStatAlter.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patAgeProperty().asString());
  132. colStatAufnahmedatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationAufnahmeProperty().asString());
  133. colStatEntlassungsdatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationEntlassungProperty().asString());
  134. }
  135. @FXML
  136. private void clickedCreatePatient (){
  137. showEditWindow(null);
  138. }
  139. @FXML
  140. private void clickedEditPatient(){
  141. showEditWindow(tblPatientOverview.getSelectionModel().getSelectedItem());
  142. }
  143. private void showEditWindow(Patient patient){
  144. FXMLLoader fxmlLoader = new FXMLLoader();
  145. fxmlLoader.setLocation(getClass().getClassLoader().getResource("patient_edit.fxml"));
  146. PatientEditorController patientEditorController = new PatientEditorController(mainController);
  147. fxmlLoader.setControllerFactory(clazz -> patientEditorController);
  148. Parent root = null;
  149. try{
  150. root = fxmlLoader.load();
  151. }catch (IOException e){
  152. e.printStackTrace();
  153. return;
  154. }
  155. Stage stage = new Stage();
  156. stage.setTitle(patient==null ? "Neuen Patienten erstellen": "Patient bearbeiten");
  157. stage.setScene(new Scene(root, 600, 600));
  158. stage.getIcons().add(new Image("icon.png"));
  159. stage.initModality(Modality.WINDOW_MODAL);
  160. stage.initOwner(btnPatEdit.getScene().getWindow());
  161. patientEditorController.setPatient(patient);
  162. stage.show();
  163. }
  164. public ObjectBinding<Patient> selectedPatientProperty(){
  165. return Bindings.<Patient>createObjectBinding(() ->{
  166. return patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab)
  167. ? tblPatientOverview.getSelectionModel().getSelectedItem()
  168. : null; //(Patient)tblStationOverview.getSelectionModel().getSelectedItem(); //TODO
  169. }, tblPatientOverview.getSelectionModel().selectedItemProperty(),
  170. tblStationOverview.getSelectionModel().selectedItemProperty(),
  171. patientOverviewTabPane.getSelectionModel().selectedItemProperty());
  172. }
  173. public Patient getSelectedPatient(){
  174. return selectedPatientProperty().get();
  175. }
  176. }