public string TestNotPerformedReportExport(TestNotPerformedListModelFilter filter, long userId) { var dataGen = new ExportableDataGenerator <TestNotPerformedViewModel, TestNotPerformedListModelFilter>(_testNotPerformedService.GetTestNotPerformed, Logger); var model = dataGen.GetData(filter); var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <TestNotPerformedViewModel>(); return(WriteCsv(GetExportableFileName("TestNotPerformed"), exporter, model.Collection, userId)); }
private void GenerateTestNotPerformedCsvByFilter(TestNotPerformedListModelFilter filter, CorporateAccount healthPlan) { _logger.Info(string.Format("Generating Report for filter : EventDateFrom: {0}, EventDateTo {1}, HealthPlanId {2} ", filter.EventDateFrom, filter.EventDateTo, filter.HealthPlanId)); var dataGen = new ExportableDataGenerator <TestNotPerformedViewModel, TestNotPerformedListModelFilter>(_testNotPerformedService.GetTestNotPerformed, _logger); var model = dataGen.GetData(filter); if (model != null) { var fileName = GetCsvFileName(filter, healthPlan); var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <TestNotPerformedViewModel>(); if (model.Collection != null && model.Collection.Any()) { _baseExportableReportHelper.GenerateCsv(fileName, exporter, model.Collection); } } }
private string GetCsvFileName(TestNotPerformedListModelFilter filter, CorporateAccount healthPlan) { var folderLocation = string.Format(_healthPlanTestNotPerformedExportDownloadPath, healthPlan.FolderName, filter.EventDateFrom.Value.Year); if (!Directory.Exists(folderLocation)) { Directory.CreateDirectory(folderLocation); } var csvFileName = string.Format("TestNotPerformedReport.csv"); var fileName = folderLocation + "\\" + csvFileName; if (File.Exists(fileName)) { File.Delete(fileName); } return(fileName); }
public ActionResult TestNotPerformed(TestNotPerformedListModelFilter filter = null, int pageNumber = 1) { int totalRecords = 0; if (filter == null) { filter = new TestNotPerformedListModelFilter { EventDateFrom = DateTime.Now.AddMonths(-1).Date, EventDateTo = DateTime.Now.Date } } ; var model = _testNotPerformedService.GetTestNotPerformed(pageNumber, _pageSize, filter, out totalRecords); if (model == null) { model = new TestNotPerformedListModel(); } filter.EventDateFrom = filter.EventDateFrom.HasValue ? filter.EventDateFrom.Value : DateTime.Now.AddMonths(-1).Date; filter.EventDateTo = filter.EventDateTo.HasValue ? filter.EventDateTo.Value : DateTime.Now; model.Filter = filter; var currentAction = ControllerContext.RouteData.Values["action"].ToString(); Func <int, string> urlFunc = pn => Url.Action(currentAction, new { pageNumber = pn, filter.EventDateFrom, filter.EventDateTo, filter.HealthPlanId, filter.EventId, filter.Pod, filter.TestId }); model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc); return(View(model)); }
public void PollForTestNotPerformed() { try { if (DateTime.Today.DayOfWeek != _dayOfWeek) { _logger.Info(string.Format("todays day : {0}, export set to run on {1}", DateTime.Today.DayOfWeek, _dayOfWeek)); return; } var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); _logger.Info("Test Not Performed Report Started"); foreach (var healthPlan in healthPlans) { try { _logger.Info(string.Format("Report Generation Started for {0} ", healthPlan.Tag)); var toDate = DateTime.Today.Date; var fromDate = DateTime.Today.AddDays(-7); if (fromDate.Year == toDate.Year) { fromDate = new DateTime(fromDate.Year, 1, 1); var filter = new TestNotPerformedListModelFilter { EventDateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, EventDateTo = toDate, HealthPlanId = healthPlan.Id, }; GenerateTestNotPerformedCsvByFilter(filter, healthPlan); } else { //for Previous Year fromDate = new DateTime(fromDate.Year, 1, 1); var filter = new TestNotPerformedListModelFilter { EventDateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, EventDateTo = new DateTime(fromDate.Year, 12, 31), HealthPlanId = healthPlan.Id, }; GenerateTestNotPerformedCsvByFilter(filter, healthPlan); //for current Year fromDate = new DateTime(toDate.Year, 1, 1); filter = new TestNotPerformedListModelFilter { EventDateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, EventDateTo = toDate, HealthPlanId = healthPlan.Id, }; GenerateTestNotPerformedCsvByFilter(filter, healthPlan); } _logger.Info(string.Format("Report Generation Completed for {0} ", healthPlan.Tag)); } catch (Exception ex) { _logger.Info(string.Format("Some Error Exception Occured while Generating Report for Tag: {0} Message: {1} Stack Trace {2}", healthPlan.Tag, ex.Message, ex.StackTrace)); _logger.Info(string.Format("Report Generation Completed for {0} ", healthPlan.Tag)); } } } catch (Exception ex) { _logger.Info(string.Format("Some Error Exception Occured Message: {0} Stack Trace {1}", ex.Message, ex.StackTrace)); } }
public ActionResult TestNotPerformed(TestNotPerformedListModelFilter filter = null) { return(CreateExportQueue(filter, ExportableReportType.TestNotPerformed, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId)); }
public IEnumerable <TestNotPerformed> GetTestNotPerformedForHealthPlan(TestNotPerformedListModelFilter filter, int pageNumber, int pageSize, out int totalRecords) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); filter.EventDateFrom = filter.EventDateFrom.HasValue ? filter.EventDateFrom.Value.Date : DateTime.Now.AddMonths(-1).Date; filter.EventDateTo = filter.EventDateTo.HasValue ? filter.EventDateTo.Value.Date : DateTime.Now.Date; var query = (from ecr in linqMetaData.EventCustomerResult join ces in linqMetaData.CustomerEventScreeningTests on ecr.EventCustomerResultId equals ces.EventCustomerResultId join cets in linqMetaData.CustomerEventTestState on ces.CustomerEventScreeningTestId equals cets.CustomerEventScreeningTestId join tnep in linqMetaData.TestNotPerformed on ces.CustomerEventScreeningTestId equals tnep.CustomerEventScreeningTestId join ec in linqMetaData.EventCustomers on ecr.EventCustomerResultId equals ec.EventCustomerId join ea in linqMetaData.EventAppointment on ec.AppointmentId equals ea.AppointmentId join e in linqMetaData.Events on ecr.EventId equals e.EventId where !ec.NoShow && !ec.LeftWithoutScreeningReasonId.HasValue && ea.CheckinTime.HasValue && ea.CheckoutTime.HasValue && (filter.TechnicianId > 0 ? cets.ConductedByOrgRoleUserId == filter.TechnicianId : true) && cets.ConductedByOrgRoleUserId.HasValue && e.EventDate <= DateTime.Today select new { ecr, tnep, e.EventDate, ces.TestId }); if (filter.EventId > 0) { query = (from q in query where q.ecr.EventId == filter.EventId select q); } else { if (filter.EventDateFrom.HasValue || filter.EventDateTo.HasValue) { query = (from q in query where (filter.EventDateFrom != null ? q.EventDate >= filter.EventDateFrom.Value : true) && (filter.EventDateTo != null ? q.EventDate <= filter.EventDateTo.Value : true) select q); } if (!string.IsNullOrEmpty(filter.Pod)) { var podEventIds = (from ep in linqMetaData.EventPod join p in linqMetaData.PodDetails on ep.PodId equals p.PodId where ep.IsActive && p.Name.Contains(filter.Pod) select ep.EventId); query = (from q in query where podEventIds.Contains(q.ecr.EventId) select q); } if (filter.HealthPlanId > 0) { var eventIds = (from ea in linqMetaData.EventAccount where ea.AccountId == filter.HealthPlanId select ea.EventId); query = (from q in query where eventIds.Contains(q.ecr.EventId) select q); } if (filter.TestId > 0) { query = (from q in query where q.TestId == filter.TestId select q); } } var testNotPerformedQuery = (from q in query orderby q.EventDate, q.ecr.EventId, q.ecr.CustomerId select q.tnep); totalRecords = testNotPerformedQuery.Count(); var entities = testNotPerformedQuery.TakePage(pageNumber, pageSize).ToArray(); return(Mapper.Map <IEnumerable <TestNotPerformedEntity>, IEnumerable <TestNotPerformed> >(entities)); } }