feat: update medical training case and auth modules

This commit is contained in:
2026-06-03 17:34:47 +08:00
parent b4bb38b7be
commit fd0b3e1982
45 changed files with 1459 additions and 812 deletions
+45 -5
View File
@@ -59,6 +59,12 @@ def inject_sms_code(phone, scene, code='123456'):
cache.set(f'sms:{scene}:{phone}', code, timeout=300)
# ─── 默认测试机构 ─────────────────────────────────────────────────────────────
DEFAULT_INSTITUTION_CODE = 'TEST-HOSP-001'
DEFAULT_INSTITUTION_NAME = '测试医院'
# ─── 用户工具 ─────────────────────────────────────────────────────────────────
def create_test_user(phone='13900000001', password='TestPass1',
@@ -103,10 +109,10 @@ def create_teacher_student_relation(teacher, student, status=1):
# ─── 科室工具 ─────────────────────────────────────────────────────────────────
def ensure_institution(name='测试医院'):
def ensure_institution(name='测试医院', code='TEST-HOSP-001'):
inst, _ = Institution.objects.get_or_create(
name=name,
defaults={'type': 'hospital', 'province': '北京', 'city': '北京'},
code=code,
defaults={'name': name, 'type': 'hospital', 'province': '北京', 'city': '北京'},
)
return inst
@@ -122,7 +128,25 @@ def ensure_department(name='儿科', institution_name='测试医院'):
# ─── 病例载荷构建 ─────────────────────────────────────────────────────────────
def build_traditional_payload(department_name='儿科', scoring_rules_count=2):
def sample_exam_items():
"""示例检查项(用于 C3 full-create)。"""
return [
{
'item_code': 'blood_routine',
'item_name': '血常规',
'item_type': 'lab',
'category': '实验室检查',
'result_text': 'WBC 10×10^9/L',
'result_structured': {'wbc': '10×10^9/L'},
'is_key': True,
'is_abnormal': False,
'score_weight': 1.0,
'display_order': 1,
},
]
def build_traditional_payload(department_name='儿科', scoring_rules_count=2, with_exam_items=False):
"""构建合法的传统病例 full-create 载荷。"""
rules = [
{
@@ -133,7 +157,7 @@ def build_traditional_payload(department_name='儿科', scoring_rules_count=2):
}
for i in range(scoring_rules_count)
]
return {
payload = {
'title': '测试传统病例-表单录入',
'case_type': 'traditional',
'difficulty': 'medium',
@@ -152,6 +176,9 @@ def build_traditional_payload(department_name='儿科', scoring_rules_count=2):
},
'scoring_rules': rules,
}
if with_exam_items:
payload['exam_items'] = sample_exam_items()
return payload
def build_teaching_payload(department_name='儿科', scoring_rules_count=2):
@@ -206,6 +233,19 @@ MOCK_C1_PARSE_RESULT = {
'standard_treatment': 'Mock 对症治疗',
'guideline_reference': 'Mock 指南',
},
'exam_items': [
{
'item_code': 'blood_routine',
'item_name': '血常规',
'item_type': 'lab',
'category': '实验室检查',
'result_text': 'WBC 10×10^9/L',
'is_key': True,
'is_abnormal': False,
'score_weight': 1.0,
'display_order': 1,
},
],
},
'usage': {'prompt_tokens': 100, 'completion_tokens': 200, 'total_tokens': 300},
}