예제 #1
0
        private void CopyMediaFile(long customerId, long eventId, IEnumerable <string> mediaFiles)
        {
            var mediaPath       = _mediaRepository.GetResultMediaFileLocation(customerId, eventId).PhysicalPath;
            var destinationPath = Path.Combine(_settings.SendTestMediaFilesClientLocation, eventId.ToString(), customerId.ToString());

            DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationPath);
            DirectoryOperationsHelper.DeleteFiles(destinationPath);

            foreach (var file in mediaFiles)
            {
                var sourceFileName = Path.Combine(mediaPath, file);
                if (File.Exists(sourceFileName))
                {
                    File.Copy(sourceFileName, Path.Combine(destinationPath, file));
                    _logger.Info("Media file(" + file + ") successfully copied on location @" + destinationPath + " for Customer Id: " + customerId + " Event Id: " + eventId);
                }
                else
                {
                    _logger.Info("Media file(" + file + ") does not exist on Media file Location for Customer Id: " + customerId + " Event Id: " + eventId);
                }
            }
        }
예제 #2
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);
                //    }

                //}
            }
        }
예제 #3
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);
                //}
            }
        }
예제 #4
0
        public void GenerateHafAssessment(long eventId)
        {
            try
            {
                var eventLogger = _logManager.GetLogger("HealthAssessmentFormGenerator_" + eventId);
                eventLogger.Info("Generating HAF for Event Id: " + eventId);
                _pdfGenerator.PaperSize = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.PaperSize);

                try
                {
                    var eventCustomers = _eventCustomerRepository.GetbyEventId(eventId);

                    if (eventCustomers != null && eventCustomers.Any())
                    {
                        eventCustomers = eventCustomers.Where(ec => ec.AppointmentId.HasValue).ToArray();

                        if (eventCustomers != null && eventCustomers.Any())
                        {
                            eventLogger.Info("found EventCustomers Count: " + eventCustomers.Count());

                            var mediaLocation = _mediaRepository.GetMedicalHistoryMediaLocation(eventId);

                            DirectoryOperationsHelper.CreateDirectoryIfNotExist(mediaLocation.PhysicalPath);

                            DirectoryOperationsHelper.DeleteFiles(mediaLocation.PhysicalPath);
                            var eventData = _eventRepository.GetById(eventId);
                            var account   = _corporateAccountRepository.GetbyEventId(eventId);

                            var corporateSurveyPdf = "";
                            if (account != null && account.CaptureSurvey)
                            {
                                if (account.SurveyPdfFileId > 0)
                                {
                                    var surveyPdf = _fileRepository.GetById(account.SurveyPdfFileId);
                                    if (surveyPdf != null)
                                    {
                                        corporateSurveyPdf = _mediaRepository.GetCorporateSurveyPdfFolderLocation().PhysicalPath + surveyPdf.Path;
                                    }
                                }
                            }

                            var corporateCheckListPdf = "";
                            if (account != null && account.PrintCheckList && account.CheckListFileId > 0 && eventData.EventDate >= _settings.ChecklistChangeDate)
                            {
                                var checkListFilePdf = _fileRepository.GetById(account.CheckListFileId);
                                if (checkListFilePdf != null)
                                {
                                    corporateCheckListPdf = _mediaRepository.GetCorporateCheckListPdfFolderLocation().PhysicalPath + checkListFilePdf.Path;
                                }
                            }

                            var filesFocAttestation    = new[] { "" };
                            var mediaLocFocAttestation = _mediaRepository.GetUnlockEventsParseLocation(eventId);

                            if (account != null && account.Id == _settings.HcpNvAccountId)
                            {
                                if (DirectoryOperationsHelper.IsDirectoryExist(mediaLocFocAttestation.PhysicalPath))
                                {
                                    filesFocAttestation = Directory.GetFiles(mediaLocFocAttestation.PhysicalPath, "*.*");
                                    filesFocAttestation = filesFocAttestation.Where(fsd => !string.IsNullOrEmpty(fsd)).ToArray();
                                }
                            }
                            else
                            {
                                if (DirectoryOperationsHelper.IsDirectoryExist(mediaLocFocAttestation.PhysicalPath))
                                {
                                    filesFocAttestation = Directory.GetFiles(mediaLocFocAttestation.PhysicalPath, "*.pdf");
                                    filesFocAttestation = filesFocAttestation.Where(fsd => !string.IsNullOrEmpty(fsd)).ToArray();
                                }
                            }

                            var tempMediaLocation = _mediaRepository.GetTempMediaFileLocation();
                            var customers         = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray());

                            int index = 0;
                            foreach (var eventCustomer in eventCustomers)
                            {
                                eventLogger.Info(string.Format("Generating HAF for Event Id: {0} and Customer Id : {1} ", eventId, eventCustomer.CustomerId));
                                string url                = _settings.HealthAssessmentFormUrl + string.Format("?eventId={0}&customerId={1}&LoadLayout=false&showKynEditModel=true&bulkPrint=true&removeChache={2}", eventCustomer.EventId, eventCustomer.CustomerId, Guid.NewGuid());
                                var    customer           = customers.First(c => c.CustomerId == eventCustomer.CustomerId);
                                var    focAttestationFile = string.Empty;

                                if (account != null)
                                {
                                    var questFile = Path.Combine(_mediaRepository.GetQuestUploadMediaFileLocation().PhysicalPath, account.Tag + "_Quest.pdf");

                                    if (account.Id == _settings.WellmedAccountId || account.Id == _settings.WellmedTxAccountId)
                                    {
                                        var memberId = string.IsNullOrEmpty(customer.InsuranceId) ? "" : customer.InsuranceId.ToLower().Trim();
                                        focAttestationFile = filesFocAttestation.FirstOrDefault(fsd => !string.IsNullOrEmpty(fsd) && Path.GetFileNameWithoutExtension(fsd).ToLower().Trim() == memberId);
                                        eventLogger.Info(string.Format("focAttestationFile : {0}", focAttestationFile));

                                        var _files = new List <string>();

                                        if (!string.IsNullOrEmpty(focAttestationFile) && DirectoryOperationsHelper.IsFileExist(focAttestationFile))
                                        {
                                            eventLogger.Info(string.Format("focAttestationFile : First if {0}", focAttestationFile));
                                            _files.Add(focAttestationFile);
                                        }

                                        if (DirectoryOperationsHelper.IsFileExist(questFile))
                                        {
                                            eventLogger.Info(string.Format("focAttestationFile : 2nd if {0}", questFile));
                                            _files.Add(questFile);
                                        }

                                        if (!_files.IsNullOrEmpty())
                                        {
                                            if (_files.Count() > 1)
                                            {
                                                eventLogger.Info(string.Format("focAttestationFile : File Count {0}", _files.Count()));
                                                focAttestationFile = GetFocAttestationFileMerge(_files, focAttestationFile, eventLogger);
                                            }
                                            else
                                            {
                                                eventLogger.Info(string.Format("focAttestationFile : File[0] {0}", _files[0]));
                                                focAttestationFile = _files[0];
                                                eventLogger.Info(string.Format("focAttestationFile : Last {0}", focAttestationFile));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        focAttestationFile = GetFocAttestationFileForMht(filesFocAttestation, customer.CustomerId.ToString(), eventLogger);
                                    }
                                    //else if (account.Id == _settings.MolinaAccountId)
                                    //{
                                    //    var hicn = string.IsNullOrEmpty(customer.Hicn) ? "" : customer.Hicn.ToLower().Trim();
                                    //    focAttestationFile = filesFocAttestation.FirstOrDefault(fsd => !string.IsNullOrEmpty(fsd) && Path.GetFileNameWithoutExtension(fsd).ToLower().Trim() == hicn);
                                    //}
                                    //else if (account.Id == _settings.HcpNvAccountId)
                                    //{

                                    //}
                                    //else if (_settings.MonarchAccountIds.Contains(account.Id))
                                    //{
                                    //    var gmpi = string.IsNullOrEmpty(customer.AdditionalField4) ? "" : customer.AdditionalField4.ToLower().Trim();

                                    //    if (!string.IsNullOrEmpty(gmpi))
                                    //    {
                                    //        focAttestationFile = GetFocAttestationFile(filesFocAttestation, "_" + gmpi.ToLower(), focAttestationFile, eventLogger);
                                    //    }
                                    //}
                                    //else if (account.Id == _settings.AppleCareAccountId)
                                    //{
                                    //    focAttestationFile = GetFocAttestationFile(filesFocAttestation, customer.CustomerId.ToString(), focAttestationFile, eventLogger);
                                    //}
                                    //else if (account.Id == _settings.NammAccountId)
                                    //{
                                    //    focAttestationFile = GetFocAttestationFile(filesFocAttestation, customer.CustomerId.ToString(), focAttestationFile, eventLogger);
                                    //}
                                }

                                var focAttestationFilePath = string.Empty;
                                eventLogger.Info("focAttestationFile: " + focAttestationFile);

                                if (!string.IsNullOrEmpty(focAttestationFile))
                                {
                                    focAttestationFilePath = focAttestationFile;
                                }

                                var annualComprehensiveExamPdf  = string.Empty;
                                var memberInformationProfilePdf = string.Empty;

                                if (!string.IsNullOrEmpty(customer.Hicn))
                                {
                                    var fileNamePattern = customer.Hicn + (customer.Name != null ? "_" + customer.Name.LastName + "_" + customer.Name.FirstName : "");
                                    if (account != null && account.PrintAceForm)
                                    {
                                        try
                                        {
                                            var mediaLocationForAce = _mediaRepository.GetAceMipLocation(account.FolderName, fileNamePattern, "ACE");
                                            var aceFiles            = DirectoryOperationsHelper.GetFiles(mediaLocationForAce.PhysicalPath, fileNamePattern + "*_ACE.pdf");
                                            if (aceFiles.Any())
                                            {
                                                annualComprehensiveExamPdf = _pdfGenerator.ExtractPdfPagesFromEnd(aceFiles.First(), tempMediaLocation.PhysicalPath + "Ripped_" + customer.Hicn + "_ACE.pdf", NumberOfPagesToExtractFromAcePdf);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            eventLogger.Error(string.Format("Unable to attach ACE form to the bulk HAF for CustomerID : {0}\nMessage : {1}", customer.CustomerId, ex.Message));
                                        }
                                    }

                                    if (account != null && account.PrintMipForm)
                                    {
                                        try
                                        {
                                            var mediaLocationForMip = _mediaRepository.GetAceMipLocation(account.FolderName, fileNamePattern, "MIP");
                                            var mipFiles            = DirectoryOperationsHelper.GetFiles(mediaLocationForMip.PhysicalPath, fileNamePattern + "*_MIP.pdf");
                                            if (mipFiles.Any())
                                            {
                                                memberInformationProfilePdf = mipFiles.First();
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            eventLogger.Error(string.Format("Unable to attach MIP to the bulk HAF for CustomerID : {0}\nMessage : {1}", customer.CustomerId, ex.Message));
                                        }
                                    }
                                }
                                var consentHeaderWithChecklistpdf = string.Empty;

                                if (!string.IsNullOrWhiteSpace(corporateCheckListPdf) && DirectoryOperationsHelper.IsFileExist(corporateCheckListPdf))
                                {
                                    var    tempPath         = _mediaRepository.GetTempMediaFileLocation();
                                    var    consentHeader    = Path.Combine(tempPath.PhysicalPath, Guid.NewGuid() + ".pdf");
                                    string consentHeaderUrl = _settings.ConsentHeaderFormUrl + string.Format("?eventId={0}&customerId={1}&removeChache={2}", eventCustomer.EventId, eventCustomer.CustomerId, Guid.NewGuid());
                                    _pdfGenerator.GeneratePdf(consentHeaderUrl, consentHeader);

                                    consentHeaderWithChecklistpdf = Path.Combine(tempPath.PhysicalPath, Guid.NewGuid() + ".pdf");
                                    var consentHeaderWithChecklistpdfArray = new string[] { consentHeader, corporateCheckListPdf };
                                    _pdfGenerator.Merge(consentHeaderWithChecklistpdf, consentHeaderWithChecklistpdfArray);
                                }


                                _pdfGenerator.GeneratePdfForHaf(url, mediaLocation.PhysicalPath + (++index).ToString("000.") + eventCustomer.CustomerId + ".pdf", corporateSurveyPdf, "", focAttestationFilePath, consentHeaderWithChecklistpdf,
                                                                annualComprehensiveExamPdf, memberInformationProfilePdf);
                            }

                            eventLogger.Info("Merging HAF for Event Id: " + eventId);
                            _pdfGenerator.GetPdffilesfromLocationandMergeintoOne(mediaLocation.PhysicalPath, mediaLocation.PhysicalPath + "Event_" + eventId + ".pdf");
                            _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, false, (long)GenerateHealthAssesmentFormStatus.Completed);

                            index = 0;

                            foreach (var eventCustomer in eventCustomers)
                            {
                                DirectoryOperationsHelper.Delete(mediaLocation.PhysicalPath + (++index).ToString("000.") + eventCustomer.CustomerId + ".pdf");
                            }
                        }
                        else
                        {
                            eventLogger.Info("No customer found with appointment attached with this event. Merging HAF for Event Id: " + eventId);
                            _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, false, (long)GenerateHealthAssesmentFormStatus.Completed);
                        }
                    }
                    else
                    {
                        eventLogger.Info("No customer found attached with this event. Merging HAF for Event Id: " + eventId);
                        _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, false, (long)GenerateHealthAssesmentFormStatus.Completed);
                    }
                }
                catch (Exception ex)
                {
                    _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, true, (long)GenerateHealthAssesmentFormStatus.Pending);
                    eventLogger.Error("\n" + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, true, (long)GenerateHealthAssesmentFormStatus.Pending);
                _logger.Error("\n" + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
            }
        }
예제 #5
0
        private void CreateCrossWalkFile(string csvFilePath, IEnumerable <AnthemPdfCrossWalkVeiwModel> modelData)
        {
            try
            {
                if (modelData.IsNullOrEmpty())
                {
                    _logger.Info("No Data found to generate crosswalk file ");
                    return;
                }
                try
                {
                    DirectoryOperationsHelper.DeleteFiles(csvFilePath, "CrosswalkFile_*.csv");
                }
                catch (Exception exception)
                {
                    _logger.Error(" While deleting old files");
                    _logger.Error("message: " + exception);
                    _logger.Error("stack Trace: " + exception.StackTrace);
                }

                DirectoryOperationsHelper.CreateDirectoryIfNotExist(_crosswalkFilePath);
                DirectoryOperationsHelper.CreateDirectoryIfNotExist(csvFilePath);

                var filePath = Path.Combine(_crosswalkFilePath, "CrosswalkFile_" + _crosswalkFileYear + ".csv");

                bool createHeaderRow = !DirectoryOperationsHelper.IsFileExist(filePath);

                _logger.Info("File Path: " + filePath);

                if (createHeaderRow)
                {
                    _logger.Info("Header info being created");
                }

                var csvFileName = Path.Combine(csvFilePath, "CrosswalkFile_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv");

                using (var streamWriter = new StreamWriter(filePath, append: !createHeaderRow))
                {
                    var members = (typeof(AnthemPdfCrossWalkVeiwModel)).GetMembers();

                    if (createHeaderRow)
                    {
                        var header = new List <string>();
                        foreach (var memberInfo in members)
                        {
                            if (memberInfo.MemberType != MemberTypes.Property)
                            {
                                continue;
                            }

                            var propInfo = (memberInfo as PropertyInfo);
                            if (propInfo != null)
                            {
                                if (propInfo.PropertyType == typeof(FeedbackMessageModel))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }

                            string propertyName = memberInfo.Name;
                            bool   isHidden     = false;

                            var attributes = propInfo.GetCustomAttributes(false);
                            if (!attributes.IsNullOrEmpty())
                            {
                                foreach (var attribute in attributes)
                                {
                                    if (attribute is HiddenAttribute)
                                    {
                                        isHidden = true;
                                        break;
                                    }
                                    if (attribute is DisplayNameAttribute)
                                    {
                                        propertyName = (attribute as DisplayNameAttribute).DisplayName;
                                    }
                                }
                            }

                            if (isHidden)
                            {
                                continue;
                            }

                            header.Add(propertyName);
                        }

                        streamWriter.Write(string.Join(",", header.ToArray()) + Environment.NewLine);
                    }

                    var sanitizer = new CSVSanitizer();
                    foreach (var model in modelData)
                    {
                        var values = new List <string>();
                        foreach (var memberInfo in members)
                        {
                            if (memberInfo.MemberType != MemberTypes.Property)
                            {
                                continue;
                            }

                            var propInfo = (memberInfo as PropertyInfo);
                            if (propInfo != null)
                            {
                                if (propInfo.PropertyType == typeof(FeedbackMessageModel))
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }


                            bool            isHidden  = false;
                            FormatAttribute formatter = null;

                            var attributes = propInfo.GetCustomAttributes(false);
                            if (!attributes.IsNullOrEmpty())
                            {
                                foreach (var attribute in attributes)
                                {
                                    if (attribute is HiddenAttribute)
                                    {
                                        isHidden = true;
                                        break;
                                    }
                                    if (attribute is FormatAttribute)
                                    {
                                        formatter = (FormatAttribute)attribute;
                                    }
                                }
                            }

                            if (isHidden)
                            {
                                continue;
                            }
                            var obj = propInfo.GetValue(model, null);
                            if (obj == null)
                            {
                                values.Add(string.Empty);
                            }
                            else if (formatter != null)
                            {
                                values.Add(formatter.ToString(obj));
                            }
                            else
                            {
                                values.Add(sanitizer.EscapeString(obj.ToString()));
                            }
                        }
                        streamWriter.Write(string.Join(",", values.ToArray()) + Environment.NewLine);
                    }

                    streamWriter.Close();

                    _logger.Info("crosswalk .csv has been created at following location: ");
                    _logger.Info(filePath);

                    if (DirectoryOperationsHelper.IsFileExist(filePath))
                    {
                        DirectoryOperationsHelper.DeleteFileIfExist(csvFileName);
                        DirectoryOperationsHelper.Copy(filePath, csvFileName);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("While Generating crosswalk file: message " + ex.Message + " stack trace:  " + ex.StackTrace);
            }
        }
        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));

                        DateTime fromDate;
                        if (DateTime.Now.Year > _cutOfDate.Date.Year)
                        {
                            fromDate = DateTime.Today.GetFirstDateOfYear();
                        }
                        else
                        {
                            fromDate = _cutOfDate;
                        }

                        var destinationPath = string.Format(_pcpAppointmentBookedReportDownloadPath, account.FolderName);

                        if (account.Id != _settings.ExcellusAccountId && account.Id != _settings.HealthNowAccountId)
                        {
                            destinationPath = Path.Combine(destinationPath, DateTime.Today.Year.ToString());
                        }

                        var appointmentSettings = string.Format(_appointmentSettings, account.Tag);
                        var customSettings      = _customSettingManager.Deserialize(appointmentSettings);


                        var toDate = DateTime.Today.GetLastDateOfYear();

                        _logger.Info(string.Format("Generating AppointmentBooked Date From. {0} To Date {1}", fromDate.Date.ToShortDateString(), toDate.ToShortDateString()));
                        string[] customTags          = null;
                        var      appointmentFileName = string.Format(@"\AppointmentBookedReport_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));

                        if (account.Id == _martinsPointExclusiveAccountId)
                        {
                            appointmentFileName = string.Format(@"\Exclusive_AppointmentBookedReport_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                            DirectoryOperationsHelper.DeleteFiles(destinationPath, "Exclusive_AppointmentBookedReport*.csv");
                        }
                        else if (account.Id == _settings.ExcellusAccountId)
                        {
                            appointmentFileName = string.Format(@"\AppointmentBooked_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                            customTags          = _settings.ExcellusCustomTags;
                            DirectoryOperationsHelper.DeleteFiles(destinationPath, "AppointmentBooked*.csv");
                        }
                        else if (account.Id == _settings.HealthNowAccountId)
                        {
                            destinationPath     = string.Format(_settings.HealthPlanDownloadPath, account.FolderName);
                            appointmentFileName = string.Format(@"\AppointmentBooked_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                            customTags          = _settings.HealthNowCustomTags;
                            DirectoryOperationsHelper.DeleteFiles(destinationPath, "AppointmentBooked*.csv");
                        }
                        else if (account.Id == _settings.MedMutualAccountId)
                        {
                            destinationPath     = string.Format(_settings.HealthPlanDownloadPath, account.FolderName);
                            appointmentFileName = string.Format(@"\AppointmentsBooked_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                            DirectoryOperationsHelper.DeleteFiles(destinationPath, "AppointmentsBooked*.csv");
                        }
                        else if (account.Id == _settings.AppleCareAccountId)
                        {
                            if (DateTime.Today.DayOfWeek != _settings.AppleCareAppointmentBookedReportDayOfWeek)
                            {
                                _logger.Info("today is " + DateTime.Today.DayOfWeek + " while service is configured to run on " + _settings.AppleCareAppointmentBookedReportDayOfWeek);
                                _logger.Info("Please set in " + (int)DateTime.Today.DayOfWeek + " to run Service today");
                                continue;
                            }

                            appointmentFileName = @"\AppointmentsBooked.csv";
                            DirectoryOperationsHelper.DeleteFiles(destinationPath, "AppointmentsBooked.csv");
                        }
                        else if (account.Id == _settings.ConnecticareAccountId)
                        {
                            destinationPath     = string.Format(_settings.HealthPlanDownloadPath, account.FolderName);
                            appointmentFileName = @"\Comm Appts Booked " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv";
                        }
                        else if (account.Id == _settings.ConnecticareMaAccountId)
                        {
                            destinationPath     = string.Format(_settings.HealthPlanDownloadPath, account.FolderName);
                            appointmentFileName = @"\MCR Appts Booked " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv";
                        }
                        else if (account.Id == _settings.BcbsScAssessmentAccountId)
                        {
                            destinationPath = string.Format(_settings.HealthPlanExportRootPath, account.FolderName);
                        }
                        else if (account.Id == _settings.FloridaBlueFepAccountId)
                        {
                            destinationPath     = Path.Combine(string.Format(_settings.HealthPlanDownloadPath, account.FolderName), "Reports");
                            appointmentFileName = string.Format(@"\AppointmentBooked_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                        }
                        else if (account.Id == _settings.NammAccountId)
                        {
                            destinationPath     = string.Format(_settings.HealthPlanExportRootPath, account.FolderName);
                            appointmentFileName = string.Format(@"\AppointmentBooked_{0}.csv", DateTime.Today.ToString("yyyyMMdd"));
                        }
                        //else if (account.Id == _settings.BcbsScAccountId)
                        //{
                        //    var folder = _settings.BcbsScFolder;
                        //    destinationPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folder), "Appointments");
                        //    appointmentFileName = string.Format(@"\AppointmentsBooked_{0}_{1}_{2}.csv", account.AcesClientShortName, folder, DateTime.Today.ToString("MMddyyyy"));
                        //}
                        else
                        {
                            DirectoryOperationsHelper.DeleteFiles(destinationPath, "AppointmentBookedReport*.csv");
                        }

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

                        var fileName = destinationPath + appointmentFileName;
                        _logger.Info(string.Format("Completed AppointmentBooked Date From. {0} To Date {1}", fromDate.Date.ToShortDateString(), toDate.ToShortDateString()));

                        if (File.Exists(fileName))
                        {
                            _pgpFileEncryptionHelper.EncryptFile(account, fileName);

                            if (account.Id == _settings.FloridaBlueFepAccountId && _settings.SendReportToFloridaBlueSftp)
                            {
                                var destinationSftpPath = _settings.FloridaBlueSftpPath + "\\" + account.FolderName + "\\Download\\Reports";
                                PostFile(fileName, destinationSftpPath, _settings.FloridaBlueSftpHost, _settings.FloridaBlueSftpUserName, _settings.FloridaBlueSftpPassword);
                            }
                            else
                            {
                                PostFileOnClientSftp(account, fromDate, fileName);
                            }
                        }
                        else
                        {
                            _logger.Info("file Not found " + 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));
            }
        }