private int Resolve(IEnumerable <Domain2.Hours.Hours> hours) { int count = 0; int loopCount = 0; int totalCount = hours.Count(); var resolver = new AuthorizationResolution(new ResolutionServiceRepository(Context), HoursResolutionLoggingService.Create()); foreach (var h in hours) { try { resolver.Resolve(new List <Domain2.Hours.Hours> { h }); Context.SaveChanges(); onAuthResolved(totalCount, loopCount, h.ID); count += h.AuthorizationBreakdowns != null ? h.AuthorizationBreakdowns.Count : 0; } catch (Exception e) { onExceptionBypassed(h.ID, e); } loopCount++; System.Diagnostics.Debug.WriteLine("LOOP: " + loopCount + " of " + totalCount); } return(count); }
public void AuthResolverGetsFinalBreakdown() { var repoMock = CreateMockResolutionServiceRepository(); var targetCase = repoMock.Object.GetCase(0); var hours = GetMockHours(); var insurance = targetCase.Patient.Insurance; hours.Date = new DateTime(2017, 1, 1); hours.Service.ID = 9; // DR hours.Provider.ProviderType.ID = 17; // Aide targetCase.Authorizations = new List<Authorization> { new Authorization() { ID = 1, AuthorizationCodeID = 100, StartDate = new DateTime(2016, 1, 1), EndDate = new DateTime(2018, 1, 1) }, new Authorization() { ID = 2, AuthorizationCodeID = 200, StartDate = new DateTime(2016, 1, 1), EndDate = new DateTime(2018, 1, 1) } }; var matchRule = new AuthorizationMatchRule() { InitialAuthorizationID = 100, FinalAuthorizationID = 200, InitialAuthorization = new AuthorizationCode(), FinalAuthorization = new AuthorizationCode(), ServiceID = 9, // DR ProviderTypeID = 17, // Aide InitialMinimumMinutes = 16, InitialUnitSize = 30, FinalMinimumMinutes = 16, FinalUnitSize = 30 }; insurance.AuthorizationMatchRules = new List<AuthorizationMatchRule> { matchRule }; hours.TotalHours = 2; var authService = new AuthorizationResolution(repoMock.Object, null); var result = authService.Resolve(new List<Domain2.Hours.Hours>() { hours }); Assert.AreEqual(2, hours.AuthorizationBreakdowns.Count); Assert.AreEqual(90, hours.AuthorizationBreakdowns.ToList()[1].Minutes); }