예제 #1
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);
        }