public void DisposeSamples() { ParentninExists_GivenHaveParentNin.DisposeSamples(); SpouseExists_GivenHasSpouse.DisposeSamples(); SpouseSameSex_GivenHasValidSpouse.DisposeSamples(); SpouseDuplex_GivenHasValidSpouse.DisposeSamples(); ParentSameSex_GivenHaveValidParentNin.DisposeSamples(); HasChildren_GivenHasSpouseNin.DisposeSamples(); HasChildren_GivenHasNotSpouseNin.DisposeSamples(); HasChildrenWithBetterHalf_GivenValidSpouseNinAndHaveChildren.DisposeSamples(); HaveMoreThanOneKidTogether_GivenHaveOneKidTogether.DisposeSamples(); NumberOfChildren_GivenHaveChildren.DisposeSamples(); AgeDifferentalInYearsToParent.DisposeSamples(); Custody_HaveParentNin.DisposeSamples(); Custody_HaveNotParentNin.DisposeSamples(); ParentsAreMarried.DisposeSamples(); SpouseAgeDifferentialInYears.DisposeSamples(); }
private void SetChildrenStatistics(PregNode person, Dictionary <string, PregNode> allpersons, PregNode spouse) { var kids = person.ChildNins.Where(nin => allpersons.ContainsKey(nin) && allpersons[nin].Confirmed).Select(a => allpersons[a]).ToList(); if (kids.Count > 0) { NumberOfChildren_GivenHaveChildren.Update(kids.Count); } if (kids.Count > MaxNumberOfChildren_GivenHaveChildren) { MaxNumberOfChildren_GivenHaveChildren = kids.Count; } if (string.IsNullOrEmpty(person.MarriedNin)) { HasChildren_GivenHasNotSpouseNin.Update(kids.Any() ? 1: 0); } else { HasChildren_GivenHasSpouseNin.Update(kids.Any() ? 1 : 0); } if (!kids.Any()) { return; } if (spouse != null) { HasChildrenWithBetterHalf_GivenValidSpouseNinAndHaveChildren.Update(kids.Any(kid => kid.DadNin == spouse.Nin || kid.MomNin == spouse.Nin) ? 1 : 0); } var kidsTogetherWithOther = kids.Where(kid => kid.DadNin != null && kid.MomNin != null).ToList(); if (kidsTogetherWithOther.Any()) { var allParentNins = new List <string>(); foreach (var kid in kidsTogetherWithOther) { if (kid.DadNin != person.Nin) { allParentNins.Add(kid.DadNin); } if (kid.MomNin != person.Nin) { allParentNins.Add(kid.MomNin); } } var duplicateKeys = allParentNins.GroupBy(x => x) .Where(group => group.Count() > 1) .Select(group => group.Key); HaveMoreThanOneKidTogether_GivenHaveOneKidTogether.Update(duplicateKeys.Any() ? 1 : 0); } if (!person.BirthDay.HasValue) { return; } foreach (var kid in kids.Where(k => k.BirthDay.HasValue)) { var value = kid.BirthDay.Value.Subtract(person.BirthDay.Value).TotalDays / 365; AgeDifferentalInYearsToParent.Update(value); } }