From 3c75fdda676e32d55305e61109c5164126823cad Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 11:27:42 +0100 Subject: [PATCH 01/20] Stationsuebersicht fuellbar --- .../de/uniluebeck/mi/projmi6/db/DBHandler.java | 44 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java index b6c77a5..8df2fc2 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java @@ -109,6 +109,17 @@ public class DBHandler { private static final String SELECT_ALL_KASSEN = "SELECT * FROM `kasse`"; private static final String SELECT_KASSE_BY_KASSENID = "SELECT * FROM `kasse` WHERE `kasse`.`KassenID` = ?"; private static final String SELECT_STATHIST_BY_STATION = "SELECT * FROM `stationshistorie` WHERE `stationshistorie`.`Station` = ?"; + private static final String SELECT_STATUBERITEMS_BY_STATION = "SELECT p.id AS patid," + + "concat(p.nachname, ', ', p.vorname) AS patname," + + "p.geburtsdatum AS dob," + + "timestampdiff(YEAR, p.geburtsdatum, curdate()) AS patage," + + "f.aufnahmedatum AS aufnahme," + + "f.entlassungsdatum AS entlassung," + + "f.fallid AS fallid " + + "FROM stationshistorie s " + + "INNER JOIN fall f ON s.fallid = f.fallid " + + "INNER JOIN patient p ON f.patientid = p.id " + + "WHERE s.station = ?"; /** * Gibt alle {@link Patient} aus der DB zurueck. @@ -253,6 +264,34 @@ public class DBHandler { return station; } + public static List getStationsUebersichtsItems(String station) throws SQLException { + PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATUBERITEMS_BY_STATION); + statement.setString(1, station); + ResultSet rs = statement.executeQuery(); + + List statUeberItems = new ArrayList<>(); + while (rs.next()) { + statUeberItems.add(getStatUeberItem(rs)); + } + return statUeberItems; + } + + private static StationsUebersichtsItem getStatUeberItem(ResultSet rs) throws SQLException { + StationsUebersichtsItem item = new StationsUebersichtsItem(); + item.setFallId(rs.getInt("fallid")); + item.setPatId(rs.getInt("patid")); + item.setPatName(rs.getString("patname")); + item.setPatAge(rs.getInt("patage")); + item.setPatBirthdate(rs.getDate("dob").toLocalDate()); + if (rs.getDate("aufnahme") != null) { + item.setStationAufnahme(rs.getDate("aufnahme").toLocalDate()); + } + if (rs.getDate("entlassung") != null) { + item.setStationEntlassung(rs.getDate("entlassung").toLocalDate()); + } + return item; + } + public static List getStationsHistorieByStation(String station) throws SQLException { PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_STATION); statement.setString(1, station); @@ -331,7 +370,7 @@ public class DBHandler { /** * Fuehrt {@code INSERT} bei einem neuen Datensatz und {@code UPDATE} bei einem existierenden Datensatz aus. * - * @param fall zu verarbeitender Datensatz. + * @param fall zu verarbeitender Datensatz. * @param mitarbid {@link Mitarbeiter#mitarbID} des aktuellen Benutzers/Mitarbeiters. * @param isUpdate {@code true} wenn der Datensatz bereits existiert, sonst {@code false}. * @throws SQLException wenn Fehler bei der SQL Verarbeitung auftreten. @@ -396,7 +435,8 @@ public class DBHandler { /** * Fuehrt {@code INSERT} eines neuen Datensatz durch. - * @param fall zu verarbeitender Datensatz. + * + * @param fall zu verarbeitender Datensatz. * @param mitarbid {@link Mitarbeiter#mitarbID} des aktuellen Benutzers/Mitarbeiters. * @throws SQLException wenn Fehler bei der SQL Verarbeitung auftreten. */ From 6ecebe1e636211115535ee25b5b7adad7e995d7b Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 11:29:59 +0100 Subject: [PATCH 02/20] =?UTF-8?q?Stationshistorie=20korrigiert,=20nicht=20?= =?UTF-8?q?mehr=20abh=C3=A4ngig=20von=20Station=20sondern=20von=20Fall.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java index 8df2fc2..f019c7b 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java @@ -108,7 +108,7 @@ public class DBHandler { private static final String SELECT_DIAGNOSE_BY_FALLID = "SELECT * FROM `diagnose` WHERE `fallid` = ?"; private static final String SELECT_ALL_KASSEN = "SELECT * FROM `kasse`"; private static final String SELECT_KASSE_BY_KASSENID = "SELECT * FROM `kasse` WHERE `kasse`.`KassenID` = ?"; - private static final String SELECT_STATHIST_BY_STATION = "SELECT * FROM `stationshistorie` WHERE `stationshistorie`.`Station` = ?"; + private static final String SELECT_STATHIST_BY_FALLID = "SELECT * FROM `stationshistorie` WHERE `stationshistorie`.`fallid` = ?"; private static final String SELECT_STATUBERITEMS_BY_STATION = "SELECT p.id AS patid," + "concat(p.nachname, ', ', p.vorname) AS patname," + "p.geburtsdatum AS dob," + @@ -292,9 +292,9 @@ public class DBHandler { return item; } - public static List getStationsHistorieByStation(String station) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_STATION); - statement.setString(1, station); + public static List getStationsHistorieByFall(Fall fall) throws SQLException { + PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_FALLID); + statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); List historie = new ArrayList<>(); From 9628f045398c2c05f3d321f231ef041dbe0e23bb Mon Sep 17 00:00:00 2001 From: Johannes Oehm Date: Wed, 18 Nov 2015 11:42:00 +0100 Subject: [PATCH 03/20] 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 @@ From 9b31050a012cf42cb9bafa7c6614e364257efb5f Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 11:54:25 +0100 Subject: [PATCH 04/20] Station bekommt jetzt auch die Abteilung (String) mit uebergeben. --- .../de/uniluebeck/mi/projmi6/db/DBHandler.java | 5 ++- .../de/uniluebeck/mi/projmi6/model/Station.java | 46 ++++++++++++++-------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java index f019c7b..31c096a 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java @@ -48,7 +48,9 @@ public class DBHandler { "`LetzterBearbeiter`," + "`Ersteller`)" + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - private static final String SELECT_ALL_STATIONEN = "SELECT * FROM `stammstation`"; + private static final String SELECT_ALL_STATIONEN = "SELECT *,r.abteilung AS abteilung" + + "FROM stammstation s " + + "INNER JOIN relfachrichtungstation r ON s.station = r.station"; private static final String SELECT_FAELLE_BY_PATID = "SELECT * FROM `fall` WHERE `patientid` = ?"; private static final String INSERT_FALL = "INSERT INTO `fall`" + "(`Aufnahmedatum`," + @@ -260,6 +262,7 @@ public class DBHandler { station.setBezeichnung(rs.getString("bezeichnung")); station.setBezeichnungLang(rs.getString("bezeichnunglang")); station.setStationstyp(rs.getInt("stationstyp")); + station.setAbteilung(rs.getString("abteilung")); return station; } diff --git a/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java b/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java index 9464256..051c4a8 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java @@ -10,57 +10,69 @@ public class Station { private SimpleStringProperty bezeichnung = new SimpleStringProperty(this, "bezeichnung"); private SimpleStringProperty bezeichnungLang = new SimpleStringProperty(this, "bezeichnungLang"); private SimpleStringProperty station = new SimpleStringProperty(this, "station"); - private SimpleIntegerProperty stationstyp = new SimpleIntegerProperty( this, "stationstyp"); + private SimpleIntegerProperty stationstyp = new SimpleIntegerProperty(this, "stationstyp"); + private SimpleStringProperty abteilung = new SimpleStringProperty(this, "abteilung"); + public String getAbteilung() { + return abteilung.get(); + } - public String getBezeichnung() { - return bezeichnung.get(); + public void setAbteilung(String abteilung) { + this.abteilung.set(abteilung); } - public SimpleStringProperty bezeichnungProperty() { - return bezeichnung; + public SimpleStringProperty abteilungProperty() { + return abteilung; + } + + public String getBezeichnung() { + return bezeichnung.get(); } public void setBezeichnung(String bezeichnung) { this.bezeichnung.set(bezeichnung); } - public String getBezeichnungLang() { - return bezeichnungLang.get(); + public SimpleStringProperty bezeichnungProperty() { + return bezeichnung; } - public SimpleStringProperty bezeichnungLangProperty() { - return bezeichnungLang; + public String getBezeichnungLang() { + return bezeichnungLang.get(); } public void setBezeichnungLang(String bezeichnungLang) { this.bezeichnungLang.set(bezeichnungLang); } - public String getStation() { - return station.get(); + public SimpleStringProperty bezeichnungLangProperty() { + return bezeichnungLang; } - public SimpleStringProperty stationProperty() { - return station; + public String getStation() { + return station.get(); } public void setStation(String station) { this.station.set(station); } - public int getStationstyp() { - return stationstyp.get(); + public SimpleStringProperty stationProperty() { + return station; } - public SimpleIntegerProperty stationstypProperty() { - return stationstyp; + public int getStationstyp() { + return stationstyp.get(); } public void setStationstyp(int stationstyp) { this.stationstyp.set(stationstyp); } + public SimpleIntegerProperty stationstypProperty() { + return stationstyp; + } + @Override public String toString() { return getBezeichnung(); From 9aebeaba0f0c1bd471910c3a84c83171e6693698 Mon Sep 17 00:00:00 2001 From: Ileana Krontsi Date: Wed, 18 Nov 2015 12:01:19 +0100 Subject: [PATCH 05/20] MessageListener angelegt. --- .../mi/projmi6/view/MessageListener.java | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/de/uniluebeck/mi/projmi6/view/MessageListener.java diff --git a/src/main/java/de/uniluebeck/mi/projmi6/view/MessageListener.java b/src/main/java/de/uniluebeck/mi/projmi6/view/MessageListener.java new file mode 100644 index 0000000..b7d08e6 --- /dev/null +++ b/src/main/java/de/uniluebeck/mi/projmi6/view/MessageListener.java @@ -0,0 +1,54 @@ +package de.uniluebeck.mi.projmi6.view; + +import ca.uhn.hl7v2.app.HL7Service; +// import ca.uhn.hl7v2.app.AcceptorThread.AcceptedSocket; +import ca.uhn.hl7v2.concurrent.Service; +// import ca.uhn.hl7v2.app; + +/** + * Created by 630030 on 18.11.15. + */ + +//Build a simple TCP/IP based Server + // nach diesem beispiel: http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/app/SimpleServer.html + +// public class MessageListener extends HL7Service { + + // Socket timeout for server TODO +//public static final int SO_TIMEOUT = AcceptorThread.TIMEOUT; + /* + Create new instance of MessageListener that listens on given port, + using the MinLayerProtocol and a standard. TODO + */ +// public MessageListener(int port){ + + +//} + /* + Creates a new instance of MessageListener that listens on a given ServerSocket. + MessageListener will bind the socket when it is started, so the server socket must not + be already bound. TODO + */ + + /* + Prepare server by initializing the server socket. TODO + */ + + /* + Loop that waits for connection and starts a ConnectionManager when it gets one. TODO + */ + + /* + CLose down socket TODO + */ + + +/* + + + @Override + protected void handle() { + + } +} +*/ \ No newline at end of file From 48e2a466ab67b3320352008972aebff2b1e8d7da Mon Sep 17 00:00:00 2001 From: Johannes Oehm Date: Wed, 18 Nov 2015 12:03:00 +0100 Subject: [PATCH 06/20] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stammstationen.... --- .../mi/projmi6/controller/MainController.java | 4 +- .../controller/StationsHistorieController.java | 44 +++++++++++++++++++--- src/main/resources/stationshistorie.fxml | 1 - 3 files changed, 42 insertions(+), 7 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 aebc1b7..17d1952 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 = DBHandler.getStationsHistorieByStation(""); + stationsHistorieList = DBHandler.getStationsHistorieByFall(newValue); return null; } @@ -277,6 +277,8 @@ public class MainController { } untersuchungenController.setUntersuchungen(FXCollections.observableArrayList(untersuchungList)); diagnoseController.setDiagnosen(FXCollections.observableArrayList(diagnoseList)); + stationsHistorieController.setStationsHistorie(FXCollections.observableArrayList(stationsHistorieList)); + tabPaneFall.setDisable(false); tabFallDiagnose.setDisable(false); 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 faaf0b1..775f6bf 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java @@ -1,15 +1,21 @@ package de.uniluebeck.mi.projmi6.controller; +import de.uniluebeck.mi.projmi6.db.DBHandler; import de.uniluebeck.mi.projmi6.model.Station; import de.uniluebeck.mi.projmi6.model.StationsHistorie; import de.uniluebeck.mi.projmi6.view.DateTimePicker; +import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleObjectProperty; +import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.collections.transformation.FilteredList; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; /** * Created by 631806 on 12.11.15. @@ -33,7 +39,7 @@ public class StationsHistorieController { private Label statHistCreator, statHistCreateTime, statHistEditor, statHistEditTime; @FXML - private TableColumncolStatHistAbteilung, colStatHistStation; + private TableColumn colStatHistStation; @FXML private TableColumn colStatHistAufnahmeDatum, colStatHistEntlassungsDatum; @@ -45,19 +51,44 @@ public class StationsHistorieController { private ComboBox cmbStation; @FXML - private ComboBox cmbAbteilung; + private ComboBox cmbAbteilung; public StationsHistorieController(MainController mainController){ this.mainController = mainController; } + public void setStationsHistorie(ObservableList stationsHistorie) { + this.stationsHistorie.set(stationsHistorie); + } + + private SimpleObjectProperty> stationsHistorie = + new SimpleObjectProperty<>(); + + + @FXML private void initialize() { + initColumns(); + + List abteilungen = mainController.getStammdaten().getStationen().stream() + .map(stat->stat.getAbteilung()).distinct().collect(Collectors.toList()); + cmbAbteilung.setItems(FXCollections.observableArrayList(abteilungen)); + + + FilteredList stationenFiltered = new FilteredList(mainController.getStammdaten().getStationen()); + + stationenFiltered.predicateProperty().bind(Bindings.createObjectBinding(() -> { + return p -> p.getAbteilung().equals(cmbAbteilung.getValue()); + },cmbAbteilung.valueProperty())); + cmbStation.setItems(mainController.getStammdaten().getStationen()); + + + + tblStationsHistorie.itemsProperty().bind(stationsHistorie); tblStationsHistorie.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { setStationsHistorieSelected(newValue); - }); } @@ -91,7 +122,6 @@ public class StationsHistorieController { this.stationsHistorie.set(stationsHistorie); } - private SimpleObjectProperty> stationsHistorie = new SimpleObjectProperty<>(); public void setStationsHistorieSelected(StationsHistorie stationsHistorie){ @@ -105,7 +135,7 @@ public class StationsHistorieController { private void initColumns(){ - //colStatHistAbteilung.setCellValueFactory(); + // colStatHistStation.setCellValueFactory(new PropertyValueFactory()); colStatHistAufnahmeDatum.setCellValueFactory(new PropertyValueFactory("aufnahmeDatum")); colStatHistEntlassungsDatum.setCellValueFactory(new PropertyValueFactory("entlassungsDatum")); //colStatHistStation.setCellValueFactory(new PropertyValueFactory()); @@ -114,6 +144,10 @@ public class StationsHistorieController { private void copyStationsHistorieDataIntoFields(){ + if(stationsHistorieSelected==null){ + return; + } + //TODO cmbStation.setValue dtTmAufnahme.setDateTime(stationsHistorieSelected.getAufnahmeDatum()); diff --git a/src/main/resources/stationshistorie.fxml b/src/main/resources/stationshistorie.fxml index 704d2fa..9b3d1c0 100644 --- a/src/main/resources/stationshistorie.fxml +++ b/src/main/resources/stationshistorie.fxml @@ -21,7 +21,6 @@ - From 4f190d2b8bf9f85b293a680db72c9bd311f6a3cd Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 13:16:39 +0100 Subject: [PATCH 07/20] Fixed typo in sql statement. Fixed issue #4. --- src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java index 31c096a..90d2858 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java @@ -48,9 +48,9 @@ public class DBHandler { "`LetzterBearbeiter`," + "`Ersteller`)" + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - private static final String SELECT_ALL_STATIONEN = "SELECT *,r.abteilung AS abteilung" + - "FROM stammstation s " + - "INNER JOIN relfachrichtungstation r ON s.station = r.station"; + private static final String SELECT_ALL_STATIONEN = "SELECT *,`r`.`abteilung` AS abteilung " + + "FROM `stammstation` s " + + "INNER JOIN `relfachrichtungstation` r ON s.station = r.station"; private static final String SELECT_FAELLE_BY_PATID = "SELECT * FROM `fall` WHERE `patientid` = ?"; private static final String INSERT_FALL = "INSERT INTO `fall`" + "(`Aufnahmedatum`," + From 54c81a0914d9f82c39f32da195c41ae04528fe58 Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 13:30:54 +0100 Subject: [PATCH 08/20] Stationsuebersicht zeigt die verfuegbaren Stationen jetzt sortiert an! --- .../de/uniluebeck/mi/projmi6/model/Stammdaten.java | 42 +++++++++++----------- .../de/uniluebeck/mi/projmi6/model/Station.java | 7 +++- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java b/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java index 2f9c08b..9d09d09 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java @@ -1,6 +1,7 @@ package de.uniluebeck.mi.projmi6.model; import javafx.beans.property.SimpleObjectProperty; +import javafx.collections.FXCollections; import javafx.collections.ObservableList; /** @@ -17,60 +18,61 @@ public class Stammdaten { return opsCodes.get(); } - public SimpleObjectProperty> opsCodesProperty() { - return opsCodes; + public void setOpsCodes(ObservableList opsCodes) { + this.opsCodesProperty().set(opsCodes); } - public void setOpsCodes(ObservableList opsCodes){ - this.opsCodesProperty().set(opsCodes); + public SimpleObjectProperty> opsCodesProperty() { + return opsCodes; } public ObservableList getIcd10Codes() { return icd10Codes.get(); } - public SimpleObjectProperty> icd10CodesProperty() { - return icd10Codes; - } - public void setIcd10Codes(ObservableList icd10Codes) { this.icd10Codes.set(icd10Codes); } - public ObservableList getStationen() { - return stationen.get(); + public SimpleObjectProperty> icd10CodesProperty() { + return icd10Codes; } - public SimpleObjectProperty> stationenProperty() { - return stationen; + public ObservableList getStationen() { + return stationen.get(); } public void setStationen(ObservableList stationen) { + FXCollections.sort(stationen); this.stationen.set(stationen); } - public ObservableList getMitarbeiter() { - return mitarbeiter.get(); + public SimpleObjectProperty> stationenProperty() { + return stationen; } - public SimpleObjectProperty> mitarbeiterProperty() { - return mitarbeiter; + public ObservableList getMitarbeiter() { + return mitarbeiter.get(); } public void setMitarbeiter(ObservableList mitarbeiter) { this.mitarbeiter.set(mitarbeiter); } - public ObservableList getKassen() { - return kassen.get(); + public SimpleObjectProperty> mitarbeiterProperty() { + return mitarbeiter; } - public SimpleObjectProperty> kassenProperty() { - return kassen; + public ObservableList getKassen() { + return kassen.get(); } public void setKassen(ObservableList kassen) { this.kassen.set(kassen); } + public SimpleObjectProperty> kassenProperty() { + return kassen; + } + } diff --git a/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java b/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java index 051c4a8..9a1b88a 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/model/Station.java @@ -6,7 +6,7 @@ import javafx.beans.property.SimpleStringProperty; /** * Created by 630030 on 12.11.15. */ -public class Station { +public class Station implements Comparable { private SimpleStringProperty bezeichnung = new SimpleStringProperty(this, "bezeichnung"); private SimpleStringProperty bezeichnungLang = new SimpleStringProperty(this, "bezeichnungLang"); private SimpleStringProperty station = new SimpleStringProperty(this, "station"); @@ -77,4 +77,9 @@ public class Station { public String toString() { return getBezeichnung(); } + + @Override + public int compareTo(Object o) { + return bezeichnung.get().compareTo(((Station) o).getBezeichnung()); + } } From 97dcf2c904032cd43651412903ccb82fb1b3a638 Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 13:35:17 +0100 Subject: [PATCH 09/20] Die Mitarbeiter sind jetzt auch sortiert. --- .../uniluebeck/mi/projmi6/model/Mitarbeiter.java | 119 +++++++++++---------- .../de/uniluebeck/mi/projmi6/model/Stammdaten.java | 1 + 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/model/Mitarbeiter.java b/src/main/java/de/uniluebeck/mi/projmi6/model/Mitarbeiter.java index 0e98139..6a72add 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/model/Mitarbeiter.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/model/Mitarbeiter.java @@ -6,7 +6,7 @@ import javafx.beans.property.SimpleStringProperty; /** * Created by 627933 on 12.11.15. */ -public class Mitarbeiter { +public class Mitarbeiter implements Comparable { private SimpleStringProperty anrede = new SimpleStringProperty(this, "anrede"); private SimpleStringProperty einweisenderArzt = new SimpleStringProperty(this, "einweisenderArzt"); private SimpleStringProperty fachrichtung = new SimpleStringProperty(this, "fachrichtung"); @@ -30,172 +30,177 @@ public class Mitarbeiter { return anrede.get(); } - public SimpleStringProperty anredeProperty() { - return anrede; - } - public void setAnrede(String anrede) { this.anrede.set(anrede); } - public String getEinweisenderArzt() { - return einweisenderArzt.get(); + public SimpleStringProperty anredeProperty() { + return anrede; } - public SimpleStringProperty einweisenderArztProperty() { - return einweisenderArzt; + public String getEinweisenderArzt() { + return einweisenderArzt.get(); } public void setEinweisenderArzt(String einweisenderArzt) { this.einweisenderArzt.set(einweisenderArzt); } - public String getFachrichtung() { - return fachrichtung.get(); + public SimpleStringProperty einweisenderArztProperty() { + return einweisenderArzt; } - public SimpleStringProperty fachrichtungProperty() { - return fachrichtung; + public String getFachrichtung() { + return fachrichtung.get(); } public void setFachrichtung(String fachrichtung) { this.fachrichtung.set(fachrichtung); } - public String getFachrichtungKurz() { - return fachrichtungKurz.get(); + public SimpleStringProperty fachrichtungProperty() { + return fachrichtung; } - public SimpleStringProperty fachrichtungKurzProperty() { - return fachrichtungKurz; + public String getFachrichtungKurz() { + return fachrichtungKurz.get(); } public void setFachrichtungKurz(String fachrichtungKurz) { this.fachrichtungKurz.set(fachrichtungKurz); } - public String getLand() { - return land.get(); + public SimpleStringProperty fachrichtungKurzProperty() { + return fachrichtungKurz; } - public SimpleStringProperty landProperty() { - return land; + public String getLand() { + return land.get(); } public void setLand(String land) { this.land.set(land); } - public int getMitarbID() { - return mitarbID.get(); + public SimpleStringProperty landProperty() { + return land; } - public SimpleIntegerProperty mitarbIDProperty() { - return mitarbID; + public int getMitarbID() { + return mitarbID.get(); } public void setMitarbID(int mitarbID) { this.mitarbID.set(mitarbID); } - public String getNachname() { - return nachname.get(); + public SimpleIntegerProperty mitarbIDProperty() { + return mitarbID; } - public SimpleStringProperty nachnameProperty() { - return nachname; + public String getNachname() { + return nachname.get(); } public void setNachname(String nachname) { this.nachname.set(nachname); } - public String getPlz() { - return plz.get(); + public SimpleStringProperty nachnameProperty() { + return nachname; } - public SimpleStringProperty plzProperty() { - return plz; + public String getPlz() { + return plz.get(); } public void setPlz(String plz) { this.plz.set(plz); } - public String getStadt() { - return stadt.get(); + public SimpleStringProperty plzProperty() { + return plz; } - public SimpleStringProperty stadtProperty() { - return stadt; + public String getStadt() { + return stadt.get(); } public void setStadt(String stadt) { this.stadt.set(stadt); } - public String getStrasse1() { - return strasse1.get(); + public SimpleStringProperty stadtProperty() { + return stadt; } - public SimpleStringProperty strasse1Property() { - return strasse1; + public String getStrasse1() { + return strasse1.get(); } public void setStrasse1(String strasse1) { this.strasse1.set(strasse1); } - public String getStrasse2() { - return strasse2.get(); + public SimpleStringProperty strasse1Property() { + return strasse1; } - public SimpleStringProperty strasse2Property() { - return strasse2; + public String getStrasse2() { + return strasse2.get(); } public void setStrasse2(String strasse2) { this.strasse2.set(strasse2); } - public String getTelefon() { - return telefon.get(); + public SimpleStringProperty strasse2Property() { + return strasse2; } - public SimpleStringProperty telefonProperty() { - return telefon; + public String getTelefon() { + return telefon.get(); } public void setTelefon(String telefon) { this.telefon.set(telefon); } - public String getTitel() { - return titel.get(); + public SimpleStringProperty telefonProperty() { + return telefon; } - public SimpleStringProperty titelProperty() { - return titel; + public String getTitel() { + return titel.get(); } public void setTitel(String titel) { this.titel.set(titel); } - public String getVorname() { - return vorname.get(); + public SimpleStringProperty titelProperty() { + return titel; } - public SimpleStringProperty vornameProperty() { - return vorname; + public String getVorname() { + return vorname.get(); } public void setVorname(String vorname) { this.vorname.set(vorname); } + public SimpleStringProperty vornameProperty() { + return vorname; + } + @Override public String toString() { return getNachname() + ", " + getVorname(); } + + @Override + public int compareTo(Object o) { + return nachname.get().compareTo(((Mitarbeiter) o).getNachname()); + } } diff --git a/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java b/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java index 9d09d09..99502e8 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/model/Stammdaten.java @@ -56,6 +56,7 @@ public class Stammdaten { } public void setMitarbeiter(ObservableList mitarbeiter) { + FXCollections.sort(mitarbeiter); this.mitarbeiter.set(mitarbeiter); } From 182fa0c845f675e41e61d2ee26cdef4d6514ad79 Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Wed, 18 Nov 2015 17:40:05 +0100 Subject: [PATCH 10/20] Klasse ConnectionFactory umbenannt. --- .../de/uniluebeck/mi/projmi6/db/DBHandler.java | 46 +++++++++++----------- .../uniluebeck/mi/projmi6/db/MySqlConnFactory.java | 38 ------------------ .../mi/projmi6/db/MySqlConnectionFactory.java | 38 ++++++++++++++++++ 3 files changed, 61 insertions(+), 61 deletions(-) delete mode 100644 src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java create mode 100644 src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java index 90d2858..8715bb2 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java @@ -130,7 +130,7 @@ public class DBHandler { * @throws SQLException wenn Fehler bei der SQL Verarbeitung auftreten. */ public static List getAllPatients() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_PATIENTS); List patients = new ArrayList<>(); @@ -179,7 +179,7 @@ public class DBHandler { // TODO: Never used. public static Patient getPatient(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_PATIENT_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_PATIENT_BY_ID); ResultSet rs; statement.setInt(1, id); rs = statement.executeQuery(); @@ -198,9 +198,9 @@ public class DBHandler { public static void setPatient(Patient patient, int mitarbid, boolean isUpdate) throws SQLException { PreparedStatement statement; if (isUpdate) { - statement = MySqlConnFactory.getConnection().prepareStatement(UPDATE_PATIENT); + statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_PATIENT); } else { - statement = MySqlConnFactory.getConnection().prepareStatement(INSERT_PATIENT); + statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_PATIENT); } statement.setString(1, patient.getCave()); // CAVE @@ -238,7 +238,7 @@ public class DBHandler { } public static List getAllStationen() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_STATIONEN); List stationen = new ArrayList<>(); @@ -268,7 +268,7 @@ public class DBHandler { } public static List getStationsUebersichtsItems(String station) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATUBERITEMS_BY_STATION); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_STATUBERITEMS_BY_STATION); statement.setString(1, station); ResultSet rs = statement.executeQuery(); @@ -296,7 +296,7 @@ public class DBHandler { } public static List getStationsHistorieByFall(Fall fall) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_FALLID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_FALLID); statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); @@ -327,7 +327,7 @@ public class DBHandler { } public static List getFaelleByPatID(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_FAELLE_BY_PATID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_FAELLE_BY_PATID); statement.setInt(1, id); ResultSet rs = statement.executeQuery(); @@ -381,9 +381,9 @@ public class DBHandler { public static void setFall(Fall fall, int mitarbid, boolean isUpdate) throws SQLException { PreparedStatement statement; if (isUpdate) { - statement = MySqlConnFactory.getConnection().prepareStatement(UPDATE_FALL); + statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_FALL); } else { - statement = MySqlConnFactory.getConnection().prepareStatement(INSERT_FALL); + statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_FALL); } if (fall.getAufnahmeDatum() != null) { @@ -455,7 +455,7 @@ public class DBHandler { } private static Diagnose getDiagnose(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_ID); statement.setInt(1, id); ResultSet rs = statement.executeQuery(); @@ -493,7 +493,7 @@ public class DBHandler { } public static List getAllIcd10Codes() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_ICD10CODES); List icd10codes = new ArrayList<>(); @@ -505,7 +505,7 @@ public class DBHandler { } private static Icd10Code getIcd10Code(String code, int version) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_ICD10CODE_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_ICD10CODE_BY_ID); ResultSet rs; statement.setString(1, code); statement.setInt(2, version); @@ -531,7 +531,7 @@ public class DBHandler { } public static List getAllOpsCodes() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_OPSCODES); List opscodes = new ArrayList<>(); @@ -543,7 +543,7 @@ public class DBHandler { } private static OpsCode getOpsCode(String code, int version) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_OPSCODE_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_OPSCODE_BY_ID); ResultSet rs; statement.setString(1, code); statement.setInt(2, version); @@ -569,7 +569,7 @@ public class DBHandler { } public static List getAllMitarbeiter() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_MITARBEITER); List mitarbeiters = new ArrayList<>(); @@ -581,7 +581,7 @@ public class DBHandler { } private static Mitarbeiter getMitarbeiter(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_MITARBEITER_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_MITARBEITER_BY_ID); ResultSet rs; statement.setInt(1, id); rs = statement.executeQuery(); @@ -614,7 +614,7 @@ public class DBHandler { * @throws SQLException wenn Fehler bei der SQL Verarbeitung auftreten. */ public static List getUntersuchungByFall(Fall fall) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_UNTERS_BY_FALLID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_UNTERS_BY_FALLID); statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); @@ -649,9 +649,9 @@ public class DBHandler { public static void setUntersuchung(Untersuchung untersuchung, int mitarbid, boolean isUpdate) throws SQLException { PreparedStatement statement; if (isUpdate) { - statement = MySqlConnFactory.getConnection().prepareStatement(UPDATE_UNTERSUCHUNG); + statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_UNTERSUCHUNG); } else { - statement = MySqlConnFactory.getConnection().prepareStatement(INSERT_UNTERSUCHUNG); + statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_UNTERSUCHUNG); } statement.setInt(1, untersuchung.getDurchfuehrenderArzt().getMitarbID()); // DurchfuehrenderArzt @@ -669,7 +669,7 @@ public class DBHandler { } public static List getDiagnosenByFall(Fall fall) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_FALLID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_FALLID); statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); @@ -682,7 +682,7 @@ public class DBHandler { } public static List getAllKassen() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_KASSEN); List kassen = new ArrayList<>(); @@ -694,7 +694,7 @@ public class DBHandler { } private static Kasse getKasse(int kassenid) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_KASSE_BY_KASSENID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_KASSE_BY_KASSENID); statement.setInt(1, kassenid); ResultSet rs = statement.executeQuery(); diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java deleted file mode 100644 index edceed9..0000000 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package de.uniluebeck.mi.projmi6.db; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -/** - * MySQL Connection Factory. - */ -public class MySqlConnFactory { - public static final String URL = "jdbc:mysql://141.83.20.84:3306/pmiw15g06_v01"; - public static final String USER = "pmiw15g06"; - public static final String PASS = "AX3yQSYJSH43PrSz"; - public static final String DRIVER = "com.mysql.jdbc.Driver"; - private static MySqlConnFactory instance = new MySqlConnFactory(); - - private MySqlConnFactory() { - try { - Class.forName(DRIVER); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - - protected static Connection getConnection() { - return instance.createConnection(); - } - - private Connection createConnection() { - Connection conn = null; - try { - conn = DriverManager.getConnection(URL, USER, PASS); - } catch (SQLException e) { - e.printStackTrace(); - } - return conn; - } -} diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java new file mode 100644 index 0000000..e680c1c --- /dev/null +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java @@ -0,0 +1,38 @@ +package de.uniluebeck.mi.projmi6.db; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +/** + * MySQL Connection Factory. + */ +public class MySqlConnectionFactory { + public static final String URL = "jdbc:mysql://141.83.20.84:3306/pmiw15g06_v01"; + public static final String USER = "pmiw15g06"; + public static final String PASS = "AX3yQSYJSH43PrSz"; + public static final String DRIVER = "com.mysql.jdbc.Driver"; + private static MySqlConnectionFactory instance = new MySqlConnectionFactory(); + + private MySqlConnectionFactory() { + try { + Class.forName(DRIVER); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + protected static Connection getConnection() { + return instance.createConnection(); + } + + private Connection createConnection() { + Connection conn = null; + try { + conn = DriverManager.getConnection(URL, USER, PASS); + } catch (SQLException e) { + e.printStackTrace(); + } + return conn; + } +} From dbe8b93e0c2774ad05871a1a3523b80a635a6300 Mon Sep 17 00:00:00 2001 From: Johannes Oehm Date: Thu, 19 Nov 2015 10:27:41 +0100 Subject: [PATCH 11/20] =?UTF-8?q?Patient=20Stations=C3=BCbersicht=20wird?= =?UTF-8?q?=20asynchron=20geladen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PatientTablesController.java | 81 +++++++++++++++++++--- src/main/resources/patient_tables.fxml | 2 + 2 files changed, 75 insertions(+), 8 deletions(-) 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 20b752e..2fa7e79 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java @@ -146,7 +146,7 @@ public class PatientTablesController { return tableRow; }); lblTablePatientEmpty.setText("Liste ist leer."); - lblTableStationEmpty.setText("Daten werden geladen..."); + lblTableStationEmpty.setText(""); cmbStationenFilter.itemsProperty().bind(mainController.getStammdaten().stationenProperty()); @@ -198,13 +198,7 @@ public class PatientTablesController { 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(); - } + updateStationsHistorieFromDb(); }); tblStationOverview.itemsProperty().bind(Bindings.createObjectBinding(() -> { if (btnEntlassenePatientenZeigen.isSelected()) { @@ -304,6 +298,77 @@ public class PatientTablesController { } + @FXML + Button btnStatRefresh; + + @FXML + private void clickedRefreshStation(){ + updateStationsHistorieFromDb(); + } + + private Task loadStationsHistorieTask = null; + + public void updateStationsHistorieFromDb() { + if (this.loadStationsHistorieTask != null && this.loadStationsHistorieTask.isRunning()) { + loadStationsHistorieTask.cancel(); + return; + } + + btnStatRefresh.setDisable(true); + + stationsUebersicht.clear(); + + mainController.increaseParallelTaskCount(); + + lblTableStationEmpty.setText("Liste wird geladen..."); + + Task> loadStatHist = new Task>() { + + @Override + protected List call() throws Exception { + return FXCollections.observableArrayList( + DBHandler.getStationsUebersichtsItems(cmbStationenFilter.getValue().getStation())); + } + + @Override + protected void succeeded() { + super.succeeded(); + if(!isCancelled()) { + lblTableStationEmpty.setText("Liste ist leer."); + stationsUebersicht.setAll(this.getValue()); + btnStatRefresh.setDisable(false); + mainController.decreaseParallelTaskCount(); + } + } + + @Override + protected void cancelled() { + super.cancelled(); + btnStatRefresh.setDisable(false); + mainController.decreaseParallelTaskCount(); + System.out.println("Cancelled"); + } + + @Override + protected void failed() { + super.failed(); + if(!isCancelled()){ + lblTablePatientEmpty.setText("Laden fehlgeschlagen!"); + getException().printStackTrace(); + } + mainController.decreaseParallelTaskCount(); + btnStatRefresh.setDisable(false); + } + }; + this.loadStationsHistorieTask = loadStatHist; + + Thread thread = new Thread(loadStationsHistorieTask); + thread.setDaemon(true); + thread.start(); + } + + + private Task loadPatientTask = null; @FXML diff --git a/src/main/resources/patient_tables.fxml b/src/main/resources/patient_tables.fxml index e1aad8f..d31a6a7 100644 --- a/src/main/resources/patient_tables.fxml +++ b/src/main/resources/patient_tables.fxml @@ -61,6 +61,8 @@