/// <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 } } } }
public void m_mthShowMessage(bool p_blnAdd, clsDeviceSampleDataKey p_objDSDKey, object[] p_objResultVOArr) { string strCommingDate; if (p_blnAdd) { ListViewItem lvi = new ListViewItem(p_objDSDKey.strDeviceName); lvi.SubItems.Add(p_objDSDKey.strDeviceSampleID); lvi.SubItems.Add(p_objDSDKey.strCheckDate); this.m_lsvList.Items.Add(lvi); lvi.Selected = true; lvi.Focused = true; lvi.EnsureVisible(); lvi.Tag = p_objDSDKey; strCommingDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); p_objDSDKey.strCommingDateTime = strCommingDate; } else { strCommingDate = p_objDSDKey.strCommingDateTime; } string strSeq; string strItemName; string strResult; string strFlag; string strRefrange; this.m_txtWindow.Clear(); m_txtWindow.AppendText("Device data comming in " + strCommingDate + " ......\r\n"); m_txtWindow.AppendText("Device Name: " + p_objDSDKey.strDeviceName + " Device Sample ID: " + p_objDSDKey.strDeviceSampleID + " CheckDate: " + p_objDSDKey.strCheckDate + "\r\n\r\n"); m_txtWindow.AppendText("Seq. ItemName Result Flag ReferanceRange\r\n"); m_txtWindow.AppendText("--------------------------------------------------------------------------\r\n"); for (int i = 0; i < p_objResultVOArr.Length; i++) //clsLIS_Device_Test_ResultVO[] { strSeq = i.ToString().PadRight(8); if (p_objResultVOArr[i] is clsLIS_Device_Test_ResultVO) { clsLIS_Device_Test_ResultVO objTestResult = (clsLIS_Device_Test_ResultVO)p_objResultVOArr[i]; strItemName = objTestResult.strDevice_Check_Item_Name; if (strItemName != null) { strItemName = strItemName.PadRight(20); } else { strItemName = " "; } if (objTestResult.strResult != null) { strResult = objTestResult.strResult.PadRight(12); } else { strResult = " "; } if (objTestResult.strAbnormal_Flag != null) { strFlag = objTestResult.strAbnormal_Flag.PadRight(8); } else { strFlag = " "; } strRefrange = objTestResult.strRefRange; } else { clsDeviceReslutVO objResult = (clsDeviceReslutVO)p_objResultVOArr[i]; strItemName = objResult.m_strDeviceCheckItemName; if (strItemName != null) { strItemName = strItemName.PadRight(20); } else { strItemName = " "; } if (objResult.m_strResult != null) { strResult = objResult.m_strResult.PadRight(12); } else { strResult = " "; } if (objResult.m_strAbnormalFlag != null) { strFlag = objResult.m_strAbnormalFlag.PadRight(8); } else { strFlag = " "; } strRefrange = objResult.m_strRefRange; } m_txtWindow.AppendText(strSeq); m_txtWindow.AppendText(strItemName); m_txtWindow.AppendText(strResult); m_txtWindow.AppendText(strFlag); m_txtWindow.AppendText(strRefrange + "\r\n"); } m_txtWindow.AppendText("--------------------------------------------------------------------------\r\n"); if ((!this.Visible) || (this.WindowState == FormWindowState.Minimized)) { // frmMessageNotify frm = new frmMessageNotify(); // frm.m_frmRealWindow = this; // frm.m_lblDevice.Text = p_objDSDKey.strDeviceName; // frm.m_lnkDeviceSample.Text = p_objDSDKey.strDeviceSampleID; // frm.TopMost = true; // frm.m_objKey = p_objDSDKey; // frm.Show(); } else { // this.Show(); this.Activate(); } }
public long lngDataAnalysis(string p_strRawData, out List <clsLIS_Device_Test_ResultVO> p_arlResult) { p_arlResult = null; if ((p_strRawData == "") || (p_strRawData == null)) { return(0L); } if (p_strRawData.Length < 7) { return(0L); } p_arlResult = new List <clsLIS_Device_Test_ResultVO>(); string strSampleID = p_strRawData.Substring(7, 4); //Substring(9, 4); // 质控上机号 if (strSampleID.ToUpper().StartsWith("Q0")) { strSampleID += "-" + Convert.ToInt32(p_strRawData.Substring(12, 3)); } string strCheckDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int intCurrPos = p_strRawData.IndexOf("E0");// 38; // 20171028.由于检验科换试剂厂家,重装了控制软件,导致数据结构变了 --- 质控上机号还需要找时间做标本 strSampleID = p_strRawData.Substring(intCurrPos - 8, 4); // <----- string strData = p_strRawData.Substring(intCurrPos + 1); List <string> lstChar = new List <string>() { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; string strItem = string.Empty; clsLIS_Device_Test_ResultVO vo = null; int count = strData.Length / 11; // 循环次数 for (int i = 0; i < count; i++) { strItem = strData.Substring(0, 11); vo = new clsLIS_Device_Test_ResultVO(); vo.strDevice_Sample_ID = strSampleID; vo.strCheck_Date = strCheckDate; vo.strDevice_Check_Item_Name = strItem.Substring(0, 3); vo.strResult = strItem.Substring(3).Trim(); #region bak //if (vo.strResult.EndsWith("r")) // 重传 // vo.strResult = vo.strResult.TrimEnd('r').Trim(); //else if (vo.strResult.EndsWith("e")) // vo.strResult = vo.strResult.TrimEnd('e').Trim(); //else if (vo.strResult.EndsWith("f")) // 报警 // vo.strResult = vo.strResult.TrimEnd('f').Trim(); //if (vo.strResult.EndsWith("R")) // vo.strResult = vo.strResult.TrimEnd('R').Trim(); //else if (vo.strResult.EndsWith("E")) // vo.strResult = vo.strResult.TrimEnd('E').Trim(); //else if (vo.strResult.EndsWith("F")) // vo.strResult = vo.strResult.TrimEnd('F').Trim(); //// 如果结果无效,结果负数时报错 //if (vo.strResult == "999999") // || vo.strResult.StartsWith("-")) // vo.strResult = "***"; //else if (vo.strResult.StartsWith("-")) //{ // if (!vo.strResult.StartsWith("- ")) // vo.strResult = "***"; // else // vo.strResult = vo.strResult.Substring(1).Trim(); //} //else if (string.IsNullOrEmpty(vo.strResult)) // vo.strResult = "0.00"; //if (vo.strResult.IndexOf("f") >= 0) vo.strResult = vo.strResult.Replace("f", ""); //if (vo.strResult.IndexOf("F") >= 0) vo.strResult = vo.strResult.Replace("F", ""); #endregion 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 (IsNumeric(vo.strResult.Substring(k, 1)) == false) //{ // vo.strResult = vo.strResult.Substring(0, k); //} //else //{ // break; //} } if (isOk == false) { vo.strResult = ""; } } // 重置 strData = strData.Substring(11); // 读取配置 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 == "F" + vo.strDevice_Check_Item_Name) { vo.strDevice_Check_Item_Name = this.dtConfig.Rows[0]["F" + vo.strDevice_Check_Item_Name].ToString().Trim(); break; } } } //vo.strDevice_Check_Item_Name = this.m_strConvertItem(vo.strDevice_Check_Item_Name); //vo.strResult = this.m_strConvertValue(vo.strDevice_Check_Item_Name, vo.strResult); p_arlResult.Add(vo); } return(1L); }
/// <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()); } } }