コード例 #1
0
        private void CreateResultPostedLoger(CorporateAccount corporateAccount)
        {
            if (_resultPdfPostedXml != null && !_resultPdfPostedXml.Customer.IsNullOrEmpty())
            {
                _logger.Info("Result posted Log for " + corporateAccount.Tag);
                _resultPdfPostedXml = _resultPdfFileHelper.CorrectMissingRecords(_resultPdfPostedXml);

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

                try
                {
                    _resultPdfFileHelper.CreateCsvForFileShared(_resultPdfPostedXml.Customer, 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);
            }
        }
コード例 #2
0
        private void CorrectandSaveResultPosted(ResultPdfPostedXml resultPosted, CorporateAccount account)
        {
            if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty())
            {
                _logger.Info("Result posted Log for " + account.Tag);
                resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted);

                if (account.Id == _settings.AppleCareAccountId || account.Id == _settings.MedMutualAccountId)
                {
                    var pdfLogfile = string.Format(_settings.PdfLogFilePath, account.FolderName);
                    if (account.Id == _settings.MedMutualAccountId)
                    {
                        pdfLogfile = pdfLogfile.Replace(" ", "");
                    }
                    pdfLogfile = Path.Combine(pdfLogfile, "Download");

                    try
                    {
                        _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, pdfLogfile, account.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 " + account.Tag);
            }

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

            _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted);
        }
コード例 #3
0
        private void GetResultPostedList(string tag)
        {
            var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", tag));
            var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName);

            _resultPdfPostedXml = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml {
                Customer = new List <CustomerInfo>()
            } : resultPosted;
        }
        private void CorrectMissingRecords(ResultPdfPostedXml resultPdfPostedXml)
        {
            if (resultPdfPostedXml == null || resultPdfPostedXml.Customer.IsNullOrEmpty())
            {
                return;
            }

            var isRecordMissing = resultPdfPostedXml.Customer.Any(x => !x.EventDate.HasValue || string.IsNullOrEmpty(x.MemberId));

            if (!isRecordMissing)
            {
                return;
            }

            var customersInfo = resultPdfPostedXml.Customer;

            foreach (var customerInfo in customersInfo)
            {
                try
                {
                    if (string.IsNullOrEmpty(customerInfo.MemberId))
                    {
                        var customer = _customerRepository.GetCustomer(customerInfo.CustomerId);
                        customerInfo.MemberId = customer.InsuranceId;
                    }

                    if (!customerInfo.EventDate.HasValue)
                    {
                        var eventData = _eventRepository.GetById(customerInfo.EventId);
                        customerInfo.EventDate = eventData.EventDate;
                    }
                }
                catch (Exception ex)
                {
                    _logger.Info("Error while getting memberId for customer Id " + customerInfo.CustomerId);
                    _logger.Error("Message " + ex.Message);
                    _logger.Error("StackTrace " + ex.StackTrace);
                }
            }

            var resultpdfPosted = new ResultPdfPostedXml {
                Customer = customersInfo.ToList()
            };
            var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, "resultPostedMonarchToWellmed.xml");

            _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultpdfPosted);
        }
コード例 #5
0
        private ResultPdfPostedXml CorrectMissingRecords(ResultPdfPostedXml resultPdfPostedXml)
        {
            if (resultPdfPostedXml == null || resultPdfPostedXml.Customer.IsNullOrEmpty())
            {
                return(resultPdfPostedXml);
            }

            var isRecordMissing = resultPdfPostedXml.Customer.Any(x => !x.EventDate.HasValue || string.IsNullOrEmpty(x.MemberId));

            if (!isRecordMissing)
            {
                return(resultPdfPostedXml);
            }

            var customersInfo = resultPdfPostedXml.Customer;

            foreach (var customerInfo in customersInfo)
            {
                try
                {
                    if (string.IsNullOrEmpty(customerInfo.MemberId))
                    {
                        var customer = _customerRepository.GetCustomer(customerInfo.CustomerId);
                        customerInfo.MemberId = customer.InsuranceId;
                    }

                    if (!customerInfo.EventDate.HasValue)
                    {
                        var eventData = _eventRepository.GetById(customerInfo.EventId);
                        customerInfo.EventDate = eventData.EventDate;
                    }
                }
                catch (Exception ex)
                {
                    _logger.Info("Error while getting memberId for customer Id " + customerInfo.CustomerId);
                    _logger.Error("Message " + ex.Message);
                    _logger.Error("StackTrace " + ex.StackTrace);
                }
            }

            return(new ResultPdfPostedXml()
            {
                Customer = customersInfo
            });
        }
コード例 #6
0
        public void PollForPdfDownload()
        {
            try
            {
                if (_accountIds.IsNullOrEmpty())
                {
                    _logger.Info("Account Ids Can not be empty: ");
                    return;
                }

                var accounts = _corporateAccountRepository.GetByIds(_accountIds);

                if (accounts.IsNullOrEmpty())
                {
                    _logger.Info("No valid account Found");
                    return;
                }

                var destinationFolderPdf = _settings.AnthemDownloadPath;
                destinationFolderPdf = Path.Combine(destinationFolderPdf, "pdf");

                DirectoryOperationsHelper.CreateDirectoryIfNotExist(destinationFolderPdf);

                foreach (var corporateAccount in accounts)
                {
                    PostResultAccountWise(corporateAccount, destinationFolderPdf);
                }

                CreateEobFile(_anthemPdfCrossWalkVeiwModel, destinationFolderPdf);
                CreateCrossWalkFile(destinationFolderPdf, _anthemPdfCrossWalkVeiwModel);

                _resultPdfPostedXml          = null;
                _anthemPdfCrossWalkVeiwModel = null;
                _resultPdfNotPosted          = null;
                _customSettings = null;
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace));
            }
        }
コード例 #7
0
        private void PostCustomerWithNoMrn(CorporateAccount corporateAccount, string destinationFolderPdf, ResultPdfPostedXml resultPosted, List <long> customersMrnNotUpdated)
        {
            var customers = _customerWithNoMrn.Deserialize(_customerWithNoMrnPath + "\\CustomerWithNoMrn_" + corporateAccount.Tag + ".xml");

            int pageNumber   = 1;
            int totalRecords = 0;

            var customersWithMrn = new List <long>();

            var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport();

            var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport();

            if (customers != null && !customers.CustomerIds.IsNullOrEmpty())
            {
                while (true)
                {
                    totalRecords = customers.CustomerIds.Count();
                    if (totalRecords < 1)
                    {
                        break;
                    }

                    var pagedCusotmerIds = customers.CustomerIds.Skip((pageNumber - 1) * PageSize).Take(PageSize);

                    _logger.Info(string.Format("Total No of Customer: {0}, Page Number {1} ", totalRecords, pageNumber));

                    var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsByCustomerIds((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, corporateAccount.Id, pagedCusotmerIds, _cutOfDate);
                    foreach (var ecr in eventCustomerResults)
                    {
                        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, customersMrnNotUpdated);
                            }
                            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 (!eventCustomerResults.IsNullOrEmpty())
                    {
                        _logger.Info(string.Format("Total Customer found With MRN: {0} ", eventCustomerResults.Count()));
                        customersWithMrn.AddRange(eventCustomerResults.Select(x => x.CustomerId));
                    }
                    else
                    {
                        _logger.Info(string.Format("No Records found"));
                    }

                    pageNumber++;
                    if ((pageNumber * PageSize) > totalRecords)
                    {
                        break;
                    }
                }

                customersMrnNotUpdated.AddRange(customers.CustomerIds.Where(c => !customersWithMrn.Contains(c)));
            }
        }
コード例 #8
0
        private void SetReusltPdfNameing(EventCustomerResult ecr, CorporateAccount corporateAccount, string destinationFolderPdfPath, string sourcePath, ResultPdfPostedXml resultPosted, List <long> newCustomersWithNoMrn)
        {
            var eventDirectoryPdf   = destinationFolderPdfPath + "\\" + ecr.EventId;
            var destinationFilename = ecr.CustomerId.ToString();
            var customer            = _customerRepository.GetCustomer(ecr.CustomerId);
            var eventData           = _eventRepository.GetById(ecr.EventId);

            if (_optumAccountIds.Contains(corporateAccount.Id))
            {
                eventDirectoryPdf = destinationFolderPdfPath;
            }

            if (corporateAccount.Id == _settings.OptumNvAccountId || corporateAccount.Id == _settings.OptumNvMedicareAccountId)
            {
                if (!string.IsNullOrEmpty(customer.Mrn))
                {
                    destinationFilename = customer.Mrn + "_" + eventData.EventDate.ToString("yyyyMMdd");
                    var customerPcp = _primaryCarePhysicianRepository.Get(ecr.CustomerId);
                    destinationFilename += (customerPcp != null ? "_" + customerPcp.Name.LastName : "");
                }
                else
                {
                    newCustomersWithNoMrn.Add(ecr.CustomerId);
                    _logger.Info("MRN not available for Customer ID : " + ecr.CustomerId);
                    return;
                }
            }

            if (_monarchAccountIds.Contains(corporateAccount.Id))
            {
                destinationFilename = ResultFileName(customer);
            }

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

            if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both)
            {
                var fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.PDF);

                var resultPdfFile = eventDirectoryPdf + "/" + fileName + ".pdf";
                _resultPdfDownloadHelper.ExportResultInPdfFormat(fileName + ".pdf", sourcePath, eventDirectoryPdf);

                _logger.Info("source Url: " + sourcePath);
                _logger.Info("destination Url: " + eventDirectoryPdf + "/" + fileName + ".pdf");

                if (File.Exists(resultPdfFile))
                {
                    var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultPdfFile);

                    resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.PDF, customer, ecr.Id));
                }
                else
                {
                    _logger.Info("File Not Found : " + resultPdfFile);
                }
            }

            if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both)
            {
                var fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.TIF);

                var resultTifFile = eventDirectoryPdf + "/" + fileName + ".tif";
                _resultPdfDownloadHelper.ExportResultInTiffFormat(fileName + ".tif", sourcePath, eventDirectoryPdf);

                _logger.Info("source Url: " + sourcePath);
                _logger.Info("destination Url: " + eventDirectoryPdf + "/" + fileName + ".tif");

                if (File.Exists(resultTifFile))
                {
                    var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultTifFile);
                    resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customer, ecr.Id));
                }
                else
                {
                    _logger.Info(string.Format("File {0} not Exist for pgp Encryption ", resultTifFile));
                }
            }
        }
コード例 #9
0
        private void SetResultPostedList(string tag, ResultPdfPostedXml resultPdfPosted)
        {
            var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", tag));

            _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPdfPosted);
        }
コード例 #10
0
        private void PostResultAccountWise(CorporateAccount corporateAccount, string destinationFolderPdf)
        {
            try
            {
                _resultPdfPostedXml = null;
                //_anthemPdfCrossWalkVeiwModel = null;
                _resultPdfNotPosted = null;

                var customerResultObject = new AnthemResultPostedViewModel
                {
                    Tag = corporateAccount.Tag,
                    DestinationFilePath = destinationFolderPdf,
                    ExportToTime        = DateTime.Now.AddHours(-1),
                    CorporateAccount    = corporateAccount,
                };

                var customerResults = GetEventCustomersToPostResult(customerResultObject);

                foreach (var ecr in customerResults)
                {
                    try
                    {
                        customerResultObject.EventCustomerResult = ecr;
                        SetSourcePath(customerResultObject);

                        if (File.Exists(customerResultObject.SourceFilePath))
                        {
                            var ec = _eventCustomerRepository.GetById(ecr.Id);
                            if (ec.AwvVisitId.HasValue)
                            {
                                try
                                {
                                    _logger.Info(" fetching NPI info for VistId :" + ec.AwvVisitId.Value);
                                    var visitDetails = new EhrAssignedNursePractitionerDetails
                                    {
                                        VisitId = ec.AwvVisitId.Value
                                    };

                                    // var model = _medicareApiService.PostAnonymous<EhrAssignedNursePractitionerDetails>(_settings.MedicareApiUrl + MedicareApiUrl.AssignedNursePractitionerDetails, visitDetails);
                                    var npi = string.Empty;
                                    if (!string.IsNullOrWhiteSpace(npi))
                                    {
                                        customerResultObject.Npi = npi;
                                        _logger.Info("NPI: " + npi + " for VistId :" + ec.AwvVisitId.Value);
                                    }
                                    else
                                    {
                                        var mssage = "NPI Is Null or Empty";
                                        mssage = mssage + " for visit id: " + ec.AwvVisitId.Value;
                                        _logger.Info(mssage);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("exception while fetching NPI information");
                                    _logger.Error("Message: " + ex.Message);
                                    _logger.Error("stack Trace: " + ex.StackTrace);
                                    AddToResultNotPosted(customerResultObject);
                                    continue;
                                }
                            }

                            SetEventCustomerDetail(customerResultObject);

                            SetDestinationFileNameWithoutExt(customerResultObject);

                            PostResultPdf(customerResultObject);
                        }
                        else
                        {
                            AddToResultNotPosted(customerResultObject);
                        }
                    }
                    catch (Exception exception)
                    {
                        _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));
                    }
                }

                SaveExportStartTime(customerResultObject);

                CreateResultPostedLoger(corporateAccount);

                SetResultPostedList(corporateAccount.Tag, _resultPdfPostedXml);

                SaveResultNotPosted(corporateAccount.Tag);
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("some error occurred for custom tag: {0} Exception Message: \n{1}, \n stack Trace: \n\t {2} ", corporateAccount.Id, ex.Message, ex.StackTrace));
            }
            finally
            {
                _resultPdfPostedXml = null;
                //_anthemPdfCrossWalkVeiwModel = null;
                _resultPdfNotPosted = null;
                _customSettings     = null;
            }
        }
コード例 #11
0
        public List <CrosswalkInboundViewModel> Create(IEnumerable <Customer> customers, IEnumerable <ChaseOutbound> chaseOutbounds, IEnumerable <CustomerChaseCampaign> customerChaseCampaigns, IEnumerable <ChaseCampaign> chaseCampaigns,
                                                       IEnumerable <Relationship> relationships, IEnumerable <EventCustomer> eventCustomers, IEnumerable <EventCustomerResult> eventCustomerResults, IEnumerable <Event> events, CorporateAccount corporateAccount,
                                                       IEnumerable <CustomerEventScreeningTests> customerEventScreeningTests, IEnumerable <OrderedPair <long, long> > customerEventScreeningTestIdFileIdPairs)
        {
            var collection = new List <CrosswalkInboundViewModel>();

            ResultPdfPostedXml resultPosted = null;

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

            foreach (var eventCustomerResult in eventCustomerResults)
            {
                var customer = customers.FirstOrDefault(x => x.CustomerId == eventCustomerResult.CustomerId);
                if (customer == null)
                {
                    continue;
                }

                var theEvent = events.FirstOrDefault(x => x.Id == eventCustomerResult.EventId);
                if (theEvent == null)
                {
                    continue;
                }

                var chaseOutbound = chaseOutbounds.FirstOrDefault(x => x.CustomerId == customer.CustomerId);
                if (chaseOutbound == null)
                {
                    continue;
                }
                var customerChaseCampaign = !customerChaseCampaigns.IsNullOrEmpty() ? customerChaseCampaigns.FirstOrDefault(x => x.CustomerId == customer.CustomerId) : null;
                var campaign = !chaseCampaigns.IsNullOrEmpty() && customerChaseCampaign != null?chaseCampaigns.FirstOrDefault(x => x.Id == customerChaseCampaign.ChaseCampaignId) : null;

                var relationship  = !relationships.IsNullOrEmpty() && chaseOutbound.RelationshipId.HasValue ? relationships.FirstOrDefault(x => x.Id == chaseOutbound.RelationshipId.Value) : null;
                var eventCustomer = eventCustomers.First(x => x.CustomerId == customer.CustomerId);

                var postedPdf = resultPosted.Customer.FirstOrDefault(x => x.CustomerId == eventCustomerResult.CustomerId && x.EventId == eventCustomerResult.EventId);

                /*if (postedPdf != null)
                 * {
                 *  var eventScreeningTests = customerEventScreeningTests.Where(x => x.EventCustomerResultId == eventCustomerResult.Id);
                 *  if (eventScreeningTests.Any())
                 *  {
                 *      if (customerEventScreeningTestIdFileIdPairs.Any(x => eventScreeningTests.Select(est => est.Id).Contains(x.FirstValue)))
                 *          continue;
                 *  }
                 * }*/

                var crosswalkInboundViewModel = new CrosswalkInboundViewModel
                {
                    TenantId             = chaseOutbound.TenantId,
                    ClientId             = chaseOutbound.ClientId,
                    CampaignId           = campaign != null ? campaign.CampaignId : "",
                    IndividualIDNumber   = chaseOutbound.IndividualId,
                    ContractNumber       = chaseOutbound.ContractNumber,
                    ContractPersonNumber = chaseOutbound.ContractPersonNumber,
                    ConsumerId           = chaseOutbound.ConsumerId,
                    ExtractDate          = DateTime.Now,
                    RelationshipCode     = relationship != null ? "\"" + relationship.Code + "\"" : "",
                    LastName             = customer.Name.LastName,
                    FirstName            = customer.Name.FirstName,
                    BirthDate            = customer.DateOfBirth,
                    FileName             = GetResultPdfFileName(chaseOutbound, customer, eventCustomerResult, corporateAccount),
                    ServiceStartDate     = theEvent.EventDate,
                    ServiceEndDate       = theEvent.EventDate,
                    EventId          = eventCustomer.EventId,
                    CustomerId       = eventCustomer.CustomerId,
                    ClientProviderID = "NURSE",
                    ProjectTypeName  = "Wkly Mbr",
                    Npi        = "Dr. Pham",
                    DocumentID = customer.CustomerId.ToString()
                };

                collection.Add(crosswalkInboundViewModel);
            }

            return(collection);
        }