| @@ -167,6 +167,41 @@ public class DiagnoseController { | |||||
| } | } | ||||
| /** | |||||
| * Alert dialog when the data entered is invalid. | |||||
| */ | |||||
| private void showMessage(String title, String message) { | |||||
| Alert alert = new Alert(Alert.AlertType.INFORMATION); | |||||
| alert.setTitle("Diagnosedaten unvollst\u00e4ndig!"); | |||||
| alert.setHeaderText(title); | |||||
| alert.setContentText(message); | |||||
| alert.showAndWait(); | |||||
| } | |||||
| /** | |||||
| * Checks if doctor, icd10-code and Diagnoseart are set. | |||||
| */ | |||||
| private boolean validateData(Diagnose diagnose){ | |||||
| if(diagnose.getArzt()==null){ | |||||
| showMessage("Arzt nicht angegeben!","Bitte den Arzt, der die Diagnose erstellt hat, aus der List ausw\u00e4hlen!"); | |||||
| return false; | |||||
| } | |||||
| if(diagnose.getDiagArt()==null){ | |||||
| showMessage("Diagnoseart nicht angegeben!", "Bitte die Art der Diagnose angeben!"); | |||||
| return false; | |||||
| } | |||||
| if(diagnose.getIcd10code()==null){ | |||||
| showMessage("Die Diagnose hat keinen ICD-10-Code!", "Bitte einen ICD-10-Code angeben!"); | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| /** | /** | ||||
| * Bind button visibility to application state. | * Bind button visibility to application state. | ||||
| */ | */ | ||||
| @@ -229,6 +264,9 @@ public class DiagnoseController { | |||||
| //Create new diagnosis | //Create new diagnosis | ||||
| Diagnose diagnose = new Diagnose(); | Diagnose diagnose = new Diagnose(); | ||||
| copyFieldDataIntoDiagnose(diagnose); | copyFieldDataIntoDiagnose(diagnose); | ||||
| if(!validateData(diagnose)){ | |||||
| return; | |||||
| } | |||||
| try { | try { | ||||
| DBHandler.setDiagnose(diagnose); | DBHandler.setDiagnose(diagnose); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||