Пример #1
0
        public IEnumerable <GmsExcludedCustomerViewModel> GetGmsExcludedCustomers(OutboundCallQueueFilter filter, CallQueue callQueue)
        {
            var suppressionTypes = SuppressionFilterType.MaxAttempt.GetNameValuePairs();

            var organization = _organizationRepository.GetOrganizationbyId(filter.HealthPlanId);

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
            var collection = new List <GmsExcludedCustomerViewModel>();

            foreach (var suppressionType in suppressionTypes)
            {
                int totalRecords             = 0;
                var suppressionTypeCustomers = new List <GmsExcludedCustomerViewModel>();
                var pageNumber = 1;

                while (true)
                {
                    var excludedCustomers = _gmsExcludedCustomerRepository.GetGmsExcludedCallQueueCustomers(pageNumber, PageSize, filter, callQueue,
                                                                                                            (SuppressionFilterType)suppressionType.FirstValue, out totalRecords);

                    if (excludedCustomers.IsNullOrEmpty())
                    {
                        break;
                    }

                    var customerIds = excludedCustomers.Where(x => x.CustomerId.HasValue).Select(x => x.CustomerId.Value).ToArray();

                    var customers  = _customerRepository.GetCustomers(customerIds);
                    var customTags = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds);

                    suppressionTypeCustomers.AddRange(Create(excludedCustomers, customers, customTags, organization));

                    if ((pageNumber * PageSize) >= totalRecords)
                    {
                        break;
                    }

                    pageNumber++;
                }

                var distinctCustomers = suppressionTypeCustomers.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId));
                collection.AddRange(distinctCustomers);
            }

            return(collection);
        }
Пример #2
0
        public EventBasicInfoListModel GetEventBasicInfoForCallQueue(FillEventsCallQueueFilter filter, int pageSize, out int totalRecords)
        {
            var criteria = _healthPlanCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteria(filter.CallQueueId, filter.HealthPlanId, filter.AssignedToOrgRoleUserId, 0, filter.CriteriaId);

            if (criteria != null && criteria.IsQueueGenerated == false)
            {
                throw new Exception("Please wait for 10 minutes(max) after you have changed the criteria so that the queue is regenerated.");
            }
            var events = _eventRepository.GetHealthPlanEventsForCallQueue(filter, criteria.Id);

            if (events == null || !events.Any())
            {
                totalRecords = 0;
                return(null);
            }

            var endDate = DateTime.Today.AddDays(criteria.NoOfDays);

            events = events.Where(x => x.EventDate.Date <= endDate.Date);

            var outboundCallQueueFilter = new OutboundCallQueueFilter
            {
                CallQueueId   = criteria.CallQueueId,
                CriteriaId    = criteria.Id,
                HealthPlanId  = criteria.HealthPlanId ?? 0,
                Radius        = 25,
                GmsAccountIds = _settings.GmsAccountIds
            };

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(outboundCallQueueFilter);

            var eventIdsWithCustomers = _callQueueCustomerRepository.GetHealthPlanEventsForCriteria(outboundCallQueueFilter);

            events = events.Where(x => (eventIdsWithCustomers.IsNullOrEmpty() || eventIdsWithCustomers.Contains(x.Id)));

            events       = _fillEventsCallQueueHelper.GetAllTheEventFilledUnderPecentage(events, criteria.Percentage);
            totalRecords = events.Count();
            events       = events.OrderBy(ev => ev.EventDate).Skip((filter.PageNumber - 1) * pageSize).Take(pageSize);

            var eventList = _eventCallQueueHelper.EventBasicInfoListForCallQueue(events);

            return(eventList);
        }
Пример #3
0
        public ActionResult CallQueueEstimatedCustomer(OutboundCallQueueFilter filter, int pageNumber = 1)
        {
            filter = filter ?? new OutboundCallQueueFilter();
            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
            var model = _callQueueCustomerRepository.GetCallQueueEstimatedNumbers(filter);

            model.CallQueueCriteria = _healthPlanCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteria(filter.CallQueueId, filter.HealthPlanId, null, filter.CampaignId.HasValue ? filter.CampaignId.Value : 0, filter.CriteriaId);

            return(View(model));
        }
        public StartOutBoundCallViewModel GetCustomerContactViewModel(OutboundCallQueueFilter filter)
        {
            StartOutBoundCallViewModel customerContactViewModel = null;

            //var isAllowed = _callQueueCriteriaRepository.CheckForHealthplanRestriction(filter.AgentOrganizationId, filter.HealthPlanId);
            //if (!isAllowed)
            //{
            //    return new StartOutBoundCallViewModel
            //    {
            //        NoMoreCustomerInList = true
            //    };
            //}

            var iscriteriaAssignmentChanged = _callQueueCriteriaRepository.CheckForCriteriaAssignmentChange(filter.CriteriaId, filter.AgentOrganizationRoleUserId,
                                                                                                            filter.AgentOrganizationId, filter.HealthPlanId);

            if (iscriteriaAssignmentChanged)
            {
                return(new StartOutBoundCallViewModel
                {
                    AssignmentChanged = true
                });
            }

            var callQueue = _callQueueRepository.GetById(filter.CallQueueId);

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
            var index = 1;

            _logger.Info("fetching customer for agent " + _sessionContext.UserSession.UserName);
            do
            {
                _logger.Info(string.Format("Call Queue Customer loop number {0} for agent {1}", index++, _sessionContext.UserSession.UserName));

                _logger.Info("fetching next customers");
                customerContactViewModel = GetStartOutboundCallViewModel(filter, callQueue);
                if (customerContactViewModel != null && customerContactViewModel.NoMoreCustomerInList)
                {
                    _logger.Info("queue completed no customer found");
                    break;
                }

                Thread.Sleep(100);
            } while (customerContactViewModel == null && index < 3);

            if (customerContactViewModel == null)
            {
                customerContactViewModel = new StartOutBoundCallViewModel
                {
                    TryAgain = true
                };
            }

            return(customerContactViewModel);
        }
Пример #5
0
        public long CustomerCountForHealthPlanCriteria(HealthPlanCallQueueCriteria criteria, IEnumerable <CallQueue> callQueues, bool isForDashboard = false)
        {
            var  callQueueCategory         = callQueues.FirstOrDefault(x => x.Id == criteria.CallQueueId).Category;
            long totalCustomersForCriteria = 0;
            var  filter = new OutboundCallQueueFilter
            {
                CallQueueId   = criteria.CallQueueId,
                CriteriaId    = criteria.Id,
                HealthPlanId  = criteria.HealthPlanId ?? 0,
                GmsAccountIds = _settings.GmsAccountIds
                                //Radius = 25,
                                //ZipCode = criteria.ZipCode
            };

            if (callQueueCategory == HealthPlanCallQueueCategory.FillEventsHealthPlan)
            {
                _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
                totalCustomersForCriteria = _callQueueCustomerRepository.GetCallQueueCustomerCountForHealthPlanFillEvents(filter, isForDashboard);
            }
            else if (callQueueCategory == HealthPlanCallQueueCategory.MailRound)
            {
                filter.CampaignId = criteria.CampaignId;

                _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
                totalCustomersForCriteria = _callQueueCustomerRepository.GetMailRoundCallqueueCustomerCount(filter, isForDashboard);
            }
            else if (callQueueCategory == HealthPlanCallQueueCategory.LanguageBarrier)
            {
                _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
                totalCustomersForCriteria = _callQueueCustomerRepository.GetLanguageBarrierCallQueueCustomerCount(filter, isForDashboard);
            }
            else if (callQueueCategory == HealthPlanCallQueueCategory.AppointmentConfirmation)
            {
                _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);
                totalCustomersForCriteria = _callQueueCustomerRepository.GetConfirmationCallQueueCustomerCount(filter);
            }
            return(totalCustomersForCriteria);
        }
Пример #6
0
        private List <MailRoundCustomersReportViewModel> GetCustomersForMatrixReport(long healthPlanId, CallQueue callQueue)
        {
            var list = new List <MailRoundCustomersReportViewModel>();

            if (callQueue == null)
            {
                return(list);
            }

            var       pageNumber = 1;
            const int pageSize   = 100;

            var filter = new OutboundCallQueueFilter();

            filter.HealthPlanId  = healthPlanId;
            filter.CallQueueId   = callQueue.Id;
            filter.GmsAccountIds = _settings.GmsAccountIds;

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);

            while (true)
            {
                int totalRecords;
                var model = _callQueueCustomerReportService.GetCustomersForMatrixReport(pageNumber, pageSize, filter, callQueue, out totalRecords);
                if (model == null || model.Collection == null || !model.Collection.Any())
                {
                    break;
                }

                list.AddRange(model.Collection);
                _logger.Info(String.Format("\n\nPageNumber:{0} TotalRecords: {1},  Current Length: {2}", pageNumber, totalRecords, list.Count));

                pageNumber++;

                if (list.Count >= totalRecords)
                {
                    break;
                }
            }
            return(list);
        }
        public ListModelBase <CallQueueCustomersReportModel, OutboundCallQueueFilter> GetCallQueueCustomers(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var callQueueFilter = filter as OutboundCallQueueFilter;

            callQueueFilter = callQueueFilter ?? new OutboundCallQueueFilter();
            if (!callQueueFilter.CustomTags.IsNullOrEmpty())
            {
                callQueueFilter.CustomCorporateTag = string.Join(",", callQueueFilter.CustomTags);
            }

            var criteria = _callQueueCriteriaRepository.GetById(callQueueFilter.CriteriaId);

            var callQueueId = callQueueFilter.CallQueueId;

            callQueueFilter.CallQueueId   = criteria.CallQueueId;
            callQueueFilter.GmsAccountIds = _settings.GmsAccountIds;
            //callQueueFilter.NumberOfDays = _settings.CustomerReturnInCallQueue;
            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(callQueueFilter);

            var callQueue = _callQueueRepository.GetById(callQueueFilter.CallQueueId);
            var callqueueCustomersList = new List <CallQueueCustomer>();

            totalRecords = 0;


            if (criteria.IsQueueGenerated)
            {
                if (callQueue.Category == HealthPlanCallQueueCategory.CallRound)
                {
                    var customersInQueueList = _callQueueCustomerRepository.GetOutboundCallRoundCallQueue(callQueueFilter, pageNumber, pageSize, callQueue, callQueueFilter.CriteriaId, out totalRecords);
                    callqueueCustomersList = customersInQueueList == null ? new List <CallQueueCustomer>() : customersInQueueList.ToList();
                }
                else if (callQueue.Category == HealthPlanCallQueueCategory.FillEventsHealthPlan)
                {
                    var customersInQueueList = _callQueueCustomerRepository.GetCallQueueCustomerForHealthPlanFillEvents(callQueueFilter, pageNumber, pageSize, callQueueFilter.CriteriaId, callQueue, out totalRecords);
                    callqueueCustomersList = customersInQueueList == null ? new List <CallQueueCustomer>() : customersInQueueList.ToList();
                }
                else if (callQueue.Category == HealthPlanCallQueueCategory.LanguageBarrier)
                {
                    var customersInQueueList = _callQueueCustomerRepository.GetLanguageBarrierCallQueueCustomer(callQueueFilter, pageNumber, pageSize, callQueueFilter.CriteriaId, callQueue, out totalRecords);
                    callqueueCustomersList = customersInQueueList == null ? new List <CallQueueCustomer>() : customersInQueueList.ToList();
                }
                else if (callQueue.Category == HealthPlanCallQueueCategory.UncontactedCustomers)
                {
                    var customersInQueueList = _callQueueCustomerRepository.GetUncontactedCallQueueCustomers(callQueueFilter, pageNumber, pageSize, callQueueFilter.CriteriaId, _settings.NeverBeenCalledInDays, _settings.NoPastAppointmentInDaysUncontactedCustomers, out totalRecords);
                    callqueueCustomersList = customersInQueueList == null ? new List <CallQueueCustomer>() : customersInQueueList.ToList();
                }
                else if (callQueue.Category == HealthPlanCallQueueCategory.NoShows)
                {
                    var customersInQueueList = _callQueueCustomerRepository.GetNoShowCallQueueCustomer(callQueueFilter, pageNumber, pageSize, callQueueFilter.CriteriaId, out totalRecords);
                    callqueueCustomersList = customersInQueueList == null ? new List <CallQueueCustomer>() : customersInQueueList.ToList();
                }
                else if (callQueue.Category == HealthPlanCallQueueCategory.MailRound)
                {
                    var customersInQueueList = _callQueueCustomerRepository.GetMailRoundCallqueueCustomer(callQueueFilter, pageNumber, pageSize, callQueueFilter.CriteriaId, callQueue, out totalRecords);
                    callqueueCustomersList = customersInQueueList == null ? new List <CallQueueCustomer>() : customersInQueueList.ToList();
                }
            }

            var organization = _organizationRepository.GetOrganizationbyId(callQueueFilter.HealthPlanId);

            var rejectedCustomersStats = _excludedCustomerRepository.GetExcludedCustomers(callQueueFilter, callQueue);
            CallQueueCustomersReportModelListModel model = null;

            var criteriaModel = _healthPlanCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteria(callQueueFilter.CallQueueId, callQueueFilter.HealthPlanId, null, callQueueFilter.CampaignId.HasValue ? callQueueFilter.CampaignId.Value : 0, callQueueFilter.CriteriaId);

            callQueueFilter.CallQueueId = callQueueId;

            if (!callqueueCustomersList.IsNullOrEmpty())
            {
                var customerIds = callqueueCustomersList.Select(x => x.CustomerId.Value);

                var customers           = _customerRepository.GetCustomers(customerIds.ToArray());
                var corporateAccount    = ((IUniqueItemRepository <CorporateAccount>)_corporateAccountRepository).GetById(callQueueFilter.HealthPlanId);
                var corporateCustomTags = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds);
                model = _callQueueCustomerReportFactory.GetCallQueueCustomersList(callqueueCustomersList, customers, corporateCustomTags, corporateAccount, criteria.IsQueueGenerated, criteriaModel);
            }

            model = model ?? new CallQueueCustomersReportModelListModel();
            model.CallQueueCriteria      = criteriaModel;
            model.IsQueueGenerated       = criteria.IsQueueGenerated;
            model.RejectedCustomersStats = rejectedCustomersStats ?? new CallQueueCustomersStatsViewModel();
            model.HealthPlanName         = organization.Name;
            model.CallQueueCategory      = callQueue.Category;
            model.CallQueueName          = callQueue.Name;
            model.Filter = callQueueFilter;

            return(model);
        }
        public void PollForReportGeneration()
        {
            var healthPlans = !_healthPlanIds.IsNullOrEmpty() ? _corporateAccountRepository.GetByIds(_healthPlanIds) : _corporateAccountRepository.GetAllHealthPlan();

            var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound);

            var collection = new List <GmsCallQueueCustomerViewModel>();

            foreach (var healthPlan in healthPlans)
            {
                if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount)
                {
                    break;
                }

                _logger.Info(string.Format("Getting call queue customers for Account ID : {0} and Tag : {1}", healthPlan.Id, healthPlan.Tag));

                var criterias = _healthPlanCallQueueCriteriaRepository.GetCriteriaByHealthPlanCallQueue(healthPlan.Id, HealthPlanCallQueueCategory.MailRound);

                if (!_settings.GmsCampaignIds.IsNullOrEmpty())
                {
                    criterias = _healthPlanCallQueueCriteriaRepository.GetByCampaignIds(_settings.GmsCampaignIds, healthPlan.Id);

                    _logger.Info(string.Format("Found {0} criterias for Campaign IDs : ", criterias.Count(), string.Join(",", _settings.GmsCampaignIds)));
                }

                foreach (var criteria in criterias)
                {
                    if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount)
                    {
                        break;
                    }

                    _logger.Info(string.Format("Criteria ID : {0}", criteria.Id));

                    try
                    {
                        var filter = new OutboundCallQueueFilter
                        {
                            CallQueueId             = callQueue.Id,
                            CriteriaId              = criteria.Id,
                            CampaignId              = criteria.CampaignId,
                            Tag                     = healthPlan.Tag,
                            HealthPlanId            = healthPlan.Id,
                            UseCustomTagExclusively = false
                        };

                        if (filter.HealthPlanId == _settings.OptumUtAccountId)
                        {
                            filter.CustomCorporateTag = _settings.OptumUtCustomTagsForGms;
                        }
                        else if (filter.HealthPlanId == 1083)
                        {
                            filter.CustomCorporateTag = "UHC-TX_GMS_2018_List-1";
                        }
                        else if (filter.HealthPlanId == 1066)
                        {
                            filter.CustomCorporateTag = "Excellus_GMS_2018_List-1";
                        }
                        else if (filter.HealthPlanId == 1061)
                        {
                            filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-1_GMS,Optum-NV_Assessments_2018_List-2_GMS,Optum-NV_Assessments_2018_List-3_GMS,Optum-NV_Mammo_2018_List-2_GMS";
                        }
                        else if (filter.HealthPlanId == 1111)
                        {
                            filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-4_GMS";
                        }
                        else if (filter.HealthPlanId == 1087)
                        {
                            filter.CustomCorporateTag = "UHC-AZ_Assessments_2018_List-1_GMS";
                        }
                        else if (filter.HealthPlanId == 1093)
                        {
                            filter.CustomCorporateTag = "UHC-CT_Assessments_2018_List-1_GMS";
                        }

                        _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter);

                        var dataGen = new ExportableDataGenerator <GmsCallQueueCustomerViewModel, OutboundCallQueueFilter>(_callQueueCustomerReportService.GetGmsCallQueueCustomersReport, _logger);

                        var model = dataGen.GetData(filter);

                        var distinctCustomers = model.Collection.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId));

                        collection.AddRange(distinctCustomers);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Error getting call queue customers for Account ID : " + healthPlan.Id + " Criteria ID : " + criteria.Id);
                        _logger.Error(ex);
                    }
                }
            }

            if (!collection.Any())
            {
                _logger.Info("No records found.");
                return;
            }

            if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount)
            {
                collection = collection.Take(_settings.GmsMaxCustomerCount).ToList();
            }

            if (!Directory.Exists(_settings.GmsCustomerReportPath))
            {
                Directory.CreateDirectory(_settings.GmsCustomerReportPath);
            }

            var fileName = _settings.GmsCustomerReportPath + @"\" + string.Format("PatientList_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));

            WriteCsv(collection, fileName);

            if (_settings.SendReportToGmsSftp)
            {
                _logger.Info("Sending Customer List to GMS sftp.");
                var sftpFolderReportDirectory = _settings.GmsSftpPath;
                var processFtp = new ProcessFtp(_logger, _settings.GmsSftpHost, _settings.GmsSftpUserName, _settings.GmsSftpPassword);

                processFtp.UploadSingleFile(fileName, sftpFolderReportDirectory, "");
                _logger.Info("Sent Customer List to GMS sftp.");
            }
            else
            {
                _logger.Info("Setting to send Customer list to sftp is OFF.");
            }
        }