diff --git a/RIS/src/main/java/aasim/ris/Rad.java b/RIS/src/main/java/aasim/ris/Rad.java index 51669b8..f0052f1 100644 --- a/RIS/src/main/java/aasim/ris/Rad.java +++ b/RIS/src/main/java/aasim/ris/Rad.java @@ -47,6 +47,7 @@ import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; +import javafx.scene.control.Alert; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; import javafx.scene.control.TextArea; @@ -382,6 +383,14 @@ public void handle(ActionEvent e) { confirm.setOnAction(new EventHandler() { @Override public void handle(ActionEvent e) { + if (reportText.getText().isBlank()) { + Alert a = new Alert(Alert.AlertType.INFORMATION); + a.setTitle("Error"); + a.setHeaderText("Try Again"); + a.setContentText("Please enter a valid report.\n"); + a.show(); + return; + } addReportToDatabase(reportText.getText(), apptId); updateAppointmentStatus(patID, apptId); x.close(); diff --git a/RIS/src/main/java/aasim/ris/Receptionist.java b/RIS/src/main/java/aasim/ris/Receptionist.java index 740c47d..3f1ca08 100644 --- a/RIS/src/main/java/aasim/ris/Receptionist.java +++ b/RIS/src/main/java/aasim/ris/Receptionist.java @@ -175,12 +175,12 @@ private void loadCenter() { //Set Column Widths apptIDCol.prefWidthProperty().bind(table.widthProperty().multiply(0.09)); - patientIDCol.prefWidthProperty().bind(table.widthProperty().multiply(0.04)); + patientIDCol.prefWidthProperty().bind(table.widthProperty().multiply(0.09)); firstNameCol.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); timeCol.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); - orderCol.prefWidthProperty().bind(table.widthProperty().multiply(0.4)); + orderCol.prefWidthProperty().bind(table.widthProperty().multiply(0.3)); updateAppt.prefWidthProperty().bind(table.widthProperty().multiply(0.1)); - status.prefWidthProperty().bind(table.widthProperty().multiply(0.2)); + status.prefWidthProperty().bind(table.widthProperty().multiply(0.15)); //Add columns to table table.getColumns().addAll(apptIDCol, patientIDCol, firstNameCol, timeCol, orderCol, status, updateAppt); table.setStyle("-fx-background-color: #25A18E; -fx-text-fill: WHITE; "); diff --git a/RIS/src/main/java/aasim/ris/ReferralDoctor.java b/RIS/src/main/java/aasim/ris/ReferralDoctor.java index f69bd47..a604e14 100644 --- a/RIS/src/main/java/aasim/ris/ReferralDoctor.java +++ b/RIS/src/main/java/aasim/ris/ReferralDoctor.java @@ -402,7 +402,7 @@ public void handle(ActionEvent t) { @Override public void handle(ActionEvent t) { //Validation - if (!InputValidation.validateDate(datePicker.getValue().toString())) { + if (!InputValidation.validateDOB(datePicker.getValue().toString())) { return; } if (!InputValidation.validateAddress(address.getText())) { diff --git a/RIS/src/main/java/datastorage/InputValidation.java b/RIS/src/main/java/datastorage/InputValidation.java index a115f58..85dcc5f 100644 --- a/RIS/src/main/java/datastorage/InputValidation.java +++ b/RIS/src/main/java/datastorage/InputValidation.java @@ -16,7 +16,7 @@ public class InputValidation { public static boolean validateName(String name) { - if (name.isBlank() || !name.matches("^[a-zA-Z]+ [a-zA-Z]+$")) { + if (name == null || name.isBlank() || !name.matches("^[a-zA-Z]+ [a-zA-Z]+$")) { Alert a = new Alert(Alert.AlertType.INFORMATION); a.setTitle("Error"); a.setHeaderText("Try Again"); @@ -52,7 +52,7 @@ public static boolean validatePassword(String pass) { } public static boolean validateEmail(String email) { - if (email.isBlank() || !email.matches("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")) { + if (email == null || email.isBlank() || !email.matches("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")) { Alert a = new Alert(Alert.AlertType.INFORMATION); a.setTitle("Error"); a.setHeaderText("Try Again"); @@ -76,7 +76,7 @@ public static boolean validateConfirm(String confirm) { } public static boolean validateDate(String date) { - if (date == null || !date.matches("^[0-9]{4}-[0-9]{2}-[0-9]{2}$")) { + if (date == null || date.isBlank() || !date.matches("^[0-9]{4}-[0-9]{2}-[0-9]{2}$")) { Alert a = new Alert(Alert.AlertType.INFORMATION); a.setTitle("Error"); a.setHeaderText("Try Again"); @@ -127,7 +127,7 @@ public static boolean validateInsurance(String insurance) { } public static boolean validateTime(String time) { - if (time.isBlank() || !time.matches("(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$)")) { + if (time == null || time.isBlank() || !time.matches("(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$)")) { Alert a = new Alert(Alert.AlertType.INFORMATION); a.setTitle("Error"); a.setHeaderText("Try Again"); @@ -169,4 +169,20 @@ public static boolean validatePayment(String payment) { } return true; } + + public static boolean validateDOB(String date) { + if (!validateDate(date)) { + return false; + } + if (LocalDate.now().isBefore(LocalDate.parse(date))) { + Alert a = new Alert(Alert.AlertType.INFORMATION); + a.setTitle("Error"); + a.setHeaderText("Try Again"); + a.setContentText("Please enter a valid Date of Birth.\n"); + a.show(); + return false; + } + return true; + } + }