|
|
@@ -3,6 +3,7 @@ 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 ca.uhn.hl7v2.model.v251.segment.LOC; |
|
|
import com.sun.org.apache.bcel.internal.generic.LoadClass; |
|
|
import com.sun.org.apache.bcel.internal.generic.LoadClass; |
|
|
import de.uniluebeck.mi.projmi6.db.DBHandler; |
|
|
import de.uniluebeck.mi.projmi6.db.DBHandler; |
|
|
@@ -16,6 +17,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.collections.transformation.FilteredList; |
|
|
import javafx.concurrent.Task; |
|
|
import javafx.concurrent.Task; |
|
|
import javafx.fxml.FXML; |
|
|
import javafx.fxml.FXML; |
|
|
import javafx.fxml.FXMLLoader; |
|
|
import javafx.fxml.FXMLLoader; |
|
|
@@ -37,7 +39,7 @@ import java.util.List; |
|
|
/** |
|
|
/** |
|
|
* Controller class. |
|
|
* Controller class. |
|
|
*/ |
|
|
*/ |
|
|
public class PatientTablesController{ |
|
|
|
|
|
|
|
|
public class PatientTablesController { |
|
|
|
|
|
|
|
|
private MainController mainController; |
|
|
private MainController mainController; |
|
|
|
|
|
|
|
|
@@ -84,8 +86,6 @@ public class PatientTablesController{ |
|
|
private TableColumn<Patient, String> colPatCave; |
|
|
private TableColumn<Patient, String> colPatCave; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
@FXML |
|
|
private ToggleButton btnEntlassenePatientenZeigen; |
|
|
private ToggleButton btnEntlassenePatientenZeigen; |
|
|
|
|
|
|
|
|
@@ -124,29 +124,26 @@ public class PatientTablesController{ |
|
|
private Tab patientOverviewTab; |
|
|
private Tab patientOverviewTab; |
|
|
|
|
|
|
|
|
@FXML |
|
|
@FXML |
|
|
private TabPane patientOverviewTabPane; |
|
|
|
|
|
|
|
|
private TabPane patientOverviewTabPane; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PatientTablesController(MainController mainController){ |
|
|
|
|
|
|
|
|
public PatientTablesController(MainController mainController) { |
|
|
this.mainController = mainController; |
|
|
this.mainController = mainController; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
@FXML |
|
|
public void initialize() { |
|
|
public void initialize() { |
|
|
btnPatEdit.disableProperty().bind(tblPatientOverview.getSelectionModel().selectedItemProperty().isNull()); |
|
|
btnPatEdit.disableProperty().bind(tblPatientOverview.getSelectionModel().selectedItemProperty().isNull()); |
|
|
tblPatientOverview.setRowFactory(tableView -> { |
|
|
tblPatientOverview.setRowFactory(tableView -> { |
|
|
TableRow<Patient> tableRow = new TableRow<>(); |
|
|
TableRow<Patient> tableRow = new TableRow<>(); |
|
|
tableRow.setOnMouseClicked(event -> { |
|
|
tableRow.setOnMouseClicked(event -> { |
|
|
if(event.getClickCount()==2 && (!tableRow.isEmpty())){ |
|
|
|
|
|
|
|
|
if (event.getClickCount() == 2 && (!tableRow.isEmpty())) { |
|
|
Patient patient = tableRow.getItem(); |
|
|
Patient patient = tableRow.getItem(); |
|
|
showEditWindow(patient); |
|
|
showEditWindow(patient); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
return tableRow; |
|
|
|
|
|
|
|
|
return tableRow; |
|
|
}); |
|
|
}); |
|
|
lblTablePatientEmpty.setText("Liste ist leer."); |
|
|
lblTablePatientEmpty.setText("Liste ist leer."); |
|
|
lblTableStationEmpty.setText("Daten werden geladen..."); |
|
|
lblTableStationEmpty.setText("Daten werden geladen..."); |
|
|
@@ -154,7 +151,7 @@ public class PatientTablesController{ |
|
|
cmbStationenFilter.itemsProperty().bind(mainController.getStammdaten().stationenProperty()); |
|
|
cmbStationenFilter.itemsProperty().bind(mainController.getStammdaten().stationenProperty()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
patientObjectBinding = Bindings.<Patient>createObjectBinding(() ->{ |
|
|
|
|
|
|
|
|
patientObjectBinding = Bindings.<Patient>createObjectBinding(() -> { |
|
|
return patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab) |
|
|
return patientOverviewTabPane.getSelectionModel().getSelectedItem().equals(patientOverviewTab) |
|
|
? tblPatientOverview.getSelectionModel().getSelectedItem() |
|
|
? tblPatientOverview.getSelectionModel().getSelectedItem() |
|
|
: null; //(Patient)tblStationOverview.getSelectionModel().getSelectedItem(); //TODO |
|
|
: null; //(Patient)tblStationOverview.getSelectionModel().getSelectedItem(); //TODO |
|
|
@@ -162,13 +159,20 @@ public class PatientTablesController{ |
|
|
tblStationOverview.getSelectionModel().selectedItemProperty(), |
|
|
tblStationOverview.getSelectionModel().selectedItemProperty(), |
|
|
patientOverviewTabPane.getSelectionModel().selectedItemProperty()); |
|
|
patientOverviewTabPane.getSelectionModel().selectedItemProperty()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initColumnsPatient(); |
|
|
initColumnsPatient(); |
|
|
initColumnsStation(); |
|
|
initColumnsStation(); |
|
|
|
|
|
|
|
|
updatePatientsFromDb(); |
|
|
updatePatientsFromDb(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void initColumnsPatient(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableList<StationsUebersichtsItem> stationsUebersicht = FXCollections.observableArrayList(); |
|
|
|
|
|
|
|
|
|
|
|
private FilteredList<StationsUebersichtsItem> stationsUebersichtsItemFilteredList = new FilteredList<StationsUebersichtsItem>(stationsUebersicht, |
|
|
|
|
|
item -> item.getStationEntlassung() == null || !item.getStationEntlassung().isAfter(LocalDate.now())); |
|
|
|
|
|
|
|
|
|
|
|
private void initColumnsPatient() { |
|
|
colPatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIDProperty().asString()); |
|
|
colPatPatId.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patIDProperty().asString()); |
|
|
colPatGeburtsname.setCellValueFactory(new PropertyValueFactory<>("geburtsname")); |
|
|
colPatGeburtsname.setCellValueFactory(new PropertyValueFactory<>("geburtsname")); |
|
|
colPatNachname.setCellValueFactory(new PropertyValueFactory<>("nachname")); |
|
|
colPatNachname.setCellValueFactory(new PropertyValueFactory<>("nachname")); |
|
|
@@ -176,7 +180,7 @@ public class PatientTablesController{ |
|
|
colPatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().geburtsdatumProperty()); |
|
|
colPatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().geburtsdatumProperty()); |
|
|
colPatStrasse.setCellValueFactory(cellDataFeatures -> { |
|
|
colPatStrasse.setCellValueFactory(cellDataFeatures -> { |
|
|
Patient patient = cellDataFeatures.getValue(); |
|
|
Patient patient = cellDataFeatures.getValue(); |
|
|
return Bindings.concat(patient.strasseProperty(), " ", patient.hausnummerProperty()); |
|
|
|
|
|
|
|
|
return Bindings.concat(patient.strasseProperty(), " ", patient.hausnummerProperty()); |
|
|
}); |
|
|
}); |
|
|
colPatPlz.setCellValueFactory(new PropertyValueFactory<>("plz")); |
|
|
colPatPlz.setCellValueFactory(new PropertyValueFactory<>("plz")); |
|
|
colPatOrt.setCellValueFactory(new PropertyValueFactory<>("ort")); |
|
|
colPatOrt.setCellValueFactory(new PropertyValueFactory<>("ort")); |
|
|
@@ -184,7 +188,7 @@ public class PatientTablesController{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initColumnsStation(){ |
|
|
|
|
|
|
|
|
private void initColumnsStation() { |
|
|
colStatPatId.setCellValueFactory(new PropertyValueFactory<StationsUebersichtsItem, Integer>("patId")); |
|
|
colStatPatId.setCellValueFactory(new PropertyValueFactory<StationsUebersichtsItem, Integer>("patId")); |
|
|
colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty()); |
|
|
colStatFullName.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patNameProperty()); |
|
|
colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty()); |
|
|
colStatGebDatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().patBirthdateProperty()); |
|
|
@@ -193,46 +197,52 @@ public class PatientTablesController{ |
|
|
colStatEntlassungsdatum.setCellValueFactory(cellDataFeatures -> cellDataFeatures.getValue().stationEntlassungProperty()); |
|
|
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 |
|
|
@FXML |
|
|
private void clickedCreatePatient (){ |
|
|
|
|
|
|
|
|
private void clickedCreatePatient() { |
|
|
showEditWindow(null); |
|
|
showEditWindow(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
@FXML |
|
|
private void clickedEditPatient(){ |
|
|
|
|
|
|
|
|
private void clickedEditPatient() { |
|
|
showEditWindow(tblPatientOverview.getSelectionModel().getSelectedItem()); |
|
|
showEditWindow(tblPatientOverview.getSelectionModel().getSelectedItem()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void showEditWindow(Patient patient){ |
|
|
|
|
|
|
|
|
private void showEditWindow(Patient patient) { |
|
|
FXMLLoader fxmlLoader = new FXMLLoader(); |
|
|
FXMLLoader fxmlLoader = new FXMLLoader(); |
|
|
fxmlLoader.setLocation(getClass().getClassLoader().getResource("patient_edit.fxml")); |
|
|
fxmlLoader.setLocation(getClass().getClassLoader().getResource("patient_edit.fxml")); |
|
|
PatientEditorController patientEditorController = new PatientEditorController(mainController); |
|
|
PatientEditorController patientEditorController = new PatientEditorController(mainController); |
|
|
fxmlLoader.setControllerFactory(clazz -> patientEditorController); |
|
|
fxmlLoader.setControllerFactory(clazz -> patientEditorController); |
|
|
|
|
|
|
|
|
Parent root = null; |
|
|
Parent root = null; |
|
|
try{ |
|
|
|
|
|
|
|
|
try { |
|
|
root = fxmlLoader.load(); |
|
|
root = fxmlLoader.load(); |
|
|
}catch (IOException e){ |
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Stage stage = new Stage(); |
|
|
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.setScene(new Scene(root, 600, 600)); |
|
|
|
|
|
|
|
|
stage.getIcons().add(new Image("icon.png")); |
|
|
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<List<Patient>>loadPatientsTask = new Task<List<Patient>>(){ |
|
|
|
|
|
|
|
|
Task<List<Patient>> loadPatientsTask = new Task<List<Patient>>() { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected List<Patient> call() throws Exception { |
|
|
|
|
|
return FXCollections.<Patient>observableArrayList(DBHandler.getAllPatients()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected List<Patient> call() throws Exception { |
|
|
|
|
|
return FXCollections.<Patient>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; |
|
|
private Button btnPatRefresh; |
|
|
|
|
|
|
|
|
@FXML |
|
|
@FXML |
|
|
private void clickedRefreshPatient(){ |
|
|
|
|
|
|
|
|
private void clickedRefreshPatient() { |
|
|
updatePatientsFromDb(); |
|
|
updatePatientsFromDb(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ObjectBinding<Patient> patientObjectBinding = null; |
|
|
private ObjectBinding<Patient> patientObjectBinding = null; |
|
|
|
|
|
|
|
|
public ObjectBinding<Patient> selectedPatientProperty(){ |
|
|
|
|
|
|
|
|
public ObjectBinding<Patient> selectedPatientProperty() { |
|
|
return patientObjectBinding; |
|
|
return patientObjectBinding; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Patient getSelectedPatient(){ |
|
|
|
|
|
|
|
|
public Patient getSelectedPatient() { |
|
|
return selectedPatientProperty().get(); |
|
|
return selectedPatientProperty().get(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|