Ejemplo n.º 1
0
        private void ResultExportForGapPatient(DateTime fromDate, DateTime toDate, CorporateAccount account, DateTime eventStartDate, DateTime eventEndDate)
        {
            try
            {
                var bcbsmiResultExportDownloadPath = string.Format(_bcbsmiResultExportDownloadPath, account.FolderName);

                var gapFileName = string.Format(@"Q_MOBILE_ResultExport_{0}_{1}.csv", fromDate.Date.ToString("yyyyMMdd"), toDate.Date.ToString("yyyyMMdd"));

                var finalFilename = Path.Combine(bcbsmiResultExportDownloadPath, gapFileName);

                CreateDistinationDirectory(_accumulativeResultExportsPath);
                CreateDistinationDirectory(_incrementalResultExportsPath);

                var cumulativeFilePath = Path.Combine(_accumulativeResultExportsPath, string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, eventStartDate.Year));

                var incrementalFile = string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, Guid.NewGuid());

                var incrementalFilePath = Path.Combine(_incrementalResultExportsPath, incrementalFile);

                DateTime?stopSendingPdftoHealthPlanDate = null;
                if (account != null && account.IsHealthPlan)
                {
                    stopSendingPdftoHealthPlanDate = _stopSendingPdftoHealthPlanDate;
                }

                _pcpResultExportServiceHelper.ResultExport(fromDate, toDate, account.Id, _incrementalResultExportsPath, account.Tag,
                                                           _bcbsMiGapPatinetTags, useBlankValue: true, resultExportFileName: incrementalFile, considerEventDate: true,
                                                           eventStartDate: eventStartDate, eventEndDate: eventEndDate, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate);

                _pcpResultExportServiceHelper.CreateCumulativeFileAndPost(incrementalFilePath, cumulativeFilePath, finalFilename);

                if (DirectoryOperationsHelper.IsFileExist(finalFilename))
                {
                    _csvReader.RemoveEmptyColumnsFromCsv(finalFilename);

                    _pgpFileEncryptionHelper.EncryptFile(account, finalFilename);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Message: {0} \n Stack Trace: {1} ", ex.Message, ex.StackTrace));
            }
        }
Ejemplo n.º 2
0
        public void GenerateCummulativeReport(DateTime fromDate, DateTime toDate, CorporateAccount account, string finalDestinationPath, string[] showHiddenColumns, string reportName)
        {
            DirectoryOperationsHelper.CreateDirectoryIfNotExist(_accumulativeResultExportsPath);
            DirectoryOperationsHelper.CreateDirectoryIfNotExist(_incrementalResultExportsPath);

            var cumulativeFilePath  = Path.Combine(_accumulativeResultExportsPath, string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, _cutOfDate.Year));
            var incrementalFile     = string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, Guid.NewGuid());
            var incrementalFilePath = Path.Combine(_incrementalResultExportsPath, incrementalFile);

            var finalFilename = Path.Combine(finalDestinationPath, reportName);

            _logger.Info("finalDestinationPath:  " + finalDestinationPath);
            DirectoryOperationsHelper.CreateDirectoryIfNotExist(finalDestinationPath);

            _pcpResultExportServiceHelper.ResultExport(fromDate, toDate, account.Id, _incrementalResultExportsPath, account.Tag, resultExportFileName: incrementalFile,
                                                       considerEventDate: true, showHiddenColumns: showHiddenColumns, eventStartDate: _cutOfDate, eventEndDate: null, stopSendingPdftoHealthPlanDate: _stopSendingPdftoHealthPlanDate);

            _pcpResultExportServiceHelper.CreateCumulativeFileAndPost(incrementalFilePath, cumulativeFilePath, finalFilename);
        }
Ejemplo n.º 3
0
        public void ResultExport()
        {
            try
            {
                string[] showAdditionalFields = null;
                if (!string.IsNullOrEmpty(_settings.AnthemAdditionalFieldValues))
                {
                    showAdditionalFields = _settings.AnthemAdditionalFieldValues.Split(new char[','], StringSplitOptions.RemoveEmptyEntries);
                }

                foreach (var customTag in _customTags)
                {
                    try
                    {
                        _logger.Info("Running report for CustomTag: " + customTag);
                        var corporateTag = _corporateTagRepository.GetByTag(customTag);

                        if (corporateTag == null)
                        {
                            _logger.Info("No Corporate Tag Found: " + customTag);
                            continue;
                        }
                        var account = (_corporateAccountRepository).GetById(corporateTag.CorporateId);

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

                        var folderStateCode = string.Empty;
                        if (account.Id == _anthemAccountId)
                        {
                            folderStateCode = "CA";
                        }
                        else
                        {
                            foreach (var stateCode in _settings.AnthemCustomTagStates)
                            {
                                if (customTag.Contains(stateCode))
                                {
                                    folderStateCode = stateCode.Substring(stateCode.Length - 2);

                                    break;
                                }
                            }
                        }

                        if (folderStateCode == string.Empty)
                        {
                            continue;
                        }

                        var destinationPath = string.Format(_settings.AnthemDownloadPath, folderStateCode);
                        destinationPath = Path.Combine(destinationPath, "results");

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

                        var customSettings = _customSettingManager.Deserialize(resultExportSettings);

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

                        var toDate = DateTime.Now;

                        CreateDistinationDirectory(destinationPath);

                        CreateDistinationDirectory(_accumulativeResultExportsPath);
                        CreateDistinationDirectory(_incrementalResultExportsPath);

                        var customTags = new[] { customTag };

                        var finalFilename   = string.Format("HLTHFAIR_ResultsExport_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                        var incrementalFile = string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, Guid.NewGuid());

                        var cumulativeFilePath  = Path.Combine(_accumulativeResultExportsPath, string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, DateTime.Today.Year));
                        var incrementalFilePath = Path.Combine(_incrementalResultExportsPath, incrementalFile);

                        var finalFilePath = Path.Combine(destinationPath, finalFilename);

                        DateTime?stopSendingPdftoHealthPlanDate = null;
                        if (account != null && account.IsHealthPlan)
                        {
                            stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate;
                        }

                        _pcpResultExportServiceHelper.ResultExport(fromDate, toDate, account.Id, _incrementalResultExportsPath, account.Tag, customTags, resultExportFileName: incrementalFile, considerEventDate: true, eventStartDate: fromDate.GetFirstDateOfYear(), eventEndDate: fromDate.GetLastDateOfYear(), showHiddenAdditionalFields: showAdditionalFields, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate);

                        _pcpResultExportServiceHelper.CreateCumulativeFileAndPost(incrementalFilePath, cumulativeFilePath, finalFilePath);

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

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