|
@@ -286,6 +286,7 @@ class CDSSHelper(GraphHelper):
|
|
|
symptom_same_edge = ['症状同义词', '症状同义词2.0']
|
|
|
department_edge = ['belongs_to','所属科室']
|
|
|
allowed_links = symptom_edge+department_edge+symptom_same_edge
|
|
|
+ #allowed_links = symptom_edge + department_edge
|
|
|
# 将输入的症状名称转换为节点ID
|
|
|
# 由于可能存在同名节点,转换后的节点ID数量可能大于输入的症状数量
|
|
|
node_ids = []
|
|
@@ -710,32 +711,35 @@ class CDSSHelper(GraphHelper):
|
|
|
count = 1
|
|
|
for disease, data in final_results[department]["diseases"]:
|
|
|
total_diags += 1
|
|
|
- disease_id = disease.split(":")[0]
|
|
|
- disease = disease.split(":")[1]
|
|
|
if disease in diags.keys():
|
|
|
diags[disease]["count"] += data["count"]+count
|
|
|
diags[disease]["score"] += (data["count"]+count)*0.1 * department_factor
|
|
|
else:
|
|
|
- symptoms_data = self.get_symptoms_data(disease_id, symptom_edge)
|
|
|
- if symptoms_data is None:
|
|
|
- continue
|
|
|
- symptoms = []
|
|
|
- for symptom in symptoms_data:
|
|
|
- matched = False
|
|
|
- if symptom in start_nodes:
|
|
|
- matched = True
|
|
|
- symptoms.append({"name":symptom,"matched":matched})
|
|
|
- #symtoms中matched=true的排在前面,matched=false的排在后面
|
|
|
- symptoms = sorted(symptoms, key=lambda x: x["matched"], reverse=True)
|
|
|
- diags[disease] = {"count": data["count"]+count, "score": (data["count"]+count)*0.1 * department_factor,"symptoms":symptoms}
|
|
|
+ diags[disease] = {"count": data["count"]+count, "score": (data["count"]+count)*0.1 * department_factor}
|
|
|
|
|
|
#sorted_score_diags = sorted(diags.items(), key=lambda x: x[1]["score"], reverse=True)[:10]
|
|
|
sorted_score_diags = sorted(diags.items(), key=lambda x: x[1]["count"], reverse=True)[:10]
|
|
|
|
|
|
diags = {}
|
|
|
for item in sorted_score_diags:
|
|
|
+ disease_info = item[0].split(":");
|
|
|
+ disease_id = disease_info[0]
|
|
|
+ disease = disease_info[1]
|
|
|
+ symptoms_data = self.get_symptoms_data(disease_id, symptom_edge)
|
|
|
+ if symptoms_data is None:
|
|
|
+ continue
|
|
|
+ symptoms = []
|
|
|
+ for symptom in symptoms_data:
|
|
|
+ matched = False
|
|
|
+ if symptom in start_nodes:
|
|
|
+ matched = True
|
|
|
+ symptoms.append({"name": symptom, "matched": matched})
|
|
|
+ # symtoms中matched=true的排在前面,matched=false的排在后面
|
|
|
+ symptoms = sorted(symptoms, key=lambda x: x["matched"], reverse=True)
|
|
|
+
|
|
|
+
|
|
|
new_item = {"old_score": item[1]["score"],"count": item[1]["count"], "score": float(item[1]["count"])*0.1,"symptoms":symptoms}
|
|
|
- diags[item[0]] = new_item
|
|
|
+ diags[disease] = new_item
|
|
|
sorted_score_diags = sorted(diags.items(), key=lambda x: x[1]["score"], reverse=True)
|
|
|
|
|
|
print(f"STEP 5 finished")
|