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