Ejemplo n.º 1
0
        private CompoundResultReading <T> GetResultReading <T>(T reading, ReadingLabels label, int?readingForFinding, TestType type, ref string errorSummary)
        {
            try
            {
                var resultReading = new CompoundResultReading <T>
                {
                    Label         = label,
                    ReadingSource = ReadingSource.Automatic,
                    Reading       = reading
                };

                if (readingForFinding != null)
                {
                    resultReading.Finding = new StandardFinding <T>(_testResultService.GetCalculatedStandardFinding(readingForFinding, (int)type, (int)label));
                }

                return(resultReading);
            }
            catch (Exception ex)
            {
                string message = string.Format("Exception while extracting value for {0}. Message: {1} ", label.ToString(), ex.Message);
                _logger.Error(message);
                errorSummary += message;
            }

            return(null);
        }
Ejemplo n.º 2
0
 public CompoundResultReading <int?> GetReading(string reading, ReadingLabels label, TestType type, ref string errorSummary)
 {
     if (!string.IsNullOrEmpty(reading))
     {
         int s;
         if (int.TryParse(reading, out s))
         {
             return(GetResultReading((int?)s, label, s, type, ref errorSummary));
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
 public CompoundResultReading <string> GetReading(string reading, ReadingLabels label, ref decimal?value, TestType type, ref string errorSummary)
 {
     if (!string.IsNullOrEmpty(reading))
     {
         int s;
         if (!int.TryParse(reading, out s))
         {
             return(GetResultReading(s.ToString(), label, null, type, ref errorSummary));
         }
         if (s > 0)
         {
             value = s;
         }
         return(GetResultReading(s.ToString(), label, s, type, ref errorSummary));
     }
     return(null);
 }
Ejemplo n.º 4
0
        private static ResultReading <decimal?> GetDecimalObject(string value, ReadingLabels readingLabel)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }

            decimal reading = 0;

            if (decimal.TryParse(value, out reading))
            {
                return(new ResultReading <decimal?>(readingLabel)
                {
                    Reading = reading, ReadingSource = ReadingSource.Automatic
                });
            }

            return(null);
        }
Ejemplo n.º 5
0
        private static ResultReading <int?> GetIntObject(string value, ReadingLabels readingLabel)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }

            int reading = 0;

            if (int.TryParse(value, out reading))
            {
                return(new ResultReading <int?>(readingLabel)
                {
                    Reading = reading, ReadingSource = ReadingSource.Automatic
                });
            }

            return(null);
        }
Ejemplo n.º 6
0
 private ResultReading <int?> GetDataReading(string columnName, ReadingLabels readingLabel, DataRow dr)
 {
     try
     {
         if (!IsDataRowItemEmpty(dr[columnName]))
         {
             int s;
             if (int.TryParse(dr[columnName].ToString(), out s))
             {
                 return(new ResultReading <int?>(readingLabel)
                 {
                     Reading = s,
                     ReadingSource = ReadingSource.Automatic
                 });
             }
         }
     }
     catch (Exception ex)
     {
         _errorSummary += "Exception caused while recording data for " + columnName;
         _logger.Error("\nException caused while recording data for " + columnName + ". Message: " + ex.Message + "\n\t" + ex.StackTrace);
     }
     return(null);
 }
Ejemplo n.º 7
0
 public CompoundResultReading(ReadingLabels readingLabel) : base(readingLabel)
 {
 }
Ejemplo n.º 8
0
 public ResultReading(ReadingLabels readingLabel)
 {
     Label = readingLabel;
 }
Ejemplo n.º 9
0
        private bool IsCompareReadingValid <X>(Func <LipidTestResult, X> _propertyToCompare, ReadingLabels _propertyType, LipidTestResult _testResultObject)
        {
            int?_valueToCompare = Convert.ToInt32(_propertyToCompare(_testResultObject)) as int?;

            if (_valueToCompare == null)
            {
                return(true);
            }

            int valueCalculated = 0;

            switch (_propertyType)
            {
            case ReadingLabels.LDL:
                valueCalculated = Convert.ToInt32(_testResultObject.TotalCholestrol.Reading)
                                  - Convert.ToInt32(_testResultObject.HDL.Reading)
                                  - Convert.ToInt32(decimal.Round((Convert.ToDecimal(_testResultObject.TriGlycerides.Reading) / 5), 0));
                break;

            case ReadingLabels.HDL:
                valueCalculated = Convert.ToInt32(_testResultObject.TotalCholestrol.Reading)
                                  - _testResultObject.LDL.Reading.Value
                                  - Convert.ToInt32(decimal.Round((Convert.ToDecimal(_testResultObject.TriGlycerides.Reading) / 5), 0));
                break;

            case ReadingLabels.TotalCholestrol:
                valueCalculated = Convert.ToInt32(_testResultObject.HDL.Reading)
                                  + _testResultObject.LDL.Reading.Value
                                  + Convert.ToInt32(decimal.Round((Convert.ToDecimal(_testResultObject.TriGlycerides.Reading) / 5), 0));
                break;

            case ReadingLabels.TriGlycerides:
                valueCalculated = (Convert.ToInt32(_testResultObject.TotalCholestrol.Reading)
                                   - Convert.ToInt32(_testResultObject.HDL.Reading)
                                   - _testResultObject.LDL.Reading.Value) * 5;
                break;
            }

            int minValue = _valueToCompare.Value - validRangeDecider;
            int maxValue = _valueToCompare.Value + validRangeDecider;

            if (valueCalculated >= minValue && valueCalculated <= maxValue)
            {
                return(true);
            }

            return(false);
        }