first commit
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
"""Render the structured reception medication/case card for visual review."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from PySide6.QtCore import QThreadPool
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from doctor_workstation.services.mock_repository import DemoDoctorRepository
|
||||
from doctor_workstation.ui.shell import ShellWindow
|
||||
from doctor_workstation.ui.theme import apply_theme
|
||||
|
||||
|
||||
def main() -> int:
|
||||
app = QApplication.instance() or QApplication([])
|
||||
apply_theme(app)
|
||||
repository = DemoDoctorRepository()
|
||||
session = repository.login("doctor", "doctor123")
|
||||
window = ShellWindow(repository, session)
|
||||
window.resize(1710, 920)
|
||||
window.show()
|
||||
if not window.navigate("reception"):
|
||||
raise RuntimeError("reception navigation is unavailable")
|
||||
for _index in range(4):
|
||||
app.processEvents()
|
||||
QThreadPool.globalInstance().waitForDone(10_000)
|
||||
|
||||
page = window.pages.get("reception")
|
||||
if page is None:
|
||||
raise RuntimeError("reception page was not created")
|
||||
page.detail_stack.setCurrentIndex(1)
|
||||
medication_index = next(
|
||||
index
|
||||
for index in range(page.detail_tabs.count())
|
||||
if page.detail_tabs.tabText(index) == "用药记录"
|
||||
)
|
||||
page.detail_tabs.setCurrentIndex(medication_index)
|
||||
page._render_case(
|
||||
{"has_prescription": True},
|
||||
{"age": 56, "gender": 1},
|
||||
{
|
||||
"diagnosis_date": "2026-08-14",
|
||||
"diagnosis_type_text": "复诊",
|
||||
"systolic": 148,
|
||||
"diastolic": 92,
|
||||
"blood_pressure_status": "偏高",
|
||||
"fasting_blood_sugar": "6.8",
|
||||
"fasting_blood_sugar_status": "偏高",
|
||||
"clinical_diagnosis": "2 型糖尿病(血糖控制未达标),合并高血压与轻度脂肪肝",
|
||||
"current_medications": [
|
||||
"二甲双胍缓释片 0.5 g,早晚餐后各一次",
|
||||
"格列吡嗪片 5 mg,早餐前一次",
|
||||
],
|
||||
"allergy_history_text": "青霉素过敏",
|
||||
"chief_complaint": "口干口苦、多饮多汗,近期睡眠欠佳",
|
||||
"present_illness": (
|
||||
"近两周空腹血糖波动,伴头昏、腰膝酸软及夜间多尿;"
|
||||
"未发生明确低血糖,服药依从性一般。"
|
||||
),
|
||||
"tongue": "舌红,苔黄腻",
|
||||
"pulse": "脉弦滑",
|
||||
"treatment_principle": "益气养阴、清热利湿,兼顾健脾化痰",
|
||||
"diabetes_history_text": "10 年",
|
||||
"past_history_text": "高血压 6 年、高脂血症 3 年",
|
||||
"family_history_text": "父亲患 2 型糖尿病",
|
||||
"sleep_condition_text": "多梦、入睡困难",
|
||||
"diet_condition_text": "主食量偏多,晚餐较晚",
|
||||
"remark": "重点核对降糖药剂量,复查肝肾功能,并关注夜间低血糖风险。",
|
||||
},
|
||||
)
|
||||
for _index in range(6):
|
||||
app.processEvents()
|
||||
|
||||
output = (
|
||||
Path(__file__).resolve().parents[1]
|
||||
/ "artifacts"
|
||||
/ "reception_medication_case"
|
||||
/ "reception_medication_case_1710x920.png"
|
||||
)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not window.grab().save(str(output), "PNG"):
|
||||
raise RuntimeError(f"failed to save {output}")
|
||||
print(output)
|
||||
window.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user