Пример #1
0
        static void getdata()
        {
            //依据sign从数据库中读取相关疾病并计算概率;
            connect2sql conn = new connect2sql();

            conn.initialization();
            conn.connection.Open();
            List <string> nofinding_collection = new List <string>(); //记录患者没有的症候;
            string        command;
            double        count = 0;                                  //count用来记录globalvarible.signs里症候的个数;

            foreach (detail tempdetail in globalvarible.signs)
            {
                string temp1 = tempdetail.symptomname;
                string temp2 = tempdetail.propertyname;
                string temp3 = tempdetail.optionname;
                if (temp2 == "NULL" && temp3 == "NULL") //两层,说明该症候没有property;
                {
                    count++;
                    command = "SELECT DiagnosisDataUID, DiseaseName, Specifity FROM DiagnosisData WHERE (FindingName='" + temp1 + "') AND (PropertyName IS NULL)";
                    add_disease(command, conn.connection, count);//取出相关疾病,计算概率,并把记录已经询问过的ID;
                }
                else if (temp2 == "None" && temp3 == "NULL")
                {
                    //症候不存在;
                    nofinding_collection.Add(temp1);
                }
                else                                           //三层;
                {
                    count++;
                    command = "SELECT DiagnosisDataUID, DiseaseName, Specifity FROM DiagnosisData WHERE (FindingName='" + temp1 + "') AND (PropertyName='" + temp2 + "') AND (OptionName='" + temp3 + "')";
                    add_disease(command, conn.connection, count);
                }
            }
            if (nofinding_collection.Count > 0)
            {
                add_disease_none(nofinding_collection, conn.connection); //利用不存在的症候进行筛选;
            }
            if (normalization() > 0)                                     //已确定诊断疾病;
            {
                return;
            }
            else
            {
                complete_disease(conn.connection);//不能确定疾病,将相关疾病的症候提取到globalvarible.disease里,以便询问新的症候;
            }
            conn.connection.Close();
            //ask_finding();
        }
Пример #2
0
        static void read_option(string findingtype, string findingname, string propertyname)
        {
            //从findingbase里提取optionname,并存储在globalvarible.newquestion里,为输出做准备;
            connect2sql conn = new connect2sql();

            conn.initialization();
            conn.connection.Open();
            string     command   = "select Description from FindingsBase where (ChineseName ='" + findingname + "')";
            SqlCommand mycommand = new SqlCommand();

            mycommand.CommandText = command;
            mycommand.Connection  = conn.connection;
            XmlReader   reader = mycommand.ExecuteXmlReader();
            XmlDocument xml    = new XmlDocument();

            xml.Load(reader);
            reader.Close();
            conn.connection.Close();
            XmlElement    root   = xml.DocumentElement;
            XmlNodeList   xl1    = root.ChildNodes;
            string        name   = "";
            string        tempop = "";
            List <string> option = new List <string>();

            #region
            foreach (XmlNode xn1 in xl1)
            {
                if (xn1.Name == "Properties")
                {
                    XmlNodeList xl2 = xn1.ChildNodes;
                    foreach (XmlNode xn2 in xl2)
                    {
                        XmlNodeList xl3 = xn2.ChildNodes;
                        foreach (XmlNode xn3 in xl3)
                        {
                            if (xn3.Name == "Name")
                            {
                                name = xn3.InnerText;
                                name = name.Trim();
                            }
                            if (xn3.Name == "Options" && name == propertyname)
                            {
                                foreach (XmlNode xn4 in xn3.ChildNodes)
                                {
                                    tempop = xn4.InnerText;
                                    //tempop.Replace(" ", "");
                                    tempop = tempop.Trim();
                                    option.Add(tempop);
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            #region
            List <string> key = new List <string>();
            key.Add(findingtype);
            key.Add(findingname);
            newask tempnewask = new newask();
            tempnewask.propertyname = propertyname;
            tempnewask.optionname   = option;
            if (globalvarible.newquestion.ContainsKey(key))
            {
                globalvarible.newquestion[key].Add(tempnewask);
            }
            else
            {
                List <newask> tempq = new List <newask>();
                tempq.Add(tempnewask);
                globalvarible.newquestion.Add(key, tempq);
            }
            #endregion
        }