| @@ -23,39 +23,21 @@ public class PatientEditorController { | |||
| */ | |||
| private Patient patient = null; | |||
| /** | |||
| * The superior controller | |||
| */ | |||
| private MainController mainController; | |||
| @FXML | |||
| private Label patChangeTime; | |||
| @FXML | |||
| private Label patChanger; | |||
| @FXML | |||
| private Label patCreator; | |||
| @FXML | |||
| private Label patCreateTime; | |||
| private Label patChangeTime, patChanger, patCreator, patCreateTime; | |||
| @FXML | |||
| private Label patId; | |||
| @FXML | |||
| private TextField patVorname; | |||
| @FXML | |||
| private TextField patGeburtsname; | |||
| @FXML | |||
| private TextField patNachname; | |||
| @FXML | |||
| private TextField patTelefonnummer; | |||
| @FXML | |||
| private TextField patStrasse; | |||
| private TextField patVorname, patGeburtsname, patNachname, patTelefonnummer, patStrasse, patHausnummer, patPlz, | |||
| patOrt, patVersicherungsnummer; | |||
| @FXML | |||
| private TextField patHausnummer; | |||
| @FXML | |||
| private TextField patPlz; | |||
| @FXML | |||
| private TextField patOrt; | |||
| private TextArea patCave; | |||
| @FXML | |||
| private DatePicker patGeburtsdatum; | |||
| @@ -65,30 +47,35 @@ public class PatientEditorController { | |||
| private ComboBox<Patient.Geschlecht> patGeschlecht; | |||
| @FXML | |||
| private TextField patVersicherungsnummer; | |||
| @FXML | |||
| private ComboBox<Kasse> patVersicherung; | |||
| @FXML | |||
| private TextArea patCave; | |||
| @FXML | |||
| private Button btnPatAbort; | |||
| @FXML | |||
| private Button btnPatSave; | |||
| private Button btnPatAbort, btnPatSave; | |||
| /** | |||
| * The constructor. | |||
| * @param mainController | |||
| */ | |||
| public PatientEditorController(MainController mainController) { | |||
| this.mainController = mainController; | |||
| } | |||
| /** | |||
| * FXMLLoaders initialize()-method | |||
| */ | |||
| @FXML | |||
| public void initialize() { | |||
| private void initialize() { | |||
| patGeschlecht.setItems(FXCollections.observableArrayList(Patient.Geschlecht.values())); | |||
| patFamilienstand.setItems(FXCollections.observableArrayList(Patient.Familienstand.values())); | |||
| patVersicherung.setItems(mainController.getStammdaten().getKassen()); | |||
| } | |||
| /** | |||
| * Sets the patient that is shown in this view. | |||
| * @param patient The patient to be edited, or null if a new patient shall be created. | |||
| */ | |||
| public void setPatient(Patient patient) { | |||
| this.patient = patient; | |||
| if (patient == null) { | |||
| @@ -99,6 +86,7 @@ public class PatientEditorController { | |||
| } | |||
| private void copyPatientDataIntoFields() { | |||
| patId.setText(Integer.toString(patient.getPatID())); | |||
| patGeburtsname.setText(patient.getGeburtsname()); | |||
| @@ -127,6 +115,11 @@ public class PatientEditorController { | |||
| patChangeTime.setText(patient.getBearbeitetDatumZeit().toString()); | |||
| } | |||
| /** | |||
| * Shows alert dialog if data is invalid | |||
| * @param title the alert's header text. | |||
| * @param message the alert's content text. | |||
| */ | |||
| private void showMessage(String title, String message) { | |||
| Alert alert = new Alert(Alert.AlertType.INFORMATION); | |||
| alert.setTitle("Ung\u00fcltige Daten!"); | |||
| @@ -136,8 +129,10 @@ public class PatientEditorController { | |||
| alert.showAndWait(); | |||
| } | |||
| /** | |||
| * Copies the data entered in the fields into patient object. | |||
| */ | |||
| private void copyFieldDataIntoPatient(Patient patient) { | |||
| patient.setGeburtsname(patGeburtsname.getText()); | |||
| patient.setNachname(patNachname.getText()); | |||
| patient.setVorname(patVorname.getText()); | |||
| @@ -156,12 +151,32 @@ public class PatientEditorController { | |||
| } | |||
| /** | |||
| * Validates the data in the fields. Makes alerts if data not valid. | |||
| * @return true if data is valid, false otherwise. | |||
| */ | |||
| private boolean validateData() { | |||
| if (!patPlz.getText().matches("[0-9]{5}") && !(patPlz.getText().length() == 0)) { | |||
| showMessage("Die eingegebene PLZ ist ung\u00fcltig!", | |||
| "Postleitzahlen m\u00fcssen aus exakt 5 Ziffern bestehen!"); | |||
| return false; | |||
| } | |||
| if(patNachname.getText()==null || patNachname.getText().isEmpty()){ | |||
| showMessage("Nachname ist leer", "Es muss ein Nachname eingegeben werden!"); | |||
| return false; | |||
| } | |||
| if(patVorname.getText()==null || patVorname.getText().isEmpty()){ | |||
| showMessage("Vorname ist leer", "Es muss ein Vorname eingegeben werden!"); | |||
| return false; | |||
| } | |||
| if(patGeburtsdatum.getValue()==null || patGeburtsdatum.getValue().isAfter(LocalDate.now().plusMonths(1))){ | |||
| showMessage("Geburtsdatum ist ung\u00fcltig", "Das Geburtsdatum ist nicht gesetzt oder liegt zuweit in der Zukunft!"); | |||
| return false; | |||
| } | |||
| if(patVersicherung.getValue()==null){ | |||
| showMessage("Es ist keine Kasse ausgew\u00e4hlt!", "Bitte eine Kassse aus der List w\u00e4hle"); | |||
| return false; | |||
| } | |||
| return true; | |||
| } | |||
| @@ -169,7 +184,7 @@ public class PatientEditorController { | |||
| // TODO: Remove default values. | |||
| private void clearFields() { | |||
| patId.setText("<auto>"); | |||
| patId.setText(""); | |||
| patGeburtsname.setText(""); | |||
| patNachname.setText(""); | |||
| patVorname.setText(""); | |||
| @@ -185,14 +200,17 @@ public class PatientEditorController { | |||
| patVersicherung.setValue(null); | |||
| patCave.setText(""); | |||
| patCreator.setText("todo"); | |||
| patCreateTime.setText("<auto>"); | |||
| patChanger.setText("todo"); | |||
| patChangeTime.setText("<auto>"); | |||
| patCreator.setText(""); | |||
| patCreateTime.setText(""); | |||
| patChanger.setText(""); | |||
| patChangeTime.setText(""); | |||
| } | |||
| /** | |||
| * | |||
| */ | |||
| @FXML | |||
| void clickedSave(ActionEvent event) { | |||
| private void clickedSave() { | |||
| if (!validateData()) { | |||
| return; | |||
| } | |||
| @@ -219,7 +237,7 @@ public class PatientEditorController { | |||
| } | |||
| @FXML | |||
| void clickedAbort(ActionEvent event) { | |||
| private void clickedAbort() { | |||
| ((Stage) patVorname.getScene().getWindow()).close(); //Close Window | |||
| } | |||