コード例 #1
0
        public void PollForAppointmentBookExport()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    return;
                }
                var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds);

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

                        var fromDate = DateTime.Now.Year > _cutOfDate.Date.Year ? DateTime.Today.GetFirstDateOfYear() : _cutOfDate;

                        var destinationPath     = string.Format(_optumAppointmentBookedReportDownloadPath, account.FolderName, fromDate.Year);
                        var appointmentSettings = string.Format(_appointmentSettings, account.Tag);
                        var customSettings      = _customSettingManager.Deserialize(appointmentSettings);

                        try
                        {
                            DirectoryOperationsHelper.DeleteDirectory(destinationPath, true);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("Some error occurred while deleting directory at path: " + destinationPath);
                            _logger.Error("Message: " + ex.Message);
                            _logger.Error("Stack Trace: " + ex.StackTrace);
                        }

                        var toDate = DateTime.Today.GetLastDateOfYear();

                        AppointmentsBooked(new AppointmentsBookedListModelFilter {
                            EventFrom = fromDate, EventTo = toDate.Date, AccountId = account.Id, Tag = account.Tag
                        }, destinationPath);

                        var fileName = destinationPath + string.Format(@"\AppointmentBookedReport_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));

                        if (DirectoryOperationsHelper.IsFileExist(fileName))
                        {
                            _pgpFileEncryptionHelper.EncryptFile(account, fileName);
                        }

                        customSettings.LastTransactionDate = toDate;
                        _customSettingManager.SerializeandSave(appointmentSettings, customSettings);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("Exception For AccountId {0} and Account Tag {1} : \n Error {2} \n Trace: {3} \n\n\n", account.Id, account.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Main App: \n Error {0} \n Trace: {1} \n\n\n", ex.Message, ex.StackTrace));
            }
        }
コード例 #2
0
        private void MoveFileToArchive(string sourceFolder, string destinationFolder)
        {
            _logger.Info("Moving directory to archive folder.");
            var directories = DirectoryOperationsHelper.GetDirectories(sourceFolder);

            if (directories == null || !directories.Any())
            {
                _logger.Info("No directory found to move into archive.");
                return;
            }

            directories = directories.Where(x => !x.Contains(DateTime.Today.Year.ToString())).ToArray();

            if (directories.Any())
            {
                foreach (var dir in directories)
                {
                    var files = DirectoryOperationsHelper.GetFiles(dir, "*.pdf");
                    if (!files.Any())
                    {
                        _logger.Info("No files found in Directory: " + dir + "to move into archive.");
                        continue;
                    }

                    _logger.Info(string.Format("{0} files found in directory: {1}.", files.Count(), dir));

                    var folderName = Path.GetFileName(dir.TrimEnd(Path.DirectorySeparatorChar));

                    var destinationPath = Path.Combine(destinationFolder, folderName);
                    DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationPath);

                    foreach (var file in files)
                    {
                        if (DirectoryOperationsHelper.IsFileExist(file))
                        {
                            var fileName            = Path.GetFileName(file);
                            var destinationFileName = Path.Combine(destinationPath, fileName);
                            try
                            {
                                DirectoryOperationsHelper.DeleteFileIfExist(destinationFileName);
                                DirectoryOperationsHelper.Move(file, destinationFileName);
                                _logger.Info(string.Format("{0} file moved into {1} from directory: {2}.", fileName, destinationPath, dir));
                            }
                            catch (Exception ex)
                            {
                                _logger.Error(string.Format("Exception occurred while moving file {0} to {1}. \nException Message: {2}\n\tStackTrace:{3}", file, destinationFileName, ex.Message, ex.StackTrace));
                            }
                        }
                    }

                    DirectoryOperationsHelper.DeleteDirectory(dir);
                }
            }
        }
コード例 #3
0
        public void PollForParsing()
        {
            try
            {
                var timeOfDay = DateTime.Now;

                if (_isDevEnvironment || timeOfDay.TimeOfDay > new TimeSpan(4, 0, 0))
                {
                    _logger.Info("Service started...");
                    var directoryInfo = DirectoryOperationsHelper.GetDirectories(_hkynParsePdfPath);

                    if (directoryInfo.IsNullOrEmpty())
                    {
                        _logger.Info("No Directory found for Parsing");
                        return;
                    }

                    foreach (var dirPath in directoryInfo)
                    {
                        try
                        {
                            var dirInfo = DirectoryOperationsHelper.GetDirectoryInfo(dirPath);
                            if (dirInfo != null)
                            {
                                var files = DirectoryOperationsHelper.GetFiles(dirPath, "*.Pdf");


                                long eventid = 0;
                                long.TryParse(dirInfo.Name, out eventid);

                                if (eventid > 0)
                                {
                                    var eventData = _eventRepository.GetById(eventid);

                                    if (files.IsNullOrEmpty())
                                    {
                                        _logger.Info("No file found inside " + dirInfo.Name);
                                        if (eventData.EventDate > DateTime.Today.AddDays(-DeleteEmptyFolderAfter))
                                        {
                                            DirectoryOperationsHelper.DeleteDirectory(dirPath, true);
                                        }
                                        continue;
                                    }

                                    ParseFilesForCustomer(dirPath, eventid);
                                }
                                else
                                {
                                    _logger.Info("folder does not contain valid Name: " + dirInfo.Name);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("Some error occurred for Dir Path: " + dirPath);
                            _logger.Error("Message: " + ex.Message);
                            _logger.Error("Stack Trace: " + ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Some error occurred while parsing");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
        }
コード例 #4
0
        public void PollForPdfDownload()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    return;
                }
                var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds);

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

                        var destinationFolderPdf  = string.Format(_destinationFolderPdfSetting, corporateAccount.FolderName);
                        var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag);
                        var customSettings        = _customSettingManager.Deserialize(customSettingFilePath);

                        var exportToTime   = DateTime.Now.AddHours(-1);
                        var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate;

                        bool     inclcludeCustomTag = false;
                        string[] CustomTags         = null;
                        var      considerEventDate  = true;

                        DateTime?eventCutOfDate = _settings.PPEventCutOfDate;

                        if (corporateAccount.Id == _settings.HealthNowAccountId)
                        {
                            CustomTags         = _settings.HealthNowCustomTags;
                            inclcludeCustomTag = true;
                        }
                        if (corporateAccount.Id == _settings.ExcellusAccountId)
                        {
                            CustomTags         = _settings.ExcellusCustomTags;
                            inclcludeCustomTag = true;
                        }

                        if (corporateAccount.Id == _settings.PPAccountId)
                        {
                            considerEventDate = true;
                        }

                        DateTime?stopSendingPdftoHealthPlanDate = null;
                        if (corporateAccount.IsHealthPlan)
                        {
                            stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate;
                        }

                        var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime,
                                                                                                               corporateAccount.Id, corporateAccount.Tag, true, CustomTags, inclcludeCustomTag, considerEventDate, eventCutOfDate
                                                                                                               , stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate);

                        var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray();
                        customerResults = customerResults ?? new EventCustomerResult[] { };

                        var resultNotPostedFileName       = string.Format("ResultNotPostedto_{0}.xml", corporateAccount.Tag);
                        var resultNotPostedToPlanFileName = Path.Combine(_settings.ResultNotPostedToPlanPath, resultNotPostedFileName);

                        var resultNotPosted = _resultPdfNotPostedSerializer.Deserialize(resultNotPostedToPlanFileName);
                        resultNotPosted = resultNotPosted == null || resultNotPosted.EventCustomer.IsNullOrEmpty() ? new ResultPdfNotPosted {
                            EventCustomer = new List <EventCustomerInfo>()
                        } : resultNotPosted;

                        if (resultNotPosted.EventCustomer.Count > 0)
                        {
                            var eventCustomerIds = resultNotPosted.EventCustomer.Select(x => x.EventCustomerId);

                            if (!customerResults.IsNullOrEmpty())
                            {
                                var freshCustomerEventCustomerIds = customerResults.Select(x => x.Id);
                                eventCustomerIds = (from q in eventCustomerIds where !freshCustomerEventCustomerIds.Contains(q) select q).ToList();
                            }


                            int totalRecords = eventCustomerIds.Count();
                            int pageNumber   = 0;
                            int pagesize     = 100;

                            while (true)
                            {
                                if (totalRecords < 1)
                                {
                                    break;
                                }

                                var totalItems  = pageNumber * pagesize;
                                var customerIds = eventCustomerIds.Skip(totalItems).Take(pagesize);
                                var resultNotPostedEventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsByIdsAndResultState(customerIds, (int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false);

                                if (!resultNotPostedEventCustomerResults.IsNullOrEmpty())
                                {
                                    var resultReports = resultNotPostedEventCustomerResults.ToArray();

                                    if (customerResults.IsNullOrEmpty())
                                    {
                                        customerResults = resultReports.ToArray();
                                    }
                                    else
                                    {
                                        customerResults = customerResults.Concat(resultReports).ToArray();
                                    }
                                }
                                pageNumber++;

                                if (totalItems >= totalRecords)
                                {
                                    break;
                                }
                            }
                        }

                        resultNotPosted.EventCustomer = !resultNotPosted.EventCustomer.IsNullOrEmpty() ? new List <EventCustomerInfo>() : resultNotPosted.EventCustomer;

                        if (eventCustomerResults == null || !customerResults.Any())
                        {
                            _logger.Info(string.Format("No event customer result list for {0} Result Pdf Download.", corporateAccount.Tag));
                            continue;
                        }

                        _logger.Info(string.Format("Found {0} customers for {1} Result Pdf Download. ", eventCustomerResults.Count(), corporateAccount.Tag));

                        var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport();

                        var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport();

                        var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag));
                        var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName);

                        resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml {
                            Customer = new List <CustomerInfo>()
                        } : resultPosted;
                        var resultPostedCustomer = new List <CustomerInfo>();

                        var healthPlanDownloadPath = Path.Combine(string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName), string.Format("ResultPDFs_{0}", DateTime.Now.ToString("yyyyMMdd")));

                        foreach (var ecr in customerResults)
                        {
                            var sourceUrl = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport;

                            if (!DirectoryOperationsHelper.IsFileExist(sourceUrl))
                            {
                                sourceUrl = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport;
                            }

                            if (DirectoryOperationsHelper.IsFileExist(sourceUrl))
                            {
                                try
                                {
                                    string fileName = ecr.CustomerId.ToString();

                                    var eventDirectoryPdf = Path.Combine(destinationFolderPdf, ecr.EventId.ToString());
                                    var customer          = _customerRepository.GetCustomer(ecr.CustomerId);
                                    var theEvent          = _eventRepository.GetById(ecr.EventId);

                                    if (corporateAccount.Id == _martinsPointExclusiveAccountId)
                                    {
                                        fileName = "Exclusive_" + customer.InsuranceId;
                                    }
                                    else if (corporateAccount.Id == _settings.ExcellusAccountId)
                                    {
                                        fileName = customer.InsuranceId;
                                    }
                                    else if (corporateAccount.Id == _settings.HealthNowAccountId)
                                    {
                                        fileName          = customer.InsuranceId;
                                        eventDirectoryPdf = healthPlanDownloadPath;
                                    }
                                    else if (corporateAccount.Id == _settings.AppleCareAccountId)
                                    {
                                        if (!string.IsNullOrEmpty(customer.InsuranceId))
                                        {
                                            fileName = string.Format("{0}_{1}", customer.InsuranceId, theEvent.EventDate.ToString("yyyyMMdd"));
                                        }
                                        else
                                        {
                                            fileName = string.Format("NoMember_{0}_{1}", customer.CustomerId, theEvent.EventDate.ToString("yyyyMMdd"));
                                        }

                                        fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, fileName, (long)ResultFormatType.PDF);
                                    }
                                    else if (corporateAccount.Id == _settings.MedMutualAccountId)
                                    {
                                        if (!string.IsNullOrEmpty(customer.InsuranceId))
                                        {
                                            fileName = string.Format("{0}_{1}", customer.InsuranceId, theEvent.EventDate.ToString("yyyyMMdd"));
                                        }
                                        else
                                        {
                                            fileName = string.Format("NoMember_{0}_{1}", customer.CustomerId, theEvent.EventDate.ToString("yyyyMMdd"));
                                        }

                                        eventDirectoryPdf = healthPlanDownloadPath;

                                        fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, fileName, (long)ResultFormatType.PDF);
                                    }
                                    else if (corporateAccount.Id == _settings.ConnecticareAccountId)
                                    {
                                        if (!string.IsNullOrEmpty(customer.InsuranceId))
                                        {
                                            fileName = customer.InsuranceId + "_" + customer.Name.LastName + "_" + customer.Name.FirstName + " " + customer.Name.MiddleName
                                                       + theEvent.EventDate.ToString("yyyy-MM-dd") + "_HF_COMM";
                                        }

                                        else
                                        {
                                            fileName = customer.Name.LastName + "_" + customer.Name.FirstName + " " + customer.Name.MiddleName
                                                       + theEvent.EventDate.ToString("yyyy-MM-dd") + "_HF_COMM";
                                        }

                                        eventDirectoryPdf = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                                    }
                                    else if (corporateAccount.Id == _settings.ConnecticareMaAccountId)
                                    {
                                        if (!string.IsNullOrEmpty(customer.InsuranceId))
                                        {
                                            fileName = customer.InsuranceId + "_" + customer.Name.LastName + "_" + customer.Name.FirstName + " " + customer.Name.MiddleName
                                                       + theEvent.EventDate.ToString("yyyy-MM-dd") + "_HF_MCR";
                                        }

                                        else
                                        {
                                            fileName = customer.Name.LastName + "_" + customer.Name.FirstName + " " + customer.Name.MiddleName
                                                       + theEvent.EventDate.ToString("yyyy-MM-dd") + "_HF_MCR";
                                        }

                                        eventDirectoryPdf = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                                    }
                                    else if (corporateAccount.Id == _settings.BcbsAlAccountId)
                                    {
                                        if (!string.IsNullOrEmpty(customer.InsuranceId))
                                        {
                                            fileName = customer.CustomerId + "_" + customer.Name.FirstName + " " + customer.Name.LastName + "_" + customer.InsuranceId;
                                        }
                                        else
                                        {
                                            fileName = customer.CustomerId + "_" + customer.Name.FirstName + " " + customer.Name.LastName;
                                        }

                                        eventDirectoryPdf = destinationFolderPdf + "\\" + ecr.EventId + "_" + DateTime.Today.ToString("MM-dd-yyyy");
                                    }
                                    else if (corporateAccount.Id == _settings.FloridaBlueFepAccountId)
                                    {
                                        if (!string.IsNullOrEmpty(customer.InsuranceId))
                                        {
                                            fileName = string.Format("GWC_CW_{0}", customer.InsuranceId);
                                        }

                                        else
                                        {
                                            fileName = string.Format("GWC_CW_NoMemberId_{0}", customer.CustomerId);
                                        }

                                        eventDirectoryPdf = Path.Combine(string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName), "PDFs");
                                    }
                                    else if (corporateAccount.Id == _settings.PPAccountId)
                                    {
                                        fileName          = theEvent.Id + "_" + customer.CustomerId;
                                        eventDirectoryPdf = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                                    }
                                    else if (corporateAccount.Id == _settings.NammAccountId)
                                    {
                                        fileName          = theEvent.Id + "_" + customer.CustomerId;
                                        eventDirectoryPdf = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName);
                                    }

                                    if (corporateAccount.MarkPennedBack && ecr.IsPennedBack)
                                    {
                                        fileName += "_" + corporateAccount.PennedBackText;
                                    }

                                    if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF)
                                    {
                                        var destinationFileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, fileName, (long)ResultFormatType.PDF);
                                        var pdfFileName         = destinationFileName + ".pdf";
                                        var pdfResultFile       = Path.Combine(eventDirectoryPdf, pdfFileName);
                                        _resultPdfDownloadHelper.ExportResultInPdfFormat(pdfFileName, sourceUrl, eventDirectoryPdf);

                                        var isFilePosted = true;

                                        if (DirectoryOperationsHelper.IsFileExist(pdfResultFile))
                                        {
                                            var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, pdfResultFile);

                                            if (_settings.SendReportToHcpNv && _settings.HcpNvAccountId == corporateAccount.Id)
                                            {
                                                isFilePosted = ExportResultOnHcpNvSftp(ecr.CustomerId + ".pdf", sourceUrl, ecr.EventId);
                                            }

                                            if (_settings.BcbsAlAccountId == corporateAccount.Id)
                                            {
                                                var sftpSettings = _sftpCridentialManager.Deserialize(_settings.SftpResouceFilePath + corporateAccount.Tag + ".xml");

                                                isFilePosted = ExportFileOnClientSftp(pdfResultFile, _settings.BcbsAlSftpDownloadPath + "Individual Member Results (PDFs)\\" + ecr.EventId + "_" + DateTime.Today.ToString("MM-dd-yyyy"), sftpSettings);
                                            }

                                            if (corporateAccount.Id == _settings.FloridaBlueFepAccountId)
                                            {
                                                var destinationSftpPath = _settings.FloridaBlueSftpPath + "\\" + corporateAccount.FolderName + "\\Download\\PDfs";
                                                isFilePosted = UploadSingleFile(pdfResultFile, destinationSftpPath, _settings.FloridaBlueSftpHost, _settings.FloridaBlueSftpUserName, _settings.FloridaBlueSftpPassword);
                                            }

                                            if (isFilePosted)
                                            {
                                                resultPostedCustomer.Add(_resultPdfFileHelper.GetCustomerInfo(theEvent, Path.GetFileName(pgpFilePath), (long)ResultFormatType.PDF, customer, ecr.Id));
                                            }
                                            else
                                            {
                                                resultNotPosted.EventCustomer.Add(new EventCustomerInfo
                                                {
                                                    EventCustomerId = ecr.Id,
                                                    EventId         = ecr.EventId,
                                                    CustomerId      = ecr.CustomerId,
                                                    Error           = "File Not posted on Client SFTP."
                                                });
                                            }

                                            _logger.Info("destination: " + pdfResultFile);
                                            _logger.Info("Source: " + sourceUrl);
                                        }
                                        else
                                        {
                                            resultNotPosted.EventCustomer.Add(new EventCustomerInfo
                                            {
                                                EventCustomerId = ecr.Id,
                                                EventId         = ecr.EventId,
                                                CustomerId      = ecr.CustomerId,
                                                Error           = "file not Moved on HIP SFTP."
                                            });
                                        }
                                    }

                                    if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF)
                                    {
                                        var destinationFileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, fileName, (long)ResultFormatType.TIF);
                                        var tipResultFile       = Path.Combine(eventDirectoryPdf, destinationFileName + ".tif");
                                        _resultPdfDownloadHelper.ExportResultInTiffFormat(destinationFileName + ".tif", sourceUrl, eventDirectoryPdf);

                                        var isFilePosted = true;
                                        var pgpFilePath  = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, tipResultFile);

                                        if (DirectoryOperationsHelper.IsFileExist(tipResultFile))
                                        {
                                            if (_settings.SendReportToHcpNv && _settings.HcpNvAccountId == corporateAccount.Id)
                                            {
                                                isFilePosted = ExportResultOnHcpNvSftp(ecr.CustomerId + ".tif", sourceUrl, ecr.EventId, false);
                                            }

                                            if (_settings.BcbsAlAccountId == corporateAccount.Id)
                                            {
                                                var sftpSettings = _sftpCridentialManager.Deserialize(_settings.SftpResouceFilePath + corporateAccount.Tag + ".xml");
                                                isFilePosted = ExportFileOnClientSftp(tipResultFile, _settings.BcbsAlSftpDownloadPath + "Individual Member Results (PDFs)\\" + ecr.EventId + "_" + DateTime.Today.ToString("MM-dd-yyyy"), sftpSettings);
                                            }
                                            if (isFilePosted)
                                            {
                                                resultPostedCustomer.Add(_resultPdfFileHelper.GetCustomerInfo(theEvent, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customer, ecr.Id));
                                            }
                                            else
                                            {
                                                resultNotPosted.EventCustomer.Add(new EventCustomerInfo
                                                {
                                                    EventCustomerId = ecr.Id,
                                                    EventId         = ecr.EventId,
                                                    CustomerId      = ecr.CustomerId,
                                                    Error           = "File Not posted on Client SFTP."
                                                });
                                            }

                                            _logger.Info("destination: " + tipResultFile);
                                            _logger.Info("Source: " + sourceUrl);
                                        }
                                        else
                                        {
                                            resultNotPosted.EventCustomer.Add(new EventCustomerInfo
                                            {
                                                EventCustomerId = ecr.Id,
                                                EventId         = ecr.EventId,
                                                CustomerId      = ecr.CustomerId,
                                                Error           = "file not Moved on HIP SFTP."
                                            });
                                        }
                                    }
                                }
                                catch (Exception exception)
                                {
                                    resultNotPosted.EventCustomer.Add(new EventCustomerInfo
                                    {
                                        EventCustomerId = ecr.Id,
                                        EventId         = ecr.EventId,
                                        CustomerId      = ecr.CustomerId,
                                        Error           = "file not Moved on HIP SFTP."
                                    });

                                    _logger.Error(string.Format("some error occurred for the customerId {0}, {1},\n Message {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace));
                                }
                            }
                            else
                            {
                                _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId));

                                resultNotPosted.EventCustomer.Add(new EventCustomerInfo
                                {
                                    EventCustomerId = ecr.Id,
                                    EventId         = ecr.EventId,
                                    CustomerId      = ecr.CustomerId,
                                    Error           = "File not generated or removed."
                                });
                            }
                        }

                        if (corporateAccount.Id == _settings.HealthNowAccountId || corporateAccount.Id == _settings.MedMutualAccountId)
                        {
                            if (DirectoryOperationsHelper.IsDirectoryExist(healthPlanDownloadPath) &&
                                DirectoryOperationsHelper.GetFiles(healthPlanDownloadPath).Any())
                            {
                                var isZipFileCreated = false;
                                try
                                {
                                    _zipHelper.CreateZipFiles(healthPlanDownloadPath);
                                    isZipFileCreated = true;
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error(string.Format("some error occurred while creating zip file for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ",
                                                                corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace));
                                }

                                if (isZipFileCreated)
                                {
                                    resultPosted.Customer.AddRange(resultPostedCustomer);
                                }
                                else
                                {
                                    resultNotPosted.EventCustomer.AddRange(
                                        resultPostedCustomer.Select(x => new EventCustomerInfo
                                    {
                                        EventCustomerId = x.EventCustomerId,
                                        CustomerId      = x.CustomerId,
                                        EventId         = x.EventId,
                                        Error           = "Error occurred while creating zip file."
                                    }));
                                }
                            }

                            DirectoryOperationsHelper.DeleteDirectory(healthPlanDownloadPath, true);
                        }
                        else
                        {
                            resultPosted.Customer.AddRange(resultPostedCustomer);
                        }

                        customSettings.LastTransactionDate = exportToTime;
                        _customSettingManager.SerializeandSave(customSettingFilePath, customSettings);

                        CorrectandSaveResultPosted(resultPosted, corporateAccount);
                        _resultPdfNotPostedSerializer.SerializeandSave(resultNotPostedToPlanFileName, resultNotPosted);

                        if (resultNotPosted.EventCustomer.Count > 0)
                        {
                            _resultPdfEmailNotificationHelper.SendEmailNotificationForFileNotPosted(corporateAccount.Tag, resultNotPosted.EventCustomer.Count, _logger);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("some error occurred for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("some error occurred Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace));
            }
        }
コード例 #5
0
        public void HealthPlanIncorrectPhoneCustomerExport(DateTime cutOffDate, string destinationFileFormate, ILogger logger)
        {
            var healthPlans = _corporateAccountRepository.GetAllHealthPlan();

            if (healthPlans.IsNullOrEmpty())
            {
                logger.Info("No Healthplan exists");
                return;
            }

            if (!_settings.DoNotSendHomeVistIncorrectPhoneNumberAccountIds.IsNullOrEmpty())
            {
                healthPlans = healthPlans.Where(hp => !_settings.DoNotSendHomeVistIncorrectPhoneNumberAccountIds.Contains(hp.Id));
            }

            logger.Info("Starting Corporate Customer Export for Incorrect Phone Number");

            foreach (var corporateAccount in healthPlans)
            {
                if ((corporateAccount.Id == _settings.WellmedAccountId || corporateAccount.Id == _settings.WellmedTxAccountId))
                {
                    if (DateTime.Today.DayOfWeek != _settings.WellmedIncorrectPhoneNumberDayOfWeek)
                    {
                        logger.Info("Day of the week is " + ((long)DateTime.Today.DayOfWeek) + " Account Id: " + corporateAccount.Id);
                        continue;
                    }
                }
                //else if (corporateAccount.Id == _settings.HcpNvAccountId)
                //{
                //    if ((long)DateTime.Today.DayOfWeek != _settings.HcpNvIncorrectPhoneNumberDayOfWeek)
                //    {
                //        logger.Info("Today is Day of Week is " + DateTime.Today.DayOfWeek);
                //        logger.Info("Service will run on Day of Week " +
                //                     (DayOfWeek)_settings.HcpNvIncorrectPhoneNumberDayOfWeek);
                //        continue;
                //    }
                //}
                else if (DateTime.Today.DayOfWeek != _dayOfWeek)
                {
                    logger.Info("Day of the week is " + ((long)DateTime.Today.DayOfWeek) + " Account Id: " + corporateAccount.Id);
                    continue;
                }


                var filter = new HealthPlanCustomerIncorrectPhoneExportFilter
                {
                    CorporateTag = corporateAccount.Tag,
                    StartDate    = cutOffDate
                };

                if (corporateAccount.Id == _settings.HealthNowAccountId)
                {
                    filter.CustomTags = _settings.HealthNowCustomTags;
                }
                else if (corporateAccount.Id == _settings.ExcellusAccountId)
                {
                    filter.CustomTags = _settings.ExcellusCustomTags;
                }

                logger.Info(string.Format("Starting for Corporate Tag: {0} StartDate: {1}", filter.CorporateTag, filter.StartDate.ToShortDateString()));

                var list = IncorrectPhoneNumberExportReport(filter, logger);

                if (!list.Any())
                {
                    continue;
                }

                var destinationFolderPath = string.Format(destinationFileFormate, corporateAccount.FolderName, DateTime.Today.Year);

                var fileName = "IncorrectPhoneNumber.csv";

                if (_settings.OptumIncorrectPhoneNumberAccountIds.Contains(corporateAccount.Id))
                {
                    destinationFolderPath = string.Format(_settings.OptumIncorrectPhoneNumberDownloadPath, corporateAccount.FolderName);
                    fileName = "IncorrectPhoneNumber" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                else if (corporateAccount.Id == _martinsPointExclusiveAccountId)
                {
                    fileName = "Exclusive_IncorrectPhoneNumber.csv";
                }
                else if (corporateAccount.Id == _settings.ExcellusAccountId)
                {
                    destinationFolderPath = Directory.GetParent(destinationFolderPath).FullName;
                    fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.HealthNowAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "IncorrectPhoneNumber*.csv");
                }
                else if (corporateAccount.Id == _settings.MedMutualAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "IncorrectPhoneNumbers_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "IncorrectPhoneNumbers*.csv");
                }
                else if (corporateAccount.Id == _settings.WellmedWellCareAccountId)
                {
                    var wellmedAccount = healthPlans.FirstOrDefault(x => x.Id == _settings.WellmedAccountId);
                    if (wellmedAccount != null)
                    {
                        destinationFolderPath = string.Format(destinationFileFormate, wellmedAccount.FolderName, DateTime.Today.Year);

                        fileName = "WCR_IncorrectPhoneNumbers_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    }

                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "WCR_IncorrectPhoneNumbers*.csv");
                }
                else if (corporateAccount.Id == _settings.ConnecticareAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "Comm Incorrect Phone Number " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.ConnecticareMaAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "MCR Incorrect Phone Number " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.BcbsScAccountId || corporateAccount.Id == _settings.BcbsScAssessmentAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName);
                }
                else if (corporateAccount.Id == _settings.FloridaBlueFepAccountId)
                {
                    destinationFolderPath = Path.Combine(string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName), "Reports");
                    fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "IncorrectPhoneNumber*.csv");
                }
                else if (corporateAccount.Id == _settings.PPAccountId)
                {
                    logger.Info("PP Account");
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.NammAccountId)
                {
                    logger.Info("Namm Account Id");
                    destinationFolderPath = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName);
                    fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                //else if (corporateAccount.Id == _settings.HcpNvAccountId)
                //{

                //    logger.Info("HCP NV");
                //    var folderName = _settings.HcpNvFolder;
                //    destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "IncorrectPhone");
                //    fileName = string.Format("IncorrectPhoneNumber_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy"));
                //}
                else if (corporateAccount.Id == _settings.WellmedAccountId)
                {
                    logger.Info("Wellmed FL");
                    var folderName = _settings.WellmedFlFolder;
                    destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "IncorrectPhone");
                    fileName = string.Format("IncorrectPhoneNumber_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy"));
                }
                else if (corporateAccount.Id == _settings.WellmedTxAccountId)
                {
                    logger.Info("Wellmed TX");
                    var folderName = _settings.WellmedTxFolder;
                    destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "IncorrectPhone");
                    fileName = string.Format("IncorrectPhoneNumber_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy"));
                }

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

                if (!Directory.Exists(destinationFolderPath))
                {
                    Directory.CreateDirectory(destinationFolderPath);
                }

                var destinationFileName = Path.Combine(destinationFolderPath, fileName);

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

                logger.Info(string.Format("Corporate Tag: {0} StartDate: {1} Create CSV at Path: {2} ", filter.CorporateTag, filter.StartDate.ToShortDateString(), destinationFileName));

                WriteCsv(destinationFileName, list, logger);

                //if (File.Exists(destinationFileName))
                //{
                //    if (corporateAccount.Id == _settings.FloridaBlueFepAccountId && _settings.SendReportToFloridaBlueSftp)
                //    {
                //        var destinationSftpPath = _settings.FloridaBlueSftpPath + "\\" + corporateAccount.FolderName + "\\Download\\Reports";
                //        PostFile(destinationFileName, destinationSftpPath, _settings.FloridaBlueSftpHost, _settings.FloridaBlueSftpUserName, _settings.FloridaBlueSftpPassword, fileName, logger);
                //    }
                //    else
                //    {
                //        SendIncorrectPhoneNumberClientSftp(corporateAccount, destinationFileName, logger);
                //    }

                //}
            }
        }
コード例 #6
0
        public void HealthPlanHomeVisitRequestedCustomerExport(DateTime cutOffDate, string destinationFileFormate, ILogger logger)
        {
            var healthPlans = _corporateAccountRepository.GetAllHealthPlan();

            if (healthPlans.IsNullOrEmpty())
            {
                logger.Info("No Healthplan exists");
                return;
            }

            if (!_settings.DoNotSendHomeVistIncorrectPhoneNumberAccountIds.IsNullOrEmpty())
            {
                healthPlans = healthPlans.Where(hp => !_settings.DoNotSendHomeVistIncorrectPhoneNumberAccountIds.Contains(hp.Id));
            }

            logger.Info("Starting Corporate Customer Export for Home Vist Requested");

            foreach (var corporateAccount in healthPlans)
            {
                var filter = new HealthPlanCustomerExportFilter
                {
                    CallStatus   = CallStatus.Attended,
                    CorporateTag = corporateAccount.Tag,
                    StartDate    = cutOffDate,
                    Tag          = ProspectCustomerTag.HomeVisitRequested
                };

                if (corporateAccount.Id == _settings.HealthNowAccountId)
                {
                    filter.CustomTags = _settings.HealthNowCustomTags;
                }

                if (corporateAccount.Id == _settings.ExcellusAccountId)
                {
                    filter.CustomTags = _settings.ExcellusCustomTags;
                }

                logger.Info(string.Format("Starting for Corporate Tag: {0} StartDate: {1}", filter.CorporateTag, filter.StartDate.ToShortDateString()));

                var list = HomeVisitExportCustomerReport(filter, logger);

                if (!list.Any())
                {
                    continue;
                }

                var destinationFolderPath = string.Format(destinationFileFormate, corporateAccount.FolderName, DateTime.Today.Year);

                var fileName = "HomeVisitRequested.csv";

                if (_settings.OptumHomeVisitRequesedAccountIds.Contains(corporateAccount.Id))
                {
                    destinationFolderPath = string.Format(_settings.OptumHomeVisitRequesedDownloadPath, corporateAccount.FolderName);
                    fileName = "HomeVisitRequested" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                else if (corporateAccount.Id == _martinsPointExclusiveAccountId)
                {
                    fileName = "Exclusive_HomeVisitRequested.csv";
                }
                else if (corporateAccount.Id == _settings.ExcellusAccountId)
                {
                    destinationFolderPath = Directory.GetParent(destinationFolderPath).FullName;
                    fileName = "HomeVisitRequest_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.HealthNowAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "HomeVisitRequest_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "HomeVisitRequest*.csv");
                }
                else if (corporateAccount.Id == _settings.MedMutualAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "HomeVisitRequest_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "HomeVisitRequest*.csv");
                }
                else if (corporateAccount.Id == _settings.WellmedWellCareAccountId)
                {
                    var wellmedAccount = healthPlans.FirstOrDefault(x => x.Id == _settings.WellmedAccountId);
                    if (wellmedAccount != null)
                    {
                        destinationFolderPath = string.Format(destinationFileFormate, wellmedAccount.FolderName, DateTime.Today.Year);

                        fileName = "WCR_HomeVisitRequest_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                    }

                    DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "WCR_HomeVisitRequest*.csv");
                }
                else if (corporateAccount.Id == _settings.ConnecticareAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "Comm Home Visit Req " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.ConnecticareMaAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "MCR Home Visit Req " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.BcbsScAssessmentAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName);
                }
                else if (corporateAccount.Id == _settings.PPAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName);
                    fileName = "HomeVisitRequest_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                else if (corporateAccount.Id == _settings.NammAccountId)
                {
                    destinationFolderPath = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName);
                    fileName = "HomeVisitRequest_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                }
                //else if (corporateAccount.Id == _settings.BcbsScAccountId)
                //{
                //    var folder = _settings.BcbsScFolder;
                //    destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folder), "HomeVisitRequest");
                //    fileName = string.Format("HomeVisitRequest_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folder, DateTime.Today.ToString("MMddyyyy"));
                //}

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

                if (!Directory.Exists(destinationFolderPath))
                {
                    Directory.CreateDirectory(destinationFolderPath);
                }

                var destinationFileName = Path.Combine(destinationFolderPath, fileName);

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

                logger.Info(string.Format("Corporate Tag: {0} StartDate: {1} Create CSV at Path: {2} ", filter.CorporateTag, filter.StartDate.ToShortDateString(), destinationFileName));

                WriteCsv(destinationFileName, list, logger);

                //if (File.Exists(destinationFileName))
                //{
                //    SendHomevisitRequestToClientSftp(corporateAccount, destinationFileName, logger);
                //}
            }
        }
コード例 #7
0
        public void PollForPdfDownload()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    return;
                }
                var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds);

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

                        var destinationFolderPdf  = string.Format(_destinationFolderPdfSetting, corporateAccount.FolderName);
                        var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag);
                        var customSettings        = _customSettingManager.Deserialize(customSettingFilePath);

                        var exportToTime   = DateTime.Now.AddHours(-1);
                        var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate;

                        DateTime?stopSendingPdftoHealthPlanDate = null;
                        if (corporateAccount.IsHealthPlan)
                        {
                            stopSendingPdftoHealthPlanDate = _stopSendingPdftoHealthPlanDate;
                        }
                        _logger.Info("exportToTime: " + exportToTime.ToString("MM/dd/yyyy"));
                        _logger.Info("exportFromTime: " + exportFromTime.ToString("MM/dd/yyyy"));

                        var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, true, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate);

                        var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray();

                        if (eventCustomerResults == null || !customerResults.Any())
                        {
                            _logger.Info(string.Format("No event customer result list for {0} Result Pdf Download.", corporateAccount.Tag));
                            continue;
                        }

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

                        _logger.Info(string.Format("Found {0} customers for {1} Result Pdf Download. ", eventCustomerResults.Count(), corporateAccount.Tag));

                        var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport();

                        var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport();

                        var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag));
                        var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName);
                        resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml {
                            Customer = new List <CustomerInfo>()
                        } : resultPosted;

                        _logger.Info(string.Format("Result Pdf file Transfer started for {0} ", corporateAccount.Tag));

                        var customersWithNoMrn    = new List <long>();
                        var newCustomersWithNoMrn = new List <long>();

                        foreach (var ecr in customerResults)
                        {
                            var sourceUrl = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport;

                            if (!File.Exists(sourceUrl))
                            {
                                sourceUrl = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport;
                            }

                            if (File.Exists(sourceUrl))
                            {
                                try
                                {
                                    SetReusltPdfNameing(ecr, corporateAccount, destinationFolderPdf, sourceUrl, resultPosted, newCustomersWithNoMrn);
                                }
                                catch (Exception exception)
                                {
                                    _logger.Error(string.Format("some error occured for the customerId {0}, {1},\n Messagen {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace));
                                }
                            }
                            else
                            {
                                _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId));
                            }
                        }

                        if (corporateAccount.Id == _settings.OptumNvAccountId || corporateAccount.Id == _settings.OptumNvMedicareAccountId)
                        {
                            _logger.Info("Sending Old Files to SFTP");

                            PostCustomerWithNoMrn(corporateAccount, destinationFolderPdf, resultPosted, customersWithNoMrn);

                            _logger.Info("Sending Old Files to SFTP Completed");

                            if (!customersWithNoMrn.IsNullOrEmpty())
                            {
                                newCustomersWithNoMrn.AddRange(customersWithNoMrn);
                            }

                            newCustomersWithNoMrn = newCustomersWithNoMrn.Distinct().ToList();

                            SaveCustomersWithNoMrn(corporateAccount, newCustomersWithNoMrn);
                        }

                        customSettings.LastTransactionDate = exportToTime;
                        _customSettingManager.SerializeandSave(customSettingFilePath, customSettings);

                        if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty())
                        {
                            _logger.Info("Result posted Log for " + corporateAccount.Tag);
                            resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted);

                            var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName);
                            pdfLogfile = Path.Combine(pdfLogfile, "Download");

                            try
                            {
                                DirectoryOperationsHelper.CreateDirectoryIfNotExist(pdfLogfile);
                                if (DirectoryOperationsHelper.IsDirectoryExist(pdfLogfile))
                                {
                                    var filesTobedeleted = DirectoryOperationsHelper.GetFiles(pdfLogfile, "*" + corporateAccount.Tag + "_PdfLogFile*");
                                    foreach (var logFile in filesTobedeleted)
                                    {
                                        DirectoryOperationsHelper.DeleteFileIfExist(logFile);
                                    }
                                }

                                var resultPostedCustomers = resultPosted.Customer.Where(x => x.EventDate.HasValue && x.EventDate.Value.Year >= _cutOfDate.Year);
                                _resultPdfFileHelper.CreateCsvForFileShared(resultPostedCustomers, pdfLogfile, corporateAccount.Tag + "_PdfLogFile");
                            }
                            catch (Exception ex)
                            {
                                _logger.Error("some error occurred");
                                _logger.Error("exception: " + ex.Message);
                                _logger.Error("stack trace: " + ex.StackTrace);
                            }

                            _logger.Info("Result posted Log Completed for " + corporateAccount.Tag);
                        }

                        _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted);

                        _logger.Info(string.Format("Result Pdf file Transfer completed for {0} ", corporateAccount.Tag));
                        _logger.Info("");
                        _logger.Info("");
                        _logger.Info("================================================================================");
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("some error occured for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace));
            }
        }
コード例 #8
0
        private void GenerateCrosswalkInboundReport(CrosswalkInboundFilter filter)
        {
            var account = _corporateAccountRepository.GetById(filter.AccountId);

            filter.Tag = account.Tag;

            if (account.IsHealthPlan)
            {
                filter.StopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate;
            }

            var model = _crosswalkInboundReportService.GetCrosswalkInboundReportList(filter, _logger);

            if (model != null)
            {
                var folder = string.Format(_settings.FloridaBlueInboundReportPath, account.FolderName, DateTime.Now.ToString("yyyy-MM-dd"));
                if (!Directory.Exists(folder))
                {
                    DirectoryOperationsHelper.CreateDirectory(folder);
                }
                var fileName    = _pipeDelimitedReportHelper.GetReportName(ReportType.CrosswalkInbound) + ".txt";
                var zipFileName = _pipeDelimitedReportHelper.GetReportName(ReportType.CrosswalkZip);

                if (model.Collection != null && model.Collection.Any())
                {
                    _logger.Info("generating File");
                    var tempMediaLocation = _mediaRepository.GetTempMediaFileLocation().PhysicalPath + zipFileName + "\\";
                    if (!Directory.Exists(tempMediaLocation))
                    {
                        DirectoryOperationsHelper.CreateDirectory(tempMediaLocation);
                    }

                    var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", account.Tag));
                    var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName);
                    resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml {
                        Customer = new List <CustomerInfo>()
                    } : resultPosted;

                    foreach (var crosswalkViewModel in model.Collection)
                    {
                        var hafResultPdfLocation = _mediaRepository.GetPremiumVersionResultPdfLocation(crosswalkViewModel.EventId, crosswalkViewModel.CustomerId);
                        var hafResultPdfFileName = _mediaRepository.GetPdfFileNameForHealthPlanResultReport();
                        var pcpResultPdfFileName = _mediaRepository.GetPdfFileNameForPcpResultReport();

                        _logger.Info(" Event Id: " + crosswalkViewModel.EventId + " Customer Id: " + crosswalkViewModel.CustomerId);

                        if (DirectoryOperationsHelper.IsFileExist(tempMediaLocation + crosswalkViewModel.FileName))
                        {
                            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(tempMediaLocation + crosswalkViewModel.FileName);
                            var files = DirectoryOperationsHelper.GetFiles(tempMediaLocation, fileNameWithoutExtension + "*.pdf");
                            crosswalkViewModel.FileName = fileNameWithoutExtension + "_" + files.Count() + ".pdf";
                        }

                        if (File.Exists(hafResultPdfLocation.PhysicalPath + hafResultPdfFileName))
                        {
                            var destinationFileName = GetFileName(resultPosted.Customer, crosswalkViewModel.EventId, crosswalkViewModel.CustomerId, Path.GetFileNameWithoutExtension(crosswalkViewModel.FileName), (long)ResultFormatType.PDF);
                            crosswalkViewModel.FileName = destinationFileName + ".pdf";

                            _logger.Info("Copying File.. filePath from : " + hafResultPdfLocation.PhysicalPath + hafResultPdfFileName);
                            _logger.Info("Copying File.. filePath To : " + tempMediaLocation + crosswalkViewModel.FileName);

                            DirectoryOperationsHelper.Copy(hafResultPdfLocation.PhysicalPath + hafResultPdfFileName, tempMediaLocation + crosswalkViewModel.FileName);

                            resultPosted.Customer.Add(GetCustomerInfo(crosswalkViewModel));
                        }
                        else if (File.Exists(hafResultPdfLocation.PhysicalPath + pcpResultPdfFileName))
                        {
                            var destinationFileName = GetFileName(resultPosted.Customer, crosswalkViewModel.EventId, crosswalkViewModel.CustomerId, Path.GetFileNameWithoutExtension(crosswalkViewModel.FileName), (long)ResultFormatType.PDF);
                            crosswalkViewModel.FileName = destinationFileName + ".pdf";

                            _logger.Info("Copying File.. filePath from : " + hafResultPdfLocation.PhysicalPath + pcpResultPdfFileName);
                            _logger.Info("Copying File.. filePath To : " + tempMediaLocation + crosswalkViewModel.FileName);

                            DirectoryOperationsHelper.Copy(hafResultPdfLocation.PhysicalPath + pcpResultPdfFileName, tempMediaLocation + crosswalkViewModel.FileName);

                            resultPosted.Customer.Add(GetCustomerInfo(crosswalkViewModel));
                        }
                        else
                        {
                            _logger.Info("file not found");
                        }
                    }

                    _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted);

                    _pipeDelimitedReportHelper.Write(model.Collection, folder, fileName);
                    DirectoryOperationsHelper.Copy(folder + "\\" + fileName, tempMediaLocation + fileName);

                    _logger.Info("generating Zip ");
                    _zipHelper.CreateZipFiles(tempMediaLocation, folder + "\\" + zipFileName + ".zip");

                    if (_sendReportToSftp)
                    {
                        try
                        {
                            _logger.Info("Sending zip to SFTP.");

                            var destinationPath = _destinationSftpPath + "\\" + account.FolderName + "\\Download\\Reports";
                            SendFilesToSftp(Path.Combine(folder, zipFileName + ".zip"), destinationPath, zipFileName + ".zip");

                            _logger.Info("Zip sent to SFTP.");
                        }
                        catch (Exception ex)
                        {
                            _logger.Info("Error sending zip to SFTP.");
                            _logger.Error("Message : " + ex.Message);
                            _logger.Error("Stack Trace : " + ex.StackTrace);
                        }
                    }

                    _logger.Info("Deleting temp folder: " + tempMediaLocation);
                    DirectoryOperationsHelper.DeleteDirectory(tempMediaLocation, true);

                    _logger.Info("Deleting text file: " + folder + "\\" + fileName);
                    DirectoryOperationsHelper.Delete(folder + "\\" + fileName);
                }
                else
                {
                    _logger.Info("No Data found for account Id: " + filter.AccountId);
                }
            }
            else
            {
                _logger.Info("No record found for " + account.Tag);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
        public void PollGiftCertificateOptumReport()
        {
            try
            {
                var corporateAccounts = _corporateAccountRepository.GetByIds(_settings.GiftCerificateOptumAccountIds);

                if (corporateAccounts.IsNullOrEmpty())
                {
                    _logger.Info("No Account Found to run Report");
                    return;
                }

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

                _logger.Info("starting for PollGiftCerificateOptumReport ");

                foreach (var account in corporateAccounts)
                {
                    if (account.Id == _applecareAccountId && _runReportForAppleCareDaysOfWeek != DateTime.Today.DayOfWeek)
                    {
                        _logger.Info(string.Format("Today is {0}. Job is set to run on {1} for Account Tag {2}.", DateTime.Today.DayOfWeek, _runReportForAppleCareDaysOfWeek, account.Tag));
                        continue;
                    }

                    if (account.Id != _applecareAccountId && (long)DateTime.Today.DayOfWeek != _settings.GiftCerificateOptumDayServiceRun)
                    {
                        _logger.Info("Today is Day of Week is " + DateTime.Today.DayOfWeek);
                        _logger.Info("Service will run on Day of Week " + (DayOfWeek)_settings.GiftCerificateOptumDayServiceRun);
                        return;
                    }

                    _logger.Info("starting for Account : " + account.Tag);

                    var destinationFoler = string.Format(_settings.GiftCerificateOptumDownloadPath, account.FolderName);

                    if (account.Id == _applecareAccountId)
                    {
                        destinationFoler = string.Format(_settings.GiftCertificateReportDownloadPath, account.FolderName);
                    }
                    if (account.Id != _applecareAccountId)
                    {
                        try
                        {
                            DirectoryOperationsHelper.DeleteDirectory(destinationFoler, true);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("Some error occurred while deleting directory at path: " + destinationFoler);
                            _logger.Error("Message: " + ex.Message);
                            _logger.Error("Stack Trace: " + ex.StackTrace);
                        }
                    }

                    DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationFoler);

                    var lastReportRunDate = toDate.AddDays(-7);

                    if (toDate.Year == lastReportRunDate.Year)
                    {
                        var fileName = "GiftCardReport_" + DateTime.Today.ToString("yyyyMMdd") + ".csv";
                        var filter   = new GiftCertificateReportFilter
                        {
                            HealthPlanId = account.Id,
                            EventFrom    = fromDate,
                            EventTo      = toDate,
                            Tag          = account.Tag
                        };

                        var isReportGenerated = GenerateReport(destinationFoler, fileName, filter);
                        if (account.Id != _applecareAccountId)
                        {
                            if (!isReportGenerated)
                            {
                                filter = new GiftCertificateReportFilter
                                {
                                    HealthPlanId = account.Id,
                                    EventFrom    = new DateTime((fromDate.Year - 1), 1, 1),
                                    EventTo      = new DateTime((fromDate.Year - 1), 12, 31),
                                    Tag          = account.Tag
                                };
                                isReportGenerated = GenerateReport(destinationFoler, fileName, filter);
                                if (!isReportGenerated)
                                {
                                    WriteHeader(Path.Combine(destinationFoler, fileName));
                                }
                            }
                        }
                    }
                    else if (lastReportRunDate.Year < toDate.Year)
                    {
                        fromDate = new DateTime(lastReportRunDate.Year, 1, 1);
                        var toforPreviousYearDate = fromDate.GetLastDateOfYear();

                        var filter = new GiftCertificateReportFilter
                        {
                            HealthPlanId = account.Id,
                            EventFrom    = fromDate,
                            EventTo      = toforPreviousYearDate,
                            Tag          = account.Tag
                        };

                        var fileName = "GiftCardReport_" + toforPreviousYearDate.ToString("yyyyMMdd") + ".csv";

                        GenerateReport(destinationFoler, fileName, filter);

                        filter = new GiftCertificateReportFilter
                        {
                            HealthPlanId = account.Id,
                            EventFrom    = toDate.GetFirstDateOfYear(),
                            EventTo      = toDate,
                            Tag          = account.Tag
                        };

                        fileName = "GiftCardReport_" + toDate.ToString("yyyyMMdd") + ".csv";
                        GenerateReport(destinationFoler, fileName, filter);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
        }
コード例 #11
0
        public void ResultExport()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    return;
                }

                var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds);

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

                        var resultExportSettings          = string.Format(_resultExportSettings, account.Tag);
                        var optumResultExportDownloadPath = string.Format(_optumeResultExportDownloadPath, account.FolderName);

                        var customSettings = _customSettingManager.Deserialize(resultExportSettings);

                        var fromDate = customSettings.LastTransactionDate ?? DateTime.Today.GetFirstDateOfYear();

                        var toDate = DateTime.Now;

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

                        string[] showHiddenColumns = new string[1];

                        if (_optumNVSettingAccountIds.Contains(account.Id))
                        {
                            showHiddenColumns[0] = "Mrn";
                        }

                        _logger.Info(" Create Destination Path: " + optumResultExportDownloadPath);

                        DirectoryOperationsHelper.CreateDirectoryIfNotExist(optumResultExportDownloadPath);

                        var fileName = optumResultExportDownloadPath + string.Format(@"\ResultExport_{0}.csv", DateTime.Now.Date.ToString("yyyyMMdd"));

                        if (_optumAccountIds.Contains(account.Id))
                        {
                            GenerateCummulativeReport(fromDate, toDate, account, optumResultExportDownloadPath, showHiddenColumns, fileName);
                        }
                        else
                        {
                            DateTime?stopSendingPdftoHealthPlanDate = null;
                            if (account != null && account.IsHealthPlan)
                            {
                                stopSendingPdftoHealthPlanDate = _stopSendingPdftoHealthPlanDate;
                            }

                            _pcpResultExportServiceHelper.ResultExport(fromDate, toDate, account.Id, optumResultExportDownloadPath, account.Tag, resultExportFileName: fileName, showHiddenColumns: showHiddenColumns, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate);
                        }

                        if (DirectoryOperationsHelper.IsFileExist(fileName))
                        {
                            _pgpFileEncryptionHelper.EncryptFile(account, fileName);
                        }
                        else if (_optumNVSettingAccountIds.Contains(account.Id))
                        {
                            _pcpResultExportServiceHelper.WriteCsvHeader(fileName, showHiddenColumns);
                        }

                        customSettings.LastTransactionDate = toDate;
                        _customSettingManager.SerializeandSave(resultExportSettings, customSettings);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("Account Id {0} and account Tag {1}  Message: {2} \n Stack Trace: {3} ", account.Id, account.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Message: {0} \n Stack Trace: {1} ", ex.Message, ex.StackTrace));
            }
        }