Beispiel #1
0
        public ActionResult HealthPlanEvents(bool showUpcoming = false, EventBasicInfoViewModelFilter filter = null, int pageNumber = 1)
        {
            int totalRecords = 0;

            if (filter == null)
            {
                filter = new EventBasicInfoViewModelFilter();
            }
            filter.AccountId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId;
            if (showUpcoming)
            {
                filter.DateFrom = DateTime.Now.Date;
                filter.DateTo   = null;
            }

            var listModel = _eventService.GetHealthPlanEvents(pageNumber, _pageSize, filter, out totalRecords) ?? new HealthPlanEventListModel();

            listModel.Filter = filter;

            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc =
                pn => Url.Action(currentAction, new { pageNumber = pn, filter.DateFrom, filter.DateTo, filter.City, filter.EventId, filter.Name, filter.Pod, filter.Radius, filter.State, filter.ZipCode, filter.AccountId });

            listModel.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

            return(View(listModel));
        }
        public ActionResult HealthPlanEventReport(EventBasicInfoViewModelFilter filter = null)
        {
            if (filter == null)
            {
                filter = new EventBasicInfoViewModelFilter();
            }
            filter.AccountId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId;

            return(CreateExportQueue(filter, ExportableReportType.EventReport, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId));
        }
Beispiel #3
0
        public void GetUpcomingEventBasicModelwithnameFiltertester()
        {
            int totalRecords = 0;
            var filter       = new EventBasicInfoViewModelFilter()
            {
                Name = "Albert"
            };
            var modelList = _eventService.GetEventBasicInfo(filter, Page_Number, Page_Size, out totalRecords);

            Assert.IsNotNull(modelList);
            Assert.IsNotNull(modelList.Events);
            Assert.IsNotEmpty(modelList.Events.ToArray());
        }
Beispiel #4
0
        public void GetEventBasicInfo_FiltersCorrectlyForSepcificEventsBasedOnPodName()
        {
            int totalRecords = 0;
            var filter       = new EventBasicInfoViewModelFilter()
            {
                Pod = "VB023"
            };
            var modelList = _eventService.GetEventBasicInfo(filter, Page_Number, Page_Size, out totalRecords);

            Assert.IsNotNull(modelList);
            Assert.IsNotNull(modelList.Events);
            Assert.IsNotEmpty(modelList.Events.ToArray());
        }
Beispiel #5
0
        public void GetEventBasicInfo_FiltersCorrectlyForAllConditionsProvided()
        {
            int totalRecords = 0;
            var filter       = new EventBasicInfoViewModelFilter()
            {
                Pod = "VB023", DateFrom = new DateTime(2007, 5, 15), DateTo = new DateTime(2007, 12, 15), Name = "Walgreen", City = "Fort", State = "Florida", ZipCode = "33308", Radius = 25
            };
            var modelList = _eventService.GetEventBasicInfo(filter, Page_Number, Page_Size, out totalRecords);

            Assert.IsNotNull(modelList);
            Assert.IsNotNull(modelList.Events);
            Assert.IsNotEmpty(modelList.Events.ToArray());
        }
Beispiel #6
0
        public ActionResult Index(bool showUpcoming = false, EventBasicInfoViewModelFilter filter = null, int pageNumber = 1)
        {
            if (filter == null)
            {
                filter = new EventBasicInfoViewModelFilter();
            }
            //if (_sessionContext.UserSession.CurrentOrganizationRole.CheckRole((long)Roles.NursePractitioner))
            //{
            //    filter.AccountId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId;
            //}

            if (showUpcoming)
            {
                filter.DateFrom = DateTime.Now.Date;
                filter.DateTo   = null;
            }
            return(View(GetModel(filter, pageNumber)));
        }
Beispiel #7
0
        public EventBasicInfoListModel GetModel(EventBasicInfoViewModelFilter filter, int pageNumber)
        {
            int totalRecords = 0;

            if (_sessionContext.UserSession.CurrentOrganizationRole.CheckRole((long)Roles.CallCenterRep))
            {
                filter.AgentOrganizationId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId;
            }

            var listModel = _eventService.GetEventBasicInfo(filter, pageNumber, _pageSize, out totalRecords) ??
                            new EventBasicInfoListModel();



            listModel.Filter = filter;

            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc =
                pn => Url.Action(currentAction, new { pageNumber = pn, filter.DateFrom, filter.DateTo, filter.City, filter.EventId, filter.Name, filter.Pod, filter.Radius, filter.State, filter.ZipCode, filter.AccountId });

            listModel.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);
            return(listModel);
        }
Beispiel #8
0
        public void CleanUpPastCdContentFolder()
        {
            if (_settings.ResultArchiveWaitDays < 1)
            {
                return;
            }

            const int days = 45;
            var       dateForCleaningUpCdContent = DateTime.Now.Date.AddDays(-1 * days);
            var       filter = new EventBasicInfoViewModelFilter
            {
                DateTo   = dateForCleaningUpCdContent,
                DateFrom = dateForCleaningUpCdContent.AddDays(-1 * days)
            };

            int pageNumber = 1;

            _logger.Info(
                "\n\n ****************************************** Cd Content (Fortnight Loop) ****************************************");

            _logger.Info("\nBatch Started -------------------------------------------------------------------\n");

            while (true)
            {
                int totalRecords = 0;
                var events       = _eventRepository.GetEventsbyFilters(filter, pageNumber++, 100, out totalRecords);

                if (events == null || events.Count() < 1)
                {
                    break;
                }

                foreach (var @event in events)
                {
                    try
                    {
                        var eventCustomerResults = _eventCustomerResultRepository.GetByEventId(@event.Id);
                        if (eventCustomerResults == null || eventCustomerResults.Count() < 1)
                        {
                            continue;
                        }

                        var eventCustomerResultIds = eventCustomerResults.Select(ecr => ecr.Id).ToArray();

                        var cdContentTrackingRecords = _cdContentGeneratorTrackingRepository.GetCdContentGeneratedforEventCustomerIds(eventCustomerResultIds);
                        cdContentTrackingRecords = cdContentTrackingRecords != null?cdContentTrackingRecords.Where(r => r.IsContentGenerated && (!r.ContentGeneratedDate.HasValue || r.ContentGeneratedDate < DateTime.Now.AddDays(-1 * _settings.ResultArchiveWaitDays))) : null;

                        if (cdContentTrackingRecords != null && cdContentTrackingRecords.Count() > 0)
                        {
                            eventCustomerResultIds = cdContentTrackingRecords.Select(cd => cd.EventCustomerResultId).ToArray();
                            eventCustomerResults   = eventCustomerResults.Where(ecr => eventCustomerResultIds.Contains(ecr.Id)).ToArray();

                            CleanUpCdContentForRecords(eventCustomerResults, cdContentTrackingRecords);
                        }

                        var location = _mediaRepository.GetCdContentFolderLocation(@event.Id, false);
                        if (location == null)
                        {
                            continue;
                        }

                        if (Directory.Exists(location.PhysicalPath))
                        {
                            var files = Directory.GetFiles(location.PhysicalPath, "*.zip");
                            if (files.Count() < 1)
                            {
                                Directory.Delete(location.PhysicalPath, true);
                            }
                        }
                        var zipFileName = Path.GetDirectoryName(Path.GetDirectoryName(location.PhysicalPath)) + "\\" + @event.Id + ".zip";
                        if (System.IO.File.Exists(zipFileName))
                        {
                            System.IO.File.Delete(zipFileName);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("\n Failed For Event Id [" + @event.Id + "]. Message: " + ex.Message + ".\n\t Stack Trace:  " + ex.StackTrace);
                    }
                }
            }
        }
        public void PollforAttestationForm()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    _logger.Info("no account id provided");
                    return;
                }

                var accounts = (_corporateAccountRepository).GetByIds(_accountIds);
                _pdfGenerator.PaperSize = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.PaperSize);
                foreach (var account in accounts)
                {
                    try
                    {
                        _logger.Info("Starting fetching attestation Form for tag: " + account.Tag);

                        var filter = new EventBasicInfoViewModelFilter {
                            AccountId = account.Id, DateFrom = DateTime.Today, DateTo = DateTime.Today
                        };
                        var pageNumber = 1;

                        while (true)
                        {
                            int totalRecords;
                            var events = _eventRepository.GetEventsbyFilters(filter, pageNumber, PageSize, out totalRecords);

                            _logger.Info("Total no of records found: " + totalRecords);

                            if (totalRecords < 1)
                            {
                                break;
                            }

                            foreach (var theEventData in events)
                            {
                                try
                                {
                                    _logger.Info("Parsing started for Event ID : " + theEventData.Id);

                                    var eventCustomers = _eventCustomerRepository.GetbyEventId(theEventData.Id);

                                    if (eventCustomers.IsNullOrEmpty())
                                    {
                                        _logger.Info("No event customers found for the event : " + theEventData.Id);
                                        continue;
                                    }

                                    var customers             = _customerRepository.GetCustomersWoithoutLoginAndAddressDetails(eventCustomers.Select(x => x.CustomerId).ToArray());
                                    var unlockedParseLocation = _mediaRepository.GetUnlockEventsParseLocation(theEventData.Id, true);

                                    if (_settings.MonarchAccountIds.Contains(account.Id))
                                    {
                                        customers = customers.Where(x => !string.IsNullOrEmpty(x.AdditionalField4)).ToList();
                                        ParseMonarchAttestationForm(customers, unlockedParseLocation);
                                    }

                                    if (_settings.AppleCareAccountId == account.Id)
                                    {
                                        if (customers.IsNullOrEmpty())
                                        {
                                            continue;
                                        }

                                        ParseAppleCareAttestationForm(customers, unlockedParseLocation, account);
                                    }

                                    if (_settings.NammAccountId == account.Id)
                                    {
                                        if (customers.IsNullOrEmpty())
                                        {
                                            continue;
                                        }

                                        ParseNammAttestationForm(customers, unlockedParseLocation, account, theEventData.Id);
                                    }

                                    _logger.Info("Parsing completed for Event ID : " + theEventData.Id);
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("Message: " + ex.Message);
                                    _logger.Error("Stack Trace: " + ex.StackTrace);
                                }
                            }


                            pageNumber++;
                            if ((pageNumber * PageSize) > totalRecords)
                            {
                                break;
                            }
                        }

                        _logger.Info("Attestation Form for tag: " + account.Tag + " completed");
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Message: " + ex.Message);
                        _logger.Error("Stack Trace: " + ex.StackTrace);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
        }
Beispiel #10
0
        public void PollforSendingScreeningReminders()
        {
            var value = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.ScreeningReminderNotification);

            if (value.ToLower() != bool.TrueString.ToLower())
            {
                return;
            }

            const int pageSize   = 50;
            int       pageNumber = 1;

            _logger.Info("\n");
            _logger.Info(string.Format("Screening Reminder Queuing. Date: {0:MM/dd/yyyy} ", DateTime.Now));
            _logger.Info("\n");

            var filter = new EventBasicInfoViewModelFilter
            {
                DateFrom = DateTime.Now.Date.AddDays(_daysIntervalBeforeEvent),
                DateTo   = DateTime.Now.Date.AddDays(_daysIntervalBeforeEvent)
            };

            while (true)
            {
                int totalRecords;

                var events = _eventRepository.GetEventsbyFilters(filter, pageNumber, pageSize, out totalRecords);

                events = events.Where(e => e.Status == EventStatus.Active || (e.Status == EventStatus.Suspended && e.IsLocked));

                if (events == null || !events.Any())
                {
                    _logger.Info("No Events Found!");
                    break;
                }

                foreach (var theEvent in events)
                {
                    CorporateAccount account = null;
                    if (theEvent.EventType == EventType.Corporate)
                    {
                        var sendNotification = false;

                        if (theEvent.AccountId.HasValue && theEvent.AccountId.Value > 0)
                        {
                            account          = ((IUniqueItemRepository <CorporateAccount>)_corporateAccountRepository).GetById(theEvent.AccountId.Value);
                            sendNotification = account.SendAppointmentMail && account.AppointmentReminderMailTemplateId > 0;
                        }
                        if (!sendNotification)
                        {
                            continue;
                        }
                    }

                    _logger.Info(string.Format("Queuing Event [Id:{0}] [Name:{1}]  [Date:{2:MM/dd/yyyy}] ", theEvent.Id, theEvent.Name, theEvent.EventDate));
                    _logger.Info("\n");

                    var eventCustomers = _eventCustomerRepository.GetbyEventId(theEvent.Id);

                    var customerIds = eventCustomers.Where(ec => ec.AppointmentId.HasValue && !ec.NoShow && !ec.LeftWithoutScreeningReasonId.HasValue).Select(ec => ec.CustomerId).Distinct().ToArray();
                    if (!customerIds.Any())
                    {
                        _logger.Info("No Customers Found!");
                        continue;
                    }

                    var customers = _customerRepository.GetCustomers(customerIds);

                    foreach (var customer in customers)
                    {
                        _logger.Info(string.Format("Queuing Customer [Id:{0}] [Name:{1}]  ", customer.CustomerId, customer.NameAsString));
                        try
                        {
                            var appointmentConfirmationViewModel = _emailNotificationModelsFactory.GetAppointmentConfirmationModel(theEvent.Id, customer.CustomerId);

                            string emailTemplateAlias = EmailTemplateAlias.ScreeningReminderMail;

                            if (account != null && account.AppointmentReminderMailTemplateId > 0)
                            {
                                var emailTemplate = _emailTemplateRepository.GetById(account.AppointmentReminderMailTemplateId);
                                emailTemplateAlias = emailTemplate.Alias;
                            }

                            _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.ScreeningReminderMail, emailTemplateAlias, appointmentConfirmationViewModel, customer.Id, customer.CustomerId, "Automated Reminder Notification", useAlternateEmail: true);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace));
                        }
                    }
                }

                if ((pageNumber * pageSize) >= totalRecords)
                {
                    break;
                }

                pageNumber++;
            }
        }
        public void PollForPatientInputFiles()
        {
            _logger.Info("Started Patient Input File");
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    return;
                }
                var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds);

                foreach (var account in corporateAccounts)
                {
                    try
                    {
                        var eventDate       = DateTime.Today.AddDays(-1);
                        var destinationPath = string.Format(_patientInputFileDestinationPath, account.FolderName, eventDate.Year);

                        _logger.Info(string.Format("Started Patient Input File For Account Id: {0} Tag: {1} for event Date: {2}", account.Id, account.Tag, eventDate));

                        var filter = new EventBasicInfoViewModelFilter
                        {
                            AccountId = account.Id,
                            DateTo    = eventDate.Date,
                            DateFrom  = eventDate.Date
                        };
                        var fileName    = "PatientInputfiles_" + eventDate.ToString("MMddyyyy") + ".csv";
                        var csvFilePath = destinationPath + "\\" + fileName;

                        if (File.Exists(csvFilePath))
                        {
                            File.Delete(csvFilePath);
                        }

                        int pageNumber = 1;

                        while (true)
                        {
                            int totalRecords = 0;
                            var events       = _eventRepository.GetEventsbyFilters(filter, pageNumber++, PageSize, out totalRecords);

                            if (events.IsNullOrEmpty())
                            {
                                break;
                            }

                            _logger.Info("total event count :" + totalRecords);

                            foreach (var eventData in events)
                            {
                                var model = _patientInputFileService.GetPatientFileInputByEvent(eventData, account.Tag);

                                if (model != null && model.Any())
                                {
                                    _logger.Info("event id : " + eventData.Id + " customer for Event " + model.Count());
                                    WriteCsvAppointmentBooked(model, destinationPath, fileName);
                                }
                                else
                                {
                                    _logger.Info("event id : " + eventData.Id + " no customer found for event ");
                                }
                            }
                        }

                        _logger.Info(string.Format("Completed Patient Input File For Account Id: {0} Tag: {1} for event Date: {2}", account.Id, account.Tag, eventDate));
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("some Error occured for while generating file for Tag {0} Message: {1} Stack Trace {2}", account.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error occured Message: {0} Stack trace {1}", ex.Message, ex.StackTrace));
            }

            _logger.Info("Completed Patient Input File");
        }
        public void PollforSurveyEmails()
        {
            var filter = new EventBasicInfoViewModelFilter {
                DateFrom = DateTime.Now.Date.AddDays(-1), DateTo = DateTime.Now.Date.AddDays(-1)
            };

            int totalRecords;
            var events = _eventRepository.GetEventsbyFilters(filter, 1, 100, out totalRecords); // Assuming there will be no mre than 100 events in one single day

            _logger.Info("\n\n");
            _logger.Info("---------------------------- Survey Emails -------------------------------------");

            if (events == null || !events.Any())
            {
                _logger.Info("No Events found!");
                return;
            }
            try
            {
                foreach (var @event in events)
                {
                    if (@event.Status != EventStatus.Active)
                    {
                        continue;                                     //|| @event.AccountId.HasValue
                    }
                    var account = _corporateAccountRepository.GetbyEventId(@event.Id);
                    if (account != null && !(account.SendSurveyMail && account.SurveyMailTemplateId > 0))
                    {
                        continue;
                    }

                    _logger.Info(string.Format("Starting for {0} dated {1}", @event.Name, @event.EventDate.ToShortDateString()));
                    var pods = _podRepository.GetPodsForEvent(@event.Id);

                    var eventCustomers = _eventCustomerRepository.GetbyEventId(@event.Id);
                    eventCustomers = eventCustomers.Where(ec => ec.AppointmentId.HasValue && !ec.NoShow && !ec.LeftWithoutScreeningReasonId.HasValue).ToArray();

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

                    string emailTemplateAlias = EmailTemplateAlias.SurveyEmailNotification;

                    if (account != null && account.SurveyMailTemplateId > 0)
                    {
                        var emailTemplate = ((IUniqueItemRepository <EmailTemplate>)_emailTemplateRepository).GetById(account.SurveyMailTemplateId);
                        emailTemplateAlias = emailTemplate.Alias;
                    }

                    foreach (var customer in customers)
                    {
                        if ((customer.DoNotContactTypeId.HasValue && (customer.DoNotContactTypeId.Value == (long)DoNotContactType.DoNotContact || customer.DoNotContactTypeId.Value == (long)DoNotContactType.DoNotMail)) || !customer.EnableEmail) //(customer.DoNotContactReasonId.HasValue && customer.DoNotContactReasonId.Value > 0)
                        {
                            continue;
                        }
                        if (customer.Email == null)
                        {
                            _logger.Info(string.Format("{0} has no Email!", customer.NameAsString));
                            continue;
                        }

                        ServiceNotification(customer, @event, pods, emailTemplateAlias);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
        }