From 9628f045398c2c05f3d321f231ef041dbe0e23bb Mon Sep 17 00:00:00 2001 From: Johannes Oehm Date: Wed, 18 Nov 2015 11:42:00 +0100 Subject: [PATCH] Vorbereitende Arbeiten am Stationshistoriecontroller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stationsübersicht funktioniert jetzt --- .../mi/projmi6/controller/MainController.java | 2 +- .../controller/PatientTablesController.java | 150 +++++++++++---------- .../controller/StationsHistorieController.java | 122 +++++++++++------ src/main/resources/stationshistorie.fxml | 7 +- 4 files changed, 166 insertions(+), 115 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java index 1f9332a..aebc1b7 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java @@ -264,7 +264,7 @@ public class MainController { protected Void call() throws Exception { untersuchungList = DBHandler.getUntersuchungByFall(newValue); diagnoseList = DBHandler.getDiagnosenByFall(newValue); - //stationsHistorieList = + // stationsHistorieList = DBHandler.getStationsHistorieByStation(""); return null; } diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java index d842fee..20b752e 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java @@ -3,6 +3,7 @@ package de.uniluebeck.mi.projmi6.controller; /** * Created by Johannes on 12.11.15. */ + import ca.uhn.hl7v2.model.v251.segment.LOC; import com.sun.org.apache.bcel.internal.generic.LoadClass; import de.uniluebeck.mi.projmi6.db.DBHandler; @@ -16,6 +17,7 @@ import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.collections.transformation.FilteredList; import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -37,7 +39,7 @@ import java.util.List; /** * Controller class. */ -public class PatientTablesController{ +public class PatientTablesController { private MainController mainController; @@ -84,8 +86,6 @@ public class PatientTablesController{ private TableColumn colPatCave; - - @FXML private ToggleButton btnEntlassenePatientenZeigen; @@ -124,29 +124,26 @@ public class PatientTablesController{ private Tab patientOverviewTab; @FXML - private TabPane patientOverviewTabPane; + private TabPane patientOverviewTabPane; - public PatientTablesController(MainController mainController){ + public PatientTablesController(MainController mainController) { this.mainController = mainController; } - - - @FXML public void initialize() { btnPatEdit.disableProperty().bind(tblPatientOverview.getSelectionModel().selectedItemProperty().isNull()); tblPatientOverview.setRowFactory(tableView -> { TableRow tableRow = new TableRow<>(); tableRow.setOnMouseClicked(event -> { - if(event.getClickCount()==2 && (!tableRow.isEmpty())){ + if (event.getClickCount() == 2 && (!tableRow.isEmpty())) { Patient patient = tableRow.getItem(); showEditWindow(patient); } }); - return tableRow; + return tableRow; }); lblTablePatientEmpty.setText("Liste ist leer."); lblTableStationEmpty.setText("Daten werden geladen..."); @@ -154,7 +151,7 @@ public class PatientTablesController{ cmbStationenFilter.itemsProperty().bind(mainController.getStammdaten().stationenProperty()); - patientObjectBinding = Bindings.createObjectBinding(() ->{ + patientObjectBinding = Bindings.createObjectBinding(() -> { return patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab) ? tblPatientOverview.getSelectionModel().getSelectedItem() : null; //(Patient)tblStationOverview.getSelectionModel().getSelectedItem(); //TODO @@ -162,13 +159,20 @@ public class PatientTablesController{ tblStationOverview.getSelectionModel().selectedItemProperty(), patientOverviewTabPane.getSelectionModel().selectedItemProperty()); + initColumnsPatient(); initColumnsStation(); updatePatientsFromDb(); } - private void initColumnsPatient(){ + + private ObservableList stationsUebersicht = FXCollections.observableArrayList(); + + private FilteredList stationsUebersichtsItemFilteredList = new FilteredList(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")); colPatNachname.setCellValueFactory(new PropertyValueFactory<>("nachname")); @@ -176,7 +180,7 @@ public class PatientTablesController{ colPatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().geburtsdatumProperty()); colPatStrasse.setCellValueFactory(cellDataFeatures -> { Patient patient = cellDataFeatures.getValue(); - return Bindings.concat(patient.strasseProperty(), " ", patient.hausnummerProperty()); + return Bindings.concat(patient.strasseProperty(), " ", patient.hausnummerProperty()); }); colPatPlz.setCellValueFactory(new PropertyValueFactory<>("plz")); colPatOrt.setCellValueFactory(new PropertyValueFactory<>("ort")); @@ -184,7 +188,7 @@ public class PatientTablesController{ } - private void initColumnsStation(){ + private void initColumnsStation() { colStatPatId.setCellValueFactory(new PropertyValueFactory("patId")); colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty()); colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty()); @@ -193,46 +197,52 @@ public class PatientTablesController{ colStatEntlassungsdatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationEntlassungProperty()); - StationsUebersichtsItem stationsUebersichtsItem = new StationsUebersichtsItem(); - stationsUebersichtsItem.setPatId(12212); - stationsUebersichtsItem.setFallId(1223); - stationsUebersichtsItem.setPatAge(80); - stationsUebersichtsItem.setPatBirthdate(LocalDate.of(1935, 9, 22)); - stationsUebersichtsItem.setPatName("Wurst, Hans"); - stationsUebersichtsItem.setStationAufnahme(LocalDate.of(1980, 8, 17)); - stationsUebersichtsItem.setStationEntlassung(LocalDate.of(1981, 2, 1)); - - tblStationOverview.setItems(FXCollections.observableArrayList(stationsUebersichtsItem)); + cmbStationenFilter.valueProperty().addListener((observableValue, oldValue, newValue) -> { + try { + List uebersichtsItems = DBHandler.getStationsUebersichtsItems(newValue.getStation()); + stationsUebersicht.setAll(uebersichtsItems); + System.out.println(uebersichtsItems); + } catch (SQLException e) { + e.printStackTrace(); + } + }); + tblStationOverview.itemsProperty().bind(Bindings.createObjectBinding(() -> { + if (btnEntlassenePatientenZeigen.isSelected()) { + return stationsUebersicht; + } else { + return stationsUebersichtsItemFilteredList; + } + }, btnEntlassenePatientenZeigen.selectedProperty())); } @FXML - private void clickedCreatePatient (){ + private void clickedCreatePatient() { showEditWindow(null); } @FXML - private void clickedEditPatient(){ + private void clickedEditPatient() { showEditWindow(tblPatientOverview.getSelectionModel().getSelectedItem()); } - private void showEditWindow(Patient patient){ + private void showEditWindow(Patient patient) { FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(getClass().getClassLoader().getResource("patient_edit.fxml")); PatientEditorController patientEditorController = new PatientEditorController(mainController); fxmlLoader.setControllerFactory(clazz -> patientEditorController); Parent root = null; - try{ + try { root = fxmlLoader.load(); - }catch (IOException e){ + } catch (IOException e) { e.printStackTrace(); return; } Stage stage = new Stage(); - stage.setTitle(patient==null ? "Neuen Patienten erstellen": "Patient bearbeiten"); + stage.setTitle(patient == null ? "Neuen Patienten erstellen" : "Patient bearbeiten"); stage.setScene(new Scene(root, 600, 600)); stage.getIcons().add(new Image("icon.png")); @@ -244,53 +254,53 @@ public class PatientTablesController{ } - public void updatePatientsFromDb(){ - if(this.loadPatientTask != null && this.loadPatientTask.isRunning()) { - System.out.println("Patienten werden bereits geladen."); - return; - } + public void updatePatientsFromDb() { + if (this.loadPatientTask != null && this.loadPatientTask.isRunning()) { + System.out.println("Patienten werden bereits geladen."); + return; + } - btnPatRefresh.setDisable(true); + btnPatRefresh.setDisable(true); - tblPatientOverview.setItems(null); + tblPatientOverview.setItems(null); - mainController.increaseParallelTaskCount(); + mainController.increaseParallelTaskCount(); - lblTablePatientEmpty.setText("Liste wird geladen..."); + lblTablePatientEmpty.setText("Liste wird geladen..."); - Task>loadPatientsTask = new Task>(){ + Task> loadPatientsTask = new Task>() { - @Override - protected List call() throws Exception { - return FXCollections.observableArrayList(DBHandler.getAllPatients()); - } + @Override + protected List call() throws Exception { + return FXCollections.observableArrayList(DBHandler.getAllPatients()); + } - @Override - protected void succeeded() { - super.succeeded(); - btnPatRefresh.setDisable(false); - lblTablePatientEmpty.setText("Liste ist leer."); - tblPatientOverview.setItems(FXCollections.observableArrayList(this.getValue())); - mainController.decreaseParallelTaskCount(); - } + @Override + protected void succeeded() { + super.succeeded(); + btnPatRefresh.setDisable(false); + lblTablePatientEmpty.setText("Liste ist leer."); + tblPatientOverview.setItems(FXCollections.observableArrayList(this.getValue())); + mainController.decreaseParallelTaskCount(); + } - @Override - protected void failed() { - super.failed(); - btnPatRefresh.setDisable(false); - lblTablePatientEmpty.setText("Laden fehlgeschlagen!"); - mainController.decreaseParallelTaskCount(); - tblPatientOverview.setItems(null); - if(getException()!=null){ - getException().printStackTrace(); - } + @Override + protected void failed() { + super.failed(); + btnPatRefresh.setDisable(false); + lblTablePatientEmpty.setText("Laden fehlgeschlagen!"); + mainController.decreaseParallelTaskCount(); + tblPatientOverview.setItems(null); + if (getException() != null) { + getException().printStackTrace(); } - }; - this.loadPatientTask = loadPatientsTask; + } + }; + this.loadPatientTask = loadPatientsTask; - Thread thread = new Thread(loadPatientsTask); - thread.setDaemon(true); - thread.start(); + Thread thread = new Thread(loadPatientsTask); + thread.setDaemon(true); + thread.start(); } @@ -300,17 +310,17 @@ public class PatientTablesController{ private Button btnPatRefresh; @FXML - private void clickedRefreshPatient(){ + private void clickedRefreshPatient() { updatePatientsFromDb(); } private ObjectBinding patientObjectBinding = null; - public ObjectBinding selectedPatientProperty(){ + public ObjectBinding selectedPatientProperty() { return patientObjectBinding; } - public Patient getSelectedPatient(){ + public Patient getSelectedPatient() { return selectedPatientProperty().get(); } diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java index 86c3c10..faaf0b1 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java @@ -1,14 +1,15 @@ package de.uniluebeck.mi.projmi6.controller; -import de.uniluebeck.mi.projmi6.model.Fall; +import de.uniluebeck.mi.projmi6.model.Station; import de.uniluebeck.mi.projmi6.model.StationsHistorie; -import de.uniluebeck.mi.projmi6.model.Untersuchung; import de.uniluebeck.mi.projmi6.view.DateTimePicker; +import javafx.beans.property.SimpleObjectProperty; +import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; + +import java.time.LocalDate; /** * Created by 631806 on 12.11.15. @@ -18,29 +19,51 @@ public class StationsHistorieController { /** * The station history that is shown in the edit window, or null if a new station history should be created. */ - private StationsHistorie stationsHistorie = null; + private StationsHistorie stationsHistorieSelected = null; private MainController mainController; @FXML - private TableViewtblStationsHistorie; + private TableViewtblStationsHistorie; @FXML private Button btnStatHistCancel, btnStatHistSave; @FXML - private Label statHistCreator, statHistCreatTime, statHistEditor, statHistEditTime; + private Label statHistCreator, statHistCreateTime, statHistEditor, statHistEditTime; + + @FXML + private TableColumncolStatHistAbteilung, colStatHistStation; @FXML - private TableColumn colStatHistAbteilung, colStatHistStation, colStatHistAufnahmeDatum, colStatHistEntlassungsDatum; + private TableColumn colStatHistAufnahmeDatum, colStatHistEntlassungsDatum; @FXML private DateTimePicker dtTmAufnahme, dtTmEntlassung; + @FXML + private ComboBox cmbStation; + + @FXML + private ComboBox cmbAbteilung; + public StationsHistorieController(MainController mainController){ this.mainController = mainController; } + + @FXML + private void initialize() { + cmbStation.setItems(mainController.getStammdaten().getStationen()); + tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { + setStationsHistorieSelected(newValue); + + }); + } + + + + @FXML private void clickedCancel(){ @@ -56,8 +79,22 @@ public class StationsHistorieController { } - public void setStationsHistorie(StationsHistorie stationsHistorie){ - this.stationsHistorie = stationsHistorie; + public ObservableList getStationsHistorie() { + return stationsHistorie.get(); + } + + public SimpleObjectProperty> stationsHistorieProperty() { + return stationsHistorie; + } + + public void setStationsHistorieSelected(ObservableList stationsHistorie) { + this.stationsHistorie.set(stationsHistorie); + } + + private SimpleObjectProperty> stationsHistorie = new SimpleObjectProperty<>(); + + public void setStationsHistorieSelected(StationsHistorie stationsHistorie){ + if(stationsHistorie==null){ clearFields(); }else { @@ -66,47 +103,48 @@ public class StationsHistorieController { } + + private void initColumns(){ + //colStatHistAbteilung.setCellValueFactory(); + colStatHistAufnahmeDatum.setCellValueFactory(new PropertyValueFactory("aufnahmeDatum")); + colStatHistEntlassungsDatum.setCellValueFactory(new PropertyValueFactory("entlassungsDatum")); + //colStatHistStation.setCellValueFactory(new PropertyValueFactory()); + // + } + private void copyStationsHistorieDataIntoFields(){ - // colStatHistAbteilung.setText(stationsHistorie.get()); - // colStatHistStation.setText(stationsHistorie.getStation()); - // colStatHistAufnahmeDatum.setDateTime(stationsHistorie.getAufnahmeDatum()); - // colStatHistEntlassungsDatum.setDateTime(stationsHistorie.getEntlassungsDatum()); - // dtTmAufnahme=setDateTime(stationsHistorie.getAufnahmeDatum()); - // dtTmEntlassung=setDateTime(stationsHistorie.getEntlassungsDatum()); - - statHistCreator.setText(Integer.toString(stationsHistorie.getErsteller())); - statHistCreatTime.setText(stationsHistorie.getErstellDatumZeit().toString()); - statHistEditor.setText(Integer.toString(stationsHistorie.getBearbeiter())); - statHistEditTime.setText(stationsHistorie.getBearbeitetDatumZeit().toString()); + + //TODO cmbStation.setValue + + dtTmAufnahme.setDateTime(stationsHistorieSelected.getAufnahmeDatum()); + dtTmEntlassung.setDateTime(stationsHistorieSelected.getEntlassungsDatum()); + + statHistCreator.setText(Integer.toString(stationsHistorieSelected.getErsteller())); + statHistCreateTime.setText(stationsHistorieSelected.getErstellDatumZeit().toString()); + statHistEditor.setText(Integer.toString(stationsHistorieSelected.getBearbeiter())); + statHistEditTime.setText(stationsHistorieSelected.getBearbeitetDatumZeit().toString()); } private void copyFieldDataIntoStationsHistorie(StationsHistorie stationsHistorie){ - if(stationsHistorie==null){ - clearFields(); - return; - } - // stationsHistorie.set(colStatHistAbteilung.getText()); - // stationsHistorie.setStation(colStatHistStation.getText()); - // stationsHistorie.setAufnahmeDatum(colStatHistAufnahmeDatum.getDateTime()); - // stationsHistorie.getEntlassungsDatum(colStatHistEntlassungsDatum.getDateTime()); + //stationsHistorie.s(colStatHistAbteilun); stationsHistorie.setAufnahmeDatum(dtTmAufnahme.getDateTime()); - // stationsHistorie.getEntlassungsDatum(dtTmEntlassung.getDateTime()); - + stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime()); + stationsHistorie.setStation(cmbStation.getValue()); } private void clearFields(){ - //statHistCreateTime.setText(""); - //statHistCreator.setText(""); - //statHistEditTime.setText(""); - // statHistEditor.setText(""); + statHistCreateTime.setText(""); + statHistCreator.setText(""); + statHistEditTime.setText(""); + statHistEditor.setText(""); + + cmbAbteilung.setValue(null); + cmbStation.setValue(null); + - colStatHistAbteilung.setText(""); - colStatHistStation.setText(""); - // colStatHistAufnahmeDatum.setDateTime(null); - // colStatHistEntlassungsDatum.setDateTime(null); dtTmAufnahme.setDateTime(null); - dtTmEntlassung.setDateTime(null); + dtTmEntlassung.setDateTime(null); } } diff --git a/src/main/resources/stationshistorie.fxml b/src/main/resources/stationshistorie.fxml index e72953c..704d2fa 100644 --- a/src/main/resources/stationshistorie.fxml +++ b/src/main/resources/stationshistorie.fxml @@ -44,13 +44,16 @@