public void PollForReportGeneration() { var healthPlans = !_healthPlanIds.IsNullOrEmpty() ? _corporateAccountRepository.GetByIds(_healthPlanIds) : _corporateAccountRepository.GetAllHealthPlan(); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); var collection = new List <GmsCallQueueCustomerViewModel>(); foreach (var healthPlan in healthPlans) { if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount) { break; } _logger.Info(string.Format("Getting call queue customers for Account ID : {0} and Tag : {1}", healthPlan.Id, healthPlan.Tag)); var criterias = _healthPlanCallQueueCriteriaRepository.GetCriteriaByHealthPlanCallQueue(healthPlan.Id, HealthPlanCallQueueCategory.MailRound); if (!_settings.GmsCampaignIds.IsNullOrEmpty()) { criterias = _healthPlanCallQueueCriteriaRepository.GetByCampaignIds(_settings.GmsCampaignIds, healthPlan.Id); _logger.Info(string.Format("Found {0} criterias for Campaign IDs : ", criterias.Count(), string.Join(",", _settings.GmsCampaignIds))); } foreach (var criteria in criterias) { if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount) { break; } _logger.Info(string.Format("Criteria ID : {0}", criteria.Id)); try { var filter = new OutboundCallQueueFilter { CallQueueId = callQueue.Id, CriteriaId = criteria.Id, CampaignId = criteria.CampaignId, Tag = healthPlan.Tag, HealthPlanId = healthPlan.Id, UseCustomTagExclusively = false }; if (filter.HealthPlanId == _settings.OptumUtAccountId) { filter.CustomCorporateTag = _settings.OptumUtCustomTagsForGms; } else if (filter.HealthPlanId == 1083) { filter.CustomCorporateTag = "UHC-TX_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1066) { filter.CustomCorporateTag = "Excellus_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1061) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-1_GMS,Optum-NV_Assessments_2018_List-2_GMS,Optum-NV_Assessments_2018_List-3_GMS,Optum-NV_Mammo_2018_List-2_GMS"; } else if (filter.HealthPlanId == 1111) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-4_GMS"; } else if (filter.HealthPlanId == 1087) { filter.CustomCorporateTag = "UHC-AZ_Assessments_2018_List-1_GMS"; } else if (filter.HealthPlanId == 1093) { filter.CustomCorporateTag = "UHC-CT_Assessments_2018_List-1_GMS"; } _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter); var dataGen = new ExportableDataGenerator <GmsCallQueueCustomerViewModel, OutboundCallQueueFilter>(_callQueueCustomerReportService.GetGmsCallQueueCustomersReport, _logger); var model = dataGen.GetData(filter); var distinctCustomers = model.Collection.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId)); collection.AddRange(distinctCustomers); } catch (Exception ex) { _logger.Error("Error getting call queue customers for Account ID : " + healthPlan.Id + " Criteria ID : " + criteria.Id); _logger.Error(ex); } } } if (!collection.Any()) { _logger.Info("No records found."); return; } if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount) { collection = collection.Take(_settings.GmsMaxCustomerCount).ToList(); } if (!Directory.Exists(_settings.GmsCustomerReportPath)) { Directory.CreateDirectory(_settings.GmsCustomerReportPath); } var fileName = _settings.GmsCustomerReportPath + @"\" + string.Format("PatientList_{0}.csv", DateTime.Today.ToString("yyyyMMdd")); WriteCsv(collection, fileName); if (_settings.SendReportToGmsSftp) { _logger.Info("Sending Customer List to GMS sftp."); var sftpFolderReportDirectory = _settings.GmsSftpPath; var processFtp = new ProcessFtp(_logger, _settings.GmsSftpHost, _settings.GmsSftpUserName, _settings.GmsSftpPassword); processFtp.UploadSingleFile(fileName, sftpFolderReportDirectory, ""); _logger.Info("Sent Customer List to GMS sftp."); } else { _logger.Info("Setting to send Customer list to sftp is OFF."); } }
public void PollForReport() { if (_healthPlanIds.IsNullOrEmpty()) { _logger.Info("No Health Plan IDs found."); return; } var healthPlans = _corporateAccountRepository.GetByIds(_healthPlanIds); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); var collection = new List <GmsExcludedCustomerViewModel>(); foreach (var healthPlan in healthPlans) { _logger.Info("Getting excluded customers for Account ID : " + healthPlan.Id); var criterias = _healthPlanCallQueueCriteriaRepository.GetCriteriaForMailRoundGms(healthPlan.Id); if (!_settings.GmsCampaignIds.IsNullOrEmpty()) { criterias = _healthPlanCallQueueCriteriaRepository.GetByCampaignIds(_settings.GmsCampaignIds, healthPlan.Id); _logger.Info(string.Format("Found {0} criterias for Campaign IDs : ", criterias.Count(), string.Join(",", _settings.GmsCampaignIds))); } foreach (var criteria in criterias) { _logger.Info("Criteria ID : " + criteria.Id); try { var filter = new OutboundCallQueueFilter { CallQueueId = callQueue.Id, CriteriaId = criteria.Id, CampaignId = criteria.CampaignId, Tag = healthPlan.Tag, HealthPlanId = healthPlan.Id, UseCustomTagExclusively = false }; if (filter.HealthPlanId == _settings.OptumUtAccountId) { filter.CustomCorporateTag = _settings.OptumUtCustomTagsForGms; } else if (filter.HealthPlanId == 1083) { filter.CustomCorporateTag = "UHC-TX_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1066) { filter.CustomCorporateTag = "Excellus_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1061) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-1_GMS,Optum-NV_Assessments_2018_List-2_GMS,Optum-NV_Assessments_2018_List-3_GMS,Optum-NV_Mammo_2018_List-2_GMS"; } else if (filter.HealthPlanId == 1111) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-4_GMS"; } else if (filter.HealthPlanId == 1087) { filter.CustomCorporateTag = "UHC-AZ_Assessments_2018_List-1_GMS"; } else if (filter.HealthPlanId == 1093) { filter.CustomCorporateTag = "UHC-CT_Assessments_2018_List-1_GMS"; } var excludedCustomerCollection = _gmsExcludedCustomerService.GetGmsExcludedCustomers(filter, callQueue); var distinctCustomers = excludedCustomerCollection.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId)); collection.AddRange(distinctCustomers); } catch (Exception ex) { _logger.Error("Error getting excluded customers for Account ID : " + healthPlan.Id + " Criteria ID : " + criteria.Id); _logger.Error(ex); } } _logger.Info("Completed for Account ID : " + healthPlan.Id); } var excludedPath = _settings.GmsExcludeReportDownloadCustomerPath; if (DirectoryOperationsHelper.CreateDirectoryIfNotExist(excludedPath)) { var fileName = Path.Combine(excludedPath, string.Format("ExcludedPatientList_{0}.csv", DateTime.Today.ToString("yyyyMMdd"))); WriteCsv(collection, fileName); } else { _logger.Error("Folder can not be created"); } }