public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new QuantaFloABITestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId) { RepeatStudy = this.CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities) }; 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 }; } var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Any()) { var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.QuantaFloABI); 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; } }); } testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); return(testResult); }
public PcpResultExportModel SetQuantaFloABIData(PcpResultExportModel model, QuantaFloABITestResult testResult, bool useBlankValue = false) { if (testResult.Finding != null) { model.QuantaFloAbiResult = testResult.Finding.Label; } model.QuantaFloAbiUnableToScreen = testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0 ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); if ((testResult.ResultStatus != null && testResult.ResultStatus.SelfPresent) || (testResult.PhysicianInterpretation != null && testResult.PhysicianInterpretation.IsCritical)) { model.QuantaFloAbiCritical = PcpResultExportHelper.YesString; } else if (!useBlankValue) { model.QuantaFloAbiCritical = PcpResultExportHelper.NoString; } return(model); }
public IEnumerable <EventCustomerScreeningAggregate> Parse() { var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>(); var directoryPath = GetFolderPathfor(_resultOutputPath); if (string.IsNullOrEmpty(directoryPath)) { return(null); } var testType = TestType.QuantaFloABI; foreach (var filePath in Directory.GetFiles(directoryPath)) { long customerId = 0; if (string.IsNullOrEmpty(filePath) || !Path.GetExtension(filePath).ToLower().Contains("pdf")) { _logger.Info("file path empty or not contain pdf"); continue; } var fileName = Path.GetFileName(filePath); try { if (fileName.Split('_').Length > 2) { long.TryParse(fileName.Split('_')[2], out customerId); } } 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; } if (customerId <= 0) { _logger.Error(string.Format("customerId not found in file Path {0}", filePath)); continue; } try { bool isQuantaFloAbiPurchased = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)testType); if (!isQuantaFloAbiPurchased) { _logger.Info("QuantaFlo ABI 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) { var mediaFilePath = foldertoSaveImage + Path.GetFileNameWithoutExtension(resultMedia.File.Path) + ".pdf"; File.Copy(filePath, mediaFilePath); } var testResult = new QuantaFloABITestResult { ResultImage = resultMedia }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.QuantaFlo); _logger.Info(string.Concat("\nParsing succeeded for QuantaFlo-ABI 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.QuantaFlo, false); } } return(eventCustomerAggregates); }
public void CopyOverQuantaFloABIPdf(long eventId, long customerId, string saveFilePath, QuantaFloABITestResult testResult) { if (testResult == null || testResult.ResultImage == null) { return; } var destinationDirectory = Path.GetDirectoryName(saveFilePath); var supportDestDirectoryPath = destinationDirectory + @"\" + StringforMediaDirectory; if (!Directory.Exists(supportDestDirectoryPath)) { Directory.CreateDirectory(supportDestDirectoryPath); } string input = _mediaRepository.GetResultMediaFileLocation(customerId, eventId).PhysicalPath + testResult.ResultImage.File.Path; using (Image img = Image.FromFile(input)) { img.Save(supportDestDirectoryPath + "\\" + testResult.ResultImage.File.Path, System.Drawing.Imaging.ImageFormat.Jpeg); } }