static void complete_disease(SqlConnection connection) { //读取相关疾病未曾提到的症候,放入globalvarabile.disease;疾病作为key; SqlCommand mycommand = new SqlCommand(); mycommand.Connection = connection; string command; SqlDataReader reader; for (int i = 0; i < globalvarible.possibility.Keys.Count; i++) { List <string> keys = new List <string>(globalvarible.possibility.Keys); string tempdis = keys[i]; command = "SELECT * FROM DiagnosisData WHERE (DiseaseName='" + tempdis + "') AND (PropertyName IS NOT NULL)"; mycommand.CommandText = command; SqlDataReader tempreader = mycommand.ExecuteReader(); bool indicator = tempreader.HasRows; tempreader.Close(); if (!indicator) { command = "SELECT * FROM DiagnosisData WHERE (DiseaseName='" + tempdis + "') AND (PropertyName IS NULL)"; mycommand.CommandText = command; } reader = mycommand.ExecuteReader(); #region while (reader.Read()) { string id = reader["DiagnosisDataUID"].ToString(); if (!globalvarible.askedid.Contains(id)) { symbol tempsym = new symbol(); tempsym.id = reader["DiagnosisDataUID"].ToString(); tempsym.findingtype = reader["FindingType"].ToString(); tempsym.findingname = reader["FindingName"].ToString(); if (reader.IsDBNull(4) || reader.IsDBNull(5)) { tempsym.propertyname = "NULL"; tempsym.optionname = "NULL"; } else { tempsym.propertyname = reader["PropertyName"].ToString(); tempsym.optionname = reader["OptionName"].ToString(); } tempsym.frequency = reader.GetInt32(6); tempsym.specifity = reader.GetInt32(7); if (globalvarible.disease.ContainsKey(tempdis)) { (globalvarible.disease)[tempdis].Add(tempsym); } else { List <symbol> templist = new List <symbol>(); templist.Add(tempsym); globalvarible.disease.Add(tempdis, templist); } } } reader.Close(); #endregion } }
static void complete_disease(SqlConnection connection) { //读取相关疾病未曾提到的症候,放入globalvarabile.disease;疾病作为key; SqlCommand mycommand = new SqlCommand(); mycommand.Connection = connection; string command; SqlDataReader reader; //上述list用来暂存症候信息; foreach (string tempdis in globalvarible.possibility.Keys) { List <string> tempid = new List <string>(); List <string> tempfindingtype = new List <string>(); List <string> tempfindingname = new List <string>(); List <string> temppropertyname = new List <string>(); List <string> tempoptionname = new List <string>(); List <int> tempfrequency = new List <int>(); List <int> tempspecifity = new List <int>(); command = "SELECT * FROM DiagnosisData WHERE (DiseaseName='" + tempdis + "')";//取出所有跟疾病相关的症候; mycommand.CommandText = command; reader = mycommand.ExecuteReader(); #region while (reader.Read()) { string id = reader["DiagnosisDataUID"].ToString(); if (!globalvarible.askedid.Contains(id)) { tempid.Add(reader["DiagnosisDataUID"].ToString()); tempfindingtype.Add(reader["FindingType"].ToString()); tempfindingname.Add(reader["FindingName"].ToString()); if (reader.IsDBNull(4) || reader.IsDBNull(5)) { temppropertyname.Add("NULL"); tempoptionname.Add("NULL"); } else { temppropertyname.Add(reader["PropertyName"].ToString()); tempoptionname.Add(reader["OptionName"].ToString()); } tempfrequency.Add(reader.GetInt32(6)); tempspecifity.Add(reader.GetInt32(7)); } } reader.Close(); #endregion #region 将症候向globalvaribel.disease里存储; List <string> level3_dis = new List <string>();//存储三层症候用来判断症候是两层还是三层; for (int i = 0; i < tempid.Count; i++) { if (temppropertyname[i] != "NULL") { level3_dis.Add(tempfindingname[i]); } } for (int i = 0; i < tempid.Count; i++) { if (level3_dis.Contains(tempfindingname[i]) && temppropertyname[i] == "NULL") //该症候是三层的 { continue; //症候是三层,数据库对应的是两层,此情况不应该记录; } symbol sym = new symbol(); sym.id = tempid[i]; sym.findingtype = tempfindingtype[i]; sym.findingname = tempfindingname[i]; sym.propertyname = temppropertyname[i]; sym.optionname = tempoptionname[i]; sym.frequency = tempfrequency[i]; sym.specifity = tempspecifity[i]; List <symbol> tempsym = new List <symbol>(); tempsym.Add(sym); if (globalvarible.disease.ContainsKey(tempdis)) { globalvarible.disease[tempdis].Add(sym); } else { globalvarible.disease.Add(tempdis, tempsym); } } #endregion } Dictionary <string, List <symbol> > temp55 = globalvarible.disease; }