public bool ValidateAddPatienInfo(List <string> errors, PatientInformation patient) { bool isValid = true; if (!PatientValidation.ValidateFirstName(patient.firstname)) { isValid = false; errors.Add("Error: Invalid First Name."); } if (!PatientValidation.ValidateLastName(patient.LastName)) { isValid = false; errors.Add("Error: Invalid Last Name."); } if (!PatientValidation.ValidateHCN(patient.HCN)) { isValid = false; errors.Add("Error: Invalid Health Card Number."); } if (!PatientValidation.ValidateMInitial(patient.MInitial)) { isValid = false; errors.Add("Error: Invalid Middle Initial."); } if (!PatientValidation.ValidateDOB(patient.DOB)) { isValid = false; errors.Add("Error: Invalid Birth Date."); } return(isValid); }
/// <summary> Event handler. Called by HcnTextBox for text changed events. /// Ensures a valid health card, and that it does not already exist.</summary> /// /// <remarks> 2019-04-20. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Text changed event information. </param> private void HcnTextBox_TextChanged(object sender, TextChangedEventArgs e) { SubmitError.Visibility = Visibility.Hidden; //Hide the error initally hcnError.Content = "*Invalid Health Card Number!"; bool isValid = true; //Validate health card number isValid = PatientValidation.ValidateHCN(hcnTextBox.Text); if (!isValid) //Not valid. Make error visile. { hcnEntered = false; hcnError.Visibility = Visibility.Visible; } else //Health card is valid. { if (PatientValidation.ValidateNewHCN(hcnTextBox.Text)) //Ensure it doesnt yet exist, if it does show error { hcnEntered = false; hcnError.Content = "Health Card Number Already Exists!"; hcnError.Visibility = Visibility.Visible; } else //Health card is valid and does not exist. Set boolean to true. { hcnEntered = true; hcnError.Visibility = Visibility.Hidden; } } if (String.IsNullOrEmpty(hcnTextBox.Text)) //Nothing was entered. { hcnEntered = false; hcnError.Visibility = Visibility.Hidden; } }