/// <summary>
        /// Validates the specified object.
        /// </summary>
        /// <param name="learner">The object to validate.</param>
        public void Validate(ILearner learner)
        {
            if (learner?.DateOfBirthNullable == null || learner.LearnerFAMs == null || learner.LearningDeliveries == null)
            {
                return;
            }

            var age = _dateTimeQueryService.YearsBetween(
                learner.DateOfBirthNullable ?? DateTime.MinValue,
                _academicYearDataService.AugustThirtyFirst());

            if (age < MinAge || age > MaxAge)
            {
                return;
            }

            if (learner.LearnerFAMs.All(lf => !lf.LearnFAMType.CaseInsensitiveEquals(LearnerFAMTypeConstants.HNS)) ||
                learner.LearnerFAMs.Any(lf => lf.LearnFAMType.CaseInsensitiveEquals(LearnerFAMTypeConstants.EHC)))
            {
                return;
            }

            foreach (var learningDelivery in learner.LearningDeliveries)
            {
                if (learningDelivery.FundModel == FundModels.Age16To19ExcludingApprenticeships)
                {
                    RaiseValidationMessage(learner, learningDelivery);
                }
            }
        }
 public bool ConditionMet(DateTime?dateOfBirth, DateTime academicYearAugustThirtyFirst, long?fundModel)
 {
     return(fundModel.HasValue &&
            _fundModels.Contains(fundModel.Value) &&
            dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, academicYearAugustThirtyFirst) < 13);
 }
 public bool ConditionMet(int fundModel, int?progType, DateTime learnStartDate, DateTime dateOfBirth, string learnAimRef, IEnumerable <ILearningDeliveryFAM> learningDeliveryFams)
 {
     return(!Excluded(progType, learningDeliveryFams, learnAimRef) &&
            fundModel == TypeOfFunding.AdultSkills &&
            learnStartDate >= _firstAugust2017 &&
            _dateTimeQueryService.YearsBetween(dateOfBirth, learnStartDate) >= 24 &&
            _larsDataService.NotionalNVQLevelV2MatchForLearnAimRefAndLevels(learnAimRef, _notionalNvqLevels));
 }
Beispiel #4
0
 public bool ConditionMet(long?fundModel, DateTime?dateOfBirth, DateTime academicYearEnd, bool hasSOFOne)
 {
     return(hasSOFOne &&
            fundModel.HasValue &&
            fundModel.Value == 99 &&
            dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, academicYearEnd) < 16);
 }
Beispiel #5
0
 public bool LearningDeliveryConditionMet(DateTime?dateOfBirth, DateTime learnStartDate)
 => dateOfBirth.HasValue &&
 learnStartDate >= _augustFirst2014 &&
 _dateTimeQueryService.YearsBetween(
     dateOfBirth.Value,
     _academicYearQueryService.GetAcademicYearOfLearningDate(
         learnStartDate,
         AcademicYearDates.August31)) >= 19;
 public bool ConditionMet(DateTime?dateOfBirth, DateTime?learnStartDate, long?fundModel)
 {
     return(fundModel.HasValue &&
            _fundModels.Contains(fundModel.Value) &&
            dateOfBirth.HasValue &&
            learnStartDate.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, learnStartDate.Value) < 4);
 }
 public bool ConditionMet(ILearningDelivery learningDelivery, DateTime dateOfBirth)
 {
     return(!Excluded(learningDelivery.LearningDeliveryFAMs) &&
            learningDelivery.LearnStartDate > _julyThirtyFirst2016 &&
            (learningDelivery.ProgTypeNullable.HasValue && learningDelivery.ProgTypeNullable == ProgTypes.Traineeship) &&
            learningDelivery.AimType == AimTypes.ProgrammeAim &&
            _dateTimeQueryService.YearsBetween(dateOfBirth, learningDelivery.LearnStartDate) >= 25);
 }
 public bool ConditionMet(long?fundModel, DateTime?dateOfBirth, DateTime?learnStartDate, bool hasASLOneorTwo)
 {
     return(hasASLOneorTwo &&
            fundModel.HasValue &&
            fundModel.Value == 10 &&
            dateOfBirth.HasValue &&
            learnStartDate.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, learnStartDate.Value) < 19);
 }
        /// <summary>
        /// Validates the specified object.
        /// </summary>
        /// <param name="learner">The object to validate.</param>
        public void Validate(ILearner learner)
        {
            if (learner?.LearningDeliveries == null ||
                !learner.DateOfBirthNullable.HasValue)
            {
                return;
            }

            foreach (var learningDelivery in learner.LearningDeliveries)
            {
                if (learningDelivery.LearnStartDate > _ruleEndDate)
                {
                    continue;
                }

                var age = _dateTimeQueryService.AgeAtGivenDate(
                    learner.DateOfBirthNullable.Value,
                    learningDelivery.LearnStartDate);

                if (age < MinAge)
                {
                    continue;
                }

                if (_fundModels.All(fm => fm != learningDelivery.FundModel) ||
                    (learningDelivery.ProgTypeNullable ?? -1) != ProgrammeType ||
                    learningDelivery.AimType != AimType)
                {
                    continue;
                }

                if (_learningDeliveryFAMQueryService.HasLearningDeliveryFAMType(
                        learningDelivery.LearningDeliveryFAMs,
                        LearningDeliveryFAMTypeConstants.RES))
                {
                    continue;
                }

                if (!learningDelivery.OutcomeNullable.HasValue ||
                    learningDelivery.OutcomeNullable.Value != OutcomeConstants.Achieved)
                {
                    continue;
                }

                if (!learningDelivery.LearnActEndDateNullable.HasValue ||
                    _dateTimeQueryService.YearsBetween(
                        learningDelivery.LearnStartDate,
                        learningDelivery.LearnActEndDateNullable.Value) >= 1)
                {
                    continue;
                }

                RaiseValidationMessage(learner, learningDelivery);
            }
        }
        public bool DateOfBirthConditionMet(DateTime?dateOfBirth)
        {
            if (dateOfBirth.HasValue)
            {
                var augustThirtyFirstAge = _dateTimeQueryService.YearsBetween(dateOfBirth.Value, _academicYearDataService.AugustThirtyFirst());

                return(augustThirtyFirstAge >= 19 && augustThirtyFirstAge <= 24);
            }

            return(false);
        }
Beispiel #11
0
 public bool ConditionMet(DateTime learnStartDate, DateTime dateOfBirth, int fundModel, int?progType, int aimType, DateTime learnPlanEndDate, IEnumerable <ILearningDeliveryFAM> learningDeliveryFams)
 {
     return(!Excluded(learningDeliveryFams) &&
            learnStartDate < _firstAugust2016 &&
            learnStartDate >= _firstAugust2014 &&
            (fundModel == TypeOfFunding.AdultSkills || fundModel == TypeOfFunding.OtherAdult) &&
            (progType.HasValue && progType.Value == TypeOfLearningProgramme.ApprenticeshipStandard) &&
            aimType == TypeOfAim.ProgrammeAim &&
            _dateTimeQueryService.YearsBetween(dateOfBirth, learnStartDate) >= 19 &&
            _dateTimeQueryService.MonthsBetween(learnStartDate, learnPlanEndDate) < 12);
 }
        public bool DateOfBirthLearnStartDateConditionMet(DateTime learnStartDate, DateTime dateOfBirth)
        {
            var learnStartDateAcademicYearLastFridayJune = _academicYearCalendarService.LastFridayInJuneForDateInAcademicYear(learnStartDate);
            var learnStartDateFirstSeptember             = new DateTime(learnStartDateAcademicYearLastFridayJune.Year, 9, 1);
            var sixteenthBirthday = dateOfBirth.AddYears(16);
            var learnStartDateAge = _dateTimeQueryService.YearsBetween(dateOfBirth, learnStartDate);

            return(learnStartDateAge < 16
                   &&
                   !(learnStartDateAge == 15 &&
                     sixteenthBirthday > learnStartDateAcademicYearLastFridayJune && sixteenthBirthday < learnStartDateFirstSeptember &&
                     learnStartDate > learnStartDateAcademicYearLastFridayJune && learnStartDate < learnStartDateFirstSeptember));
        }
Beispiel #13
0
        public void Validate(ILearner learner)
        {
            if (learner?.LearningDeliveries == null)
            {
                return;
            }

            if (!_priorAttain.Contains(learner.PriorAttainNullable ?? -1))
            {
                return;
            }

            foreach (var learningDelivery in learner.LearningDeliveries)
            {
                if (learningDelivery.FundModel != FundingModel ||
                    LearnStartDateIsOutsideValidDateRange(learningDelivery.LearnStartDate) ||
                    learningDelivery.LearningDeliveryFAMs == null)
                {
                    continue;
                }

                var ageAtCourseStart = _dateTimeQueryService.YearsBetween(learner.DateOfBirthNullable ?? DateTime.MinValue, learningDelivery.LearnStartDate);
                if (ageAtCourseStart < MinAge || ageAtCourseStart > MaxAge)
                {
                    continue;
                }

                var nvqLevel = _larsDataService.GetNotionalNVQLevelv2ForLearnAimRef(learningDelivery.LearnAimRef);
                if (!_nvqLevels.Any(x => x.CaseInsensitiveEquals(nvqLevel)))
                {
                    continue;
                }

                if (ExclusionsApply(learner, learningDelivery))
                {
                    continue;
                }

                foreach (var deliveryFam in learningDelivery.LearningDeliveryFAMs)
                {
                    if (deliveryFam.LearnDelFAMType.CaseInsensitiveEquals(LearningDeliveryFAMTypeConstants.FFI) &&
                        deliveryFam.LearnDelFAMCode.CaseInsensitiveEquals(LearningDeliveryFAMCodeConstants.FFI_Fully))
                    {
                        RaiseValidationMessage(learner, learningDelivery, deliveryFam);
                    }
                }
            }
        }
        public bool AgeConditionMet(DateTime learnStartDate, DateTime?dateOfBirth)
        {
            if (!dateOfBirth.HasValue)
            {
                return(false);
            }

            var ageAtCourseStart = _dateTimeQueryService.YearsBetween(dateOfBirth.Value, learnStartDate);

            if (ageAtCourseStart >= MinAge)
            {
                return(true);
            }

            return(false);
        }
Beispiel #15
0
        public int?GetLearnersAgeAtStartOfESFContract(
            ILearner learner,
            string conRefNumber)
        {
            if (learner?.DateOfBirthNullable == null)
            {
                return(null);
            }

            var delivery = learner.LearningDeliveries
                           ?.OrderByDescending(x => x.LearnStartDate)
                           .FirstOrDefault(ld => ld.LearnAimRef.CaseInsensitiveEquals(AimTypes.References.ESFLearnerStartandAssessment) &&
                                           ld.CompStatus == CompletionState.HasCompleted &&
                                           ld.ConRefNumber.CaseInsensitiveEquals(conRefNumber));

            if (delivery == null)
            {
                return(null);
            }

            return(_dateTimeQueryService.YearsBetween(
                       learner.DateOfBirthNullable.Value,
                       delivery.LearnStartDate));
        }
 public bool Exclude(DateTime?dateOfBirth, DateTime?minimumLearningDeliveryStartDate)
 {
     return(dateOfBirth.HasValue &&
            minimumLearningDeliveryStartDate.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, minimumLearningDeliveryStartDate.Value) >= 25);
 }
 public bool AgeConditionMet(DateTime?dateOfBirth)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, _academicYearDataService.Start()) >= 115);
 }
 public bool DateOfBirthConditionMet(DateTime?dateOfBirth)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, _academicYearDataService.AugustThirtyFirst()) < 19);
 }
 public bool ConditionMet(DateTime learnPlanEndDate, DateTime learnStartDate)
 {
     return(_dateTimeQueryService.YearsBetween(learnStartDate, learnPlanEndDate) >= 10);
 }
Beispiel #20
0
 public bool ExcludedDOBConditionMet(DateTime?dateOfBirth, DateTime dd06Date)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, dd06Date) >= 25);
 }
 public bool LearningDeliveryConditionMet(DateTime?dateOfBirth, DateTime learnStartDate)
 {
     return(dateOfBirth.HasValue &&
            learnStartDate >= _augustFirst2014 &&
            _dateTimeQueryService.YearsBetween((DateTime)dateOfBirth, _academicYearQueryService.AugustThirtyFirstOfLearnStartDate(learnStartDate)) >= 19);
 }
Beispiel #22
0
        private bool ExceptionApplies(DateTime?dateOfBirth, IEnumerable <ILearningDelivery> learningDeliveries)
        {
            var startDate = _derivedData06.Derive(learningDeliveries);

            return(_dateTimeQueryService.YearsBetween(dateOfBirth ?? DateTime.MaxValue, startDate) >= MaxRuleAge);
        }
Beispiel #23
0
 public virtual bool AgeConditionMet(DateTime?dateOfBirth, DateTime learnStartDate)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, learnStartDate) >= 24);
 }
Beispiel #24
0
 public virtual bool AgeConditionMet(DateTime?dateOfBirth, DateTime startDate)
 {
     return(dateOfBirth.HasValue && (_dateTimeQueryService.YearsBetween(dateOfBirth.Value, startDate)) >= MinAge);
 }
Beispiel #25
0
 public bool DateOfBirthConditionMet(DateTime? dateOfBirth, DateTime learnStartDate)
 {
     return dateOfBirth.HasValue
         && learnStartDate >= _augustFirst2014
         && _dateTimeQueryService.YearsBetween((DateTime)dateOfBirth, learnStartDate) >= 19;
 }
Beispiel #26
0
 public bool WithinViableAgeGroup(DateTime candidate, DateTime reference) =>
 _dateTimeQueryService.YearsBetween(candidate, reference).IsBetween(MinimumViableAge, MaximumViableAge);
 public bool ConditionMet(DateTime?dateOfBirth, DateTime academicYearStart)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, academicYearStart) >= 115);
 }
 public bool DateOfBirthConditionMet(DateTime?dateOfBirth, DateTime learnStartDate)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, learnStartDate) < 19);
 }
 public bool LearnerConditionMet(DateTime?dateOfBirth, DateTime academicYearAugustThirtyFirst)
 {
     return(dateOfBirth.HasValue &&
            _dateTimeQueryService.YearsBetween(dateOfBirth.Value, academicYearAugustThirtyFirst) >= 25);
 }