예제 #1
0
        public IEnumerable <AssignedPhysicianViewModel> GetPhysicianAssignments(long eventId, IEnumerable <long> eventCustomerIds)
        {
            var physicanCustomerAssignments = _physicianCustomerAssignmentRepository.GetCustomerAssignmentbyEventCustomerIds(eventCustomerIds);
            var physicianEventAssignment    = _physicianEventAssignmentRepository.GetAssignedPhysicians(eventId);

            if (physicianEventAssignment == null && physicanCustomerAssignments == null)
            {
                return(null);
            }

            var eventCustomers  = _eventCustomerRepository.GetByIds(eventCustomerIds);
            var models          = new List <AssignedPhysicianViewModel>();
            var specializations = _physicianRepository.GetPhysicianSpecilizationIdNamePairs();
            var physicians      = new List <Physician>();

            foreach (long eventCustomerId in eventCustomerIds)
            {
                var eventCustomer = eventCustomers.Where(ec => ec.Id == eventCustomerId).SingleOrDefault();
                var physicianCustomerAssignment = physicanCustomerAssignments != null?physicanCustomerAssignments.Where(pc => pc.EventCustomerId == eventCustomerId).SingleOrDefault() : null;

                if (physicianCustomerAssignment != null)
                {
                    var assignedPhysicians = GetAssignedPhysicians(physicianCustomerAssignment.PhysicianId, physicianCustomerAssignment.OverReadPhysicianId, physicians, specializations);

                    var model = new AssignedPhysicianViewModel
                    {
                        CustomerId          = eventCustomer.CustomerId,
                        IsDefaultAssignment = false,
                        Primary             = assignedPhysicians.FirstOrDefault(),
                        Overread            = assignedPhysicians.ElementAtOrDefault(1),
                    };
                    models.Add(model);
                }
                else if (physicianEventAssignment != null)
                {
                    var assignedPhysicians = GetAssignedPhysicians(physicianEventAssignment.PhysicianId, physicianEventAssignment.OverReadPhysicianId, physicians, specializations);

                    var model = new AssignedPhysicianViewModel
                    {
                        CustomerId          = eventCustomer.CustomerId,
                        IsDefaultAssignment = true,
                        Primary             = assignedPhysicians.FirstOrDefault(),
                        Overread            = assignedPhysicians.ElementAtOrDefault(1),
                    };
                    models.Add(model);
                }
            }
            return(models);
        }
예제 #2
0
        public ListModelBase <LabsInboundViewModel, LabsInboundFilter> GetLabsInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new LabsInboundFilter();

            var customerEventTestStates = _customerEventTestStateRepository.GetForLabInboundReport(filter as LabsInboundFilter, pageNumber, pageSize, out totalRecords);

            if (customerEventTestStates.IsNullOrEmpty())
            {
                return(null);
            }

            var customerEventScreeningTestIds = customerEventTestStates.Select(x => x.CustomerEventScreeningTestId).Distinct();
            var customerEventScreeningTests   = _eventCustomerResultRepository.GetCustomerEventScreeningTestsByIds(customerEventScreeningTestIds);

            var testIds = customerEventScreeningTests.Select(x => x.TestId).Distinct();
            var tests   = _testRepository.GetTestByIds(testIds);

            var eventCustomerResultIds = customerEventScreeningTests.Select(x => x.EventCustomerResultId).Distinct();
            var eventCustomerResults   = _eventCustomerResultRepository.GetByIds(eventCustomerResultIds);
            var eventCustomers         = _eventCustomerRepository.GetByIds(eventCustomerResultIds);

            var eventIds    = eventCustomers.Select(x => x.EventId).Distinct();
            var events      = _eventRepository.GetByIds(eventIds);
            var customerIds = eventCustomers.Select(x => x.CustomerId).Distinct().ToArray();
            var customers   = _customerRepository.GetCustomers(customerIds);

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds);
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            return(_labsInboundReportFactory.Create(customerEventTestStates, customerEventScreeningTests, eventCustomers, customers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns, tests, events, eventCustomerResults));
        }
예제 #3
0
        public ListModelBase <MemberResultMailedReportViewModel, MemberResultMailedReportFilter> GetMemberResultMailedReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var memberFilter = filter as MemberResultMailedReportFilter;

            var pcpResultMailedFilter = new PcpResultMailedReportModelFilter
            {
                CustomTags = memberFilter.CustomTags,
                ExcludeCustomerWithCustomTag = memberFilter.ExcludeCustomerWithCustomTag,
                DateTo       = memberFilter.DateTo,
                DateFrom     = memberFilter.DateFrom,
                HealthPlanId = memberFilter.HealthPlanId,
                Tag          = memberFilter.Tag
            };
            var shippingDetails = _shippingDetailRepository.GetEventCustomerShippingDetailForFilter(pageNumber, pageSize, pcpResultMailedFilter, memberFilter.ShippingOptions, out totalRecords);

            if (shippingDetails.IsNullOrEmpty())
            {
                return(null);
            }

            var shippingDetailIdEventCustomerIdPairs = _shippingDetailRepository.GetShippingDetailIdEventCustomerIdPairs(shippingDetails.Select(sd => sd.Id).ToArray());
            var addresses      = _addressRepository.GetAddresses(shippingDetails.Select(sd => sd.ShippingAddress.Id).ToList());
            var eventCustomers = _eventCustomerRepository.GetByIds(shippingDetailIdEventCustomerIdPairs.Select(sdec => sdec.SecondValue).ToArray());

            var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray());

            return(_memberResultMailedReportFactory.Create(shippingDetails, shippingDetailIdEventCustomerIdPairs, eventCustomers, customers, addresses));
        }
예제 #4
0
        public ListModelBase <ConfirmationReportViewModel, ConfirmationReportFilter> GetConfirmationReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var confirmationReportFilter   = filter as ConfirmationReportFilter ?? new ConfirmationReportFilter();
            var confirmationQueueCustomers = _callQueueCustomerRepository.GetForConfirmationReport(confirmationReportFilter, pageNumber, pageSize, out totalRecords);

            var collection = new List <ConfirmationReportViewModel>();

            if (confirmationQueueCustomers.IsNullOrEmpty())
            {
                return(new ConfirmationReportListModel
                {
                    Collection = new List <ConfirmationReportViewModel>(),
                    Filter = confirmationReportFilter
                });
            }

            var customerIds = confirmationQueueCustomers.Select(x => x.CustomerId.Value).ToArray();
            var customers   = _customerRepository.GetCustomers(customerIds);

            var callQueueCustomerCalls = _callQueueCustomerCallRepository.GetByCallQueueCustomerIds(confirmationQueueCustomers.Select(x => x.Id));

            var calls = _callCenterCallRepository.GetCallByCustomerIdAndCallQueue(customerIds, HealthPlanCallQueueCategory.AppointmentConfirmation);

            var eventIds = confirmationQueueCustomers.Where(x => x.EventId.HasValue && x.EventId.Value > 0).Select(x => x.EventId.Value).ToArray();
            var events   = _eventService.GetEventBasicInfoEventIds(eventIds);

            var eventCustomerIds = confirmationQueueCustomers.Where(x => x.EventCustomerId.HasValue).Select(x => x.EventCustomerId.Value).ToArray();
            var eventCustomers   = _eventCustomerRepository.GetByIds(eventCustomerIds);

            var eventCustomersByEventIdsAndCustomerIds = _eventCustomerRepository.GetEventCustomersByEventIdsCustomerIds(eventIds, customerIds);

            if (!eventCustomersByEventIdsAndCustomerIds.IsNullOrEmpty())
            {
                eventCustomersByEventIdsAndCustomerIds = eventCustomersByEventIdsAndCustomerIds.Where(x => !eventCustomerIds.Contains(x.Id)).ToArray();
                eventCustomers = eventCustomers.Concat(eventCustomersByEventIdsAndCustomerIds);
            }

            var appointments = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList());

            var healthPlanIds          = confirmationQueueCustomers.Where(x => x.HealthPlanId.HasValue).Select(x => x.HealthPlanId.Value).ToArray();
            var healthPlans            = _corporateAccountRepository.GetByIds(healthPlanIds);
            var restrictionIdNamePairs = _corporateAccountRepository.GetRestrictionIdNamePairs(healthPlanIds);

            var calledByAgentIds         = calls.Select(x => x.CreatedByOrgRoleUserId).Distinct().ToArray();
            var calledByAgentNameIdPairs = _organizationRoleUserRepository.GetNameIdPairofUsers(calledByAgentIds).ToArray();

            var confirmedByAgentIds         = eventCustomers.Where(x => x.ConfirmedBy.HasValue).Select(x => x.ConfirmedBy.Value).ToArray();
            var confirmedByAgentNameIdPairs = _organizationRoleUserRepository.GetNameIdPairofUsers(confirmedByAgentIds).ToArray();

            collection = _confirmationReportingFactory.Create(confirmationQueueCustomers, customers, events, calls, eventCustomers, appointments, healthPlans, restrictionIdNamePairs,
                                                              confirmedByAgentNameIdPairs, calledByAgentNameIdPairs, callQueueCustomerCalls).ToList();

            return(new ConfirmationReportListModel
            {
                Collection = collection,
                Filter = confirmationReportFilter
            });
        }
        public void PollForAdjustOrder()
        {
            _logger.Info("Enter in Service to adjust Order");

            var eventCustomersToAdjustOrder = _eventCustomerAdjustOrderLogRepository.GetEventCustomerToAdjustOrder();

            if (eventCustomersToAdjustOrder.IsNullOrEmpty())
            {
                _logger.Info("No Event Customer Found For Adjusting Order");
                return;
            }

            var eventCustomers = _eventCustomerRepository.GetByIds(eventCustomersToAdjustOrder.Select(x => x.EventCustomerId));

            foreach (var eventCustomer in eventCustomers)
            {
                if (eventCustomer.AppointmentId == null)
                {
                    _logger.Info("Appointment has been cancel");
                    continue;
                }

                var customrePreApprovedTest = _preApprovedTestRepository.GetByCustomerId(eventCustomer.Id);

                if (customrePreApprovedTest.IsNullOrEmpty())
                {
                    _logger.Info("Customer  has no pre approved test" + eventCustomer.CustomerId);
                }

                var preApprovedPackage = _preApprovedPackageRepository.GetByCustomerId(eventCustomer.CustomerId);

                if (customrePreApprovedTest.IsNullOrEmpty())
                {
                    _logger.Info("Customer  has no pre-approved test" + eventCustomer.CustomerId);
                }

                if (preApprovedPackage.IsNullOrEmpty())
                {
                    _logger.Info("Customer  has no pre-approved package" + eventCustomer.CustomerId);
                }

                var customerOrderDtails = new CustomerOrderDetail
                {
                    CustomerId         = eventCustomer.CustomerId,
                    EventId            = eventCustomer.EventId,
                    PreApprovedTestIds = customrePreApprovedTest != null?customrePreApprovedTest.Select(x => x.TestId) : null,
                                             PrePackageId = preApprovedPackage.IsNullOrEmpty() ? 0 : preApprovedPackage.First().PackageId
                };

                ChangePackage(customerOrderDtails);
            }
        }
        public ListModelBase <ConditionInboundViewModel, ConditionInboundFilter> GetConditionInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new ConditionInboundFilter();

            var diagnosisRecords = _eventCustomerDiagnosisRepository.GetForConditionInboundReport(filter as ConditionInboundFilter, pageNumber, pageSize, out totalRecords);

            if (!diagnosisRecords.Any())
            {
                return(null);
            }

            var eventCustomerIds = diagnosisRecords.Select(x => x.EventCustomerId).Distinct().ToArray();
            var eventCustomers   = _eventCustomerRepository.GetByIds(eventCustomerIds);

            var customerIds    = eventCustomers.Select(x => x.CustomerId).Distinct().ToArray();
            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds);
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            return(_conditionInboundReportFactory.Create(diagnosisRecords, eventCustomers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns));
        }
        public ListModelBase <BarrierInboundViewModel, BarrierInboundFilter> GetBarrierInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new BarrierInboundFilter();

            var eventCustomerBarriers = _barrierRepository.GetForBarrierInboundReport(filter as BarrierInboundFilter, pageNumber, pageSize, out totalRecords);

            var barrierIds = eventCustomerBarriers.Select(x => x.BarrierId).ToArray();
            var barriers   = _barrierRepository.GetByIds(barrierIds);

            var eventCustomerIds = eventCustomerBarriers.Select(x => x.EventCustomerId);
            var eventCustomers   = _eventCustomerRepository.GetByIds(eventCustomerIds);

            var customerIds = eventCustomers.Select(x => x.CustomerId).ToArray();
            var customers   = customerIds.Any() ? _customerRepository.GetCustomers(customerIds) : null;

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds);
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            return(_barrierInboundReportFactory.Create(eventCustomerBarriers, barriers, eventCustomers, customers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns));
        }
예제 #8
0
        public ListModelBase <TestNotPerformedViewModel, TestNotPerformedListModelFilter> GetTestNotPerformed(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var testNotPerformFilter = filter as TestNotPerformedListModelFilter;
            var testNotPerformed     = _testNotPerformedRepository.GetTestNotPerformedForHealthPlan(testNotPerformFilter, pageNumber, pageSize, out totalRecords);

            if (testNotPerformed == null || !testNotPerformed.Any())
            {
                return(null);
            }

            var customerEventScreeningTestIds = testNotPerformed.Select(x => x.CustomerEventScreeningTestId).ToArray();

            var customerEventScreeningTests = _eventCustomerResultRepository.GetCustomerEventScreeningTestsByIds(customerEventScreeningTestIds);

            var customerEventTestStates = _customerEventTestStateRepository.GetCustomerEventTestState(customerEventScreeningTestIds);

            var orgRoleUserIds = customerEventTestStates.Where(cets => cets.ConductedByOrgRoleUserId.HasValue).Select(cets => cets.ConductedByOrgRoleUserId.Value).Distinct().ToArray();
            var idNamePairs    = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds);

            var eventCustomerResults = _eventCustomerResultRepository.GetByIds(customerEventScreeningTests.Select(ces => ces.EventCustomerResultId).Distinct().ToArray());
            var eventIds             = eventCustomerResults.Select(ecr => ecr.EventId).Distinct().ToArray();

            var events = _eventRepository.GetEventswithPodbyIds(eventIds);
            var hosts  = _hostRepository.GetEventHosts(events.Select(x => x.Id));
            IEnumerable <OrderedPair <long, long> >   staffOrgRoleUserEventsPair = null;
            IEnumerable <OrderedPair <long, string> > staffNamePair = null;

            var npRoles = _eventRoleRepository.GetByName(_awvNpEventStaffRole);

            if (npRoles != null && npRoles.Any())
            {
                var eventStaffs = _eventStaffAssignmentRepository.GetForEvents(eventIds);
                var npRoleIds   = npRoles.Select(x => x.Id);

                if (eventStaffs != null && eventStaffs.Any())
                {
                    eventStaffs = eventStaffs.Where(x => npRoleIds.Contains(x.StaffEventRoleId)).ToArray();
                }

                staffOrgRoleUserEventsPair = eventStaffs.Select(p => new OrderedPair <long, long>(p.ScheduledStaffOrgRoleUserId, p.EventId)).ToArray();

                staffNamePair = _organizationRoleUserRepository.GetNameIdPairofUsers(staffOrgRoleUserEventsPair.Select(x => x.FirstValue).ToArray());
            }

            var customers = _customerRepository.GetCustomers(eventCustomerResults.Select(ecr => ecr.CustomerId).Distinct().ToArray());

            //var tags = customers.Select(x => x.Tag).Distinct().ToArray();

            //var corporateAccount = _corporateAccountRepository.GetByTags(tags);

            var accountIds = events.Where(x => x.AccountId.HasValue && x.AccountId > 0).Select(x => x.AccountId.Value).Distinct().ToArray();

            var corporateAccount = _corporateAccountRepository.GetByIds(accountIds);

            if (corporateAccount != null && corporateAccount.Any())
            {
                corporateAccount = corporateAccount.Where(x => x.IsHealthPlan);
            }

            var tests = ((IUniqueItemRepository <Test>)_testRepository).GetByIds(customerEventScreeningTests.Select(ces => ces.TestId).Distinct().ToArray());

            var customersPreApprovedTest = _preApprovedTestRepository.GetPreApprovedTestIdsByCustomerIds(eventCustomerResults.Select(x => x.Id));
            var pods = _podRepository.GetByIds(events.SelectMany(e => e.PodIds).Distinct());

            var eventCustomers = _eventCustomerRepository.GetByIds(customerEventScreeningTests.Select(ces => ces.EventCustomerResultId).Distinct().ToArray());

            return(_testNotPerformedFactory.Create(testNotPerformed, customerEventScreeningTests, eventCustomerResults, events, customers, tests,
                                                   customersPreApprovedTest, corporateAccount, pods, customerEventTestStates, idNamePairs, staffOrgRoleUserEventsPair, staffNamePair, hosts, eventCustomers));
        }