import asyncio import sys import os import re # Add the current directory to path so we can import qc_engine sys.path.append(os.path.dirname(__file__)) from qc_engine import qc_manager async def test_local_report(): report_text = """ 姓名:郭翠 性别:男 年龄:47 检查部位:子宫,卵巢 检查所见: 膀胱充盈良好,子宫前位,体积大笑如常,宫区光点分布均匀,内膜厚约0.9cm,宫颈厚约3.5cm,于左侧附件区探及一大小约2.2x1.8cm的无回声区,边界清晰,后方回声增强,余未见其他明显异常回声。彩色多普勒未探及异常血流信号。 诊断结论: 1.宫颈肥厚 2.右侧附件区囊肿 """ mock_report_data = { "report": report_text, "examinePart": "子宫,卵巢", "patient_info": { "sex": "男", "patientName": "郭翠", "age": "47" }, "model": "consensus" # 使用交叉验证进行一致性测试 } print("="*50) print("🚀 开始本地质控一致性测试 (运行3次)") print("="*50) all_results = [] for i in range(3): print(f"\n[第 {i+1} 次运行] 分析中...") try: result = await qc_manager.run_qc(mock_report_data) all_results.append(result) print(f"✅ 第 {i+1} 次运行完成") except Exception as e: print(f"❌ 第 {i+1} 次运行失败: {e}") print("\n" + "="*50) print("📊 一致性分析总结") print("="*50) # 改进的评分提取正则 for idx, res in enumerate(all_results): # 尝试匹配各种可能的评分格式 score_match = re.search(r"(?:总计得分|最终评分)[::]\D*(\d+)/100", res) score = score_match.group(1) if score_match else "未知" print(f"运行 {idx+1}: 评分={score}, 结果长度={len(res)}") if score == "未知": print(f"--- 运行 {idx+1} 未提取到评分,内容片段: {res[-200:].strip()} ---") print("\n【第 3 次运行的完整输出文本】:") print("-" * 20) print(all_results[-1]) print("-" * 20) if __name__ == "__main__": asyncio.run(test_local_report())