| @@ -23,39 +23,21 @@ public class PatientEditorController { | |||||
| */ | */ | ||||
| private Patient patient = null; | private Patient patient = null; | ||||
| /** | |||||
| * The superior controller | |||||
| */ | |||||
| private MainController mainController; | private MainController mainController; | ||||
| @FXML | @FXML | ||||
| private Label patChangeTime; | |||||
| @FXML | |||||
| private Label patChanger; | |||||
| @FXML | |||||
| private Label patCreator; | |||||
| @FXML | |||||
| private Label patCreateTime; | |||||
| private Label patChangeTime, patChanger, patCreator, patCreateTime; | |||||
| @FXML | @FXML | ||||
| private Label patId; | private Label patId; | ||||
| @FXML | |||||
| private TextField patVorname; | |||||
| @FXML | |||||
| private TextField patGeburtsname; | |||||
| @FXML | |||||
| private TextField patNachname; | |||||
| @FXML | |||||
| private TextField patTelefonnummer; | |||||
| @FXML | @FXML | ||||
| private TextField patStrasse; | |||||
| private TextField patVorname, patGeburtsname, patNachname, patTelefonnummer, patStrasse, patHausnummer, patPlz, | |||||
| patOrt, patVersicherungsnummer; | |||||
| @FXML | @FXML | ||||
| private TextField patHausnummer; | |||||
| @FXML | |||||
| private TextField patPlz; | |||||
| @FXML | |||||
| private TextField patOrt; | |||||
| private TextArea patCave; | |||||
| @FXML | @FXML | ||||
| private DatePicker patGeburtsdatum; | private DatePicker patGeburtsdatum; | ||||
| @@ -65,30 +47,35 @@ public class PatientEditorController { | |||||
| private ComboBox<Patient.Geschlecht> patGeschlecht; | private ComboBox<Patient.Geschlecht> patGeschlecht; | ||||
| @FXML | @FXML | ||||
| private TextField patVersicherungsnummer; | |||||
| @FXML | |||||
| private ComboBox<Kasse> patVersicherung; | private ComboBox<Kasse> patVersicherung; | ||||
| @FXML | @FXML | ||||
| private TextArea patCave; | |||||
| @FXML | |||||
| private Button btnPatAbort; | |||||
| @FXML | |||||
| private Button btnPatSave; | |||||
| private Button btnPatAbort, btnPatSave; | |||||
| /** | |||||
| * The constructor. | |||||
| * @param mainController | |||||
| */ | |||||
| public PatientEditorController(MainController mainController) { | public PatientEditorController(MainController mainController) { | ||||
| this.mainController = mainController; | this.mainController = mainController; | ||||
| } | } | ||||
| /** | |||||
| * FXMLLoaders initialize()-method | |||||
| */ | |||||
| @FXML | @FXML | ||||
| public void initialize() { | |||||
| private 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()); | ||||
| } | } | ||||
| /** | |||||
| * 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) { | public void setPatient(Patient patient) { | ||||
| this.patient = patient; | this.patient = patient; | ||||
| if (patient == null) { | if (patient == null) { | ||||
| @@ -99,6 +86,7 @@ public class PatientEditorController { | |||||
| } | } | ||||
| 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()); | ||||
| @@ -127,6 +115,11 @@ public class PatientEditorController { | |||||
| patChangeTime.setText(patient.getBearbeitetDatumZeit().toString()); | 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) { | 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!"); | ||||
| @@ -136,8 +129,10 @@ public class PatientEditorController { | |||||
| alert.showAndWait(); | alert.showAndWait(); | ||||
| } | } | ||||
| /** | |||||
| * Copies the data entered in the fields into patient object. | |||||
| */ | |||||
| 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()); | ||||
| patient.setVorname(patVorname.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() { | private boolean validateData() { | ||||
| if (!patPlz.getText().matches("[0-9]{5}") && !(patPlz.getText().length() == 0)) { | if (!patPlz.getText().matches("[0-9]{5}") && !(patPlz.getText().length() == 0)) { | ||||
| 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; | ||||
| } | } | ||||
| 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; | return true; | ||||
| } | } | ||||
| @@ -169,7 +184,7 @@ public class PatientEditorController { | |||||
| // TODO: Remove default values. | // TODO: Remove default values. | ||||
| private void clearFields() { | private void clearFields() { | ||||
| patId.setText("<auto>"); | |||||
| patId.setText(""); | |||||
| patGeburtsname.setText(""); | patGeburtsname.setText(""); | ||||
| patNachname.setText(""); | patNachname.setText(""); | ||||
| patVorname.setText(""); | patVorname.setText(""); | ||||
| @@ -185,14 +200,17 @@ public class PatientEditorController { | |||||
| patVersicherung.setValue(null); | patVersicherung.setValue(null); | ||||
| patCave.setText(""); | patCave.setText(""); | ||||
| patCreator.setText("todo"); | |||||
| patCreateTime.setText("<auto>"); | |||||
| patChanger.setText("todo"); | |||||
| patChangeTime.setText("<auto>"); | |||||
| patCreator.setText(""); | |||||
| patCreateTime.setText(""); | |||||
| patChanger.setText(""); | |||||
| patChangeTime.setText(""); | |||||
| } | } | ||||
| /** | |||||
| * | |||||
| */ | |||||
| @FXML | @FXML | ||||
| void clickedSave(ActionEvent event) { | |||||
| private void clickedSave() { | |||||
| if (!validateData()) { | if (!validateData()) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -219,7 +237,7 @@ public class PatientEditorController { | |||||
| } | } | ||||
| @FXML | @FXML | ||||
| void clickedAbort(ActionEvent event) { | |||||
| private void clickedAbort() { | |||||
| ((Stage) patVorname.getScene().getWindow()).close(); //Close Window | ((Stage) patVorname.getScene().getWindow()).close(); //Close Window | ||||
| } | } | ||||