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)); }
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)); }
public ListModelBase <GiftCertificateReportWellmedViewModel, GiftCertificateReportFilter> GetGiftCertificateWellmedReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords) { var eventCustomers = _eventCustomerRepository.GetForGiftCertificateReport(pageNumber, pageSize, filter as GiftCertificateReportFilter, out totalRecords); if (!eventCustomers.Any()) { return(null); } var customerIds = eventCustomers.Select(x => x.CustomerId).ToArray(); var customers = _customerRepository.GetCustomers(customerIds); var model = _eventReportingService.GetEventVolumeModel(eventCustomers.Select(ec => ec.EventId).ToArray()); var eventCustomerIds = eventCustomers.Select(ec => ec.Id).ToArray(); var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds); var orderIds = orders.Select(o => o.Id).ToArray(); var orderPackageIdNamePair = _eventPackageRepository.GetPackageNamesForOrder(orderIds); var orderTestIdNamePair = _eventTestRepository.GetTestNamesForOrders(orderIds); return(_giftCertificateReportWellmedFactory.Create(customers, eventCustomers, model, orders, orderPackageIdNamePair, orderTestIdNamePair)); }
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)); }
private HospitalPartnerCustomerListModel GetCustomers(IEnumerable <EventCustomer> eventCustomers, HospitalPartner hospitalPartner) { var eventCustomerIds = eventCustomers.Select(ec => ec.Id).ToArray(); var eventIds = eventCustomers.Select(ec => ec.EventId).Distinct().ToArray(); var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).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 hospitalPartnerCustomers = _hospitalPartnerCustomerRepository.GetHospitalPartnerCustomers(eventIds); var orgRoleUserIds = new List <long>(); orgRoleUserIds.AddRange(hospitalPartnerCustomers.Select(hpc => hpc.CareCoordinatorOrgRoleUserId).ToArray()); orgRoleUserIds.AddRange(hospitalPartnerCustomers.Select(hpc => hpc.DataRecorderMetaData.DataRecorderCreator.Id).ToArray()); orgRoleUserIds.AddRange(hospitalPartnerCustomers.Where(hpc => hpc.DataRecorderMetaData.DataRecorderModifier != null).Select(hpc => hpc.DataRecorderMetaData.DataRecorderModifier.Id).ToArray()); orgRoleUserIds = orgRoleUserIds.Select(oru => oru).Distinct().ToList(); var idNamePairs = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()); var eventCustomerResults = _eventCustomerResultRepository.GetByIds(eventCustomerIds); eventCustomerResults = eventCustomerResults.Where(ecr => ecr.ResultState >= (long)TestResultStateNumber.Evaluated).ToArray(); var pods = _podRepository.GetPodsForEvents(eventIds); var events = _eventRepository.GetEventswithPodbyIds(eventIds); var shippingDetailIds = orders.SelectMany(o => o.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Select(sdod => sdod.ShippingDetailId))).ToArray(); var resultStatuses = _eventCustomerResultRepository.GetTestResultStatus(eventCustomerIds); var shippingDetails = _shippingDetailRepository.GetByIds(shippingDetailIds); var cdShippingOption = _shippingOptionRepository.GetShippingOptionByProductId((long)Product.UltraSoundImages); //var eventIdHospitalPartnerIdPairs = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds); 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 primaryCarePhysicians = _primaryCarePhysicianRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).ToArray()); var healthAssessmentQuestions = _healthAssessmentRepository.GetAllQuestions(); var healthAssessmentAnswers = _healthAssessmentRepository.GetByCustomerIds(eventCustomers.Select(ec => ec.CustomerId).ToArray()); var notes = _customerCallNotesRepository.GetNotes(eventCustomers.Select(ec => ec.CustomerId).ToArray(), CustomerRegistrationNotesType.PostScreeningFollowUpNotes); var eventCustomerNotifications = _eventCustomerNotificationRepository.GetByEventCustomerIds(eventCustomerIds, NotificationTypeAlias.CannedMessageNotification); var hospitalFacilities = hospitalFacilityIds.Any() ? _hospitalFacilityRepository.GetByIds(hospitalFacilityIds) : null; var eventCustomerIdHospitalFacilityNamePairs = (from ec in eventCustomers join org in organizations on ec.HospitalFacilityId equals org.Id select new OrderedPair <long, string>(ec.Id, org.Name)).ToArray(); var showScannedDocumentHospitalPartnerIds = _settings.ShowScannedDocumentHospitalPartnerIds; var languages = _languageRepository.GetAll(); return(_hospitalPartnerCustomerViewModelFactory.Create(eventCustomers, orders, customers, orderPackageIdNamePair, orderTestIdNamePair, hospitalPartnerCustomers, idNamePairs, events, shippingDetails, resultStatuses, cdShippingOption, pods, eventIdHospitalPartnerNamePairs, eventIdCorporateAccounrNamePairs, primaryCarePhysicians, healthAssessmentQuestions, healthAssessmentAnswers, eventCustomerResults, hospitalPartner, notes, eventCustomerNotifications, eventHospitalPartners, eventCustomerIdHospitalFacilityNamePairs, hospitalFacilities, showScannedDocumentHospitalPartnerIds, languages)); }