public static CaseAuthDTO Create(Authorization caseAuth) { var obj = new CaseAuthDTO() { Id = caseAuth.ID, Code = caseAuth.AuthorizationCode?.Code, AuthStartDate = caseAuth.StartDate, AuthEndDate = caseAuth.EndDate }; return(obj); }
private List <AuthorizationBreakdown> getAuthBreakdowns(Domain2.Hours.Hours entry) { var providerType = entry.Provider.ProviderType; var service = entry.Service; var insurance = ResolutionServiceRepository.GetActiveInsurance(entry.CaseID, entry.Date); if (insurance == null) { Log(new HoursResolutionLoggingEntry { WasResolved = false, HoursID = entry.ID, HoursDate = entry.Date, ServiceID = service.ID, BillableHours = entry.BillableHours, ProviderTypeID = providerType.ID, InsuranceID = 0, AuthMatchRuleDetailJSON = Serialize(new { Message = "No insurance" }) }); return(null); } var rules = insurance.AuthorizationMatchRules; if (rules == null || rules.Count == 0) { Log(new HoursResolutionLoggingEntry { WasResolved = false, HoursID = entry.ID, HoursDate = entry.Date, ServiceID = service.ID, BillableHours = entry.BillableHours, ProviderTypeID = providerType.ID, InsuranceID = insurance.ID, AuthMatchRuleDetailJSON = Serialize(new { Message = "No rules" }) }); return(null); } var matchedRule = rules.Where(x => x.ServiceID == service.ID && x.ProviderTypeID == providerType.ID).FirstOrDefault(); if (matchedRule == null) { Log(new HoursResolutionLoggingEntry { WasResolved = false, HoursID = entry.ID, HoursDate = entry.Date, ServiceID = service.ID, BillableHours = entry.BillableHours, ProviderTypeID = providerType.ID, InsuranceID = insurance.ID, AuthMatchRuleDetailJSON = Serialize(rules.Select(m => RuleDTO.Create(m))) }); return(null); } var breakdowns = getBreakdownsForRule(entry, matchedRule); if (breakdowns == null) { Log(new HoursResolutionLoggingEntry { WasResolved = false, HoursID = entry.ID, HoursDate = entry.Date, ServiceID = service.ID, BillableHours = entry.BillableHours, ProviderTypeID = providerType.ID, InsuranceID = insurance.ID, AuthMatchRuleDetailJSON = Serialize(RuleDTO.Create(matchedRule)), ActiveAuthorizationsJSON = Serialize(entry.Case.GetActiveAuthorizations()?.Select(m => CaseAuthDTO.Create(m))) }); } else { foreach (var b in breakdowns) { Log(new HoursResolutionLoggingEntry { WasResolved = true, HoursID = entry.ID, HoursDate = entry.Date, ServiceID = service.ID, BillableHours = entry.BillableHours, ProviderTypeID = providerType.ID, InsuranceID = insurance.ID, AuthMatchRuleDetailJSON = Serialize(RuleDTO.Create(matchedRule)), ResolvedAuthID = b.Authorization?.AuthorizationCode?.ID, ResolvedAuthCode = b.Authorization?.AuthorizationCode?.Code, ResolvedCaseAuthID = b.Authorization?.ID, ResolvedCaseAuthStart = b.Authorization?.StartDate, ResolvedCaseAuthEndDate = b.Authorization?.EndDate, ResolvedAuthMatchRuleID = matchedRule.ID, ResolvedMinutes = b.Minutes }); } } return(breakdowns); }