Пример #1
0
        public HospitalPartnerDashboardViewModel GetHospitalPartnerDashboardModel(long hospitalPartnerId)
        {
            var hospitalPartner = _hospitalPartnerRepository.GetHospitalPartnerforaVendor(hospitalPartnerId);

            var eventIds = _hospitalPartnerRepository.GetEventIdsForHospitalPartner(hospitalPartnerId);

            if (eventIds.IsNullOrEmpty())
            {
                return(new HospitalPartnerDashboardViewModel());
            }

            var reccentContactedEventId = _hospitalPartnerCustomerRepository.GetMostRecentContactedEvent(hospitalPartnerId);
            var recentMailedEvents      = _shippingDetailRepository.GetRecentMailedHospitalPartnerEvents(hospitalPartnerId).ToList();

            var recentCriticalCustomers =
                _eventCustomerResultRepository.GetRecentCriticalAndUrgentCustomersForHospitalPartner(hospitalPartnerId, 1, 8, hospitalPartner.CriticalResultValidityPeriod);

            var getEventIds = recentMailedEvents.Count() > 0 ? recentMailedEvents.Select(me => me.FirstValue).ToList() : new List <long>();

            if (reccentContactedEventId > 0)
            {
                getEventIds.Add(reccentContactedEventId);
            }

            IEnumerable <Customer> customers = null;
            IEnumerable <Event>    events    = null;
            IEnumerable <Host>     hosts     = null;
            IEnumerable <CustomerResultStatusViewModel> customerResultStatusViewModels = null;

            if (recentCriticalCustomers != null && recentCriticalCustomers.Count() > 0)
            {
                getEventIds.AddRange(recentCriticalCustomers.Select(rcc => rcc.EventId).ToArray());
                customers = _customerRepository.GetCustomers(recentCriticalCustomers.Select(rcc => rcc.CustomerId).ToArray());
                customerResultStatusViewModels = _eventCustomerResultRepository.GetTestResultStatus(recentCriticalCustomers.Select(rcc => rcc.Id).ToArray());
            }

            if (getEventIds.Count > 0)
            {
                events = _eventRepository.GetEventswithPodbyIds(getEventIds.ToArray());
                hosts  = _hostRepository.GetEventHosts(events.Select(e => e.Id).ToArray());
            }
            var totalCustomers    = _eventRepository.GetCustomersWithAppointmentByHospitalPartnerId(hospitalPartnerId);
            var customersAttended = _eventRepository.GetAttendedCustomersByHospitalPartnerId(hospitalPartnerId);

            var normalCustomers   = _eventCustomerResultRepository.GetResultSummaryEventIdCustomersCountForHospitalPartner(hospitalPartnerId, ResultInterpretation.Normal, true, hospitalPartner.NormalResultValidityPeriod);
            var abnormalCustomers = _eventCustomerResultRepository.GetResultSummaryEventIdCustomersCountForHospitalPartner(hospitalPartnerId, ResultInterpretation.Abnormal, true, hospitalPartner.AbnormalResultValidityPeriod);
            var criticalCustomers = _eventCustomerResultRepository.GetCriticalEventIdCustomersCountForHospitalPartner(hospitalPartnerId, ResultInterpretation.Critical, true, hospitalPartner.CriticalResultValidityPeriod);
            var urgentCustomers   = _eventCustomerResultRepository.GetResultSummaryEventIdCustomersCountForHospitalPartner(hospitalPartnerId, ResultInterpretation.Urgent, true, hospitalPartner.CriticalResultValidityPeriod);

            var mailedDate = _shippingDetailRepository.MailedDateForEvent(reccentContactedEventId);

            return(_hospitalPartnerViewModelFactory.Create(eventIds.Count(), totalCustomers, customersAttended,
                                                           criticalCustomers, normalCustomers, abnormalCustomers,
                                                           events, hosts,
                                                           reccentContactedEventId, recentMailedEvents, mailedDate,
                                                           recentCriticalCustomers, customers, customerResultStatusViewModels, urgentCustomers));
        }
Пример #2
0
        public HospitalPartnerCallStatusViewModel GetHospitalPartnerCallStatus(long hospitalPartnerId, int abnormalCustomers, int criticalCustomers, int urgentCustomers)
        {
            using (var t = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadUncommitted
            }))
            {
                var hospitalPartner = _hospitalPartnerRepository.GetHospitalPartnerforaVendor(hospitalPartnerId);

                var eventIds = _hospitalPartnerRepository.GetEventIdsForHospitalPartner(hospitalPartnerId);
                if (eventIds.IsNullOrEmpty())
                {
                    return(null);
                }

                var hospitalPartnerCustomers = new List <HospitalPartnerCustomer>();
                hospitalPartnerCustomers.AddRange(_hospitalPartnerCustomerRepository.GetHospitalPartnerCustomersByHospitalPartnerId(hospitalPartnerId, ResultInterpretation.Abnormal, hospitalPartner.AbnormalResultValidityPeriod));
                hospitalPartnerCustomers.AddRange(_hospitalPartnerCustomerRepository.GetHospitalPartnerCustomersByHospitalPartnerIdForCritical(hospitalPartnerId, ResultInterpretation.Critical, hospitalPartner.CriticalResultValidityPeriod));
                hospitalPartnerCustomers.AddRange(_hospitalPartnerCustomerRepository.GetHospitalPartnerCustomersByHospitalPartnerId(hospitalPartnerId, ResultInterpretation.Urgent, hospitalPartner.CriticalResultValidityPeriod));

                t.Complete();
                return(_hospitalPartnerViewModelFactory.CreateCallStatus(abnormalCustomers, criticalCustomers, urgentCustomers, hospitalPartnerCustomers));
            }
        }