Files
DEMO-AGENT/review_agent/regulatory_review/services/info_extract.py

82 lines
2.7 KiB
Python

from __future__ import annotations
from review_agent.models import FileSummaryBatch
OPTION_FIELDS = {
"product_category": ["体外诊断试剂", "医疗器械", "其他"],
"registration_type": ["首次注册", "变更注册", "延续注册"],
"clinical_evaluation_path": ["临床试验", "免临床", "同品种比对", "待确认"],
}
def detect_regulatory_condition_candidates(summary_batch: FileSummaryBatch) -> dict[str, dict[str, object]]:
"""Infers review-scope conditions from the summary batch and file names."""
corpus_parts = [summary_batch.product_name or ""]
for item in summary_batch.items.order_by("file_index"):
corpus_parts.extend([item.directory_level, item.file_name, item.relative_path])
corpus = "\n".join(part for part in corpus_parts if part)
return {
"product_category": {
"label": "产品类别",
"input_type": "select",
"options": OPTION_FIELDS["product_category"],
"suggested": _detect_product_category(corpus),
},
"registration_type": {
"label": "注册类型",
"input_type": "select",
"options": OPTION_FIELDS["registration_type"],
"suggested": _detect_registration_type(corpus),
},
"clinical_evaluation_path": {
"label": "临床评价路径",
"input_type": "select",
"options": OPTION_FIELDS["clinical_evaluation_path"],
"suggested": _detect_clinical_path(corpus),
},
"product_name": {
"label": "产品名称",
"input_type": "text",
"suggested": summary_batch.product_name or "",
},
"model_spec": {
"label": "型号规格",
"input_type": "text",
"suggested": "",
},
"intended_use": {
"label": "预期用途",
"input_type": "text",
"suggested": "",
},
}
def _detect_product_category(corpus: str) -> str:
if any(keyword in corpus for keyword in ["体外诊断", "检测试剂", "试剂盒", "IVD"]):
return "体外诊断试剂"
if "医疗器械" in corpus:
return "医疗器械"
return "其他"
def _detect_registration_type(corpus: str) -> str:
if "延续" in corpus:
return "延续注册"
if "变更" in corpus:
return "变更注册"
return "首次注册"
def _detect_clinical_path(corpus: str) -> str:
if "免临床" in corpus or "免于临床" in corpus:
return "免临床"
if "同品种" in corpus or "同类" in corpus:
return "同品种比对"
if "临床试验" in corpus:
return "临床试验"
return "待确认"