Пример #1
0
        //Should this method be part of IEventReportingService.
        private EventVolumeListModel GetEventVolumeModel(IEnumerable <Event> events)
        {
            if (events.IsNullOrEmpty())
            {
                return(null);
            }
            var eventIds = events.Select(e => e.Id).ToList();
            var hosts    = _hostRepository.GetEventHosts(eventIds);

            var eventAppointmentStatsModels = _eventAppointmentStatsService.Get(events);

            var pods = _podRepository.GetPodsForEvents(eventIds);

            var primaryPhysicians  = _physicianEventAssignmentRepository.GetPrimaryPhysicianForEvents(eventIds);
            var overReadPhysicians = _physicianEventAssignmentRepository.GetOverReadPhysicianForEvents(eventIds);

            var eventIdHospitalPartnerIdPairs = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds);
            //var eventIdCorporateAccountPairs = _corporateAccountRepository.GetEventIdCorporateAccountPairForSponsoredBy(eventIds);

            var organizationIds = new List <long>();

            organizationIds.AddRange(eventIdHospitalPartnerIdPairs.Select(ehp => ehp.SecondValue).Distinct().ToArray());
            //organizationIds.AddRange(eventIdCorporateAccountPairs.Select(ehp => ehp.SecondValue).Distinct().ToArray());

            var organizations = _organizationRepository.GetOrganizations(organizationIds.ToArray());

            var eventIdHospitalPartnerNamePairs = (from ehp in eventIdHospitalPartnerIdPairs
                                                   join org in organizations on ehp.SecondValue equals org.Id
                                                   select new OrderedPair <long, string>(ehp.FirstValue, org.Name)).ToArray();

            var eventIdCorporateNamePairs = _corporateAccountRepository.GetEventIdCorporateAccountNamePair(eventIds);

            var customersAttended = _eventRepository.GetAttendedCustomers(eventIds);

            var eventStaffCollection = _eventStaffAssignmentRepository.GetForEvents(eventIds);

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

            if (eventStaffCollection != null && eventStaffCollection.Any())
            {
                var orgRoleUserIds = eventStaffCollection.Select(esc => (esc.ActualStaffOrgRoleUserId != null ? esc.ActualStaffOrgRoleUserId.Value : esc.ScheduledStaffOrgRoleUserId)).ToArray();
                staffIdNamePairs = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds);
            }

            return(_eventVolumeFactory.Create(events, hosts, pods, eventAppointmentStatsModels, primaryPhysicians, overReadPhysicians, eventIdHospitalPartnerNamePairs, customersAttended,
                                              eventIdCorporateNamePairs, eventStaffCollection, staffIdNamePairs));
        }
Пример #2
0
        private IEnumerable <OrderedPair <long, string> > GetEventIdSponsorPair(EventStaffAssignmentListModel data)
        {
            var eventIdSponsorPair = new List <OrderedPair <long, string> >();

            var eventIds = data.StaffEventAssignments.Select(x => x.Event.Id).Distinct();
            var events   = _eventRepository.GetEventsByIds(eventIds);

            var eventHpPairs    = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds);
            var organizationIds = new List <long>();

            if (eventHpPairs != null && eventHpPairs.Any())
            {
                organizationIds.AddRange(eventHpPairs.Select(o => o.SecondValue).ToArray());
            }

            organizationIds.AddRange(events.Where(e => e.AccountId.HasValue && e.AccountId.Value > 0).Select(e => e.AccountId.Value).ToArray());

            var organizations = _organizationRepository.GetOrganizations(organizationIds.Distinct().ToArray());
            var sponsor       = string.Empty;

            foreach (var theEvent in events)
            {
                if (eventHpPairs != null && eventHpPairs.Any())
                {
                    var hospitalPartnerId =
                        eventHpPairs.Where(o => o.FirstValue == theEvent.Id).Select(o => o.SecondValue).FirstOrDefault();
                    if (hospitalPartnerId > 0)
                    {
                        sponsor = organizations.Where(o => o.Id == hospitalPartnerId).Select(o => o.Name).First();
                    }
                }

                if (string.IsNullOrEmpty(sponsor))
                {
                    if (theEvent.AccountId.HasValue && theEvent.AccountId.Value > 0)
                    {
                        sponsor = organizations.Where(o => o.Id == theEvent.AccountId.Value).Select(o => o.Name).First();
                    }
                }
                eventIdSponsorPair.Add(new OrderedPair <long, string>(theEvent.Id, sponsor));
            }
            return(eventIdSponsorPair);
        }
Пример #3
0
        public EventBasicInfoListModel EventBasicInfoListForCallQueue(IEnumerable <Event> events)
        {
            var eventIds = events.Select(e => e.Id).ToArray();
            var hosts    = _hostRepository.GetEventHosts(eventIds);
            var pods     = _podRepository.GetPodsForEvents(eventIds);

            var eventAppointmentStatsModels = _eventAppointmentStatsService.Get(eventIds);

            var eventHpPairs = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds);


            var organizationIds = new List <long>();

            if (eventHpPairs != null && eventHpPairs.Any())
            {
                organizationIds.AddRange(eventHpPairs.Select(o => o.SecondValue).ToArray());
            }

            organizationIds.AddRange(
                events.Where(e => e.AccountId.HasValue && e.AccountId.Value > 0).Select(e => e.AccountId.Value).ToArray());

            var organizations = _organizationRepository.GetOrganizations(organizationIds.Distinct().ToArray());

            var eventModels = new List <EventBasicInfoViewModel>();

            foreach (var theEvent in events) // Should go inside a mapper
            {
                var eventModel = EventBasicInfoViewModel(hosts, theEvent, pods, eventAppointmentStatsModels, eventHpPairs, organizations);

                eventModels.Add(eventModel);
            }
            return(new EventBasicInfoListModel()
            {
                Events = eventModels
            });
        }
Пример #4
0
        public IEnumerable <OnlineEventViewModel> GetEvents(OnlineSchedulingEventListModelFilter filter, int maxNumberofRecordstoFetch, int pageSize, out int totalRecords)
        {
            var events = _eventRepository.GetEventsbyFilters(filter, out totalRecords);

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

            var todayEventIds = events.Where(e => e.EventDate < DateTime.Now.Date.AddDays(1)).Select(e => e.Id);
            var todaySlots    = _eventSchedulingSlotRepository.GetbyEventIds(todayEventIds);

            var eventIds = events.Select(e => e.Id).Distinct().ToArray();
            var hosts    = _hostRepository.GetEventHosts(eventIds);

            var eventAppointmentStatsModels = _eventAppointmentStatsService.Get(eventIds);

            ZipCode zipCode = null;

            try
            {
                if (!string.IsNullOrEmpty(filter.ZipCode))
                {
                    zipCode = _zipCodeRepository.GetZipCode(filter.ZipCode).FirstOrDefault();
                }
            }
            catch (ObjectNotFoundInPersistenceException <ZipCode> )
            {
                zipCode = null;
            }

            var eventCollection = _onlineEventListModelFactory.Create(events, hosts, eventAppointmentStatsModels, zipCode, todaySlots, filter.EventId, filter.CutOffHourstoMarkEventforOnlineSelection,
                                                                      filter.OrderBy, filter.OrderType, maxNumberofRecordstoFetch, filter.PageNumber, pageSize, out totalRecords);

            eventIds = eventCollection.Select(e => e.EventId).Distinct().ToArray();

            foreach (var theEvent in eventCollection)
            {
                var eventTest = _eventTestRepository.GetByEventAndTestIds(theEvent.EventId, TestGroup.BreastCancer);
                theEvent.HasBreastCancer = eventTest != null && eventTest.Any();
            }


            var eventHpPairs = _hospitalPartnerRepository.GetEventAndHospitalPartnerOrderedPair(eventIds);
            var eventCorporateAccountPairs = _corporateAccountRepository.GetEventIdCorporateAccountPairForSponsoredBy(eventIds);


            var organizations = eventCorporateAccountPairs == null || eventCorporateAccountPairs.Count() < 1 ? null : _organizationRepository.GetOrganizations(eventCorporateAccountPairs.Select(m => m.SecondValue).Distinct().ToArray());
            var fileIds       = organizations != null?organizations.Where(o => o.LogoImageId > 0).Select(o => o.LogoImageId).ToArray() : null;

            var files = fileIds == null ? null : _fileRepository.GetByIds(fileIds);

            if (files != null)
            {
                var location = _mediaRepository.GetOrganizationLogoImageFolderLocation();
                files = files.Select(f =>
                {
                    f.Path = location.Url + f.Path;
                    return(f);
                }).ToArray();

                eventCollection = _onlineEventListModelFactory.ManageSponsoredByLogo(eventCollection, eventCorporateAccountPairs, organizations, files);
            }

            organizations = eventHpPairs == null || eventHpPairs.Count() < 1 ? null : _organizationRepository.GetOrganizations(eventHpPairs.Select(m => m.SecondValue).Distinct().ToArray());
            fileIds       = organizations != null?organizations.Where(o => o.LogoImageId > 0).Select(o => o.LogoImageId).ToArray() : null;

            files = fileIds == null ? null : _fileRepository.GetByIds(fileIds);
            if (files != null)
            {
                var location = _mediaRepository.GetOrganizationLogoImageFolderLocation();
                files = files.Select(f =>
                {
                    f.Path = location.Url + f.Path;
                    return(f);
                }).ToArray();

                eventCollection = _onlineEventListModelFactory.ManageSponsoredByLogo(eventCollection, eventHpPairs, organizations, files);
            }

            return(eventCollection);
        }