示例#1
0
        /// <summary>
        /// 用于判断,是否询问检查水平
        /// </summary>
        /// <param name="getValueAndType">ValueOfResult类,用来检查value和type</param>
        /// <returns>返回状态数字,0代表不是,2代表含数字和指标名,3代表还有单位</returns>
        public static int isAskLevel(ValueOfResult getValueAndType)
        {
            int result = 0;//0表示不包含数字,不是该类问题

            if (getValueAndType.DoHaveValue)
            {
                int    typeNum     = 0;//计算含有的type的种类
                string typeCombine = string.Empty;
                foreach (var item in getValueAndType.ValueAndType)
                {
                    typeCombine += item.type + ";";
                    typeNum     += 1;
                }
                if (typeCombine.Contains("builtin.number") && typeCombine.Contains("IndicatorOfHealth"))
                {
                    if (typeNum == 2)
                    {
                        result = 2;//表示只含有数字和指标
                    }
                    else if (typeNum == 3 && typeCombine.Contains("unit"))
                    {
                        result = 3;//表示含有数字和指标,单位
                    }
                }
            }
            return(result);
        }
示例#2
0
 /// <summary>
 /// 用来查找是否具有用于数据库查询的合适的type
 /// </summary>
 /// <param name="getValueAndType">value和type,使用type进行比对</param>
 /// <param name="checkType">需要检查的type</param>
 /// <returns>找到为true,没找到为false</returns>
 public static bool isHave(ValueOfResult getValueAndType, string[] checkType)
 {
     if (getValueAndType.DoHaveValue)
     {
         foreach (var item_ValueAndType in getValueAndType.ValueAndType)
         {
             foreach (var item_checkType in checkType)
             {
                 if (item_checkType == item_ValueAndType.type)
                 {
                     return(true); //找到相同的type,返回true
                 }
             }
         }
     }
     else
     {
         return(false);
     }
     return(false); //找不到相同的type,返回false
 }
示例#3
0
        /// <summary>
        /// 比较检测值与数据库数据大小关系
        /// </summary>
        /// <param name="getValueAndType">对luis返回的result的分析结果</param>
        /// <param name="queryResult">数据库查询结果</param>
        /// <param name="stateOfAskLevel">用来判断有几个相关实体,是否含有单位</param>
        /// <returns>返回一个以string[]为单位的list,其中compareResult[0]是数值偏低的数据,compareResult[1]是数值偏高的数据</returns>
        public static List <string[]> compareDiffLevel(ValueOfResult getValueAndType, List <string[]> queryResult, int stateOfAskLevel)
        {
            List <string[]> compareResult = new List <string[]>(); //最终结果,compareResult[0]记录测试值偏小的区间,compareResult[1]记录测试值偏大的区间
            List <string>   biggerLevel   = new List <string>();   //记录偏大的区间
            List <string>   smallerLevel  = new List <string>();   //记录偏小的区间

            string[] isHaveUnit = new string[1] {
                "no"
            };
            string    textToShow = string.Empty;
            Reference reference  = new Reference(queryResult[0][6]);

            //找到数字的具体数值
            double number = new double();

            foreach (var item in getValueAndType.ValueAndType)
            {
                if (item.type == "builtin.number")
                {
                    number = Convert.ToDouble(item.value);
                    break;
                }
            }
            if (stateOfAskLevel == 2)
            {
                //只有数字和指标名的情况
                foreach (var itemFirstNode in reference.firstnode)
                {
                    foreach (var itemSecondNode in itemFirstNode.secondNode)
                    {
                        foreach (var itemInterval in itemSecondNode.Interval)
                        {
                            if (number < itemInterval.down)
                            {
                                string firstNodeTemp = string.Empty;
                                if (itemFirstNode.nameOfNode.Length > 0)
                                {
                                    //判断是否有一级节点的名称,有则加冒号
                                    firstNodeTemp = itemFirstNode.nameOfNode + ":";
                                }
                                textToShow += "\"" + firstNodeTemp + itemSecondNode.nameOfNode + " " + itemInterval.down + "-" + itemInterval.up + itemInterval.unit + "\"";
                                smallerLevel.Add(textToShow);
                                textToShow = "";
                            }
                            else if (number > itemInterval.up)
                            {
                                string firstNodeTemp = string.Empty;
                                if (itemFirstNode.nameOfNode.Length > 0)
                                {
                                    //判断是否有一级节点的名称,有则加冒号
                                    firstNodeTemp = itemFirstNode.nameOfNode + ":";
                                }
                                textToShow += "\"" + firstNodeTemp + itemSecondNode.nameOfNode + " " + itemInterval.down + "-" + itemInterval.up + itemInterval.unit + "\"";;
                                biggerLevel.Add(textToShow);
                                textToShow = "";
                            }
                        }
                    }
                }
            }
            else if (stateOfAskLevel == 3)
            {
                //只有数字,指标名,单位的情况
                string unit = string.Empty;
                foreach (var item in getValueAndType.ValueAndType)
                {
                    if (item.type == "unit")
                    {
                        unit = item.value.ToUpper();
                        break;
                    }
                }
                foreach (var itemFirstNode in reference.firstnode)
                {
                    foreach (var itemSecondNode in itemFirstNode.secondNode)
                    {
                        foreach (var itemInterval in itemSecondNode.Interval)
                        {
                            if (itemInterval.unit.ToUpper() == unit)
                            {
                                isHaveUnit[0] = "yes";
                                if (number < itemInterval.down)
                                {
                                    string firstNodeTemp = string.Empty;
                                    if (itemFirstNode.nameOfNode.Length > 0)
                                    {
                                        //判断是否有一级节点的名称,有则加冒号
                                        firstNodeTemp = itemFirstNode.nameOfNode + ":";
                                    }
                                    textToShow += "\"" + firstNodeTemp + itemSecondNode.nameOfNode + " " + itemInterval.down + "-" + itemInterval.up + itemInterval.unit + "\"";
                                    smallerLevel.Add(textToShow);
                                    textToShow = "";
                                }
                                else if (number > itemInterval.up)
                                {
                                    string firstNodeTemp = string.Empty;
                                    if (itemFirstNode.nameOfNode.Length > 0)
                                    {
                                        //判断是否有一级节点的名称,有则加冒号
                                        firstNodeTemp = itemFirstNode.nameOfNode + ":";
                                    }
                                    textToShow += "\"" + firstNodeTemp + itemSecondNode.nameOfNode + " " + itemInterval.down + "-" + itemInterval.up + itemInterval.unit + "\"";;
                                    biggerLevel.Add(textToShow);
                                    textToShow = "";
                                }
                            }
                        }
                    }
                }
            }
            string[] bigger = biggerLevel.ToArray();
            string[] small  = smallerLevel.ToArray();
            compareResult.Add(small);
            compareResult.Add(bigger);
            compareResult.Add(isHaveUnit);
            return(compareResult);
        }
示例#4
0
        /// <summary>
        /// 用于生成分析参考值的结果
        /// </summary>
        /// <param name="getValueAndType">luis的result分析的结果</param>
        /// <param name="queryResult">查询结果</param>
        /// <param name="stateOfAskLevel">含有多少entity的分析</param>
        /// <returns></returns>
        public static string[] GenerateTextForAskLevel(ValueOfResult getValueAndType, List <string[]> queryResult, int stateOfAskLevel)
        {
            int             numOfResult = 0;     //返回的字符串变量的个数
            bool            isHigh      = false; //判断是否有偏高的体检结果
            bool            isLow       = false; //判断是否有偏低的体检结果
            List <string[]> compareResult;       //用于记录不同的参考值区间

            compareResult = compareDiffLevel(getValueAndType, queryResult, stateOfAskLevel);
            if (compareResult[0].Length > 0)
            {
                numOfResult += 2;
                isLow        = true;
            }
            if (compareResult[1].Length > 0)
            {
                numOfResult += 2;
                isHigh       = true;
            }
            if (numOfResult == 0)
            {
                numOfResult = 1;
            }
            string[] result_textForShow = new string[numOfResult];//最终返回的结果
            int      i = 0;
            string   textForShowTemp = string.Empty;

            if (isLow)
            {
                textForShowTemp += "检查水平偏低,参考:";
                foreach (var itemLow in compareResult[0])
                {
                    textForShowTemp += itemLow + ",";
                }
                textForShowTemp       = textForShowTemp.TrimEnd(',');
                result_textForShow[i] = textForShowTemp;
                textForShowTemp       = "";
                i += 1;
                result_textForShow[i] = "检测水平过低可能的情况:" + queryResult[0][8] + "\n";
                i += 1;
            }
            if (isHigh)
            {
                textForShowTemp += "检查水平偏高,参考:";
                foreach (var itemLow in compareResult[1])
                {
                    textForShowTemp += itemLow + ",";
                }
                textForShowTemp       = textForShowTemp.TrimEnd(',');
                result_textForShow[i] = textForShowTemp;
                textForShowTemp       = "";
                i += 1;
                result_textForShow[i] = "检测水平过高可能的情况:" + queryResult[0][7] + "\n";
                i += 1;
            }
            else if (!isLow && compareResult[2][0] == "no" && stateOfAskLevel == 3)
            {
                //既没有偏高也没有偏低,而且具有单位
                result_textForShow[0] += "没有找到对应单位,以下为参考的区间:" + queryResult[0][6];
            }
            else if ((!isLow && compareResult[2][0] == "yes" && stateOfAskLevel == 3) || (!isLow && stateOfAskLevel == 2))
            {
                result_textForShow[0] += "正常,以下为参考的区间:" + queryResult[0][6];
            }
            return(result_textForShow);
        }