|
@@ -274,18 +274,18 @@ class SimilarConceptsRequest(BaseModel):
|
|
response_model=StandardResponse
|
|
response_model=StandardResponse
|
|
)
|
|
)
|
|
async def search_concept(
|
|
async def search_concept(
|
|
- query: str = Query(...,
|
|
|
|
|
|
+ concept_name: str = Query(...,
|
|
description="概念名称,应为标准医学术语。该参数用于搜索匹配的概念节点。",
|
|
description="概念名称,应为标准医学术语。该参数用于搜索匹配的概念节点。",
|
|
examples="糖尿病",
|
|
examples="糖尿病",
|
|
min_length=1),
|
|
min_length=1),
|
|
- type: str = Query(None,
|
|
|
|
|
|
+ concept_type: str = Query(None,
|
|
description="概念类型,可选参数。用于限定搜索的概念类型。",
|
|
description="概念类型,可选参数。用于限定搜索的概念类型。",
|
|
examples="疾病")
|
|
examples="疾病")
|
|
):
|
|
):
|
|
try:
|
|
try:
|
|
# 实现搜索医学概念的逻辑
|
|
# 实现搜索医学概念的逻辑
|
|
search = SearchBusiness()
|
|
search = SearchBusiness()
|
|
- results = search.search_concept(name=query, type=type)
|
|
|
|
|
|
+ results = search.search_concept(name=concept_name, type=concept_type)
|
|
return StandardResponse(success=True, data=results)
|
|
return StandardResponse(success=True, data=results)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logger.error(f"搜索医学概念失败: {str(e)}")
|
|
logger.error(f"搜索医学概念失败: {str(e)}")
|
|
@@ -318,7 +318,7 @@ async def search_concept(
|
|
response_model=StandardResponse
|
|
response_model=StandardResponse
|
|
)
|
|
)
|
|
async def get_relations(
|
|
async def get_relations(
|
|
- concept_id: str = Query(...,
|
|
|
|
|
|
+ concept_name: str = Query(...,
|
|
description="概念ID,应为标准医学术语ID。该参数用于查询该概念的相关关系。",
|
|
description="概念ID,应为标准医学术语ID。该参数用于查询该概念的相关关系。",
|
|
examples="D001",
|
|
examples="D001",
|
|
min_length=1)
|
|
min_length=1)
|
|
@@ -326,7 +326,7 @@ async def get_relations(
|
|
try:
|
|
try:
|
|
# 实现获取概念关系的逻辑
|
|
# 实现获取概念关系的逻辑
|
|
search = SearchBusiness()
|
|
search = SearchBusiness()
|
|
- results = search.get_relations(src_id=concept_id)
|
|
|
|
|
|
+ results = search.get_relations(src_id=concept_name)
|
|
return StandardResponse(success=True, data=results)
|
|
return StandardResponse(success=True, data=results)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logger.error(f"获取概念关系失败: {str(e)}")
|
|
logger.error(f"获取概念关系失败: {str(e)}")
|
|
@@ -358,7 +358,7 @@ async def get_relations(
|
|
}""",
|
|
}""",
|
|
)
|
|
)
|
|
async def get_similar_concepts(
|
|
async def get_similar_concepts(
|
|
- concept_id: str = Query(...,
|
|
|
|
|
|
+ concept_name: str = Query(...,
|
|
description="概念ID,应为标准医学术语ID。该参数用于查询该概念的相似概念。",
|
|
description="概念ID,应为标准医学术语ID。该参数用于查询该概念的相似概念。",
|
|
examples="D001",
|
|
examples="D001",
|
|
min_length=1),
|
|
min_length=1),
|
|
@@ -369,7 +369,7 @@ async def get_similar_concepts(
|
|
try:
|
|
try:
|
|
# 1. 先根据ID获取节点名称
|
|
# 1. 先根据ID获取节点名称
|
|
search = SearchBusiness()
|
|
search = SearchBusiness()
|
|
- results = search.get_similar_concepts(id=concept_id, top_k=top_k)
|
|
|
|
|
|
+ results = search.get_similar_concepts(id=concept_name, top_k=top_k)
|
|
|
|
|
|
return StandardResponse(success=True, data=results)
|
|
return StandardResponse(success=True, data=results)
|
|
except Exception as e:
|
|
except Exception as e:
|