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

238 行
7.8 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. patientObjectBinding = Bindings.<Patient>createObjectBinding(() ->{
  110. return patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab)
  111. ? tblPatientOverview.getSelectionModel().getSelectedItem()
  112. : null; //(Patient)tblStationOverview.getSelectionModel().getSelectedItem(); //TODO
  113. }, tblPatientOverview.getSelectionModel().selectedItemProperty(),
  114. tblStationOverview.getSelectionModel().selectedItemProperty(),
  115. patientOverviewTabPane.getSelectionModel().selectedItemProperty());
  116. tblPatientOverview.setItems(patientList);
  117. initColumnsPatient();
  118. initColumnsStation();
  119. }
  120. private void initColumnsPatient(){
  121. colPatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIDProperty().asString());
  122. colPatGeburtsname.setCellValueFactory(new PropertyValueFactory<>("geburtsname"));
  123. colPatNachname.setCellValueFactory(new PropertyValueFactory<>("nachname"));
  124. colPatVorname.setCellValueFactory(new PropertyValueFactory<>("vorname"));
  125. colPatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().geburtsdatumProperty());
  126. colPatStrasse.setCellValueFactory(cellDataFeatures -> {
  127. Patient patient = cellDataFeatures.getValue();
  128. return Bindings.concat(patient.strasseProperty(), " ", patient.hausnummerProperty());
  129. });
  130. colPatPlz.setCellValueFactory(new PropertyValueFactory<>("plz"));
  131. colPatOrt.setCellValueFactory(new PropertyValueFactory<>("ort"));
  132. colPatCave.setCellValueFactory(new PropertyValueFactory<>("cave"));
  133. }
  134. private void initColumnsStation(){
  135. colStatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIdProperty().asString());
  136. colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty());
  137. colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty().asString());
  138. colStatAlter.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patAgeProperty().asString());
  139. colStatAufnahmedatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationAufnahmeProperty().asString());
  140. colStatEntlassungsdatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationEntlassungProperty().asString());
  141. }
  142. @FXML
  143. private void clickedCreatePatient (){
  144. showEditWindow(null);
  145. }
  146. @FXML
  147. private void clickedEditPatient(){
  148. showEditWindow(tblPatientOverview.getSelectionModel().getSelectedItem());
  149. }
  150. private void showEditWindow(Patient patient){
  151. FXMLLoader fxmlLoader = new FXMLLoader();
  152. fxmlLoader.setLocation(getClass().getClassLoader().getResource("patient_edit.fxml"));
  153. PatientEditorController patientEditorController = new PatientEditorController(mainController);
  154. fxmlLoader.setControllerFactory(clazz -> patientEditorController);
  155. Parent root = null;
  156. try{
  157. root = fxmlLoader.load();
  158. }catch (IOException e){
  159. e.printStackTrace();
  160. return;
  161. }
  162. Stage stage = new Stage();
  163. stage.setTitle(patient==null ? "Neuen Patienten erstellen": "Patient bearbeiten");
  164. stage.setScene(new Scene(root, 600, 600));
  165. stage.getIcons().add(new Image("icon.png"));
  166. stage.initModality(Modality.WINDOW_MODAL);
  167. stage.initOwner(btnPatEdit.getScene().getWindow());
  168. patientEditorController.setPatient(patient);
  169. stage.show();
  170. }
  171. private ObjectBinding<Patient> patientObjectBinding = null;
  172. public ObjectBinding<Patient> selectedPatientProperty(){
  173. return patientObjectBinding;
  174. }
  175. public Patient getSelectedPatient(){
  176. return selectedPatientProperty().get();
  177. }
  178. }