/// <summary> // /// </summary> /// <param name="values"></param> /// <returns></returns> public override Validations ValidateFields(List <string> values) { var validations = new Validations(); ValidateOrgDeterminationFields(validations, values); ValidateField(UniverseFieldNames.PersonMakingRequest, values, validations, ValidateFieldWithPossibleValues, personWhoMadeRequestPossibleValues); ValidateField(UniverseFieldNames.RequestReceivedTime, values, validations, ValidateTime); ValidateField(UniverseFieldNames.SubsequentRequest, values, validations, ValidateFieldWithPossibleValues, subsequentRequestPossibleValues); ValidateField(UniverseFieldNames.SponsorDecisionTime, values, validations, ValidateTime); ValidateField(UniverseFieldNames.OralNotificationTime, values, validations, ValidateTime); ValidateField(UniverseFieldNames.WrittenNotificationTime, values, validations, ValidateTime); ValidateField(UniverseFieldNames.SponsorEffectuatedTime, values, validations, ValidateTime); var errors = validations.FindAll(v => !v.IsValid); //Logical Errors //If this is BR then Column AORReceiptDate should not be NA and Subsequent Request should also be BR. var tmpPersonRequestValidation = validations.Find(UniverseFieldNames.PersonMakingRequest); if (tmpPersonRequestValidation.IsValid && tmpPersonRequestValidation.Field.Value.Equals("BR")) { var tmprequestSubsequentRequest = validations.Find(UniverseFieldNames.SubsequentRequest); var tmprequestAORValidation = validations.Find(UniverseFieldNames.AORReceiptDate); if (tmprequestSubsequentRequest.IsValid && !tmprequestSubsequentRequest.Field.Value.Equals("BR")) { var v = new Validation(); v.IsValid = false; v.Field = tmprequestSubsequentRequest.Field; v.AdditionalFields.Add(tmpPersonRequestValidation.Field); v.Message = string.Format("{0} needs to have a value of BR", tmprequestSubsequentRequest.Field.Name); validations.Add(v); } if (tmprequestAORValidation.IsValid && tmprequestAORValidation.Field.Value.Equals("NA")) { var v = new Validation(); v.IsValid = false; v.Field = tmprequestAORValidation.Field; v.AdditionalFields.Add(tmpPersonRequestValidation.Field); v.Message = string.Format("{0} cannot have a value of NA", tmprequestSubsequentRequest.Field.Name); validations.Add(v); } } //If this is BR then Person Making request and AOR Receipt date cannot be NA var tmpValidation = validations.Find(UniverseFieldNames.SubsequentRequest); if (tmpValidation.IsValid && tmpValidation.Field.Value.Equals("BR")) { var tmprequestAORValidation = validations.Find(UniverseFieldNames.AORReceiptDate); var tmprequestPersonRequest = validations.Find(UniverseFieldNames.PersonMakingRequest); if (tmprequestPersonRequest.IsValid && tmprequestPersonRequest.Field.Value.Equals("NA")) { var v = new Validation(); v.IsValid = false; v.Field = tmpPersonRequestValidation.Field; v.AdditionalFields.Add(tmpValidation.Field); v.Message = string.Format("{0} cannot have a value of NA", tmpPersonRequestValidation.Field.Name); validations.Add(v); } if (tmprequestAORValidation.IsValid && tmprequestAORValidation.Field.Value.Equals("NA")) { var v = new Validation(); v.IsValid = false; v.Field = tmprequestAORValidation.Field; v.AdditionalFields.Add(tmpValidation.Field); v.Message = string.Format("{0} cannot have a value of NA", tmprequestAORValidation.Field.Name); validations.Add(v); } } //If column O is Y then this cannot be NA. tmpValidation = validations.Find(UniverseFieldNames.TimeframeExtensionTaken); if (tmpValidation.IsValid && tmpValidation.Field.Value.Equals("Y")) { var tmprequestSponsorNotificationDelay = validations.Find(UniverseFieldNames.SponsorNotificationDelay); if (tmprequestSponsorNotificationDelay.IsValid && tmprequestSponsorNotificationDelay.Field.Value.Equals("NA")) { var v = new Validation(); v.Field = tmprequestSponsorNotificationDelay.Field; v.IsValid = false; v.AdditionalFields.Add(tmpValidation.Field); v.Message = string.Format("{0} cannot be NA", tmprequestSponsorNotificationDelay.Field.Name); validations.Add(v); } } //if request disposition is approved //request denied for lack of necessity should be NA //review completed for denial should be NA var tmpRequestDisposition = validations.Find(UniverseFieldNames.RequestDisposition); var tmpRequestDenied = validations.Find(UniverseFieldNames.RequestDeniedNecessity); var tmpRequestReviewed = validations.Find(UniverseFieldNames.RequestDeniedReviewd); if (tmpRequestDisposition.IsValid && tmpRequestDisposition.Field.Value.ToLower().Equals("approved")) { if (!tmpRequestDenied.Field.Value.ToUpper().Equals("NA") || !tmpRequestReviewed.Field.Value.ToUpper().Equals("NA")) { var v = new Validation(); v.Field = tmpValidation.Field; v.IsValid = false; v.AdditionalFields.Add(tmpRequestDenied.Field); v.AdditionalFields.Add(tmpRequestReviewed.Field); v.Message = string.Format("{0} and {1} fields both need to be NA", tmpRequestDenied.Field.Name, tmpRequestReviewed.Field.Name); validations.Add(v); } } if (tmpRequestReviewed.IsValid && (tmpRequestReviewed.Field.Value.Equals("Y") || tmpRequestReviewed.Field.Value.Equals("N")) && tmpRequestDenied.IsValid && tmpRequestDenied.Field.Value.Equals("NA") && tmpRequestDisposition.IsValid && !tmpRequestDisposition.Field.Value.ToLower().Equals("approved")) { var v = new Validation(); v.Field = tmpRequestDenied.Field; v.IsValid = false; v.AdditionalFields.Add(tmpRequestReviewed.Field); v.Message = string.Format("{0} cannot be NA", tmpRequestDenied.Field.Name); validations.Add(v); } if (tmpRequestReviewed.IsValid && tmpRequestReviewed.Field.Value.Equals("NA") && tmpRequestDenied.IsValid && tmpRequestDenied.Field.Value.Equals("Y") && tmpRequestDisposition.IsValid && !tmpRequestDisposition.Field.Value.ToLower().Equals("approved")) { var v = new Validation(); v.Field = tmpRequestReviewed.Field; v.IsValid = false; v.AdditionalFields.Add(tmpRequestDenied.Field); v.Message = string.Format("{0} cannot be NA", tmpRequestReviewed.Field.Name); validations.Add(v); } //Oral Notification should be within 24 hours of Sponsor Decision Date var tmpSponsorDecisionDate = validations.Find(UniverseFieldNames.SponsorDecisionDate); var tmpSponsorDecisionTime = validations.Find(UniverseFieldNames.SponsorDecisionTime); var tmpOralNotificationDate = validations.Find(UniverseFieldNames.OralNotificationDate); var tmpOralNotificationTime = validations.Find(UniverseFieldNames.OralNotificationTime); if (tmpSponsorDecisionDate.IsValid && tmpSponsorDecisionDate.Field.DateValue.HasValue && tmpSponsorDecisionTime.IsValid && tmpSponsorDecisionTime.Field.DateValue.HasValue && tmpOralNotificationDate.IsValid && tmpOralNotificationDate.Field.DateValue.HasValue && tmpOralNotificationTime.IsValid && tmpOralNotificationTime.Field.DateValue.HasValue) { var sponsorDate = tmpSponsorDecisionDate.Field.DateValue.Value.AddTicks(tmpSponsorDecisionTime.Field.DateValue.Value.Ticks); var oralDate = tmpOralNotificationDate.Field.DateValue.Value.AddTicks(tmpOralNotificationTime.Field.DateValue.Value.Ticks); var span = oralDate.Subtract(sponsorDate); if (span.TotalHours > 24) { var v = new Validation(); v.Field = tmpOralNotificationDate.Field; v.AdditionalFields.Add(tmpOralNotificationTime.Field); v.AdditionalFields.Add(tmpSponsorDecisionDate.Field); v.AdditionalFields.Add(tmpSponsorDecisionTime.Field); v.IsValid = false; v.Message = string.Format("{0} and {1} need to be within 24 hours of {2} and {3}", tmpOralNotificationDate.Field.Name, tmpOralNotificationTime.Field.Name, tmpSponsorDecisionDate.Field.Name, tmpSponsorDecisionTime.Field.Name); validations.Add(v); } } //Written Notification should be within 72 hours of Oral Notification //Oral Notification should be within 24 hours of Sponsor Decision Date var tmpWrittenDate = validations.Find(UniverseFieldNames.EnrolleeWrittenNotificationDate); var tmpWrittenTime = validations.Find(UniverseFieldNames.WrittenNotificationTime); tmpOralNotificationDate = validations.Find(UniverseFieldNames.OralNotificationDate); tmpOralNotificationTime = validations.Find(UniverseFieldNames.OralNotificationTime); if (tmpSponsorDecisionDate.IsValid && tmpSponsorDecisionDate.Field.DateValue.HasValue && tmpSponsorDecisionTime.IsValid && tmpSponsorDecisionTime.Field.DateValue.HasValue && tmpOralNotificationDate.IsValid && tmpOralNotificationDate.Field.DateValue.HasValue && tmpOralNotificationTime.IsValid && tmpOralNotificationTime.Field.DateValue.HasValue) { var sponsorDate = tmpSponsorDecisionDate.Field.DateValue.Value.AddTicks(tmpSponsorDecisionTime.Field.DateValue.Value.Ticks); var oralDate = tmpOralNotificationDate.Field.DateValue.Value.AddTicks(tmpOralNotificationTime.Field.DateValue.Value.Ticks); var span = oralDate.Subtract(sponsorDate); if (span.TotalHours > 24) { var v = new Validation(); v.Field = tmpOralNotificationDate.Field; v.AdditionalFields.Add(tmpOralNotificationTime.Field); v.AdditionalFields.Add(tmpSponsorDecisionDate.Field); v.AdditionalFields.Add(tmpSponsorDecisionTime.Field); v.IsValid = false; v.Message = string.Format("{0} and {1} need to be within 24 hours of {2} and {3}", tmpOralNotificationDate.Field.Name, tmpOralNotificationTime.Field.Name, tmpSponsorDecisionDate.Field.Name, tmpSponsorDecisionTime.Field.Name); validations.Add(v); } } return(validations); }
/// <summary> // /// </summary> /// <param name="values"></param> /// <returns></returns> public override Validations ValidateFields(List <string> values) { var v = new Validations(); UniverseField field = null; ValidateOrgDeterminationFields(v, values); ValidateField(UniverseFieldNames.PersonMakingRequest, values, v, ValidateFieldWithPossibleValues, personWhoMadeRequestPossibleValues); ValidateField(UniverseFieldNames.ExpeditedOrStandardTimeFrame, values, v, ValidateFieldWithPossibleValues, yesNo); ValidateField(UniverseFieldNames.RequestExpedited, values, v, ValidateFieldWithPossibleValues, requestExpeditedTimeFrame); //Logical Errors //If this is BR then column X should have a date that is not more than a year from column I var tmpValidation = v.Find(f => f.Field.Name == UniverseFieldNames.PersonMakingRequest); if (tmpValidation.IsValid && field.Value.Equals("BR")) { var tmprequestReceivedValidation = v.Find(f => f.Field.Name == UniverseFieldNames.RequestReceivedDate); var tmprequestAORValidation = v.Find(f => f.Field.Name == UniverseFieldNames.AORReceiptDate); if (tmprequestReceivedValidation.IsValid && tmprequestAORValidation.IsValid) { DateTime requesteReceived = Convert.ToDateTime(tmprequestReceivedValidation.Field.Value); DateTime AORRequest = Convert.ToDateTime(tmprequestAORValidation.Field.Value); if (AORRequest.Subtract(requesteReceived).TotalDays > 365) { var tmpV = new Validation(); tmpV.Field = tmpValidation.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmprequestReceivedValidation.Field); tmpV.AdditionalFields.Add(tmprequestAORValidation.Field); tmpV.Message = String.Format("Fields {0} and {1} have to be 1 year apart", tmprequestAORValidation.Field.Name, tmprequestReceivedValidation.Field.Name); tmpV.ValidationType = ValidationType.Field; v.Add(tmpV); } } } DateTime tmpDate; //Request for Expedited time frame //If value is BR then AORDate should be a date. tmpValidation = v.Find(f => f.Field.Name == UniverseFieldNames.RequestExpedited); if (tmpValidation.IsValid && tmpValidation.Field.Value.Equals("BR")) { var tmprequestAORValidation = v.Find(f => f.Field.Name == UniverseFieldNames.AORReceiptDate); if (!DateTime.TryParse(tmprequestAORValidation.Field.Value, out tmpDate)) { var tmpV = new Validation(); tmpV.Field = tmpValidation.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmprequestAORValidation.Field); tmpV.Message = string.Format("{0} needs to be a valid date", tmprequestAORValidation.Field.Name); v.Add(tmpV); } } //If column O is Y then this cannot be NA. tmpValidation = v.Find(UniverseFieldNames.TimeframeExtensionTaken); if (tmpValidation.IsValid && tmpValidation.Field.Value.Equals("Y")) { var tmprequestSponsorNotificationDelay = v.Find(UniverseFieldNames.SponsorNotificationDelay); if (!DateTime.TryParse(tmprequestSponsorNotificationDelay.Field.Value, out tmpDate)) { var tmpV = new Validation(); tmpV.Field = tmpValidation.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmprequestSponsorNotificationDelay.Field); tmpV.Message = string.Format("{0} needs to be a valid date", tmprequestSponsorNotificationDelay.Field.Name); v.Add(tmpV); } } //if request disposition is approved //request denied for lack of necessity should be NA //review completed for denial should be NA tmpValidation = v.Find(UniverseFieldNames.RequestDisposition); var tmpRequestDenied = v.Find(UniverseFieldNames.RequestDeniedNecessity); var tmpRequestReviewed = v.Find(UniverseFieldNames.RequestDeniedReviewd); if (tmpValidation.IsValid && tmpValidation.Field.Value.ToLower().Equals("approved")) { if (!tmpRequestDenied.Field.Value.ToUpper().Equals("NA") || !tmpRequestReviewed.Field.Value.ToUpper().Equals("NA")) { var tmpV = new Validation(); tmpV.Field = tmpValidation.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmpRequestDenied.Field); tmpV.AdditionalFields.Add(tmpRequestReviewed.Field); tmpV.Message = string.Format("{0} and {1} fields both need to be NA", tmpRequestDenied.Field.Name, tmpRequestReviewed.Field.Name); v.Add(tmpV); } } if (tmpRequestReviewed.IsValid && (tmpRequestReviewed.Field.Value.Equals("Y") || tmpRequestReviewed.Field.Value.Equals("N")) && tmpRequestDenied.IsValid && tmpRequestDenied.Field.Value.Equals("NA")) { var tmpV = new Validation(); tmpV.Field = tmpRequestDenied.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmpRequestReviewed.Field); tmpV.Message = string.Format("{0} cannot be NA", tmpRequestDenied.Field.Name); v.Add(tmpV); } if (tmpRequestReviewed.IsValid && tmpRequestReviewed.Field.Value.Equals("NA") && tmpRequestDenied.IsValid && tmpRequestDenied.Field.Value.Equals("Y")) { var tmpV = new Validation(); tmpV.Field = tmpRequestReviewed.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmpRequestDenied.Field); tmpV.Message = string.Format("{0} cannot be NA", tmpRequestReviewed.Field.Name); v.Add(tmpV); } var tmpOralNotification = v.Find(UniverseFieldNames.OralNotificationDate); var tmpWrittenNotfication = v.Find(UniverseFieldNames.EnrolleeWrittenNotificationDate); if (tmpOralNotification.IsValid && tmpWrittenNotfication.IsValid) { DateTime dateOralNotification; DateTime dateWrittenNotification; if (DateTime.TryParse(tmpOralNotification.Field.Value, out dateOralNotification)) { if (DateTime.TryParse(tmpWrittenNotfication.Field.Value, out dateWrittenNotification)) { var timeSpan = dateWrittenNotification.Subtract(dateOralNotification); if (timeSpan.TotalHours > 72) { var tmpV = new Validation(); tmpV.Field = tmpOralNotification.Field; String.Format("{0} field must be within 72 hours of {1}", tmpOralNotification.Field.Name, tmpWrittenNotfication.Field.Name); tmpV.IsValid = false; v.Add(tmpV); } } else { var tmpV = new Validation(); tmpV.Field = tmpOralNotification.Field; tmpV.AdditionalFields.Add(tmpWrittenNotfication.Field); tmpV.IsValid = false; tmpV.Message = string.Format("{0} field must be a valid date", tmpOralNotification.Field.Value); v.Add(tmpV); } } } var tmpAORReceiptDate = v.Find(UniverseFieldNames.AORReceiptDate); var tmpPersonMadeRequest = v.Find(UniverseFieldNames.PersonMakingRequest); var tmpRequestExpedited = v.Find(UniverseFieldNames.RequestExpedited); if (tmpAORReceiptDate.IsValid && tmpPersonMadeRequest.IsValid && tmpRequestExpedited.IsValid) { if (tmpAORReceiptDate.Field.Value.Equals("NA") && (tmpPersonMadeRequest.Field.Value.Equals("BR") || tmpRequestExpedited.Field.Value.Equals("BR") )) { var tmpV = new Validation(); tmpV.Field = tmpAORReceiptDate.Field; tmpV.AdditionalFields.Add(tmpPersonMadeRequest.Field); tmpV.AdditionalFields.Add(tmpRequestExpedited.Field); tmpV.IsValid = false; tmpV.Message = string.Format("{0} cannot be NA and needs to be a valid date", tmpAORReceiptDate.Field.Name); v.Add(tmpV); } } return(v); }
/// <summary> // /// </summary> /// <param name="values"></param> /// <returns></returns> public override Validations ValidateFields(List <string> values) { var v = new Validations(); ValidateOrgDeterminationFields(v, values); ValidateField(UniverseFieldNames.CleanClaim, values, v, ValidateFieldWithPossibleValues, yesNoNotApplicable); ValidateField(UniverseFieldNames.ClaimPaidDate, values, v, ValidateDate); ValidateField(UniverseFieldNames.ClaimInterestPaid, values, v, ValidateFieldWithPossibleValues, yesNo); ValidateField(UniverseFieldNames.ProviderWrittenNotifiationDate, values, v, ValidateDate); Validation tmpV; //If this is Y, then Column I and S should be less than or equal to 30 days. ///If this is N, then column I and S should less than or equal to 60 days. var vCleanClaim = v.Find(UniverseFieldNames.CleanClaim); var vReceivedDate = v.Find(UniverseFieldNames.RequestReceivedDate); var vWrittenDate = v.Find(UniverseFieldNames.ProviderWrittenNotifiationDate); var vClaimInterest = v.Find(UniverseFieldNames.ClaimInterestPaid); if (vCleanClaim.IsValid && vReceivedDate.IsValid && vWrittenDate.IsValid && vClaimInterest.IsValid) { if (vWrittenDate.Field.DateValue.HasValue) { if (vCleanClaim.Field.Value.Equals("Y")) { if (vWrittenDate.Field.DateValue.Value.Subtract(vReceivedDate.Field.DateValue.Value).TotalDays > 30) { tmpV = new Validation(); tmpV.Field = vCleanClaim.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(vReceivedDate.Field); tmpV.AdditionalFields.Add(vWrittenDate.Field); tmpV.Message = string.Format("{0} and {1} must be within 30 days", vWrittenDate.Field.Name, vReceivedDate.Field.Name); v.Add(tmpV); } else if (vClaimInterest.Field.Value.Equals("Y")) { tmpV = new Validation(); tmpV.Field = vClaimInterest.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(vReceivedDate.Field); tmpV.AdditionalFields.Add(vWrittenDate.Field); tmpV.Message = string.Format("No Interest should be charged, claim was paid on time"); v.Add(tmpV); } } else if (vCleanClaim.Field.Value.Equals("N")) { if (vWrittenDate.Field.DateValue.Value.Subtract(vReceivedDate.Field.DateValue.Value).TotalDays > 60) { tmpV = new Validation(); tmpV.Field = vWrittenDate.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(vReceivedDate.Field); tmpV.AdditionalFields.Add(vWrittenDate.Field); tmpV.Message = string.Format("{0} and {1} must be within 60 days", vWrittenDate.Field.Name, vReceivedDate.Field.Name); v.Add(tmpV); } else if (vClaimInterest.Field.Value.Equals("Y")) { tmpV = new Validation(); tmpV.Field = vClaimInterest.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(vReceivedDate.Field); tmpV.AdditionalFields.Add(vWrittenDate.Field); tmpV.Message = string.Format("No Interest should be charged, claim was paid on time"); v.Add(tmpV); } } } else { tmpV = new Validation(); tmpV.Field = vWrittenDate.Field; tmpV.IsValid = false; tmpV.Message = String.Format("{0} is required to be a date to compute timeliness", vWrittenDate.Field.Name); v.Add(tmpV); } } //if request disposition is approved //request denied for lack of necessity should be NA //review completed for denial should be NA var tmpReqDis = v.Find(UniverseFieldNames.RequestDisposition); var tmpReqDenied = v.Find(UniverseFieldNames.RequestDeniedNecessity); var tmpReqReviewed = v.Find(UniverseFieldNames.RequestDeniedReviewd); if (tmpReqDis.IsValid && tmpReqDis.Field.Value.ToLower().Equals("approved")) { if (!tmpReqDenied.Field.Value.ToUpper().Equals("NA") || !tmpReqReviewed.Field.Value.ToUpper().Equals("NA")) { tmpV = new Validation(); tmpV.Field = tmpReqDis.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmpReqDenied.Field); tmpV.AdditionalFields.Add(tmpReqReviewed.Field); tmpV.Message = string.Format("{0} and {1} fields both need to be NA", tmpReqDenied.Field.Name, tmpReqReviewed.Field.Name); v.Add(tmpV); } } if (tmpReqReviewed.IsValid && (tmpReqReviewed.Field.Value.Equals("Y") || tmpReqReviewed.Field.Value.Equals("N")) && tmpReqDenied.IsValid && tmpReqDenied.Field.Value.Equals("NA")) { tmpV = new Validation(); tmpV.Field = tmpReqDenied.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmpReqReviewed.Field); tmpV.Message = string.Format("{0} cannot be NA", tmpReqDenied.Field.Name); v.Add(tmpV); } if (tmpReqReviewed.IsValid && tmpReqReviewed.Field.Value.Equals("NA") && tmpReqDenied.IsValid && tmpReqDenied.Field.Value.Equals("Y")) { tmpV = new Validation(); tmpV.Field = tmpReqReviewed.Field; tmpV.IsValid = false; tmpV.AdditionalFields.Add(tmpReqDenied.Field); tmpV.Message = string.Format("{0} cannot be NA", tmpReqReviewed.Field.Name); v.Add(tmpV); } return(v); }