Browse Source

FallProperty des FallControllers angepasst

Patientenliste wird beim Erstellen eines neuen Patienten neu geladen
Patientenladen aus eigenem Task
testBranch
Johannes 10 years ago
parent
commit
d454e8a862
5 changed files with 90 additions and 33 deletions
  1. +3
    -2
      src/main/java/de/uniluebeck/mi/projmi6/Main.java
  2. +7
    -5
      src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java
  3. +7
    -6
      src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java
  4. +5
    -3
      src/main/java/de/uniluebeck/mi/projmi6/controller/PatientEditorController.java
  5. +68
    -17
      src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java

+ 3
- 2
src/main/java/de/uniluebeck/mi/projmi6/Main.java View File

@@ -13,6 +13,7 @@ import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.Background; import javafx.scene.layout.Background;
@@ -63,7 +64,7 @@ public class Main extends Application {
DBHandler.getAllStationen()) DBHandler.getAllStationen())
); );


System.out.printf("Lade GUI...");
System.out.println("Lade GUI...");
FXMLLoader fxmlLoader = new FXMLLoader(); FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getClassLoader().getResource("main.fxml")); fxmlLoader.setLocation(getClass().getClassLoader().getResource("main.fxml"));
fxmlLoader.setControllerFactory(mainController.getControllerFactory()); fxmlLoader.setControllerFactory(mainController.getControllerFactory());
@@ -121,7 +122,7 @@ public class Main extends Application {
Text gruppe6 = new Text("Gruppe 06"); Text gruppe6 = new Text("Gruppe 06");
gruppe6.setFont(Font.font(20)); gruppe6.setFont(Font.font(20));


VBox root = new VBox(gruppe6, new ImageView(icon), kis);
VBox root = new VBox(gruppe6, new ImageView(icon), kis);
root.setSpacing(20); root.setSpacing(20);
root.setAlignment(Pos.CENTER); root.setAlignment(Pos.CENTER);
Scene scene = new Scene(root, 400, 400); Scene scene = new Scene(root, 400, 400);


+ 7
- 5
src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java View File

@@ -155,16 +155,18 @@ public class FallController {


@FXML @FXML
void clickedFallSave(ActionEvent event) { void clickedFallSave(ActionEvent event) {
copyFieldDataIntoFall(fallProperty.get());
if (this.state.get() == State.CREATE) { if (this.state.get() == State.CREATE) {
Fall fall = new Fall();
copyFieldDataIntoFall(fall);
try { try {
DBHandler.setFall(fallProperty.get(), mainController.currentMitarbeiterProperty().get().getMitarbID());
DBHandler.setFall(fall, mainController.getCurrentMitarbeiter().getMitarbID());
//TODO Reload Faelle for Patient im MainController
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
try { try {
DBHandler.setFall(fallProperty.get(), mainController.currentMitarbeiterProperty().get().getMitarbID(), true);
DBHandler.setFall(fallProperty.get(), mainController.getCurrentMitarbeiter().getMitarbID(), true);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -179,8 +181,8 @@ public class FallController {
clearFields(); clearFields();
this.state.set(State.CREATE); this.state.set(State.CREATE);
// TODO: Jojo: Kannst Du das wieder heile machen? :D // TODO: Jojo: Kannst Du das wieder heile machen? :D
fallProperty.unbind();
fallProperty.set(new Fall());
// fallProperty.unbind();
// fallProperty.set(new Fall());
} }






+ 7
- 6
src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java View File

@@ -7,6 +7,7 @@ import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.util.Callback; import javafx.util.Callback;
@@ -35,6 +36,7 @@ public class MainController {


@FXML @FXML
private ProgressIndicator progressIndicator; private ProgressIndicator progressIndicator;

@FXML @FXML
private Button btnFallCreate; private Button btnFallCreate;


@@ -121,14 +123,14 @@ public class MainController {


public void increaseParallelTaskCount(){ public void increaseParallelTaskCount(){
parallelTaskCount++; parallelTaskCount++;
if(parallelTaskCount>0){
if(parallelTaskCount>0 && progressIndicator!=null){
progressIndicator.setVisible(true); progressIndicator.setVisible(true);
} }
} }


public void decreaseParallelTaskCount(){ public void decreaseParallelTaskCount(){
parallelTaskCount++;
if(parallelTaskCount<=0){
parallelTaskCount--;
if(parallelTaskCount<=0 && progressIndicator!=null){
parallelTaskCount = 0; parallelTaskCount = 0;
progressIndicator.setVisible(false); progressIndicator.setVisible(false);
} }
@@ -157,9 +159,6 @@ public class MainController {
System.out.println(faelle); System.out.println(faelle);
System.out.println("Liste der Faelle hat "+ faelle.size()+ " Eintrage "); System.out.println("Liste der Faelle hat "+ faelle.size()+ " Eintrage ");
lvFall.setItems(FXCollections.observableArrayList(faelle)); lvFall.setItems(FXCollections.observableArrayList(faelle));



}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@@ -202,6 +201,8 @@ public class MainController {
} }






@FXML @FXML
private void clickedCreateFall(){ private void clickedCreateFall(){
tabFallDiagnose.setDisable(true); tabFallDiagnose.setDisable(true);


+ 5
- 3
src/main/java/de/uniluebeck/mi/projmi6/controller/PatientEditorController.java View File

@@ -109,12 +109,12 @@ public class PatientEditorController {
patFamilienstand.setValue(patient.getFamilienstand()); patFamilienstand.setValue(patient.getFamilienstand());
patGeschlecht.setValue(patient.getGeschlecht()); patGeschlecht.setValue(patient.getGeschlecht());
patVersicherungsnummer.setText(patient.getVersichertennummer()); patVersicherungsnummer.setText(patient.getVersichertennummer());
for (Kasse kasse : patVersicherung.getItems())
for (Kasse kasse : patVersicherung.getItems()) {
if (kasse.getKassenID() == patient.getKassenID()) { if (kasse.getKassenID() == patient.getKassenID()) {
patVersicherung.getSelectionModel().select(kasse); patVersicherung.getSelectionModel().select(kasse);
break; break;
} }
}
patCave.setText(patient.getCave()); patCave.setText(patient.getCave());


patCreator.setText(Integer.toString(patient.getErsteller())); patCreator.setText(Integer.toString(patient.getErsteller()));
@@ -195,6 +195,8 @@ public class PatientEditorController {
copyFieldDataIntoPatient(patient); copyFieldDataIntoPatient(patient);
try { try {
DBHandler.insertPatient(patient, mainController.getCurrentMitarbeiter().getMitarbID()); DBHandler.insertPatient(patient, mainController.getCurrentMitarbeiter().getMitarbID());
mainController.getPatientTablesController().updatePatientsFromDb();
((Stage) patNachname.getScene().getWindow()).close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -202,11 +204,11 @@ public class PatientEditorController {
copyFieldDataIntoPatient(patient); copyFieldDataIntoPatient(patient);
try { try {
DBHandler.updatePatient(patient, mainController.getCurrentMitarbeiter().getMitarbID()); DBHandler.updatePatient(patient, mainController.getCurrentMitarbeiter().getMitarbID());
((Stage) patNachname.getScene().getWindow()).close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
((Stage) patNachname.getScene().getWindow()).close();
} }


@FXML @FXML


+ 68
- 17
src/main/java/de/uniluebeck/mi/projmi6/controller/PatientTablesController.java View File

@@ -3,6 +3,8 @@ 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.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;
@@ -14,6 +16,7 @@ import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
@@ -28,6 +31,8 @@ import java.io.IOException;
import java.rmi.server.ExportException; import java.rmi.server.ExportException;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;


/** /**
* Controller class. * Controller class.
@@ -91,22 +96,22 @@ public class PatientTablesController{
private TableView<StationsUebersichtsItem> tblStationOverview; private TableView<StationsUebersichtsItem> tblStationOverview;


@FXML @FXML
private TableColumn<StationsUebersichtsItem, String> colStatPatId;
private TableColumn<StationsUebersichtsItem, Integer> colStatPatId;


@FXML @FXML
private TableColumn<StationsUebersichtsItem, String> colStatFullName; private TableColumn<StationsUebersichtsItem, String> colStatFullName;


@FXML @FXML
private TableColumn<StationsUebersichtsItem, String> colStatGebDatum;
private TableColumn<StationsUebersichtsItem, LocalDate> colStatGebDatum;


@FXML @FXML
private TableColumn<StationsUebersichtsItem, String> colStatAlter;
private TableColumn<StationsUebersichtsItem, Integer> colStatAlter;


@FXML @FXML
private TableColumn<StationsUebersichtsItem, String> colStatAufnahmedatum;
private TableColumn<StationsUebersichtsItem, LocalDate> colStatAufnahmedatum;


@FXML @FXML
private TableColumn<StationsUebersichtsItem, String> colStatEntlassungsdatum;
private TableColumn<StationsUebersichtsItem, LocalDate> colStatEntlassungsdatum;


@FXML @FXML
private Tab stationOverviewTab; private Tab stationOverviewTab;
@@ -180,12 +185,24 @@ public class PatientTablesController{




private void initColumnsStation(){ private void initColumnsStation(){
colStatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIdProperty().asString());
colStatPatId.setCellValueFactory(new PropertyValueFactory<StationsUebersichtsItem, Integer>("patId"));
colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty()); colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty());
colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty().asString());
colStatAlter.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patAgeProperty().asString());
colStatAufnahmedatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationAufnahmeProperty().asString());
colStatEntlassungsdatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationEntlassungProperty().asString());
colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty());
colStatAlter.setCellValueFactory(new PropertyValueFactory<StationsUebersichtsItem, Integer>("patAge"));
colStatAufnahmedatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationAufnahmeProperty());
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));
} }


@FXML @FXML
@@ -228,17 +245,51 @@ public class PatientTablesController{




public void updatePatientsFromDb(){ public void updatePatientsFromDb(){
ObservableList<Patient> patientList = null;
try {
patientList = FXCollections.<Patient>observableArrayList(DBHandler.getAllPatients());
} catch (SQLException e) {
e.printStackTrace();
}


tblPatientOverview.setItems(patientList);
//if(!loadPatientsTask.isRunning()) {
lblTablePatientEmpty.setText("Daten werden geladen...");
tblPatientOverview.setItems(null);

mainController.increaseParallelTaskCount();


Task<List<Patient>>loadPatientsTask = new Task<List<Patient>>(){

@Override
protected List<Patient> call() throws Exception {
return FXCollections.<Patient>observableArrayList(DBHandler.getAllPatients());
}

@Override
protected void succeeded() {
super.succeeded();
tblPatientOverview.setItems(FXCollections.observableArrayList(this.getValue()));
lblTablePatientEmpty.setText("Es sind keine Patienten in der Datenbank");
mainController.decreaseParallelTaskCount();
System.out.println("Patientenlsite erfolgreich aus Task geladen!");
}

@Override
protected void failed() {
super.failed();
mainController.decreaseParallelTaskCount();
tblPatientOverview.setItems(null);
lblTablePatientEmpty.setText("Ein Fehler ist aufgetreten: "+this.getException());
if(getException()!=null){
getException().printStackTrace();
}
}
};


Thread thread = new Thread(loadPatientsTask);
thread.setDaemon(true);
thread.start();
// }
} }





private ObjectBinding<Patient> patientObjectBinding = null; private ObjectBinding<Patient> patientObjectBinding = null;


public ObjectBinding<Patient> selectedPatientProperty(){ public ObjectBinding<Patient> selectedPatientProperty(){


Loading…
Cancel
Save