public TestResult Parse(DataTable dtSourceFromExcel) { var testResult = new StrokeTestResult(); if (dtSourceFromExcel != null) { if (CheckifDatatableisValidfortheTestType(dtSourceFromExcel)) { testResult.LeftResultReadings = GetStrokeResultReadings(dtSourceFromExcel, FieldValueforBodySideLeft); testResult.RightResultReadings = GetStrokeResultReadings(dtSourceFromExcel, FieldValueforBodySideRight); if (testResult.LeftResultReadings != null) { if (testResult.LeftResultReadings.ICAEDV != null) { testResult.LeftResultReadings.ICAEDV.Label = ReadingLabels.LICAEDV; } if (testResult.LeftResultReadings.ICAPSV != null) { testResult.LeftResultReadings.ICAPSV.Label = ReadingLabels.LICAPSV; } } if (testResult.RightResultReadings != null) { if (testResult.RightResultReadings.ICAEDV != null) { testResult.RightResultReadings.ICAEDV.Label = ReadingLabels.RICAEDV; } if (testResult.RightResultReadings.ICAPSV != null) { testResult.RightResultReadings.ICAPSV.Label = ReadingLabels.RICAPSV; } } } } testResult.ResultImages = new List <ResultMedia>(); foreach (var path in _pathToMediaFolder) { var media = GetMediaforTest(path); if (media != null) { testResult.ResultImages.AddRange(media); } } if (testResult.LeftResultReadings == null && testResult.RightResultReadings == null && testResult.ResultImages.Count() < 1) { return(null); } return(testResult); }
public StrokeTestResult MapXmlToDomainObject(string filePathtoXml) { var testResult = new StrokeTestResult(); var xDoc = XDocument.Load(filePathtoXml); testResult.LeftResultReadings = GetStrokeTestReadings(xDoc, SideToCheckLeft); testResult.RightResultReadings = GetStrokeTestReadings(xDoc, SideToCheckRight); if (testResult.LeftResultReadings != null) { if (testResult.LeftResultReadings.ICAEDV != null) { testResult.LeftResultReadings.ICAEDV.Label = ReadingLabels.LICAEDV; } if (testResult.LeftResultReadings.ICAPSV != null) { testResult.LeftResultReadings.ICAPSV.Label = ReadingLabels.LICAPSV; } } if (testResult.RightResultReadings != null) { if (testResult.RightResultReadings.ICAEDV != null) { testResult.RightResultReadings.ICAEDV.Label = ReadingLabels.RICAEDV; } if (testResult.RightResultReadings.ICAPSV != null) { testResult.RightResultReadings.ICAPSV.Label = ReadingLabels.RICAPSV; } } bool isExceptionCaused; testResult.ResultImages = _mediaHelper.GetMediaSortedByDecimalValue(Directory.GetParent(filePathtoXml).FullName, _mediaLocation, TestType.Stroke.ToString(), out isExceptionCaused).ToList(); if (isExceptionCaused) { _errorSummary += "Media Extraction Failed. "; } return(testResult); }
private void GetDataImportedtoSystem(long customerId, IEnumerable <string> allImageFiles, IEnumerable <string> allXmlFiles) { bool strokeFound = false; bool aaaFound = false; var aaaPurchased = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AAA); var strokePurchased = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Stroke); var mediaLocation = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath; var aaaTestResult = new AAATestResult { ResultImages = new List <ResultMedia>() }; var strokeTestResult = new StrokeTestResult { ResultImages = new List <ResultMedia>() }; foreach (var imageFile in allImageFiles) { var fileName = Path.GetFileNameWithoutExtension(imageFile); string imageType = string.Empty; string xmlFile = ""; if (allXmlFiles.Count() == 0) { if (strokePurchased) { imageType = StrokeImageIdentifier; } else if (aaaPurchased) { imageType = AaaImageIdentifier; } } else { var startIndex = fileName.IndexOf("["); var endIndex = fileName.IndexOf("]"); if (startIndex < 0 || endIndex < 0) { continue; } var identifier = fileName.Substring(startIndex + 1, endIndex - (startIndex + 1)).ToLower(); xmlFile = allXmlFiles.Where(f => Path.GetFileNameWithoutExtension(f).ToLower().Contains(identifier)).SingleOrDefault(); if (string.IsNullOrEmpty(xmlFile)) { continue; } imageType = GetImageTypefromXmlFile(xmlFile); } if (string.IsNullOrEmpty(imageType)) { continue; } imageType = imageType.ToLower(); if (imageType == AaaImageIdentifier) { aaaFound = true; if (!aaaPurchased) { continue; } var resultMedia = _mediaHelper.GetfromImageFile(new FileInfo(imageFile), "Aaa", mediaLocation); aaaTestResult.ResultImages.Add(resultMedia); } else if (imageType == StrokeImageIdentifier) { strokeFound = true; if (!strokePurchased) { continue; } var resultMedia = _mediaHelper.GetfromImageFile(new FileInfo(imageFile), "Stroke", mediaLocation); strokeTestResult.ResultImages.Add(resultMedia); } else { _logger.Info(string.Format("Invalid Image Identifier = [{0}] from XML = [{1}].", imageType, xmlFile)); } } if (!aaaPurchased && aaaFound) { _logger.Info(string.Format("AAA not purchased by Customer [{0}], but files are found.", customerId)); } else if (aaaPurchased && aaaFound) { _resultParserHelper.AddTestResulttoEventCustomerAggregate(_eventCustomerScreeningAggregates, _eventId, customerId, aaaTestResult); _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.AAA, customerId, MedicalEquipmentTag.UltrasoundTransducer); } else if (aaaPurchased) { _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.AAA, customerId, MedicalEquipmentTag.UltrasoundTransducer, false); } if (!strokePurchased && strokeFound) { _logger.Info(string.Format("Stroke not purchased by Customer [{0}], but files are found.", customerId)); } else if (strokePurchased && strokeFound) { _resultParserHelper.AddTestResulttoEventCustomerAggregate(_eventCustomerScreeningAggregates, _eventId, customerId, strokeTestResult); _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.Stroke, customerId, MedicalEquipmentTag.UltrasoundTransducer); } else if (strokePurchased) { _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.Stroke, customerId, MedicalEquipmentTag.UltrasoundTransducer, false); } }