Ejemplo n.º 1
0
        public ActionResult CorporateEventVolume(bool showThisYear = false, EventVolumeListModelFilter filter = null, int pageNumber = 1)
        {
            if (showThisYear)
            {
                if (filter == null)
                {
                    filter = new EventVolumeListModelFilter();
                }
                filter.FromDate = Convert.ToDateTime("01/01/" + DateTime.Today.Year);
            }
            int totalRecords;
            var model = _eventReportingService.GetEventVolumeForCorporatePatients(pageNumber, _pageSize, filter, out totalRecords);

            if (model == null)
            {
                model = new EventVolumeListModel();
            }
            model.Filter = filter;


            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc =
                pn =>
                Url.Action(currentAction,
                           new
            {
                pageNumber = pn,
                filter.Territory,
                filter.Vehicle,
                filter.FromDate,
                filter.ToDate,
                filter.ZipCode,
                filter.IsPublicEvent,
                filter.IsPrivateEvent
            });

            model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

            return(View(model));
        }
Ejemplo n.º 2
0
        public CancelledCustomerListModel Create(IEnumerable <EventCustomer> eventCustomers, EventVolumeListModel eventListModel, IEnumerable <Customer> customers, IEnumerable <OrderedPair <long, long> > orderIdEventCustomerIdPairs,
                                                 IEnumerable <CustomerCallNotes> notes, IEnumerable <RefundRequest> refundRequests, IEnumerable <Order> orders, IEnumerable <OrderedPair <long, string> > idNamePairs,
                                                 IEnumerable <OrganizationRoleUser> agents, IEnumerable <Role> roles, IEnumerable <EventAppointmentCancellationLog> appointmentCancellationLogs)
        {
            var model = new CancelledCustomerListModel();
            var cancelledCustomerModels = new List <CancelledCustomerModel>();

            eventCustomers.ToList().ForEach(ec =>
            {
                var eventModel = eventListModel.Collection.Where(e => e.EventCode == ec.EventId).FirstOrDefault();

                var customer = customers.Where(c => c.CustomerId == ec.CustomerId).FirstOrDefault();

                var order = orders.Where(o => o.EventId == ec.EventId && o.CustomerId == ec.CustomerId).FirstOrDefault();

                var scheduledBy = ec.DataRecorderMetaData.DataRecorderCreator.Id == ec.CustomerId ? "Self" : idNamePairs.Where(p => p.FirstValue == ec.DataRecorderMetaData.DataRecorderCreator.Id).First().SecondValue;

                var cancellationReason = "N/A";
                var canceledDate       = string.Empty;
                var subReason          = string.Empty;

                if (!appointmentCancellationLogs.IsNullOrEmpty())
                {
                    var customerLog = appointmentCancellationLogs.OrderByDescending(x => x.DateCreated).FirstOrDefault(x => x.EventCustomerId == ec.Id);
                    canceledDate    = customerLog != null ? customerLog.DateCreated.ToShortDateString() : "N/A";
                    if (customerLog != null)
                    {
                        cancellationReason = ((CancelAppointmentReason)customerLog.ReasonId).GetDescription();
                        if (customerLog.SubReasonId.HasValue && customerLog.SubReasonId.Value > 0)
                        {
                            subReason = ((CancelAppointmentSubReason)customerLog.SubReasonId).GetDescription();
                        }
                    }
                }


                var cancelledBy = string.Empty;
                IEnumerable <RefundRequest> requests = null;
                if (refundRequests != null)
                {
                    requests = refundRequests.Where(rr => rr.OrderId == order.Id).Select(rr => rr).ToArray();
                }
                var totalAmount = 0.00m;
                if (order != null)
                {
                    if (order.OrderDetails.Where(od => od.IsCompleted).Any() && requests != null)
                    {
                        totalAmount = order.DiscountedTotal;
                        cancelledBy = idNamePairs.Where(p => p.FirstValue == requests.Last().RequestedByOrgRoleUserId).First().SecondValue;
                    }
                    else
                    {
                        var orderDetails = order.OrderDetails.OrderByDescending(od => od.Id).ToList();
                        cancelledBy      = idNamePairs.Where(p => p.FirstValue == orderDetails.First().DataRecorderMetaData.DataRecorderCreator.Id).First().SecondValue;

                        foreach (var orderDetail in orderDetails)
                        {
                            if (orderDetail.Price > 0)
                            {
                                break;
                            }
                            totalAmount += (-1) * orderDetail.Price;
                        }
                    }
                }

                var registeredBy = (ec.DataRecorderMetaData == null || ec.DataRecorderMetaData.DataRecorderCreator == null ? null : agents.Where(a => a.Id == ec.DataRecorderMetaData.DataRecorderCreator.Id).FirstOrDefault());

                var agentRole = string.Empty;
                if (registeredBy != null)
                {
                    agentRole = registeredBy.RoleId == (long)Roles.Customer ? "Internet" : roles.Where(r => r.Id == registeredBy.RoleId).FirstOrDefault().DisplayName;
                }

                var sponsorName = eventModel.EventType.ToLower() == EventType.Corporate.ToString().ToLower() ? eventModel.CorporateAccount : eventModel.HospitalPartner;

                var cancelledCustomerModel = new CancelledCustomerModel()
                {
                    Address              = customer.Address,
                    CustomerId           = ec.CustomerId,
                    CustomerName         = customer.NameAsString,
                    DateofBirth          = customer.DateOfBirth,
                    Email                = customer.Email != null ? customer.Email.ToString() : string.Empty,
                    EventId              = eventModel.EventCode,
                    EventDate            = eventModel.EventDate,
                    Pod                  = eventModel.Pod,
                    Gender               = customer.Gender.ToString(),
                    Host                 = eventModel.Location,
                    HostAddress          = eventModel.Address,
                    PhoneBusiness        = customer.OfficePhoneNumber != null ? customer.OfficePhoneNumber.ToString() : string.Empty,
                    PhoneCell            = customer.MobilePhoneNumber != null ? customer.MobilePhoneNumber.ToString() : string.Empty,
                    PhoneHome            = customer.HomePhoneNumber != null ? customer.HomePhoneNumber.ToString() : string.Empty,
                    AdSource             = ec.MarketingSource,
                    PhoneOfficeExtension = customer.PhoneOfficeExtension,
                    OrderId              = orderIdEventCustomerIdPairs.Where(oe => oe.SecondValue == ec.Id).Select(oe => oe.FirstValue).FirstOrDefault(),
                    TotalAmount          = totalAmount,
                    ScheduledBy          = scheduledBy,
                    CancelledBy          = cancelledBy,
                    SignUpMethod         = agentRole,
                    CancellationReason   = cancellationReason,
                    Notes                = notes.Where(n => n.CustomerId == ec.CustomerId && n.EventId == ec.EventId).ToArray(),
                    CanceledDate         = canceledDate,
                    SponsoredBy          = sponsorName,
                    SubReason            = subReason,
                };


                if (requests.Count() > 0)
                {
                    var modelNotes = cancelledCustomerModel.Notes.ToList();
                    foreach (var refundRequest in requests)
                    {
                        modelNotes.Add(new CustomerCallNotes
                        {
                            Notes                = refundRequest.Reason,
                            NotesType            = CustomerRegistrationNotesType.CancellationNote,
                            DataRecorderMetaData = new DataRecorderMetaData(refundRequest.RequestedByOrgRoleUserId, refundRequest.RequestedOn, null)
                        });

                        //if (refundRequest.IsResolved && refundRequest.RefundRequestResult != null)
                        //    modelNotes.Add(new CustomerCallNotes
                        //                            {
                        //                                Notes = refundRequest.RefundRequestResult.Notes,
                        //                                NotesType = CustomerRegistrationNotesType.CancellationNote,
                        //                                DataRecorderMetaData = new DataRecorderMetaData(refundRequest.RefundRequestResult.ProcessedByOrgRoleUserId, refundRequest.RefundRequestResult.ProcessedOn, null)
                        //                            });
                    }
                    cancelledCustomerModel.Notes = modelNotes;
                }
                cancelledCustomerModels.Add(cancelledCustomerModel);
            });
            model.Collection = cancelledCustomerModels;
            return(model);
        }
Ejemplo n.º 3
0
        public CustomerLeftWithoutScreeningListModel Create(IEnumerable <EventCustomer> eventCustomers, IEnumerable <Appointment> appointments, IEnumerable <Order> orders, EventVolumeListModel eventListModel,
                                                            IEnumerable <Customer> customers, IEnumerable <OrderedPair <long, string> > packages, IEnumerable <OrderedPair <long, string> > tests, IEnumerable <OrderedPair <long, string> > idNamePairs,
                                                            IEnumerable <OrganizationRoleUser> agents, IEnumerable <Role> roles, IEnumerable <PcpAppointment> pcpAppointments, IEnumerable <CustomerCallNotes> patientLeftNotes, IEnumerable <CorporateAccount> corporateAccounts)
        {
            var model = new CustomerLeftWithoutScreeningListModel();
            var customerLeftWithoutScreeningModels = new List <CustomerLeftWithoutScreeningModel>();

            eventCustomers.ToList().ForEach(ec =>
            {
                var eventModel = eventListModel.Collection.Where(e => e.EventCode == ec.EventId).FirstOrDefault();
                var order      = orders.Where(o => o.EventId == ec.EventId && o.CustomerId == ec.CustomerId).FirstOrDefault();
                var customer   = customers.Where(c => c.CustomerId == ec.CustomerId).FirstOrDefault();
                var package    = packages.Where(p => p.FirstValue == order.Id).FirstOrDefault();
                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;
                }

                var scheduledBy  = ec.DataRecorderMetaData.DataRecorderCreator.Id == ec.CustomerId ? "Self" : idNamePairs.Where(p => p.FirstValue == ec.DataRecorderMetaData.DataRecorderCreator.Id).First().SecondValue;
                var registeredBy = (ec.DataRecorderMetaData == null || ec.DataRecorderMetaData.DataRecorderCreator == null ? null : agents.Where(a => a.Id == ec.DataRecorderMetaData.DataRecorderCreator.Id).FirstOrDefault());

                var agentRole = string.Empty;

                var pcpAppointment = pcpAppointments.SingleOrDefault(m => m.EventCustomerId == ec.Id);

                if (registeredBy != null)
                {
                    agentRole = registeredBy.RoleId == (long)Roles.Customer ? "Internet" : roles.Where(r => r.Id == registeredBy.RoleId).FirstOrDefault().DisplayName;
                }

                var appointment = ec.AppointmentId.HasValue ? appointments.FirstOrDefault(a => a.Id == ec.AppointmentId.Value) : null;

                var note = string.Empty;
                if (ec.LeftWithoutScreeningNotesId.HasValue)
                {
                    var patientLeftNotesForCustomer = patientLeftNotes.FirstOrDefault(x => x.Id == ec.LeftWithoutScreeningNotesId.Value);
                    note = patientLeftNotesForCustomer != null ? patientLeftNotesForCustomer.Notes : string.Empty;
                }
                var account = corporateAccounts.IsNullOrEmpty() ? null : corporateAccounts.SingleOrDefault(x => x.Tag == customer.Tag);

                var customerLeftWithoutScreeningModel = new CustomerLeftWithoutScreeningModel()
                {
                    Address                    = customer.Address,
                    CustomerCode               = customer.CustomerId.ToString(),
                    AmountPaid                 = order.TotalAmountPaid,
                    AppointmentTime            = appointment != null ? (DateTime?)appointment.StartTime : null,
                    CheckInTime                = (appointment != null && appointment.CheckInTime.HasValue) ? (DateTime?)appointment.CheckInTime.Value : null,
                    CheckOutTime               = (appointment != null && appointment.CheckOutTime.HasValue) ? (DateTime?)appointment.CheckOutTime.Value : null,
                    CustomerId                 = ec.CustomerId,
                    CustomerName               = customer.NameAsString,
                    DateofBirth                = customer.DateOfBirth,
                    Email                      = customer.Email != null ? customer.Email.ToString() : string.Empty,
                    EventId                    = eventModel.EventCode,
                    EventDate                  = eventModel.EventDate,
                    Pod                        = eventModel.Pod,
                    Gender                     = customer.Gender.ToString(),
                    Host                       = eventModel.Location,
                    HostAddress                = eventModel.Address,
                    Package                    = productPurchased,
                    PhoneBusiness              = customer.OfficePhoneNumber != null ? customer.OfficePhoneNumber.ToString() : string.Empty,
                    PhoneCell                  = customer.MobilePhoneNumber != null ? customer.MobilePhoneNumber.ToString() : string.Empty,
                    PhoneHome                  = customer.HomePhoneNumber != null ? customer.HomePhoneNumber.ToString() : string.Empty,
                    TotalAmount                = order.DiscountedTotal,
                    AdSource                   = ec.MarketingSource,
                    PhoneOfficeExtension       = customer.PhoneOfficeExtension,
                    BookingAgent               = scheduledBy,
                    RegistrationMode           = agentRole,
                    RegistrationDate           = ec.DataRecorderMetaData != null ? (DateTime?)ec.DataRecorderMetaData.DateCreated : null,
                    PCPAppointmentDate         = pcpAppointment != null ? pcpAppointment.AppointmentOn : (DateTime?)null,
                    PCPAppointmentTime         = pcpAppointment != null ? pcpAppointment.AppointmentOn.ToShortTimeString() : string.Empty,
                    LeftWithoutScreeningReason = ec.LeftWithoutScreeningReasonId.HasValue ? ((LeftWithoutScreeningReason)ec.LeftWithoutScreeningReasonId.Value).GetDescription() : string.Empty,
                    LeftWithoutScreeningNotes  = note,
                    Healthplan                 = account != null ? account.Name : string.Empty,
                };

                customerLeftWithoutScreeningModels.Add(customerLeftWithoutScreeningModel);
            });
            model.Collection = customerLeftWithoutScreeningModels;
            return(model);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public CustomerExportListModel Create(IEnumerable <Customer> customers, IEnumerable <EventCustomer> eventCustomers, EventVolumeListModel eventListModel, IEnumerable <Order> orders, IEnumerable <OrderedPair <long, string> > packages,
                                              IEnumerable <OrderedPair <long, string> > tests, IEnumerable <Role> roles, IEnumerable <SourceCode> sourceCodes, IEnumerable <Call> calls, IEnumerable <Language> languages, IEnumerable <Lab> labs,
                                              IEnumerable <CorporateCustomerCustomTag> customTags, IEnumerable <PrimaryCarePhysician> primaryCarePhysicians, IEnumerable <Notes> doNotContactReasonNotes, IEnumerable <OrderedPair <long, string> > customersPreApprovedTests,
                                              IEnumerable <OrderedPair <long, string> > customersPreApprovedPackages, IEnumerable <Appointment> appointments, IEnumerable <CorporateAccount> corporateAccounts, IEnumerable <AccountAdditionalFields> additionalFields,
                                              IEnumerable <CustomerPredictedZip> customerPredictedZips, IEnumerable <CustomerEligibility> customerEligibilities, IEnumerable <ChaseOutbound> chaseOutbounds, IEnumerable <Relationship> relationships, IEnumerable <Falcon.App.Core.Medical.Domain.ActivityType> activityTypes)
        {
            var model = new CustomerExportListModel();
            var customerExportModels = new List <CustomerExportModel>();

            foreach (var customer in customers)
            {
                string signupMode;
                if (customer.AddedByRoleId.HasValue && customer.AddedByRoleId.Value != (long)Roles.Customer)
                {
                    signupMode = roles.First(r => r.Id == customer.AddedByRoleId.Value).DisplayName;
                }
                else
                {
                    signupMode = "Online";
                }

                var incomingLine        = calls.Where(c => c.CalledCustomerId == customer.CustomerId && !string.IsNullOrEmpty(c.CalledInNumber)).Select(c => c.CalledInNumber).LastOrDefault();
                var customerEligibility = customerEligibilities.FirstOrDefault(x => x.CustomerId == customer.CustomerId);
                var isEligible          = "N/A";
                var language            = "N/A";
                var lab = "N/A";
                var corporateCustomTags = "N/A";

                if (customerEligibility != null && customerEligibility.IsEligible.HasValue)
                {
                    if (customerEligibility.IsEligible.Value)
                    {
                        isEligible = EligibleStatus.Yes.ToString();
                    }
                    else
                    {
                        isEligible = EligibleStatus.No.ToString();
                    }
                }

                if (customer.LanguageId.HasValue)
                {
                    var customerLanguage = languages.FirstOrDefault(l => l.Id == customer.LanguageId.Value);
                    if (customerLanguage != null)
                    {
                        language = customerLanguage.Name;
                    }
                }

                if (customer.LabId.HasValue)
                {
                    var customerLab = labs.FirstOrDefault(l => l.Id == customer.LabId.Value);
                    if (customerLab != null)
                    {
                        lab = customerLab.Name;
                    }
                }

                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 doNotContactReason     = string.Empty;
                var doNotContactReasonNote = string.Empty;
                if (customer.DoNotContactReasonId.HasValue)
                {
                    doNotContactReason = ((DoNotContactReason)customer.DoNotContactReasonId.Value).GetDescription();
                }

                if (customer.DoNotContactReasonNotesId.HasValue)
                {
                    doNotContactReasonNote = doNotContactReasonNotes.First(x => x.Id == customer.DoNotContactReasonNotesId).Text;
                }

                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 customerPredictedZip = customerPredictedZips != null?customerPredictedZips.Where(x => x.CustomerId == customer.CustomerId) : null;

                var chaseOutbound = chaseOutbounds.FirstOrDefault(x => x.CustomerId == customer.CustomerId && x.IsActive);
                var relationship  = chaseOutbound != null && chaseOutbound.RelationshipId.HasValue ? relationships.FirstOrDefault(x => x.Id == chaseOutbound.RelationshipId.Value) : null;

                Falcon.App.Core.Medical.Domain.ActivityType activityType = null;
                if (customer.ActivityId.HasValue)
                {
                    activityType = activityTypes != null && activityTypes.Any() ? activityTypes.First(x => x.Id == customer.ActivityId.Value) : null;
                }

                var customerExportModel = new CustomerExportModel
                {
                    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,
                                                             DateCreated                     = customer.DateCreated,
                                                             MarketingSource                 = customer.MarketingSource,
                                                             SignUpMode                      = signupMode,
                                                             Email                           = customer.Email != null?customer.Email.ToString() : string.Empty,
                                                                                      Race   = customer.Race.ToString(),
                                                                                      Height = customer.Height != null?customer.Height.TotalInches.ToString() : string.Empty,
                                                                                                   Weight = customer.Weight != null?customer.Weight.Pounds.ToString() : string.Empty,
                                                                                                                LastScreeningDate = customer.LastScreeningDate,
                                                                                                                IncomingPhoneLine = incomingLine,
                                                                                                                Tag                                                        = string.IsNullOrEmpty(customer.Tag) ? "N/A" : customer.Tag,
                                                                                                                MemberId                                                   = string.IsNullOrEmpty(customer.InsuranceId) ? "N/A" : customer.InsuranceId,
                                                                                                                IsEligible                                                 = isEligible,
                                                                                                                Language                                                   = language,
                                                                                                                Lab                                                        = lab,
                                                                                                                CustomTag                                                  = corporateCustomTags,
                                                                                                                Copay                                                      = customer.Copay,
                                                                                                                MedicarePlanName                                           = string.IsNullOrEmpty(customer.MedicareAdvantagePlanName) ? "N/A" : customer.MedicareAdvantagePlanName,
                                                                                                                Hicn                                                       = string.IsNullOrEmpty(customer.Hicn) ? "N/A" : customer.Hicn,
                                                                                                                Lpi                                                        = string.IsNullOrEmpty(customer.Lpi) ? "N/A" : customer.Lpi,
                                                                                                                Market                                                     = string.IsNullOrEmpty(customer.Market) ? "N/A" : customer.Market,
                                                                                                                Mrn                                                        = string.IsNullOrEmpty(customer.Mrn) ? "N/A" : customer.Mrn,
                                                                                                                GroupName                                                  = string.IsNullOrEmpty(customer.GroupName) ? "N/A" : customer.GroupName,
                                                                                                                DoNotContactReason                                         = doNotContactReason,
                                                                                                                DoNotContactReasonNote                                     = doNotContactReasonNote,
                                                                                                                PreApprovedTest                                            = customerPreApprovedTest,
                                                                                                                PreApprovedPackage                                         = customerPreApprovedPakages,
                                                                                                                Activity                                                   = activityType != null ? activityType.Name : "N/A",
                                                                                                                PredictedZip                                               = customerPredictedZip != null?string.Join(", ", customerPredictedZip.Select(x => x.PredictedZip)) : "N/A",
                                                                                                                                                          Mbi              = string.IsNullOrEmpty(customer.Mbi) ? "N/A" : customer.Mbi,
                                                                                                                                                          AcesId           = string.IsNullOrWhiteSpace(customer.AcesId) ? "N/A" : customer.AcesId,
                                                                                                                                                          RelationshipCode = relationship != null ? relationship.Code : string.Empty,
                                                                                                                                                          RelationshipName = relationship != null ? relationship.Description : string.Empty,
                                                                                                                                                          Product          = customer.ProductTypeId.HasValue && customer.ProductTypeId.Value > 0 ? ((ProductType)customer.ProductTypeId.Value).GetDescription() : "N/A"
                };

                if (!string.IsNullOrEmpty(customer.Tag))
                {
                    var corporateAccount = corporateAccounts.FirstOrDefault(x => x.Tag == customer.Tag);

                    if (corporateAccount != null)
                    {
                        var accountAdditionalFields = additionalFields.Where(x => x.AccountId == corporateAccount.Id);
                        customerExportModel.AdditionalFields = accountAdditionalFields.Select(x => new OrderedPair <string, string>(x.DisplayName, GetCustomerAdditionalField(customer, x.AdditionalFieldId)));
                    }
                }

                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;
                }

                if (eventCustomers != null && eventCustomers.Any())
                {
                    var eventCustomer = (from ec in eventCustomers
                                         join e in eventListModel.Collection on ec.EventId equals e.EventCode
                                         where ec.AppointmentId.HasValue && ec.CustomerId == customer.CustomerId
                                         orderby e.EventDate descending
                                         select ec).FirstOrDefault();

                    if (eventCustomer != null)
                    {
                        var order = orders.FirstOrDefault(o => o.EventId == eventCustomer.EventId && o.CustomerId == eventCustomer.CustomerId);
                        if (order != null)
                        {
                            var sourceCodeOrderDetail = order.OrderDetails.Where(od => od.SourceCodeOrderDetail != null && od.SourceCodeOrderDetail.IsActive).Select(od => od.SourceCodeOrderDetail).FirstOrDefault();

                            string  sourceCode       = string.Empty;
                            decimal sourceCodeAmount = 0;
                            if (sourceCodeOrderDetail != null)
                            {
                                var coupon = sourceCodes.FirstOrDefault(sc => sc.Id == sourceCodeOrderDetail.SourceCodeId);

                                sourceCode       = coupon.CouponCode;
                                sourceCodeAmount = sourceCodeOrderDetail.Amount;
                            }

                            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.IsPaid           = order.TotalAmountPaid >= order.DiscountedTotal;
                            customerExportModel.Amount           = order.DiscountedTotal;
                            customerExportModel.Package          = productPurchased;
                            customerExportModel.ScreeningCost    = order.OrderDetails.Where(od => (od.DetailType == OrderItemType.EventPackageItem || od.DetailType == OrderItemType.EventTestItem) && od.IsCompleted).Sum(od => od.Price);
                            customerExportModel.SourceCode       = sourceCode;
                            customerExportModel.SourceCodeAmount = sourceCodeAmount;
                        }

                        var 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;
                        }
                        var appointment = appointments.FirstOrDefault(a => a.Id == eventCustomer.AppointmentId.Value);
                        customerExportModel.Status = (appointment != null && appointment.CheckInTime.HasValue && appointment.CheckOutTime.HasValue && !eventCustomer.LeftWithoutScreeningReasonId.HasValue) ? "Availed" : "Not Availed";
                    }
                }
                customerExportModels.Add(customerExportModel);
            }

            model.Collection = customerExportModels;
            return(model);
        }
Ejemplo n.º 6
0
        public IEnumerable <PcpAppointmentViewModel> Create(IEnumerable <ViewPcpAppointmentDisposition> vwPcpDispositions, IEnumerable <EventCustomer> eventCustomers, IEnumerable <Customer> customers, IEnumerable <CorporateCustomerCustomTag> corporateCustomerCustomTags,
                                                            IEnumerable <PrimaryCarePhysician> primaryCarePhysician, IEnumerable <OrderedPair <long, string> > agentOrderedPairs, EventVolumeListModel eventListModel,
                                                            IEnumerable <PcpAppointment> pcpAppointments, IEnumerable <PcpDisposition> pcpDispositions, IEnumerable <CustomerEligibility> customerEligibilities)
        {
            var pcpAppointmentCollection = new List <PcpAppointmentViewModel>();

            foreach (var vwData in vwPcpDispositions)
            {
                var eventCustomer = eventCustomers.First(x => x.Id == vwData.EventCustomerId);

                var customerId          = eventCustomer.CustomerId;
                var eventId             = eventCustomer.EventId;
                var customerEligibility = customerEligibilities.FirstOrDefault(x => x.CustomerId == customerId);

                var customer   = customers.First(c => c.CustomerId == customerId);
                var eventModel = eventListModel.Collection.First(x => x.EventCode == eventId);

                var pcp            = primaryCarePhysician.FirstOrDefault(x => x.CustomerId == customerId);
                var pcpAppointment = pcpAppointments.FirstOrDefault(x => x.EventCustomerId == eventCustomer.Id);

                var customTags = "N/A";

                if (corporateCustomerCustomTags.Any())
                {
                    var customerCustomTag = corporateCustomerCustomTags.Where(x => x.CustomerId == customerId).OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Select(x => x.Tag);
                    if (!customerCustomTag.IsNullOrEmpty())
                    {
                        customTags = string.Join(", ", customerCustomTag);
                    }
                }
                var eligibilityStatus = "N/A";
                if (customerEligibility != null && customerEligibility.IsEligible.HasValue)
                {
                    if (customerEligibility.IsEligible.Value)
                    {
                        eligibilityStatus = EligibleStatus.Yes.ToString();
                    }
                    else
                    {
                        eligibilityStatus = EligibleStatus.No.ToString();
                    }
                }

                var pcpAppointmentViewModel = GetPcpAppointmentViewModel(customerId, customer, customTags, eligibilityStatus, eventModel, pcp);

                if (vwData.PcpDispositionId <= 0 && pcpAppointment != null)
                {
                    pcpAppointmentViewModel.ModifiedByAgentName = "N/A";
                    pcpAppointmentViewModel.AgentName           = "N/A";

                    if (pcpAppointment.ModifiedBy.HasValue)
                    {
                        var agent = agentOrderedPairs.First(x => x.FirstValue == pcpAppointment.ModifiedBy.Value);
                        pcpAppointmentViewModel.AppointmentModifiedOn = pcpAppointment.ModifiedOn;
                        pcpAppointmentViewModel.ModifiedByAgentName   = agent.SecondValue;
                    }

                    if (pcpAppointment.CreatedBy.HasValue)
                    {
                        var agent = agentOrderedPairs.First(x => x.FirstValue == pcpAppointment.CreatedBy.Value);
                        pcpAppointmentViewModel.AppointmentCreatedOn = pcpAppointment.CreatedOn;
                        pcpAppointmentViewModel.AgentName            = agent.SecondValue;
                    }

                    pcpAppointmentViewModel.AppointmentCreatedOn = pcpAppointment.CreatedOn;

                    pcpAppointmentViewModel.AppointmentDateTime = pcpAppointment.AppointmentOn;
                    pcpAppointmentCollection.Add(pcpAppointmentViewModel);
                }

                if (vwData.PcpDispositionId > 0)
                {
                    var disposition = pcpDispositions.First(x => x.PcpDispositionId == vwData.PcpDispositionId);

                    var agent = agentOrderedPairs.First(x => x.FirstValue == disposition.DataRecorderMetaData.DataRecorderCreator.Id);

                    pcpAppointmentViewModel.PcpDisposition        = disposition.Disposition.GetDescription();
                    pcpAppointmentViewModel.DispositionsCreatedBy = agent.SecondValue;
                    pcpAppointmentViewModel.DispositionsCreatedOn = disposition.DataRecorderMetaData.DateCreated;
                    pcpAppointmentViewModel.Notes = string.IsNullOrEmpty(disposition.Notes) ? "N/A" : disposition.Notes;

                    pcpAppointmentCollection.Add(pcpAppointmentViewModel);
                }
            }

            return(pcpAppointmentCollection);
        }
Ejemplo n.º 7
0
        public VoiceMailReminderListModel Create(IEnumerable <EventCustomer> eventCustomers, EventVolumeListModel eventListModel, IEnumerable <Customer> customers,
                                                 IEnumerable <OrderedPair <long, string> > packages, IEnumerable <Appointment> appointments, IEnumerable <Order> orders, IEnumerable <OrderedPair <long, string> > tests)
        {
            var model = new VoiceMailReminderListModel();
            var voiceMailReminderModels = new List <VoiceMailReminderModel>();

            eventCustomers.ToList().ForEach(ec =>
            {
                var eventModel = eventListModel.Collection.Where(e => e.EventCode == ec.EventId).FirstOrDefault();

                var customer = customers.Where(c => c.CustomerId == ec.CustomerId).FirstOrDefault();

                var order = orders.Where(o => o.EventId == ec.EventId && o.CustomerId == ec.CustomerId).FirstOrDefault();

                var package = packages.Where(p => p.FirstValue == order.Id).FirstOrDefault();

                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;
                }


                var sponsorName = eventModel.EventType.ToLower() == EventType.Corporate.ToString().ToLower() ? eventModel.CorporateAccount : eventModel.HospitalPartner;


                var voiceMailReminderModel = new VoiceMailReminderModel()
                {
                    CustomerId      = ec.CustomerId,
                    EventId         = eventModel.EventCode,
                    PhoneHome       = customer.HomePhoneNumber != null ? customer.HomePhoneNumber.ToString() : string.Empty,
                    SponsoredBy     = sponsorName,
                    EventDate       = eventModel.EventDate,
                    Address         = eventModel.Address,
                    Package         = productPurchased,
                    AppointmentTime = ec.AppointmentId.HasValue ? (DateTime?)appointments.Where(a => a.Id == ec.AppointmentId.Value).FirstOrDefault().StartTime : null,
                };

                voiceMailReminderModels.Add(voiceMailReminderModel);
            });
            model.Collection = voiceMailReminderModels;
            return(model);
        }
        public ListModelBase <GiftCertificateReportViewModel, GiftCertificateReportFilter> Create(IEnumerable <Customer> customers, IEnumerable <EventCustomer> eventCustomers, EventVolumeListModel eventListModel, IEnumerable <Order> orders,
                                                                                                  IEnumerable <OrderedPair <long, string> > packages, IEnumerable <OrderedPair <long, string> > tests)
        {
            var model = new GiftCertificateReportListModel();
            var customerExportModels = new List <GiftCertificateReportViewModel>();

            foreach (var eventCustomer in eventCustomers)
            {
                var customer = customers.FirstOrDefault(x => x.CustomerId == eventCustomer.CustomerId);

                if (customer != null)
                {
                    var customerExportModel = new GiftCertificateReportViewModel
                    {
                        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,
                                                                                              IsGiftCertificateDelivered = eventCustomer.IsGiftCertificateDelivered,
                                                                                              GiftCode = eventCustomer.GiftCode
                    };

                    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;
                    }

                    var 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;
                    }
                    customerExportModels.Add(customerExportModel);
                }
            }

            model.Collection = customerExportModels;
            return(model);
        }
Ejemplo n.º 9
0
        public CustomAppointmentsBookedListModel Create(IEnumerable <EventCustomer> eventCustomers, IEnumerable <Appointment> appointments, IEnumerable <Order> orders,
                                                        EventVolumeListModel eventListModel, IEnumerable <Customer> customers, IEnumerable <OrganizationRoleUser> agents, IEnumerable <Role> roles, IEnumerable <OrderedPair <long, string> > agentIdNamePairs,
                                                        IEnumerable <EventAppointmentChangeLog> eventAppointmentChangeLogs, IEnumerable <PrimaryCarePhysician> primaryCarePhysicians, IEnumerable <EventPackage> eventPackages, IEnumerable <EventTest> eventTests,
                                                        IEnumerable <Language> languages)
        {
            var model = new CustomAppointmentsBookedListModel();
            var appointmentsBookedModels = new List <CustomAppointmentsBookedModel>();

            eventCustomers.ToList().ForEach(ec =>
            {
                var eventModel = eventListModel.Collection.FirstOrDefault(e => e.EventCode == ec.EventId);

                var order = orders.FirstOrDefault(o => o.EventId == ec.EventId && o.CustomerId == ec.CustomerId);

                var customer = customers.FirstOrDefault(c => c.CustomerId == ec.CustomerId);

                var customerLanguage = "N/A";
                if (customer.LanguageId.HasValue)
                {
                    var language = languages.FirstOrDefault(x => x.Id == customer.LanguageId);
                    if (language != null)
                    {
                        customerLanguage = language.Name;
                    }
                }

                var productPurchased = string.Empty;

                if (order != null && order.OrderDetails != null && order.OrderDetails.Any())
                {
                    var packageOrderItem = order.OrderDetails.FirstOrDefault(od => od.DetailType == OrderItemType.EventPackageItem && od.IsCompleted);
                    var testOrderItems   = order.OrderDetails.Where(od => od.DetailType == OrderItemType.EventTestItem && od.IsCompleted);

                    if (packageOrderItem != null)
                    {
                        var eventPackage = eventPackages.FirstOrDefault(x => x.Id == packageOrderItem.OrderItem.ItemId);
                        if (eventPackage != null)
                        {
                            productPurchased = eventPackage.Package.Name;
                        }
                    }

                    if (!testOrderItems.IsNullOrEmpty())
                    {
                        var orderIds      = testOrderItems.Select(x => x.OrderItem.ItemId);
                        var customerTests = eventTests.Where(x => orderIds.Contains(x.Id));

                        if (!customerTests.IsNullOrEmpty())
                        {
                            var testNames = customerTests.Select(x => x.Test.Name).ToArray();

                            productPurchased = string.IsNullOrEmpty(productPurchased) ? string.Join(",", testNames) : productPurchased + "," + string.Join(",", testNames);
                        }
                    }
                }

                var rescheduleApplointmentModels = new List <RescheduleApplointmentModel>();

                var eventCustomerReschedules = eventAppointmentChangeLogs.Where(eacl => eacl.EventCustomerId == ec.Id).Select(eacl => eacl).ToArray();

                if (eventCustomerReschedules != null && eventCustomerReschedules.Any())
                {
                    foreach (var ecr in eventCustomerReschedules)
                    {
                        var rescheduledBy = agents.Single(a => a.Id == ecr.CreatedByOrgRoleUserId);

                        var rescheduleAgentRole = roles.Single(r => r.Id == rescheduledBy.RoleId).DisplayName;
                        var rescheduleAgentName = agentIdNamePairs.Single(ap => ap.FirstValue == rescheduledBy.Id).SecondValue;

                        rescheduleApplointmentModels.Add(new RescheduleApplointmentModel()
                        {
                            RescheduledOn = ecr.DateCreated,
                            RescheduledBy = rescheduleAgentName + "(" + rescheduleAgentRole + ")",
                            Reason        = ecr.ReasonId.HasValue && ecr.ReasonId > 0 ? ((RescheduleAppointmentReason)ecr.ReasonId.Value).GetDescription() : "N/A",
                            Notes         = ecr.Notes,
                            SubReason     = ecr.SubReasonId.HasValue && ecr.SubReasonId > 0 ? ((RescheduleAppointmentSubReason)ecr.SubReasonId.Value).GetDescription() : string.Empty,
                        });
                    }
                }

                var pcp = primaryCarePhysicians.Where(p => p.CustomerId == ec.CustomerId).Select(p => p).FirstOrDefault();

                var appointment = ec.AppointmentId.HasValue ? appointments.FirstOrDefault(a => a.Id == ec.AppointmentId.Value) : null;

                var groupName = "N/A";

                if (!string.IsNullOrEmpty(customer.GroupName))
                {
                    groupName = customer.GroupName;
                }
                var status = (appointment != null && appointment.CheckInTime.HasValue && appointment.CheckOutTime.HasValue && !ec.LeftWithoutScreeningReasonId.HasValue) ? "Availed" : "Not Availed";

                var apptModel = new CustomAppointmentsBookedModel
                {
                    CustomerId                = ec.CustomerId,
                    CustomerCode              = customer.CustomerId.ToString(),
                    RegistrantId              = string.IsNullOrEmpty(customer.InsuranceId) ? "N/A" : customer.InsuranceId,
                    RegistrationStatus        = !ec.AppointmentId.HasValue ? "Cancelled" : string.Empty,
                    RescheduleInfo            = rescheduleApplointmentModels,
                    EventDate                 = eventModel.EventDate,
                    AppointmentTime           = ec.AppointmentId.HasValue ? (DateTime?)appointment.StartTime : null,
                    CustomerName              = customer.NameAsString,
                    DateofBirth               = customer.DateOfBirth,
                    Gender                    = customer.Gender.ToString(),
                    Market                    = string.IsNullOrEmpty(customer.Market) ? "N/A" : customer.Market,
                    AdditionalField3          = string.IsNullOrEmpty(customer.AdditionalField3) ? "N/A" : customer.AdditionalField3,
                    AdditionalField4          = string.IsNullOrEmpty(customer.AdditionalField4) ? "N/A" : customer.AdditionalField4,
                    Language                  = customerLanguage,
                    InsuranceId               = string.IsNullOrEmpty(customer.InsuranceId) ? "N/A" : customer.InsuranceId,
                    Address                   = customer.Address,
                    PhoneHome                 = customer.HomePhoneNumber != null ? customer.HomePhoneNumber.ToString() : string.Empty,
                    PhoneCell                 = customer.MobilePhoneNumber != null ? customer.MobilePhoneNumber.ToString() : string.Empty,
                    MedicareAdvantagePlanName = string.IsNullOrEmpty(customer.MedicareAdvantagePlanName) ? "N/A" : customer.MedicareAdvantagePlanName,
                    Package                   = productPurchased,
                    Host                 = eventModel.Location,
                    HostAddress          = eventModel.Address,
                    Status               = status,
                    RegistrationDate     = ec.DataRecorderMetaData.DateCreated,
                    EventId              = ec.EventId.ToString(),
                    GroupName            = groupName,
                    PreferredContactType = customer.PreferredContactType.HasValue ? ((PreferredContactType)customer.PreferredContactType).GetDescription() : "N/A",
                };

                if (pcp != null)
                {
                    apptModel.PcpName  = pcp.Name.FullName;
                    apptModel.PcpPhone = pcp.Primary != null ? pcp.Primary.ToString() : string.Empty;
                    apptModel.PcpNpi   = pcp.Npi;

                    if (pcp.Address != null && !pcp.Address.IsEmpty())
                    {
                        apptModel.PcpAddress1 = pcp.Address.StreetAddressLine1;
                        apptModel.PcpAddress2 = pcp.Address.StreetAddressLine2;
                        apptModel.PcpCity     = pcp.Address.City;
                        apptModel.PcpState    = pcp.Address.State;
                        apptModel.PcpZip      = pcp.Address.ZipCode.Zip;
                    }
                }

                appointmentsBookedModels.Add(apptModel);
            });

            model.Collection = appointmentsBookedModels;
            return(model);
        }
Ejemplo n.º 10
0
        public HourlyAppointmentsBookedListModel CreateHourlyModel(IEnumerable <EventCustomer> eventCustomers, IEnumerable <Appointment> appointments, IEnumerable <Order> orders, EventVolumeListModel eventListModel, IEnumerable <Customer> customers,
                                                                   IEnumerable <OrganizationRoleUser> agents, IEnumerable <Role> roles, IEnumerable <OrderedPair <long, string> > agentIdNamePairs, IEnumerable <SourceCode> sourceCodes, IEnumerable <Call> calls, IEnumerable <ShippingDetail> shippingDetails,
                                                                   ShippingOption cdShippingOption, IEnumerable <ShippingOption> shippingOptions, IEnumerable <EventAppointmentChangeLog> eventAppointmentChangeLogs,
                                                                   IEnumerable <PrimaryCarePhysician> primaryCarePhysicians, IEnumerable <EventPackage> eventPackages, IEnumerable <EventTest> eventTests, IEnumerable <Language> languages,
                                                                   IEnumerable <CorporateCustomerCustomTag> customTags, IEnumerable <CorporateAccount> corporateAccounts, IEnumerable <AccountAdditionalFields> accountAdditionalFields,
                                                                   IEnumerable <PcpAppointment> pcpAppointments, IEnumerable <CustomerEligibility> customerEligibilities)
        {
            var model = new HourlyAppointmentsBookedListModel();
            var appointmentsBookedModels = new List <HourlyAppointmentBookedModel>();

            foreach (var ec in eventCustomers)
            {
                var eventModel = eventListModel.Collection.First(e => e.EventCode == ec.EventId);

                var order = orders.FirstOrDefault(o => o.EventId == ec.EventId && o.CustomerId == ec.CustomerId);

                var productCost = order != null ? order.ProductCost : null;

                var sourceCodeOrderDetail = order == null ? null : order.OrderDetails.Where(
                    od =>
                    od.SourceCodeOrderDetail != null &&
                    od.SourceCodeOrderDetail.IsActive).Select(od => od.SourceCodeOrderDetail).FirstOrDefault();

                var customerEligibility = customerEligibilities.FirstOrDefault(x => x.CustomerId == ec.CustomerId);

                string  sourceCode     = string.Empty;
                decimal sourceCodeDisc = 0;
                if (sourceCodeOrderDetail != null)
                {
                    var coupon = sourceCodes.FirstOrDefault(sc => sc.Id == sourceCodeOrderDetail.SourceCodeId);

                    sourceCode     = coupon != null ? coupon.CouponCode : string.Empty;
                    sourceCodeDisc = sourceCodeOrderDetail.Amount;
                }

                var customer = customers.First(c => c.CustomerId == ec.CustomerId);

                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)));
                        }
                    }
                }

                var     productPurchased    = string.Empty;
                decimal remibursmentRateSum = 0;
                if (order != null && order.OrderDetails != null && order.OrderDetails.Any())
                {
                    var packageOrderItem = order.OrderDetails.FirstOrDefault(od => od.DetailType == OrderItemType.EventPackageItem && od.IsCompleted);
                    var testOrderItems   = order.OrderDetails.Where(od => od.DetailType == OrderItemType.EventTestItem && od.IsCompleted);

                    if (packageOrderItem != null)
                    {
                        var eventPackage = eventPackages.FirstOrDefault(x => x.Id == packageOrderItem.OrderItem.ItemId);
                        if (eventPackage != null)
                        {
                            productPurchased    = eventPackage.Package.Name;
                            remibursmentRateSum = eventPackage.Tests.Sum(t => t.ReimbursementRate);
                        }
                    }

                    if (!testOrderItems.IsNullOrEmpty())
                    {
                        var orderIds      = testOrderItems.Select(x => x.OrderItem.ItemId);
                        var customerTests = eventTests.Where(x => orderIds.Contains(x.Id));

                        if (!customerTests.IsNullOrEmpty())
                        {
                            var testNames = customerTests.Select(x => x.Test.Name).ToArray();
                            remibursmentRateSum = remibursmentRateSum + customerTests.Sum(x => x.ReimbursementRate);
                            productPurchased    = string.IsNullOrEmpty(productPurchased) ? string.Join(",", testNames) : productPurchased + "," + string.Join(",", testNames);
                        }
                    }
                }

                var    registeredBy = (ec.DataRecorderMetaData == null || ec.DataRecorderMetaData.DataRecorderCreator == null ? null : agents.Where(a => a.Id == ec.DataRecorderMetaData.DataRecorderCreator.Id).FirstOrDefault());
                string agentName, callType;
                string agentRole = agentName = callType = string.Empty;

                var incomingLine = calls.Where(c => c.CalledCustomerId == ec.CustomerId && !string.IsNullOrEmpty(c.CalledInNumber)).Select(c => c.CalledInNumber).LastOrDefault();
                var callerNumber = calls.Where(c => c.CalledCustomerId == ec.CustomerId && !string.IsNullOrEmpty(c.CallerNumber)).Select(c => c.CallerNumber).LastOrDefault();


                if (registeredBy != null)
                {
                    if (GetParentRoleIdByRoleId(roles, registeredBy.RoleId) != (long)Roles.CallCenterRep)
                    {
                        incomingLine = "";
                    }

                    if (GetParentRoleIdByRoleId(roles, registeredBy.RoleId) == (long)Roles.Customer)
                    {
                        agentRole = "Internet";
                        agentName = "";
                    }
                    else
                    {
                        agentRole = roles.Where(r => r.Id == registeredBy.RoleId).FirstOrDefault().DisplayName;
                        agentName = agentIdNamePairs.Where(ap => ap.FirstValue == registeredBy.Id).FirstOrDefault().SecondValue;

                        if (GetParentRoleIdByRoleId(roles, registeredBy.RoleId) == (long)Roles.CallCenterRep)
                        {
                            var isIncoming = calls.Where(c => c.CalledCustomerId == ec.CustomerId && c.CreatedByOrgRoleUserId == registeredBy.Id && c.EventId == ec.EventId).Select(c => c.IsIncoming).LastOrDefault();
                            if (isIncoming)
                            {
                                callType = "Inbound ";
                            }
                            else
                            {
                                callType = "Outbound";
                            }
                        }
                    }
                }
                var corporateCustomTags = "N/A";

                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 shippingDetailIds = order == null ? new long[0] : order.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Where(sdod => sdod.IsActive).Select(sdod => sdod.ShippingDetailId)).ToArray();

                var customerShippingDetails = shippingDetails.Where(sd => shippingDetailIds.Contains(sd.Id) && sd.ShippingOption.Id != (cdShippingOption != null ? cdShippingOption.Id : 0)).Select(sd => sd).ToArray();

                IEnumerable <string> customerShippingOptions = null;
                var shippingCost = 0.0m;
                if (customerShippingDetails != null && customerShippingDetails.Count() > 0)
                {
                    var shippingoptionIds = customerShippingDetails.Select(csd => csd.ShippingOption.Id).ToArray();
                    shippingCost            = customerShippingDetails.Sum(sd => sd.ActualPrice);
                    customerShippingOptions = shippingOptions.Where(so => shippingoptionIds.Contains(so.Id)).Select(so => so.Name).ToArray();
                }
                else
                {
                    customerShippingOptions = new[] { "Online" };
                }

                var rescheduleApplointmentModels = new List <RescheduleApplointmentModel>();

                var eventCustomerReschedules = eventAppointmentChangeLogs.Where(eacl => eacl.EventCustomerId == ec.Id).Select(eacl => eacl).ToArray();

                if (eventCustomerReschedules != null && eventCustomerReschedules.Any())
                {
                    foreach (var ecr in eventCustomerReschedules)
                    {
                        var rescheduledBy = agents.Single(a => a.Id == ecr.CreatedByOrgRoleUserId);

                        var rescheduleAgentRole = roles.Single(r => r.Id == rescheduledBy.RoleId).DisplayName;
                        var rescheduleAgentName = agentIdNamePairs.Single(ap => ap.FirstValue == rescheduledBy.Id).SecondValue;

                        rescheduleApplointmentModels.Add(new RescheduleApplointmentModel()
                        {
                            RescheduledOn = ecr.DateCreated,
                            RescheduledBy = rescheduleAgentName + "(" + rescheduleAgentRole + ")",
                            Reason        = ecr.ReasonId.HasValue && ecr.ReasonId > 0 ? ((RescheduleAppointmentReason)ecr.ReasonId.Value).GetDescription() : "N/A",
                            Notes         = ecr.Notes,
                            SubReason     = ecr.SubReasonId.HasValue && ecr.SubReasonId > 0 ? ((RescheduleAppointmentSubReason)ecr.SubReasonId.Value).GetDescription() : string.Empty,
                        });
                    }
                }

                var pcp = primaryCarePhysicians.Where(p => p.CustomerId == ec.CustomerId).Select(p => p).FirstOrDefault();

                var appointment = ec.AppointmentId.HasValue ? appointments.FirstOrDefault(a => a.Id == ec.AppointmentId.Value) : null;

                PcpAppointment pcpAppointment = null;

                if (!pcpAppointments.IsNullOrEmpty())
                {
                    pcpAppointment = pcpAppointments.FirstOrDefault(x => x.EventCustomerId == ec.Id);
                }

                var isEligible = "N/A";
                if (customerEligibility != null && customerEligibility.IsEligible.HasValue)
                {
                    if (customerEligibility.IsEligible.Value)
                    {
                        isEligible = EligibleStatus.Yes.ToString();
                    }
                    else
                    {
                        isEligible = EligibleStatus.No.ToString();
                    }
                }

                var groupName = "N/A";

                if (!string.IsNullOrEmpty(customer.GroupName))
                {
                    groupName = customer.GroupName;
                }
                var status = (appointment != null && appointment.CheckInTime.HasValue && appointment.CheckOutTime.HasValue && !ec.LeftWithoutScreeningReasonId.HasValue) ? "Availed" : "Not Availed";

                var apptModel = new HourlyAppointmentBookedModel
                {
                    CustomerId                = ec.CustomerId,
                    CustomerCode              = customer.CustomerId.ToString(),
                    EventId                   = ec.EventId.ToString(),
                    RecommendPackage          = eventModel.RecommendPackage ? "Yes" : "No",
                    MedicareAdvantagePlanName = string.IsNullOrEmpty(customer.MedicareAdvantagePlanName) ? "N/A" : customer.MedicareAdvantagePlanName,
                    RegistrationDate          = ec.DataRecorderMetaData.DateCreated,
                    //RegistrationTime
                    RegistrationStatus = !ec.AppointmentId.HasValue ? "Cancelled" : string.Empty,
                    AppointmentTime    = ec.AppointmentId.HasValue ? (DateTime?)appointment.StartTime : null,
                    Package            = productPurchased,
                    ShippingOptions    = customerShippingOptions,
                    ShippingCost       = shippingCost,
                    ImagesPurchased    = productCost.HasValue ? "Yes" : "No",
                    ImagesCost         = productCost.HasValue ? productCost.Value : 0,
                    PackageCost        = order == null ? 0 : order.UndiscountedTotal, // Need the Package Cost This includes CD also
                    TotalAmount        = order == null ? 0 : order.DiscountedTotal,
                    AmountPaid         = order == null ? 0 : order.TotalAmountPaid,
                    ReimbursementRate  = remibursmentRateSum,
                    //PrePaid
                    Pod                 = eventModel.Pod,
                    PriortyCode         = sourceCode,
                    PriortyCodeDiscount = sourceCodeDisc,
                    AdSource            = ec.MarketingSource,
                    EventDate           = eventModel.EventDate,
                    EventType           = eventModel.EventType,

                    Host        = eventModel.Location,
                    HostAddress = eventModel.Address,
                    SponsoredBy = string.IsNullOrEmpty(eventModel.CorporateAccount) && string.IsNullOrEmpty(eventModel.HospitalPartner) ? "N/A"
                    : (string.IsNullOrEmpty(eventModel.CorporateAccount) ? eventModel.HospitalPartner : eventModel.CorporateAccount),
                    IncomingPhoneLine   = incomingLine,
                    CallersPhoneNumber  = callerNumber,
                    LastScreeningDate   = string.Empty,
                    RegisterationByRole = agentRole,
                    CallType            = callType,
                    RegisteredBy        = agentName,
                    RescheduleInfo      = rescheduleApplointmentModels,
                    CheckInTime         = (appointment != null && appointment.CheckInTime.HasValue) ? (DateTime?)appointment.CheckInTime.Value : null,
                    CheckOutTime        = (appointment != null && appointment.CheckOutTime.HasValue) ? (DateTime?)appointment.CheckOutTime.Value : null,
                    Status             = status,
                    Tag                = string.IsNullOrEmpty(customer.Tag) ? "N/A" : customer.Tag,
                    CustomTag          = corporateCustomTags,
                    PcpAppointmentDate = pcpAppointment != null ? pcpAppointment.AppointmentOn : (DateTime?)null,
                    IsEligible         = isEligible,
                    GroupName          = groupName,
                    AdditionalFields   = displayFielAandAdditionalFieldsPairs,
                };
                if (pcp != null)
                {
                    apptModel.PcpName  = pcp.Name.FullName;
                    apptModel.PcpPhone = pcp.Primary != null?pcp.Primary.ToString() : string.Empty;

                    apptModel.PcpFax = pcp.Fax != null?pcp.Fax.ToString() : string.Empty;

                    apptModel.PcpNpi = pcp.Npi;
                }

                appointmentsBookedModels.Add(apptModel);
            }
            ;

            model.Collection = appointmentsBookedModels;
            return(model);
        }
Ejemplo n.º 11
0
        public EventCustomerScheduleListModel Create(IEnumerable <EventCustomer> eventCustomers, IEnumerable <Appointment> appointments, IEnumerable <Order> orders, EventVolumeListModel eventListModel,
                                                     IEnumerable <Customer> customers, IEnumerable <OrderedPair <long, string> > packages, IEnumerable <OrderedPair <long, string> > tests, IEnumerable <OrderedPair <long, string> > products)
        {
            var model = new EventCustomerScheduleListModel();
            var eventCustomerModels = new List <EventCustomerScheduleModel>();

            eventListModel.Collection.ToList().ForEach(e =>
            {
                var eventCustomerModel = new EventCustomerScheduleModel
                {
                    Address   = e.Address,
                    EventDate = e.EventDate,
                    EventId   = e.EventCode,
                    Location  = e.Location,

                    Vehicle       = e.Pod,
                    CustomerCount = e.AppointmentsBooked,
                    Customers     =
                        CreateCustomerScheduleModelforEvent(eventCustomers, appointments, orders, e.EventCode, customers, packages, tests, products)
                };
                eventCustomerModels.Add(eventCustomerModel);
            });
            if (eventCustomerModels != null)
            {
                eventCustomerModels = eventCustomerModels.OrderBy(a => a.EventDate).ToList();
            }
            model.Collection = eventCustomerModels;
            return(model);
        }
Ejemplo n.º 12
0
        public TextReminderListModel Create(IEnumerable <EventCustomer> eventCustomers, EventVolumeListModel eventListModel, IEnumerable <Customer> customers, IEnumerable <OrganizationRoleUser> agents, IEnumerable <Role> roles, IEnumerable <OrderedPair <long, string> > agentIdNamePairs)
        {
            var model = new TextReminderListModel();
            var textReminderModels = new List <TextReminderViewModel>();

            eventCustomers.ToList().ForEach(ec =>
            {
                var eventModel = eventListModel.Collection.Where(e => e.EventCode == ec.EventId).FirstOrDefault();

                var customer = customers.Where(c => c.CustomerId == ec.CustomerId).FirstOrDefault();

                var registeredBy = (ec.DataRecorderMetaData == null || ec.DataRecorderMetaData.DataRecorderCreator == null ? null : agents.Where(a => a.Id == ec.DataRecorderMetaData.DataRecorderCreator.Id).FirstOrDefault());

                string agentName, agentRole;
                agentRole = agentName = string.Empty;
                if (registeredBy != null)
                {
                    if (GetParentRoleIdByRoleId(registeredBy.RoleId) == (long)Roles.Customer)
                    {
                        agentRole = "Internet";
                        agentName = "";
                    }
                    else
                    {
                        agentRole = roles.Where(r => r.Id == registeredBy.RoleId).FirstOrDefault().DisplayName;
                        agentName = agentIdNamePairs.Where(ap => ap.FirstValue == registeredBy.Id).FirstOrDefault().SecondValue;
                    }
                }

                var textReminderModel = new TextReminderViewModel
                {
                    CustomerId       = ec.CustomerId,
                    OptedForSmsStaus = ec.EnableTexting ? "Yes" : "No",
                    EventId          = eventModel.EventCode,
                    CustomerName     = customer.Name.FullName,
                    AgentName        = agentName + " (" + agentRole + ")",
                };

                textReminderModels.Add(textReminderModel);
            });
            model.Collection = textReminderModels;
            return(model);
        }
Ejemplo n.º 13
0
        public RescheduleApplointmentListModel Create(IEnumerable <EventAppointmentChangeLog> rescheduledAppointments, IEnumerable <EventCustomer> eventCustomers, IEnumerable <Customer> customers, IEnumerable <Event> events,
                                                      IEnumerable <OrganizationRoleUser> agents, IEnumerable <Role> roles, IEnumerable <OrderedPair <long, string> > agentIdNamePairs, EventVolumeListModel eventsVolumeWithSponsoredBy)
        {
            var model      = new RescheduleApplointmentListModel();
            var collection = new List <RescheduleApplointmentModel>();

            rescheduledAppointments.ToList().ForEach(ra =>
            {
                var eventCustomer = eventCustomers.Single(ec => ec.Id == ra.EventCustomerId);
                var customer      = customers.Single(c => c.CustomerId == eventCustomer.CustomerId);
                var oldEvent      = events.Single(e => e.Id == ra.OldEventId);
                var newEvent      = events.Single(e => e.Id == ra.NewEventId);

                var oldEventsVolumeWithSponsoredBy = eventsVolumeWithSponsoredBy.Collection.Where(e => e.EventCode == ra.OldEventId).FirstOrDefault();
                var newEventsVolumeWithSponsoredBy = eventsVolumeWithSponsoredBy.Collection.Where(e => e.EventCode == ra.NewEventId).FirstOrDefault();

                var oldEventSponsoredByName = string.Empty;
                var newEventSponsoredByName = string.Empty;

                if (oldEventsVolumeWithSponsoredBy != null)
                {
                    oldEventSponsoredByName = oldEventsVolumeWithSponsoredBy.EventType.ToLower() == EventType.Corporate.ToString().ToLower() ? oldEventsVolumeWithSponsoredBy.CorporateAccount : oldEventsVolumeWithSponsoredBy.HospitalPartner;
                }
                if (newEventsVolumeWithSponsoredBy != null)
                {
                    newEventSponsoredByName = newEventsVolumeWithSponsoredBy.EventType.ToLower() == EventType.Corporate.ToString().ToLower() ? newEventsVolumeWithSponsoredBy.CorporateAccount : newEventsVolumeWithSponsoredBy.HospitalPartner;
                }

                var registeredBy = agents.Single(a => a.Id == ra.CreatedByOrgRoleUserId);

                var agentRole = roles.Single(r => r.Id == registeredBy.RoleId).DisplayName;
                var agentName = agentIdNamePairs.Single(ap => ap.FirstValue == registeredBy.Id).SecondValue;

                var rescheduleModel = new RescheduleApplointmentModel
                {
                    CustomerId         = customer.CustomerId,
                    CustomerName       = customer.Name.FullName,
                    OldEventId         = oldEvent.Id,
                    OldEventName       = oldEvent.Name,
                    OldEventDate       = oldEvent.EventDate,
                    OldAppointmentTime = ra.OldAppointmentTime,
                    NewEventId         = newEvent.Id,
                    NewEventName       = newEvent.Name,
                    NewEventDate       = newEvent.EventDate,
                    NewAppointmentTime = ra.NewAppointmentTime,
                    RescheduledOn      = ra.DateCreated,
                    RescheduledBy      = agentName + "(" + agentRole + ")",
                    Reason             = ra.ReasonId.HasValue && ra.ReasonId > 0 ? ((RescheduleAppointmentReason)ra.ReasonId.Value).GetDescription() : "N/A",
                    SubReason          = ra.SubReasonId.HasValue && ra.SubReasonId > 0 ? ((RescheduleAppointmentSubReason)ra.SubReasonId.Value).GetDescription() : string.Empty,
                    Notes = ra.Notes,
                    NewEventSponsoredBy = newEventSponsoredByName,
                    OldEventSponsoredBy = oldEventSponsoredByName,
                };
                collection.Add(rescheduleModel);
            });

            model.Collection = collection;
            return(model);
        }