更新
This commit is contained in:
@@ -1641,6 +1641,49 @@ def test_sectioned_reply_becomes_a_structured_report(application: QApplication)
|
||||
bubble.deleteLater()
|
||||
|
||||
|
||||
def test_structured_report_shows_recorded_patient_and_skill_sources(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
reply = (
|
||||
"以下根据当前病历及历史随访资料作初步梳理,请医师结合原始记录复核所有结论,并确认记录时间与患者本人相符。\n"
|
||||
"1. 病情判断\n- 当前资料尚不足以确认具体证型,仍需补充舌脉与检查资料。\n"
|
||||
"2. 建议下一步\n- 请核对既往病历、血糖血压记录及随访记录,再决定后续检查与处置。\n"
|
||||
)
|
||||
commit = "270e94e637c4249dc411e54ac6715f21247de3cb"
|
||||
bubble = ai_consult_module._ChatBubble(role="ai", text=reply)
|
||||
bubble.set_provenance({
|
||||
"source_diagnosis_ids": [501, 502],
|
||||
"source_summary": {"diagnosis_count": 2, "blood_record_count": 3},
|
||||
"knowledge_source": {
|
||||
"title": "倪海厦 skill",
|
||||
"url": f"https://github.com/coinweth/nihaixia-skill/blob/{commit}/SKILL.md",
|
||||
"commit": commit,
|
||||
"sections": ["六经速查表"],
|
||||
},
|
||||
})
|
||||
|
||||
assert bubble.finalize_clinical_analysis() is True
|
||||
card = bubble.findChild(ai_consult_module.QFrame, "AiConsultReportProvenance")
|
||||
assert card is not None
|
||||
lines = [label.text() for label in card.findChildren(QLabel)]
|
||||
assert any("#501" in line and "#502" in line for line in lines)
|
||||
assert any("诊单 2 条" in line and "血糖血压记录 3 条" in line for line in lines)
|
||||
assert any("commit 270e94e637c4" in line for line in lines)
|
||||
assert any("/blob/270e94e637c4249dc411e54ac6715f21247de3cb/SKILL.md" in line for line in lines)
|
||||
bubble.deleteLater()
|
||||
|
||||
|
||||
def test_clinical_report_marks_unrecorded_provenance(application: QApplication) -> None:
|
||||
bubble = ai_consult_module._ChatBubble(role="ai", text=LONG_CLINICAL_REPLY)
|
||||
assert bubble.finalize_clinical_analysis() is True
|
||||
card = bubble.findChild(ai_consult_module.QFrame, "AiConsultReportProvenance")
|
||||
assert card is not None
|
||||
lines = [label.text() for label in card.findChildren(QLabel)]
|
||||
assert any("未附可核查的来源清单" in line for line in lines)
|
||||
assert any("未记录所用知识资料版本" in line for line in lines)
|
||||
bubble.deleteLater()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"reply",
|
||||
[
|
||||
|
||||
@@ -1335,6 +1335,31 @@ def test_patient_report_dialog_uses_one_scroll_owner_and_wrapped_risk_flow(
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_reception_report_displays_recorded_sources(application: QApplication) -> None:
|
||||
commit = "270e94e637c4249dc411e54ac6715f21247de3cb"
|
||||
payload = _snapshot("qwen", 2, "2026-10-08 15:00:00")
|
||||
payload.update({
|
||||
"source_diagnosis_ids": [501],
|
||||
"source_summary": {"diagnosis_count": 1, "prescription_count": 2},
|
||||
"knowledge_source": {
|
||||
"url": f"https://github.com/coinweth/nihaixia-skill/blob/{commit}/SKILL.md",
|
||||
"commit": commit,
|
||||
"sections": ["六经速查表"],
|
||||
},
|
||||
})
|
||||
dialog = _ReceptionAiAnalysisDialog({"qwen": [payload]})
|
||||
assert "#501" in dialog.source_label.text()
|
||||
assert "历史处方 2 条" in dialog.source_label.text()
|
||||
assert "六经速查表" in dialog.source_label.text()
|
||||
|
||||
page = ReceptionPage(object(), PermissionSet([]))
|
||||
page._render_ai_analysis_payload(payload, "qwen")
|
||||
assert "报告出处" in page.ai_source_label.text()
|
||||
assert "#501" in page.ai_source_label.text()
|
||||
dialog.close()
|
||||
page.close()
|
||||
|
||||
|
||||
def test_reception_ai_card_is_compact_preview_without_nested_scroll(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
|
||||
@@ -308,6 +308,7 @@ def test_diagnosis_dialog_renders_saved_case_report(
|
||||
assert dialog.snapshot_caption.text() == "完整病历"
|
||||
assert "肝郁脾虚证" in dialog.snapshot_body.text()
|
||||
assert any("核心判断" in text for text in labels)
|
||||
assert any("报告出处" in text and "关联诊单:#501" in text for text in labels)
|
||||
assert dialog.can_refresh is True
|
||||
assert not dialog.generate_button.isHidden()
|
||||
dialog.close()
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from doctor_workstation.ui.report_provenance import report_provenance_lines
|
||||
|
||||
_COMMIT = "db0155dc7c42b9c6b3736896661f317c7110038f"
|
||||
_URL = (
|
||||
"https://github.com/xiaopangxia/TCM-Ancient-Books/blob/"
|
||||
f"{_COMMIT}/123-%E6%B5%8B%E8%AF%95%E5%8F%A4%E7%B1%8D.txt#L42"
|
||||
)
|
||||
|
||||
|
||||
def test_recorded_ancient_book_reference_has_title_chapter_and_pinned_line() -> None:
|
||||
lines = report_provenance_lines(
|
||||
{
|
||||
"prompt_version": "patient-longitudinal-report-nihaixia-ancient-v4",
|
||||
"ancient_book_sources": [
|
||||
{
|
||||
"title": "测试古籍",
|
||||
"chapter": "消渴篇",
|
||||
"url": _URL,
|
||||
"commit": _COMMIT,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
assert any("《测试古籍》「消渴篇」" in line and _URL in line for line in lines)
|
||||
|
||||
|
||||
def test_old_or_unverified_report_does_not_gain_ancient_citation() -> None:
|
||||
lines = report_provenance_lines(
|
||||
{
|
||||
"prompt_version": "patient-longitudinal-report-nihaixia-v3",
|
||||
"ancient_book_sources": [
|
||||
{"title": "伪造", "url": _URL.replace(_COMMIT, "0" * 40), "commit": _COMMIT}
|
||||
],
|
||||
}
|
||||
)
|
||||
assert all("古籍参考:《" not in line for line in lines)
|
||||
Reference in New Issue
Block a user