public IEnumerable <EventCustomerScreeningAggregate> Parse() { var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>(); var directoryPath = GetFolderPathfor(_resultOutputPath); if (string.IsNullOrEmpty(directoryPath)) { return(null); } foreach (var filePath in Directory.GetFiles(directoryPath)) { _isSpiroFile = false; // IsEkgIppeFile = false; if (Path.GetExtension(filePath).ToLower().Contains("pdf")) { var fileName = Path.GetFileName(filePath); if (fileName.ToLower().StartsWith(SpiroFilePrefix.ToLower())) { _isSpiroFile = true; } //if (fileName.ToLower().StartsWith(EkgIppeFilePreFix.ToLower())) // IsEkgIppeFile = true; var customerIdString = ""; if (_isSpiroFile) { var tempFileName = fileName.Substring(fileName.IndexOf("_") + 1); customerIdString = tempFileName.Substring(0, tempFileName.IndexOf("_")); } //else if (IsEkgIppeFile) //{ // if (fileName.ToLower().StartsWith(EkgIppeFilePreFix.ToLower())) // { // var tempFileName = fileName.Substring(fileName.IndexOf("_") + 1); // customerIdString = tempFileName.Substring(0, tempFileName.IndexOf("_")); // } // else // customerIdString = fileName.Substring(0, fileName.IndexOf("_")); //} else { if (fileName.ToLower().StartsWith(EkgFilePrefix.ToLower())) { var tempFileName = fileName.Substring(fileName.IndexOf("_") + 1); customerIdString = tempFileName.Substring(0, tempFileName.IndexOf("_")); } else { customerIdString = fileName.Substring(0, fileName.IndexOf("_")); } } long customerId = 0; if (!long.TryParse(customerIdString, out customerId)) { _logger.Info("CustomerId not found on Pdf file" + filePath); continue; } bool isSpiroTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Spiro); bool isAwvSpiroTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvSpiro); bool isEkgTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.EKG); bool isAwvEkgTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvEkg); bool isAwvEkgIppeTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvEkgIPPE); try { if (_isSpiroFile) { if (!isSpiroTestPurchasedByCustomer && !isAwvSpiroTestPurchasedByCustomer) { _logger.Info("Spiro is not availed by CustomerId[" + customerId + "].\n"); continue; } } else { if (!isEkgTestPurchasedByCustomer && !isAwvEkgTestPurchasedByCustomer && !isAwvEkgIppeTestPurchasedByCustomer) { _logger.Info("EKG/ECG is not availed by CustomerId[" + customerId + "].\n"); continue; } } } catch (Exception ex) { if (_isSpiroFile) { _logger.Info("Spiro is not availed by CustomerId[" + customerId + "]. Exception Caused.\n Message: " + ex.Message + ".\t Stack Trace:" + ex.StackTrace); } else { _logger.Info("EKG/ECG is not availed by CustomerId[" + customerId + "]. Exception Caused.\n Message: " + ex.Message + ".\t Stack Trace:" + ex.StackTrace); } continue; } try { TestType testType; TestResult testResult = null; if (_isSpiroFile) { testType = TestType.Spiro; if (isAwvSpiroTestPurchasedByCustomer) { testType = TestType.AwvSpiro; } string folderToSaveImage = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath; var resultMedia = GetMediaFromPdfFile(filePath, folderToSaveImage, testType.ToString(), false); if (resultMedia != null) { if (isAwvSpiroTestPurchasedByCustomer) { testResult = new AwvSpiroTestResult { ResultImage = resultMedia }; } else if (isSpiroTestPurchasedByCustomer) { testResult = new SpiroTestResult { ResultImage = resultMedia }; } _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.Schiller); _logger.Info(string.Concat("\nParsing succeeded for Spiro for Customer Id: ", customerId, "\n")); } } else { testType = TestType.EKG; if (isAwvEkgIppeTestPurchasedByCustomer) //&& IsEkgIppeFile { testType = TestType.AwvEkgIPPE; } else if (isAwvEkgTestPurchasedByCustomer) { testType = TestType.AwvEkg; } string folderToSaveImage = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath; var resultMedia = GetMediaFromPdfFile(filePath, folderToSaveImage, testType.ToString()); if (resultMedia != null) { switch (testType) { case TestType.EKG: testResult = new EKGTestResult { ResultImage = resultMedia }; break; case TestType.AwvEkg: testResult = new AwvEkgTestResult { ResultImage = resultMedia }; break; case TestType.AwvEkgIPPE: testResult = new AwvEkgIppeTestResult { ResultImage = resultMedia }; break; } _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.Schiller); _logger.Info(string.Concat("\nParsing succeeded for EKG for Customer Id: ", customerId, "\n")); } } } catch (Exception ex) { if (_isSpiroFile) { _logger.Error("System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace); _resultParserHelper.AddResultArchiveLog(ex.Message, isAwvSpiroTestPurchasedByCustomer ? TestType.AwvSpiro : TestType.Spiro, customerId, MedicalEquipmentTag.Schiller, false); } else { _logger.Error("System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace); _resultParserHelper.AddResultArchiveLog(ex.Message, isAwvEkgIppeTestPurchasedByCustomer ? TestType.AwvEkgIPPE : isAwvEkgTestPurchasedByCustomer ? TestType.AwvEkg : TestType.EKG, customerId, MedicalEquipmentTag.Schiller, false); } } } } return(eventCustomerAggregates); }
public PcpResultExportModel SetAwvEkgData(PcpResultExportModel model, AwvEkgTestResult testResult, bool useBlankValue = false) { if (testResult.Finding != null) { model.EkgResult = testResult.Finding.Label; } model.EkgRepeatStudy = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RepeatStudy, useBlankValue); model.EkgReversedLeads = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.ReversedLeads, useBlankValue); model.EkgArtifact = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.Artifact, useBlankValue); model.EkgComparetoPreviousEkg = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.ComparetoEkg, useBlankValue); model.EkgSinusRhythm = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SinusRythm, useBlankValue); model.EkgSinusArrhythmia = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SinusArrythmia, useBlankValue); model.EkgSinusBradycardia = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SinusBradycardia, useBlankValue); model.EkgSinusBradycardiaMarkLessFifty = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.Marked, useBlankValue); model.EkgSinusTachycardia = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SinusTachycardia, useBlankValue); model.EkgAtrialFibrillation = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.AtrialFibrillation, useBlankValue); model.EkgAtrialFlutter = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.AtrialFlutter, useBlankValue); model.EkgSupraventricularArrhythmia = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SupraventricularArrythmia, useBlankValue); model.EkgSvt = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SVT, useBlankValue); model.EkgPac = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.PACs, useBlankValue); model.EkgPvc = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.PVCs, useBlankValue); model.EkgPacerRhythm = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.PacerRythm, useBlankValue); model.EkgBundleBranchBlock = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.BundleBranchBlock, useBlankValue); if (testResult.BundleBranchBlockFinding != null && testResult.BundleBranchBlockFinding.Count > 0) { model.EkgBundleBranchBlockLeft = testResult.BundleBranchBlockFinding.Where(am => am.Id == PcpResultExportHelper.Left).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgBundleBranchBlockRight = testResult.BundleBranchBlockFinding.Where(am => am.Id == PcpResultExportHelper.Right).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgBundleBranchBlockIncomplete = testResult.BundleBranchBlockFinding.Where(am => am.Id == PcpResultExportHelper.Incomplete).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgBundleBranchBlockIvcdns = testResult.BundleBranchBlockFinding.Where(am => am.Id == PcpResultExportHelper.Ivcdns).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgBundleBranchBlockBifasc = testResult.BundleBranchBlockFinding.Where(am => am.Id == PcpResultExportHelper.Bifasc).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); } else if (!useBlankValue) { model.EkgBundleBranchBlockLeft = PcpResultExportHelper.NoString; model.EkgBundleBranchBlockRight = PcpResultExportHelper.NoString; model.EkgBundleBranchBlockIncomplete = PcpResultExportHelper.NoString; model.EkgBundleBranchBlockIvcdns = PcpResultExportHelper.NoString; model.EkgBundleBranchBlockBifasc = PcpResultExportHelper.NoString; } model.EkgQrsWidening = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.QRSWidening, useBlankValue); model.EkgLeftAxis = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.LeftAxis, useBlankValue); model.EkgRightAxis = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RightAxis, useBlankValue); model.EkgAbnormalAxis = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.AbnormalAxis, useBlankValue); model.EkgAbnormalAxisLeft = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.Left, useBlankValue); model.EkgAbnormalAxisRight = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.Right, useBlankValue); model.EkgLeftAnteriorFasicularBlock = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.LeftAnteriorFasicularBlock, useBlankValue); model.EkgAvNodalHeartBlock = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.HeartBlock, useBlankValue); model.EkgAvNodalHeartBlockFirstDegree = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.FirstDegreeBlock, useBlankValue); model.EkgAvNodalHeartBlockSecondDegreeMobitzOne = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.SecondDegreeBlock, useBlankValue); model.EkgAvNodalHeartBlockSecondDegreeMobitzTwo = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.TypeII, useBlankValue); model.EkgAvNodalHeartBlockThirdDegree = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.ThirdDegreeCompleteHeartBlock, useBlankValue); model.EkgShortPrIinterval = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.ShortPrInterval, useBlankValue); model.EkgRoVentricularHypertrophy = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.VentricularHypertrophy, useBlankValue); model.EkgRoVentricularHypertrophyLeft = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.LeftVentricularHypertrophy, useBlankValue); model.EkgRoVentricularHypertrophyRight = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RightVentricularHypertrophy, useBlankValue); model.EkgProlongedQTcInterval = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.ProlongedQTInterval, useBlankValue); model.EkgRoIschemicSttChanges = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.IschemicSTTChanges, useBlankValue); model.EkgNonSpecificSttChanges = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.NonSpecificSTTChanges, useBlankValue); model.EkgPoorRWaveProgression = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.PoorRWaveProgression, useBlankValue); model.EkgRoInfarctionPattern = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.InfarctionPattern, useBlankValue); if (testResult.InfarctionPatternFinding != null && testResult.InfarctionPatternFinding.Count > 0) { model.EkgRoInfarctionPatternSeptal = testResult.InfarctionPatternFinding.Where(am => am.Id == PcpResultExportHelper.Septal).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgRoInfarctionPatternPosterior = testResult.InfarctionPatternFinding.Where(am => am.Id == PcpResultExportHelper.Posterior).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgRoInfarctionPatternAnterior = testResult.InfarctionPatternFinding.Where(am => am.Id == PcpResultExportHelper.Anterior).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgRoInfarctionPatternLateral = testResult.InfarctionPatternFinding.Where(am => am.Id == PcpResultExportHelper.Lateral).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); model.EkgRoInfarctionPatternInferior = testResult.InfarctionPatternFinding.Where(am => am.Id == PcpResultExportHelper.Inferior).Select(am => am).Any() ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString); } else if (!useBlankValue) { model.EkgRoInfarctionPatternSeptal = PcpResultExportHelper.NoString; model.EkgRoInfarctionPatternPosterior = PcpResultExportHelper.NoString; model.EkgRoInfarctionPatternAnterior = PcpResultExportHelper.NoString; model.EkgRoInfarctionPatternLateral = PcpResultExportHelper.NoString; model.EkgRoInfarctionPatternInferior = PcpResultExportHelper.NoString; } model.EkgAtypicalQWavelead = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.AtypicalQWaveLead, useBlankValue); model.EkgAtrialEnlargement = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.AtrialEnlargement, useBlankValue); model.EkgAtrialEnlargementLeft = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.LeftAtrialEnlargement, useBlankValue); model.EkgAtrialEnlargementRight = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RightAtrialEnlargement, useBlankValue); model.EkgRepolarizationVariant = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RepolarizationVariant, useBlankValue); model.EkgLowVoltage = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.LowVoltage, useBlankValue); model.EkgLowVoltageLimbleads = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.LimbLeads, useBlankValue); model.EkgLowVoltagePrecordialleads = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.PrecordialLeads, useBlankValue); model.EkgUnabletoScreen = 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.EkgCritical = PcpResultExportHelper.YesString; } else if (!useBlankValue) { model.EkgCritical = PcpResultExportHelper.NoString; } if (testResult.PhysicianInterpretation != null) { model.EkgPhysicianNotes = testResult.PhysicianInterpretation.Remarks; } return(model); }
public void LoadAwvEkgTestResults(HtmlDocument doc, AwvEkgTestResult testResult, bool removeLongDescription, List <OrderedPair <long, string> > technicianIdNamePairs, bool loadImages, IEnumerable <CustomerScreeningEvaluatinPhysicianViewModel> physicians, IEnumerable <EventPhysicianTest> eventPhysicianTests, bool showUnreadableTest, IEnumerable <PhysicianEvaluation> eventCustomerPhysicianEvaluation, CustomerSkipReview customerSkipReview, string stringforMediaDirectory) { var bbbFindings = _standardFindingRepository.GetAllStandardFindings <int>((Int32)TestType.AwvEkg, (Int32)ReadingLabels.BundleBranchBlock); var ipFindings = _standardFindingRepository.GetAllStandardFindings <int>((Int32)TestType.AwvEkg, (Int32)ReadingLabels.InfarctionPattern); if (testResult != null) { var selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='AwvEkg-rpp-section']"); if (selectedNode != null && (testResult.UnableScreenReason == null || testResult.UnableScreenReason.Count == 0) && (testResult.TestNotPerformed == null || testResult.TestNotPerformed.TestNotPerformedReasonId <= 0) && (showUnreadableTest || testResult.RepeatStudy == null || testResult.RepeatStudy.Reading == false)) { selectedNode.SetAttributeValue("style", "display:block;"); } selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='rpp-eus-AwvEkg-div']"); if (selectedNode != null) { selectedNode.SetAttributeValue("style", "display:block;"); } _resultPdfHelper.SetPhysicianSignature(doc, "AwvEkg-primaryEvalPhysicianSign", "AwvEkg-overreadEvalPhysicianSign", physicians, eventPhysicianTests, eventCustomerPhysicianEvaluation, customerSkipReview); LoadAwvEkgFindings(doc, testResult.Finding, true, (testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0 ? testResult.UnableScreenReason.First() : null)); _resultPdfHelper.SetInputBox(doc, "AwvEkgprIntervalTextbox", testResult.PRInterval); _resultPdfHelper.SetInputBox(doc, "AwvEkgventRateTextbox", testResult.VentRate); _resultPdfHelper.SetInputBox(doc, "AwvEkgqrsDurationTextbox", testResult.QRSDuration); _resultPdfHelper.SetInputBox(doc, "AwvEkgqtIntervalTextbox", testResult.QTInterval); _resultPdfHelper.SetInputBox(doc, "AwvEkgqtcInterval", testResult.QTcInterval); _resultPdfHelper.SetCheckBox(doc, "AwvEkgReversedLeadInputCheck", testResult.ReversedLeads); _resultPdfHelper.SetCheckBox(doc, "AwvEkgRepeatStudyInputCheck", testResult.RepeatStudy); _resultPdfHelper.SetCheckBox(doc, "AwvEkgArtifactInputCheck", testResult.Artifact); _resultPdfHelper.SetCheckBox(doc, "ComparetoPrevAwvEkgInputCheck", testResult.ComparetoEkg); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSinusRythmInputCheck", testResult.SinusRythm); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSinusArrythmiaInputCheck", testResult.SinusArrythmia); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSinusBradycardiaInputCheck", testResult.SinusBradycardia); _resultPdfHelper.SetCheckBox(doc, "AwvEkgMarkedInputCheck", testResult.Marked); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSinusTachycardiaInputCheck", testResult.SinusTachycardia); _resultPdfHelper.SetCheckBox(doc, "AwvEkgAtrialFibrillationInputCheck", testResult.AtrialFibrillation); _resultPdfHelper.SetCheckBox(doc, "AwvEkgAtrialFlutterInputCheck", testResult.AtrialFlutter); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSupraventriculaCheckbox", testResult.SupraventricularArrythmia); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSvtInputCheck", testResult.SVT); _resultPdfHelper.SetCheckBox(doc, "AwvEkgPacInputCheck", testResult.PACs); _resultPdfHelper.SetCheckBox(doc, "AwvEkgPvcInputCheck", testResult.PVCs); _resultPdfHelper.SetCheckBox(doc, "AwvEkgPacerRythmCheckbox", testResult.PacerRythm); _resultPdfHelper.SetCheckBox(doc, "AwvEkgBundleBranchBlockCheckbox", testResult.BundleBranchBlock); _resultPdfHelper.SetFindingsHorizontal(doc, testResult.BundleBranchBlockFinding, bbbFindings, "AwvEkgBundleBranchBlockFinding", 3); _resultPdfHelper.SetCheckBox(doc, "AwvEkgQrsWideningInputCheck", testResult.QRSWidening); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLeftAxisInputCheck", testResult.LeftAxis); _resultPdfHelper.SetCheckBox(doc, "AwvEkgRightAxisInputCheck", testResult.RightAxis); _resultPdfHelper.SetCheckBox(doc, "AwvEkgAbnormalAxisInputCheck", testResult.AbnormalAxis); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLeftInputCheck", testResult.Left); _resultPdfHelper.SetCheckBox(doc, "AwvEkgRightInputCheck", testResult.Right); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLeftAnteriorfasicularBlockCheckbox", testResult.LeftAnteriorFasicularBlock); _resultPdfHelper.SetCheckBox(doc, "AwvEkgHeartBlockInputCheck", testResult.HeartBlock); _resultPdfHelper.SetCheckBox(doc, "AwvEkgFirstDegreeBlockInputCheck", testResult.FirstDegreeBlock); _resultPdfHelper.SetCheckBox(doc, "AwvEkgSecondDegreeBlockCheckbox", testResult.SecondDegreeBlock); _resultPdfHelper.SetCheckBox(doc, "AwvEkgTypeIIInputCheck", testResult.TypeII); _resultPdfHelper.SetCheckBox(doc, "AwvEkgThirdDegreeBlockInputCheck", testResult.ThirdDegreeCompleteHeartBlock); _resultPdfHelper.SetCheckBox(doc, "AwvEkgVentricularCheckbox", testResult.VentricularHypertrophy); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLeftVentricularCheckbox", testResult.LeftVentricularHypertrophy); _resultPdfHelper.SetCheckBox(doc, "AwvEkgRightVentricularCheckbox", testResult.RightVentricularHypertrophy); _resultPdfHelper.SetCheckBox(doc, "AwvEkgProlongedQTCheckbox", testResult.ProlongedQTInterval); _resultPdfHelper.SetCheckBox(doc, "AwvEkgISchemicSttCheckbox", testResult.IschemicSTTChanges); _resultPdfHelper.SetCheckBox(doc, "AwvEkgNonSpecificSttCheckbox", testResult.NonSpecificSTTChanges); _resultPdfHelper.SetCheckBox(doc, "AwvEkgPoorRWaveProgressionCheckbox", testResult.PoorRWaveProgression); _resultPdfHelper.SetCheckBox(doc, "AwvEkgInfarctionPatternCheckbox", testResult.InfarctionPattern); _resultPdfHelper.SetCheckBox(doc, "AwvEkgATypicalWaveCheckbox", testResult.AtypicalQWaveLead); _resultPdfHelper.SetCheckBox(doc, "AwvEkgAtrialEnlargementCheckbox", testResult.AtrialEnlargement); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLeftAtrialCheckbox", testResult.LeftAtrialEnlargement); _resultPdfHelper.SetCheckBox(doc, "AwvEkgRightAtrialCheckbox", testResult.RightAtrialEnlargement); _resultPdfHelper.SetCheckBox(doc, "AwvEkgRepolarizationCheckbox", testResult.RepolarizationVariant); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLowVoltageCheckbox", testResult.LowVoltage); _resultPdfHelper.SetCheckBox(doc, "AwvEkgLimbLeadsCheckbox", testResult.LimbLeads); _resultPdfHelper.SetCheckBox(doc, "AwvEkgPrecordialLeadsCheckbox", testResult.PrecordialLeads); _resultPdfHelper.SetCheckBox(doc, "AwvEkgShortPrIntervalCheckbox", testResult.ShortPrInterval); _resultPdfHelper.SetFindingsHorizontal(doc, testResult.InfarctionPatternFinding, ipFindings, "AwvEkgInfarctionPatternFinding", 2); if (testResult.ResultImage != null && (testResult.UnableScreenReason == null || testResult.UnableScreenReason.Count == 0) && (showUnreadableTest || testResult.RepeatStudy == null || testResult.RepeatStudy.Reading == false)) { _resultPdfHelper.LoadTestMedia(doc, new[] { testResult.ResultImage }, "testmedia-AwvEkg", loadImages); selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='AwvEkgReport']"); if (selectedNode != null) { selectedNode.SetAttributeValue("style", "display:block"); } selectedNode = doc.DocumentNode.SelectSingleNode("//img[@id='AwvEkgGraph']"); if (selectedNode != null) { selectedNode.SetAttributeValue("src", stringforMediaDirectory + "/" + testResult.ResultImage.File.Path); } } _resultPdfHelper.SetTechnician(doc, testResult, "techAwvEkg", "technotesAwvEkg", technicianIdNamePairs); _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.AwvEkg, "AwvEkgUnableToScreen", testResult.UnableScreenReason); _resultPdfHelper.SetPhysicianRemarks(doc, testResult, "followUpAwvEkg", "criticalAwvEkg", "AwvEkgPhysicianNotesTextbox"); selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='AwvEkg-longdescription-div']"); if (selectedNode != null) { selectedNode.SetAttributeValue("style", removeLongDescription ? "display:none" : "display:block"); } } else { LoadAwvEkgFindings(doc, null, false); _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.AwvEkg, "AwvEkgUnableToScreen", null); _resultPdfHelper.SetFindingsHorizontal(doc, new StandardFinding <int>(), bbbFindings, "AwvEkgBundleBranchBlockFinding", 3); _resultPdfHelper.SetFindingsHorizontal(doc, new StandardFinding <int>(), ipFindings, "AwvEkgInfarctionPatternFinding", 2); } }
public void CopyOverAwvEkgGraph(long eventId, long customerId, string saveFilePath, AwvEkgTestResult testResult) { if (testResult == null || testResult.ResultImage == null) { return; } var destinationDirectory = Path.GetDirectoryName(saveFilePath); var supportDestDirectoryPath = destinationDirectory + @"\" + StringforMediaDirectory; if (!DirectoryOperationsHelper.IsDirectoryExist(supportDestDirectoryPath)) { DirectoryOperationsHelper.CreateDirectory(supportDestDirectoryPath); } string input = _mediaRepository.GetResultMediaFileLocation(customerId, eventId).PhysicalPath + testResult.ResultImage.File.Path; using (Image img = Image.FromFile(input)) { //rotate the picture by 90 degrees and re-save the picture as a Jpeg img.RotateFlip(RotateFlipType.Rotate270FlipNone); img.Save(supportDestDirectoryPath + "\\" + testResult.ResultImage.File.Path, System.Drawing.Imaging.ImageFormat.Jpeg); } }
public IEnumerable <EventCustomerScreeningAggregate> Parse() { var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>(); var directoryPath = GetFolderPathfor(_resultOutputPath); if (string.IsNullOrEmpty(directoryPath)) { return(null); } foreach (var filePath in DirectoryOperationsHelper.GetFiles(directoryPath)) { if (Path.GetExtension(filePath).ToLower().Contains("pdf")) { _logger.Info("Parsing file : " + filePath); var fileName = Path.GetFileName(filePath); bool isSpiro = false; var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); isSpiro = fileNameWithoutExtension.ToLower().EndsWith(SpiroFilePrefix); var searchPattern = fileName.Substring(0, GetIndexOfNthOccurence(fileName, '_', 5)) + "*" + (isSpiro ? "_spiro.pdf" : "_ecg.pdf"); var versionedFiles = DirectoryOperationsHelper.GetFiles(directoryPath, searchPattern).Select(Path.GetFileName);; var latestVersion = versionedFiles.OrderByDescending(x => x).First(); if (Path.GetFileName(filePath) != latestVersion) { _logger.Info("A more recent version of this file is present : " + latestVersion); continue; } var customerIdString = fileName.IndexOf("_") > 0 ? fileName.Substring(0, fileName.IndexOf("_")) : fileName; long customerId; if (!long.TryParse(customerIdString, out customerId)) { _logger.Info("Customer ID not found on Pdf file : " + filePath); continue; } if (!isSpiro) { bool isEkgTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.EKG); bool isAwvEkgTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvEkg); bool isAwvEkgIppeTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvEkgIPPE); try { if (!isEkgTestPurchasedByCustomer && !isAwvEkgTestPurchasedByCustomer && !isAwvEkgIppeTestPurchasedByCustomer) { _logger.Info("EKG/ECG is not availed by CustomerId[" + customerId + "].\n"); continue; } } catch (Exception ex) { _logger.Info("EKG/ECG is not availed by CustomerId[" + customerId + "]. Exception Caused.\n Message: " + ex.Message + ".\t Stack Trace:" + ex.StackTrace); continue; } try { TestResult testResult = null; var testType = TestType.EKG; if (isAwvEkgIppeTestPurchasedByCustomer) //&& IsEkgIppeFile { testType = TestType.AwvEkgIPPE; } else if (isAwvEkgTestPurchasedByCustomer) { testType = TestType.AwvEkg; } var folderToSaveImage = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath; var resultMedia = GetMediaFromPdfFile(filePath, folderToSaveImage, testType.ToString()); resultMedia.ReadingSource = ReadingSource.Automatic; if (resultMedia != null) { switch (testType) { case TestType.EKG: testResult = new EKGTestResult { ResultImage = resultMedia }; break; case TestType.AwvEkg: testResult = new AwvEkgTestResult { ResultImage = resultMedia }; break; case TestType.AwvEkgIPPE: testResult = new AwvEkgIppeTestResult { ResultImage = resultMedia }; break; } _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.CardioCard); _logger.Info(string.Concat("\nParsing succeeded for EKG for Customer Id: ", customerId, "\n")); } } catch (Exception ex) { _logger.Error("System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace); _resultParserHelper.AddResultArchiveLog(ex.Message, isAwvEkgIppeTestPurchasedByCustomer ? TestType.AwvEkgIPPE : isAwvEkgTestPurchasedByCustomer ? TestType.AwvEkg : TestType.EKG, customerId, MedicalEquipmentTag.CardioCard, false); } } else if (isSpiro) { bool isSpiroTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.Spiro); bool isAwvSpiroTestPurchasedByCustomer = _testResultService.IsTestPurchasedByCustomer(_eventId, customerId, (long)TestType.AwvSpiro); try { if (!isSpiroTestPurchasedByCustomer && !isAwvSpiroTestPurchasedByCustomer) { _logger.Info("SPIRO/AWVSPIRO is not availed by CustomerId[" + customerId + "].\n"); continue; } } catch (Exception ex) { _logger.Info("SPIRO/AWVSPIRO is not availed by CustomerId[" + customerId + "]. Exception Caused.\n Message: " + ex.Message + ".\t Stack Trace:" + ex.StackTrace); continue; } try { TestResult testResult = null; var testType = TestType.Spiro; if (isAwvSpiroTestPurchasedByCustomer) { testType = TestType.AwvSpiro; } var folderToSaveImage = _mediaRepository.GetResultMediaFileLocation(customerId, _eventId).PhysicalPath; var resultMedia = GetMediaFromPdfFile(filePath, folderToSaveImage, testType.ToString(), false); resultMedia.ReadingSource = ReadingSource.Automatic; if (resultMedia != null) { switch (testType) { case TestType.Spiro: testResult = new SpiroTestResult { ResultImage = resultMedia }; break; case TestType.AwvSpiro: testResult = new AwvSpiroTestResult { ResultImage = resultMedia }; break; } _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, _eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, testType, customerId, MedicalEquipmentTag.CardioCard); _logger.Info(string.Concat("\nParsing succeeded for SPIRO/AWVSPIRO for Customer Id: ", customerId, "\n")); } } catch (Exception ex) { _logger.Error("System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace); _resultParserHelper.AddResultArchiveLog(ex.Message, isSpiroTestPurchasedByCustomer ? TestType.Spiro : TestType.AwvSpiro, customerId, MedicalEquipmentTag.CardioCard, false); } } } } return(eventCustomerAggregates); }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new AwvEkgTestResult(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); testResult.ResultImage.File = GetFileObjectfromEntity(testMediaEntity.FileId, fileEntityCollection); testResult.ResultImage.Thumbnail = testMediaEntity.ThumbnailFileId != null ? new File(testMediaEntity.ThumbnailFileId.Value) : null; if (testMediaEntity.IsManual) { testResult.ResultImage.ReadingSource = ReadingSource.Manual; } else { testResult.ResultImage.ReadingSource = ReadingSource.Automatic; } } var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.AwvEkg); var bundleBranchFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.AwvEkg, (int)ReadingLabels.BundleBranchBlock); var infarctionFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.AwvEkg, (int)ReadingLabels.InfarctionPattern); var standardFindingTestReadingEntities = customerEventScreeningTestEntity. StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var standardFindingEntity = standardFindings.ToList().FindAll(standardFinding => standardFinding.Id == standardFindingTestReadingEntity.StandardFindingId).FirstOrDefault(); if (standardFindingEntity != null) { testResult.Finding = new StandardFinding <int?>(standardFindingEntity.Id) { CustomerEventStandardFindingId = customerEventTestStandardFindingEntity. CustomerEventTestStandardFindingId, Label = standardFindingEntity.Label, MaxValue = Convert.ToInt32(standardFindingEntity.MaxValue), MinValue = Convert.ToInt32(standardFindingEntity.MinValue) }; return; } standardFindingEntity = bundleBranchFindings.ToList().FindAll(standardFinding => standardFinding.Id == standardFindingTestReadingEntity.StandardFindingId).FirstOrDefault(); if (standardFindingEntity != null) { var finding = new StandardFinding <int>(standardFindingEntity.Id) { CustomerEventStandardFindingId = customerEventTestStandardFindingEntity. CustomerEventTestStandardFindingId, Label = standardFindingEntity.Label, MaxValue = Convert.ToInt32(standardFindingEntity.MaxValue), MinValue = Convert.ToInt32(standardFindingEntity.MinValue) }; if (testResult.BundleBranchBlockFinding == null) { testResult.BundleBranchBlockFinding = new List <StandardFinding <int> >(); } testResult.BundleBranchBlockFinding.Add(finding); return; } standardFindingEntity = infarctionFindings.ToList().FindAll(standardFinding => standardFinding.Id == standardFindingTestReadingEntity.StandardFindingId).FirstOrDefault(); if (standardFindingEntity != null) { var finding = new StandardFinding <int>(standardFindingEntity.Id) { CustomerEventStandardFindingId = customerEventTestStandardFindingEntity. CustomerEventTestStandardFindingId, Label = standardFindingEntity.Label, MaxValue = Convert.ToInt32(standardFindingEntity.MaxValue), MinValue = Convert.ToInt32(standardFindingEntity.MinValue) }; if (testResult.InfarctionPatternFinding == null) { testResult.InfarctionPatternFinding = new List <StandardFinding <int> >(); } testResult.InfarctionPatternFinding.Add(finding); return; } }); testResult.PRInterval = CreateResultReadingforNullableDecimal((int)ReadingLabels.PRInterval, customerEventReadingEntities); testResult.QRSDuration = CreateResultReadingforNullableDecimal((int)ReadingLabels.QRSDuration, customerEventReadingEntities); testResult.QTcInterval = CreateResultReadingforNullableDecimal((int)ReadingLabels.QTcInterval, customerEventReadingEntities); testResult.PRTAxis = new PRTAxis(); testResult.PRTAxis.PFront = CreateResultReadingforNullableInt((int)ReadingLabels.PRTAxisPFront, customerEventReadingEntities); testResult.PRTAxis.QRSFront = CreateResultReadingforNullableInt((int)ReadingLabels.PRTAxisQRSFront, customerEventReadingEntities); testResult.PRTAxis.TFront = CreateResultReadingforNullableInt((int)ReadingLabels.PRTAxisTFront, customerEventReadingEntities); testResult.QTDispersion = CreateResultReadingforNullableInt((int)ReadingLabels.QTDispersion, customerEventReadingEntities); testResult.QTInterval = CreateResultReadingforNullableDecimal((int)ReadingLabels.QTInterval, customerEventReadingEntities); testResult.RRInterval = CreateResultReadingforNullableInt((int)ReadingLabels.RRInterval, customerEventReadingEntities); testResult.VentRate = CreateResultReadingforNullableInt((int)ReadingLabels.VentRate, customerEventReadingEntities); testResult.SinusRythm = CreateResultReading((int)ReadingLabels.SinusRythm, customerEventReadingEntities); testResult.SinusArrythmia = CreateResultReading((int)ReadingLabels.SinusArrythmia, customerEventReadingEntities); testResult.SinusBradycardia = CreateResultReading((int)ReadingLabels.SinusBradycardia, customerEventReadingEntities); testResult.Mild = CreateResultReading((int)ReadingLabels.Mild, customerEventReadingEntities); testResult.Marked = CreateResultReading((int)ReadingLabels.Marked, customerEventReadingEntities); testResult.SinusTachycardia = CreateResultReading((int)ReadingLabels.SinusTachycardia, customerEventReadingEntities); testResult.AtrialFibrillation = CreateResultReading((int)ReadingLabels.AtrialFibrillation, customerEventReadingEntities); testResult.AtrialFlutter = CreateResultReading((int)ReadingLabels.AtrialFlutter, customerEventReadingEntities); testResult.SVT = CreateResultReading((int)ReadingLabels.SVT, customerEventReadingEntities); testResult.PACs = CreateResultReading((int)ReadingLabels.PACs, customerEventReadingEntities); testResult.PVCs = CreateResultReading((int)ReadingLabels.PVCs, customerEventReadingEntities); testResult.QRSWidening = CreateResultReading((int)ReadingLabels.QRSWidening, customerEventReadingEntities); testResult.LeftAxis = CreateResultReading((int)ReadingLabels.LeftAxis, customerEventReadingEntities); testResult.RightAxis = CreateResultReading((int)ReadingLabels.RightAxis, customerEventReadingEntities); testResult.AbnormalAxis = CreateResultReading((int)ReadingLabels.AbnormalAxis, customerEventReadingEntities); testResult.Left = CreateResultReading((int)ReadingLabels.Left, customerEventReadingEntities); testResult.Right = CreateResultReading((int)ReadingLabels.Right, customerEventReadingEntities); testResult.HeartBlock = CreateResultReading((int)ReadingLabels.HeartBlock, customerEventReadingEntities); testResult.TypeI = CreateResultReading((int)ReadingLabels.TypeI, customerEventReadingEntities); testResult.TypeII = CreateResultReading((int)ReadingLabels.TypeII, customerEventReadingEntities); testResult.FirstDegreeBlock = CreateResultReading((int)ReadingLabels.FirstDegreeBlock, customerEventReadingEntities); testResult.SecondDegreeBlock = CreateResultReading((int)ReadingLabels.SecondDegreeBlock, customerEventReadingEntities); testResult.ThirdDegreeCompleteHeartBlock = CreateResultReading((int)ReadingLabels.ThirdDegreeCompleteHeartBlock, customerEventReadingEntities); testResult.Artifact = CreateResultReading((int)ReadingLabels.Artifact, customerEventReadingEntities); testResult.ShortPrInterval = CreateResultReading((int)ReadingLabels.ShortPrInterval, customerEventReadingEntities); testResult.BundleBranchBlock = CreateResultReading((int)ReadingLabels.BundleBranchBlock, customerEventReadingEntities); testResult.LeftAnteriorFasicularBlock = CreateResultReading((int)ReadingLabels.LeftAnteriorFasicularBlock, customerEventReadingEntities); testResult.VentricularHypertrophy = CreateResultReading((int)ReadingLabels.VentricularHypertrophy, customerEventReadingEntities); testResult.LeftVentricularHypertrophy = CreateResultReading((int)ReadingLabels.LeftVHypertrophy, customerEventReadingEntities); testResult.RightVentricularHypertrophy = CreateResultReading((int)ReadingLabels.RightVHypertrophy, customerEventReadingEntities); testResult.ProlongedQTInterval = CreateResultReading((int)ReadingLabels.ProlongedQTInterval, customerEventReadingEntities); testResult.IschemicSTTChanges = CreateResultReading((int)ReadingLabels.IschemicSTTChanges, customerEventReadingEntities); testResult.NonSpecificSTTChanges = CreateResultReading((int)ReadingLabels.NonSpecificSTTChanges, customerEventReadingEntities); testResult.PoorRWaveProgression = CreateResultReading((int)ReadingLabels.PoorRWaveProgression, customerEventReadingEntities); testResult.InfarctionPattern = CreateResultReading((int)ReadingLabels.InfarctionPattern, customerEventReadingEntities); testResult.AtypicalQWaveLead = CreateResultReading((int)ReadingLabels.AtypicalQWaveLead, customerEventReadingEntities); testResult.AtrialEnlargement = CreateResultReading((int)ReadingLabels.AtrialEnlargement, customerEventReadingEntities); testResult.LeftAtrialEnlargement = CreateResultReading((int)ReadingLabels.LeftAtrialEnlargment, customerEventReadingEntities); testResult.RightAtrialEnlargement = CreateResultReading((int)ReadingLabels.RightAtrialEnlargment, customerEventReadingEntities); testResult.RepolarizationVariant = CreateResultReading((int)ReadingLabels.RepolarizationVariant, customerEventReadingEntities); testResult.PacerRythm = CreateResultReading((int)ReadingLabels.PacerRythm, customerEventReadingEntities); testResult.SupraventricularArrythmia = CreateResultReading((int)ReadingLabels.SupraventricularArrythmia, customerEventReadingEntities); testResult.ReversedLeads = CreateResultReading((int)ReadingLabels.ReversedLeads, customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); testResult.ComparetoEkg = CreateResultReading((int)ReadingLabels.ComparetoEkg, customerEventReadingEntities); testResult.LowVoltage = CreateResultReading((int)ReadingLabels.LowVoltage, customerEventReadingEntities); testResult.LimbLeads = CreateResultReading((int)ReadingLabels.LimbLeads, customerEventReadingEntities); testResult.PrecordialLeads = CreateResultReading((int)ReadingLabels.PrecordialLeads, customerEventReadingEntities); return(testResult); }