|
@@ -112,7 +112,7 @@ class SearchBusiness:
|
|
|
processed_disease_ids = set()
|
|
|
simplified_diseases = []
|
|
|
# 获取症状节点ID
|
|
|
- symptom_nodes = self.search_nodes(name=symptom_name, type="症状")
|
|
|
+ symptom_nodes = self.search_nodes(name=symptom_name, type="症状", limit=100)
|
|
|
if not symptom_nodes:
|
|
|
return simplified_diseases
|
|
|
|
|
@@ -300,6 +300,38 @@ class SearchBusiness:
|
|
|
]
|
|
|
|
|
|
return {"similar_concepts": similar_concepts}
|
|
|
+
|
|
|
+ def validate_medical_record(self, medical_record: str, validate_type: str) -> dict:
|
|
|
+ """
|
|
|
+ 验证病历数据
|
|
|
+ :param medical_record: 病历数据字典
|
|
|
+ :param validate_type: 验证类型
|
|
|
+ :return: 验证结果字典
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ # 基本验证逻辑
|
|
|
+ if not medical_record:
|
|
|
+ return {"valid": False, "errors": ["病历数据为空"]}
|
|
|
+
|
|
|
+ # 根据验证类型进行不同验证
|
|
|
+ if validate_type == "completeness":
|
|
|
+ # 检查病历完整性
|
|
|
+ required_fields = ["patient_name", "diagnosis", "treatment"]
|
|
|
+ missing_fields = [field for field in required_fields if field not in medical_record]
|
|
|
+ if missing_fields:
|
|
|
+ return {"valid": False, "errors": [f"缺少必填字段: {', '.join(missing_fields)}"]}
|
|
|
+
|
|
|
+ elif validate_type == "consistency":
|
|
|
+ # 检查病历一致性
|
|
|
+ if "diagnosis" in medical_record and "symptoms" in medical_record:
|
|
|
+ # 这里可以添加更复杂的诊断与症状一致性检查逻辑
|
|
|
+ pass
|
|
|
+
|
|
|
+ return {"valid": True, "errors": []}
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f"病历验证失败: {str(e)}")
|
|
|
+ return {"valid": False, "errors": [f"验证过程中发生错误: {str(e)}"]}
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|