예제 #1
0
        public ListModelBase <GmsExcludedCustomerViewModel, OutboundCallQueueFilter> GetExcludedCustomers(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var outboundCallQueueFilter = filter as OutboundCallQueueFilter ?? new OutboundCallQueueFilter();
            var organization            = _organizationRepository.GetOrganizationbyId(outboundCallQueueFilter.HealthPlanId);

            CallQueue callQueue = null;

            var criteria = _healthPlanCallQueueCriteriaRepository.GetById(outboundCallQueueFilter.CriteriaId);

            callQueue = _callQueueRepository.GetById(outboundCallQueueFilter.CallQueueId > 0 ? outboundCallQueueFilter.CallQueueId : criteria.CallQueueId);
            outboundCallQueueFilter.CallQueueId = callQueue.Id;

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(outboundCallQueueFilter);

            var excludedCustomers = _gmsExcludedCustomerRepository.GetExcludedCallQueueCustomers(pageNumber, pageSize, outboundCallQueueFilter, callQueue, outboundCallQueueFilter.SuppressionType, out totalRecords);

            var model = new ExcludedCustomerListModel {
                Filter = outboundCallQueueFilter
            };
            var customerIds = excludedCustomers.Where(x => x.CustomerId.HasValue).Select(x => x.CustomerId.Value).ToArray();

            if (!customerIds.IsNullOrEmpty())
            {
                var customers  = _customerRepository.GetCustomers(customerIds);
                var customTags = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds);
                model.Collection = Create(excludedCustomers, customers, customTags, organization);

                return(model);
            }
            model.Collection = Create(excludedCustomers, null, null, organization);

            return(model);
        }
        //public void GetDataFromAPI(PreAssessmentCallQueueModel preAssessmentCallQueueModel)
        //{

        //    try
        //    {


        //        var eventIds = preAssessmentCallQueueModel.Data.Select(x => x.EventID).Distinct();
        //        var eventDetails = _eventRepository.GetEvents(eventIds);
        //        var NotexistsEvents = eventIds.Except(eventDetails.Select(x=>x.Id));
        //        if (NotexistsEvents.Count() > default(long))
        //        {
        //            _logger.Info(string.Format("EventId : {0}   is not exists", string.Join(",", NotexistsEvents)));
        //        }

        //        foreach (var eventId in eventDetails)
        //        {


        //                var customers = preAssessmentCallQueueModel.Data.Where(x => x.EventID == eventId.Id);
        //                foreach (var customer in customers)
        //                {
        //                    var eventCustomer = _eventCustomerRepository.Get(eventId.Id, customer.CustomerId);
        //                    if (eventCustomer != null)
        //                    {

        //                        var flagupdate = _eventCustomerRepository.UpdateGeneratePreAssessmentCallQueueStatus(eventCustomer.Id, customer.IsAssessmentCompleted);
        //                    }
        //                    else
        //                    {
        //                        _logger.Info(string.Format("CustomerId : {0}   is not exists in this EventId: {1}", customer.CustomerId, eventId.Id));
        //                    }

        //                }


        //        }

        //    }
        //    catch (Exception exception)
        //    {
        //        throw exception;
        //    }
        //}

        public long StartCallForPreAssessment(long orgRoleUserId, long customerId, long eventId, long callQueueId, long callId = 0)
        {
            var callQueue = _callQueueRepository.GetById(callQueueId);
            var preAssessmentCustomerCallQueueCallAttempt = _preAssessmentCustomerCallQueueCallAttemptRepository.GetCustomerCallQueueCallPreAssessmentAttemptIfCustomerLockedforAgent(customerId, orgRoleUserId, eventId);

            if (preAssessmentCustomerCallQueueCallAttempt != null)
            {
                var callQueueCustomerLock = new PreAssessmentCallQueueCustomerLock
                {
                    CreatedBy  = orgRoleUserId,
                    CreatedOn  = DateTime.Now,
                    CustomerId = customerId
                };

                _preAssessmentCallQueueCustomerLockRepository.UpdatePreAssessmentCallQueueCustomerLock(callQueueCustomerLock);

                if (preAssessmentCustomerCallQueueCallAttempt.CallId.HasValue)
                {
                    return(preAssessmentCustomerCallQueueCallAttempt.CallId.Value);
                }
            }
            var eventCustomer = _eventCustomerRepository.GetRegisteredEventForUser(customerId, eventId);

            if (eventCustomer == null)
            {
                return(0);
            }
            var customer = _customerRepository.GetCustomer(customerId);

            return(SaveCallQueueCustomerDetailAndGetCallId(customer, callQueue, orgRoleUserId, callId, (long)DialerType.Vici, eventId));
        }
예제 #3
0
        public ActionResult Create(CallQueueEditModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                model = _callQueueService.SaveCallQueue(model, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
                var callQueue  = _callQueueRepository.GetById(model.Id);
                var queueCount = _outboundCallQueueService.GetCallQueueCustomers(callQueue).Count;

                ModelState.Clear();
                var newModel = new CallQueueEditModel
                {
                    FeedbackMessage = queueCount > 0
                     ? FeedbackMessageModel.CreateSuccessMessage(string.Format("Call Queue created sucessfully. You can create more call queue or close this page. Based on the Queue created, currently there are {0} records satisfying the criteria(s).", queueCount))
                     : FeedbackMessageModel.CreateWarningMessage(string.Format("Call Queue created sucessfully. You can create more call queue or close this page. Based on the Queue created, currently there are {0} records satisfying the criteria(s).", queueCount))
                };
                return(View(newModel));
            }
            catch (Exception ex)
            {
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Error:" + ex.Message);
                return(View(model));
            }
        }
예제 #4
0
        public OutboundCallQueueListModel GetOutboundCallQueue([FromUri] OutboundCallQueueFilter filter)
        {
            int  totalRecords;
            var  callQueue  = _callQueueRepository.GetById(filter.CallQueueId);
            var  criteria   = _systemGeneratedCallQueueCritairaService.GetSystemGeneratedCallQueueCriteria(filter.CallQueueId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
            long criteriaId = criteria != null ? criteria.Id : 0;
            OutboundCallQueueListModel model = null;

            if (callQueue.Category == CallQueueCategory.Upsell || callQueue.Category == CallQueueCategory.Confirmation)
            {
                if (criteria != null && criteria.IsQueueGenerated == false)
                {
                    model = new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = false
                    };
                    totalRecords = 0;
                }
                else
                {
                    model = _outboundCallQueueService.GetOutboundCallQueueUpsellAndConfirmation(filter, callQueue, PageSize, criteriaId, out totalRecords) ??
                            new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = true
                    };
                }
            }
            else
            {
                if (criteria != null && criteria.IsQueueGenerated == false)
                {
                    model = new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = false
                    };
                    totalRecords = 0;
                }
                else
                {
                    model = _outboundCallQueueService.GetOutboundCallQueueListModel(filter, callQueue, PageSize, criteriaId, out totalRecords) ?? new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = true
                    };
                }
            }

            model.PagingModel = new PagingModel(filter.PageNumber, PageSize, totalRecords, null);

            return(model);
        }
        public HealthPlanCallQueueCriteria GetSystemGeneratedCallQueueCriteria(long callQueueId, long healthPlanId, long?organizationUserRoleId, long campaignId, long?criterialId = null)
        {
            var callQueue = _callQueueRepository.GetById(callQueueId);
            HealthPlanCallQueueCriteria criteria = null;

            if (callQueue.Category == HealthPlanCallQueueCategory.LanguageBarrier)
            {
                criteria = _healthPlanCallQueueCriteriaRepository.GetQueueCriteriaForQueue(callQueueId, healthPlanId);
            }
            else
            {
                criteria = criterialId.HasValue
                    ? _healthPlanCallQueueCriteriaRepository.GetById(criterialId.Value)
                    : _healthPlanCallQueueCriteriaRepository.GetQueueCriteria(callQueueId, organizationUserRoleId, healthPlanId, DateTime.Today);
            }

            return(criteria);
        }
        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);
        }
예제 #7
0
        public CallQueueContactViewModel GetCategoryByCallQueueCustomerId(long callQueueCustomerId)
        {
            var callQueueContactViewModel = new CallQueueContactViewModel();
            var callQueueCustomer         = _callQueueCustomerRepository.GetById(callQueueCustomerId);
            var callQueue = _callQueueRepository.GetById(callQueueCustomer.CallQueueId);

            callQueueContactViewModel.CallQueueId = callQueue.Id;
            callQueueContactViewModel.Name        = callQueue.Name;
            callQueueContactViewModel.Category    = callQueue.Category;
            //if (callQueueCustomer.EventId.HasValue)
            //{
            //    var host = _hostRepository.GetHostForEvent(callQueueCustomer.EventId.Value);
            //    callQueueContactViewModel.EventZipCode = host.Address.ZipCode.Zip;
            //}
            return(callQueueContactViewModel);
        }
예제 #8
0
        public long SaveViciDialerCall(ViciDialerCallModel model, long orgRoleUserId)
        {
            long status      = 0;
            var  disposition = string.Empty;

            if (model.Disposition.ToUpper() == "ANS.MACH")//Left Voice mail
            {
                status = (long)CallStatus.VoiceMessage;
            }
            else if (model.Disposition.ToUpper() == "NO.ANS" || model.Disposition.ToUpper() == "BUSY") //No Answer/Busy/Mail Full
            {
                status = (long)CallStatus.NoAnswer;
            }
            else if (model.Disposition.ToUpper() == "DEAD") //Incorrect Phone number
            {
                status      = (long)CallStatus.TalkedtoOtherPerson;
                disposition = ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString();
            }
            CallQueue callQueue = null;

            if (model.CallQueueId > 0)
            {
                callQueue = _callQueueRepository.GetById(model.CallQueueId);
            }

            var customer = _customerRepository.GetCustomer(model.CustomerId);
            var account  = _corporateAccountRepository.GetByTag(customer.Tag);

            bool?isContacted = false;

            if (callQueue == null || callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation)
            {
                isContacted = null;
            }
            else
            {
                isContacted = (status == (long)CallStatus.Attended || status == (long)CallStatus.VoiceMessage || status == (long)CallStatus.LeftMessageWithOther);
            }

            var call = new Call()
            {
                CallDateTime           = model.CallStartDateTime,
                StartTime              = model.CallStartDateTime,
                EndTime                = model.CallEndDateTime,
                CallStatus             = CallType.Existing_Customer.GetDescription(),
                IsIncoming             = false,
                CalledCustomerId       = model.CustomerId,
                Status                 = status,
                CreatedByOrgRoleUserId = orgRoleUserId,
                IsNewCustomer          = false,
                DateCreated            = model.CallStartDateTime,
                DateModified           = model.CallStartDateTime,
                ReadAndUnderstood      = true,
                HealthPlanId           = account != null ? account.Id : (long?)null,
                CallQueueId            = callQueue != null ? callQueue.Id : (long?)null,
                DialerType             = (long)DialerType.Vici,
                CalledInNumber         = model.CallerId,
                CallerNumber           = model.CallerPhoneNumber,
                CallBackNumber         = model.CallerPhoneNumber,
                IsContacted            = isContacted,
                Disposition            = disposition,
                ProductTypeId          = customer.ProductTypeId
            };

            call = _callCenterCallRepository.Save(call);

            if (status == (long)CallStatus.TalkedtoOtherPerson && disposition == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString())
            {
                _customerService.UpdateIsIncorrectPhoneNumber(model.CustomerId, true, orgRoleUserId);
            }

            if (!string.IsNullOrEmpty(model.CallerId))
            {
                var customerAccountGlocomNumber = new CustomerAccountGlocomNumber
                {
                    CallId       = call.Id,
                    CustomerId   = model.CustomerId,
                    GlocomNumber = PhoneNumber.ToNumber(model.CallerId),
                    CreatedDate  = model.CallStartDateTime,
                    IsActive     = true
                };
                _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber);
            }

            if (callQueue != null)
            {
                var callQueueCustomer = _callQueueCustomerRepository.GetCallQueueCustomerByCustomerIdAndHealthPlanId(model.CustomerId, account.Id, callQueue.Category);

                var callQueueCustomerCall = new CallQueueCustomerCall {
                    CallQueueCustomerId = callQueueCustomer.Id, CallId = call.Id
                };
                _callQueueCustomerCallRepository.Save(callQueueCustomerCall);



                bool removeFromCallQueue = status == (long)CallStatus.TalkedtoOtherPerson;
                var  callQueueStatus     = CallQueueStatus.Initial;
                if (removeFromCallQueue)
                {
                    callQueueStatus = CallQueueStatus.Removed;
                }

                _callQueueCustomerContactService.SetCallQueueCustomerStatus(callQueueCustomer, callQueueStatus, orgRoleUserId, false, status, model.CallStartDateTime);


                var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0;

                if (prospectCustomerId == 0)
                {
                    var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(model.CustomerId);
                    if (prospectCustomer != null)
                    {
                        prospectCustomerId = prospectCustomer.Id;
                    }
                }

                _callQueueCustomerRepository.UpdateOtherCustomerAttempt(callQueueCustomer.Id, model.CustomerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId, status, model.CallStartDateTime, isForParsing: true, disposition: disposition);
            }

            return(call.Id);
        }
        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);
        }
예제 #10
0
        public Customer SaveCallOutCome(CallOutComeEditModel model, long organizationRoleUserId)
        {
            Customer customer         = _customerRepository.GetCustomer(model.CustomerId);
            var      isConverted      = _eventRepository.CheckCustomerRegisteredForFutureEvent(model.CustomerId);
            var      prospectCustomer = ((IProspectCustomerRepository)_prospectCustomerRepository).GetProspectCustomerByCustomerId(model.CustomerId);

            if (prospectCustomer == null)
            {
                prospectCustomer = _prospectCustomerFactory.CreateProspectCustomerFromCustomer(customer, isConverted);
            }
            else
            {
                prospectCustomer.IsConverted = isConverted;
            }

            if (model.CallStatusId == (long)CallStatus.Attended || model.CallStatusId == (long)CallStatus.VoiceMessage || model.CallStatusId == (long)CallStatus.LeftMessageWithOther ||
                model.CallStatusId == (long)CallStatus.InvalidNumber || model.CallStatusId == (long)CallStatus.NoAnswer || model.CallStatusId == (long)CallStatus.NoEventsInArea || model.CallStatusId == (long)CallStatus.TalkedtoOtherPerson)
            {
                prospectCustomer.IsContacted   = true;
                prospectCustomer.ContactedDate = DateTime.Now;
                prospectCustomer.ContactedBy   = organizationRoleUserId;
            }
            if (!string.IsNullOrEmpty(model.DispositionAlias))
            {
                prospectCustomer.Tag           = (ProspectCustomerTag)Enum.Parse(typeof(ProspectCustomerTag), model.DispositionAlias);
                prospectCustomer.TagUpdateDate = DateTime.Now;
            }

            prospectCustomer         = UpdateProspectCustomer(prospectCustomer, model.CallBackDateTime);
            model.ProspectCustomerId = prospectCustomer.Id;
            // }

            var notes = string.IsNullOrWhiteSpace(model.Note) ? "" : model.Note;

            if ((ProspectCustomerTag)Enum.Parse(typeof(ProspectCustomerTag), model.DispositionAlias) == ProspectCustomerTag.MemberStatesIneligibleMastectomy)
            {
                notes = notes.Replace(ProspectCustomerTag.MemberStatesIneligibleMastectomy.GetDescription() + " : ", "");
                notes = !string.IsNullOrWhiteSpace(notes) ? ProspectCustomerTag.MemberStatesIneligibleMastectomy.GetDescription() + " : " + notes : ProspectCustomerTag.MemberStatesIneligibleMastectomy.GetDescription();
            }

            SaveNotes(notes, model.CallId);
            SaveRegistrationNotes(model.CustomerId, notes, organizationRoleUserId);

            var objCall = _callCenterCallRepository.GetById(model.CallId);

            var disposition = "";
            var tag         = ProspectCustomerTag.Unspecified;

            if ((model.CallStatusId == (long)CallStatus.Attended || model.CallStatusId == (long)CallStatus.LeftMessageWithOther || model.CallStatusId == (long)CallStatus.TalkedtoOtherPerson ||
                 model.CallStatusId == (long)CallStatus.NoEventsInArea) && !string.IsNullOrEmpty(model.DispositionAlias))
            {
                tag = (ProspectCustomerTag)Enum.Parse(typeof(ProspectCustomerTag), model.DispositionAlias);
                if (tag == ProspectCustomerTag.BookedAppointment || tag == ProspectCustomerTag.HomeVisitRequested || tag == ProspectCustomerTag.MobilityIssue ||
                    tag == ProspectCustomerTag.DoNotCall || tag == ProspectCustomerTag.Deceased || tag == ProspectCustomerTag.NoLongeronInsurancePlan ||
                    tag == ProspectCustomerTag.MobilityIssues_LeftMessageWithOther || tag == ProspectCustomerTag.DebilitatingDisease || tag == ProspectCustomerTag.InLongTermCareNursingHome ||
                    tag == ProspectCustomerTag.PatientConfirmed || tag == ProspectCustomerTag.CancelAppointment || tag == ProspectCustomerTag.ConfirmLanguageBarrier || tag == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers ||
                    tag == ProspectCustomerTag.DeclinedMobileAndTransferredToHome || tag == ProspectCustomerTag.DeclinedMobileAndHomeVisit)
                {
                    model.RemoveFromQueue = true;
                }

                disposition = model.DispositionAlias;
            }

            objCall.NotInterestedReasonId = model.NotIntrestedReasonId;

            if (model.CallQueueId > 0)
            {
                var callQueue = _callQueueRepository.GetById(model.CallQueueId);
                if (callQueue != null)
                {
                    objCall.IsContacted = false;
                    if (callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation)
                    {
                        objCall.IsContacted = null;
                    }
                    else
                    {
                        if (model.CallStatusId == (long)CallStatus.Attended || model.CallStatusId == (long)CallStatus.VoiceMessage || model.CallStatusId == (long)CallStatus.LeftMessageWithOther || model.CallStatusId == (long)CallStatus.InvalidNumber || model.CallStatusId == (long)CallStatus.NoAnswer || model.CallStatusId == (long)CallStatus.NoEventsInArea || model.CallStatusId == (long)CallStatus.TalkedtoOtherPerson)
                        {
                            objCall.IsContacted = true;
                        }
                    }
                }
            }

            if (model.DoNotCall || tag == ProspectCustomerTag.DoNotCall)
            {
                if (model.ProspectCustomerId > 0)
                {
                    ((IProspectCustomerRepository)_prospectCustomerRepository).UpdateDoNotCallStatus(model.ProspectCustomerId, ProspectCustomerConversionStatus.Declined);
                }

                customer = _customerService.UpdateDoNotCallStatus(customer, false, (long)DoNotContactSource.CallCenter);
            }
            else if (model.CallStatusId == (long)CallStatus.Attended && tag == ProspectCustomerTag.LanguageBarrier)
            {
                customer = _customerService.UpdateIsLanguageBarrier(customer, true);
            }
            else
            {
                if (model.ProspectCustomerId > 0)
                {
                    ((IProspectCustomerRepository)_prospectCustomerRepository).UpdateDoNotCallStatus(model.ProspectCustomerId, ProspectCustomerConversionStatus.NotConverted);
                }

                customer = _customerService.UpdateDoNotCallStatus(customer, true);
            }

            if (model.CustomerId > 0 && (model.CallStatusId == (long)CallStatus.TalkedtoOtherPerson && tag == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers) || (model.CallStatusId == (long)CallStatus.Attended && tag == ProspectCustomerTag.IncorrectPhoneNumber))
            {
                customer = _customerService.UpdateIsIncorrectPhoneNumber(customer, true);
            }
            else if (model.CallStatusId == (long)CallStatus.InvalidNumber)
            {
                var secondLastCall = _callCenterCallRepository.GetSecondLastCall(model.CustomerId, model.CallId);
                if (secondLastCall != null && secondLastCall.Status == (long)CallStatus.InvalidNumber && secondLastCall.InvalidNumberCount == 1)
                {
                    objCall.InvalidNumberCount = 2;
                    customer = _customerService.UpdateIsIncorrectPhoneNumber(customer, true);
                }
                else
                {
                    objCall.InvalidNumberCount = 1;
                    customer = _customerService.UpdateIsIncorrectPhoneNumber(customer, false);
                }
            }
            else
            {
                objCall.InvalidNumberCount = 0;
                customer = _customerService.UpdateIsIncorrectPhoneNumber(customer, false);
            }

            if (model.CallStatusId == (long)CallStatus.Attended && (tag == ProspectCustomerTag.DeclinedMobileAndTransferredToHome || tag == ProspectCustomerTag.MemberStatesIneligibleMastectomy))
            {
                customer.ActivityId = null;
            }
            else if (objCall.Status == (long)CallStatus.Attended && (objCall.Disposition == ProspectCustomerTag.DeclinedMobileAndTransferredToHome.ToString() || objCall.Disposition == ProspectCustomerTag.MemberStatesIneligibleMastectomy.ToString()))
            {
                customer.ActivityId = model.ActivityId > 0 ? model.ActivityId : (long?)null;
            }

            if (model.CallStatusId == (long)CallStatus.Attended && tag == ProspectCustomerTag.MemberStatesIneligibleMastectomy)
            {
                customer = _customerService.UpdateDoNotCallStatuswithReason(customer, false, ProspectCustomerTag.MemberStatesIneligibleMastectomy);
                var noteId = SaveDNCNotes(ProspectCustomerTag.MemberStatesIneligibleMastectomy.GetDescription(), organizationRoleUserId);
                customer.DoNotContactReasonNotesId = noteId;
            }
            else if (objCall.Status == (long)CallStatus.Attended && objCall.Disposition == ProspectCustomerTag.MemberStatesIneligibleMastectomy.ToString())
            {
                customer = _customerService.UpdateDoNotCallStatus(customer, true);
            }

            objCall.Status      = model.CallStatusId;
            objCall.Disposition = disposition;
            _callCenterCallRepository.Save(objCall);

            UpdateOutboundCallStatus(organizationRoleUserId, model.CallQueueCustomerId, model.CallBackDateTime, model.RemoveFromQueue);

            if (objCall.Status == (long)CallStatus.Attended)
            {
                ModifyCustomerToSaveConsent(customer, model);
            }
            _customerService.SaveCustomerOnly(customer, organizationRoleUserId);

            UpdateCallProspectCustomerData(model, model.CallBackDateTime, organizationRoleUserId, model.CallQueueCustomerId, model.RemoveFromQueue);

            return(customer);
        }
예제 #11
0
        public CallQueueEditModel SaveCallQueue(CallQueueEditModel callQueueEditModel, long orgRoleUserId)
        {
            var callQueue = Mapper.Map <CallQueueEditModel, CallQueue>(callQueueEditModel);

            if (callQueue.Id > 0)
            {
                var callQueueInDb = _callQueueRepository.GetById(callQueue.Id);
                callQueue.DataRecorderMetaData                      = callQueueInDb.DataRecorderMetaData;
                callQueue.LastQueueGeneratedDate                    = callQueueInDb.LastQueueGeneratedDate;
                callQueue.DataRecorderMetaData.DateModified         = DateTime.Now;
                callQueue.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(orgRoleUserId);
            }
            else
            {
                callQueue.DataRecorderMetaData = new DataRecorderMetaData(orgRoleUserId, DateTime.Now, null);
            }
            Script script = null;

            if (callQueueEditModel.ScriptId > 0)
            {
                script              = _scriptRepository.GetById(callQueueEditModel.ScriptId);
                script.ScriptText   = callQueueEditModel.ScriptText;
                script.DateModified = DateTime.Now;
            }
            else
            {
                script = new Script
                {
                    Name         = callQueueEditModel.Name,
                    ScriptText   = callQueueEditModel.ScriptText,
                    Description  = "",
                    DateCreated  = DateTime.Now,
                    DateModified = DateTime.Now,
                    ScriptTypeId = (long)ScriptType.OutboundCallQueueScript
                };
            }

            script             = _scriptRepository.Save(script);
            callQueue.ScriptId = script.Id;

            callQueue = _callQueueRepository.Save(callQueue);


            foreach (var criteriaEditModel in callQueueEditModel.Criterias)
            {
                criteriaEditModel.CallQueueId = callQueue.Id;
            }
            var criterias = Mapper.Map <IEnumerable <CallQueueCriteriaEditModel>, IEnumerable <CallQueueCriteria> >(callQueueEditModel.Criterias);

            _callQueueCriteriaRepository.Save(criterias, callQueue.Id);

            foreach (var callQueueAssignmentEditModel in callQueueEditModel.Assignments)
            {
                callQueueAssignmentEditModel.CallQueueId = callQueue.Id;
            }
            var assignments = Mapper.Map <IEnumerable <CallQueueAssignmentEditModel>, IEnumerable <CallQueueAssignment> >(callQueueEditModel.Assignments);

            _callQueueAssignmentRepository.Save(assignments, callQueue.Id);

            callQueueEditModel.Id       = callQueue.Id;
            callQueueEditModel.ScriptId = script.Id;

            return(callQueueEditModel);
        }