コード例 #1
0
        private bool GenerateReport(string destinationFolder, string fileName, GiftCertificateReportFilter filter)
        {
            var completePath = Path.Combine(destinationFolder, fileName);

            var dataGen = new ExportableDataGenerator <GiftCertificateReportOptumViewModel, GiftCertificateReportFilter>(_giftCerificateOptumReportService.GetGiftCertificateOptumReport, _logger);

            var model = dataGen.GetData(filter);

            if (model != null && !model.Collection.IsNullOrEmpty())
            {
                _logger.Info("Writing Gift Certificate Report");
                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <GiftCertificateReportOptumViewModel>();

                _logger.Info("Record count" + model.Collection.Count());

                DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationFolder);

                DirectoryOperationsHelper.DeleteFileIfExist(completePath);

                _baseExportableReportHelper.GenerateCsv(completePath, exporter, model.Collection);

                _logger.Info("completed Gift Certificate Report for account tag " + filter.Tag);

                _logger.Info("Destination Path: " + completePath);

                return(true);
            }

            return(false);
        }
コード例 #2
0
        private void MemberReportForRiskCustomer(CorporateAccount account, DateTime fromDate, DateTime toDate, string directoryPath, IEnumerable <long> shippintOptionId)
        {
            var fileName = string.Format("R_MemberReport_{0}.csv", toDate.ToString("yyyyMMdd"));

            var filter = new MemberResultMailedReportFilter
            {
                DateFrom     = fromDate,
                DateTo       = toDate,
                HealthPlanId = account.Id,
                CustomTags   = _bcbsMiRiskPatientTags,
                ExcludeCustomerWithCustomTag = false,
                ShippingOptions = shippintOptionId,
                Tag             = account.Tag
            };

            _logger.Info("generating R_MemberReport for " + account.Tag);

            var dataGen = new ExportableDataGenerator <BcbsMiMemberResultMailedReportViewModel, MemberResultMailedReportFilter>(_bcbsMiMemberResultMailedReportService.GetBcbsMiMemberResultMailedReport, _logger);

            var model = dataGen.GetData(filter);

            if (model != null && !model.Collection.IsNullOrEmpty())
            {
                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <BcbsMiMemberResultMailedReportViewModel>();

                _logger.Info("Record count" + model.Collection.Count());

                if (File.Exists(directoryPath + fileName))
                {
                    File.Delete(directoryPath + fileName);
                }

                _baseExportableReportHelper.GenerateCsv(directoryPath + fileName, exporter, model.Collection);

                _logger.Info("Destination file " + directoryPath + fileName);
            }
            else
            {
                _logger.Info("No Record Found for Tag" + account.Tag);
            }

            _logger.Info("Completed R-MemberReport for " + account.Tag);
        }
コード例 #3
0
        private void ServiceReportForRiskCustomer(CorporateAccount account, DateTime dateFrom, DateTime dateTo, string directoryPath)
        {
            var fileName = string.Format("R_ServicesReport_{0}.csv", dateTo.ToString("yyyyMMdd"));

            var filter = new CustomTestPerformedReportFilter
            {
                DateFrom     = dateFrom,
                DateTo       = dateTo,
                HealthPlanId = account.Id,
                CustomTags   = _bcbsMiRiskPatientTags,
                ExcludeCustomerWithCustomTag = false,
                Tag = account.Tag
            };

            _logger.Info("generating R-ServicesReport for " + account.Tag);

            var dataGen = new ExportableDataGenerator <CustomTestPerformedViewModel, CustomTestPerformedReportFilter>(_customTestPerformedReportService.CustomTestPerformedReport, _logger);

            var model = dataGen.GetData(filter);

            if (model != null && !model.Collection.IsNullOrEmpty())
            {
                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <CustomTestPerformedViewModel>();

                _logger.Info("Record count" + model.Collection.Count());

                if (File.Exists(directoryPath + fileName))
                {
                    File.Delete(directoryPath + fileName);
                }

                _baseExportableReportHelper.GenerateCsv(directoryPath + fileName, exporter, model.Collection);

                _logger.Info("CSV Generated at " + directoryPath + fileName);
            }
            else
            {
                _logger.Info("No Record Found for Tag" + account.Tag);
            }

            _logger.Info("Completed R-ServicesReport for " + account.Tag);
        }
コード例 #4
0
        public void PollForDiabeticRetinopathyParserlog()
        {
            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 fromDate = DateTime.Today.AddDays(-1 * _numberOfDays);
                var toDate   = DateTime.Today;

                _logger.Info("Diabetic Retinopathy Parser Log Report Started");
                var filter = new DiabeticRetinopathyParserlogListModelFilter
                {
                    DateFrom = fromDate,
                    DateTo   = toDate
                };

                _logger.Info(string.Format("Generating report for filter diabetic retinopathy parser log : DateFrom: {0}, DateTo {1} ", filter.DateFrom, filter.DateTo));


                var dataGen = new ExportableDataGenerator <DiabeticRetinopathyParserlogViewModel, DiabeticRetinopathyParserlogListModelFilter>(_diabeticRetinopathyParserlogService.GetDiabeticRetinopathyParserlog, _logger);
                var model   = dataGen.GetData(filter);

                if (model != null)
                {
                    var fileName = GetCsvFileName(filter);

                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <DiabeticRetinopathyParserlogViewModel>();

                    if (model.Collection != null && model.Collection.Any())
                    {
                        _baseExportableReportHelper.GenerateCsv(fileName, exporter, model.Collection);
                    }
                }
                _logger.Info(string.Format("Report Generation Completed. "));
            }
            catch (Exception ex)
            {
                _logger.Error("Some Error Exception Occured while Generating Report");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("StackTrace: " + ex.StackTrace);

                _logger.Error(string.Format("Report Generation Completed  "));
            }
        }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
        private void GenerateMemberStatusListCsvByFilter(MemberStatusListModelFilter filter, CorporateAccount account)
        {
            _logger.Info(string.Format("Generating Member Status Report for filter :  Tag {0}", filter.Tag));

            var dataGen = new ExportableDataGenerator <MemberStatusModel, MemberStatusListModelFilter>(_eventCustomerReportingService.GetMemberStatusReport, _logger);
            var model   = dataGen.GetData(filter);

            if (model != null)
            {
                var fileName = GetCsvFileName(account);

                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <MemberStatusModel>();

                if (model.Collection != null && model.Collection.Any())
                {
                    _baseExportableReportHelper.GenerateCsv(fileName, exporter, model.Collection);
                }
            }
        }
コード例 #7
0
        public void PollForDailyVolumeReport()
        {
            try
            {
                _logger.Info("Setting filter to pull data for Daily Volume Report");
                var filter = new DailyVolumeListModelFilter
                {
                    FromDate = new DateTime(DateTime.Today.Year, 1, 1),
                    ToDate   = new DateTime(DateTime.Today.Year, 12, 31)
                };

                _logger.Info("fetching Daily Volume Report");
                var dataGen = new ExportableDataGenerator <DailyVolumeModel, DailyVolumeListModelFilter>(_eventReportingService.GetDailyVolumeReport, _logger);
                var model   = dataGen.GetData(filter);

                if (model != null && !model.Collection.IsNullOrEmpty())
                {
                    _logger.Info("Writing Daily volume Report");
                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <DailyVolumeModel>();

                    _logger.Info("Record count" + model.Collection.Count());
                    var dailyVolumeReportPath = Path.Combine(_settings.DailyVolumeReportPath, DateTime.Today.Year.ToString());

                    DirectoryOperationsHelper.CreateDirectoryIfNotExist(dailyVolumeReportPath);
                    var reportName     = "HF_DailyVolume_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    var reportfilePath = Path.Combine(dailyVolumeReportPath, reportName);

                    DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath);

                    _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection);

                    _logger.Info("Daily Volume Report File Posted " + reportfilePath);
                }
            }
            catch (Exception exception)
            {
                _logger.Error("Some error occurred ");
                _logger.Error("Message:  " + exception.Message);
                _logger.Error("Stack Trace:  " + exception.StackTrace);
            }
        }
コード例 #8
0
        private void PcpSummaryLogReport(CorporateAccount account, DateTime dateFrom, DateTime dateTo, string directoryPath, string fileName)
        {
            var filter = new PcpSummaryLogReportModelFilter
            {
                DateFrom     = dateFrom,
                DateTo       = dateTo,
                HealthPlanId = account.Id,
                Tag          = account.Tag
            };

            _logger.Info("Generating Summary Log for " + account.Tag);

            var dataGen = new ExportableDataGenerator <PcpSummaryLogReportModel, PcpSummaryLogReportModelFilter>(_pcpSummaryLogReportService.GetPcpSummaryLogReport, _logger);

            var model = dataGen.GetData(filter);


            if (model != null && !model.Collection.IsNullOrEmpty())
            {
                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <PcpSummaryLogReportModel>();

                _logger.Info("Record count" + model.Collection.Count());

                if (File.Exists(directoryPath + fileName) && !FirstReportGenerated)
                {
                    File.Delete(directoryPath + fileName);
                }

                FirstReportGenerated = _baseExportableReportHelper.GenerateCsv(directoryPath + fileName, exporter, model.Collection, skipHeader: FirstReportGenerated);


                _logger.Info("Destination file " + directoryPath + fileName);
            }
            else
            {
                _logger.Info("No Record Found for Tag" + account.Tag);
            }
            _logger.Info("Completed Summary Log for " + account.Tag);
        }
コード例 #9
0
        public void PollMailRoundCustomersReport()
        {
            try
            {
                _logger.Info("Entering Matrix Report Polling Agent");

                var healthPlans = _corporateAccountRepository.GetAllHealthPlan();
                var callQueues  = _callQueueRepository.GetAll(false, true);

                if (callQueues.IsNullOrEmpty())
                {
                    _logger.Info("No call queue found.");
                    return;
                }
                var mailRoundCallQueue       = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.MailRound);
                var fillEventCallQueue       = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.FillEventsHealthPlan);
                var languageBarrierCallQueue = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.LanguageBarrier);

                foreach (var healthPlan in healthPlans)
                {
                    try
                    {
                        _logger.Info(string.Format("Generating Matrix Report for accountId {0} and account tag {1}. ", healthPlan.Id, healthPlan.Tag));

                        var destinationPath = _settings.MailRoundCustomersReportDestinantionPath;

                        var filePath = Path.Combine(destinationPath, string.Format(@"MatrixReport_{0}_{1}.csv", healthPlan.Tag, DateTime.Now.ToString("MMddyyyy")));

                        DirectoryOperationsHelper.CreateDirectory(destinationPath);

                        var customers = new List <MailRoundCustomersReportViewModel>();

                        _logger.Info("Fetching customers for fill event call queue");
                        var fillEventCustomers = GetCustomersForMatrixReport(healthPlan.Id, fillEventCallQueue);
                        if (!fillEventCustomers.IsNullOrEmpty())
                        {
                            customers.AddRange(fillEventCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for fill event call queue");
                        }


                        _logger.Info("Fetching customers for mail round call queue");
                        var mailRoundCustomers = GetCustomersForMatrixReport(healthPlan.Id, mailRoundCallQueue);
                        if (!mailRoundCustomers.IsNullOrEmpty())
                        {
                            if (!customers.IsNullOrEmpty())
                            {
                                var existingCustomerIds = customers.Select(c => c.CustomerID);
                                mailRoundCustomers = mailRoundCustomers.Where(x => !existingCustomerIds.Contains(x.CustomerID)).ToList();
                            }
                            customers.AddRange(mailRoundCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for mail round call queue");
                        }


                        _logger.Info("Fetching customers for language barrier call queue");
                        var languageBarrierCustomers = GetCustomersForMatrixReport(healthPlan.Id, languageBarrierCallQueue);
                        if (!languageBarrierCustomers.IsNullOrEmpty())
                        {
                            if (!customers.IsNullOrEmpty())
                            {
                                var existingCustomerIds = customers.Select(c => c.CustomerID);
                                languageBarrierCustomers = languageBarrierCustomers.Where(x => !existingCustomerIds.Contains(x.CustomerID)).ToList();
                            }
                            customers.AddRange(languageBarrierCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for language barrier call queue");
                        }


                        if (customers.Any())
                        {
                            var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <MailRoundCustomersReportViewModel>();

                            DirectoryOperationsHelper.DeleteFileIfExist(filePath);

                            _baseExportableReportHelper.GenerateCsv(filePath, exporter, customers);
                            _logger.Error(string.Format("Successfully Matrix Report Generated for AccountId {0} and Account Tag {1}.", healthPlan.Id, healthPlan.Tag));
                        }
                        else
                        {
                            _logger.Error(string.Format("No records found for AccountId {0} and Account Tag {1}. \n\n", healthPlan.Id, healthPlan.Tag));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("Error occured while generating Matrix Report for AccountId {0} and Account Tag {1} : \n Error {2} \n Trace: {3} ", healthPlan.Id, healthPlan.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error occured while generating Matrix Report : \n Error {0} \n Trace: {1} ", ex.Message, ex.StackTrace));
            }
        }
コード例 #10
0
        public void PollForEventScheduleReort()
        {
            try
            {
                _logger.Info("starting Event Schedule Report");

                var accounts = _corporateAccountRepository.GetByIds(_settings.EventScheduleAccountIds);

                foreach (var account in accounts)
                {
                    _logger.Info("Event Schedule Report for Account Tag" + account.Tag);

                    if ((account.Id == _settings.ConnecticareAccountId || account.Id == _settings.ConnecticareMaAccountId) && DateTime.Today.DayOfWeek != _settings.ConnecticareEventScheduleExportDay)
                    {
                        _logger.Info("today is " + DateTime.Today.DayOfWeek + " while service is configured to run on " + _settings.ConnecticareEventScheduleExportDay);
                        _logger.Info("Please set " + (int)DateTime.Today.DayOfWeek + " to run Service today");
                        continue;
                    }

                    var fromDate = new DateTime(DateTime.Today.Year, 1, 1);
                    var toDate   = new DateTime(DateTime.Today.Year, 12, 31);

                    var filter = new EventScheduleListModelFilter
                    {
                        AccountId = account.Id,
                        FromDate  = fromDate,
                        ToDate    = toDate,
                    };
                    var stateIds = _eventRepository.GetEventStateByAccountId(filter);

                    if (stateIds.IsNullOrEmpty())
                    {
                        _logger.Info("No State found for Account Tag " + account.Tag);
                        continue;
                    }

                    var states = _stateRepository.GetStates(stateIds);
                    foreach (var state in states)
                    {
                        try
                        {
                            _logger.Info("fetching records for State Name " + state.Name);
                            filter.StateId = state.Id;

                            var dataGen = new ExportableDataGenerator <EventScheduleModel, EventScheduleListModelFilter>(_eventReportingService.GetEventScheduleReport, _logger);
                            var model   = dataGen.GetData(filter);

                            if (model != null && !model.Collection.IsNullOrEmpty())
                            {
                                _logger.Info("Writing Event Schedule Report");
                                var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <EventScheduleModel>();

                                _logger.Info("Record count" + model.Collection.Count());
                                var eventScheduleReportPath = Path.Combine(_settings.EventScheduleReportPath, DateTime.Today.Year.ToString());

                                DirectoryOperationsHelper.CreateDirectoryIfNotExist(eventScheduleReportPath);
                                var reportName = "EventScheduleReport_" + account.Tag + "_" + state.Name + "_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";

                                var reportfilePath = Path.Combine(eventScheduleReportPath, reportName);

                                if (account.Id == _settings.ConnecticareAccountId || account.Id == _settings.ConnecticareMaAccountId)
                                {
                                    reportfilePath = Path.Combine(_settings.HealthPlanDownloadPath, account.FolderName);
                                    reportfilePath = Path.Combine(reportfilePath, reportName);
                                }

                                DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath);

                                _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection);

                                _logger.Info("Generated report of Event Schedule Report for Account " + account.Tag + " state " + state.Name);
                                _logger.Info("Path: " + reportfilePath + " state " + state.Name);

                                if (_sendReportToSftp)
                                {
                                    _logger.Info("Sending file to sftp.");
                                    var eventScheduleReportSftpPath = string.Format(_eventScheduleReportSftpPath, fromDate.Year);
                                    var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword);

                                    processFtp.UploadSingleFile(reportfilePath, eventScheduleReportSftpPath, "");

                                    _logger.Info("File sent on sftp.");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("some Error occurred while generating report of Event Schedule Report for Account " + account.Tag + " state " + state.Name);
                            _logger.Error("ex: " + ex.Message);
                            _logger.Error("stack Trace: " + ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("some Error occurred while generating report of Event Schedule Report ");
                _logger.Error("ex: " + ex.Message);
                _logger.Error("stack Trace: " + ex.StackTrace);
            }
        }
コード例 #11
0
        public void PollForPcpLogSummaryReportExport()
        {
            try
            {
                if (_wellCarePcpSummaryLogReportDayOfWeek != DateTime.Today.DayOfWeek)
                {
                    _logger.Info("Report is schedule to run on " + _wellCarePcpSummaryLogReportDayOfWeek);
                    _logger.Info("Today is day of week " + DateTime.Today.DayOfWeek);
                    _logger.Info(string.Format("Set day of week to {0} to run today ", ((int)DateTime.Today.DayOfWeek)));
                    return;
                }

                if (_accountIds.IsNullOrEmpty())
                {
                    _logger.Info("No Account Ids found");
                    return;
                }


                var directoryPath = _destinationFolderPdfPath + "\\";

                CreateDestinationDirectory(directoryPath);

                var toDate = DateTime.Now;

                var fileName = string.Format("PCPSummaryLog-HealthFair-{0}.csv", toDate.ToString("yyyyMMdd"));


                var accounts = _corporateAccountRepository.GetByIds(_accountIds);

                var model = new PcpSummaryLogReportListModel();

                foreach (var account in accounts)
                {
                    _logger.Info("Running Report for Tag: " + account.Tag);

                    try
                    {
                        var serviceReportSettings = string.Format(_wellCarePcpSummaryLogReportSettingPath, account.Tag);
                        var customSettings        = _customSettingManager.Deserialize(serviceReportSettings);

                        var fromDate = (customSettings.LastTransactionDate != null) ? customSettings.LastTransactionDate.Value : _cutOfDate;

                        var listModel = PcpSummaryLogReport(account, fromDate, toDate, directoryPath, fileName);
                        if (listModel != null && !listModel.Collection.IsNullOrEmpty())
                        {
                            if (model.Collection.IsNullOrEmpty())
                            {
                                model.Collection = listModel.Collection;
                            }
                            else
                            {
                                model.Collection = model.Collection.Concat(listModel.Collection);
                            }
                        }

                        customSettings.LastTransactionDate = toDate;
                        _customSettingManager.SerializeandSave(serviceReportSettings, customSettings);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Some Error occurred  for Tag" + account.Tag);
                        _logger.Error("Message: " + ex.Message);
                        _logger.Error("Stack Trace: " + ex.StackTrace);
                    }
                }

                if (model != null && !model.Collection.IsNullOrEmpty())
                {
                    model.Collection = model.Collection.OrderBy(x => x.PcpMailedDate).ThenBy(x => x.EventId);

                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <PcpSummaryLogReportModel>();

                    _logger.Info("Record count" + model.Collection.Count());

                    if (File.Exists(directoryPath + fileName) && !FirstReportGenerated)
                    {
                        File.Delete(directoryPath + fileName);
                    }

                    FirstReportGenerated = _baseExportableReportHelper.GenerateCsv(directoryPath + fileName, exporter, model.Collection, skipHeader: FirstReportGenerated);


                    _logger.Info("Destination file " + directoryPath + fileName);
                }
                else
                {
                    _logger.Info(string.Format("No Data found for PCP summary log Period {0} ", toDate));
                }

                if (_settings.SendPdfToWellCareSftp)
                {
                    ExportResultOnWellCareSftp(fileName, directoryPath + fileName);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
        }
コード例 #12
0
        public void PollForAppointmentEncounterData()
        {
            try
            {
                if (_settings.AppointmentEncounterReportAccountIds.IsNullOrEmpty())
                {
                    _logger.Info("No Account found for AppointmentHeader");
                    return;
                }

                var corporateAccounts = _corporateAccountRepository.GetByIds(_settings.AppointmentEncounterReportAccountIds);
                if (corporateAccounts.IsNullOrEmpty())
                {
                    _logger.Info("No Account found for AppointmentHeader");
                    return;
                }

                foreach (var account in corporateAccounts)
                {
                    try
                    {
                        _logger.Info("running Report for account tag " + account.Tag);

                        var fromDate = DateTime.Today.GetFirstDateOfYear();
                        var toDate   = DateTime.Today.GetLastDateOfYear();

                        var filter = new AppointmentEncounterFilter
                        {
                            AccountId     = account.Id,
                            EventFromDate = fromDate,
                            EventToDate   = toDate,
                            Tag           = account.Tag
                        };

                        var dataGen = new ExportableDataGenerator <AppointmentEncounterModel, AppointmentEncounterFilter>(_appointmentEncounterService.GetAppointmentEncounterReport, _logger);
                        var model   = dataGen.GetData(filter);

                        if (model != null && !model.Collection.IsNullOrEmpty())
                        {
                            _logger.Info("Writing Event Schedule Report");
                            var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <AppointmentEncounterModel>();

                            _logger.Info("Record count" + model.Collection.Count());
                            var folderLocation = string.Format(_settings.AppointmentEncounterReportPath, account.FolderName);

                            if (_settings.OptumAccountIds.Contains(account.Id))
                            {
                                try
                                {
                                    DirectoryOperationsHelper.DeleteDirectory(folderLocation, true);
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("Some error occurred while deleting directory at path: " + folderLocation);
                                    _logger.Error("Message: " + ex.Message);
                                    _logger.Error("Stack Trace: " + ex.StackTrace);
                                }
                            }

                            DirectoryOperationsHelper.CreateDirectoryIfNotExist(folderLocation);
                            var fileName = string.Format("EncounterHeader_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));

                            var completePath = Path.Combine(folderLocation, fileName);
                            DirectoryOperationsHelper.DeleteFileIfExist(completePath);

                            _baseExportableReportHelper.GenerateCsv(completePath, exporter, model.Collection);

                            _logger.Info("completed Report for account tag " + account.Tag);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("some Error occurred While Appointment Encounter for Account Tag: " + account.Tag);
                        _logger.Error("Message: " + ex.Message);
                        _logger.Error("Stack Trace: " + ex.StackTrace);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("some Error occurred While Appointment Encounter: ");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
        }
コード例 #13
0
        private void GenerateReport(EventScheduleListModelFilter eventScheduleModelFilter, PotentialPcpChangeReportModelFilter filter, CorporateAccount account)
        {
            var stateIds = (IReadOnlyCollection <long>)_eventRepository.GetEventStateByAccountId(eventScheduleModelFilter);

            if (stateIds.IsNullOrEmpty())
            {
                _logger.Info("No State found for Wellmed");             //Do not return from here as we are updating last transaction date at last
            }

            var states = _stateRepository.GetStates(stateIds);

            foreach (var state in states)
            {
                try
                {
                    _logger.Info("Generating Report for State: " + state.Name);

                    var dataGen = new ExportableDataGenerator <PotentialPcpChangeReportViewModel, PotentialPcpChangeReportModelFilter>(_potentialPcpChangeReportService.GetPotentialPcpChangeData, _logger);
                    filter.StateId = state.Id;
                    var model = dataGen.GetData(filter);

                    if (model != null && !model.Collection.IsNullOrEmpty())
                    {
                        var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <PotentialPcpChangeReportViewModel>();

                        var path           = string.Format(_pcpChangeReportPath, account.FolderName);
                        var reportfilePath = Path.Combine(path, state.Name);

                        DirectoryOperationsHelper.CreateDirectoryIfNotExist(reportfilePath);
                        reportfilePath = Path.Combine(reportfilePath, string.Format("WellMed_PCP_Change_Report_{0}.csv", filter.StartDate.ToString("yyyyMM")));
                        _logger.Info("File path : " + reportfilePath);

                        DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath);
                        _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection);

                        if (_sendReportToSftp && DirectoryOperationsHelper.IsFileExist(reportfilePath))
                        {
                            _logger.Info("Starting to post Potential Pcp Change report on sftp for StateId: " + state.Id + " State: " + state.Name);

                            var sftpResultExportDirectory = string.Format(_sftpPathForPcpChangeReport, state.Name);
                            var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword);
                            processFtp.UploadSingleFile(reportfilePath, sftpResultExportDirectory, "");

                            _logger.Info("Potential Pcp Change report posted on sftp for StateId: " + state.Id + " State: " + state.Name);
                        }
                        _logger.Info("Potential Pcp Change Report generation completed for StateId: " + state.Id + " State: " + state.Name);
                    }
                    else
                    {
                        _logger.Info("No data found for StateId: " + state.Id + " State: " + state.Name);
                    }
                }
                catch (Exception exception)
                {
                    _logger.Error("Error occurred during generation of report for StateId: " + state.Id);
                    _logger.Error("Message:  " + exception.Message);
                    _logger.Error("Stack Trace:  " + exception.StackTrace);
                }
            }

            //update custom setting XML
            var customSetting = _customSettingManager.Deserialize(_pcpCustomSetting);

            customSetting.LastTransactionDate = filter.EndDate;
            _customSettingManager.SerializeandSave(_pcpCustomSetting, customSetting);
        }
コード例 #14
0
        public void PollForEventList()
        {
            var timeOfDay = DateTime.Now;

            _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss"));

            var startTime = new TimeSpan(_settings.GmsEventStartTime, 0, 0);
            var endTime   = new TimeSpan(_settings.GmsEventEndTime, 0, 0);

            if (timeOfDay.TimeOfDay < startTime || timeOfDay.TimeOfDay > endTime)
            {
                _logger.Info(string.Format("Report is generated only between {0} and {1}.", startTime.ToString(), endTime.ToString()));
                return;
            }

            _logger.Info(string.Format("Generating Event List for GMS."));
            try
            {
                var filter = new EventListGmsModelFilter
                {
                    FromDate      = DateTime.Today,
                    HealthPlanIds = _settings.GmsAccountIds
                };

                var dataGen = new ExportableDataGenerator <EventListGmsModel, EventListGmsModelFilter>(_eventReportingService.GetEventListForGmsReport, _logger);
                var model   = dataGen.GetData(filter);

                if (model != null && !model.Collection.IsNullOrEmpty())
                {
                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <EventListGmsModel>();

                    DirectoryOperationsHelper.CreateDirectoryIfNotExist(_settings.EventListGmsReportPath);

                    var reportfilePath = Path.Combine(_settings.EventListGmsReportPath, string.Format("EventList_{0}.csv", DateTime.Now.ToString("yyyyMMdd_HH")));
                    _logger.Info("File path : " + reportfilePath);

                    DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath);

                    _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection);

                    if (_settings.SendReportToGmsSftp)
                    {
                        _logger.Info("Sending Event List to GMS sftp.");
                        var sftpFolderReportDirectory = _settings.GmsSftpPath;
                        var processFtp = new ProcessFtp(_logger, _settings.GmsSftpHost, _settings.GmsSftpUserName, _settings.GmsSftpPassword);

                        processFtp.UploadSingleFile(reportfilePath, sftpFolderReportDirectory, "");
                        _logger.Info("Sent Event List to GMS sftp.");
                    }
                    else
                    {
                        _logger.Info("Setting to send Event list to sftp is OFF.");
                    }

                    _logger.Info(string.Format("Event List generation for GMS completed."));
                }
                else
                {
                    _logger.Info("No future events found.");
                }
            }
            catch (Exception exception)
            {
                _logger.Error("Some error occurred ");
                _logger.Error("Message:  " + exception.Message);
                _logger.Error("Stack Trace:  " + exception.StackTrace);
            }
        }
コード例 #15
0
        public void PollForBiWeeklyMicroAlbuminFobt()
        {
            try
            {
                var timeOfDay = DateTime.Now;
                _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss"));

                if (!_settings.IsDevEnvironment && _runningDates.All(x => x != DateTime.Today.Day))
                {
                    _logger.Info("Report is generated only on 1st and 15th of the month");
                    return;
                }
                if (_accountId <= 0)
                {
                    _logger.Info("Account Id Not Provided");
                    return;
                }
                var account = _corporateAccountRepository.GetById(_accountId);
                if (account == null)
                {
                    _logger.Info("Account not exists");
                    return;
                }

                _logger.Info(string.Format("Generating Report for BiWeekly MicroAlbumin and IFobt"));

                var lastMonthDate = (DateTime.Today).AddMonths(-1);
                var endDate       = new DateTime(lastMonthDate.Year, lastMonthDate.Month, DateTime.DaysInMonth(lastMonthDate.Year, lastMonthDate.Month));
                var filter        = new BiWeeklyMicroAlbuminFobtReportModelFilter
                {
                    StartDate  = new DateTime(DateTime.Today.Year, 1, 1),
                    EndDate    = DateTime.Today,
                    AccountId  = _accountId,
                    CutOffDate = _cutoffDate
                };

                _logger.Info(string.Format("Generating Report for BiWeekly MicroAlbumin and IFobt"));
                if (lastMonthDate.Year < DateTime.Today.Year)
                {
                    filter = new BiWeeklyMicroAlbuminFobtReportModelFilter
                    {
                        AccountId = _accountId,
                        StartDate = new DateTime(lastMonthDate.Year, 1, 1),
                        EndDate   = endDate
                    };
                }

                _logger.Info("Start Date: " + filter.StartDate.ToShortDateString());
                _logger.Info("End Date: " + filter.EndDate.ToShortDateString());

                var dataGen = new ExportableDataGenerator <BiWeeklyMicroAlbuminFobtReportViewModel, BiWeeklyMicroAlbuminFobtReportModelFilter>(_biWeeklyMicroAlbuminFobtReportService.GetEventCustomerResultForReport, _logger);
                var model   = dataGen.GetData(filter);

                if (model != null && !model.Collection.IsNullOrEmpty())
                {
                    var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <BiWeeklyMicroAlbuminFobtReportViewModel>();

                    var path = string.Format(_biWeeklyReportPath, account.FolderName);
                    DirectoryOperationsHelper.CreateDirectoryIfNotExist(path);

                    var reportfilePath = Path.Combine(path, string.Format("WellMed_Kit_Disbursement_{0}.csv", DateTime.Now.ToString("yyyyMMdd")));
                    _logger.Info("File path : " + reportfilePath);
                    DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath);
                    _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection);

                    if (_sendReportToSftp && DirectoryOperationsHelper.IsFileExist(reportfilePath))
                    {
                        var sftpResultExportDirectory = _sftpPathForBiWeeklyMicroAlbuminFobtReport;

                        var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword);
                        processFtp.UploadSingleFile(reportfilePath, sftpResultExportDirectory, "");
                    }
                    _logger.Info("BiWeeklyMicroAlbuminFobt Report generation completed");
                }
                else
                {
                    _logger.Info("No customer found for Report");
                }
            }
            catch (Exception exception)
            {
                _logger.Error("Some error occurred ");
                _logger.Error("Message:  " + exception.Message);
                _logger.Error("Stack Trace:  " + exception.StackTrace);
            }
        }
コード例 #16
0
        public void PollForNonTargetableCustomer()
        {
            try
            {
                var timeOfDay = DateTime.Now;
                _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss"));

                if (!_settings.IsDevEnvironment && _runningDate != DateTime.Today.Day)
                {
                    _logger.Info("Report is generated only in 1st week of the month");
                    return;
                }
                if (_accountId <= 0)
                {
                    _logger.Info("Account Id Not Provided");
                    return;
                }
                var account = _corporateAccountRepository.GetById(_accountId);
                if (account == null)
                {
                    _logger.Info("Account not exists");
                    return;
                }

                _logger.Info(string.Format("Generating Report for Non Target-able Report"));
                var lastMonthDate = (DateTime.Today).AddMonths(-1);

                var endDate = new DateTime(lastMonthDate.Year, lastMonthDate.Month, DateTime.DaysInMonth(lastMonthDate.Year, lastMonthDate.Month));
                var filter  = new NonTargetableReportModelFilter
                {
                    AccountId = _accountId,
                    StartDate = new DateTime(DateTime.Today.Year, 1, 1),
                    EndDate   = endDate
                };

                if (lastMonthDate.Year < DateTime.Today.Year)
                {
                    filter = new NonTargetableReportModelFilter
                    {
                        AccountId = _accountId,
                        StartDate = new DateTime(lastMonthDate.Year, 1, 1),
                        EndDate   = endDate
                    };
                }

                var eventScheduleModelFilter = new EventScheduleListModelFilter
                {
                    AccountId = _accountId,
                    FromDate  = filter.StartDate,
                    ToDate    = filter.EndDate
                };
                var stateIds = _eventRepository.GetEventStateByAccountId(eventScheduleModelFilter);
                if (stateIds.IsNullOrEmpty())
                {
                    _logger.Info("No State found for Wellmed");
                }
                var states = _stateRepository.GetStates(stateIds);

                foreach (var state in states)
                {
                    try
                    {
                        _logger.Info("Generating Report for State: " + state.Name);

                        var dataGen = new ExportableDataGenerator <NonTargetableReportModel, NonTargetableReportModelFilter>(_nonTargetableReportService.GetCustomersForNonTargetableService, _logger);
                        filter.StateId = state.Id;
                        var model = dataGen.GetData(filter);

                        if (model != null && !model.Collection.IsNullOrEmpty())
                        {
                            var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <NonTargetableReportModel>();

                            var path           = string.Format(_nonTargetableReportPath, account.FolderName);
                            var reportfilePath = Path.Combine(path, state.Name);

                            DirectoryOperationsHelper.CreateDirectoryIfNotExist(reportfilePath);
                            reportfilePath = Path.Combine(reportfilePath, string.Format("WellMed_NonTargetable_{0}.csv", DateTime.Now.ToString("yyyyMM")));
                            _logger.Info("File path : " + reportfilePath);

                            DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath);
                            _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection);

                            if (_sendReportToSftp && DirectoryOperationsHelper.IsFileExist(reportfilePath))
                            {
                                _logger.Info("Starting to post non targetable report on sftp for StateId: " + state.Id + " State: " + state.Name);

                                var sftpResultExportDirectory = string.Format(_sftpPathForNonTargetableReport, state.Name);
                                var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword);
                                processFtp.UploadSingleFile(reportfilePath, sftpResultExportDirectory, "");

                                _logger.Info("Non targetable report posted on sftp for StateId: " + state.Id + " State: " + state.Name);
                            }
                            _logger.Info("Non targetable Report generation completed for StateId: " + state.Id + " State: " + state.Name);
                        }
                        else
                        {
                            _logger.Info("No customer found for StateId: " + state.Id + " State: " + state.Name);
                        }
                    }
                    catch (Exception exception)
                    {
                        _logger.Error("Error occurred during generation of report for StateId: " + state.Id);
                        _logger.Error("Message:  " + exception.Message);
                        _logger.Error("Stack Trace:  " + exception.StackTrace);
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error("Some error occurred ");
                _logger.Error("Message:  " + exception.Message);
                _logger.Error("Stack Trace:  " + exception.StackTrace);
            }
        }