コード例 #1
0
        public ListModelBase <PhysicianReviewViewModel, PhysicianReviewListModelFilter> GetPhysicianReviews(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var evaluations = _physicianEvaluationRepository.GetEvaluations(pageNumber, pageSize, filter as PhysicianReviewListModelFilter, out totalRecords);

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

            var physiciansIdNamePair = _organizationRoleUserRepository.GetNameIdPairofUsers(evaluations.Select(e => e.PhysicianId).ToArray());

            var eventCustomerIds = evaluations.Select(e => e.EventCustomerId).ToArray();

            var eventCustomers = _eventCustomerRepository.GetByIds(eventCustomerIds);

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

            var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds, true);

            var orderIds = orders.Select(o => o.Id).ToArray();
            var orderPackageIdNamePair = _eventPackageRepository.GetPackageNamesForOrder(orderIds);
            var orderTestIdNamePair    = _eventTestRepository.GetTestNamesForOrders(orderIds);

            var eventIds = eventCustomers.Select(ec => ec.EventId).ToArray();

            var eventCustomerResults = _eventCustomerResultRepository.GetByIds(eventCustomerIds).ToArray();

            //var criticalEventIdCustomerIdPair = _eventCustomerResultRepository.GetCriticalEventIdCustomerIdPairForPhysicianReview(eventIds);

            var criticalEventIdCustomerIdPair = (from ecr in eventCustomerResults
                                                 where ecr.ResultSummary == (long)ResultInterpretation.Critical
                                                 &&
                                                 (
                                                     (ecr.ResultState == (int)TestResultStateNumber.Evaluated && !ecr.IsPartial) ||
                                                     ecr.ResultState > (int)TestResultStateNumber.Evaluated
                                                 )
                                                 select new OrderedPair <long, long>(ecr.EventId, ecr.CustomerId)).ToList();

            //var pdfGeneratedEventIdCustomerIdPair = _eventCustomerResultRepository.GetPdfGeneraredEventIdCustomerIdPair(eventIds);

            var pdfGeneratedEventIdCustomerIdPair = (from ecr in eventCustomerResults
                                                     where ecr.IsClinicalFormGenerated && ecr.IsResultPdfGenerated
                                                     select new OrderedPair <long, long>(ecr.EventId, ecr.CustomerId)).ToList();

            var events = _eventRepository.GetEventswithPodbyIds(eventIds);
            var pods   = _podRepository.GetPodsForEvents(events.Select(e => e.Id).ToArray());

            var halfStudyEventCustomerIds = _physicianEvaluationRepository.GetEventCustomerIdsForHalfStudy(eventCustomerIds);

            var evaluationPendingEventCustomerIds = (from ecr in eventCustomerResults
                                                     where ecr.ResultState == (int)TestResultStateNumber.Evaluated && ecr.IsPartial
                                                     select ecr.Id).ToList();

            return(_physicianReviewListFactory.Create(evaluations, physiciansIdNamePair, eventCustomers, customers, orders, orderPackageIdNamePair, orderTestIdNamePair,
                                                      criticalEventIdCustomerIdPair, events, pdfGeneratedEventIdCustomerIdPair, pods, halfStudyEventCustomerIds, evaluationPendingEventCustomerIds));
        }
コード例 #2
0
        private List <EventHostDepositViewData> GetEventHostDepositViewDatas(long?eventId, DateTime?dueStartDate, DateTime?dueEndDate, HostPaymentStatus?hostPaymentStatus)
        {
            var hostDeposits = _hostDeositRepository.GetByFilters(eventId, dueStartDate, dueEndDate,
                                                                  hostPaymentStatus);

            var eventIds = hostDeposits.Select(hp => hp.EventId);

            var events = _uniqueItemRepository.GetByIds(eventIds);

            var hosts = _hostRepository.GetEventHosts(eventIds);

            return(hostDeposits.HostDepositViewData(events, hosts));
        }
コード例 #3
0
        public CustomerPhoneNumberListModel GetPhoneNumberUploadDetails(CustomerPhoneNumberUpdateModelFilter filter, int pageNumber, int pageSize, out int totalRecords)
        {
            var phoneNumberUploads = _customerPhoneNumberUpdateUploadRepository.GetByFilter(pageNumber, pageSize, filter, out totalRecords);

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

            var successFieldIds = phoneNumberUploads.Select(s => s.FileId).ToArray();
            var failedFileIds   = phoneNumberUploads.Where(x => x.LogFileId.HasValue).Select(x => x.LogFileId.Value).ToArray();
            var totalFileIds    = successFieldIds.Concat(failedFileIds);

            IEnumerable <FileModel> fileModels = null;

            if (!totalFileIds.IsNullOrEmpty())
            {
                var files = _fileRepository.GetByIds(totalFileIds);
                if (files != null && files.Any())
                {
                    fileModels = GetFileModelFromFile(files, _mediaRepository.GetCustomerPhoneNumberUploadLocation());
                }
            }

            var phoneNumberUploadedByIds = phoneNumberUploads.Select(x => x.UploadedByOrgRoleUserId).ToArray();
            IEnumerable <OrderedPair <long, string> > uploadedbyAgentNameIdPair = null;

            if (!phoneNumberUploadedByIds.IsNullOrEmpty())
            {
                uploadedbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(phoneNumberUploadedByIds).ToArray();
            }

            return(_customerPhoneNumberListModelFactory.Create(fileModels, phoneNumberUploads, uploadedbyAgentNameIdPair));
        }
コード例 #4
0
        public ListModelBase <PcpSummaryLogReportModel, PcpSummaryLogReportModelFilter> GetPcpSummaryLogReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var shippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages, true);

            var shippingDetails = _shippingDetailRepository.GetEventCustomerShippingDetailForFilter(pageNumber, pageSize, filter as PcpSummaryLogReportModelFilter, new[] { shippingOption.Id }, out totalRecords);

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

            var shippingDetailIdEventCustomerIdPairs = _shippingDetailRepository.GetShippingDetailIdEventCustomerIdPairs(shippingDetails.Select(sd => sd.Id).ToArray());

            var eventCustomers = _eventCustomerRepository.GetByIds(shippingDetailIdEventCustomerIdPairs.Select(sdec => sdec.SecondValue).ToArray());

            var customerIds = eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray();

            var customers = _customerRepository.GetCustomers(customerIds);

            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(customerIds);

            var eventids = eventCustomers.Select(e => e.EventId).Distinct().ToArray();

            var eventCollection = ((IUniqueItemRepository <Event>)_eventRepository).GetByIds(eventids);

            return(_pcpSummaryLogReportListModelFactory.Create(shippingDetails, shippingDetailIdEventCustomerIdPairs, eventCustomers, customers, primaryCarePhysicians, eventCollection));
        }
コード例 #5
0
        public PodListModel GetPodListModel(int pageNumber, int pageSize)
        {
            var pods   = _podRepository.GetAllPods();
            var podIds = pods.Select(p => p.Id).ToArray();

            var multiplePodStaff = _podStaffAssignmentRepository.GetPodStaffforMultiplePods(podIds);
            var eventRoles       = _staffEventRoleRepository.GetByIds(multiplePodStaff.Select(p => p.EventRoleId).Distinct()).ToArray();
            var territories      = _territoryRepository.GetMultiplePodTerritoriesIdNamePair(podIds);

            var orgRoleUsers  = _orgRoleUserrepository.GetNameIdPairofUsers(multiplePodStaff.Select(mps => mps.OrganizationRoleUserId).Distinct().ToArray());
            var organizations =
                _organizationRepository.GetOrganizationCollection(OrganizationType.Franchisee)
                .Where(o => pods.Select(p => p.AssignedToFranchiseeid).Contains(o.Id));

            return(_podListModelFactory.Create(pods, multiplePodStaff, eventRoles, territories, orgRoleUsers, organizations));
        }
コード例 #6
0
        public StaffEventScheduleUploadListModel GetStaffEventScheduleUploadDetails(int pageNumber, int pageSize, StaffEventScheduleUploadModelFilter filter, out int totalRecords)
        {
            var staffEventUploads = (IReadOnlyCollection <StaffEventScheduleUpload>)_staffEventScheduleUploadRepository.GetByFilter(pageNumber, pageSize, filter, out totalRecords);

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

            var successfileIds = staffEventUploads.Select(s => s.FileId).ToArray();
            var failedfileIds  = staffEventUploads.Where(x => x.LogFileId.HasValue).Select(s => s.LogFileId.Value).ToArray();
            var fileIds        = successfileIds.Concat(failedfileIds).ToArray();

            IEnumerable <FileModel> fileModels = null;

            if (fileIds != null && fileIds.Any())
            {
                var files = _fileRepository.GetByIds(fileIds);

                if (files != null && files.Any())
                {
                    fileModels = GetFileModelFromFile(files, _mediaRepository.GetStaffScheduleUploadMediaFileLocation());
                }
            }
            var eligibilityUploadByIds = staffEventUploads.Select(c => c.UploadedByOrgRoleUserId).ToArray();
            IEnumerable <OrderedPair <long, string> > uploadedbyNameIdPair = null;

            uploadedbyNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(eligibilityUploadByIds).ToArray();

            return(_staffEventScheduleUploadListModelFactory.Create(fileModels, staffEventUploads, uploadedbyNameIdPair));
        }
コード例 #7
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));
        }
コード例 #8
0
        public CustomerActivityTypeUploadListModel GetCustomerActivityTypeUploadDetails(int pageNumber, int pageSize, CustomerActivityTypeUploadListModelFilter filter, out int totalRecords)
        {
            var customerActivityTypeUploads = (IReadOnlyCollection <CustomerActivityTypeUpload>)_customerActivityTypeUploadRepository.GetByFilter(pageNumber, pageSize, filter, out totalRecords);

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

            var successfileIds = customerActivityTypeUploads.Select(s => s.FileId).ToArray();
            var failedfileIds  = customerActivityTypeUploads.Where(x => x.LogFileId.HasValue).Select(s => s.LogFileId.Value).ToArray();
            var fileIds        = successfileIds.Concat(failedfileIds).ToArray();

            IEnumerable <FileModel> fileModels = null;

            if (fileIds != null && fileIds.Any())
            {
                var files = _fileRepository.GetByIds(fileIds);

                if (files != null && files.Any())
                {
                    fileModels = GetFileModelFromFile(files, _mediaRepository.GetCustomerActivityTypeUploadMediaFileLocation());
                }
            }
            var customerActivityTypeUploadByIds = customerActivityTypeUploads.Select(c => c.UploadedBy).ToArray();
            IEnumerable <OrderedPair <long, string> > uploadedbyNameIdPair = null;

            uploadedbyNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(customerActivityTypeUploadByIds).ToArray();

            return(GetListModel(fileModels, customerActivityTypeUploads, uploadedbyNameIdPair));
        }
コード例 #9
0
        public MemberUploadDetailsListModel GetMemberUploadDetails(int pageNumber, int pageSize, MemberUploadDetailsListModelFilter filter, out int totalRecords)
        {
            filter.SourceId = (long)MemberUploadSource.Aces;
            var corporateUploads = (IReadOnlyCollection <CorporateUpload>)_corporateUploadRepository.GetByFilter(pageNumber, pageSize, filter, out totalRecords);

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

            var successfileIds = corporateUploads.Select(s => s.FileId).ToArray();
            var failedfileIds  = corporateUploads.Where(x => x.LogFileId.HasValue).Select(s => s.LogFileId.Value).ToArray();
            var fileIds        = successfileIds.Concat(failedfileIds).ToArray();
            // var mediaLocation = filter.SourceId == (long)MemberUploadSource.Aces ? _mediaRepository.GetMemberUploadbyAcesFolderLocation() : _mediaRepository.GetUploadCsvMediaFileLocation();
            var mediaLocation = _mediaRepository.GetMemberUploadbyAcesFolderLocation();


            IEnumerable <FileModel> fileModels = null;

            if (fileIds != null && fileIds.Any())
            {
                var files = _fileRepository.GetByIds(fileIds);

                if (files != null && files.Any())
                {
                    fileModels = GetFileModelFromFile(files, mediaLocation);
                }
            }

            return(GetListModel(fileModels, corporateUploads));
        }
コード例 #10
0
        public IEnumerable <EventCustomerShippingDetailViewData> GetEventCustomerShippingDetailViewData(int pageNumber, int pageSize, EventCustomerShippingDetailViewDataFilter filter)
        {
            int totalRecords    = 0;
            var shippingDetails = _shippingDetailRepository.GetEventCustomerShippingDetailForFilter(pageNumber, pageSize, filter, out totalRecords);

            if (shippingDetails.IsNullOrEmpty())
            {
                return(null);
            }
            var shippingDetailIdEventCustomerIdPairs = _shippingDetailRepository.GetShippingDetailIdEventCustomerIdPairs(shippingDetails.Select(sd => sd.Id).ToArray());

            var eventCustomers   = _eventCustomerRepository.GetByIds(shippingDetailIdEventCustomerIdPairs.Select(sdec => sdec.SecondValue).ToArray());
            var eventCustomerIds = eventCustomers.Select(ec => ec.Id).ToArray();
            var eventIds         = eventCustomers.Select(ec => ec.EventId).ToArray();

            var customers            = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray());
            var events               = _eventRepository.GetEventswithPodbyIds(eventIds);
            var eventCustomerResults = _eventCustomerResultRepository.GetByIds(eventCustomerIds);

            var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds, true);
            var orderPackageIdNamePairs = _eventPackageRepository.GetPackageNamesForOrder(orders.Select(o => o.Id).ToList());
            var orderTestIdNamePairs    = _eventTestRepository.GetTestNamesForOrders(orders.Select(o => o.Id).ToList());
            var addresses       = _addressRepository.GetAddresses(shippingDetails.Select(sd => sd.ShippingAddress.Id).ToList());
            var shippingOptions = _shippingOptionRepository.GetByIds(shippingDetails.Select(sd => sd.ShippingOption.Id).Distinct().ToArray());

            var orderIdProductNamePairs = _productRepository.GetProductNamesForOrder(orders.Select(o => o.Id).ToArray());

            return(_eventCustomerShippingDetailViewDataFactory.Create(shippingDetails,
                                                                      shippingDetailIdEventCustomerIdPairs,
                                                                      eventCustomers, customers, events,
                                                                      eventCustomerResults, orders,
                                                                      orderPackageIdNamePairs, orderTestIdNamePairs,
                                                                      addresses,
                                                                      shippingOptions, totalRecords, orderIdProductNamePairs));
        }
コード例 #11
0
        public PhysicianDashboardViewModel GetPhysicianStats(long physicianId)
        {
            var overReadEvaluationPair = _physicianRepository.GetEventCustomerIdForOverReadPhysicianEvaluation(physicianId);
            var evaluationPair         = _physicianRepository.GetEventCustomerIdForPhysicianEvaluation(physicianId);

            var physician            = _physicianRepository.GetPhysician(physicianId);
            var specializations      = _physicianRepository.GetPhysicianSpecilizationIdNamePairs();
            var tests                = _uniqueItemTestRepository.GetByIds(physician.PermittedTests);
            var physicianEvaluations = _physicianEvaluationRepository.GetPhysicianEvaluationbyPhysician(physicianId);
            var count                = physicianEvaluations == null ? 0 : physicianEvaluations.Where(pe => pe.EvaluationEndTime != null).Count();

            IEnumerable <PhysicianLicesneViewModel> licenses = null;

            if (physician.AuthorizedStateLicenses != null && physician.AuthorizedStateLicenses.Count() > 0)
            {
                var states =
                    _stateRepository.GetStates(physician.AuthorizedStateLicenses.Select(p => p.StateId).ToArray());

                licenses = physician.AuthorizedStateLicenses.Select(asl => new PhysicianLicesneViewModel()
                {
                    ExpiryDate    = asl.Expirydate,
                    LicenseNumber = asl.LicenseNumber,
                    State         = states.Where(s => asl.StateId == s.Id).First().Name,
                    Id            = asl.Id
                }).ToArray();
            }

            var mediaLocation = _mediaRepository.GetPhysicianSignatureMediaFileLocation();

            return(new PhysicianDashboardViewModel
            {
                //TotalEvaluationsDone = count,
                PhysicianId = physicianId,
                Name = physician.NameAsString,
                Specialization = physician.SpecializationId > 0 ? specializations.Where(sp => sp.FirstValue == physician.SpecializationId).Single().SecondValue : "",
                PermittedTests = tests,
                Licenses = licenses,
                SignaturePath = physician.SignatureFile != null ? mediaLocation.Url + physician.SignatureFile.Path : "",
                //TotalEvaluationsAvailable = evaluationPair != null ? evaluationPair.SecondValue : 0,
                //TotalOverreadsAvailable = overReadEvaluationPair != null ? overReadEvaluationPair.SecondValue : 0
                PhysicianEvaluationsQueue = new PhysicianEvaluationQueueSummary
                {
                    ItemsDone = count,
                    CriticalsInQueue = evaluationPair.CriticalsInQueue,
                    PriorityInQueueCount = evaluationPair.PriorityInQueueCount,
                    ItemsAvailable = evaluationPair.ItemsAvailable,
                    FirstItemInTheQueue = evaluationPair.FirstItemInTheQueue
                },
                PhysicianOverReadsQueue = new PhysicianEvaluationQueueSummary
                {
                    CriticalsInQueue = overReadEvaluationPair.CriticalsInQueue,
                    PriorityInQueueCount = overReadEvaluationPair.PriorityInQueueCount,
                    FirstItemInTheQueue = overReadEvaluationPair.FirstItemInTheQueue,
                    ItemsAvailable = overReadEvaluationPair.ItemsAvailable
                }
            });
        }
コード例 #12
0
        public ListModelBase <InterviewInboundViewModel, InterviewInboundFilter> GetInterviewInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new InterviewInboundFilter();
            var interviewInboundFilter = filter as InterviewInboundFilter ?? new InterviewInboundFilter();

            var responseVendorReportFilter = new ResponseVendorReportFilter
            {
                StartDate  = interviewInboundFilter.StartDate,
                EndDate    = interviewInboundFilter.EndDate,
                AccountId  = interviewInboundFilter.AccountId,
                CustomTags = interviewInboundFilter.CustomTags
            };

            var customerIds = _customerRepository.GetCustomersByCustomTag(responseVendorReportFilter, pageNumber, pageSize, out totalRecords);

            //var customerIds = _callRepository.GetForInterviewReport(filter as InterviewInboundFilter, pageNumber, pageSize, out totalRecords);
            if (customerIds.IsNullOrEmpty())
            {
                return(null);
            }

            var calls = _callRepository.GetCallsForInterviewReport(filter as InterviewInboundFilter, customerIds);

            var customers = customerIds.Any() ? _customerRepository.GetCustomers(customerIds.ToArray()) : new List <Customer>();

            //var eventCustomers = _eventCustomerRepository.GetEventCustomersByEventIdsCustomerIds(eventIds, customerIds) ?? new List<EventCustomer>();
            var eventCustomers   = _eventCustomerRepository.GetByEventIdsOrCustomerIds(interviewInboundFilter.StartDate, customerIds) ?? new List <EventCustomer>();
            var eventCustomerIds = eventCustomers.Select(x => x.Id);

            var eventIds = eventCustomers.Select(x => x.EventId).ToArray();
            var events   = _eventRepository.GetEvents(eventIds);

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

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

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

            var eventAppointmentCancellatonLogs = _eventAppointmentCancellationLogRepository.GetByEventCustomerIds(eventCustomerIds);

            var noteIds           = eventAppointmentCancellatonLogs.Where(x => x.NoteId.HasValue).Select(x => x.NoteId.Value);
            var customerCallNotes = _customerCallNotesRepository.GetByIds(noteIds);

            var eventIdStaffIdPairs = _eventRepository.GetEventStaffPairs(eventIds);

            var orgRoleUserIds        = eventIdStaffIdPairs.Select(x => x.SecondValue).Distinct().ToArray();
            var organizationRoleUsers = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);

            var userIds = organizationRoleUsers.Select(x => x.UserId).Distinct().ToList();
            var users   = _userRepository.GetUsers(userIds);

            return(_interviewInboundReportFactory.Create(eventCustomers, customers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns, calls, appointments, events, eventAppointmentCancellatonLogs, customerCallNotes, eventIdStaffIdPairs,
                                                         organizationRoleUsers, users));
        }
コード例 #13
0
        public void DeleteReports()
        {
            try
            {
                var timeOfDay = DateTime.Now;
                if (_isDevEnvironment || timeOfDay.TimeOfDay > new TimeSpan(4, 0, 0))
                {
                    var queues = _exportableReportsQueueRepository.GetExportableReportsQueuesForDelete(_noOfdays);
                    if (queues.IsNullOrEmpty())
                    {
                        _logger.Info("No exportable queue found.");
                        return;
                    }
                    var fileIds = queues.Where(q => q.FileId.HasValue && q.FileId > 0).Select(q => q.FileId.Value).ToArray();
                    var files   = _fileRepository.GetByIds(fileIds);
                    foreach (var exportableReportsQueue in queues)
                    {
                        try
                        {
                            if (exportableReportsQueue.FileId.HasValue && exportableReportsQueue.FileId > 0)
                            {
                                var file = files.Single(f => f.Id == exportableReportsQueue.FileId);

                                var completePath = _locationPath + file.Path;
                                if (System.IO.File.Exists(completePath))
                                {
                                    System.IO.File.Delete(completePath);
                                }
                                _exportableReportsQueueRepository.Delete(exportableReportsQueue.Id);
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("Error while deleting Exportable report queue id :" + exportableReportsQueue.Id);
                            _logger.Error("Message :" + ex.Message);
                            _logger.Error("Stack Trace :" + ex.StackTrace);
                        }
                    }


                    _logger.Info("Reports Deleted Successfully");
                }
                else
                {
                    _logger.Info(string.Format("Delete Report can not be called as time of day is {0}", timeOfDay.TimeOfDay));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Message :" + ex.Message);
                _logger.Error("Stack Trace :" + ex.StackTrace);
            }
        }
コード例 #14
0
        public SourceCodeListModel Get(SourceCodeListModelFilter filter, int pageNumber, int pageSize, out long totalRecords)
        {
            var sourceCodes = _sourceCodeRepository.GetbyFilter(filter, pageNumber, pageSize, out totalRecords);

            if (sourceCodes == null || sourceCodes.Count() < 1)
            {
                return(null);
            }

            var packageids = sourceCodes.Where(sc => sc.PackageDiscounts != null).SelectMany(sc => sc.PackageDiscounts.Select(pd => pd.Id)).ToArray();
            var packages   = packageids.Count() > 0 ? _packageRepository.GetByIds(packageids) : null;

            var testIds = sourceCodes.Where(sc => sc.TestDiscounts != null).SelectMany(sc => sc.TestDiscounts.Select(pd => pd.Id)).ToArray();
            var tests   = testIds.Count() > 0 ? _testRepository.GetByIds(testIds) : null;

            var shippingOptionIds = sourceCodes.Where(sc => sc.ShippingDiscounts != null).SelectMany(sc => sc.ShippingDiscounts.Select(sd => sd.Id)).ToArray();
            var shippingOptions   = shippingOptionIds.Count() > 0 ? _shippingOptionRepository.GetByIds(shippingOptionIds) : null;

            var productIds = sourceCodes.Where(sc => sc.ProductDiscounts != null).SelectMany(sc => sc.ProductDiscounts.Select(pd => pd.Id)).ToArray();
            var products   = productIds.Count() > 0 ? _electronicProductRepository.GetByIds(productIds) : null;

            return(_sourceCodeFactory.Create(sourceCodes, packages, tests, shippingOptions, products));
        }
コード例 #15
0
        public ListModelBase <CustomAppointmentsBookedModel, CustomAppointmentsBookedListModelFilter> GetCustomAppointmentsBooked(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var customFilter = filter as CustomAppointmentsBookedListModelFilter;

            customFilter = customFilter ?? new CustomAppointmentsBookedListModelFilter();

            var appFilter = new AppointmentsBookedListModelFilter
            {
                AccountId = customFilter.AccountId,
                FromDate  = customFilter.FromDate,
                ToDate    = customFilter.ToDate,
                Tag       = customFilter.Tag
            };
            var eventCustomers = _eventCustomerRepository.GetEventCustomersbyRegisterationDate(pageNumber, pageSize, appFilter, out totalRecords);

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

            var appointments = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList());
            var eventIds     = eventCustomers.Select(ec => ec.EventId).Distinct().ToArray();
            var model        = _eventReportingService.GetEventVolumeModel(eventCustomers.Select(ec => ec.EventId).Distinct().ToArray());

            var customers   = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var customerIds = customers.Select(x => x.CustomerId);
            var orders      = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray(), true);

            var eventPackages = _eventPackageRepository.GetbyEventIds(eventIds);
            var eventTests    = _eventTestRepository.GetByEventIds(eventIds);


            var orgRoleUserIds = eventCustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList();

            var eventAppointmentChangeLogs = _eventAppointmentChangeLogRepository.GetByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray()).ToArray();

            orgRoleUserIds.AddRange(eventAppointmentChangeLogs.Select(eacl => eacl.CreatedByOrgRoleUserId));

            var registeredbyAgent = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);

            var roles = _roleRepository.GetAll();

            var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray();

            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var languages             = _languageRepository.GetAll();

            return(_customAppointmentsBookedModelFactory.Create(eventCustomers, appointments, orders, model, customers, registeredbyAgent,
                                                                roles, registeredbyAgentNameIdPair, eventAppointmentChangeLogs, primaryCarePhysicians, eventPackages, eventTests, languages));
        }
コード例 #16
0
        public ListModelBase <CdImageStatusModel, CdImageStatusModelFilter> GetCdImageStatusmodel(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var eventCustomers = _eventCustomerRepository.GetEventCustomerswithCdPurchase(pageNumber, pageSize, filter as CdImageStatusModelFilter, out totalRecords);

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

            var orderShippingStatus = _orderDetailRepository.GetCdImageShippingStatusfortheEventCustomers(eventCustomers.Select(ec => ec.Id).ToArray());
            var events    = _eventRepository.GetByIds(eventCustomers.Select(ec => ec.EventId).ToArray());
            var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray());

            return(_cdImageStatusModelFactory.Create(eventCustomers, orderShippingStatus, customers, events));
        }
コード例 #17
0
ファイル: GiftCardService.cs プロジェクト: sahvishal/matrix
        public GiftCertificateViewModel GetModel(long eventId, long customerId)
        {
            var eventData     = _eventRepository.GetById(eventId);
            var customer      = _customerRepository.GetCustomer(customerId);
            var eventCustomer = _eventCustomerRepository.Get(eventId, customerId);
            var account       = _corporateAccountRepository.GetbyEventId(eventId);

            var patientGiftCardSignatureUrl    = string.Empty;
            var technicianGiftCardSignatureUrl = string.Empty;
            var giftCardSignatureMediaLocation = _mediaRepository.GetGiftCardSignatureLocation(eventId, customerId);
            var giftCertificateSignature       = _eventCustomerGiftCardRepository.GetByEventCustomerId(eventCustomer.Id);

            if (giftCertificateSignature != null && (giftCertificateSignature.PatientSignatureFileId.HasValue || giftCertificateSignature.TechnicianSignatureFileId.HasValue))
            {
                var signatureFileIds = new List <long>();
                if (giftCertificateSignature.PatientSignatureFileId.HasValue)
                {
                    signatureFileIds.Add(giftCertificateSignature.PatientSignatureFileId.Value);
                }
                if (giftCertificateSignature.TechnicianSignatureFileId.HasValue)
                {
                    signatureFileIds.Add(giftCertificateSignature.TechnicianSignatureFileId.Value);
                }

                var signatureFiles = _fileRepository.GetByIds(signatureFileIds);
                if (giftCertificateSignature.PatientSignatureFileId.HasValue)
                {
                    var patientFile = signatureFiles.First(x => x.Id == giftCertificateSignature.PatientSignatureFileId.Value);
                    patientGiftCardSignatureUrl = giftCardSignatureMediaLocation.Url + patientFile.Path;
                }
                if (giftCertificateSignature.TechnicianSignatureFileId.HasValue)
                {
                    var technicianFile = signatureFiles.First(x => x.Id == giftCertificateSignature.TechnicianSignatureFileId.Value);
                    technicianGiftCardSignatureUrl = giftCardSignatureMediaLocation.Url + technicianFile.Path;
                }
            }

            return(new GiftCertificateViewModel
            {
                CustomerId = customer.CustomerId,
                CustomerName = customer.Name,
                EventDate = eventData.EventDate,
                GiftAmmount = account.GiftCardAmount ?? 0,
                GiftCardReceived = giftCertificateSignature != null ? giftCertificateSignature.GiftCardReceived : (bool?)null,
                PatientSignatureUrl = patientGiftCardSignatureUrl,
                TechnicianSignatureUrl = technicianGiftCardSignatureUrl
            });
        }
コード例 #18
0
        public ListModelBase <ExportableReportsQueueViewModel, ExportableReportsQueueFilter> GetExportableReportQueue(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var exportableReports = _exportableReportsQueueRepository.GetExportableReportsQueue(pageNumber, pageSize, filter as ExportableReportsQueueFilter, out totalRecords);

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

            var fileIds = exportableReports.Where(x => x.FileId.HasValue).Select(x => x.FileId.Value).ToArray();

            var mediaLocation = _mediaRepository.GetExportToCsvMediaFileLocation();
            var files         = _fileRepository.GetByIds(fileIds);

            return(_exportableReportsQueueFactory.Create(exportableReports, mediaLocation, files));
        }
コード例 #19
0
        public void PollForAppointmentBookExport()
        {
            try
            {
                var corporateAccounts = _corporateAccountRepository.GetByIds(new[] { _settings.WellmedAccountId, _settings.WellmedTxAccountId });

                if (corporateAccounts.IsNullOrEmpty())
                {
                    _logger.Info("Account can't be null");
                    return;
                }

                foreach (var account in corporateAccounts)
                {
                    _logger.Info(string.Format("Generating AppointmentBooked for accountId {0} and account tag {1}. ", account.Id, account.Tag));

                    var fileName = "";

                    var fromDate = DateTime.Today.GetFirstDateOfYear();
                    var toDate   = DateTime.Today.GetLastDateOfYear();

                    var folderName = account.Id == _settings.WellmedAccountId ? _settings.WellmedFlFolder : _settings.WellmedTxFolder;

                    var destinationPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "Appointments");

                    fileName = string.Format("AppointmentsBooked_{0}_{1}_{2}.csv", account.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy"));

                    DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationPath);

                    var sourcePath = Path.Combine(destinationPath, fileName);

                    AppointmentsBooked(new AppointmentsBookedListModelFilter {
                        EventFrom = fromDate, EventTo = toDate.Date, AccountId = account.Id, Tag = account.Tag
                    }, sourcePath);

                    if (DirectoryOperationsHelper.IsFileExist(sourcePath))
                    {
                        _pgpFileEncryptionHelper.EncryptFile(account, sourcePath);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Main App: \n Error {0} \n Trace: {1} \n\n\n", ex.Message, ex.StackTrace));
            }
        }
コード例 #20
0
        public HealthAssessmentHeaderEditModel GetModel(long eventId, long customerId)
        {
            var eventData     = _eventRepository.GetById(eventId);
            var customer      = _customerRepository.GetCustomer(customerId);
            var eventCustomer = _eventCustomerRepository.Get(eventId, customerId);
            var pcp           = _primaryCarePhysicianRepository.Get(customerId);
            var physicianName = string.Empty;

            if (pcp != null && pcp.Name != null)
            {
                physicianName = pcp.Name.FullName;
            }

            var participationConsent = new ParticipationConsentModel();
            var participationConsentMediaLocation = _mediaRepository.GetParticipationConsentSignatureLocation(eventId, customerId);
            var participationConsentSignature     = _participationConsentSignatureRepository.GetByEventCustomerId(eventCustomer.Id);

            if (participationConsentSignature != null)
            {
                var signatureFileIds = new[] { participationConsentSignature.SignatureFileId, participationConsentSignature.InsuranceSignatureFileId };
                var signatureFiles   = _fileRepository.GetByIds(signatureFileIds);

                var participationSignatreFile = signatureFiles.First(x => x.Id == participationConsentSignature.SignatureFileId);
                participationConsent.SignatureImageUrl = participationConsentMediaLocation.Url + participationSignatreFile.Path;
                participationConsent.ConsentSignedDate = participationConsentSignature.ConsentSignedDate.ToString("MM/dd/yyyy");

                var insuranceSignatureFile = signatureFiles.First(x => x.Id == participationConsentSignature.InsuranceSignatureFileId);
                participationConsent.InsuranceSignatureImageUrl = participationConsentMediaLocation.Url + insuranceSignatureFile.Path;
                participationConsent.InsuranceConsentSignedDate = participationConsentSignature.InsuranceConsentSignedDate.ToString("MM/dd/yyyy");
            }

            return(new HealthAssessmentHeaderEditModel
            {
                CustomerId = customer.CustomerId,
                CustomerName = customer.Name,
                DateofBirth = customer.DateOfBirth,
                EventDate = eventData.EventDate,
                EventId = eventData.Id,
                PhysicianName = physicianName,
                ParticipationConsent = participationConsent
            });
        }
コード例 #21
0
        public void PollForPdfDownload()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    _logger.Info("Account Ids Can not be empty: ");
                    return;
                }

                var accounts = _corporateAccountRepository.GetByIds(_accountIds);

                if (accounts.IsNullOrEmpty())
                {
                    _logger.Info("No valid account Found");
                    return;
                }

                var destinationFolderPdf = _settings.AnthemDownloadPath;
                destinationFolderPdf = Path.Combine(destinationFolderPdf, "pdf");

                DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationFolderPdf);

                foreach (var corporateAccount in accounts)
                {
                    PostResultAccountWise(corporateAccount, destinationFolderPdf);
                }

                CreateEobFile(_anthemPdfCrossWalkVeiwModel, destinationFolderPdf);
                CreateCrossWalkFile(destinationFolderPdf, _anthemPdfCrossWalkVeiwModel);

                _resultPdfPostedXml          = null;
                _anthemPdfCrossWalkVeiwModel = null;
                _resultPdfNotPosted          = null;
                _customSettings = null;
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace));
            }
        }
コード例 #22
0
        public ListModelBase <EventArchiveStatsViewModel, EventArchiveStatsFilter> GetEventArchiveStats(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new EventArchiveStatsFilter();
            var resultArchives = _resultArchiveUploadRepository.GetForEventArchiveStatsReport(filter as EventArchiveStatsFilter, pageNumber, pageSize, out totalRecords);

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

            var fileIds = resultArchives.Where(r => r.FileId.HasValue).Select(r => r.FileId.Value).ToArray();
            var files   = _fileRepository.GetByIds(fileIds);

            var events = _eventRepository.GetEventswithPodbyIds(resultArchives.Select(r => r.EventId).ToArray());

            var orgRoleUserIds  = resultArchives.Select(r => r.UploadedByOrgRoleUserId).ToArray();
            var userIdNamePairs = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds);

            var pods = _podRepository.GetPodsForEvents(events.Select(e => e.Id).ToArray());

            return(_eventArchiveStatsFactory.Create(resultArchives, events, files, pods, userIdNamePairs));
        }
コード例 #23
0
        public CallUploadListModel GetCallUploadDetails(int pageNumber, int pageSize, CallUploadListModelFilter filter, out int totalRecords)
        {
            var callUploads = _callUploadRepository.GetByFilter(pageNumber, pageSize, filter, out totalRecords);

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

            var successfileIds = callUploads.Select(s => s.FileId).ToArray();

            var failedfileIds = callUploads.Where(x => x.LogFileId.HasValue).Select(s => s.LogFileId.Value).ToArray();

            var fileIds = successfileIds.Concat(failedfileIds).ToArray();

            IEnumerable <FileModel> fileModels = null;

            if (fileIds != null && fileIds.Any())
            {
                var files = _fileRepository.GetByIds(fileIds);

                if (files != null && files.Any())
                {
                    fileModels = GetFileModelFromFile(files, _mediaRepository.GetCallUploadMediaFileLocation());
                }
            }

            var callUploadByIds = callUploads.Select(c => c.UploadedBy).ToArray();

            IEnumerable <OrderedPair <long, string> > uploadedbyAgentNameIdPair = null;

            if (callUploadByIds != null && callUploadByIds.Any())
            {
                uploadedbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(callUploadByIds).ToArray();
            }

            return(_callUploadListModelFactory.Create(fileModels, callUploads, uploadedbyAgentNameIdPair));
        }
コード例 #24
0
        public FluVaccinationConsentViewModel GetFluVaccinationConsentViewModel(long eventId, long customerId)
        {
            var eventData = _eventRepository.GetById(eventId);
            var host      = _hostRepository.GetHostForEvent(eventId);
            var customer  = _customerRepository.GetCustomer(customerId);

            var eventCustomer = _eventCustomerRepository.Get(eventId, customerId);
            var answers       = _fluConsentAnswerRepository.GetByEventCustomerId(eventCustomer.Id);
            var questions     = _fluConsentQuestionRepository.GetAllQuestions();

            var signature = _fluConsentSignatureRepository.GetByEventCustomerId(eventCustomer.Id);

            var signatureFileIds = signature != null ? new[] { signature.SignatureFileId } : null;

            if (signature != null && signature.ClinicalProviderSignatureFileId.HasValue)
            {
                signatureFileIds = new[] { signature.SignatureFileId, signature.ClinicalProviderSignatureFileId.Value };
            }

            var signatureFiles = !signatureFileIds.IsNullOrEmpty() ? _fileRepository.GetByIds(signatureFileIds) : null;

            return(GetFluVaccinationConsentViewModel(eventData, customer, host, questions, answers, signature, signatureFiles));
        }
コード例 #25
0
        public void PollForParsingRapsUpload()
        {
            try
            {
                _logger.Info("Entering In Raps Upload File Parser Polling Agent");

                var timeOfDay = DateTime.Now;
                if (_isDevEnvironment || timeOfDay.TimeOfDay > new TimeSpan(4, 0, 0))
                {
                    var rapsUploads = _rapsUploadRepository.GetFilesToParse();
                    if (rapsUploads.IsNullOrEmpty())
                    {
                        _logger.Info("No file found for Parsing");
                        return;
                    }

                    _logger.Info("Number Of File Found For parsing: " + rapsUploads.Count());

                    var uploadedFileIds = rapsUploads.Select(x => x.FileId);
                    var uploadedFiles   = _fileRepository.GetByIds(uploadedFileIds);
                    var location        = _mediaRepository.GetRapsUploadMediaFileLocation();

                    foreach (var rapsUploadDomain in rapsUploads)
                    {
                        try
                        {
                            rapsUploadDomain.ParseStartTime = DateTime.Now;

                            var fileDomain = uploadedFiles.FirstOrDefault(x => x.Id == rapsUploadDomain.FileId);

                            if (fileDomain == null)
                            {
                                UpdateParsingStatus(rapsUploadDomain, (long)RapsUploadStatus.FileNotFound);
                                _logger.Info("Parsing Failed: FileNotFound RapsUploadId: " + rapsUploadDomain.Id);
                                continue;
                            }

                            var file = location.PhysicalPath + fileDomain.Path;
                            _logger.Info("Parsing For File " + file);

                            //if (!System.IO.File.Exists(file))
                            //{
                            //    UpdateParsingStatus(rapsUploadDomain, (long)RapsUploadStatus.FileNotFound);
                            //    _logger.Info("Parsing Failed: FileNotFound  RapsUploadId: " + rapsUploadDomain.Id);
                            //    continue;
                            //}

                            //var fInfo = new FileInfo(file);
                            //if (fInfo.Extension != ".csv")
                            //{
                            //    UpdateParsingStatus(rapsUploadDomain, (long)RapsUploadStatus.InvalidFileFormat);
                            //    _logger.Info("Parsing Failed: InvalidFileFormat RapsUploadId: " + rapsUploadDomain.Id);
                            //    continue;
                            //}

                            UpdateParsingStatus(rapsUploadDomain, (long)RapsUploadStatus.Parsing, false);
                            _csvReader.Delimiter = _csvReader.GetFileDelimiter(file).ToString();
                            var rapsTable = _csvReader.ReadWithTextQualifier(file);
                            var totalRaps = rapsTable.Rows.Count;

                            var totalPages = totalRaps / PageSize + (totalRaps % PageSize != 0 ? 1 : 0);

                            _logger.Info("Total No. Of Pages: " + totalPages + " Total No. of Records " + totalRaps);

                            var pageNumber     = 1;
                            var failedRapsList = new List <RapsUploadLog>();

                            var successfulUploadCount = 0L;

                            while (totalPages >= pageNumber)
                            {
                                var successCount = 0L;
                                var query        = rapsTable.AsEnumerable();
                                _logger.Info("Parsing For Page Number: " + pageNumber);

                                var rows = query.Skip(PageSize * (pageNumber - 1)).Take(PageSize);

                                ParseRapsUploaded(rows, failedRapsList, rapsUploadDomain.Id, out successCount);

                                successfulUploadCount += successCount;
                                pageNumber++;
                            }

                            rapsUploadDomain.SuccessfullUploadCount = successfulUploadCount;
                            rapsUploadDomain.ParseEndTime           = DateTime.Now;
                            rapsUploadDomain.StatusId = (long)RapsUploadStatus.Parsed;
                            UpdateRapsUploadDetail(rapsUploadDomain, failedRapsList, file);
                        }
                        catch (Exception exception)
                        {
                            _logger.Error(string.Format("Error on Message: {0} \n StackTrace: {1}", exception.Message, exception.StackTrace));
                        }
                    }
                    _logger.Info("Raps parsing complete");
                }
                else
                {
                    _logger.Info(string.Format("Raps Upload Parser can not be called as time of day is {0}", timeOfDay.TimeOfDay));
                }
            }
            catch (Exception exception)
            {
                _logger.Error("all Upload Parser Exception: " + exception + "\n Stack Trace:" + exception.StackTrace);
            }
        }
コード例 #26
0
        public void PollForParsingCallUpload()
        {
            try
            {
                _logger.Info("Entering In Call Upload File Parser Polling Agent");

                var timeOfDay = DateTime.Now;
                if (_isDevEnvironment || timeOfDay.TimeOfDay > new TimeSpan(4, 0, 0))
                {
                    var callUploads = _callUploadRepository.GetFilesToParse();
                    if (callUploads.IsNullOrEmpty())
                    {
                        _logger.Info("No file found for Parsing");
                        return;
                    }

                    _logger.Info("No Of File Found For parsing: " + callUploads.Count());

                    var uploadedFileIds = callUploads.Select(x => x.FileId);
                    var uploadedFiles   = _fileRepository.GetByIds(uploadedFileIds);
                    var location        = _mediaRepository.GetCallUploadMediaFileLocation();

                    foreach (var callUploadDomain in callUploads)
                    {
                        try
                        {
                            callUploadDomain.ParseStartTime = DateTime.Now;

                            var fileDomain = uploadedFiles.FirstOrDefault(x => x.Id == callUploadDomain.FileId);

                            if (fileDomain == null)
                            {
                                UpdateParsingStatus(callUploadDomain, (long)CallUploadStatus.FileNotFound);
                                _logger.Info("Parsin Failed: FileNotFound CallUploadId: " + callUploadDomain.Id);
                                continue;
                            }

                            var file = location.PhysicalPath + fileDomain.Path;
                            _logger.Info("Parsing For File " + file);

                            if (!System.IO.File.Exists(file))
                            {
                                UpdateParsingStatus(callUploadDomain, (long)CallUploadStatus.FileNotFound);
                                _logger.Info("Parsin Failed: FileNotFound  CallUploadId: " + callUploadDomain.Id);
                                continue;
                            }

                            var fInfo = new FileInfo(file);
                            if (fInfo.Extension != ".csv")
                            {
                                UpdateParsingStatus(callUploadDomain, (long)CallUploadStatus.InvalidFileFormat);
                                _logger.Info("Parsin Failed: InvalidFileFormat CallUploadId: " + callUploadDomain.Id);
                                continue;
                            }

                            UpdateParsingStatus(callUploadDomain, (long)CallUploadStatus.Parsing, false);

                            var customerTable  = _csvReader.ReadWithTextQualifier(file);
                            var totalCustomers = customerTable.Rows.Count;

                            var totalPages = totalCustomers / PageSize + (totalCustomers % PageSize != 0 ? 1 : 0);

                            _logger.Info("Total No Of Pages: " + totalPages + " Total No of Records " + totalCustomers);

                            var pageNumber          = 1;
                            var failedCustomerList  = new List <CallUploadLog>();
                            var successCustomerList = new List <CallUploadLog>();

                            while (totalPages >= pageNumber)
                            {
                                var query = customerTable.AsEnumerable();
                                _logger.Info("Parsing For Page Number: " + pageNumber);

                                var rows = query.Skip(PageSize * (pageNumber - 1)).Take(PageSize);

                                ParseCallUploadedCalls(rows, failedCustomerList, successCustomerList, callUploadDomain.Id);

                                pageNumber++;
                            }

                            callUploadDomain.SuccessfullUploadCount = successCustomerList.Count();
                            callUploadDomain.ParseEndTime           = DateTime.Now;
                            callUploadDomain.StatusId = (long)CallUploadStatus.Parsed;
                            UpdateCallUploadDetail(callUploadDomain, failedCustomerList, file);
                        }
                        catch (Exception exception)
                        {
                            _logger.Error(string.Format("Error on Message: {0} \n StackTrace: {1}", exception.Message, exception.StackTrace));
                        }
                    }
                }
                else
                {
                    _logger.Info(string.Format("Call Upload Parser can not be called as time of day is {0}", timeOfDay.TimeOfDay));
                }
            }
            catch (Exception exception)
            {
                _logger.Error("all Upload Parser Exception: " + exception + "\n Stack Trace:" + exception.StackTrace);
            }
        }
コード例 #27
0
        public void PollForParsingEligibilityUpload()
        {
            try
            {
                var timeOfDay = DateTime.Now;
                if (_isDevEnvironment || timeOfDay.TimeOfDay > new TimeSpan(3, 0, 0))
                {
                    _logger.Info("Entering EligibilityUpload parse polling agent @:" + timeOfDay);

                    var eligibilityFilesForParsing = (IReadOnlyCollection <EligibilityUpload>)_eligibilityUploadRepository.GetFilesToParse();

                    if (eligibilityFilesForParsing.IsNullOrEmpty())
                    {
                        _logger.Info("No file found for parsing , exiting");
                        return;
                    }

                    _logger.Info("No. of files to Parse:" + eligibilityFilesForParsing.Count());

                    var parseFileIds      = eligibilityFilesForParsing.Select(x => x.FileId);
                    var uploadedFiles     = (IReadOnlyCollection <File>)_fileRepository.GetByIds(parseFileIds);
                    var filesLocation     = _mediaRepository.GetEligibilityUploadMediaFileLocation();
                    var corporateAccounts = (IReadOnlyCollection <CorporateAccount>)_corporateAccountRepository.GetByIds(eligibilityFilesForParsing.Select(x => x.AccountId).Distinct());

                    foreach (var eligibilityUploadDomain in eligibilityFilesForParsing)
                    {
                        var failedRecords = new List <EligibilityUploadLogViewModel>();
                        try
                        {
                            eligibilityUploadDomain.ParseStartTime = DateTime.Now;
                            var fileDomain = uploadedFiles.FirstOrDefault(x => x.Id == eligibilityUploadDomain.FileId);
                            if (fileDomain == null)
                            {
                                UpdateParsingStatus(eligibilityUploadDomain, (long)EligibilityUploadStatus.FileNotFound);
                                _logger.Info("Parsing Failed: FileNotFound EligibilityUpload Id: " + eligibilityUploadDomain.Id);
                                continue;
                            }

                            var corporateAccount = corporateAccounts.FirstOrDefault(x => x.Id == eligibilityUploadDomain.AccountId);
                            if (corporateAccount == null)
                            {
                                UpdateParsingStatus(eligibilityUploadDomain, (long)EligibilityUploadStatus.ParseFailed);
                                _logger.Info("Parsing Failed: Corporate Account not found File name: " + fileDomain.Path + " AccountId: " + eligibilityUploadDomain.AccountId);
                                continue;
                            }

                            var filePhysicalLocation = filesLocation.PhysicalPath + fileDomain.Path;
                            _logger.Info("Parsing for File: " + filePhysicalLocation);

                            if (!System.IO.File.Exists(filePhysicalLocation))
                            {
                                UpdateParsingStatus(eligibilityUploadDomain, (long)EligibilityUploadStatus.FileNotFound);
                                _logger.Info("Parsing Failed: FileNotFound on Physical Storage File name: " + fileDomain.Path);
                                continue;
                            }

                            var fInfo = new FileInfo(filePhysicalLocation);
                            if (fInfo.Extension != ".csv")
                            {
                                UpdateParsingStatus(eligibilityUploadDomain, (long)EligibilityUploadStatus.InvalidFileFormat);
                                _logger.Info("Parsing Failed: InvalidFileFormat File name: " + fileDomain.Path);
                                continue;
                            }

                            _logger.Error("Beginning to Parse File : File name: " + fileDomain.Path);
                            UpdateParsingStatus(eligibilityUploadDomain, (long)EligibilityUploadStatus.Parsing, false);
                            var customerEligibleUploadTable = _csvReader.ReadWithTextQualifier(filePhysicalLocation);
                            var recordsInFile = customerEligibleUploadTable.Rows.Count;

                            var totalPages = recordsInFile / PageSize + (recordsInFile % PageSize != 0 ? 1 : 0);
                            _logger.Info("Total no. of Pages to process: " + totalPages + " ,total records to parse: " + recordsInFile);
                            var pageNumber = 1;

                            while (pageNumber <= totalPages)
                            {
                                try
                                {
                                    IEnumerable <CustomerEligibilityViewModel> tempParsedRecords = null;
                                    var query = customerEligibleUploadTable.AsEnumerable();
                                    _logger.Info("Parsing For Page Number: " + pageNumber);
                                    var rows = query.Skip(PageSize * (pageNumber - 1)).Take(PageSize);
                                    pageNumber++;

                                    //failedRecords is updated for invalid CustomerId and Year while parsed
                                    tempParsedRecords = ParseEligibilityDataTable(rows, failedRecords);

                                    if (tempParsedRecords.IsNullOrEmpty())
                                    {
                                        continue;
                                    }

                                    UpdateEligibilityStatus(tempParsedRecords, failedRecords, corporateAccount, fileDomain.UploadedBy.Id);
                                }
                                catch (Exception ex)
                                {
                                    _logger.Info(string.Format("Parsing failed for Page: {0} File name: {1}", pageNumber, fileDomain.Path));
                                    _logger.Error("ExceptionMessage: " + ex.Message + "\n\tStackTrace: " + ex.StackTrace);
                                    continue;
                                }
                            }
                            eligibilityUploadDomain.SuccessfullUploadCount = recordsInFile - failedRecords.Count();
                            eligibilityUploadDomain.ParseEndTime           = DateTime.Now;
                            eligibilityUploadDomain.StatusId = (long)EligibilityUploadStatus.Parsed;

                            UpdateEligibilityUploadDetail(eligibilityUploadDomain, failedRecords, filePhysicalLocation);
                            _logger.Error("Parse Succeeded : File name: " + fileDomain.Path);
                        }
                        catch (Exception ex)
                        {
                            var fileDomain = uploadedFiles.FirstOrDefault(x => x.Id == eligibilityUploadDomain.FileId);

                            if (fileDomain != null)
                            {
                                _logger.Error("Failed to parse File , File name: " + fileDomain.Path);
                                var filePhysicalLocation = filesLocation.PhysicalPath + fileDomain.Path;
                                eligibilityUploadDomain.StatusId = (long)EligibilityUploadStatus.ParseFailed;
                                UpdateEligibilityUploadDetail(eligibilityUploadDomain, failedRecords, filePhysicalLocation);
                            }
                            else
                            {
                                _logger.Error("Record does not exist in file table");
                            }

                            _logger.Error("ExceptionMessage: " + ex.Message + "\n\tStackTrace: " + ex.StackTrace);
                            continue;
                        }
                    }
                }
                else
                {
                    _logger.Info(string.Format("Eligibility Upload Parser can not be invoked as time of day is {0}", timeOfDay.TimeOfDay));
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Exception occurred during execution of polling agent\nException Message: {0}\n\tStackTrace:{1}", ex.Message, ex.StackTrace));
                return;
            }
        }
コード例 #28
0
        public void PollForMergeCustomerUpload()
        {
            try
            {
                _logger.Info("Entering In Merge Customer Polling Agent");
                var timeOfDay = DateTime.Now;
                if (_isDevEnvironment || (timeOfDay.TimeOfDay > new TimeSpan(22, 0, 0) || timeOfDay.TimeOfDay < new TimeSpan(0, 30, 0)) || (timeOfDay.TimeOfDay > new TimeSpan(2, 0, 0) && timeOfDay.TimeOfDay < new TimeSpan(3, 30, 0)))
                {
                    var uploads = _mergeCustomerUploadRepository.GetMergeCustomerUploadsForMerging();
                    if (uploads.IsNullOrEmpty())
                    {
                        _logger.Info("No file found for Merging");
                        return;
                    }

                    _logger.Info("No Of File Found For merging: " + uploads.Count());

                    var uploadedFileIds = uploads.Select(x => x.FileId);
                    var uploadedFiles   = _fileRepository.GetByIds(uploadedFileIds);
                    var location        = _mediaRepository.GetMergeCustomerUploadMediaFileLocation();

                    foreach (var mergeCustomerUpload in uploads)
                    {
                        try
                        {
                            timeOfDay = DateTime.Now;
                            if (_isDevEnvironment || (timeOfDay.TimeOfDay > new TimeSpan(22, 0, 0) || timeOfDay.TimeOfDay < new TimeSpan(0, 30, 0)) || (timeOfDay.TimeOfDay > new TimeSpan(2, 0, 0) && timeOfDay.TimeOfDay < new TimeSpan(3, 30, 0)))
                            {
                                var currentStatus = mergeCustomerUpload.StatusId;

                                var fileDomain = uploadedFiles.FirstOrDefault(x => x.Id == mergeCustomerUpload.FileId);

                                if (fileDomain == null)
                                {
                                    UpdateParsingStatus(mergeCustomerUpload, MergeCustomerUploadStatus.FileNotFound);
                                    _logger.Info("Parsin Failed: FileNotFound UploadId: " + mergeCustomerUpload.Id);
                                    continue;
                                }

                                var file = location.PhysicalPath + fileDomain.Path;
                                _logger.Info("Parsing For File " + file);

                                if (!System.IO.File.Exists(file))
                                {
                                    UpdateParsingStatus(mergeCustomerUpload, MergeCustomerUploadStatus.FileNotFound);
                                    _logger.Info("Parsin Failed: FileNotFound  UploadId: " + mergeCustomerUpload.Id);
                                    continue;
                                }

                                var fInfo = new FileInfo(file);
                                if (fInfo.Extension != ".csv")
                                {
                                    UpdateParsingStatus(mergeCustomerUpload, MergeCustomerUploadStatus.InvalidFileFormat);
                                    _logger.Info("Parsin Failed: InvalidFileFormat CallUploadId: " + mergeCustomerUpload.Id);
                                    continue;
                                }

                                UpdateParsingStatus(mergeCustomerUpload, MergeCustomerUploadStatus.Parsing);

                                if (currentStatus == (long)MergeCustomerUploadStatus.Uploaded)
                                {
                                    var customerTable  = _csvReader.ReadWithTextQualifier(file);
                                    var totalCustomers = customerTable.Rows.Count;
                                    var query          = customerTable.AsEnumerable();

                                    foreach (var dataRow in query)
                                    {
                                        var uploadLog = _mergeCustomerUploadHelper.GetUploadLog(dataRow, mergeCustomerUpload.Id);
                                        _mergeCustomerUploadLogRepository.Save(uploadLog);
                                    }
                                }

                                var uploadLogs = _mergeCustomerUploadLogRepository.GetUploadLogsForMerge(mergeCustomerUpload.Id);
                                var isNotSuitableForMerging = false;

                                foreach (var mergeCustomerUploadLog in uploadLogs)
                                {
                                    timeOfDay = DateTime.Now;
                                    if (_isDevEnvironment || (timeOfDay.TimeOfDay > new TimeSpan(22, 0, 0) || timeOfDay.TimeOfDay < new TimeSpan(0, 30, 0)) || (timeOfDay.TimeOfDay > new TimeSpan(2, 0, 0) && timeOfDay.TimeOfDay < new TimeSpan(3, 30, 0)))
                                    {
                                        var uploadLog = _mergeCustomerUploadService.ParseMergeCustomerLog(mergeCustomerUploadLog, mergeCustomerUpload.UploadedBy);
                                        _mergeCustomerUploadLogRepository.Save(uploadLog);
                                    }
                                    else
                                    {
                                        isNotSuitableForMerging = true;
                                        break;
                                    }
                                }

                                if (isNotSuitableForMerging)
                                {
                                    break;
                                }

                                var successCount    = _mergeCustomerUploadLogRepository.GetSuccessfulCustomersCount(mergeCustomerUpload.Id);
                                var failedCustomers = _mergeCustomerUploadLogRepository.GetFailedCustomers(mergeCustomerUpload.Id);

                                if (failedCustomers.Any())
                                {
                                    var failedCustomerCount = failedCustomers.Count();
                                    mergeCustomerUpload.FailedUploadCount = failedCustomerCount;

                                    var fileId = GenerateFailedCustomerLogFile(failedCustomers, file);
                                    if (fileId > 0)
                                    {
                                        mergeCustomerUpload.LogFileId = fileId;
                                    }

                                    SendFailNotification(mergeCustomerUpload.Id, mergeCustomerUpload.UploadTime, fileDomain.Path);
                                }

                                mergeCustomerUpload.SuccessUploadCount = successCount;

                                UpdateParsingStatus(mergeCustomerUpload, MergeCustomerUploadStatus.Parsed);
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            UpdateParsingStatus(mergeCustomerUpload, MergeCustomerUploadStatus.ParseFailed);
                            _logger.Error("Customer Merge Exception Message: " + ex.Message + "\n Stack Trace:" + ex.StackTrace);
                        }
                    }
                }
                else
                {
                    _logger.Info(string.Format("Merge Customer Parser can not be called as time of day is {0}", timeOfDay.TimeOfDay));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Customer Merge Exception Message: " + ex.Message + "\n Stack Trace:" + ex.StackTrace);
            }
        }
コード例 #29
0
        public ListModelBase <DailyPatientRecapModel, DailyPatientRecapModelFilter> GetDailyPatientReapModel(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var eventCustomers = _eventCustomerRepository.GetEventsCustomersForDailyPatientRecap(pageNumber, pageSize, filter as DailyPatientRecapModelFilter, out totalRecords);

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

            var eventIds       = eventCustomers.Select(x => x.EventId).Distinct();
            var appointmentids = eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList();

            var events = _eventRepository.GetEventswithPodbyIds(eventIds);

            var pods      = _podRepository.GetPodsForEvents(eventIds);
            var eventPods = _eventPodRepository.GetByEventIds(eventIds);


            var customerIds = eventCustomers.Select(x => x.CustomerId).Distinct().ToArray();
            var customers   = _customerRepository.GetCustomers(customerIds);

            var eventCustomerIds = eventCustomers.Select(x => x.Id).ToArray();

            var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds, true);

            var orderPackageIdNamePair = _eventPackageRepository.GetPackageNamesForOrder(orders.Select(o => o.Id).ToList());
            //var orderTestIdNamePair = _eventTestRepository.GetTestNamesForOrders(orders.Select(o => o.Id).ToList());

            var orderIdEventPackageTestIdPairs             = _eventPackageRepository.GetOrderIdEventPackageTestIdPairsForOrder(orders.Select(o => o.Id).ToArray());
            var orderIdTestIdPairs                         = _eventTestRepository.GetOrderIdTestIdPairsForOrders(orders.Select(o => o.Id).ToArray());
            var testNotPerformedEventCustomerIdTestIdPairs = _testNotPerformedRepository.GetEventCusromerResultIdTestIdPairs(eventCustomerIds);

            var testIds = orderIdEventPackageTestIdPairs.Select(op => op.SecondValue).Distinct().ToList();

            testIds.AddRange(orderIdTestIdPairs.Select(op => op.SecondValue).Distinct().ToArray());
            var tests = _testRepository.GetTestNameValuePair(testIds);


            var shippingDetailIds = orders.SelectMany(o => o.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Select(sdod => sdod.ShippingDetailId))).ToArray();
            var shippingDetails   = _shippingDetailRepository.GetByIds(shippingDetailIds);

            var cdShippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);


            var eventHospitalPartners = _hospitalPartnerRepository.GetEventHospitalPartnersByEventIds(eventIds).ToArray();

            var organizationIds     = eventHospitalPartners.Select(ehp => ehp.HospitalPartnerId).Distinct().ToArray();
            var hospitalFacilityIds = eventCustomers.Where(ec => ec.HospitalFacilityId.HasValue && ec.HospitalFacilityId.Value > 0).Select(ec => ec.HospitalFacilityId.Value).ToArray();

            organizationIds = organizationIds.Concat(hospitalFacilityIds).ToArray();

            var organizations = _organizationRepository.GetOrganizations(organizationIds);
            var eventIdHospitalPartnerNamePairs = (from ehp in eventHospitalPartners
                                                   join org in organizations on ehp.HospitalPartnerId equals org.Id
                                                   select new OrderedPair <long, string>(ehp.EventId, org.Name)).ToArray();

            var eventIdCorporateAccounrNamePairs = _corporateAccountRepository.GetEventIdCorporateAccountNamePair(eventIds);

            var appointments = _appointmentRepository.GetByIds(appointmentids);

            return(_dailyPatientRecapListModelFactory.CreateListModel(eventCustomers, customers, orders, shippingDetails, cdShippingOption, eventIdHospitalPartnerNamePairs, eventIdCorporateAccounrNamePairs, appointments,
                                                                      pods, eventPods, events, orderIdEventPackageTestIdPairs, orderIdTestIdPairs, testNotPerformedEventCustomerIdTestIdPairs, tests, orderPackageIdNamePair));
        }
コード例 #30
0
        public ListModelBase <HourlyAppointmentBookedModel, HourlyAppointmentsBookedListModelFilter> GetHourlyAppointmentsBooked(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var customFilter = filter as HourlyAppointmentsBookedListModelFilter;

            customFilter = customFilter ?? new HourlyAppointmentsBookedListModelFilter();

            var appFilter = new AppointmentsBookedListModelFilter
            {
                AccountId = customFilter.AccountId,
                FromDate  = customFilter.FromDate,
                ToDate    = customFilter.ToDate,
                ShowCustomersWithAppointment = customFilter.ShowCustomersWithAppointment,
                IsHealthPlanEvent            = true
            };

            var eventCustomers = _eventCustomerRepository.GetEventCustomersbyRegisterationDate(pageNumber, pageSize, appFilter, out totalRecords);

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

            var appointments = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList());
            var eventIds     = eventCustomers.Select(ec => ec.EventId).Distinct().ToArray();
            var model        = _eventReportingService.GetEventVolumeModel(eventCustomers.Select(ec => ec.EventId).Distinct().ToArray());

            var customers             = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var customerIds           = customers.Select(x => x.CustomerId);
            var orders                = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray(), true);
            var customerEligibilities = _customerEligibilityRepository.GetCustomerEligibilityByCustomerIdsAndYear(customerIds, DateTime.Today.Year);

            if (customerEligibilities.IsNullOrEmpty())
            {
                customerEligibilities = new List <CustomerEligibility>();
            }

            var eventPackages = _eventPackageRepository.GetbyEventIds(eventIds);
            var eventTests    = _eventTestRepository.GetByEventIds(eventIds);

            var sourceCodes = _sourceCodeRepository.GetSourceCodeByIds(orders.SelectMany(o => o.OrderDetails.Where(od => od.SourceCodeOrderDetail != null && od.SourceCodeOrderDetail.IsActive)
                                                                                         .Select(od => od.SourceCodeOrderDetail.SourceCodeId)).Distinct().ToArray());

            var orgRoleUserIds = eventCustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList();

            var eventAppointmentChangeLogs = _eventAppointmentChangeLogRepository.GetByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray()).ToArray();

            orgRoleUserIds.AddRange(eventAppointmentChangeLogs.Select(eacl => eacl.CreatedByOrgRoleUserId));

            var registeredbyAgent = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);

            var roles = _roleRepository.GetAll();

            var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray();

            var callDetails = _callCenterCallRepository.GetCallDetails(customers);

            var shippingDetailIds = orders.SelectMany(o => o.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Select(sdod => sdod.ShippingDetailId))).ToArray();
            var shippingDetails   = _shippingDetailRepository.GetByIds(shippingDetailIds);
            var cdShippingOption  = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages);
            var shippingOptions   = _shippingOptionRepository.GetAllShippingOptions();

            var customTags = _customTagRepository.GetByCustomerIds(customerIds);

            var tagNames               = customers.Where(x => !string.IsNullOrEmpty(x.Tag)).Select(x => x.Tag).ToArray();
            var corporateAccount       = _corporateAccountRepository.GetByTags(tagNames);
            var corporateAccountIds    = corporateAccount.Select(x => x.Id).ToArray();
            var accountAdditionalField = _accountAdditionalFieldRepository.GetAccountAdditionalFieldsByAccountIds(corporateAccountIds);

            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var languages             = _languageRepository.GetAll();
            var pcpAppointments       = _pcpAppointmentRepository.GetByEventCustomerIds(eventCustomers.Select(ec => ec.Id).ToArray());

            return(_customAppointmentsBookedModelFactory.CreateHourlyModel(eventCustomers, appointments, orders, model, customers, registeredbyAgent, roles, registeredbyAgentNameIdPair, sourceCodes, callDetails,
                                                                           shippingDetails, cdShippingOption, shippingOptions, eventAppointmentChangeLogs, primaryCarePhysicians, eventPackages, eventTests, languages, customTags, corporateAccount,
                                                                           accountAdditionalField, pcpAppointments, customerEligibilities));
        }