Пример #1
0
        private void addDomainVal(DataDomain _cdt, string _val)
        {
            if (string.IsNullOrWhiteSpace(_val))
            {
                return;
            }

            if ("-∞".Equals(_val))
            {
                _cdt.HadMinValue = false;
            }

            else if ("+∞".Equals(_val))
            {
                _cdt.HadMaxValue = false;
            }

            else
            {
                try
                {
                    _cdt.Values.Add(Convert.ToDouble(_val));
                }
                catch (Exception ex)
                {
                    this.Error = "值(" + _val + ")格式错误.";
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 解析表达式,分离表达式值
        /// </summary>
        /// <param name="_cdt"></param>
        public void paser(DataDomain _cdt)
        {
            if (null == _cdt)
            {
                return;
            }

            _cdt.Values.Clear();
            _cdt.HadMinValue = false;
            _cdt.HadMaxValue = false;
            _cdt.IncMinValue = false;
            _cdt.IncMaxValue = false;

            string domain = _cdt.Domain;

            if (string.IsNullOrWhiteSpace(domain))
            {
                return;
            }

            domain = domain.Replace(",", ",");
            domain = domain.Replace("。", ".");

            char[] arrCdt = domain.ToCharArray();
            int    i = 0, l = arrCdt.Length - 1;
            bool   readVal = true;
            string val     = "";

            while (i <= l)
            {
                if (('>' == arrCdt[i]) || ('<' == arrCdt[i]))
                {
                    if (readVal)
                    {
                        addDomainVal(_cdt, val);
                        readVal = false;
                        val     = "";
                    }


                    if ('>' == arrCdt[i])
                    {
                        _cdt.HadMinValue = true;
                        i++;
                        if ('=' == arrCdt[i])
                        {
                            _cdt.IncMinValue = true;
                        }
                        else
                        {
                            val = arrCdt[i].ToString();
                        }
                    }
                    else
                    {
                        _cdt.HadMaxValue = true;
                        if (i == l)
                        {
                            this.Error = "表达式右边没有值";
                        }
                        else
                        {
                            i++;
                            if ('=' == arrCdt[i])
                            {
                                _cdt.IncMaxValue = true;
                            }
                            else
                            {
                                val = arrCdt[i].ToString();
                            }
                        }
                    }

                    readVal = true;
                }
                else if (('(' == arrCdt[i]) || ('[' == arrCdt[i])) //最小值
                {
                    if (readVal)
                    {
                        addDomainVal(_cdt, val);
                        readVal = false;
                        val     = "";
                    }

                    if (i == l) //最后
                    {
                        this.Error = "表达式右边没有值";
                    }

                    else
                    {
                        _cdt.HadMinValue = true;
                        if ('[' == arrCdt[i])
                        {
                            _cdt.IncMinValue = true;
                        }

                        readVal = true;
                    }
                }
                else if ((')' == arrCdt[i]) || (']' == arrCdt[i])) //最大值
                {
                    if (readVal)
                    {
                        addDomainVal(_cdt, val);
                        readVal = false;
                        val     = "";
                    }

                    _cdt.HadMaxValue = true;

                    if (i == 0)
                    {
                        this.Error = "表达式左边没有值";
                    }

                    else if (']' == arrCdt[i])
                    {
                        _cdt.IncMaxValue = true;
                    }
                }
                else if (',' == arrCdt[i])
                {
                    if (readVal)
                    {
                        addDomainVal(_cdt, val);
                    }

                    readVal = true;
                    val     = "";
                }
                else if (readVal)
                {
                    val += arrCdt[i].ToString();
                }

                i++;
            }

            if (readVal)
            {
                addDomainVal(_cdt, val);
                readVal = false;
                val     = "";
            }

            if (_cdt.HadMinValue && _cdt.HadMaxValue && (2 == _cdt.Values.Count))
            {
                //交换,[0]为最小值
                if (_cdt.Values[0] > _cdt.Values[1])
                {
                    double tmp = _cdt.Values[0];
                    _cdt.Values[0] = _cdt.Values[1];
                    _cdt.Values[1] = tmp;
                }
            }
        }
Пример #3
0
 public bool compare(DataDomain _cdt, double _val)
 {
     return(0 == compareDomain(_cdt, _val));
 }
Пример #4
0
        public int compareDomain(DataDomain _cdt, double _val)
        {
            if (null == _cdt)
            {
                return(-99);
            }

            if (0 == _cdt.Values.Count)
            {
                this.Error = "没有值域内容";
                return(-99);
            }

            if (_cdt.HadMinValue && _cdt.HadMaxValue && (2 != _cdt.Values.Count))
            {
                this.Error = "缺少最大值或最小值";
                return(-99);
            }

            //列举值
            if (
                (2 < _cdt.Values.Count) ||
                (!_cdt.HadMinValue && !_cdt.HadMaxValue)
                )
            {
                return(_cdt.Values.Contains(_val) ? 0 : -99);
            }

            bool isIn = false;

            if (_cdt.HadMinValue)
            {
                if (_cdt.IncMinValue)
                {
                    isIn = (_val >= _cdt.Values[0]);
                }
                else
                {
                    isIn = (_val > _cdt.Values[0]);
                }

                if (!isIn)
                {
                    return(-1);
                }
            }

            if (_cdt.HadMaxValue)
            {
                int vIndex = 1;
                if (!_cdt.HadMinValue)
                {
                    vIndex = 0;
                }

                if (_cdt.IncMaxValue)
                {
                    isIn = (_val <= _cdt.Values[vIndex]);
                }
                else
                {
                    isIn = (_val < _cdt.Values[vIndex]);
                }

                if (!isIn)
                {
                    return(1);
                }
            }

            return(isIn ? 0 : -99);
        }
Пример #5
0
        /// <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);
        }