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