更新
This commit is contained in:
@@ -10,6 +10,7 @@ import pytest
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from doctor_workstation.core import PermissionSet
|
||||
from doctor_workstation.services import DemoDoctorRepository
|
||||
from doctor_workstation.ui.dialogs import prescription as dialog_module
|
||||
from doctor_workstation.ui.dialogs.prescription import (
|
||||
@@ -88,7 +89,7 @@ def test_admin_status_and_action_guards_are_exact() -> None:
|
||||
assert prescription_status(pending) == ("待审核", "warning")
|
||||
assert prescription_status(approved) == ("已通过", "success")
|
||||
assert prescription_status(rejected) == ("已驳回", "danger")
|
||||
assert prescription_status(voided) == ("已作废", "danger")
|
||||
assert prescription_status(voided) == ("已通过", "success")
|
||||
assert can_patch_patient(pending)
|
||||
assert can_create_order(pending)
|
||||
assert can_audit(pending)
|
||||
@@ -325,6 +326,8 @@ def test_editor_builds_complete_add_payload(
|
||||
editor.clinical_diagnosis.setPlainText("脾气虚")
|
||||
editor.herbs.rows[0].medicine.set_value(31, "黄芪")
|
||||
editor.herbs.rows[0].dosage.setValue(15)
|
||||
editor.dietary_taboo.set_values(["辛辣食物", "浓茶"])
|
||||
assert editor.dietary_taboo.lineEdit().text() == "辛辣食物、浓茶"
|
||||
editor.signature._has_strokes = True
|
||||
payload = editor.payload()
|
||||
|
||||
@@ -341,12 +344,117 @@ def test_editor_builds_complete_add_payload(
|
||||
}
|
||||
]
|
||||
assert payload["doctor_name"] == "周医生"
|
||||
assert payload["dietary_taboo"] == ["辛辣食物", "浓茶"]
|
||||
assert payload["doctor_signature"].startswith("data:image/png;base64,")
|
||||
assert isinstance(payload["aux_usage"], dict)
|
||||
editor.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_editor_matches_admin_four_observation_fields_and_edit_context(
|
||||
application: QApplication,
|
||||
immediate_async: None,
|
||||
) -> None:
|
||||
calls: list[dict[str, Any]] = []
|
||||
|
||||
class Repository:
|
||||
def list_prescription_orders(self, **filters: Any) -> dict[str, Any]:
|
||||
calls.append(filters)
|
||||
return {
|
||||
"lists": [
|
||||
{
|
||||
"order_no": "PO-901",
|
||||
"medication_days": 14,
|
||||
"remark_assistant": "按两周疗程复核",
|
||||
}
|
||||
],
|
||||
"count": 1,
|
||||
}
|
||||
|
||||
source = {
|
||||
"id": 91,
|
||||
"diagnosis_id": 501,
|
||||
"patient_name": "林晓岚",
|
||||
"visit_no": "1K00000501",
|
||||
"tongue": "面象哨兵",
|
||||
"tongue_image": "舌象哨兵",
|
||||
"pulse": "脉象哨兵",
|
||||
"pulse_condition": "脉象详情哨兵",
|
||||
"clinical_diagnosis": "气阴两虚",
|
||||
"doctor_name": "周医生",
|
||||
"audit_status": 2,
|
||||
"void_status": 1,
|
||||
"is_system_auto": 1,
|
||||
"business_prescription_audit_rejected": 1,
|
||||
"business_prescription_audit_remark": "订单审核意见",
|
||||
"herbs": [{"medicine_id": 31, "name": "黄芪", "dosage": 15}],
|
||||
}
|
||||
editor = PrescriptionEditorDialog(Repository(), source, mode="edit")
|
||||
|
||||
assert editor.tongue.text() == "面象哨兵"
|
||||
assert editor.tongue_image.text() == "舌象哨兵"
|
||||
assert editor.pulse.text() == "脉象哨兵"
|
||||
assert editor.pulse_condition.text() == "脉象详情哨兵"
|
||||
payload = editor.payload()
|
||||
assert payload["tongue"] == "面象哨兵"
|
||||
assert payload["tongue_image"] == "舌象哨兵"
|
||||
assert payload["pulse"] == "脉象哨兵"
|
||||
assert payload["pulse_condition"] == "脉象详情哨兵"
|
||||
assert "取消作废、清除驳回" in editor.context_banner.label.text()
|
||||
assert "空白处方" in editor.context_banner.label.text()
|
||||
assert calls == [{"page_no": 1, "page_size": 5, "prescription_id": 91}]
|
||||
assert "PO-901" in editor.linked_order_banner.label.text()
|
||||
assert "14 天" in editor.linked_order_banner.label.text()
|
||||
assert "按两周疗程复核" in editor.linked_order_banner.label.text()
|
||||
editor.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_editor_preserves_global_lock_and_admin_type_constraints(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
editor = PrescriptionEditorDialog(
|
||||
SimpleNamespace(),
|
||||
mode="add",
|
||||
current_user=SimpleNamespace(id=7, name="周医生"),
|
||||
permissions=PermissionSet([]),
|
||||
)
|
||||
editor.herbs.set_rows(
|
||||
[
|
||||
{
|
||||
"medicine_id": 31,
|
||||
"name": "酸枣仁",
|
||||
"dosage": 12,
|
||||
"formula_type": "辅方",
|
||||
"locked": True,
|
||||
},
|
||||
{"medicine_id": 32, "name": "黄芪", "dosage": 15, "formula_type": "主方"},
|
||||
],
|
||||
locked=False,
|
||||
)
|
||||
assert editor.herbs.locked
|
||||
assert all(row.locked for row in editor.herbs.rows)
|
||||
assert not editor.add_main_button.isEnabled()
|
||||
assert editor.import_library_button.isHidden()
|
||||
assert editor._aux_name_field.isHidden()
|
||||
|
||||
editor.prescription_type.setCurrentIndex(editor.prescription_type.findData("饮片"))
|
||||
assert editor.dosage_amount.minimum() == 50
|
||||
assert editor.dosage_amount.maximum() == 250
|
||||
assert editor.dosage_amount.value() == 50
|
||||
assert editor.bags_per_dose.maximum() == 9
|
||||
assert editor.aux_dosage_amount.value() == 50
|
||||
|
||||
editor.prescription_type.setCurrentIndex(editor.prescription_type.findData("浓缩水丸"))
|
||||
assert editor.dosage_amount.minimum() == 1
|
||||
assert editor.dosage_amount.maximum() == 10
|
||||
assert editor.dosage_amount.value() == 1
|
||||
assert editor.dosage_bag_count.maximum() == 5
|
||||
assert editor.aux_dosage_amount.value() == 5
|
||||
editor.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_audit_reject_requires_remark(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user