精简后端功能模块并补充教学互动
This commit is contained in:
+96
-2
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from sqlalchemy import select
|
||||
@@ -116,19 +117,111 @@ def _seed_traditional_case(db, case_id: int) -> None:
|
||||
|
||||
def _seed_teaching_case(db, case_id: int) -> None:
|
||||
"""教学互动病例种子:教学互动模式读取 case_base + teaching_case。"""
|
||||
if db.scalar(select(TeachingCase).where(TeachingCase.case_id == case_id)):
|
||||
existing = db.scalar(select(TeachingCase).where(TeachingCase.case_id == case_id))
|
||||
if existing:
|
||||
try:
|
||||
json.loads(existing.discussion_questions)
|
||||
except (TypeError, json.JSONDecodeError):
|
||||
existing.discussion_questions = _demo_teaching_questions_json()
|
||||
return
|
||||
questions_json = _demo_teaching_questions_json()
|
||||
case = db.get(CaseBase, case_id)
|
||||
if case and not case.multimodal_assets:
|
||||
case.multimodal_assets = [{"type": "video", "title": "儿童肺炎教学示例视频", "url": ""}]
|
||||
db.add(
|
||||
TeachingCase(
|
||||
case_id=case_id,
|
||||
teaching_goal="围绕儿科肺炎问诊、检查选择、诊断依据、治疗决策和医患沟通完成互动训练。",
|
||||
discussion_questions="如何判断病情严重程度?哪些检查是关键检查?治疗方案如何兼顾抗感染、平喘和氧合监测?",
|
||||
discussion_questions=questions_json,
|
||||
teacher_guide="观察学生是否完整追问发热、咳嗽、喘息、既往史、接触史,并能解释胸片、炎症指标和血氧。",
|
||||
scoring_focus="问诊完整性、检查合理性、诊断准确性、治疗计划、风险预案、人文沟通。",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _demo_teaching_questions_json() -> str:
|
||||
"""教学题库种子:为儿科支气管肺炎病例生成可测试的选择题、答案、解析和视频字段。"""
|
||||
video = {"title": "儿童肺炎教学示例视频", "url": ""}
|
||||
questions = [
|
||||
{
|
||||
"question_id": "q1",
|
||||
"question_type": "single_choice",
|
||||
"stem": "该患儿最需要优先关注的病情严重程度指标是?",
|
||||
"options": [
|
||||
{"key": "A", "text": "体温峰值"},
|
||||
{"key": "B", "text": "血氧饱和度"},
|
||||
{"key": "C", "text": "咳嗽天数"},
|
||||
{"key": "D", "text": "食欲下降"},
|
||||
],
|
||||
"answer": "B",
|
||||
"analysis": "血氧饱和度能帮助判断低氧和肺炎严重程度,是处置决策的重要依据。",
|
||||
"video": video,
|
||||
"knowledge_points": ["严重程度评估", "血氧判断"],
|
||||
},
|
||||
{
|
||||
"question_id": "q2",
|
||||
"question_type": "single_choice",
|
||||
"stem": "结合发热、咳嗽、喘息和肺部湿啰音,最符合的诊断方向是?",
|
||||
"options": [
|
||||
{"key": "A", "text": "支气管肺炎"},
|
||||
{"key": "B", "text": "急性胃肠炎"},
|
||||
{"key": "C", "text": "泌尿系感染"},
|
||||
{"key": "D", "text": "单纯过敏性鼻炎"},
|
||||
],
|
||||
"answer": "A",
|
||||
"analysis": "呼吸道症状、肺部体征和影像/炎症指标共同支持儿童支气管肺炎。",
|
||||
"video": video,
|
||||
"knowledge_points": ["诊断依据", "肺部体征"],
|
||||
},
|
||||
{
|
||||
"question_id": "q3",
|
||||
"question_type": "single_choice",
|
||||
"stem": "下列哪组检查最有助于完善本例肺炎诊断和严重程度评估?",
|
||||
"options": [
|
||||
{"key": "A", "text": "血常规、CRP、胸片、血氧饱和度"},
|
||||
{"key": "B", "text": "肝功能、甲状腺功能、腹部超声"},
|
||||
{"key": "C", "text": "胃镜、幽门螺杆菌、粪便常规"},
|
||||
{"key": "D", "text": "骨龄片、维生素D、微量元素"},
|
||||
],
|
||||
"answer": "A",
|
||||
"analysis": "炎症指标、胸部影像和血氧情况可共同支撑诊断和严重程度判断。",
|
||||
"video": video,
|
||||
"knowledge_points": ["检查选择", "辅助检查"],
|
||||
},
|
||||
{
|
||||
"question_id": "q4",
|
||||
"question_type": "single_choice",
|
||||
"stem": "治疗方案中最需要覆盖的核心原则是?",
|
||||
"options": [
|
||||
{"key": "A", "text": "抗感染、止咳平喘、改善氧合、严密观察"},
|
||||
{"key": "B", "text": "立即长期激素维持治疗"},
|
||||
{"key": "C", "text": "只需补充维生素"},
|
||||
{"key": "D", "text": "无需随访观察"},
|
||||
],
|
||||
"answer": "A",
|
||||
"analysis": "儿童肺炎处置需围绕抗感染、呼吸症状缓解、氧合监测和病情变化预案展开。",
|
||||
"video": video,
|
||||
"knowledge_points": ["治疗原则", "风险预案"],
|
||||
},
|
||||
{
|
||||
"question_id": "q5",
|
||||
"question_type": "single_choice",
|
||||
"stem": "向家属沟通时,最合适的内容是?",
|
||||
"options": [
|
||||
{"key": "A", "text": "说明病情、观察指标、用药注意事项和复诊/住院指征"},
|
||||
{"key": "B", "text": "只告知已经开药即可"},
|
||||
{"key": "C", "text": "不需要解释检查结果"},
|
||||
{"key": "D", "text": "避免回答家属担心的问题"},
|
||||
],
|
||||
"answer": "A",
|
||||
"analysis": "儿科场景需要重视家属知情、风险信号识别和家庭护理教育。",
|
||||
"video": video,
|
||||
"knowledge_points": ["人文沟通", "健康教育"],
|
||||
},
|
||||
]
|
||||
return json.dumps(questions, ensure_ascii=False)
|
||||
|
||||
|
||||
def _seed_exam_items(db, case_id: int) -> None:
|
||||
"""检查项目种子:写入病例可申请检查和固定返回结果。"""
|
||||
if db.scalar(select(CaseExamItem).where(CaseExamItem.case_id == case_id)):
|
||||
@@ -265,6 +358,7 @@ def _seed_prompts(db) -> None:
|
||||
("patient_teaching", "patient", "teaching", "v1", "fast", "text", "app/prompts/patient/teaching.md"),
|
||||
("novice_case_hint", "hint", "novice", "v1", "fast", "json", "app/prompts/hint/novice_case_hint.md"),
|
||||
("scoring_pediatrics_pneumonia", "scoring", "pediatrics_pneumonia", "v1", "fast", "json", "app/prompts/scoring/pediatrics_pneumonia.md"),
|
||||
("scoring_teaching_interaction", "scoring", "teaching_interaction", "v1", "fast", "json", "app/prompts/scoring/teaching_interaction_evaluation.md"),
|
||||
("report_evaluation", "report", "evaluation", "v1", "fast", "json", "app/prompts/report/evaluation_report.md"),
|
||||
]
|
||||
for code, agent_type, scene, version, model_type, output_format, file_path in templates:
|
||||
|
||||
Reference in New Issue
Block a user