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