diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java index 46566c8..c6514f9 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/FallController.java @@ -4,7 +4,9 @@ package de.uniluebeck.mi.projmi6.controller; * Created by 631806 on 12.11.15. */ +import ca.uhn.hl7v2.HL7Exception; import de.uniluebeck.mi.projmi6.db.DBHandler; +import de.uniluebeck.mi.projmi6.hapi.HL7Sender; import de.uniluebeck.mi.projmi6.model.*; import de.uniluebeck.mi.projmi6.view.DateTimePicker; import javafx.beans.property.ObjectProperty; @@ -14,48 +16,34 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ComboBox; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; +import javafx.scene.control.*; import javafx.scene.layout.GridPane; +import java.io.IOException; import java.sql.SQLException; public class FallController { + SimpleObjectProperty state = new SimpleObjectProperty<>(State.VIEW); + @FXML + Button btnFallSendHl7; private MainController mainController; - - public FallController (MainController mainController){ - this.mainController = mainController; - } - @FXML private DateTimePicker dtTmAufnahme, dtTmEntlassung; - @FXML private Label fallPatID; - @FXML private ComboBox fallFallart; - @FXML private ComboBox fallKasse; - @FXML private TextField fallVersichertennummer; - @FXML private TextField fallEinweisenderArzt; @FXML private CheckBox fallSelbsteinweisung; - - @FXML private ComboBox fallHauptdiagnose; - - @FXML private Label fallCreator; @FXML @@ -66,34 +54,30 @@ public class FallController { private Label fallEditTime; @FXML private Button btnFallSave; - @FXML private Button btnFallAbort; @FXML private Button btnFallCancel; @FXML private Button btnFallEnableEdit; - @FXML private GridPane fallFields; - - private SimpleObjectProperty fallProperty = new SimpleObjectProperty<>(); - public Fall getFall() { - return fallProperty.get(); + public FallController(MainController mainController) { + this.mainController = mainController; } - public SimpleObjectProperty fallPropertyProperty() { - return fallProperty; + public Fall getFall() { + return fallProperty.get(); } public void setFall(Fall fall) { this.fallProperty.set(fall); } - public enum State { - CREATE, EDIT, VIEW + public SimpleObjectProperty fallPropertyProperty() { + return fallProperty; } public State getState() { @@ -104,12 +88,6 @@ public class FallController { return state; } - - - SimpleObjectProperty state = new SimpleObjectProperty<>(State.VIEW); - - - public ObjectProperty> diagnosenProperty(){ return fallHauptdiagnose.itemsProperty(); } @@ -184,21 +162,24 @@ public class FallController { } @FXML - Button btnFallSendHl7; - - @FXML private void clickedSendHl7(){ /* Natascha */ //TODO send funny message - Fall fall = fallProperty.get(); Patient patient = mainController.getPatientTablesController().getSelectedPatient(); + Fall fall = fallProperty.get(); + fall.setPatient(patient); + + try { + HL7Sender.createMessageADT_A01(fall); + } catch (HL7Exception | IOException | SQLException e) { + e.printStackTrace(); + } } public void editFall(){ this.state.set(State.EDIT); } - @FXML void clickedFallEnableEdit(ActionEvent event) { editFall(); @@ -206,11 +187,11 @@ public class FallController { @FXML void clickedFallCancel(ActionEvent event) { - if(fallProperty.get()!=null){ + if (fallProperty.get() != null) { fallProperty.get().setStorniert(true); try { DBHandler.setFall(fallProperty.get(), mainController.getCurrentMitarbeiter().getMitarbID(), true); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } mainController.refreshCasesFromDb(mainController.getPatientTablesController().getSelectedPatient()); @@ -263,9 +244,6 @@ public class FallController { fallVersichertennummer.setText(patient.getVersichertennummer()); } - - - private void clearFields(){ if(state.get() == State.CREATE) { dtTmAufnahme.setToCurrentDateTime(); @@ -294,7 +272,6 @@ public class FallController { fallFallart.setValue(null); } - private void copyFieldDataIntoFall(Fall fall){ fall.setPatient(mainController.getPatientTablesController().getSelectedPatient()); fall.setAufnahmeDatum(dtTmAufnahme.getDateTime()); @@ -319,7 +296,6 @@ public class FallController { //fall.setVorstellDatum(); //TODO } - private void copyFallDataIntoField(Fall fall){ if(fall==null){ System.out.println("copyFallDataIntoFiled - Fall ist null"); @@ -366,6 +342,10 @@ public class FallController { } } + public enum State { + CREATE, EDIT, VIEW + } + } diff --git a/src/main/java/de/uniluebeck/mi/projmi6/hapi/HL7Sender.java b/src/main/java/de/uniluebeck/mi/projmi6/hapi/HL7Sender.java index cbebf12..630762f 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/hapi/HL7Sender.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/hapi/HL7Sender.java @@ -13,7 +13,6 @@ import ca.uhn.hl7v2.model.v251.message.ADT_A01; import ca.uhn.hl7v2.model.v251.segment.*; import ca.uhn.hl7v2.parser.Parser; import ca.uhn.hl7v2.parser.PipeParser; -import ca.uhn.hl7v2.validation.ValidationContext; import ca.uhn.hl7v2.validation.impl.ValidationContextFactory; import de.uniluebeck.mi.projmi6.Main; import de.uniluebeck.mi.projmi6.model.Diagnose; @@ -41,7 +40,7 @@ public class HL7Sender { * @param fall nach dem Erstellen eines neuen Falls wird diese Methode aufgerufen um Hl7 Nachricht zu erzeugen * @throws Exception */ - public void createMessageADTA01( Fall fall) throws HL7Exception, IOException, SQLException { + public static void createMessageADT_A01(Fall fall) throws HL7Exception, IOException, SQLException { Patient patient = fall.getPatient (); ADT_A01 adt = new ADT_A01 (); @@ -87,7 +86,7 @@ public class HL7Sender { DG1 dg1Segment = adt.getDG1 (); dg1Segment.getDg11_SetIDDG1 ().parse ( String.valueOf ( i ) ); dg1Segment.getDg13_DiagnosisCodeDG1 ().getIdentifier ().parse ( diagnose.getIcd10code ().getCode () ); - dg1Segment.getDg116_DiagnosingClinician ()[0].parse ( diagnose.getArzt ().getEinweisenderArzt () ); + // dg1Segment.getDg116_DiagnosingClinician ()[0].parse ( diagnose.getArzt ().getEinweisenderArzt () ); dg1Segment.getDg14_DiagnosisDescription ().parse ( diagnose.getFreiText () ); dg1Segment.getDg16_DiagnosisType ().parse ( diagnose.getDiagArt ().toString () ); adt.getDG1All ().add ( dg1Segment ); @@ -96,11 +95,11 @@ public class HL7Sender { } } - printXMLEncodedMessageADT(adt); + sendMessage(adt); } - public void sendMessage(Message message){ + private static void sendMessage(Message message) { /* * The following section of code establishes a server listening * on port 1011 for new connections, and then "handles" them by @@ -186,7 +185,7 @@ public class HL7Sender { public void validateMessage(Message msg) { HapiContext context = new DefaultHapiContext(); - context.setValidationContext( ValidationContextFactory.defaultValidation()); + context.setValidationContext(ValidationContextFactory.defaultValidation()); PipeParser parser = context.getPipeParser(); try { parser.encode(msg);