Browse Source

Kommentiert

master
Johannes Oehm 10 years ago
parent
commit
396ebe8f8a
3 changed files with 119 additions and 42 deletions
  1. +116
    -39
      src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java
  2. +1
    -1
      src/main/java/de/uniluebeck/mi/projmi6/controller/MainController.java
  3. +2
    -2
      src/main/resources/fall.fxml

+ 116
- 39
src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java View File

@@ -24,84 +24,119 @@ import java.sql.SQLException;


public class FallController { public class FallController {


SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);
@FXML
Button btnFallSendHl7;
private MainController mainController; private MainController mainController;
@FXML @FXML
private DateTimePicker dtTmAufnahme, dtTmEntlassung; private DateTimePicker dtTmAufnahme, dtTmEntlassung;
@FXML @FXML
private Label fallPatID;
private Label fallId;
@FXML @FXML
private ComboBox<FallArt> fallFallart; private ComboBox<FallArt> fallFallart;
@FXML @FXML
private ComboBox<Kasse> fallKasse; private ComboBox<Kasse> fallKasse;
@FXML @FXML
private TextField fallVersichertennummer;
@FXML
private TextField fallEinweisenderArzt;
private TextField fallVersichertennummer, fallEinweisenderArzt;
@FXML @FXML
private CheckBox fallSelbsteinweisung; private CheckBox fallSelbsteinweisung;
@FXML @FXML
private ComboBox<Diagnose> fallHauptdiagnose; private ComboBox<Diagnose> fallHauptdiagnose;
@FXML @FXML
private Label fallCreator;
@FXML
private Label fallEditor;
@FXML
private Label fallCreateTime;
@FXML
private Label fallEditTime;
@FXML
private Button btnFallSave;
private Label fallCreator, fallEditor, fallCreateTime, fallEditTime;
@FXML @FXML
private Button btnFallAbort;
@FXML
private Button btnFallCancel;
@FXML
private Button btnFallEnableEdit;
private Button btnFallSave, btnFallAbort, btnFallCancel, btnFallEnableEdit, btnFallSendHl7;
@FXML @FXML
private GridPane fallFields; private GridPane fallFields;
private SimpleObjectProperty<Fall> fallProperty = new SimpleObjectProperty<>();


/**
* A property to the case which data this controller manages.
*/
private final SimpleObjectProperty<Fall> fallProperty = new SimpleObjectProperty<>();

/**
* Controllers current state.
*/
private final SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);


/**
* Contstructor.
* @param mainController The main controller that creats this instance
*/
public FallController(MainController mainController) { public FallController(MainController mainController) {
this.mainController = mainController; this.mainController = mainController;
} }



/**
* Getter for the {@link #fallProperty()}
*/
public Fall getFall() { public Fall getFall() {
return fallProperty.get(); return fallProperty.get();
} }


/**
* Setter for the {@link #fallProperty()}
* @param fall
*/
public void setFall(Fall fall) { public void setFall(Fall fall) {
this.fallProperty.set(fall); this.fallProperty.set(fall);
} }


public SimpleObjectProperty<Fall> fallPropertyProperty() {
/**
* The case that is shown in this controller.
*/
public SimpleObjectProperty<Fall> fallProperty() {
return fallProperty; return fallProperty;
} }


/**
* State definitions.
*/
public enum State {
CREATE, EDIT, VIEW
}

/**
* Getter for the {@link #stateProperty()}.
*/
public State getState() { public State getState() {
return state.get(); return state.get();
} }


/**
* The controllers current state.
*/
public ReadOnlyObjectProperty<State> stateProperty() { public ReadOnlyObjectProperty<State> stateProperty() {
return state; return state;
} }


/**
* For showing the main diagnosis, the Controller also needs a pointer to the list of case diagnosis.
* @return
*/
public ObjectProperty<ObservableList<Diagnose>> diagnosenProperty() { public ObjectProperty<ObservableList<Diagnose>> diagnosenProperty() {
return fallHauptdiagnose.itemsProperty(); return fallHauptdiagnose.itemsProperty();
} }


/**
* Getter for the {@link #diagnosenProperty()}
*/
public ObservableList<Diagnose> getDiagnosen() { public ObservableList<Diagnose> getDiagnosen() {
return fallHauptdiagnose.getItems(); return fallHauptdiagnose.getItems();
} }


/**
* Setter for the diagnosis in the main diagnosis combo box.
* @see #diagnosenProperty()
*/
public void setDiagnosen(ObservableList<Diagnose> list) { public void setDiagnosen(ObservableList<Diagnose> list) {
fallHauptdiagnose.setItems(list); fallHauptdiagnose.setItems(list);
} }


/**
* FXMLLoaders initialize()-method.
*/
@FXML @FXML
public void initialize() {
private void initialize() {
fallEinweisenderArzt.disableProperty().bind(fallSelbsteinweisung.selectedProperty()); fallEinweisenderArzt.disableProperty().bind(fallSelbsteinweisung.selectedProperty());
fallFallart.setItems(FXCollections.observableArrayList(FallArt.values())); fallFallart.setItems(FXCollections.observableArrayList(FallArt.values()));
fallKasse.setItems(mainController.getStammdaten().getKassen()); fallKasse.setItems(mainController.getStammdaten().getKassen());
@@ -110,13 +145,13 @@ public class FallController {
initButtons(); initButtons();


fallFields.disableProperty().bind(state.isEqualTo(State.VIEW)); fallFields.disableProperty().bind(state.isEqualTo(State.VIEW));

fallProperty.addListener(((observable, oldValue, newValue) -> { fallProperty.addListener(((observable, oldValue, newValue) -> {
if (state.get() == State.VIEW) { if (state.get() == State.VIEW) {
copyFallDataIntoField(fallProperty.get()); copyFallDataIntoField(fallProperty.get());
} }
})); }));



fallHauptdiagnose.itemsProperty().addListener((observable1, oldValue1, newValue1) -> { fallHauptdiagnose.itemsProperty().addListener((observable1, oldValue1, newValue1) -> {
copyHauptdiagnoseToComboBox(fallProperty.get()); copyHauptdiagnoseToComboBox(fallProperty.get());
}); });
@@ -160,6 +195,10 @@ public class FallController {
btnFallSendHl7.visibleProperty().bind(btnFallSendHl7.managedProperty()); btnFallSendHl7.visibleProperty().bind(btnFallSendHl7.managedProperty());
} }



/**
* EventHandler for the {@link #btnFallSendHl7} button.
*/
@FXML @FXML
private void clickedSendHl7() { private void clickedSendHl7() {
/* Natascha */ /* Natascha */
@@ -175,17 +214,27 @@ public class FallController {
} }
} }


/**
* Toggle controller state to edit
*/
public void editFall() { public void editFall() {
this.state.set(State.EDIT); this.state.set(State.EDIT);
} }


/**
* EventHandler for {@link #btnFallEnableEdit}
*/
@FXML @FXML
void clickedFallEnableEdit(ActionEvent event) {
private void clickedFallEnableEdit() {
editFall(); editFall();
} }



/**
* EventHandler for the {@link #btnFallCancel}.
*/
@FXML @FXML
void clickedFallCancel(ActionEvent event) {
private void clickedFallCancel() {
if (fallProperty.get() != null) { if (fallProperty.get() != null) {
fallProperty.get().setStorniert(true); fallProperty.get().setStorniert(true);
try { try {
@@ -197,22 +246,34 @@ public class FallController {
} }
} }


/**
* EventHandler for the {@link #btnFallAbort}
*/
@FXML @FXML
void clickedFallAbort(ActionEvent event) {
private void clickedFallAbort() {
this.state.set(State.VIEW); this.state.set(State.VIEW);
copyFallDataIntoField(fallProperty.get()); copyFallDataIntoField(fallProperty.get());
} }



/**
* EventHandler for the {@link #btnFallSave} button.
*/
@FXML @FXML
void clickedFallSave(ActionEvent event) {
private void clickedFallSave() {
if (this.state.get() == State.CREATE) { if (this.state.get() == State.CREATE) {
Fall fall = new Fall(); Fall fall = new Fall();
copyFieldDataIntoFall(fall); copyFieldDataIntoFall(fall);
try { try {
int newfallid = DBHandler.setFall(fall, mainController.getCurrentMitarbeiter().getMitarbID()); int newfallid = DBHandler.setFall(fall, mainController.getCurrentMitarbeiter().getMitarbID());
fall.setFallID(newfallid); fall.setFallID(newfallid);

} catch (SQLException e) {
e.printStackTrace();
}
try {
HL7Sender.createMessageADT_A01(fall); HL7Sender.createMessageADT_A01(fall);
} catch (SQLException | HL7Exception | IOException e) {
}catch(IOException | HL7Exception | SQLException e){
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
@@ -229,6 +290,9 @@ public class FallController {
mainController.refreshCasesFromDb(mainController.getPatientTablesController().getSelectedPatient()); mainController.refreshCasesFromDb(mainController.getPatientTablesController().getSelectedPatient());
} }


/**
* Change the controllers state, init the fields for assistance.
*/
public void createNewFall() { public void createNewFall() {
clearFields(); clearFields();
this.state.set(State.CREATE); this.state.set(State.CREATE);
@@ -245,6 +309,10 @@ public class FallController {
fallVersichertennummer.setText(patient.getVersichertennummer()); fallVersichertennummer.setText(patient.getVersichertennummer());
} }



/**
* Clears the TextFields.
*/
private void clearFields() { private void clearFields() {
if (state.get() == State.CREATE) { if (state.get() == State.CREATE) {
dtTmAufnahme.setToCurrentDateTime(); dtTmAufnahme.setToCurrentDateTime();
@@ -254,7 +322,7 @@ public class FallController {
dtTmEntlassung.setDateTime(null); dtTmEntlassung.setDateTime(null);
} }


fallPatID.setText(""); //TODO
fallId.setText("");


fallCreateTime.setText(""); fallCreateTime.setText("");
fallCreator.setText(""); fallCreator.setText("");
@@ -273,6 +341,10 @@ public class FallController {
fallFallart.setValue(null); fallFallart.setValue(null);
} }


/**
* Copy the text entered in the views into a Fall object.
* @param fall The object for copying the data into.
*/
private void copyFieldDataIntoFall(Fall fall) { private void copyFieldDataIntoFall(Fall fall) {
fall.setPatient(mainController.getPatientTablesController().getSelectedPatient()); fall.setPatient(mainController.getPatientTablesController().getSelectedPatient());
fall.setAufnahmeDatum(dtTmAufnahme.getDateTime()); fall.setAufnahmeDatum(dtTmAufnahme.getDateTime());
@@ -293,12 +365,15 @@ public class FallController {
} }




//fall.setVorstellDatum(); //TODO
//fall.setVorstellDatum();
} }


/**
* Set the field values in the view to the value of the {@link Fall} object.
* @param fall The object whose data will be copied.
*/
private void copyFallDataIntoField(Fall fall) { private void copyFallDataIntoField(Fall fall) {
if (fall == null) { if (fall == null) {
System.out.println("copyFallDataIntoFiled - Fall ist null");
clearFields(); clearFields();
return; return;
} }
@@ -306,13 +381,15 @@ public class FallController {
dtTmAufnahme.setDateTime(fall.getAufnahmeDatum()); dtTmAufnahme.setDateTime(fall.getAufnahmeDatum());
dtTmEntlassung.setDateTime(fall.getEntlassungsDatum()); dtTmEntlassung.setDateTime(fall.getEntlassungsDatum());


fallPatID.setText(fallProperty.get().getPatient() + ""); //(fall.getPatient().getVorname()+" "+fall.getPatient().getNachname()); //TODO
fallId.setText(fall.getFallID() + ""); //(fall.getPatient().getVorname()+" "+fall.getPatient().getNachname()); //TODO


fallCreateTime.setText(fall.getErstellDatumZeit() != null ? fall.getErstellDatumZeit().toString() : ""); fallCreateTime.setText(fall.getErstellDatumZeit() != null ? fall.getErstellDatumZeit().toString() : "");
fallCreator.setText(Integer.toString(fall.getErsteller())); fallCreator.setText(Integer.toString(fall.getErsteller()));
fallEditTime.setText(fall.getBearbeitetDatumZeit() != null ? fall.getBearbeitetDatumZeit().toString() : ""); fallEditTime.setText(fall.getBearbeitetDatumZeit() != null ? fall.getBearbeitetDatumZeit().toString() : "");
fallEditor.setText(Integer.toString(fall.getBearbeiter())); fallEditor.setText(Integer.toString(fall.getBearbeiter()));




fallEinweisenderArzt.setText(fall.getEinweisenderArzt()); fallEinweisenderArzt.setText(fall.getEinweisenderArzt());
fallSelbsteinweisung.setSelected(fall.getSelbsteinweisung()); fallSelbsteinweisung.setSelected(fall.getSelbsteinweisung());


@@ -324,27 +401,27 @@ public class FallController {
fallFallart.setValue(fall.getFallArt()); fallFallart.setValue(fall.getFallArt());
} }



/**
* This method sets the main diagnosis in the ComboBox
* @param fall The case whose main diagnosis will be picked
*/
private void copyHauptdiagnoseToComboBox(Fall fall) { private void copyHauptdiagnoseToComboBox(Fall fall) {
if (fallHauptdiagnose.getItems() == null if (fallHauptdiagnose.getItems() == null
|| fall == null) { || fall == null) {
fallHauptdiagnose.setValue(null); fallHauptdiagnose.setValue(null);
return; return;
} }
System.out.println("Suche Diagnose...");


for (Diagnose diagnose : fallHauptdiagnose.getItems()) { for (Diagnose diagnose : fallHauptdiagnose.getItems()) {
System.out.println(diagnose.getDiagID() + "=" + fall.getHauptdiagnoseId()); System.out.println(diagnose.getDiagID() + "=" + fall.getHauptdiagnoseId());
if (diagnose.getDiagID() == fall.getHauptdiagnoseId()) { if (diagnose.getDiagID() == fall.getHauptdiagnoseId()) {
fallHauptdiagnose.getSelectionModel().select(diagnose); fallHauptdiagnose.getSelectionModel().select(diagnose);
System.out.println("Diagnose wiedergefunden!!");
return; return;
} }
} }
} }


public enum State {
CREATE, EDIT, VIEW
}




} }

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

@@ -248,7 +248,7 @@ public class MainController {


lvFall.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); lvFall.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);


fallController.fallPropertyProperty().bind(lvFall.getSelectionModel().selectedItemProperty());
fallController.fallProperty().bind(lvFall.getSelectionModel().selectedItemProperty());




lvFall.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { lvFall.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {


+ 2
- 2
src/main/resources/fall.fxml View File

@@ -10,8 +10,8 @@
<children> <children>
<GridPane vgap="5.0" fx:id="fallFields" styleClass="fields"> <GridPane vgap="5.0" fx:id="fallFields" styleClass="fields">
<children> <children>
<Label text="Patient:"/>
<Label fx:id="fallPatID" text="John Doe (PatID = XXX)" GridPane.columnIndex="1"/>
<Label text="Fallnummer:"/>
<Label fx:id="fallId" text="" GridPane.columnIndex="1"/>


<Label text="Aufnahmedatum:" GridPane.rowIndex="1"/> <Label text="Aufnahmedatum:" GridPane.rowIndex="1"/>
<DateTimePicker GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="dtTmAufnahme"/> <DateTimePicker GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="dtTmAufnahme"/>


Loading…
Cancel
Save