| @@ -8,9 +8,9 @@ import de.uniluebeck.mi.projmi6.db.DBHandler; | |||||
| import de.uniluebeck.mi.projmi6.model.Kasse; | import de.uniluebeck.mi.projmi6.model.Kasse; | ||||
| import de.uniluebeck.mi.projmi6.model.Patient; | import de.uniluebeck.mi.projmi6.model.Patient; | ||||
| import javafx.collections.FXCollections; | import javafx.collections.FXCollections; | ||||
| import javafx.event.ActionEvent; | |||||
| import javafx.fxml.FXML; | import javafx.fxml.FXML; | ||||
| import javafx.scene.control.*; | import javafx.scene.control.*; | ||||
| import javafx.event.ActionEvent; | |||||
| import javafx.stage.Stage; | import javafx.stage.Stage; | ||||
| import java.sql.SQLException; | import java.sql.SQLException; | ||||
| @@ -75,32 +75,28 @@ public class PatientEditorController { | |||||
| private Button btnPatSave; | private Button btnPatSave; | ||||
| public PatientEditorController(MainController mainController) { | |||||
| this.mainController = mainController; | |||||
| } | |||||
| @FXML | @FXML | ||||
| public void initialize(){ | |||||
| public void initialize() { | |||||
| patGeschlecht.setItems(FXCollections.observableArrayList(Patient.Geschlecht.values())); | patGeschlecht.setItems(FXCollections.observableArrayList(Patient.Geschlecht.values())); | ||||
| patFamilienstand.setItems(FXCollections.observableArrayList(Patient.Familienstand.values())); | patFamilienstand.setItems(FXCollections.observableArrayList(Patient.Familienstand.values())); | ||||
| patVersicherung.setItems(mainController.getStammdaten().getKassen()); | patVersicherung.setItems(mainController.getStammdaten().getKassen()); | ||||
| } | } | ||||
| public PatientEditorController(MainController mainController){ | |||||
| this.mainController = mainController; | |||||
| } | |||||
| public void setPatient(Patient patient){ | |||||
| public void setPatient(Patient patient) { | |||||
| this.patient = patient; | this.patient = patient; | ||||
| if(patient==null){ | |||||
| if (patient == null) { | |||||
| clearFields(); | clearFields(); | ||||
| }else { | |||||
| } else { | |||||
| copyPatientDataIntoFields(); | copyPatientDataIntoFields(); | ||||
| } | } | ||||
| } | } | ||||
| private void copyPatientDataIntoFields(){ | |||||
| private void copyPatientDataIntoFields() { | |||||
| patId.setText(Integer.toString(patient.getPatID())); | patId.setText(Integer.toString(patient.getPatID())); | ||||
| patGeburtsname.setText(patient.getGeburtsname()); | patGeburtsname.setText(patient.getGeburtsname()); | ||||
| patNachname.setText(patient.getNachname()); | patNachname.setText(patient.getNachname()); | ||||
| @@ -113,7 +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()); | ||||
| // patVersicherung.setValue(patient.getVersicherung()); TODO | |||||
| for (Kasse kasse : patVersicherung.getItems()) | |||||
| if (kasse.getKassenID() == patient.getKassenID()) { | |||||
| patVersicherung.getSelectionModel().select(kasse); | |||||
| break; | |||||
| } | |||||
| patCave.setText(patient.getCave()); | patCave.setText(patient.getCave()); | ||||
| patCreator.setText(Integer.toString(patient.getErsteller())); | patCreator.setText(Integer.toString(patient.getErsteller())); | ||||
| @@ -122,7 +123,7 @@ public class PatientEditorController { | |||||
| patChangeTime.setText(patient.getBearbeitetDatumZeit().toString()); | patChangeTime.setText(patient.getBearbeitetDatumZeit().toString()); | ||||
| } | } | ||||
| private void showMessage(String title, String message){ | |||||
| private void showMessage(String title, String message) { | |||||
| Alert alert = new Alert(Alert.AlertType.INFORMATION); | Alert alert = new Alert(Alert.AlertType.INFORMATION); | ||||
| alert.setTitle("Ung\u00fcltige Daten!"); | alert.setTitle("Ung\u00fcltige Daten!"); | ||||
| alert.setHeaderText(title); | alert.setHeaderText(title); | ||||
| @@ -131,7 +132,7 @@ public class PatientEditorController { | |||||
| alert.showAndWait(); | alert.showAndWait(); | ||||
| } | } | ||||
| private void copyFieldDataIntoPatient(Patient patient){ | |||||
| private void copyFieldDataIntoPatient(Patient patient) { | |||||
| patient.setGeburtsname(patGeburtsname.getText()); | patient.setGeburtsname(patGeburtsname.getText()); | ||||
| patient.setNachname(patNachname.getText()); | patient.setNachname(patNachname.getText()); | ||||
| @@ -144,13 +145,13 @@ public class PatientEditorController { | |||||
| patient.setFamilienstand(patFamilienstand.getValue()); | patient.setFamilienstand(patFamilienstand.getValue()); | ||||
| patient.setGeschlecht(patient.getGeschlecht()); | patient.setGeschlecht(patient.getGeschlecht()); | ||||
| patient.setVersichertennummer(patVersicherungsnummer.getText()); | patient.setVersichertennummer(patVersicherungsnummer.getText()); | ||||
| //patient.setVersicherung TODO | |||||
| patient.setKassenID(patVersicherung.getSelectionModel().getSelectedItem().getKassenID()); | |||||
| patient.setCave(patCave.getText()); | patient.setCave(patCave.getText()); | ||||
| } | } | ||||
| private boolean validateData(){ | |||||
| if(!patPlz.getText().matches("[0-9]{5}")){ | |||||
| private boolean validateData() { | |||||
| if (!patPlz.getText().matches("[0-9]{5}")) { | |||||
| showMessage("Die eingegebene PLZ ist ung\u00fcltig!", | showMessage("Die eingegebene PLZ ist ung\u00fcltig!", | ||||
| "Postleitzahlen m\u00fcssen aus exakt 5 Ziffern bestehen!"); | "Postleitzahlen m\u00fcssen aus exakt 5 Ziffern bestehen!"); | ||||
| return false; | return false; | ||||
| @@ -161,7 +162,7 @@ public class PatientEditorController { | |||||
| // TODO: Remove default values. | // TODO: Remove default values. | ||||
| private void clearFields(){ | |||||
| private void clearFields() { | |||||
| patId.setText("<auto>"); | patId.setText("<auto>"); | ||||
| patGeburtsname.setText(""); | patGeburtsname.setText(""); | ||||
| patNachname.setText("Peter"); | patNachname.setText("Peter"); | ||||
| @@ -185,11 +186,11 @@ public class PatientEditorController { | |||||
| @FXML | @FXML | ||||
| void clickedSave(ActionEvent event) { | void clickedSave(ActionEvent event) { | ||||
| if(!validateData()){ | |||||
| if (!validateData()) { | |||||
| return; | return; | ||||
| } | } | ||||
| if(patient==null){ | |||||
| if (patient == null) { | |||||
| patient = new Patient(); | patient = new Patient(); | ||||
| copyFieldDataIntoPatient(patient); | copyFieldDataIntoPatient(patient); | ||||
| try { | try { | ||||
| @@ -197,7 +198,7 @@ public class PatientEditorController { | |||||
| } catch (SQLException e) { | } catch (SQLException e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| }else{ | |||||
| } else { | |||||
| copyFieldDataIntoPatient(patient); | copyFieldDataIntoPatient(patient); | ||||
| try { | try { | ||||
| DBHandler.updatePatient(patient, mainController.getCurrentMitarbeiter().getMitarbID()); | DBHandler.updatePatient(patient, mainController.getCurrentMitarbeiter().getMitarbID()); | ||||
| @@ -205,12 +206,12 @@ public class PatientEditorController { | |||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| } | } | ||||
| ((Stage)patNachname.getScene().getWindow()).close(); | |||||
| ((Stage) patNachname.getScene().getWindow()).close(); | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| void clickedAbort(ActionEvent event) { | void clickedAbort(ActionEvent event) { | ||||
| ((Stage)patVorname.getScene().getWindow()).close(); //Close Window | |||||
| ((Stage) patVorname.getScene().getWindow()).close(); //Close Window | |||||
| } | } | ||||
| } | } | ||||