public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity)
        {
            var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList();

            var testResult = new FocAttestationTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId);

            if (customerEventScreeningTestEntity.TestMedia != null && customerEventScreeningTestEntity.TestMedia.Count > 0)
            {
                var fileEntityCollection = customerEventScreeningTestEntity.FileCollectionViaTestMedia.ToList();
                var testMediaEntity      = customerEventScreeningTestEntity.TestMedia.FirstOrDefault();

                testResult.ResultImage = new ResultMedia(testMediaEntity.MediaId)
                {
                    File          = GetFileObjectfromEntity(testMediaEntity.FileId, fileEntityCollection),
                    Thumbnail     = testMediaEntity.ThumbnailFileId != null ? new File(testMediaEntity.ThumbnailFileId.Value) : null,
                    ReadingSource = testMediaEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic
                };
            }

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

            return(testResult);
        }
Ejemplo n.º 2
0
        public IEnumerable <EventCustomerScreeningAggregate> Parse()
        {
            var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>();
            var testType      = TestType.FocAttestation;
            var directoryPath = GetFolderPathfor(_resultOutputPath);

            if (string.IsNullOrEmpty(directoryPath))
            {
                return(null);
            }

            var pdfFiles = Directory.GetFiles(directoryPath, "*.pdf");

            if (pdfFiles.IsNullOrEmpty())
            {
                _logger.Info("file path empty or not contain pdf");

                return(eventCustomerAggregates);
            }

            foreach (var filePath in pdfFiles)
            {
                long customerId = 0;

                try
                {
                    var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);

                    long.TryParse(fileNameWithoutExtension, out customerId);

                    if (customerId <= 0)
                    {
                        _logger.Error(string.Format("customerId not found in file Path  {0}", filePath));
                        continue;
                    }
                }
                catch (Exception exception)
                {
                    _logger.Error(string.Format("some Error occured while extracting customerId from file Path  {0} exception : {1} \n stacktrace: {2}", filePath, exception.Message, exception.StackTrace));
                    continue;
                }

                try
                {
                    bool isFOCAttestationPurchased = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)testType);

                    if (!isFOCAttestationPurchased)
                    {
                        _logger.Info("FOC Attestation is not availed by CustomerId[" + customerId + "].\n");
                        continue;
                    }

                    var foldertoSaveImage = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath;

                    var resultMedia = GetMediaFromPdfFile(filePath, foldertoSaveImage, testType.ToString());

                    if (resultMedia != null)
                    {
                        resultMedia.ReadingSource = ReadingSource.Automatic;

                        var testResult = new FocAttestationTestResult {
                            ResultImage = resultMedia
                        };

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

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

            return(eventCustomerAggregates);
        }