Skip to content

Commit

Permalink
Merge pull request #7 from 135dragon/135dragon-patch-1
Browse files Browse the repository at this point in the history
Bug Fixes #7
  • Loading branch information
135dragon authored Apr 4, 2022
2 parents 5ee1b27 + ab12bca commit 38c98ef
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
9 changes: 9 additions & 0 deletions RIS/src/main/java/aasim/ris/Rad.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -382,6 +383,14 @@ public void handle(ActionEvent e) {
confirm.setOnAction(new EventHandler<ActionEvent>() {
@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();
Expand Down
6 changes: 3 additions & 3 deletions RIS/src/main/java/aasim/ris/Receptionist.java
Original file line number Diff line number Diff line change
Expand Up @@ -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; ");
Expand Down
2 changes: 1 addition & 1 deletion RIS/src/main/java/aasim/ris/ReferralDoctor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
24 changes: 20 additions & 4 deletions RIS/src/main/java/datastorage/InputValidation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

}

0 comments on commit 38c98ef

Please sign in to comment.