private string GetCurrentStatus(Customer customer, IEnumerable <DirectMail> directMails, EventCustomer eventCustomer, EventVolumeModel eventModel, EventVolumeModel lastScreeningEvent, ProspectCustomer prospectCustomer, DateTime fromDate, DateTime toDate, CustomerEligibility customerEligibility) { if (eventCustomer != null && eventCustomer.NoShow) { return(CurrentStatus.NoShow); } if (eventModel != null && eventModel.EventDate.Date >= DateTime.Today && (eventCustomer != null && eventCustomer.AppointmentId.HasValue)) { return(CurrentStatus.ScheduledFutureAppointment); } //if (eventModel != null && eventModel.EventDate.Date == DateTime.Today && (eventCustomer != null && eventCustomer.AppointmentId.HasValue)) //{ // return CompletionStatus.ScheduledForToday; //} if (lastScreeningEvent != null) { return(CurrentStatus.ScheduledTestingComplete); } if (eventCustomer != null && !eventCustomer.AppointmentId.HasValue) { return(CurrentStatus.ScheduledCancelled); } if (customer.IsIncorrectPhoneNumber) { return(CurrentStatus.InvalidData); } if (CheckCustomerUnableToSchedule(prospectCustomer, fromDate, toDate, customerEligibility)) { return(CurrentStatus.UnableToSchedule); } if (CheckCustomerRefusal(prospectCustomer, fromDate, toDate) || IsCustomerMarkedDonotContact(customer, fromDate, toDate)) { return(CurrentStatus.Refusal); } if (directMails != null && directMails.Count() > 4) { var customerDirectMail = directMails.OrderByDescending(dm => dm.MailDate).FirstOrDefault(); if (customerDirectMail.MailDate.AddDays(28) < DateTime.Today) { return(CurrentStatus.Exhausted); } } return(CurrentStatus.InProgress); }
public CorporateEventViewModel Create(EventVolumeModel eventModel) { var corporateEventCustomerModel = new CorporateEventViewModel { EventId = eventModel.EventCode, EventDate = eventModel.EventDate, Address = eventModel.Address, Location = eventModel.Location, Pod = eventModel.Pod, CustomerCount = eventModel.AppointmentsBooked, }; return(corporateEventCustomerModel); }
private string GetCompletionStatus(EventCustomer eventCustomer, DateTime eventDate, EventVolumeModel lastScreeningEvent) { if (eventCustomer.NoShow) { return(CompletionStatus.NoShow); } if (eventCustomer.LeftWithoutScreeningReasonId.HasValue) { return(CompletionStatus.LeftWithoutScreening); } if (!eventCustomer.AppointmentId.HasValue) { return(CompletionStatus.Cancellation); } if (eventDate.Date > DateTime.Today) { return(CompletionStatus.FutureAppointment); } if (lastScreeningEvent != null && lastScreeningEvent.EventCode == eventCustomer.EventId) { return(CompletionStatus.Completed); } if (eventDate.Date == DateTime.Today) { return(CompletionStatus.ScheduledForToday); } return(string.Empty); }
public MemberStatusListModel Create(IEnumerable <Customer> customers, IEnumerable <EventCustomer> eventCustomers, EventVolumeListModel eventListModel, IEnumerable <Order> orders, IEnumerable <OrderedPair <long, string> > packages, IEnumerable <OrderedPair <long, string> > tests, IEnumerable <Core.CallCenter.Domain.Call> calls, IEnumerable <CorporateCustomerCustomTag> customTags, IEnumerable <PrimaryCarePhysician> primaryCarePhysicians, IEnumerable <Notes> doNotContactReasonNotes, IEnumerable <OrderedPair <long, string> > customersPreApprovedTests, IEnumerable <OrderedPair <long, string> > customersPreApprovedPackages, IEnumerable <DirectMail> directMails, IEnumerable <Appointment> appointments, IEnumerable <ShippingDetail> shipingDetails, IEnumerable <OrderedPair <long, long> > shippingDetailIdEventCustomerIdPairs, IEnumerable <ShippingOption> shippingOptions, ShippingOption pcpShippingOptions, IEnumerable <CorporateAccount> corporateAccounts, IEnumerable <AccountAdditionalFields> accountAdditionalFields, DateTime fromDate, DateTime toDate, IEnumerable <ProspectCustomer> prospectCustomers, IEnumerable <CustomerPredictedZip> customerPredictedZips, IEnumerable <CustomerEligibility> customerEligibilityList, IEnumerable <CustomerTargeted> customerTargetedList, IEnumerable <Core.Medical.Domain.ActivityType> activityTypes) { var model = new MemberStatusListModel(); var memberStatusModels = new List <MemberStatusModel>(); foreach (var customer in customers) { var customerCalls = calls.Where(c => c.CalledCustomerId == customer.CustomerId); var callDetail = customerCalls.OrderByDescending(x => x.CallDateTime).FirstOrDefault(); var customerDirectMails = directMails.Where(x => x.CustomerId == customer.CustomerId); var customerPredictedZip = customerPredictedZips != null?customerPredictedZips.Where(x => x.CustomerId == customer.CustomerId) : null; var customerEligibility = customerEligibilityList.FirstOrDefault(x => x.CustomerId == customer.CustomerId); var customerTargeted = customerTargetedList.FirstOrDefault(x => x.CustomerId == customer.CustomerId); var isEligible = "N/A"; var corporateCustomTags = "N/A"; if (customerEligibility != null && customerEligibility.IsEligible.HasValue) { isEligible = customerEligibility.IsEligible.Value ? "Yes" : "No"; } var prospectCustomer = prospectCustomers.FirstOrDefault(p => p.CustomerId == customer.CustomerId); if (customTags != null && customTags.Any()) { var customerCustomTags = customTags.Where(ct => ct.CustomerId == customer.CustomerId).Select(ct => ct.Tag).ToArray(); if (customerCustomTags.Any()) { corporateCustomTags = string.Join(", ", customerCustomTags); } } var pcp = primaryCarePhysicians.Where(p => p.CustomerId == customer.CustomerId).Select(p => p).FirstOrDefault(); var customerPreApprovedTest = "N/A"; if (customersPreApprovedTests != null && customersPreApprovedTests.Any()) { var customerTests = customersPreApprovedTests.Where(x => x.FirstValue == customer.CustomerId); if (customerTests != null && customerTests.Any()) { var preApproveTestTemp = customerTests.Select(x => string.Format("\"{0}\"", x.SecondValue)).ToArray(); customerPreApprovedTest = string.Join(", ", preApproveTestTemp); } } var customerPreApprovedPakages = "N/A"; if (customersPreApprovedPackages != null && customersPreApprovedPackages.Any()) { var customerPackages = customersPreApprovedPackages.Where(x => x.FirstValue == customer.CustomerId); if (customerPackages != null && customerPackages.Any()) { var preApproveTestTemp = customerPackages.Select(x => string.Format("\"{0}\"", x.SecondValue)).ToArray(); customerPreApprovedPakages = string.Join(", ", preApproveTestTemp); } } var displayFielAandAdditionalFieldsPairs = new List <OrderedPair <string, string> >(); if (corporateAccounts != null && corporateAccounts.Any() && !string.IsNullOrEmpty(customer.Tag) && accountAdditionalFields != null && accountAdditionalFields.Any()) { var corporateAccount = corporateAccounts.FirstOrDefault(a => a.Tag == customer.Tag); if (corporateAccount != null) { var additionalFields = accountAdditionalFields.Where(x => x.AccountId == corporateAccount.Id).ToArray(); foreach (var additionalField in additionalFields) { displayFielAandAdditionalFieldsPairs.Add(new OrderedPair <string, string>(additionalField.DisplayName, GetCustomersAdditionFiledValue(customer, (AdditionalFieldsEnum)additionalField.AdditionalFieldId))); } } } string activityType = "N/A"; if (customer.ActivityId.HasValue && !activityTypes.IsNullOrEmpty()) { activityType = activityTypes.Single(x => x.Id == customer.ActivityId.Value).Name; } var isTargetedMember = "N/A"; if (customerTargeted != null && customerTargeted.IsTargated.HasValue) { isTargetedMember = customerTargeted.IsTargated.Value ? "Yes" : "No"; } var customerExportModel = new MemberStatusModel { CustomerId = customer.CustomerId, FirstName = customer.Name.FirstName, MiddleName = customer.Name.MiddleName, LastName = customer.Name.LastName, PhoneHome = customer.HomePhoneNumber != null?customer.HomePhoneNumber.ToString() : string.Empty, Gender = customer.Gender.ToString(), DateofBirth = customer.DateOfBirth, Address1 = customer.Address.StreetAddressLine1, Address2 = customer.Address.StreetAddressLine2, City = customer.Address.City, State = customer.Address.State, Zip = customer.Address.ZipCode.Zip, Email = customer.Email != null?customer.Email.ToString() : string.Empty, Tag = string.IsNullOrEmpty(customer.Tag) ? "N/A" : customer.Tag, MemberId = string.IsNullOrEmpty(customer.InsuranceId) ? "N/A" : customer.InsuranceId, IsEligible = isEligible, IsTargetedMember = isTargetedMember, CustomTag = corporateCustomTags, MedicarePlanName = string.IsNullOrEmpty(customer.MedicareAdvantagePlanName) ? "N/A" : customer.MedicareAdvantagePlanName, Hicn = string.IsNullOrEmpty(customer.Hicn) ? "N/A" : customer.Hicn, Mbi = string.IsNullOrEmpty(customer.Mbi) ? "N/A" : customer.Mbi, Market = string.IsNullOrEmpty(customer.Market) ? "N/A" : customer.Market, GroupName = string.IsNullOrEmpty(customer.GroupName) ? "N/A" : customer.GroupName, PreApprovedTest = customerPreApprovedTest, PreApprovedPackage = customerPreApprovedPakages, AdditionalFields = displayFielAandAdditionalFieldsPairs, Activity = activityType, PredictedZip = customerPredictedZip != null?string.Join(", ", customerPredictedZip.Select(x => x.PredictedZip)) : "N/A", AcesId = customer.AcesId, Product = customer.ProductTypeId.HasValue && customer.ProductTypeId.Value > 0 ? ((ProductType)customer.ProductTypeId.Value).GetDescription() : "N/A" }; GetRestrictionData(customerExportModel, customer, fromDate, toDate, doNotContactReasonNotes); if (pcp != null) { customerExportModel.PcpFirstName = pcp.Name.FirstName; customerExportModel.PcpLastName = pcp.Name.LastName; customerExportModel.PcpNpi = string.IsNullOrEmpty(pcp.Npi) ? "N/A" : pcp.Npi; if (pcp.Address != null && !pcp.Address.IsEmpty()) { customerExportModel.PcpAddress1 = pcp.Address.StreetAddressLine1; customerExportModel.PcpAddress2 = pcp.Address.StreetAddressLine2; customerExportModel.PcpCity = pcp.Address.City; customerExportModel.PcpState = pcp.Address.State; customerExportModel.PcpZip = pcp.Address.ZipCode.Zip; } customerExportModel.PcpFax = pcp.Fax != null?pcp.Fax.ToString() : string.Empty; customerExportModel.PcpPhone = pcp.Primary != null?pcp.Primary.ToString() : string.Empty; } EventCustomer eventCustomer = null; EventVolumeModel eventModel = null; EventVolumeModel lastScreeningDate = null; var scheduledStatus = ScheduledStatus.NotScheduled; if (eventCustomers != null && eventCustomers.Any()) { //var startDate = new DateTime(DateTime.Today.Year, 1, 1); //var endDate = new DateTime(DateTime.Today.Year, 12, 31); eventCustomer = (from ec in eventCustomers join e in eventListModel.Collection on ec.EventId equals e.EventCode where ec.CustomerId == customer.CustomerId orderby e.EventDate descending select ec).FirstOrDefault(); var appointmentIds = eventCustomers.Where(ec => ec.AppointmentId.HasValue && ec.CustomerId == customer.CustomerId).Select(x => x.AppointmentId.Value).ToArray(); var hasBeenScheduledForCurrentyear = (from ec in eventCustomers join e in eventListModel.Collection on ec.EventId equals e.EventCode where ec.CustomerId == customer.CustomerId select ec).Any(); lastScreeningDate = (from a in appointments join e in eventListModel.Collection on a.EventId equals e.EventCode join ec in eventCustomers on e.EventCode equals ec.EventId where a.CheckInTime != null && a.CheckOutTime != null && appointmentIds.Contains(a.Id) && !ec.NoShow && !ec.LeftWithoutScreeningReasonId.HasValue orderby e.EventDate descending select e).FirstOrDefault(); if (hasBeenScheduledForCurrentyear) { scheduledStatus = ScheduledStatus.Scheduled; } if (eventCustomer != null) { if (shipingDetails != null && shipingDetails.Any()) { var shipingIds = shippingDetailIdEventCustomerIdPairs.Where(m => m.SecondValue == eventCustomer.Id).Select(m => m.FirstValue); if (shipingIds != null && shipingIds.Any()) { var shipingDetail = shipingDetails.Where(m => shipingIds.Contains(m.Id) && m.Status == ShipmentStatus.Shipped); if (shipingDetail != null && shipingDetail.Any()) { var customerResultShipDetail = (from s in shipingDetail join so in shippingOptions on s.ShippingOption.Id equals so.Id orderby s.ShipmentDate descending select s).FirstOrDefault(); var pcpResultShipDetail = (from s in shipingDetail where s.ShippingOption.Id == pcpShippingOptions.Id select s).FirstOrDefault(); if (pcpResultShipDetail != null) { customerExportModel.PCPResultShipedDate = pcpResultShipDetail.ShipmentDate; } if (customerResultShipDetail != null) { customerExportModel.CustomerResultShipedDate = customerResultShipDetail.ShipmentDate; } } } } var order = orders.FirstOrDefault(o => o.EventId == eventCustomer.EventId && o.CustomerId == eventCustomer.CustomerId); if (order != null) { var package = packages.FirstOrDefault(p => p.FirstValue == order.Id); var test = tests.Where(p => p.FirstValue == order.Id).ToList(); var productPurchased = string.Empty; if (package != null && !test.IsNullOrEmpty()) { productPurchased = package.SecondValue + " + " + string.Join(" + ", test.Select(t => t.SecondValue).ToArray()); } else if (!test.IsNullOrEmpty()) { productPurchased = string.Join(" + ", test.Select(t => t.SecondValue).ToArray()); } else if (package != null) { productPurchased = package.SecondValue; } customerExportModel.Package = productPurchased; } eventModel = eventListModel.Collection.FirstOrDefault(e => e.EventCode == eventCustomer.EventId); if (eventModel != null) { customerExportModel.EventId = eventModel.EventCode; customerExportModel.EventName = eventModel.Location; customerExportModel.EventDate = eventModel.EventDate; customerExportModel.EventAddress1 = eventModel.StreetAddressLine1; customerExportModel.EventAddress2 = eventModel.StreetAddressLine2; customerExportModel.EventCity = eventModel.City; customerExportModel.EventState = eventModel.State; customerExportModel.EventZip = eventModel.Zip; customerExportModel.Pod = eventModel.Pod; customerExportModel.CompletionStatus = GetCompletionStatus(eventCustomer, eventModel.EventDate, lastScreeningDate); customerExportModel.RegistrationDate = eventCustomer.DataRecorderMetaData.DateCreated; } } } customerExportModel.CurrentStatus = GetCurrentStatus(customer, customerDirectMails, eventCustomer, eventModel, lastScreeningDate, prospectCustomer, fromDate, toDate, customerEligibility); customerExportModel.ScheduledStatus = scheduledStatus; if (callDetail != null) { int?dispositionId = null; if (!string.IsNullOrEmpty(callDetail.Disposition)) { ProspectCustomerTag tag; Enum.TryParse(callDetail.Disposition, true, out tag); dispositionId = (int)tag; } customerExportModel.CurrentOutboundCallOutcome = ((CallStatus)callDetail.Status).GetDescription(); if (dispositionId.HasValue) { customerExportModel.CurrentOutboundCallDisposition = ((ProspectCustomerTag)dispositionId.Value).GetDescription(); } customerExportModel.CurrentOutboundCallCategory = GetCallCategoryByStatus(callDetail.Status, dispositionId); } SetReportModelOutReachType(customerExportModel, customerCalls, customerDirectMails, customer.CustomerId); memberStatusModels.Add(customerExportModel); } model.Collection = memberStatusModels; return(model); }
private static PcpAppointmentViewModel GetPcpAppointmentViewModel(long customerId, Customer customer, string customTags, string eligibilityStatus, EventVolumeModel eventModel, PrimaryCarePhysician pcp) { var pcpAppointmentViewModel = new PcpAppointmentViewModel { CustomerId = customerId, CustomerName = customer.NameAsString, InsuranceId = string.IsNullOrEmpty(customer.InsuranceId) ? "N/A" : customer.InsuranceId, Hicn = string.IsNullOrEmpty(customer.Hicn) ? "N/A" : customer.Hicn, Mbi = string.IsNullOrEmpty(customer.Mbi) ? "N/A" : customer.Mbi, Tag = string.IsNullOrEmpty(customer.Tag) ? "N/A" : customer.Tag, CustomerTag = customTags, IsEligible = eligibilityStatus, EventId = eventModel.EventCode, EventName = eventModel.Location, EventDate = eventModel.EventDate, Pod = eventModel.Pod, PcpName = pcp != null ? pcp.Name.FullName : "N/A", PcpPhoneNumber = pcp != null && pcp.Primary != null && !string.IsNullOrEmpty(pcp.Primary.ToString()) ? pcp.Primary.ToString() : "N/A", PcpFax = pcp != null && pcp.Fax != null && !string.IsNullOrEmpty(pcp.Fax.ToString()) ? pcp.Fax.ToString() : "N/A", }; return(pcpAppointmentViewModel); }
public EventCustomerScheduleModel Create(IEnumerable <EventCustomer> eventCustomers, IEnumerable <Appointment> appointments, IEnumerable <Order> orders, EventVolumeModel eventModel, IEnumerable <Customer> customers, IEnumerable <OrderedPair <long, string> > packages, IEnumerable <OrderedPair <long, string> > tests, IEnumerable <OrderedPair <long, string> > products) { var eventCustomerModel = new EventCustomerScheduleModel { Address = eventModel.Address, EventDate = eventModel.EventDate, EventId = eventModel.EventCode, Location = eventModel.Location, Vehicle = eventModel.Pod, CustomerCount = eventModel.AppointmentsBooked, Customers = CreateCustomerScheduleModelforEvent(eventCustomers, appointments, orders, eventModel.EventCode, customers, packages, tests, products) }; if (eventCustomerModel.Customers != null && eventCustomerModel.Customers.Count() > 0) { eventCustomerModel.Customers = eventCustomerModel.Customers.OrderBy(c => c.AppointmentTime); } return(eventCustomerModel); }