public IEnumerable <OrderedPair <long, long> > GetHealthPlanCallQueueCustomers(long callQueueId, HealthPlanCallQueueCriteria criteria, CorporateAccount healthPlan, int pastAppointmentDays, ILogger logger) { var days = criteria.NoOfDays; var percentage = criteria.Percentage; var endDate = DateTime.Today.AddDays(days); logger.Info(string.Format("HealthPlanId: {0}, CallQueueId: {1}, CriteriaId: {2}", healthPlan.Id, callQueueId, criteria.Id)); logger.Info(string.Format("Percentage: {0}, NoOfDays: {1}, EndDate: {2}", percentage, days, endDate)); IEnumerable <Event> eventList = null; var eventForNonMammoPatient = _eventRepository.GetEventsForHealthPlanFillEventsCallQueue(endDate, healthPlan.Id, true); var eventForMammoPatient = _eventRepository.GetEventsForHealthPlanFillEventsCallQueue(endDate, healthPlan.Id, false); eventList = eventForNonMammoPatient; if (eventList != null) { eventList = eventList.Concat(eventForMammoPatient); } else { eventList = eventForMammoPatient; } if (eventList == null || !eventList.Any()) { return(null); } eventList = _fillEventsCallQueueHelper.GetAllTheEventFilledUnderPecentage(eventList, percentage); if (eventList == null || !eventList.Any()) { return(null); } if (eventForMammoPatient != null && eventForMammoPatient.Any()) { logger.Info("Mammo Event count: " + eventForMammoPatient.Count()); } else { logger.Info("No Mammo Event found"); } if (eventForNonMammoPatient != null && eventForNonMammoPatient.Any()) { logger.Info("Non-Mammo Event count: " + eventForNonMammoPatient.Count()); } else { logger.Info("No Non-Mammo Event found"); } var hostIds = eventList.Select(x => x.HostId); var eventZipMammoListModel = new List <EventZipMammoModel>(); var hostIdZipCodePairs = _hostRepository.GetHostZipId(hostIds); foreach (var theEvent in eventList) { var host = hostIdZipCodePairs.First(h => h.FirstValue == theEvent.HostId); eventZipMammoListModel.Add(new EventZipMammoModel { EventId = theEvent.Id, ZipId = host.SecondValue, IsNonMammoEvent = (eventForNonMammoPatient != null && eventForNonMammoPatient.Any(x => x.Id == theEvent.Id)) }); } var customers = _customerRepository.GetCustomerForHealthPlanFillEventCallQueue(eventZipMammoListModel, healthPlan.Tag, _settings.FillEventZipRadius, logger); return(customers); }