protected override void MapDomainFields(ReadingEntity entity, ResultReading <T> domainObjectToMapTo) { domainObjectToMapTo.Label = (ReadingLabels)entity.ReadingId; domainObjectToMapTo.ReadingSource = entity.DefaultInputSource.Trim() == ReadingSource.Manual.ToString() ? ReadingSource.Manual : ReadingSource.Automatic; domainObjectToMapTo.LableText = entity.Label; }
public void SetInputBox <T>(HtmlDocument doc, string nodeName, ResultReading <T> resultReading) { var selectedNode = doc.DocumentNode.SelectSingleNode("//input[@id='" + nodeName + "']"); if (selectedNode != null) { selectedNode.SetAttributeValue("value", (resultReading != null && resultReading.Reading != null) ? resultReading.Reading.ToString() : string.Empty); } }
private static void CreateReadingRecorderMetadata <T>(ResultReading <T> obj, TestResult testResult) { if (obj != null) { obj.RecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = new OrganizationRoleUser(testResult.DataRecorderMetaData.DataRecorderCreator.Id), DateCreated = testResult.DataRecorderMetaData.DateCreated }; } }
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 void SetCheckBox(HtmlDocument doc, string nodeName, ResultReading <bool?> resultReading) { var selectedNode = doc.DocumentNode.SelectSingleNode("//input[@id='" + nodeName + "']"); if (selectedNode != null && resultReading != null && resultReading.Reading != null) { var isSelected = resultReading.Reading.Value; if (isSelected) { selectedNode.SetAttributeValue("checked", "checked"); } } }
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 bool IsValid(ResultReading <T> objectToValidate) { if (objectToValidate != null) { if (objectToValidate.Reading is string) { if (string.IsNullOrEmpty(objectToValidate.Reading.ToString()) == false) { if (objectToValidate is CompoundResultReading <T> ) { if (((CompoundResultReading <T>)objectToValidate).Finding != null) { return(true); } } else { return(true); } } } else { if (objectToValidate.Reading != null) { if (objectToValidate is CompoundResultReading <T> ) { if (((CompoundResultReading <T>)objectToValidate).Finding != null) { return(true); } } else { return(true); } } } } return(false); }
private ResultReading <string> GetUrineMicroAlbuminValue(DataTable dtRawDataTable, long eventId, long customerId, TestType testTypeId, string fileName) { ResultReading <string> microAlbuminValue = new ResultReading <string>(); if (dtRawDataTable != null && dtRawDataTable.Rows.Count() > 0) { var dt = dtRawDataTable.Select("PatientID='" + customerId + "' AND EventID='" + eventId + "' AND Test_Alias='" + testTypeId + "' AND IsParse=false"); if (!dt.Any()) { _labParseEventLogger.Info("Record not found from Text file for CustomerId: " + customerId + ", EventId: " + eventId + ", Test Type: " + testTypeId + " and pdf file name is " + fileName); _loggerForClient.Info("Record not found from Text file for CustomerId: " + customerId + ", EventId: " + eventId + ", Test Type: " + testTypeId + " and pdf file name is " + fileName); } else { string summaryFinding = dt.Any() ? Convert.ToString(dt[dt.Length - 1]["Result"]) : string.Empty; if (summaryFinding.IsNullOrEmpty()) { _labParseEventLogger.Info("PDF file(" + fileName + "): Test result not found for Customer Id :" + customerId + " Test: " + testTypeId + "and text file name is " + Convert.ToString(dt[0]["FileName"])); _loggerForClient.Info("PDF file(" + fileName + "): Test result not found for Customer Id :" + customerId + " Test: " + testTypeId + "and text file name is " + Convert.ToString(dt[0]["FileName"])); } microAlbuminValue = new ResultReading <string>() { Label = ReadingLabels.MicroalbuminValue, Reading = summaryFinding, RecorderMetaData = new DataRecorderMetaData(UploadedBy, DateTime.Now, null), ReadingSource = ReadingSource.Automatic }; foreach (var dr in dt) { dr["IsParse"] = true; } } } return(microAlbuminValue); }
private string GetResultReading(ResultReading <string> reading) { return(reading != null && !string.IsNullOrEmpty(reading.Reading) ? reading.Reading : ""); }
public static string GetOutputFromBoolTypeResultReading(ResultReading <bool> reading) { return(reading != null && reading.Reading ? YesString : NoString); }
private string Reading <T>(ResultReading <T> resultReading) { return((resultReading != null && resultReading.Reading != null) ? resultReading.Reading.ToString() : string.Empty); }
protected override void MapEntityFields(ResultReading <T> domainObject, ReadingEntity entityToMapTo) { throw new NotImplementedException(); }
protected ResultReading <T> SynchronizeResultReading <T>(ResultReading <T> currentReading, ResultReading <T> newReading, DataRecorderMetaData dataRecorderMetaData) { if (currentReading == null && newReading == null) { return(null); } if (currentReading == null) { if (newReading.Reading == null) { newReading = null; } else { newReading.RecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = dataRecorderMetaData.DataRecorderCreator, DateCreated = dataRecorderMetaData.DateCreated }; } return(newReading); } if (newReading != null) { newReading.Id = currentReading.Id; if (currentReading.Reading.Equals(newReading.Reading)) { return(currentReading); } if (currentReading.ReadingSource == ReadingSource.Manual && newReading.ReadingSource == ReadingSource.Automatic) { return(currentReading); } if (newReading.ReadingSource == ReadingSource.Manual) { if (newReading.Reading == null) { return(null); } } else if (currentReading.ReadingSource == ReadingSource.Automatic && newReading.ReadingSource == ReadingSource.Automatic) { if (newReading.Reading == null && currentReading.Reading != null) { return(currentReading); } } newReading.RecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = currentReading.RecorderMetaData.DataRecorderCreator, DateCreated = currentReading.RecorderMetaData.DateCreated, DataRecorderModifier = dataRecorderMetaData.DataRecorderCreator, DateModified = dataRecorderMetaData.DateCreated }; } else { if (currentReading.ReadingSource == ReadingSource.Manual && NewReadingSource == ReadingSource.Automatic) { return(currentReading); } } return(newReading); }
protected bool SynchronizeForChangeReadingSource <T>(ReadingSource?expectedReadingSource, ResultReading <T> newReading) { if (newReading == null) { return(false); } if (expectedReadingSource == null) { return(false); } if (expectedReadingSource.Value != newReading.ReadingSource) { return(true); } return(false); }
private string GetOutputFromNullableDecimalResultReading(ResultReading <decimal?> reading) { return(reading != null && reading.Reading.HasValue ? reading.Reading.Value.ToString() : ""); }
private void ParseDataForWomenBloodPanel(DataRow dr, BloodTestResultParserLog log, long customerId, long eventId) { string message; var isThyroidEmpty = IsDataRowItemEmpty(dr[ColumnThyroid]); ResultReading <string> thyroidResultReading = null; if (isThyroidEmpty) { message = string.Format("For Customer Id {0} and EventId {1}, no data for TSH", customerId, eventId); _logger.Info(message); AppendTestResultLog(log, message, false); } else { thyroidResultReading = new ResultReading <string>(ReadingLabels.TSHSCR) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnThyroid].ToString() }; } var isCrpEmpty = IsDataRowItemEmpty(dr[ColumnCrp]); ResultReading <string> crpResultResultReading = null; if (isCrpEmpty) { message = string.Format("For Customer Id {0} and EventId {1}, no data for CRP", customerId, eventId); _logger.Info(message); AppendTestResultLog(log, message, false); } else { crpResultResultReading = new ResultReading <string>(ReadingLabels.LCRP) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnCrp].ToString() }; } var isVitaminDEmpty = IsDataRowItemEmpty(dr[ColumnVitaminD]); ResultReading <string> vitaminDResultResultReading = null; if (isVitaminDEmpty) { message = string.Format("For Customer Id {0} and EventId {1}, no data for VitaminD", customerId, eventId); _logger.Info(message); AppendTestResultLog(log, message, false); } else { vitaminDResultResultReading = new ResultReading <string>(ReadingLabels.VitD) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnVitaminD].ToString() }; } if (thyroidResultReading != null || crpResultResultReading != null || vitaminDResultResultReading != null) { var testResult = new WomenBloodPanelTestResult { TSHSCR = thyroidResultReading, LCRP = crpResultResultReading, VitD = vitaminDResultResultReading }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(_eventCustomerScreeningAggregates, eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog("", TestType.WomenBloodPanel, customerId, MedicalEquipmentTag.Bloodworks); } }
private void ParseDataForMenBloodPanel(DataRow dr, BloodTestResultParserLog log, long customerId, long eventId) { string message; var isPsaEmpty = IsDataRowItemEmpty(dr[ColumnPsa]); ResultReading <string> psaResultReading = null; if (isPsaEmpty) { message = string.Format("For Customer Id {0} and EventId {1}, no data for PSA", customerId, eventId); _logger.Info(message); AppendTestResultLog(log, message, false); } else { psaResultReading = new ResultReading <string>(ReadingLabels.PSASCR) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnPsa].ToString() }; } var isCrpEmpty = IsDataRowItemEmpty(dr[ColumnCrp]); ResultReading <string> crpResultResultReading = null; if (isCrpEmpty) { message = string.Format("For Customer Id {0} and EventId {1}, no data for CRP", customerId, eventId); _logger.Info(message); AppendTestResultLog(log, message, false); } else { crpResultResultReading = new ResultReading <string>(ReadingLabels.LCRP) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnCrp].ToString() }; } var isTestosteroneEmpty = IsDataRowItemEmpty(dr[ColumnTestosterone]); ResultReading <string> testosteroneResultReading = null; if (isTestosteroneEmpty) { message = string.Format("For Customer Id {0} and EventId {1}, no data for Testosterone", customerId, eventId); _logger.Info(message); AppendTestResultLog(log, message, false); } else { testosteroneResultReading = new ResultReading <string>(ReadingLabels.TESTSCRE) { ReadingSource = ReadingSource.Automatic, Reading = dr[ColumnTestosterone].ToString() }; } if (psaResultReading != null || crpResultResultReading != null || testosteroneResultReading != null) { var testResult = new MenBloodPanelTestResult { PSASCR = psaResultReading, LCRP = crpResultResultReading, TESTSCRE = testosteroneResultReading }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(_eventCustomerScreeningAggregates, eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog("", TestType.MenBloodPanel, customerId, MedicalEquipmentTag.Bloodworks); } }
public string GetErrorMessage(ResultReading <T> objectToValidate) { throw new NotImplementedException(); }
private List <EventCustomerScreeningAggregate> SaveResultWithoutMedia(List <EventCustomerScreeningAggregate> eventCustomerAggregates, DataTable dtRawDataTable, List <StandardFinding <decimal?> > standardFinding) { try { foreach (DataRow dr in dtRawDataTable.Rows) { long intFinding = 0; long customerId = 0; long eventId = 0; string summaryFinding = string.Empty; string txtFileName = string.Empty; TestType testTypeId; StandardFinding <int> finding = new StandardFinding <int>(); if (!ValidateDataTable(dr, out txtFileName, out eventId, out customerId, out testTypeId, out summaryFinding)) { continue; } if (testTypeId == TestType.UrineMicroalbumin) { ResultReading <string> microAlbuminValue = new ResultReading <string>() { Label = ReadingLabels.MicroalbuminValue, Reading = summaryFinding, RecorderMetaData = new DataRecorderMetaData(UploadedBy, DateTime.Now, null), ReadingSource = ReadingSource.Automatic }; TestResult testResult = new UrineMicroalbuminTestResult { MicroalbuminValue = microAlbuminValue }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.UrineMicroalbumin, customerId, MedicalEquipmentTag.LabReportParser); } else if (testTypeId == TestType.IFOBT) { summaryFinding = summaryFinding.ToLower(); var query = standardFinding.Where(x => x.Label.ToLower() == summaryFinding).Select(x => x.Id); if (query != null && query.Count() > 0) { intFinding = query.First(); } if (intFinding == 0) { _labParseEventLogger.Info("file(" + txtFileName + "): Test result format is not correct for Customer Id :" + customerId + ",EventId :" + eventId + " and Test: " + testTypeId); _loggerForClient.Info("file(" + txtFileName + "): Test result format is not correct for Customer Id :" + customerId + ",EventId :" + eventId + " and Test: " + testTypeId); continue; } finding = new StandardFinding <int>(Convert.ToInt32(intFinding)); TestResult testResult = new IFOBTTestResult { Finding = finding }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.IFOBT, customerId, MedicalEquipmentTag.LabReportParser); } else { var message = "file(" + txtFileName + "): Test(" + testTypeId + ") is an invalid test for parsing for Customer Id :" + customerId + ",EventId :" + eventId; _labParseEventLogger.Info(message); _loggerForClient.Info(message); continue; } _labParseEventLogger.Info(string.Concat("file(" + txtFileName + "): Result saved successfully for Customer Id: ", customerId, " ,Event Id: ", eventId, " and Test :", testTypeId, "\n")); _loggerForClient.Info(string.Concat("file(" + txtFileName + "): Result saved successfully for Customer Id: ", customerId, " ,Event Id: ", eventId, " and Test :", testTypeId, "\n")); } } catch (Exception ex) { _labParseEventLogger.Info("\nText File: Issue on data saving. Exception: " + ex.Message + " \n"); _loggerForClient.Info("\nText File: Issue on data saving.Please contact to Administrator \n"); } return(eventCustomerAggregates); }
public static string GetOutputFromNullableBoolTypeResultReading(ResultReading <bool?> reading, bool useBalnkValue = false) { return(reading != null && reading.Reading.HasValue && reading.Reading.Value ? YesString : (useBalnkValue ? "" : NoString)); }
//private string GetOutputFromNullableDecimalResultReading(ResultReading<decimal?> reading) //{ // return reading != null && reading.Reading.HasValue ? reading.Reading.Value.ToString() : ""; //} private string GetOutputFromNullableStringResultReading(ResultReading <string> reading) { return(reading != null && reading.Reading != "" ? reading.Reading.ToString() : string.Empty); }
public IEnumerable <EventCustomerScreeningAggregate> Parse() { var eventCustomerAggregates = new List <EventCustomerScreeningAggregate>(); var pdfResults = DirectoryOperationsHelper.GetFiles(_labReportOutputPath, "*.pdf"); var rawTxtFile = DirectoryOperationsHelper.GetFiles(_labReportOutputPath, "*.txt"); DataTable dtRawDataTable = new DataTable(); if (rawTxtFile != null && rawTxtFile.Count() > 0) { _loggerForClient.Info("Total " + rawTxtFile.Count() + " Text File found."); foreach (var file in rawTxtFile) { string txtFilename = new FileInfo(file).Name; try { dtRawDataTable = GetRecordsFromTextFile(file, txtFilename, dtRawDataTable); } catch (Exception ex) { _loggerForClient.Info("File name :" + txtFilename + " is blank. Exception :" + ex.Message); MovedParsedFile(file); } } if (dtRawDataTable != null) { _loggerForClient.Info("Total " + dtRawDataTable.Rows.Count() + " records found from all text file "); } } else { _loggerForClient.Info("There is not any text file availble"); } var standardFinding = _standardFindingRepository.GetAllStandardFindings <decimal?>((int)TestType.IFOBT); if (pdfResults != null && pdfResults.Any()) { _loggerForClient.Info("Number of Files to be Parse : " + pdfResults.Count()); foreach (var filePath in pdfResults) { string errorMessage = string.Empty; long customerId = 0; long eventId = 0; TestType testTypeId; var fileName = Path.GetFileNameWithoutExtension(filePath); var extension = Path.GetExtension(filePath); if (extension != ".pdf") { errorMessage = "file with pdf extension supported only"; _loggerForClient.Error(errorMessage); MovedParsedFile(filePath); continue; } _loggerForClient.Info("=============== Parsing Started for file: " + fileName + " ================="); _loggerForClient.Info("Parsing Started for File: " + fileName); if (!ParseValidationCheck(fileName, filePath, out eventId, out customerId, out testTypeId)) { continue; } try { string folderToSavePdf = _mediaRepository.GetResultMediaFileLocation(customerId, eventId).PhysicalPath; var resultMedia = GetMediaFromPdfFile(filePath, folderToSavePdf, testTypeId); MovedParsedFile(filePath); if (resultMedia != null && testTypeId == TestType.IFOBT) { var finding = new StandardFinding <int>(); finding = GetIFOBTFinding(dtRawDataTable, eventId, customerId, testTypeId, fileName, standardFinding); resultMedia.ReadingSource = ReadingSource.Automatic; TestResult testResult = new IFOBTTestResult { ResultImage = resultMedia, Finding = finding }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.IFOBT, customerId, MedicalEquipmentTag.LabReportParser); _labParseEventLogger.Info(string.Concat("\nPDF Filename(" + fileName + "): Parsing successfully for Customer Id: ", customerId, " ,Event Id: ", eventId, " TestType :", TestType.IFOBT, "\n")); _loggerForClient.Info(string.Concat("\nPDF Filename (" + fileName + "): parsing successfully for Customer Id: ", customerId, " ,Event Id: ", eventId, " ,TestType :", TestType.IFOBT, "\n")); } else if (resultMedia != null && testTypeId == TestType.UrineMicroalbumin) { ResultReading <string> microAlbuminValue = new ResultReading <string>(); microAlbuminValue = GetUrineMicroAlbuminValue(dtRawDataTable, eventId, customerId, testTypeId, fileName); resultMedia.ReadingSource = ReadingSource.Automatic; TestResult testResult = new UrineMicroalbuminTestResult { ResultImage = resultMedia, MicroalbuminValue = microAlbuminValue }; _resultParserHelper.AddTestResulttoEventCustomerAggregate(eventCustomerAggregates, eventId, customerId, testResult); _resultParserHelper.AddResultArchiveLog(string.Empty, TestType.UrineMicroalbumin, customerId, MedicalEquipmentTag.LabReportParser); _labParseEventLogger.Info(string.Concat("\nFilename(" + fileName + "): Parsing successfully for Customer Id: ", customerId, " ,Event Id: ", eventId, " TestType :", TestType.UrineMicroalbumin, "\n")); _loggerForClient.Info(string.Concat("\nFilename (" + fileName + "): Parsing successfully for Customer Id: ", customerId, " ,Event Id: ", eventId, " ,TestType :", TestType.UrineMicroalbumin, "\n")); } else { var message = string.Concat("\nFilename(" + fileName + "): Test(" + testTypeId + ") is an invalid test for parsing for Customer Id: ", customerId, " ,Event Id: ", eventId, " TestType :", testTypeId, "\n"); _labParseEventLogger.Info(message); _loggerForClient.Info(message); } } catch (Exception ex) { errorMessage = " System Failure! Message: " + ex.Message + "\n\t" + ex.StackTrace; _labParseEventLogger.Error(errorMessage); _loggerForClient.Error("Parsing failed for filename :" + fileName + ".Please contact to Administrator."); MovedParsedFile(filePath); _resultParserHelper.AddResultArchiveLog(ex.Message, testTypeId, customerId, MedicalEquipmentTag.LabReportParser, false); } } } if (dtRawDataTable != null && dtRawDataTable.Columns.Count() > 0 && dtRawDataTable.Rows.Count > 0) { var rows = dtRawDataTable.Select("IsParse=false"); if (rows != null && rows.Any()) { dtRawDataTable = rows.CopyToDataTable(); if (dtRawDataTable.Rows.Count > 0) { eventCustomerAggregates = SaveResultWithoutMedia(eventCustomerAggregates, dtRawDataTable, standardFinding); } } } return(eventCustomerAggregates); }