public IEnumerable <TestResult> Parse(DataRow dr) { SaveBasicBiometric(dr); var asiTestResult = (ASITestResult)_asiTestRepository.GetTestResults(_customerId, _eventId, _isNewResultFlow); if (asiTestResult == null && _testResultService.IsTestPurchasedByCustomer(_eventId, _customerId, (long)TestType.ASI)) { asiTestResult = new ASITestResult(); } if (asiTestResult == null) { return(null); } var pressureReadings = GetBpValues(dr); if (pressureReadings == null) { return(null); } var testResults = new List <TestResult>(); asiTestResult.PressureReadings = SynchronizeBpValues(pressureReadings, asiTestResult.PressureReadings); testResults.Add(asiTestResult); return(testResults); }
public void OneValueOfASIReturnsSameValueAsTheAverage() { ASITestResult asiTestResult = new ASITestResult(); var reading = new ResultReading <int>() { Reading = 20 }; asiTestResult.RawASI = new List <ResultReading <int> >(); asiTestResult.RawASI.Add(reading); Assert.AreEqual(20, asiTestResult.AverageASI); }
public TestResult GetAsiTestResultDomain(KynHealthAssessmentEditModel model, ASITestResult inpersistence, long uploadedby, bool isNewResultFlow) { if (inpersistence == null) { inpersistence = new ASITestResult { PressureReadings = new CardiovisionPressureReadings { Pulse = new ResultReading <int?> { Reading = model.PulseRate }, DiastolicLeftArm = new ResultReading <int?>(), SystolicLeftArm = new ResultReading <int?>(), DiastolicRightArm = new ResultReading <int?>(), SystolicRightArm = new ResultReading <int?>() }, ResultStatus = new TestResultState { StateNumber = isNewResultFlow ? (int)NewTestResultStateNumber.ResultEntryPartial : (int)TestResultStateNumber.ManualEntry } }; } else { if (inpersistence.PressureReadings == null) { inpersistence.PressureReadings = new CardiovisionPressureReadings { Pulse = new ResultReading <int?> { Reading = model.PulseRate }, DiastolicLeftArm = new ResultReading <int?>(), SystolicLeftArm = new ResultReading <int?>(), DiastolicRightArm = new ResultReading <int?>(), SystolicRightArm = new ResultReading <int?>() }; } else { inpersistence.PressureReadings.Pulse = new ResultReading <int?> { Reading = model.PulseRate }; } } inpersistence.ResultStatus.DataRecorderMetaData = SetDataRecorderMetaData(inpersistence.ResultStatus.DataRecorderMetaData, uploadedby); inpersistence.DataRecorderMetaData = SetDataRecorderMetaData(inpersistence.DataRecorderMetaData, uploadedby); return(inpersistence); }
public void TwoValueOfASIOf20And30ShouldReturns25() { ASITestResult asiTestResult = new ASITestResult(); var reading1 = new ResultReading <int>() { Reading = 20 }; var reading2 = new ResultReading <int>() { Reading = 30 }; asiTestResult.RawASI = new List <ResultReading <int> >(); asiTestResult.RawASI.Add(reading1); asiTestResult.RawASI.Add(reading2); Assert.AreEqual(25, asiTestResult.AverageASI); }
public TestResult Parse(DataRow dr) { _errorSummary = string.Empty; if (!CheckifRowContainsAnyReadingData(dr)) { return(null); } var testResult = new ASITestResult(); if (!IsDataRowItemEmpty(dr[ColumnPulse]) || !IsDataRowItemEmpty(dr[ColumnPulsePressure]) || !IsDataRowItemEmpty(dr[ColumnSystolic]) || !IsDataRowItemEmpty(dr[ColumnDiastolic])) { testResult.PressureReadings = new CardiovisionPressureReadings(); } SetBloodPressureValues(testResult, dr); try { if (!IsDataRowItemEmpty(dr[ColumnAsi])) { int s = 0; if (int.TryParse(dr[ColumnAsi].ToString(), out s)) { var findingId = _testResultService.GetCalculatedStandardFinding(s, (int)TestType.ASI, (int)ReadingLabels.ASI); testResult.ASI = new CompoundResultReading <int?>(ReadingLabels.ASI) { ReadingSource = ReadingSource.Automatic, Reading = s, Finding = findingId > 0 ? new StandardFinding <int?>(findingId) : null }; } } } catch (Exception ex) { _errorSummary += "Data extraction for ASI failed. "; _logger.Error("\n Data extraction for ASI failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnPulse])) { int s = 0; if (int.TryParse(dr[ColumnPulse].ToString(), out s)) { testResult.PressureReadings.Pulse = new ResultReading <int?>(ReadingLabels.Pulse) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } catch (Exception ex) { _errorSummary += "Data extraction for Pulse failed. "; _logger.Error("\n Data extraction for Pulse failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnPulsePressure])) { int s = 0; if (int.TryParse(dr[ColumnPulsePressure].ToString(), out s)) { testResult.PressureReadings.PulsePressure = new ResultReading <int?>(ReadingLabels.PulsePressure) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } catch (Exception ex) { _errorSummary += "Data extraction for Pulse Pressure failed. "; _logger.Error("\n Data extraction for Pulse Pressure failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnPattern])) { testResult.Pattern = new ResultReading <string>(ReadingLabels.Pattern) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnPattern].ToString() }; } } catch (Exception ex) { _errorSummary += "Data extraction for Pattern failed. "; _logger.Error("\n Data extraction for Pattern failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } return(testResult); }
private void SetBloodPressureValues(ASITestResult testResult, DataRow dr) { bool isRight = true; if (!IsDataRowItemEmpty(dr[ColumnArmPressure])) { if (dr[ColumnArmPressure].ToString().Trim().ToLower().Equals("left")) { isRight = false; } } try { if (!IsDataRowItemEmpty(dr[ColumnSystolic])) { int s = 0; if (int.TryParse(dr[ColumnSystolic].ToString(), out s)) { if (!isRight) { testResult.PressureReadings.SystolicLeftArm = new ResultReading <int?>(ReadingLabels.SystolicLeft) { ReadingSource = ReadingSource.Automatic, Reading = s }; } else { testResult.PressureReadings.SystolicRightArm = new ResultReading <int?>(ReadingLabels.SystolicRight) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } } catch (Exception ex) { _errorSummary += "Data extraction for BP Systolic failed. "; _logger.Error("\n Data extraction for BP Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } try { if (!IsDataRowItemEmpty(dr[ColumnDiastolic])) { int s = 0; if (int.TryParse(dr[ColumnDiastolic].ToString(), out s)) { if (!isRight) { testResult.PressureReadings.DiastolicLeftArm = new ResultReading <int?>(ReadingLabels.DiastolicLeft) { ReadingSource = ReadingSource.Automatic, Reading = s }; } else { testResult.PressureReadings.DiastolicRightArm = new ResultReading <int?>(ReadingLabels.DiastolicRight) { ReadingSource = ReadingSource.Automatic, Reading = s }; } } } } catch (Exception ex) { _errorSummary += "Data extraction for BP Systolic failed. "; _logger.Error("\n Data extraction for BP Systolic failed! Error: " + ex.Message + "\n\t\t" + ex.StackTrace); } }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity) { var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList(); var testResult = new ASITestResult(customerEventScreeningTestsEntity.CustomerEventScreeningTestId); var rawAsiReadingEntities = customerEventReadingEntities. Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.RawASI).ToList(); if (rawAsiReadingEntities.Count > 0) { testResult.RawASI = new List <ResultReading <int> >(); rawAsiReadingEntities.ForEach(asiReading => testResult.RawASI.Add(new ResultReading <int>(asiReading.CustomerEventReadingId) { Reading = !string.IsNullOrEmpty(asiReading.Value) ? Convert.ToInt32(asiReading.Value) : 0, ReadingSource = (asiReading.IsManual == true ? ReadingSource.Manual : ReadingSource.Automatic), Label = ReadingLabels.RawASI, RecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = new OrganizationRoleUser(asiReading.CreatedByOrgRoleUserId), DateCreated = asiReading.CreatedOn, DataRecorderModifier = asiReading.UpdatedByOrgRoleUserId.HasValue ? new OrganizationRoleUser(asiReading.UpdatedByOrgRoleUserId.Value) : null, DateModified = asiReading.UpdatedOn } }) ); } testResult.PressureReadings = CreatePressureReadings(customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); var asiReadingEntity = customerEventReadingEntities. Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.ASI).SingleOrDefault(); if (asiReadingEntity != null) { testResult.ASI = new CompoundResultReading <int?>(asiReadingEntity.CustomerEventReadingId) { Reading = !string.IsNullOrEmpty(asiReadingEntity.Value) ? (int?)Convert.ToInt32(asiReadingEntity.Value) : null, ReadingSource = asiReadingEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic, Label = ReadingLabels.ASI, RecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = new OrganizationRoleUser(asiReadingEntity.CreatedByOrgRoleUserId), DateCreated = asiReadingEntity.CreatedOn, DataRecorderModifier = asiReadingEntity.UpdatedByOrgRoleUserId.HasValue ? new OrganizationRoleUser(asiReadingEntity.UpdatedByOrgRoleUserId.Value) : null, DateModified = asiReadingEntity.UpdatedOn } }; // TODO : This code should be moved to a Coordinator/Service. int testReadingValue = 0; if (asiReadingEntity.StandardFindingTestReadingId != null) { var standardFindingReadingEntity = customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventReading.ToList().Find(stdFindingTestReading => stdFindingTestReading.TestId == (int)TestType.ASI && stdFindingTestReading.ReadingId == (int)ReadingLabels.ASI); if (standardFindingReadingEntity != null) { testResult.ASI.Finding = new StandardFinding <int?>(standardFindingReadingEntity.StandardFindingId); } } else if (asiReadingEntity.Value != null && int.TryParse(asiReadingEntity.Value, out testReadingValue)) { testResult.ASI.Finding = new StandardFinding <int?>((new TestResultService()). GetCalculatedStandardFinding(testReadingValue, (int)TestType.ASI, (int)ReadingLabels.ASI)); } if (testResult.ASI.Finding != null) { testResult.ASI.Finding = new TestResultService().GetAllStandardFindings <int?>((int)TestType.ASI, (int)ReadingLabels.ASI).Find(standardFinding => standardFinding.Id == testResult.ASI.Finding.Id); } } testResult.Pattern = CreateResultReadingforInputValues((int)ReadingLabels.Pattern, customerEventReadingEntities); return(testResult); }