/// <summary> /// AddResult /// </summary> /// <param name="p_lstResultData"></param> void AddResult(List <string> p_lstResultData) { long lngRes = 0; List <clsLIS_Device_Test_ResultVO> resultVo = null; try { List <string> lstChar = new List <string>() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; clsLIS_Svc objServ = (clsLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc)); foreach (string data in p_lstResultData) { lngRes = DateAnalysis.lngDataAnalysis(data, out resultVo); if (lngRes > 0 && resultVo != null && resultVo.Count > 0) { foreach (clsLIS_Device_Test_ResultVO vo in resultVo) { vo.strDevice_ID = SerialPort.Name; if (vo.strResult != string.Empty) { bool isOk = false; int len = vo.strResult.Length; for (int k = len - 1; k >= 0; k--) { if (lstChar.IndexOf(vo.strResult.Substring(k, 1)) >= 0) { vo.strResult = vo.strResult.Substring(0, k + 1); isOk = true; break; } } if (isOk == false) { vo.strResult = ""; } } } clsLIS_Device_Test_ResultVO[] reultArr = null; lngRes = objServ.lngAddLabResult(resultVo.ToArray(), out reultArr); if (lngRes > 0) { if (ShowResult != null) { ShowResult(reultArr, null); } } } } } catch (Exception objEx) { Logger.LogDetailError(objEx, false); } }
/// <summary> /// 获取指定检验编号的检验项目字符串 /// </summary> /// <param name="p_strSampleNO"></param> /// <returns></returns> private string GetSampleCheckItems(string p_strSampleNO, string p_strSampleID, string p_strDeviceNO, string p_strDeviceID) { string strReturn = null; long lngRes = 0; if (string.IsNullOrEmpty(p_strSampleID)) { clsQueryLIS_Svc objQueryLISServ = (clsQueryLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsQueryLIS_Svc)); lngRes = objQueryLISServ.m_lngGetSampleCheckItems(p_strDeviceNO + p_strSampleNO, out strReturn); } else { clsLIS_Svc objLISServ = (clsLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc)); lngRes = objLISServ.m_lngGetSampleCheckItems(p_strSampleNO, p_strSampleID, p_strDeviceID, p_strDeviceNO, out strReturn); } return(strReturn); }
/// <summary> /// DoResult /// </summary> /// <returns></returns> void DoResult() { try { #region getResult int count = 50; // 暂定50行数据, 目前最大是30行。 string tableName = string.Empty; string itemCode = string.Empty; string itemValue = string.Empty; string checkDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string checkStr = string.Empty; List <clsLIS_Device_Test_ResultVO> data = new List <clsLIS_Device_Test_ResultVO>(); clsLIS_Device_Test_ResultVO vo = null; List <string> lstSampleId = new List <string>(); List <string> lstFileName = new List <string>(); List <string> lstCheckStr = new List <string>(); DirectoryInfo dir = new DirectoryInfo(this.FilePath); FileInfo[] files = dir.GetFiles(); clsLIS_Svc2 lisSvc2 = (clsLIS_Svc2)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc2)); foreach (FileInfo file in files) { if (!file.FullName.Contains(".xml")) { continue; } // 判断文件是否已读取 if (lisSvc2.AllergenIsRead(file.FullName)) { continue; } XmlDocument document = new XmlDocument(); document.Load(file.FullName); XmlNodeList nodeList = document.SelectNodes(@"Analysis/Container"); foreach (XmlNode node in nodeList) { string xmlNode = node.OuterXml; DataSet ds = ReadXml(xmlNode); for (int i = 0; i < count; i++) { vo = new clsLIS_Device_Test_ResultVO(); vo.strDevice_Sample_ID = node["Strip"]["Sample"]["Sample_ID"].InnerText.ToString(); if (string.IsNullOrEmpty(vo.strDevice_Sample_ID)) { continue; } vo.strCheck_Date = checkDate; #region tableName = "Row" + i.ToString(); if (ds.Tables.Contains(tableName) && ds.Tables[tableName].Rows.Count > 0) { itemCode = ds.Tables[tableName].Rows[0]["Allergenshortcut"].ToString(); if (this.dtConfig != null && this.dtConfig.Rows.Count > 0) { for (int i2 = 0; i2 < this.dtConfig.Columns.Count; i2++) { if (this.dtConfig.Columns[i2].ColumnName == itemCode) { vo.strDevice_Check_Item_Name = this.dtConfig.Rows[0][itemCode].ToString().Trim(); break; } } if (string.IsNullOrEmpty(vo.strDevice_Check_Item_Name)) { vo.strDevice_Check_Item_Name = itemCode; } } else { vo.strDevice_Check_Item_Name = itemCode; } vo.strResult = ds.Tables[tableName].Rows[0]["IU_ml"].ToString(); vo.strDevice_ID = DeviceID; checkStr = vo.strDevice_Sample_ID + vo.strDevice_Check_Item_Name; //checkStr = vo.strDevice_Check_Item_Name; if (lstCheckStr.IndexOf(checkStr) < 0) { if (lstSampleId.IndexOf(vo.strDevice_Sample_ID) < 0) { lstSampleId.Add(vo.strDevice_Sample_ID); } // 时间: 文件创建时间 vo.strCheck_Date = (file.CreationTime < DateTime.Now) ? file.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") : checkDate; data.Add(vo); lstCheckStr.Add(checkStr); if (lstFileName.IndexOf(file.FullName) < 0) { lstFileName.Add(file.FullName); } } } #endregion } } } #endregion #region addResult if (data != null && data.Count > 0) { long res = 0; clsLIS_Svc lisSvc = (clsLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc)); clsLIS_Device_Test_ResultVO[] reultArr = null; List <clsLIS_Device_Test_ResultVO> data2 = null; foreach (string sampleId in lstSampleId) { data2 = data.FindAll(t => t.strDevice_Sample_ID == sampleId); if (data2 != null && data2.Count > 0) { res = lisSvc.lngAddLabResult(data2.ToArray(), out reultArr); if (res > 0) { if (ShowResult != null) { System.Windows.Forms.Application.DoEvents(); ShowResult(reultArr, null); System.Windows.Forms.Application.DoEvents(); } } } } // 写读取记录 if (lstFileName.Count > 0) { lisSvc.SaveAllergenRec(lstFileName); } } #endregion } catch (Exception ex) { Log.Output(ex.Message); } }
void LisDataAnalysis(string _data) { this.ReceiveData.Append(_data); string data = this.ReceiveData.ToString(); int idxStart = data.IndexOf(chrStart); int idxEnd = data.IndexOf(chrEnd); if (idxStart < 0 || idxEnd < 0) { return; } if (idxEnd - idxStart - 100 < 0) { this.ReceiveData.Remove(0, idxEnd + 1); return; } List <string> lstData = new List <string>(); do { if (idxEnd - idxStart - 100 > 0) { string tmpData = data.Substring(idxStart + 1, idxEnd - idxStart - 1); if (lstData.IndexOf(tmpData) < 0) { lstData.Add(tmpData); } } this.ReceiveData.Remove(0, idxEnd + 1); data = data.Substring(idxEnd + 1); idxStart = data.IndexOf(chrStart); idxEnd = data.IndexOf(chrEnd); } while (idxStart > 0 && idxEnd > 0); this.ReceiveData.Remove(0, idxEnd + 1); if (lstData.Count > 0) { foreach (string sampleData in lstData) { string[] dataArr = sampleData.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); if (dataArr == null || dataArr.Length <= 0) { return; } string sampleID = string.Empty; string checkDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); List <clsLIS_Device_Test_ResultVO> lstResultData = new List <clsLIS_Device_Test_ResultVO>(); clsLIS_Device_Test_ResultVO vo = null; foreach (string lineData in dataArr) { string[] fieldsArr = null; string[] fieldNameArr = null; // 数据格式: OBX|22|NM|789-8^RBC^LN||4.80|10*12/L|3.80-5.80|~N|||F if (lineData.StartsWith("OBX")) { fieldsArr = lineData.Split('|'); if (fieldsArr.Length > 5) { fieldNameArr = fieldsArr[3].Split('^'); if (fieldNameArr.Length >= 3) { vo = new clsLIS_Device_Test_ResultVO(); vo.strDevice_Sample_ID = sampleID; vo.strCheck_Date = checkDate; vo.strDevice_Check_Item_Name = fieldNameArr[0]; // +fieldNameArr[2]; // 789; 789-8LN vo.strResult = fieldsArr[5]; // 4.80 if (this.ChannelConfig.ContainsKey("F" + vo.strDevice_Check_Item_Name)) { vo.strDevice_Check_Item_Name = this.ChannelConfig["F" + vo.strDevice_Check_Item_Name]; lstResultData.Add(vo); } } } } else if (lineData.StartsWith("OBR")) { fieldsArr = lineData.Split('|'); if (fieldsArr.Length > 5) { sampleID = fieldsArr[3]; } } } if (lstResultData.Count > 0 && sampleID != string.Empty && !string.IsNullOrEmpty(this.DeviceID)) { #region 写入数据 try { using (clsLIS_Svc svc = (clsLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc))) { clsLIS_Device_Test_ResultVO[] resultArr = null; foreach (clsLIS_Device_Test_ResultVO item in lstResultData) { item.strDevice_ID = this.DeviceID; item.strDevice_Sample_ID = sampleID; } svc.lngAddLabResult(lstResultData.ToArray(), out resultArr); } } catch (Exception ex) { Log.Output(ex.Message); } #endregion } } } }
/// <summary> /// 增加检验仪器结果, 多样本 /// </summary> /// <param name="p_objResultArr"></param> /// <param name="p_blnMuiltySample"> TRUE = 多样本</param> /// <param name="p_objOutResultArr"></param> /// <returns></returns> public long lngAddLabResult(clsLIS_Device_Test_ResultVO[] p_objResultArr, bool p_blnMuiltySample, out clsLIS_Device_Test_ResultVO[] p_objOutResultArr) { p_objOutResultArr = null; clsLIS_Svc objServ = (clsLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc)); long lngRes = 0; if (p_objResultArr == null || p_objResultArr.Length <= 0) { return(lngRes); } if (p_blnMuiltySample) { List <string> lstSampleID = new List <string>(); List <clsLIS_Device_Test_ResultVO> lstResult = new List <clsLIS_Device_Test_ResultVO>(); List <clsLIS_Device_Test_ResultVO> lstOutResult = new List <clsLIS_Device_Test_ResultVO>(); string strSampleID = ""; string strSampleIDTemp = null; int idx = 0; for (idx = 0; idx < p_objResultArr.Length; idx++) { strSampleID = p_objResultArr[idx].strDevice_Sample_ID; if (strSampleID != strSampleIDTemp) { if (!lstSampleID.Contains(strSampleID)) { lstSampleID.Add(strSampleID); } strSampleIDTemp = strSampleID; } } clsLIS_Device_Test_ResultVO[] objResultTempArr = null; foreach (string str in lstSampleID) { lstResult.Clear(); for (idx = 0; idx < p_objResultArr.Length; idx++) { if (str == p_objResultArr[idx].strDevice_Sample_ID) { lstResult.Add(p_objResultArr[idx]); } } if (lstResult.Count > 0) { lngRes = objServ.lngAddLabResult(lstResult.ToArray(), out objResultTempArr); if (lngRes > 0 && objResultTempArr != null && objResultTempArr.Length > 0) { lstOutResult.AddRange(objResultTempArr); } } } p_objOutResultArr = lstOutResult.ToArray(); } else { lngRes = objServ.lngAddLabResult(p_objResultArr, out p_objOutResultArr); } return(lngRes); }
/// <summary> /// 数据分析 /// </summary> public void m_mthDataTreatment() { if (string.IsNullOrEmpty(m_strData_Holder)) { return; } int j = m_strData_Holder.Length; string[] strReviceDataArr = m_strData_Holder.Split(new char[] { '\r', '\n', '-', ' ' }, StringSplitOptions.RemoveEmptyEntries); m_strData_Holder = null; List <clsLIS_Device_Test_ResultVO> p_lstResult = new List <clsLIS_Device_Test_ResultVO>(); clsLIS_Svc objServ = (clsLIS_Svc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsLIS_Svc)); clsLIS_Device_Test_ResultVO[] objOutResultArr = null; string[] strSampleId = new string[96]; string strCheckDate = null; string strDeviceId = null; string strCheckItemName = null; long lngRes = 0; strDeviceId = m_objViewer.m_strDeviceId; strCheckDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strCheckItemName = m_objViewer.m_strCheckItemName; double dblCO; double dblTemp = 0; switch (strCheckItemName.ToLower()) { case "hbeab": case "hbcab": double.TryParse(strReviceDataArr[1], out dblTemp); dblCO = dblTemp * 0.5; break; default: double.TryParse(strReviceDataArr[1], out dblCO); if (dblCO < 0.05) { dblCO = 0.05; } dblCO = 2.1 * dblCO; break; } if (strReviceDataArr == null) { return; } clsLIS_Device_Test_ResultVO objTemp = null; for (int i = 0; i < m_objViewer.m_strSampleArr.Length; i++) { objTemp = new clsLIS_Device_Test_ResultVO(); objTemp.strDevice_Sample_ID = m_objViewer.m_strSampleArr[i]; objTemp.strDevice_Check_Item_Name = strCheckItemName; objTemp.strCheck_Date = strCheckDate; objTemp.strDevice_ID = strDeviceId; double.TryParse(strReviceDataArr[i], out dblTemp); switch (strCheckItemName.ToLower()) { case "hbeab": case "hbcab": if (dblTemp > dblCO) { objTemp.strResult = "阴性"; } else { objTemp.strResult = "阳性"; } break; default: if (dblTemp < dblCO) { objTemp.strResult = "阴性"; } else { objTemp.strResult = "阳性"; } break; } p_lstResult.Add(objTemp); } if (p_lstResult.Count > 0) { //lngRes = lngAddLabResult(p_lstResult.ToArray(), true, out objOutResultArr); lngRes = objServ.lngAddLabResult(p_lstResult.ToArray(), true, out objOutResultArr); if (lngRes > 0 && objOutResultArr != null) { m_mthDataShow(p_lstResult.ToArray()); } } }