예제 #1
0
        public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity)
        {
            var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList();

            var testResult = new EAwvTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId);

            var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList();
            var standardFindingTestReadingEntities       = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList();

            if (customerEventTestStandardFindingEntities.Count() > 0)
            {
                var testResultService = new TestResultService();
                var standardFindings  = testResultService.GetAllStandardFindings <int?>((int)TestType.eAWV);

                customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity =>
                {
                    var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId);
                    if (standardFindingTestReadingEntity == null)
                    {
                        return;
                    }

                    var finding = CreateFindingObject(customerEventTestStandardFindingEntity, standardFindings, standardFindingTestReadingEntity, null);
                    if (finding != null)
                    {
                        testResult.Finding = finding; return;
                    }
                });
            }

            var testMediaCollection  = customerEventScreeningTestEntity.TestMedia.ToList();
            var fileEntityCollection = customerEventScreeningTestEntity.FileCollectionViaTestMedia.ToList();

            if (testMediaCollection.Count > 0)
            {
                var resultMedia = new List <ResultMedia>();
                testMediaCollection.ForEach(testMedia => resultMedia.Add(new ResultMedia(testMedia.MediaId)
                {
                    File          = GetFileObjectfromEntity(testMedia.FileId, fileEntityCollection),
                    Thumbnail     = testMedia.ThumbnailFileId != null ? new File(testMedia.ThumbnailFileId.Value) : null,
                    ReadingSource = testMedia.IsManual ? ReadingSource.Manual : ReadingSource.Automatic
                }));

                testResult.ResultImages = resultMedia;
            }


            testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities);
            testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities);

            return(testResult);
        }
예제 #2
0
        public IEnumerable <EventCustomerScreeningAggregate> Parse()
        {
            var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>();
            var mediaLocation           = _mediaRepository.GetEawvHraResultMediaLocation();
            var mediaArchiveLocation    = _mediaRepository.GetEawvHraResultArchiveMediaLocation();

            try
            {
                var xmlFilePaths = Directory.GetFiles(mediaLocation.PhysicalPath, "*.xml");

                foreach (var xmlfile in xmlFilePaths)
                {
                    _logger.Info("reading xml File: " + xmlfile);
                    HraResultTags eawvHraResult = null;
                    try
                    {
                        eawvHraResult = _eawvHraSerializer.Deserialize(xmlfile);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Some error occurred while reading xml. Message: " + ex.Message);
                        _logger.Error("Stack Trace: " + ex.StackTrace);
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                    }

                    if (eawvHraResult == null)
                    {
                        _logger.Info("Some error occurred while reading xml.");
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                    }

                    if (eawvHraResult.Events.IsNullOrEmpty())
                    {
                        _logger.Info("No Event Data found for Tag: " + eawvHraResult.Name);
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                        continue;
                    }

                    var eventid = eawvHraResult.Events.First().EventId;

                    var account = _corporateAccountRepository.GetbyEventId(eventid);

                    if (account == null)
                    {
                        _logger.Info("No Corporate Account For Event Id: " + eventid);
                        File.Move(xmlfile, Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile)));
                        continue;
                    }

                    _logger.Info("Running for corporate Account " + account.Tag);

                    var theEvent = _eventRepository.GetById(eventid);

                    QuestionnaireType questionnaireType = QuestionnaireType.None;
                    if (account != null && account.IsHealthPlan && theEvent != null)
                    {
                        questionnaireType = _accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, theEvent.EventDate);
                    }

                    if (questionnaireType != QuestionnaireType.HraQuestionnaire)
                    {
                        _logger.Info("HRA Questionnaire is not started");
                        continue;
                    }

                    var eawvTestNotPurchsed = new HraResultTags
                    {
                        Name   = eawvHraResult.Name,
                        Events = new List <HraResultEvent>()
                    };

                    foreach (var hraResultEvent in eawvHraResult.Events)
                    {
                        var eventCustomers = _eventCustomerRepository.GetbyEventId(hraResultEvent.EventId);

                        if (eventCustomers.IsNullOrEmpty())
                        {
                            _logger.Info("No Event Cusotmer found");
                            continue;
                        }

                        var customeridNotToParse = eventCustomers.Where(x => x.NoShow || x.LeftWithoutScreeningReasonId.HasValue).Select(x => x.CustomerId);

                        var snapshotFolderPath     = Path.Combine(mediaLocation.PhysicalPath, eawvHraResult.Name, hraResultEvent.EventId.ToString(), HraFolderSnapshot);
                        var preventionFolderPlan   = Path.Combine(mediaLocation.PhysicalPath, eawvHraResult.Name, hraResultEvent.EventId.ToString(), HraFolderPreventionPlan);
                        var resultReportFolderPath = Path.Combine(mediaLocation.PhysicalPath, eawvHraResult.Name, hraResultEvent.EventId.ToString(), HraFolderResultReport);

                        var snapShotCustomerIds       = (hraResultEvent.Snapshot != null && !hraResultEvent.Snapshot.CustomerId.IsNullOrEmpty()) ? hraResultEvent.Snapshot.CustomerId.Where(c => !customeridNotToParse.Contains(c)).Select(c => c).Distinct() : new List <long>();
                        var preventionPlanCustomerIds = (hraResultEvent.PreventionPlan != null && !hraResultEvent.PreventionPlan.CustomerId.IsNullOrEmpty()) ? hraResultEvent.PreventionPlan.CustomerId.Where(c => !customeridNotToParse.Contains(c)).Select(c => c).Distinct() : new List <long>();
                        var resultReportCustomerIds   = (hraResultEvent.ResultReport != null && !hraResultEvent.ResultReport.CustomerId.IsNullOrEmpty()) ? hraResultEvent.ResultReport.CustomerId.Where(c => !customeridNotToParse.Contains(c)).Select(c => c).Distinct() : new List <long>();

                        _logger.Info(string.Format("============================Reading Snapshot for Tag:{0} EventId {1}=================================", eawvHraResult.Name, hraResultEvent.EventId));
                        _logger.Info(string.Format("snapshot folder Path: {0}", snapshotFolderPath));

                        var customerTestNotPurchased = new List <long>();
                        if (Directory.Exists(snapshotFolderPath))
                        {
                            _logger.Info("Count: " + snapShotCustomerIds.Count());
                            foreach (var customerId in snapShotCustomerIds)
                            {
                                var snapShotFilePath = Path.Combine(snapshotFolderPath, customerId + ".pdf");

                                if (!File.Exists(snapShotFilePath))
                                {
                                    _logger.Info("SnapShot File does not exist at following location: " + snapShotFilePath);
                                    continue;
                                }

                                _logger.Info("SnapShot File exists at location: " + snapShotFilePath);

                                var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(hraResultEvent.EventId, customerId, (long)TestType.eAWV);

                                if (!isEAwvTestPurchasedByCustomer)
                                {
                                    customerTestNotPurchased.Add(customerId);
                                    _logger.Info("EAWV : EAWV tests is not availed by CustomerId [" + customerId + "].\n");
                                    continue;
                                }

                                try
                                {
                                    var mediaFiles = new List <ResultMedia>();

                                    string folderToSavePdf = _mediaRepository.GetResultMediaFileLocation(customerId, hraResultEvent.EventId).PhysicalPath;
                                    _logger.Info("Get Snapshot Media");
                                    var snapShotResultMedia = GetMediaFromPdfFile(snapShotFilePath, folderToSavePdf, TestType.eAWV, AwvFileTypes.SnapShot);

                                    if (snapShotResultMedia != null)
                                    {
                                        _logger.Info("Inside SpanShot Result Media");

                                        snapShotResultMedia.ReadingSource = ReadingSource.Automatic;

                                        mediaFiles.Add(snapShotResultMedia);

                                        if (preventionPlanCustomerIds.Any(c => c == customerId))
                                        {
                                            var preventionPlanFile = Path.Combine(preventionFolderPlan,
                                                                                  customerId + ".pdf");

                                            if (File.Exists(preventionPlanFile))
                                            {
                                                var preventionPlanMedia = GetMediaFromPdfFile(preventionPlanFile,
                                                                                              folderToSavePdf, TestType.eAWV, AwvFileTypes.PreventionPlan);
                                                if (preventionFolderPlan != null)
                                                {
                                                    preventionPlanMedia.ReadingSource = ReadingSource.Automatic;
                                                    mediaFiles.Add(preventionPlanMedia);
                                                    preventionPlanCustomerIds =
                                                        preventionPlanCustomerIds.Where(c => c != customerId).ToList();
                                                }
                                            }
                                            else
                                            {
                                                _logger.Info(
                                                    "Prevention Plan File does not exist at following location: " +
                                                    preventionPlanFile);
                                            }
                                        }

                                        if (resultReportCustomerIds.Any(c => c == customerId))
                                        {
                                            var resultReportFile = Path.Combine(resultReportFolderPath,
                                                                                customerId + ".pdf");

                                            if (File.Exists(resultReportFile))
                                            {
                                                var resultExportMedia = GetMediaFromPdfFile(resultReportFile,
                                                                                            folderToSavePdf, TestType.eAWV, AwvFileTypes.ResultExport);
                                                if (resultExportMedia != null)
                                                {
                                                    resultExportMedia.ReadingSource = ReadingSource.Automatic;
                                                    mediaFiles.Add(resultExportMedia);

                                                    resultReportCustomerIds =
                                                        resultReportCustomerIds.Where(c => c != customerId).ToList();
                                                }
                                            }
                                            else
                                            {
                                                _logger.Info(
                                                    "Result Report File does not exist at following location: " +
                                                    resultReportFile);
                                            }
                                        }
                                        var testResult = new EAwvTestResult {
                                            ResultImages = mediaFiles
                                        };

                                        _logger.Info("Inside SnapShot for adding Customer Aggregate");
                                        _resultParserHelper.AddTestResulttoEventCustomerAggregate(
                                            eventCustomerAggregates, hraResultEvent.EventId, customerId, testResult);
                                        _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.eAWV, customerId,
                                                                                MedicalEquipmentTag.HRA);
                                    }
                                    else
                                    {
                                        _logger.Info("SpanShot Result Media Not Found");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("EAwv HRA: System Failure! Message: " + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                                    _resultParserHelper.AddResultArchiveLog(ex.Message, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                }
                            }
                        }
                        else
                        {
                            _logger.Info("Snapshot Directory does not exit for EventId " + hraResultEvent.EventId);
                            _logger.Info("Snapshot Directory Path " + hraResultEvent.EventId);
                        }

                        _logger.Info(string.Format("============================Reading Prevention Plan for Tag:{0} EventId {1}=================================", eawvHraResult.Name, hraResultEvent.EventId));
                        _logger.Info(string.Format("Prevention Plan folder Path: {0}", preventionFolderPlan));


                        if (Directory.Exists(preventionFolderPlan))
                        {
                            foreach (var customerId in preventionPlanCustomerIds)
                            {
                                var preventionFilePath = Path.Combine(preventionFolderPlan, customerId + ".pdf");

                                if (!File.Exists(preventionFilePath))
                                {
                                    _logger.Info("Prevention Plan File does not exist at following location: " + preventionFilePath);
                                    continue;
                                }

                                var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(hraResultEvent.EventId, customerId, (long)TestType.eAWV);

                                if (!isEAwvTestPurchasedByCustomer)
                                {
                                    customerTestNotPurchased.Add(customerId);
                                    _logger.Info("EAWV : EAWV tests is not availed by CustomerId [" + customerId + "].\n");
                                    continue;
                                }
                                try
                                {
                                    var    mediaFiles                = new List <ResultMedia>();
                                    string folderToSavePdf           = _mediaRepository.GetResultMediaFileLocation(customerId, hraResultEvent.EventId).PhysicalPath;
                                    var    preventionPlanResultMedia = GetMediaFromPdfFile(preventionFilePath, folderToSavePdf, TestType.eAWV, AwvFileTypes.PreventionPlan);

                                    if (preventionPlanResultMedia != null)
                                    {
                                        preventionPlanResultMedia.ReadingSource = ReadingSource.Automatic;
                                        mediaFiles.Add(preventionPlanResultMedia);

                                        if (resultReportCustomerIds.Any(c => c == customerId))
                                        {
                                            var resultReportFile = Path.Combine(resultReportFolderPath, customerId + ".pdf");

                                            if (File.Exists(resultReportFile))
                                            {
                                                var resultExportaMedia = GetMediaFromPdfFile(resultReportFile, folderToSavePdf, TestType.eAWV, AwvFileTypes.ResultExport);
                                                if (resultExportaMedia != null)
                                                {
                                                    resultExportaMedia.ReadingSource = ReadingSource.Automatic;
                                                    mediaFiles.Add(resultExportaMedia);

                                                    resultReportCustomerIds = resultReportCustomerIds.Where(c => c != customerId).ToList();
                                                }
                                            }
                                            else
                                            {
                                                _logger.Info("Result Report File does not exist at following location: " + resultReportFile);
                                            }
                                        }
                                        var testResult = new EAwvTestResult {
                                            ResultImages = mediaFiles
                                        };
                                        _logger.Info("Inside PreventionPLan for adding Customer Aggregate");
                                        _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, hraResultEvent.EventId, customerId, testResult);
                                        _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("EAwv HRA: System Failure! Message: " + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                                    _resultParserHelper.AddResultArchiveLog(ex.Message, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                }
                            }
                        }
                        else
                        {
                            _logger.Info("Prevention Plan Directory does not exit for EventId " + hraResultEvent.EventId);
                            _logger.Info("Prevention Plan Directory Path " + hraResultEvent.EventId);
                        }

                        _logger.Info(string.Format("============================Reading Result Report for Tag:{0} EventId {1}=================================", eawvHraResult.Name, hraResultEvent.EventId));
                        _logger.Info(string.Format("Result Report folder Path: {0}", resultReportFolderPath));


                        if (Directory.Exists(resultReportFolderPath))
                        {
                            foreach (var customerId in resultReportCustomerIds)
                            {
                                var resultReportFilePath = Path.Combine(resultReportFolderPath, customerId + ".pdf");

                                if (!File.Exists(resultReportFilePath))
                                {
                                    _logger.Info("Result Report File does not exist at following location: " + resultReportFilePath);
                                    continue;
                                }

                                var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(hraResultEvent.EventId, customerId, (long)TestType.eAWV);

                                if (!isEAwvTestPurchasedByCustomer)
                                {
                                    customerTestNotPurchased.Add(customerId);
                                    _logger.Info("EAWV : EAWV tests is not availed by CustomerId [" + customerId + "].\n");
                                    continue;
                                }
                                try
                                {
                                    var    mediaFiles        = new List <ResultMedia>();
                                    string folderToSavePdf   = _mediaRepository.GetResultMediaFileLocation(customerId, hraResultEvent.EventId).PhysicalPath;
                                    var    resultExportMedia = GetMediaFromPdfFile(resultReportFilePath, folderToSavePdf, TestType.eAWV, AwvFileTypes.ResultExport);

                                    if (resultExportMedia != null)
                                    {
                                        resultExportMedia.ReadingSource = ReadingSource.Automatic;
                                        mediaFiles.Add(resultExportMedia);

                                        var testResult = new EAwvTestResult {
                                            ResultImages = mediaFiles
                                        };
                                        _logger.Info("Inside Result Report for adding Customer Aggregate");
                                        _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, hraResultEvent.EventId, customerId, testResult);
                                        _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _logger.Error("EAwv HRA: System Failure! Message: " + ex.Message + "\n\t Stack Trace: " + ex.StackTrace);
                                    _resultParserHelper.AddResultArchiveLog(ex.Message, TestType.eAWV, customerId, MedicalEquipmentTag.HRA);
                                }
                            }
                        }
                        else
                        {
                            _logger.Info("Result Report Directory does not exit for EventId " + hraResultEvent.EventId);
                            _logger.Info("Result Report Directory Path " + hraResultEvent.EventId);
                        }

                        if (!customerTestNotPurchased.IsNullOrEmpty())
                        {
                            eawvTestNotPurchsed.Events.Add(new HraResultEvent
                            {
                                EventId        = hraResultEvent.EventId,
                                PreventionPlan = new HraResultPreventionPlan {
                                    CustomerId = customerTestNotPurchased.ToList()
                                },
                                Snapshot = new HraResultSnapshot {
                                    CustomerId = customerTestNotPurchased.ToList()
                                },
                                ResultReport = new HraResultReport()
                                {
                                    CustomerId = customerTestNotPurchased.ToList()
                                }
                            });
                        }
                    }
                    if (!eawvTestNotPurchsed.Events.IsNullOrEmpty())
                    {
                        _eawvHraSerializer.SerializeandSave(Path.Combine(mediaLocation.PhysicalPath, "customerNotPurchaseTest_" + DateTime.Now.ToFileTime() + ".xml"), eawvTestNotPurchsed);
                    }

                    try
                    {
                        var archiveFileName = Path.Combine(mediaArchiveLocation.PhysicalPath, Path.GetFileName(xmlfile));
                        if (File.Exists(archiveFileName))
                        {
                            File.Delete(archiveFileName);
                        }
                        File.Move(xmlfile, archiveFileName);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("Error while moving XML File in Archive folder");
                        _logger.Info(string.Format("Message: {0}", ex.Message));
                        _logger.Info(string.Format("stackTrace: {0}", ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Some Error occurred while parsing Eawv Result");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }

            _logger.Info("EAWVParser eventCustomerAggregates count " + eventCustomerAggregates.Count);
            return(eventCustomerAggregates);
        }
예제 #3
0
        public IEnumerable <EventCustomerScreeningAggregate> Parse()
        {
            var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>();

            var directoryPreventionPlanPath = GetFolderPathfor(_resultOutputPreventionPlanPath);
            var directorySnapShotPath       = GetFolderPathfor(_resultOutputSanpShotPath);

            if (string.IsNullOrEmpty(directoryPreventionPlanPath) && string.IsNullOrEmpty(directorySnapShotPath))
            {
                return(null);
            }

            List <string> snapShotFiles       = null;
            List <string> preventionPlanFiles = null;

            if (!string.IsNullOrEmpty(directorySnapShotPath))
            {
                snapShotFiles = GetPdfFiles(directorySnapShotPath);
            }

            if (!string.IsNullOrEmpty(directoryPreventionPlanPath))
            {
                preventionPlanFiles = GetPdfFiles(directoryPreventionPlanPath);
            }

            if (snapShotFiles != null && snapShotFiles.Any())
            {
                foreach (var filePath in snapShotFiles)
                {
                    var customerIdString = Path.GetFileNameWithoutExtension(filePath);

                    long customerId = 0;
                    if (!long.TryParse(customerIdString, out customerId))
                    {
                        _logger.Info("AWV Snap Shot: CustomerId not found on Pdf file" + filePath);
                        continue;
                    }

                    bool isAwvTestPurchasedByCustomer      = false;
                    bool isMedicareTestPurchasedByCustomer = false;

                    try
                    {
                        isAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AWV);
                        if (!isAwvTestPurchasedByCustomer)
                        {
                            isMedicareTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Medicare);
                            if (!isMedicareTestPurchasedByCustomer)
                            {
                                bool isAwvSubsequentTestPurchadedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvSubsequent);
                                if (!isAwvSubsequentTestPurchadedByCustomer)
                                {
                                    _logger.Info("AWV Snap Shot: None of AWV tests is availed by CustomerId[" + customerId + "].\n");
                                    continue;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Info("AWV Snap Shot: None of the AWV tests is availed by CustomerId[" + customerId + "]. Exception Caused.\n Message: " + ex.Message + ".\t Stack Trace:" + ex.StackTrace);

                        continue;
                    }

                    TestType testType;

                    if (isAwvTestPurchasedByCustomer)
                    {
                        testType = TestType.AWV;
                    }
                    else if (isMedicareTestPurchasedByCustomer)
                    {
                        testType = TestType.Medicare;
                    }
                    else
                    {
                        testType = TestType.AwvSubsequent;
                    }

                    try
                    {
                        string folderToSavePdf     = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath;
                        var    snapShotResultMedia = GetMediaFromPdfFile(filePath, folderToSavePdf, testType, AwvFileTypes.SnapShot);

                        var mediaFiles = new List <ResultMedia>();
                        if (snapShotResultMedia != null)
                        {
                            mediaFiles.Add(snapShotResultMedia);

                            if (preventionPlanFiles != null && preventionPlanFiles.Any())
                            {
                                var preventionPlanFile = preventionPlanFiles.Where(ppf => Path.GetFileNameWithoutExtension(ppf) == customerIdString).Select(ppf => ppf).SingleOrDefault();
                                if (!string.IsNullOrEmpty(preventionPlanFile))
                                {
                                    var preventionPlanrResultMedia = GetMediaFromPdfFile(preventionPlanFile, folderToSavePdf, testType, AwvFileTypes.PreventionPlan);
                                    mediaFiles.Add(preventionPlanrResultMedia);
                                    preventionPlanFiles.Remove(preventionPlanFile);
                                }
                            }

                            TestResult testResult = null;
                            if (testType == TestType.AWV)
                            {
                                testResult = new AwvTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;
                            else if (testType == TestType.Medicare)
                            {
                                testResult = new MedicareTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;
                            else if (testType == TestType.AwvSubsequent)
                            {
                                testResult = new AwvSubsequentTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;

                            _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult);
                            _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.AWVPP);

                            _logger.Info(string.Concat("\n AWV Snap Shot.Parsing succeeded for Customer Id: ", customerId, "\n"));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("AWV Snap Shot: System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace);
                        _resultParserHelper.AddResultArchiveLog(ex.Message, testType, customerId, MedicalEquipmentTag.AWVPP, false);
                    }
                }
            }

            //Prevention Plan Files
            if (preventionPlanFiles != null && preventionPlanFiles.Any())
            {
                foreach (var filePath in preventionPlanFiles)
                {
                    var customerIdString = Path.GetFileNameWithoutExtension(filePath);

                    long customerId = 0;
                    if (!long.TryParse(customerIdString, out customerId))
                    {
                        _logger.Info("AWV Prevention Plan: CustomerId not found on Pdf file" + filePath);
                        continue;
                    }

                    bool isAwvTestPurchasedByCustomer           = false;
                    bool isMedicareTestPurchasedByCustomer      = false;
                    bool isAwvSubsequentTestPurchadedByCustomer = false;

                    try
                    {
                        isAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AWV);
                        if (!isAwvTestPurchasedByCustomer)
                        {
                            isMedicareTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Medicare);
                            if (!isMedicareTestPurchasedByCustomer)
                            {
                                isAwvSubsequentTestPurchadedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvSubsequent);
                                if (!isAwvSubsequentTestPurchadedByCustomer)
                                {
                                    var isEAwvTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.eAWV);
                                    if (!isEAwvTestPurchasedByCustomer)
                                    {
                                        _logger.Info("AWV Prevention Plan: None of AWV tests is availed by CustomerId[" + customerId + "].\n");
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Info("AWV Prevention Plan: None of the AWV tests is availed by CustomerId[" + customerId + "]. Exception Caused.\n Message: " + ex.Message + ".\t Stack Trace:" + ex.StackTrace);

                        continue;
                    }

                    TestType testType;

                    if (isAwvTestPurchasedByCustomer)
                    {
                        testType = TestType.AWV;
                    }
                    else if (isMedicareTestPurchasedByCustomer)
                    {
                        testType = TestType.Medicare;
                    }
                    else if (isAwvSubsequentTestPurchadedByCustomer)
                    {
                        testType = TestType.AwvSubsequent;
                    }
                    else
                    {
                        testType = TestType.eAWV;
                    }

                    try
                    {
                        string folderToSavePdf            = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath;
                        var    preventionPlanrResultMedia = GetMediaFromPdfFile(filePath, folderToSavePdf, testType, AwvFileTypes.PreventionPlan);

                        var mediaFiles = new List <ResultMedia>();
                        if (preventionPlanrResultMedia != null)
                        {
                            mediaFiles.Add(preventionPlanrResultMedia);

                            TestResult testResult = null;
                            if (testType == TestType.AWV)
                            {
                                testResult = new AwvTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;
                            else if (testType == TestType.Medicare)
                            {
                                testResult = new MedicareTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;
                            else if (testType == TestType.AwvSubsequent)
                            {
                                testResult = new AwvSubsequentTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;
                            else if (testType == TestType.eAWV)
                            {
                                testResult = new EAwvTestResult {
                                    ResultImages = mediaFiles
                                }
                            }
                            ;

                            _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult);
                            _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.AWVPP);

                            _logger.Info(string.Concat("\nParsing succeeded for Customer Id: ", customerId, "\n"));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error("AWV Prevention Plan: System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace);
                        _resultParserHelper.AddResultArchiveLog(ex.Message, testType, customerId, MedicalEquipmentTag.AWVPP, false);
                    }
                }
            }

            return(eventCustomerAggregates);
        }