public PcpResultExportModel SetAwvAbiData(PcpResultExportModel model, AwvAbiTestResult testResult, bool useBlankValue = false) { if (testResult.Finding != null) { model.AbiResult = testResult.Finding.Label; } model.AbiSystolicRArm = testResult.RightResultReadings != null ? testResult.RightResultReadings.SystolicArm != null?testResult.RightResultReadings.SystolicArm.Reading.ToString() : "" : ""; model.AbiSystolicRAnkle = testResult.RightResultReadings != null ? testResult.RightResultReadings.SystolicAnkle != null?testResult.RightResultReadings.SystolicAnkle.Reading.ToString() : "" : ""; model.AbiRightAbi = testResult.RightResultReadings != null ? testResult.RightResultReadings.ABI != null?testResult.RightResultReadings.ABI.Reading.ToString() : "" : ""; model.AbiSystolicLArm = testResult.LeftResultReadings != null ? testResult.LeftResultReadings.SystolicArm != null?testResult.LeftResultReadings.SystolicArm.Reading.ToString() : "" : ""; model.AbiSystolicLAnkle = testResult.LeftResultReadings != null ? testResult.LeftResultReadings.SystolicAnkle != null?testResult.LeftResultReadings.SystolicAnkle.Reading.ToString() : "" : ""; model.AbiLeftAbi = testResult.LeftResultReadings != null ? testResult.LeftResultReadings.ABI != null?testResult.LeftResultReadings.ABI.Reading.ToString() : "" : ""; model.AbiRepeatStudyUnreadable = PcpResultExportHelper.GetOutputFromBoolTypeResultReading(testResult.RepeatStudy); model.AbiUnabletoScreen = 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.AbiCritical = PcpResultExportHelper.YesString; } else if (!useBlankValue) { model.AbiCritical = PcpResultExportHelper.NoString; } if (testResult.PhysicianInterpretation != null) { model.AbiPhysicianNotes = testResult.PhysicianInterpretation.Remarks; } return(model); }
public TestResult Parse(DataRow dr) { _errorSummary = string.Empty; var testResult = new AwvAbiTestResult(); if (CheckifRowContainsAnyLreadingData(dr)) { testResult.LeftResultReadings = new PadTestReadings(); } if (CheckifRowContainsAnyRreadingData(dr)) { testResult.RightResultReadings = new PadTestReadings(); } //SetBloodPressureValues(testResult, dr); if (testResult.LeftResultReadings == null && testResult.RightResultReadings == null)//&& testResult.PressureReadings == null { return(null); } long leftFindingId = 0; long rightFindingId = 0; try { if (!IsDataRowItemEmpty(dr[ColumnRAbi])) { decimal s; if (decimal.TryParse(dr[ColumnRAbi].ToString(), out s)) { testResult.RightResultReadings.ABI = new ResultReading <decimal?>(ReadingLabels.RightABI) { ReadingSource = ReadingSource.Automatic, Reading = s }; rightFindingId = _testResultService.GetCalculatedStandardFinding(testResult.RightResultReadings.ABI.Reading, (int)TestType.AwvABI, null); } } } catch (Exception ex) { _errorSummary += "Data extraction for Right ABI failed. "; _logger.Error("\n Data extraction for Right ABI failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnRAnkleSystolic])) { int s; if (int.TryParse(dr[ColumnRAnkleSystolic].ToString(), out s)) { testResult.RightResultReadings.SystolicAnkle = new ResultReading <int?>(ReadingLabels.SystolicRAnkle) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } catch (Exception ex) { _errorSummary += "Data extraction for Right Ankle Systolic failed. "; _logger.Error("\n Data extraction for Right Ankle Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnRArmSystolic])) { int s; if (int.TryParse(dr[ColumnRArmSystolic].ToString(), out s)) { testResult.RightResultReadings.SystolicArm = new ResultReading <int?>(ReadingLabels.SystolicRArm) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } catch (Exception ex) { _errorSummary += "Data extraction for Right Arm Systolic failed. "; _logger.Error("\n Data extraction for Right Arm Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnLAbi])) { decimal s; if (decimal.TryParse(dr[ColumnLAbi].ToString(), out s)) { testResult.LeftResultReadings.ABI = new ResultReading <decimal?>(ReadingLabels.LeftABI) { ReadingSource = ReadingSource.Automatic, Reading = s }; leftFindingId = _testResultService.GetCalculatedStandardFinding(testResult.LeftResultReadings.ABI.Reading, (int)TestType.AwvABI, null); } } } catch (Exception ex) { _errorSummary += "Data extraction for Left ABI failed. "; _logger.Error("\n Data extraction for Left ABI failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnLAnkleSystolic])) { int s; if (int.TryParse(dr[ColumnLAnkleSystolic].ToString(), out s)) { testResult.LeftResultReadings.SystolicAnkle = new ResultReading <int?>(ReadingLabels.SystolicLAnkle) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } catch (Exception ex) { _errorSummary += "Data extraction for Left Ankle Systolic failed. "; _logger.Error("\n Data extraction for Left Ankle Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnLArmSystolic])) { int s = 0; if (int.TryParse(dr[ColumnLArmSystolic].ToString(), out s)) { testResult.LeftResultReadings.SystolicArm = new ResultReading <int?>(ReadingLabels.SystolicLArm) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } catch (Exception ex) { _errorSummary += "Data extraction for Left Arm Systolic failed. "; _logger.Error("\n Data extraction for Left Arm Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } testResult.Finding = GetAwvAbiFindingToConsider(leftFindingId, rightFindingId); return(testResult); }
public void LoadAwvAbiTestResults(HtmlDocument doc, AwvAbiTestResult testResult, bool removeLongDescription, IEnumerable <CustomerScreeningEvaluatinPhysicianViewModel> physicians, IEnumerable <EventPhysicianTest> eventPhysicianTests, List <OrderedPair <long, string> > technicianIdNamePairs, bool showUnreadableTest, IEnumerable <PhysicianEvaluation> eventCustomerPhysicianEvaluations, CustomerSkipReview customerSkipReview) { var incidentalFindings = _incidentalFindingRepository.GetAllIncidentalFinding((int)TestType.PAD); if (testResult != null) { var selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='AwvAbi-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-AwvAbi-div']"); if (selectedNode != null) { selectedNode.SetAttributeValue("style", "display:block;"); } _resultPdfHelper.SetPhysicianSignature(doc, "AwvAbi-primaryEvalPhysicianSign", "AwvAbi-overreadEvalPhysicianSign", physicians, eventPhysicianTests, eventCustomerPhysicianEvaluations, customerSkipReview); var readings = new TestResultRepository().GetAllReadings((int)TestType.PAD); decimal?leftAbi = null; decimal?rightAbi = null; foreach (var resultReading in readings) { switch (resultReading.Label) { case ReadingLabels.LeftABI: if (testResult.LeftResultReadings != null) { _resultPdfHelper.SetInputBox(doc, "AwvAbitxtLeftAbi", testResult.LeftResultReadings.ABI); if (testResult.LeftResultReadings.ABI != null && testResult.LeftResultReadings.ABI.Reading.HasValue) { leftAbi = testResult.LeftResultReadings.ABI.Reading; } } break; case ReadingLabels.SystolicLArm: if (testResult.LeftResultReadings != null) { _resultPdfHelper.SetInputBox(doc, "AwvAbitxtSystolicLeftArm", testResult.LeftResultReadings.SystolicArm); } break; case ReadingLabels.SystolicLAnkle: if (testResult.LeftResultReadings != null) { _resultPdfHelper.SetInputBox(doc, "AwvAbitxtSystolicLeftAnkle", testResult.LeftResultReadings.SystolicAnkle); } break; case ReadingLabels.RightABI: if (testResult.RightResultReadings != null) { _resultPdfHelper.SetInputBox(doc, "AwvAbitxtRightAbi", testResult.RightResultReadings.ABI); if (testResult.RightResultReadings.ABI != null && testResult.RightResultReadings.ABI.Reading.HasValue) { rightAbi = testResult.RightResultReadings.ABI.Reading; } } break; case ReadingLabels.SystolicRArm: if (testResult.RightResultReadings != null) { _resultPdfHelper.SetInputBox(doc, "AwvAbitxtSystolicRightArm", testResult.RightResultReadings.SystolicArm); } break; case ReadingLabels.SystolicRAnkle: if (testResult.RightResultReadings != null) { _resultPdfHelper.SetInputBox(doc, "AwvAbitxtSystolicRightAnkle", testResult.RightResultReadings.SystolicAnkle); } break; case ReadingLabels.RepeatStudy: _resultPdfHelper.SetCheckBox(doc, "RepeatStudyAwvAbiInputCheck", testResult.RepeatStudy); break; } } long leftFindingId = 0; if (leftAbi != null) { leftFindingId = _testResultService.GetCalculatedStandardFinding(leftAbi.Value, (int)TestType.AwvABI, null); } long rightFindingId = 0; if (rightAbi != null) { rightFindingId = _testResultService.GetCalculatedStandardFinding(rightAbi.Value, (int)TestType.AwvABI, null); } var standardFindingList = _standardFindingRepository.GetAllStandardFindings <decimal>((int)TestType.AwvABI); long findingId = 0; if (leftFindingId == rightFindingId) { findingId = leftFindingId; } else if (leftFindingId > 0 && rightFindingId > 0) { var lf = standardFindingList.Single(f => f.Id == leftFindingId); var rf = standardFindingList.Single(f => f.Id == rightFindingId); findingId = lf.WorstCaseOrder > rf.WorstCaseOrder ? lf.Id : rf.Id; } else { findingId = leftFindingId > rightFindingId ? leftFindingId : rightFindingId; } LoadAwvAbiFindings(doc, testResult.Finding, standardFindingList, findingId, true, (testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0 ? testResult.UnableScreenReason.First() : null)); _resultPdfHelper.SetTechnician(doc, testResult, "techAwvAbi", "technotesAwvAbi", technicianIdNamePairs); _resultPdfHelper.SetIncidentalFindings(doc, incidentalFindings, testResult.IncidentalFindings, "AwvAbiIncidentalFinding"); _resultPdfHelper.SetPhysicianRemarks(doc, testResult, "followUpAwvAbi", "criticalAwvAbi", "physicianRemarksAwvAbi"); _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.AwvABI, "AwvAbiUnableToScreen", testResult.UnableScreenReason); if (testResult.IncidentalFindings != null && testResult.IncidentalFindings.Any()) { selectedNode = doc.DocumentNode.SelectSingleNode("//p[@id='incidentalfinding-description-AwvAbi']"); if (selectedNode != null) { selectedNode.SetAttributeValue("style", "display:block;"); } } selectedNode = doc.DocumentNode.SelectSingleNode("//div[@id='AwvAbi-longdescription-div']"); if (selectedNode != null) { selectedNode.SetAttributeValue("style", removeLongDescription ? "display:none" : "display:block"); } } else { LoadAwvAbiFindings(doc, null, null, 0, false); _resultPdfHelper.SetUnableToScreenReasons(doc, TestType.AwvABI, "AwvAbiUnableToScreen", null); _resultPdfHelper.SetIncidentalFindings(doc, incidentalFindings, null, "AwvAbiIncidentalFinding"); } }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity) { var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList(); var testResult = new AwvAbiTestResult(customerEventScreeningTestsEntity.CustomerEventScreeningTestId) { LeftResultReadings = new PadTestReadings(), RightResultReadings = new PadTestReadings(), RepeatStudy = this.CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities) }; testResult.RightResultReadings.SystolicArm = CreateResultReadingforNullableInt((int)ReadingLabels.SystolicRArm, customerEventReadingEntities); testResult.RightResultReadings.SystolicAnkle = CreateResultReadingforNullableInt((int)ReadingLabels.SystolicRAnkle, customerEventReadingEntities); testResult.RightResultReadings.ABI = CreateResultReadingforNullableDecimal((int)ReadingLabels.RightABI, customerEventReadingEntities); testResult.LeftResultReadings.SystolicArm = CreateResultReadingforNullableInt((int)ReadingLabels.SystolicLArm, customerEventReadingEntities); testResult.LeftResultReadings.SystolicAnkle = CreateResultReadingforNullableInt((int)ReadingLabels.SystolicLAnkle, customerEventReadingEntities); testResult.LeftResultReadings.ABI = CreateResultReadingforNullableDecimal((int)ReadingLabels.LeftABI, customerEventReadingEntities); var standardFindings = new TestResultService().GetAllStandardFindings <decimal>((int)TestType.AwvABI); var standardFindingsLeftAbi = new TestResultService().GetAllStandardFindings <decimal>((int)TestType.AwvABI, (int)ReadingLabels.LeftABI); var standardFindingsRightAbi = new TestResultService().GetAllStandardFindings <decimal>((int)TestType.AwvABI, (int)ReadingLabels.RightABI); var testResultService = new TestResultService(); StandardFinding <decimal> leftResultFinding, rightResultFinding; leftResultFinding = rightResultFinding = null; if (standardFindings == null || standardFindings.Count < 1) { standardFindings = standardFindingsLeftAbi; } int findingId = 0; if (testResult.LeftResultReadings.ABI != null) { findingId = testResultService.GetCalculatedStandardFinding(testResult.LeftResultReadings.ABI.Reading, (int)TestType.AwvABI, standardFindingsLeftAbi != null && standardFindingsLeftAbi.Count() > 0 ? (int?)ReadingLabels.LeftABI : null); leftResultFinding = standardFindings.Where(f => f.Id == findingId).SingleOrDefault(); } if (testResult.RightResultReadings.ABI != null) { findingId = testResultService.GetCalculatedStandardFinding(testResult.RightResultReadings.ABI.Reading, (int)TestType.AwvABI, standardFindingsRightAbi != null && standardFindingsRightAbi.Count() > 0 ? (int?)ReadingLabels.RightABI : null); rightResultFinding = standardFindings.Where(f => f.Id == findingId).SingleOrDefault(); } if (standardFindingsLeftAbi == null || standardFindingsLeftAbi.Count() < 1) { var customerEventTestStandardFindingEntity = customerEventScreeningTestsEntity.CustomerEventTestStandardFinding.FirstOrDefault(); if (customerEventTestStandardFindingEntity != null) { var standardFindingTestReadingEntity = customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.LastOrDefault(); var standardFindingEntity = standardFindings.ToList().FindAll(standardFinding => standardFinding.Id == standardFindingTestReadingEntity.StandardFindingId).FirstOrDefault(); if (standardFindingEntity != null) { testResult.Finding = new StandardFinding <decimal>(standardFindingEntity.Id) { CustomerEventStandardFindingId = customerEventTestStandardFindingEntity.CustomerEventTestStandardFindingId, Label = standardFindingEntity.Label, MaxValue = Convert.ToInt32(standardFindingEntity.MaxValue), MinValue = Convert.ToInt32(standardFindingEntity.MinValue) }; } } else { testResult.Finding = GetFindingToConsider(leftResultFinding, rightResultFinding); if (testResult.Finding != null) { var standardFinding = standardFindings.Find(finding => finding.Id == testResult.Finding.Id); if (standardFinding != null) { testResult.Finding = standardFinding; } } } } else { var testReadingLAbiReading = customerEventReadingEntities.Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.LeftABI).SingleOrDefault(); var testReadingRAbiReading = customerEventReadingEntities.Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.RightABI).SingleOrDefault(); if (testReadingLAbiReading != null && testReadingLAbiReading.StandardFindingTestReadingId != null) { var standardFindingReadingEntity = customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventReading.ToList().Find(stdFindingTestReading => stdFindingTestReading.TestId == (int)TestType.AwvABI && stdFindingTestReading.ReadingId == (int)ReadingLabels.LeftABI); if (standardFindingReadingEntity != null) { testResult.LeftResultReadings.Finding = new StandardFinding <decimal>(standardFindingReadingEntity.StandardFindingId); } } else if (leftResultFinding != null) { testResult.LeftResultReadings.Finding = leftResultFinding; } if (testResult.LeftResultReadings.Finding != null) { testResult.LeftResultReadings.Finding = standardFindings.Where(sf => sf.Id == testResult.LeftResultReadings.Finding.Id).SingleOrDefault(); } //----------------------------------------------------------------------------------- if (testReadingRAbiReading != null && testReadingRAbiReading.StandardFindingTestReadingId != null) { var standardFindingReadingEntity = customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventReading.ToList().Find(stdFindingTestReading => stdFindingTestReading.TestId == (int)TestType.AwvABI && stdFindingTestReading.ReadingId == (int)ReadingLabels.RightABI); if (standardFindingReadingEntity != null) { testResult.RightResultReadings.Finding = new StandardFinding <decimal>(standardFindingReadingEntity.StandardFindingId); } } else if (rightResultFinding != null) { testResult.RightResultReadings.Finding = rightResultFinding; } if (testResult.RightResultReadings.Finding != null) { testResult.RightResultReadings.Finding = standardFindings.Where(sf => sf.Id == testResult.RightResultReadings.Finding.Id).SingleOrDefault(); } } return(testResult); }