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 {

SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);
@FXML
Button btnFallSendHl7;
private MainController mainController;
@FXML
private DateTimePicker dtTmAufnahme, dtTmEntlassung;
@FXML
private Label fallPatID;
private Label fallId;
@FXML
private ComboBox<FallArt> fallFallart;
@FXML
private ComboBox<Kasse> fallKasse;
@FXML
private TextField fallVersichertennummer;
@FXML
private TextField fallEinweisenderArzt;
private TextField fallVersichertennummer, fallEinweisenderArzt;
@FXML
private CheckBox fallSelbsteinweisung;
@FXML
private ComboBox<Diagnose> fallHauptdiagnose;
@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
private Button btnFallAbort;
@FXML
private Button btnFallCancel;
@FXML
private Button btnFallEnableEdit;
private Button btnFallSave, btnFallAbort, btnFallCancel, btnFallEnableEdit, btnFallSendHl7;
@FXML
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) {
this.mainController = mainController;
}


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

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

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

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

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

/**
* The controllers current state.
*/
public ReadOnlyObjectProperty<State> stateProperty() {
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() {
return fallHauptdiagnose.itemsProperty();
}

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

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

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

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

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


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


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

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

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


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

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


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

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

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


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

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

fallCreateTime.setText("");
fallCreator.setText("");
@@ -273,6 +341,10 @@ public class FallController {
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) {
fall.setPatient(mainController.getPatientTablesController().getSelectedPatient());
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) {
if (fall == null) {
System.out.println("copyFallDataIntoFiled - Fall ist null");
clearFields();
return;
}
@@ -306,13 +381,15 @@ public class FallController {
dtTmAufnahme.setDateTime(fall.getAufnahmeDatum());
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() : "");
fallCreator.setText(Integer.toString(fall.getErsteller()));
fallEditTime.setText(fall.getBearbeitetDatumZeit() != null ? fall.getBearbeitetDatumZeit().toString() : "");
fallEditor.setText(Integer.toString(fall.getBearbeiter()));



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

@@ -324,27 +401,27 @@ public class FallController {
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) {
if (fallHauptdiagnose.getItems() == null
|| fall == null) {
fallHauptdiagnose.setValue(null);
return;
}
System.out.println("Suche Diagnose...");

for (Diagnose diagnose : fallHauptdiagnose.getItems()) {
System.out.println(diagnose.getDiagID() + "=" + fall.getHauptdiagnoseId());
if (diagnose.getDiagID() == fall.getHauptdiagnoseId()) {
fallHauptdiagnose.getSelectionModel().select(diagnose);
System.out.println("Diagnose wiedergefunden!!");
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);

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


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


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

@@ -10,8 +10,8 @@
<children>
<GridPane vgap="5.0" fx:id="fallFields" styleClass="fields">
<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"/>
<DateTimePicker GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="dtTmAufnahme"/>


Loading…
Cancel
Save