/// <summary> /// US:1880 gets the most recent result, loops over all components and pieces together a string /// </summary> /// <param name="pid"></param> /// <param name="pidi"></param> /// <param name="strResult"></param> /// <returns></returns> public CStatus GetMostRecentResult(out string strResult) { strResult = string.Empty; //load the last result for this item CPatientItemData pid = new CPatientItemData(BaseMstr.BaseData); CPatientItemDataItem pidi = new CPatientItemDataItem(); CStatus status = pid.GetMostRecentPatientItemDI(PatientID, ItemID, out pidi); if (!status.Status) { return(status); } if (pidi.PatItemID < 1) { return(new CStatus()); } DataSet dsComps = null; status = pid.GetPatientItemComponentDS( PatientID, pidi.PatItemID, pidi.ItemID, out dsComps); if (!status.Status) { return(status); } foreach (DataRow row in dsComps.Tables[0].Rows) { string strLabel = CDataUtils.GetDSStringValue(row, "item_component_label"); string strValue = CDataUtils.GetDSStringValue(row, "component_value"); string strUnits = CDataUtils.GetDSStringValue(row, "units"); string strWarning = String.Empty; //question selection if (pidi.ItemTypeID == (long)k_ITEM_TYPE_ID.QuestionSelection) { if (strValue == "1") { strResult += "<font face=\"verdana,arial\" size=\"-1\">"; strResult += strLabel; strResult += "<br /></font>"; } } //question free text else if (pidi.ItemTypeID == (long)k_ITEM_TYPE_ID.QuestionFreeText) { strResult += "<font face=\"verdana,arial\" size=\"-1\">"; strResult += strLabel; strResult += ": "; strResult += strValue; strResult += "<br /></font>"; } //lab else if (pidi.ItemTypeID == (long)k_ITEM_TYPE_ID.Laboratory) { if (CDataUtils.IsNumeric(strValue)) { double dblLegalMin = CDataUtils.GetDSDoubleValue(row, "LEGAL_MIN"); double dblLow = CDataUtils.GetDSDoubleValue(row, "LOW"); double dblCritialLow = CDataUtils.GetDSDoubleValue(row, "CRITICAL_LOW"); double dblHigh = CDataUtils.GetDSDoubleValue(row, "HIGH"); double dblCriticalHigh = CDataUtils.GetDSDoubleValue(row, "CRITICAL_HIGH"); double dblLegalMax = CDataUtils.GetDSDoubleValue(row, "LEGAL_MAX"); double dblValue = Convert.ToDouble(strValue); if (dblValue < dblLegalMin) { strWarning = "LESS THAN LEGAL MIN"; } else if (dblValue < dblCritialLow) { strWarning = "CRITICAL LOW"; } else if (dblValue < dblLow) { strWarning = "LOW"; } else if (dblValue > dblLegalMax) { strWarning = "GREATER THAN LEGAL MAX"; } else if (dblValue > dblCriticalHigh) { strWarning = "CRITICAL HIGH"; } else if (dblValue > dblHigh) { strWarning = "HIGH"; } } strResult += "<font face=\"verdana,arial\" size=\"-1\">"; strResult += strLabel; strResult += ": "; strResult += strValue; strResult += " "; strResult += strUnits; strResult += " "; strResult += strWarning; strResult += "<br /></font>"; string strLegalMin = CDataUtils.GetDSStringValue(row, "LEGAL_MIN"); string strLow = CDataUtils.GetDSStringValue(row, "LOW"); string strCritialLow = CDataUtils.GetDSStringValue(row, "CRITICAL_LOW"); string strHigh = CDataUtils.GetDSStringValue(row, "HIGH"); string strCriticalHigh = CDataUtils.GetDSStringValue(row, "CRITICAL_HIGH"); string strLegalMax = CDataUtils.GetDSStringValue(row, "LEGAL_MAX"); strResult += "<font face=\"verdana,arial\" size=\"-2\">"; strResult += "(Legal Min: " + strLegalMin + " "; strResult += "Low: " + strLow + " "; strResult += "Critical Low: " + strCritialLow + " "; strResult += "High: " + strHigh + " "; strResult += "Critical High: " + strCriticalHigh + " "; strResult += "Legal Max: " + strLegalMax + ") "; strResult += "<br /><br /></font>"; } } return(new CStatus()); }