| @@ -4,18 +4,12 @@ package de.uniluebeck.mi.projmi6.controller; | |||
| * Created by Johannes on 12.11.15. | |||
| */ | |||
| import ca.uhn.hl7v2.model.v251.segment.LOC; | |||
| import com.sun.deploy.config.Platform; | |||
| import com.sun.org.apache.bcel.internal.generic.LoadClass; | |||
| import de.uniluebeck.mi.projmi6.db.DBHandler; | |||
| import de.uniluebeck.mi.projmi6.model.Patient; | |||
| import de.uniluebeck.mi.projmi6.model.Station; | |||
| import de.uniluebeck.mi.projmi6.model.StationsUebersichtsItem; | |||
| import javafx.beans.binding.Bindings; | |||
| import javafx.beans.binding.ObjectBinding; | |||
| import javafx.beans.property.ObjectProperty; | |||
| import javafx.beans.property.ReadOnlyObjectProperty; | |||
| import javafx.beans.property.SimpleObjectProperty; | |||
| import javafx.collections.FXCollections; | |||
| import javafx.collections.ObservableList; | |||
| import javafx.collections.transformation.FilteredList; | |||
| @@ -31,10 +25,7 @@ import javafx.stage.Modality; | |||
| import javafx.stage.Stage; | |||
| import java.io.IOException; | |||
| import java.rmi.server.ExportException; | |||
| import java.sql.SQLException; | |||
| import java.time.LocalDate; | |||
| import java.time.LocalDateTime; | |||
| import java.util.List; | |||
| /** | |||
| @@ -42,96 +33,78 @@ import java.util.List; | |||
| */ | |||
| public class PatientTablesController { | |||
| @FXML | |||
| Button btnStatRefresh; | |||
| private MainController mainController; | |||
| @FXML | |||
| private Label lblTablePatientEmpty; | |||
| @FXML | |||
| private Label lblTableStationEmpty; | |||
| @FXML | |||
| private Button btnPatCreate; | |||
| @FXML | |||
| private Button btnPatEdit; | |||
| @FXML | |||
| private TableView<Patient> tblPatientOverview; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatPatId; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatGeburtsname; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatNachname; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatVorname; | |||
| @FXML | |||
| private TableColumn<Patient, LocalDate> colPatGebDatum; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatStrasse; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatPlz; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatOrt; | |||
| @FXML | |||
| private TableColumn<Patient, String> colPatCave; | |||
| @FXML | |||
| private ToggleButton btnEntlassenePatientenZeigen; | |||
| @FXML | |||
| private ComboBox<Station> cmbStationenFilter; | |||
| @FXML | |||
| private TableView<StationsUebersichtsItem> tblStationOverview; | |||
| @FXML | |||
| private TableColumn<StationsUebersichtsItem, Integer> colStatPatId; | |||
| @FXML | |||
| private TableColumn<StationsUebersichtsItem, String> colStatFullName; | |||
| @FXML | |||
| private TableColumn<StationsUebersichtsItem, LocalDate> colStatGebDatum; | |||
| @FXML | |||
| private TableColumn<StationsUebersichtsItem, Integer> colStatAlter; | |||
| @FXML | |||
| private TableColumn<StationsUebersichtsItem, LocalDate> colStatAufnahmedatum; | |||
| @FXML | |||
| private TableColumn<StationsUebersichtsItem, LocalDate> colStatEntlassungsdatum; | |||
| @FXML | |||
| private Tab stationOverviewTab; | |||
| public TabPane getPatientOverviewTabPane() { | |||
| return patientOverviewTabPane; | |||
| } | |||
| @FXML | |||
| private Tab patientOverviewTab; | |||
| @FXML | |||
| private TabPane patientOverviewTabPane; | |||
| private ObservableList<StationsUebersichtsItem> stationsUebersicht = FXCollections.observableArrayList(); | |||
| private FilteredList<StationsUebersichtsItem> stationsUebersichtsItemFilteredList = new FilteredList<StationsUebersichtsItem>(stationsUebersicht, | |||
| item -> item.getStationEntlassung() == null || !item.getStationEntlassung().isAfter(LocalDate.now())); | |||
| private Task loadStationsHistorieTask = null; | |||
| private Task loadPatientTask = null; | |||
| @FXML | |||
| private Button btnPatRefresh; | |||
| private ObjectBinding<Patient> patientObjectBinding = null; | |||
| public PatientTablesController(MainController mainController) { | |||
| this.mainController = mainController; | |||
| } | |||
| public TabPane getPatientOverviewTabPane() { | |||
| return patientOverviewTabPane; | |||
| } | |||
| @FXML | |||
| public void initialize() { | |||
| @@ -153,13 +126,13 @@ public class PatientTablesController { | |||
| patientObjectBinding = Bindings.<Patient>createObjectBinding(() -> { | |||
| if(patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab)) { | |||
| if (patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab)) { | |||
| return tblPatientOverview.getSelectionModel().getSelectedItem(); | |||
| }else if(tblStationOverview.getSelectionModel().getSelectedItem()==null){ | |||
| return null; | |||
| }else{ | |||
| } else if (tblStationOverview.getSelectionModel().getSelectedItem() == null) { | |||
| return null; | |||
| } else { | |||
| int selectedPatId = tblStationOverview.getSelectionModel().getSelectedItem().getPatId(); | |||
| Patient selectedPatient = tblPatientOverview.getItems().stream().filter(p -> p.getPatID()==selectedPatId).findFirst().orElse(null); | |||
| Patient selectedPatient = tblPatientOverview.getItems().stream().filter(p -> p.getPatID() == selectedPatId).findFirst().orElse(null); | |||
| return selectedPatient; | |||
| } | |||
| }, tblPatientOverview.getSelectionModel().selectedItemProperty(), | |||
| @@ -173,12 +146,6 @@ public class PatientTablesController { | |||
| updatePatientsFromDb(); | |||
| } | |||
| private ObservableList<StationsUebersichtsItem> stationsUebersicht = FXCollections.observableArrayList(); | |||
| private FilteredList<StationsUebersichtsItem> stationsUebersichtsItemFilteredList = new FilteredList<StationsUebersichtsItem>(stationsUebersicht, | |||
| item -> item.getStationEntlassung() == null || !item.getStationEntlassung().isAfter(LocalDate.now())); | |||
| private void initColumnsPatient() { | |||
| colPatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIDProperty().asString()); | |||
| colPatGeburtsname.setCellValueFactory(new PropertyValueFactory<>("geburtsname")); | |||
| @@ -194,7 +161,6 @@ public class PatientTablesController { | |||
| colPatCave.setCellValueFactory(new PropertyValueFactory<>("cave")); | |||
| } | |||
| private void initColumnsStation() { | |||
| colStatPatId.setCellValueFactory(new PropertyValueFactory<StationsUebersichtsItem, Integer>("patId")); | |||
| colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty()); | |||
| @@ -221,7 +187,6 @@ public class PatientTablesController { | |||
| showEditWindow(null); | |||
| } | |||
| @FXML | |||
| private void clickedEditPatient() { | |||
| showEditWindow(tblPatientOverview.getSelectionModel().getSelectedItem()); | |||
| @@ -254,7 +219,6 @@ public class PatientTablesController { | |||
| stage.show(); | |||
| } | |||
| public void updatePatientsFromDb() { | |||
| if (this.loadPatientTask != null && this.loadPatientTask.isRunning()) { | |||
| System.out.println("Patienten werden bereits geladen."); | |||
| @@ -304,19 +268,13 @@ public class PatientTablesController { | |||
| thread.start(); | |||
| } | |||
| @FXML | |||
| Button btnStatRefresh; | |||
| @FXML | |||
| private void clickedRefreshStation(){ | |||
| private void clickedRefreshStation() { | |||
| updateStationsHistorieFromDb(); | |||
| } | |||
| private Task loadStationsHistorieTask = null; | |||
| public void updateStationsHistorieFromDb() { | |||
| if (this.loadStationsHistorieTask !=null) { | |||
| if (this.loadStationsHistorieTask != null) { | |||
| loadStationsHistorieTask.cancel(); | |||
| } | |||
| lblTableStationEmpty.setText("Liste wird geladen..."); | |||
| @@ -339,7 +297,7 @@ public class PatientTablesController { | |||
| @Override | |||
| protected void succeeded() { | |||
| super.succeeded(); | |||
| if(!isCancelled()) { | |||
| if (!isCancelled()) { | |||
| lblTableStationEmpty.setText("Liste ist leer."); | |||
| stationsUebersicht.setAll(this.getValue()); | |||
| btnStatRefresh.setDisable(false); | |||
| @@ -356,7 +314,7 @@ public class PatientTablesController { | |||
| @Override | |||
| protected void failed() { | |||
| super.failed(); | |||
| if(!isCancelled()){ | |||
| if (!isCancelled()) { | |||
| lblTableStationEmpty.setText("Laden fehlgeschlagen!"); | |||
| getException().printStackTrace(); | |||
| btnStatRefresh.setDisable(false); | |||
| @@ -371,20 +329,11 @@ public class PatientTablesController { | |||
| thread.start(); | |||
| } | |||
| private Task loadPatientTask = null; | |||
| @FXML | |||
| private Button btnPatRefresh; | |||
| @FXML | |||
| private void clickedRefreshPatient() { | |||
| updatePatientsFromDb(); | |||
| } | |||
| private ObjectBinding<Patient> patientObjectBinding = null; | |||
| public ObjectBinding<Patient> selectedPatientProperty() { | |||
| return patientObjectBinding; | |||
| } | |||