/// <summary> /// 加载审方条件 /// </summary> /// <returns></returns> private bool loadMonitorCondition() { this.lstMntCondition.Clear(); IDataReader dr = null; if (this.db.GetRecordSet(SQL.SEL_TPNMNT_CDT, ref dr)) { ConditionPaser paser = new ConditionPaser(); MonitorCondition cdt = null; BLPublic.BLDataReader blDr = new BLPublic.BLDataReader(dr); while (blDr.next()) { cdt = new MonitorCondition(blDr.getInt("TPNMonitorID"), blDr.getString("ItemType"), blDr.getString("Code"), blDr.getString("Condition"), blDr.getBool("IsIn")); if ("tpn".Equals(cdt.ItemType)) { paser.paser(cdt); } this.lstMntCondition.Add(cdt); } blDr.close(); return(true); } else { this.lstError.Add("加载TPN审方条件失败:" + this.db.Error); } return(false); }
/// <summary> /// 通用TPN项目审核 /// </summary> /// <param name="lstResult">错误项目列表<项目ID, 错误偏差值(小于审核值时为负数)></param> /// <returns></returns> public bool checkComTPN(BLPublic.DBOperate _db, List <int> _lstPrep, Dictionary <int, double> _tpnValue, Dictionary <int, TPNItemMonitor> lstResult) { DataTable tblChk = new DataTable(); //TPN通用审方项目 if (!_db.GetRecordSet(SQL.SEL_COMTPN_CHK, ref tblChk)) { //this.lstError.Add("加载PIVAS审核项目失败:" + _db.Error); return(false); } List <DataRow> lstChk = new List <DataRow>(16); DataRow[] rows = null; int orderType = 0; foreach (int prepID in _lstPrep) { if (0 >= prepID) { continue; } if (0x07 > orderType) { orderType |= getPrepSAFType(prepID); } rows = tblChk.Select("UniPreparationID=" + prepID.ToString()); if ((null != rows) && (0 < rows.Length)) { foreach (DataRow r in rows) { lstChk.Add(r); } } } if (0 == lstChk.Count) { rows = tblChk.Select("(UniPreparationID IS NULL) OR (UniPreparationID=0)"); foreach (DataRow r in rows) { if (!r.IsNull("RequireSugar") && (bool)r["RequireSugar"] && (0x01 != (orderType & 0x01))) { continue; } else if (!r.IsNull("RequireAA") && (bool)r["RequireAA"] && (0x02 != (orderType & 0x02))) { continue; } else if (!r.IsNull("RequireFat") && (bool)r["RequireFat"] && (0x04 != (orderType & 0x04))) { continue; } lstChk.Add(r); } } int itemID = 0; int rt = 0; double val = 0.0f; ConditionPaser paser = new ConditionPaser(); DataDomain domain = null; TPNItemMonitor mntRT = null; foreach (DataRow row in lstChk) { itemID = Convert.ToInt32(row["TPNItemID"].ToString()); //SeqNo if (lstResult.ContainsKey(itemID)) //防止重复评价 { continue; } mntRT = new TPNItemMonitor((int)row["AlwayCheckID"], Convert.ToInt32(row["SeqNo"].ToString()), row["NormalValue"].ToString()); lstResult.Add(itemID, mntRT); //只要有审核的都有记录 if (string.IsNullOrWhiteSpace(row["NormalValue"].ToString())) { continue; } if (_tpnValue.ContainsKey(itemID)) { val = _tpnValue[itemID]; } else { val = 0; } //if (0 >= _tpnValue[itemID]) // continue; domain = new tpnmonitor.DataDomain(row["NormalValue"].ToString()); paser.paser(domain); rt = paser.compareDomain(domain, val); if (-1 == rt) { mntRT.DeviateValue = val - domain.Values[0]; if (0 != domain.Values[0]) { if (0.0 == mntRT.DeviateValue) //没有等号的判断,如val=1, NormalValue为>1 { mntRT.DeviateValue = -0.0001; mntRT.DeviatePer = -0.0001; //保留四位小数 } else { mntRT.DeviatePer = mntRT.DeviateValue / domain.Values[0]; } } else { mntRT.DeviatePer = 9.9999; } } else if (1 == rt) { if (domain.HadMinValue) { mntRT.DeviateValue = val - domain.Values[1]; } else { mntRT.DeviateValue = val - domain.Values[0]; } if (0 != domain.Values[0]) { if (0.0 == mntRT.DeviateValue) { mntRT.DeviateValue = 0.0001; mntRT.DeviatePer = 0.0001; } else { mntRT.DeviatePer = mntRT.DeviateValue / domain.Values[0]; } } else { mntRT.DeviatePer = 9.9999; } } } return(true); }
/// <summary> /// 设置项目审核 /// </summary> /// <returns></returns> private bool setItemMonitor() { ConditionPaser paser = new ConditionPaser(); List <int> mntIDs = new List <int>(); //已审,存在不符合条件的审方, List <int> notChkIDs = new List <int>(); //已审,存在审方通过的ID(下一个条件不用再审) string pntICD10 = this.pntValue["patient.diagnose"]; string drugClass = this.pntValue["recipe.drugclass"]; string drugCode = this.pntValue["recipe.drugcode"]; string tempStr = ""; int SAFType = (int)this.ordersValue["recipe.tpnsaftype"]; bool isMonitor = false; //审方 foreach (MonitorCondition cdt in this.lstMntCondition) { if (notChkIDs.Contains(cdt.MonitorID)) //此审方已经有一个条件不符合,不用再审其他条件 { continue; } isMonitor = false; if ("tpn".Equals(cdt.ItemType)) { if (this.tpnValue.ContainsKey(cdt.ItemCode)) { if (0 >= this.tpnValue[cdt.ItemCode]) { isMonitor = false; } else if (paser.compare(cdt, this.tpnValue[cdt.ItemCode])) //值在指定的范围内 { if (cdt.IsIn) { isMonitor = true; } } else if (!cdt.IsIn) { isMonitor = true; } } } else if ("icd".Equals(cdt.ItemType)) { if (pntICD10.Contains("," + cdt.ItemCode + ",")) //诊断存在 { isMonitor = cdt.IsIn; } else { isMonitor = !cdt.IsIn; } } /* 药品审方 * 1. 要求药品是否存在,Domain为空。(IsIn=true,要求存在,反之要求不能存在) * 2. 药品与药品是否能一起使用, ItemCode为药品1,Domain为药品2. (IsIn=true,必须有两个药品,反正两个药品不能一起使用) * 3. 药品与药品分类是否能一起使用. 同2. */ else if ("drug".Equals(cdt.ItemType) || "class".Equals(cdt.ItemType)) { if ("drug".Equals(cdt.ItemType)) { isMonitor = drugCode.Contains("," + cdt.ItemCode + ","); } else { isMonitor = drugClass.Contains("," + cdt.ItemCode + ","); } if (isMonitor) { isMonitor = false; if (string.IsNullOrWhiteSpace(cdt.Domain)) //没有第二个条件 { isMonitor = cdt.IsIn; } else if (cdt.Domain.Contains("class.")) //第二个条件为药品分类 { tempStr = cdt.Domain.Substring(6); if (string.IsNullOrWhiteSpace(tempStr)) { isMonitor = cdt.IsIn; } else if (drugClass.Contains("," + tempStr + ",")) { isMonitor = cdt.IsIn; } else { isMonitor = !cdt.IsIn; } } else //第二个条件为药品 { tempStr = cdt.Domain.Substring(5); //5 = LEN(drug.) if (string.IsNullOrWhiteSpace(tempStr)) { isMonitor = cdt.IsIn; } else if (drugCode.Contains("," + tempStr + ",")) { isMonitor = cdt.IsIn; } else { isMonitor = !cdt.IsIn; } } } } //糖、氨基酸、脂肪乳审核 else if ("tpnsaf".Equals(cdt.ItemType)) { if (0 == string.Compare("sugar", cdt.ItemCode, true)) { isMonitor = cdt.IsIn && (0x01 == (SAFType & 0x01)); } else if (0 == string.Compare("AA", cdt.ItemCode, true)) { isMonitor = cdt.IsIn && (0x02 == (SAFType & 0x02)); } else if (0 == string.Compare("fat", cdt.ItemCode, true)) { isMonitor = cdt.IsIn && (0x04 == (SAFType & 0x04)); } } if (isMonitor) { if (!mntIDs.Contains(cdt.MonitorID)) { mntIDs.Add(cdt.MonitorID); } } else if (!notChkIDs.Contains(cdt.MonitorID)) { notChkIDs.Add(cdt.MonitorID); } } //删除不需要审核的条件 foreach (int id in notChkIDs) { if (mntIDs.Contains(id)) { mntIDs.Remove(id); } } if (0 == mntIDs.Count) //没有审方结果 { this.db.ExecSQL(string.Format(SQL.ADD_TPNCHK_RCD, this.mntRecipeID, this.EmpCode, "0")); return(true); } string maxLvl = string.Format(SQL.SEL_MAX_LVL, this.mntRecipeID); foreach (int mntID in mntIDs) { if (!this.db.ExecSQL(string.Format(SQL.ADD_TPNCHKRESULT, mntID, this.mntRecipeID, this.EmpCode))) { this.lstError.Add("增加审方记录(" + mntID.ToString() + ")失败:" + this.db.Error); } } if (!this.db.ExecSQL(string.Format(SQL.ADD_TPNCHK_RCD, this.mntRecipeID, this.EmpCode, maxLvl))) { this.lstError.Add("记录医嘱审方失败:" + this.db.Error); } return(true); }