This commit is contained in:
Your Name
2026-10-29 16:14:55 +08:00
parent a5c3235bf7
commit 28ba9b97f2
81 changed files with 6361 additions and 2301 deletions
+6
View File
@@ -41,6 +41,7 @@ from doctor_workstation.ui.widgets import (
friendly_error,
gender_text,
get_value,
has_permission,
run_async,
set_authentication_expired_handler,
show_toast,
@@ -939,6 +940,11 @@ class ApplicationController(QObject):
open_im=open_im,
patient_name=patient_name,
patient_case=patient_case,
can_ai_assistant=has_permission(
getattr(self.shell_window, "permissions", None),
"tcm.diagnosis/aiAssistant",
default=False,
),
on_open_diagnosis=lambda current_id=diagnosis_id, current_key=call_key: (
self._open_video_diagnosis(current_id, call_key=current_key)
),
@@ -4,6 +4,7 @@ from __future__ import annotations
import hashlib
import json
import re
import struct
import zlib
from collections.abc import Callable, Mapping, Sequence
@@ -2846,11 +2847,22 @@ class DemoDoctorRepository:
}
)
def sync_im_chat_messages(self, diagnosis_id: int) -> dict[str, Any]:
"""Acknowledge the same asynchronous sync contract in demo mode."""
def sync_im_chat_messages(
self, diagnosis_id: int, *, scope: str = "", sync_token: str = ""
) -> dict[str, Any]:
"""Complete synthetic archive sync while retaining the legacy receipt."""
self._find_consultation(diagnosis_id)
return {"queued": True, "diagnosis_id": diagnosis_id}
if scope not in {"", "current"}:
raise ValueError("IM sync scope must be empty or current")
if not isinstance(sync_token, str) or (
sync_token and re.fullmatch(r"[a-f0-9]{48}", sync_token) is None
):
raise ValueError("IM sync token is invalid")
return {
"queued": True, "diagnosis_id": diagnosis_id,
"completed": True, "phase": "completed", "errors": [],
}
def list_diagnosis_appointment_logs(self, diagnosis_id: int) -> list[dict[str, Any]]:
"""Build demo audit rows from the diagnosis appointments."""
@@ -692,8 +692,10 @@ class DoctorRepository(Protocol):
) -> dict[str, Any]:
"""Return diagnosis IM messages, defaulting to the fast archive-only path."""
def sync_im_chat_messages(self, diagnosis_id: int) -> Any:
"""Queue the server-side IM archive synchronisation job."""
def sync_im_chat_messages(
self, diagnosis_id: int, *, scope: str = "", sync_token: str = ""
) -> Any:
"""Advance one server-side archive page; inspect completed before using it."""
def list_diagnosis_appointment_logs(self, diagnosis_id: int) -> list[dict[str, Any]]:
"""Return per-diagnosis registration / cancellation audit rows."""
@@ -2602,12 +2604,27 @@ class RemoteDoctorRepository:
)
return dict(_require_mapping(payload, "tcm.diagnosis/getImChatMessages"))
def sync_im_chat_messages(self, diagnosis_id: int) -> Any:
"""Queue the confirmed shutdown-function archive sync endpoint."""
def sync_im_chat_messages(
self, diagnosis_id: int, *, scope: str = "", sync_token: str = ""
) -> Any:
"""Advance a bounded archive page, preserving legacy no-option callers."""
if diagnosis_id <= 0:
raise ValueError("diagnosis_id must be positive")
return self.client.post("tcm.diagnosis/triggerImChatSync", {"diagnosis_id": diagnosis_id})
if scope not in {"", "current"}:
raise ValueError("IM sync scope must be empty or current")
if not isinstance(sync_token, str) or (
sync_token and re.fullmatch(r"[a-f0-9]{48}", sync_token) is None
):
raise ValueError("IM sync token is invalid")
payload: dict[str, Any] = {"diagnosis_id": diagnosis_id}
if scope:
payload["scope"] = scope
if sync_token:
payload["sync_token"] = sync_token
return _client_request(
self.client, "post", "tcm.diagnosis/triggerImChatSync", payload, timeout=15.0
)
def list_diagnosis_appointment_logs(self, diagnosis_id: int) -> list[dict[str, Any]]:
"""Return registration/cancellation logs from ``guahaoLogList``."""
@@ -23,7 +23,6 @@ from PySide6.QtWidgets import (
QComboBox,
QDialog,
QFrame,
QGraphicsDropShadowEffect,
QGraphicsOpacityEffect,
QHBoxLayout,
QLabel,
@@ -43,6 +42,7 @@ from PySide6.QtWidgets import (
)
from ..core.appointment_modes import APPOINTMENT_MODES
from .design_system import clinical_stylesheet
from .theme import main_window_target_rect
from .widgets import (
display_text,
@@ -84,8 +84,8 @@ QDialog#AppointmentDrawerOverlay QToolButton#AppointmentDrawerClose {
min-height: 32px;
max-height: 32px;
padding: 0;
border: 0;
border-radius: 4px;
border: 1px solid transparent;
border-radius: $ds_radius_control;
background-color: transparent;
color: #606163;
font-size: 22px;
@@ -95,6 +95,10 @@ QDialog#AppointmentDrawerOverlay QToolButton#AppointmentDrawerClose {
QDialog#AppointmentDrawerOverlay QToolButton#AppointmentDrawerClose:hover {
color: #1A1C1F;
background-color: #F0F0F0;
}
QDialog#AppointmentDrawerOverlay QToolButton#AppointmentDrawerClose:focus {
border-color: $ds_focus;
background-color: $ds_accent_soft;
}
QDialog#AppointmentDrawerOverlay QScrollArea#AppointmentDrawerBody,
@@ -110,7 +114,7 @@ QDialog#AppointmentDrawerOverlay QWidget#AppointmentDrawerBodyContent {
}
QDialog#AppointmentDrawerOverlay QLabel[appointmentLabel="true"] {
color: #1A1C1F;
color: $ds_muted;
font-size: 14px;
font-weight: 500;
}
@@ -125,7 +129,7 @@ QDialog#AppointmentDrawerOverlay QPlainTextEdit {
min-height: 30px;
padding: 0 11px;
border: 1px solid #EDEDEE;
border-radius: 9px;
border-radius: 10px;
background-color: #FFFFFF;
color: #1A1C1F;
selection-background-color: #EEF1FA;
@@ -145,7 +149,14 @@ QDialog#AppointmentDrawerOverlay QPlainTextEdit:hover {
QDialog#AppointmentDrawerOverlay QComboBox:focus,
QDialog#AppointmentDrawerOverlay QLineEdit:focus,
QDialog#AppointmentDrawerOverlay QPlainTextEdit:focus {
border: 2px solid #8B9AD9;
border: 1px solid #8B9AD9;
}
QDialog#AppointmentDrawerOverlay QComboBox:disabled,
QDialog#AppointmentDrawerOverlay QLineEdit:disabled,
QDialog#AppointmentDrawerOverlay QPlainTextEdit:disabled {
color: $ds_disabled;
background-color: $ds_disabled_surface;
border-color: $ds_line;
}
QDialog#AppointmentDrawerOverlay QComboBox::drop-down {
@@ -197,7 +208,7 @@ QDialog#AppointmentDrawerOverlay QPushButton[appointmentDate="true"] {
max-height: 38px;
padding: 0;
border: 1px solid #EDEDEE;
border-radius: 8px;
border-radius: 10px;
background-color: #FFFFFF;
color: #1A1C1F;
font-size: 14px;
@@ -221,15 +232,15 @@ QDialog#AppointmentDrawerOverlay QPushButton[appointmentDate="true"]:checked {
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentSlotsPanel {
background-color: #F7F7F7;
background-color: $ds_surface_alt;
border: 0;
border-radius: 8px;
border-radius: $ds_radius_panel;
}
QDialog#AppointmentDrawerOverlay QLabel#AppointmentSlotsTitle {
color: #1A1C1F;
font-size: 15px;
font-weight: 500;
font-weight: 600;
}
QDialog#AppointmentDrawerOverlay QPushButton#AppointmentRefreshSlots {
@@ -247,13 +258,17 @@ QDialog#AppointmentDrawerOverlay QPushButton#AppointmentRefreshSlots {
QDialog#AppointmentDrawerOverlay QPushButton#AppointmentRefreshSlots:hover {
background-color: #EEF1FA;
}
QDialog#AppointmentDrawerOverlay QPushButton#AppointmentRefreshSlots:focus {
background-color: $ds_accent_soft;
border: 1px solid $ds_focus;
}
QDialog#AppointmentDrawerOverlay QPushButton[appointmentSlot="true"] {
min-width: 110px;
min-height: 70px;
padding: 0 8px;
border: 2px solid #EDEDEE;
border-radius: 8px;
border-radius: 10px;
background-color: #FFFFFF;
color: #1A1C1F;
}
@@ -330,25 +345,25 @@ QDialog#AppointmentDrawerOverlay QLabel#AppointmentEmptyText {
QDialog#AppointmentDrawerOverlay QFrame#AppointmentAlert[kind="info"] {
background-color: #EEF1FA;
border: 1px solid #EDEDEE;
border-radius: 9px;
border-radius: 10px;
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentAlert[kind="warning"] {
background-color: #FFF5E6;
border: 1px solid #F6E3C4;
border-radius: 9px;
border-radius: 10px;
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentAlert[kind="danger"] {
background-color: #FFF1F3;
border: 1px solid #F7D7DC;
border-radius: 9px;
border-radius: 10px;
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentAlert[kind="success"] {
background-color: #EAF9F3;
border: 1px solid #D4F0E5;
border-radius: 9px;
border-radius: 10px;
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentAlert[kind="info"] QLabel {
@@ -378,7 +393,7 @@ QDialog#AppointmentDrawerOverlay QFrame#AppointmentDrawerFooter QPushButton {
max-height: 30px;
padding: 0 15px;
border: 1px solid #EDEDEE;
border-radius: 9px;
border-radius: 10px;
background-color: #FFFFFF;
color: #1A1C1F;
font-size: 13px;
@@ -408,9 +423,14 @@ QDialog#AppointmentDrawerOverlay QFrame#AppointmentDrawerFooter QPushButton[prim
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentDrawerFooter QPushButton:disabled {
color: #FFFFFF;
border-color: #EDEDEE;
background-color: #8E8F90;
color: $ds_disabled;
border-color: $ds_line;
background-color: $ds_disabled_surface;
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentDrawerFooter QPushButton[primary="true"]:pressed {
color: $ds_surface;
background-color: $ds_accent_pressed;
border-color: $ds_accent_pressed;
}
QDialog#AppointmentDrawerOverlay QFrame#AppointmentLoadingOverlay {
@@ -487,6 +507,7 @@ _APPOINTMENT_DARK_REPLACEMENTS = (
)
# Light is the default application theme. Keep the replacement table available
# for a future explicit dark-mode switch, but do not mutate the light source QSS.
APPOINTMENT_DRAWER_QSS = clinical_stylesheet(APPOINTMENT_DRAWER_QSS)
def _as_int(value: Any, default: int = 0) -> int:
@@ -733,35 +754,7 @@ class _EmptyIllustration(QWidget):
painter.end()
class _HoverLiftButton(QPushButton):
"""Button with a subtle two-pixel lift and blue-tinted shadow on hover."""
def __init__(self, text: str = "", parent: QWidget | None = None) -> None:
super().__init__(text, parent)
self._lifted = False
self._base_position = QPoint()
def enterEvent(self, event: QEvent) -> None: # noqa: N802 - Qt API
if self.isEnabled() and not self._lifted:
self._base_position = self.pos()
self.move(self.x(), self.y() - 2)
shadow = QGraphicsDropShadowEffect(self)
shadow.setBlurRadius(12)
shadow.setOffset(0, 4)
shadow.setColor(QColor(26, 28, 31, 72))
self.setGraphicsEffect(shadow)
self._lifted = True
super().enterEvent(event)
def leaveEvent(self, event: QEvent) -> None: # noqa: N802 - Qt API
if self._lifted:
self.move(self._base_position)
self.setGraphicsEffect(None)
self._lifted = False
super().leaveEvent(event)
class _SlotCard(_HoverLiftButton):
class _SlotCard(QPushButton):
"""Two-line time card matching Element's independent time/status typography."""
def __init__(self, time_text: str, status_text: str) -> None:
@@ -819,8 +812,8 @@ class AppointmentDrawer(QDialog):
self._today_blocking = False
self._channel_names: dict[str, str] = {}
self._doctor_buttons: dict[int, QRadioButton] = {}
self._date_buttons: dict[str, _HoverLiftButton] = {}
self._slot_buttons: dict[str, _HoverLiftButton] = {}
self._date_buttons: dict[str, QPushButton] = {}
self._slot_buttons: dict[str, QPushButton] = {}
self._slot_available: dict[str, bool] = {}
self._slot_restore_selection = ""
self._active_loading = ""
@@ -1426,7 +1419,7 @@ class AppointmentDrawer(QDialog):
continue
label = f"{parsed.toString('MM月dd日')} ({week_days[parsed.dayOfWeek() % 7]})"
self.date_combo.addItem(label, value)
button = _HoverLiftButton(label)
button = QPushButton(label)
button.setProperty("appointmentDate", True)
button.setCheckable(True)
button.setFixedSize(130, 40)
@@ -2,143 +2,155 @@
from string import Template
from .design_system import clinical_stylesheet
from .reception_style import body_family, heading_family
def appointments_stylesheet() -> str:
return Template(_QSS).substitute(body=body_family(), heading=heading_family())
return clinical_stylesheet(Template(_QSS).safe_substitute(body=body_family(), heading=heading_family()))
_QSS = """
#AppointmentsPage { background: #F3F7FD; color: #273244; }
#AppointmentsPage { background: $ds_canvas; color: $ds_text; }
#AppointmentsPage QLabel, #AppointmentsPage QPushButton,
#AppointmentsPage QLineEdit, #AppointmentsPage QComboBox,
#AppointmentsPage QTabBar, #AppointmentsPage QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#AppointmentsPage QWidget#PageHeader QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: #202C3F;
font-family: "$heading"; font-size: 20px; font-weight: 600; color: $ds_heading;
}
#AppointmentsPage QWidget#PageHeader QLabel[role="muted"],
#AppointmentsPage QWidget#PageHeader QLabel[role="breadcrumb"],
#AppointmentsPage QWidget#PageHeader QLabel[role="breadcrumbSeparator"],
#AppointmentsPage QWidget#PageHeader QLabel[role="breadcrumbCurrent"] {
color: #5D6B80; font-size: 13px; font-weight: 400;
color: $ds_muted; font-size: 13px; font-weight: 400;
}
#AppointmentsPage QFrame#AppointmentFilterPanel,
#AppointmentsPage QFrame#AppointmentMainCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#AppointmentsPage QPushButton {
min-height: 30px; padding: 0 12px; border: 1px solid #DBE5F2;
border-radius: 6px; background: #FFFFFF;
min-height: 30px; padding: 0 12px; border: 1px solid transparent;
border-radius: $ds_radius_control; background: $ds_surface_alt;
}
#AppointmentsPage QPushButton:hover { color: #1555B6; background: #F2F7FF; border-color: #B6CDEE; }
#AppointmentsPage QPushButton:pressed { background: #DCEAFF; }
#AppointmentsPage QPushButton:focus { border-color: #75A5F0; }
#AppointmentsPage QPushButton:hover { color: $ds_accent; background: $ds_surface_alt; border-color: $ds_line_strong; }
#AppointmentsPage QPushButton:pressed { background: $ds_accent_soft; }
#AppointmentsPage QPushButton:focus { border-color: $ds_focus; }
#AppointmentsPage QPushButton[variant="primary"] {
background: #1769E8; color: #FFFFFF; border-color: #1769E8;
background: $ds_accent; color: $ds_surface; border-color: $ds_accent;
}
#AppointmentsPage QPushButton[variant="primary"]:hover { background: #155BCC; }
#AppointmentsPage QPushButton[variant="primary"]:pressed { background: #124EA9; }
#AppointmentsPage QPushButton[variant="primary"]:hover { background: $ds_accent_hover; }
#AppointmentsPage QPushButton[variant="primary"]:pressed { background: $ds_accent_pressed; }
#AppointmentsPage QPushButton[variant="primary"]:focus { border-color: $ds_focus; }
#AppointmentsPage QPushButton[variant="danger"] {
color: #B84652; background: #FFFFFF; border-color: #EFC8CE;
color: $ds_danger; background: $ds_danger_soft; border-color: transparent;
}
#AppointmentsPage QPushButton[variant="danger"]:hover { background: #FFF0F2; }
#AppointmentsPage QPushButton[variant="danger"]:hover { background: $ds_danger_soft; }
#AppointmentsPage QPushButton[variant="danger"]:pressed { border-color: $ds_danger; }
#AppointmentsPage QPushButton[variant="ghost"] { background: transparent; border-color: transparent; }
#AppointmentsPage QPushButton:disabled {
color: #8A97A9; background: #F6F8FC; border-color: #E2E9F2;
#AppointmentsPage QPushButton[variant="ghost"]:hover { background: $ds_accent_soft; }
#AppointmentsPage QPushButton[variant="ghost"]:focus { border-color: $ds_focus; }
#AppointmentsPage QPushButton:disabled, #AppointmentsPage QPushButton[variant="primary"]:disabled,
#AppointmentsPage QPushButton[variant="danger"]:disabled {
color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line;
}
#AppointmentsPage QLineEdit, #AppointmentsPage QComboBox {
min-height: 32px; padding: 0 10px; color: #273244; background: #FFFFFF;
border: 1px solid #DBE5F2; border-radius: 6px; selection-background-color: #DCEAFF;
min-height: 32px; padding: 0 10px; color: $ds_text; background: $ds_surface;
border: 1px solid $ds_line; border-radius: $ds_radius_control; selection-background-color: $ds_accent_soft;
}
#AppointmentsPage QLineEdit:focus, #AppointmentsPage QComboBox:focus { border-color: #75A5F0; }
#AppointmentsPage QLineEdit:focus, #AppointmentsPage QComboBox:focus { border-color: $ds_focus; }
#AppointmentsPage QLineEdit QToolButton {
min-width: 0; min-height: 0; padding: 0; border: 0; background: transparent;
}
#AppointmentsPage QLineEdit QToolButton:focus { background: #EAF2FF; }
#AppointmentsPage QLineEdit QToolButton:focus { background: $ds_accent_soft; }
#AppointmentsPage QPushButton#AppointmentSearchButton {
min-height: 39px; max-height: 39px; min-width: 52px;
}
#AppointmentsPage QLineEdit#AppointmentPatientSearch { min-height: 39px; max-height: 39px; }
#AppointmentsPage QPushButton[appointmentStat="true"] {
min-height: 34px; max-height: 34px; padding: 0 10px; background: #F4F7FC;
border-color: transparent; color: #5D6B80; font-size: 13px;
min-height: 34px; max-height: 34px; padding: 0 10px; background: $ds_canvas;
border-color: transparent; color: $ds_muted; font-size: 13px;
}
#AppointmentsPage QPushButton[appointmentStat="true"]:hover { color: #1555B6; background: #EAF2FF; }
#AppointmentsPage QPushButton[appointmentStat="true"]:hover { color: $ds_accent; background: $ds_accent_soft; }
#AppointmentsPage QPushButton[appointmentStat="true"]:checked {
color: #FFFFFF; background: #1769E8; border-color: #1769E8;
color: $ds_accent; background: $ds_accent_soft; border-color: transparent; font-weight: 600;
}
#AppointmentsPage QPushButton[appointmentStatKind="warning"][hasPending="true"]:!checked {
color: #9C681F; background: #FFF6E7; border-color: #EEDCBF;
color: $ds_warning; background: $ds_warning_soft; border-color: $ds_warning_soft;
}
#AppointmentsPage QLabel#FilterRowLabel { color: #5D6B80; font-size: 13px; }
#AppointmentsPage QLabel#FilterDivider { color: #DBE5F2; padding: 0 10px; }
#AppointmentsPage QLabel#FilterRowLabel { color: $ds_muted; font-size: 13px; }
#AppointmentsPage QLabel#FilterDivider { color: $ds_line; padding: 0 10px; }
#AppointmentsPage QTabBar#AppointmentStatusTabs::tab {
min-width: 52px; min-height: 32px; padding: 0 12px; color: #5D6B80;
min-width: 52px; min-height: 32px; padding: 0 12px; color: $ds_muted;
background: transparent; border: 0; border-bottom: 2px solid transparent; font-size: 13px;
}
#AppointmentsPage QTabBar#AppointmentStatusTabs::tab:hover { color: #1555B6; background: #F7FAFE; }
#AppointmentsPage QTabBar#AppointmentStatusTabs::tab:hover { color: $ds_accent; background: $ds_surface_alt; }
#AppointmentsPage QTabBar#AppointmentStatusTabs::tab:selected {
color: #1769E8; background: transparent; border-bottom-color: #1769E8;
color: $ds_accent; background: transparent; border-bottom-color: $ds_accent;
}
#AppointmentsPage QPushButton[filterChoice="true"] {
min-height: 30px; max-height: 30px; padding: 0 12px; color: #5D6B80;
min-height: 30px; max-height: 30px; padding: 0 12px; color: $ds_muted;
background: transparent; border-color: transparent; font-size: 13px;
}
#AppointmentsPage QPushButton[filterChoice="true"]:checked { color: #1555B6; background: #EAF2FF; }
#AppointmentsPage QPushButton[filterChoice="true"]:checked { color: $ds_accent; background: $ds_accent_soft; }
#AppointmentsPage QPushButton[filterChoice="true"]:focus,
#AppointmentsPage QPushButton[appointmentStat="true"]:focus { border-color: $ds_focus; }
#AppointmentsPage QFrame#AppointmentToolbar { background: transparent; border: 0; }
#AppointmentsPage QPushButton[compactAction="true"] {
min-height: 36px; max-height: 36px; padding: 0 17px; font-size: 13px;
}
#AppointmentsPage QFrame#AppointmentToolbar QPushButton[variant="secondary"]:enabled {
color: #1769E8; border-color: #ADC8F0;
color: $ds_text; border-color: transparent;
}
#AppointmentsPage QFrame#AppointmentToolbar QPushButton[variant="secondary"]:hover { color: $ds_accent; background: $ds_accent_soft; }
#AppointmentsPage QFrame#AppointmentToolbar QPushButton[variant="secondary"]:focus { border-color: $ds_focus; }
#AppointmentsPage QTableWidget#AppointmentTable {
background: #FFFFFF; alternate-background-color: #FFFFFF; border: 0; border-radius: 0;
gridline-color: #E6EDF6; selection-background-color: #EAF2FF; selection-color: #273244;
background: $ds_surface; alternate-background-color: $ds_surface; border: 0; border-radius: 0;
gridline-color: $ds_line; selection-background-color: $ds_accent_soft; selection-color: $ds_text;
}
#AppointmentsPage QTableWidget#AppointmentTable::item { padding: 0; border: 0; border-bottom: 1px solid #E6EDF6; }
#AppointmentsPage QTableWidget#AppointmentTable::item:selected { background: #EAF2FF; color: #273244; }
#AppointmentsPage QTableWidget#AppointmentTable::item { padding: 0; border: 0; border-bottom: 1px solid $ds_line; }
#AppointmentsPage QTableWidget#AppointmentTable::item:selected { background: $ds_accent_soft; color: $ds_text; }
#AppointmentsPage QTableWidget#AppointmentTable QHeaderView::section {
min-height: 40px; padding: 0; background: #F5F8FD; color: #5D6B80;
border: 0; border-top: 1px solid #E1E9F4; border-bottom: 1px solid #E1E9F4;
min-height: 40px; padding: 0; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-top: 1px solid $ds_line; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#AppointmentsPage QWidget[appointmentSelectionHost="true"] {
background: transparent; border-left: 3px solid transparent;
}
#AppointmentsPage QWidget[appointmentSelectionHost="true"][selected="true"] { border-left-color: #1769E8; }
#AppointmentsPage QWidget[appointmentSelectionHost="true"][selected="true"] { border-left-color: $ds_accent; }
#AppointmentsPage QCheckBox[appointmentSelector="true"]::indicator {
width: 16px; height: 16px; background: #FFFFFF; border: 1px solid #C8D5E6; border-radius: 3px;
width: 16px; height: 16px; background: $ds_surface; border: 1px solid $ds_line_strong; border-radius: 3px;
}
#AppointmentsPage QCheckBox[appointmentSelector="true"]::indicator:checked { background: #1769E8; border-color: #1769E8; }
#AppointmentsPage QCheckBox[appointmentSelector="true"]::indicator:checked { background: $ds_accent; border-color: $ds_accent; }
#AppointmentsPage QWidget[appointmentInfoHost="true"],
#AppointmentsPage QWidget[appointmentImHost="true"] { background: transparent; }
#AppointmentsPage QLabel[tableAppointmentStatus="true"] {
min-height: 20px; max-height: 20px; padding: 0 6px; color: #1555B6;
background: #EAF2FF; border-radius: 4px; font-size: 13px;
min-height: 20px; max-height: 20px; padding: 0 6px; color: $ds_accent;
background: $ds_accent_soft; border-radius: $ds_radius_small; font-size: 13px;
}
#AppointmentsPage QLabel[tableAppointmentStatusKind="warning"] { color: #9C681F; background: #FFF3DD; }
#AppointmentsPage QLabel[tableAppointmentStatusKind="muted"] { color: #66758A; background: #EEF2F7; }
#AppointmentsPage QLabel[tableAppointmentMeta="true"] { color: #5D6B80; font-size: 13px; }
#AppointmentsPage QLabel[tableAppointmentStatusKind="warning"] { color: $ds_warning; background: $ds_warning_soft; }
#AppointmentsPage QLabel[tableAppointmentStatusKind="muted"] { color: $ds_muted; background: $ds_disabled_surface; }
#AppointmentsPage QLabel[tableAppointmentMeta="true"] { color: $ds_muted; font-size: 13px; }
#AppointmentsPage QPushButton[tableCancelAction="true"] {
min-height: 20px; max-height: 20px; padding: 0 5px; color: #B84652;
background: #FFF0F2; border: 0; border-radius: 4px; font-size: 13px;
min-height: 20px; max-height: 20px; padding: 0 5px; color: $ds_danger;
background: $ds_danger_soft; border: 0; border-radius: $ds_radius_small; font-size: 13px;
}
#AppointmentsPage QPushButton[appointmentImAction="true"] {
min-width: 62px; min-height: 32px; max-height: 32px; padding: 0 10px;
color: #1555B6; background: #EAF2FF; border-color: #C9DCF7; font-size: 13px;
color: $ds_accent; background: $ds_accent_soft; border-color: transparent; font-size: 13px;
}
#AppointmentsPage QPushButton[appointmentImAction="true"]:hover { color: #FFFFFF; background: #1769E8; }
#AppointmentsPage QPushButton[appointmentImAction="true"]:disabled { color: #8A97A9; background: #F3F6FB; border-color: #DFE7F2; }
#AppointmentsPage QWidget#Pager { background: #FFFFFF; border: 0; border-top: 1px solid #E1E9F4; }
#AppointmentsPage QWidget#Pager QLabel { color: #5D6B80; font-size: 13px; border: 0; }
#AppointmentsPage QPushButton[appointmentImAction="true"]:hover { color: $ds_accent_hover; border-color: $ds_line_strong; }
#AppointmentsPage QPushButton[appointmentImAction="true"]:focus { border-color: $ds_focus; }
#AppointmentsPage QPushButton[appointmentImAction="true"]:disabled { color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line; }
#AppointmentsPage QWidget#Pager { background: $ds_surface; border: 0; border-top: 1px solid $ds_line; }
#AppointmentsPage QWidget#Pager QLabel { color: $ds_muted; font-size: 13px; border: 0; }
#AppointmentsPage QWidget#Pager QPushButton {
min-width: 30px; max-width: 30px; min-height: 32px; max-height: 32px;
padding: 0; border: 1px solid #DBE5F2; background: #FFFFFF; color: #5D6B80; font-size: 13px;
padding: 0; border: 1px solid $ds_line; background: $ds_surface; color: $ds_muted; font-size: 13px;
}
#AppointmentsPage QWidget#Pager QPushButton[active="true"] { color: #FFFFFF; background: #1769E8; border-color: #1769E8; }
#AppointmentsPage QWidget#Pager QPushButton:disabled { color: #9AA6B7; background: #F7F9FC; }
#AppointmentsPage QWidget#Pager QPushButton[active="true"] { color: $ds_accent; background: $ds_accent_soft; border-color: transparent; font-weight: 600; }
#AppointmentsPage QWidget#Pager QPushButton:focus { border-color: $ds_focus; }
#AppointmentsPage QWidget#Pager QPushButton:disabled { color: $ds_disabled; background: $ds_surface_alt; }
"""
@@ -24,6 +24,7 @@ from PySide6.QtWidgets import (
QWidget,
)
from .design_system import clinical_stylesheet
from .widgets import display_text, first_value, run_async
# 后台 ChatNotifyLogic 写入的三种 type。
@@ -260,7 +261,7 @@ class ChatNotificationCenter(QWidget):
super().__init__(host)
self.repository = repository
self.setObjectName("ChatNotifyLayer")
self.setStyleSheet(CHAT_NOTIFICATION_QSS)
self.setStyleSheet(clinical_stylesheet(CHAT_NOTIFICATION_QSS))
self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, False)
self._cards: dict[str, _NotificationCard] = {}
self._pending: list[ChatNotification] = []
@@ -2,59 +2,67 @@
from string import Template
from .design_system import clinical_stylesheet
from .reception_style import body_family, heading_family
def consultations_stylesheet() -> str:
return Template(_QSS).substitute(body=body_family(), heading=heading_family())
return clinical_stylesheet(Template(_QSS).safe_substitute(body=body_family(), heading=heading_family()))
_QSS = """
#DiagnosisIndex, #DiagnosisIndexContent, #DiagnosisPageScroll {
background: #F3F7FD; color: #273244; border: 0;
background: $ds_canvas; color: $ds_text; border: 0;
}
#DiagnosisIndex QLabel, #DiagnosisIndex QPushButton, #DiagnosisIndex QToolButton,
#DiagnosisIndex QLineEdit, #DiagnosisIndex QComboBox, #DiagnosisIndex QDateEdit,
#DiagnosisIndex QSpinBox, #DiagnosisIndex QTableView {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#DiagnosisIndex QWidget#PageHeader QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: #202C3F;
font-family: "$heading"; font-size: 20px; font-weight: 600; color: $ds_heading;
}
#DiagnosisIndex QLabel[role="muted"], #DiagnosisIndex QLabel[role="breadcrumb"],
#DiagnosisIndex QLabel[role="breadcrumbCurrent"], #DiagnosisIndex QLabel[role="breadcrumbSeparator"],
#DiagnosisIndex QLabel[filterGroup="true"], #DiagnosisIndex QLabel[pagerMuted="true"] {
color: #5D6B80; font-size: 13px;
color: $ds_muted; font-size: 13px;
}
#DiagnosisIndex QFrame#DiagnosisFilterCard, #DiagnosisIndex QFrame#DiagnosisListCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#DiagnosisIndex QFrame#DiagnosisStatusCard, #DiagnosisIndex QFrame#DiagnosisQuickFilters,
#DiagnosisIndex QFrame#DiagnosisListToolbar { background: transparent; border: 0; }
#DiagnosisIndex QFrame#DiagnosisAdvancedFilters {
background: transparent; border: 0; border-top: 1px solid #E6EDF6; border-radius: 0;
background: transparent; border: 0; border-top: 1px solid $ds_line; border-radius: 0;
}
#DiagnosisIndex QPushButton {
min-height: 34px; padding: 0 13px; border: 1px solid #DBE5F2;
border-radius: 6px; background: #FFFFFF;
min-height: 34px; padding: 0 13px; border: 1px solid transparent;
border-radius: $ds_radius_control; background: $ds_surface_alt;
}
#DiagnosisIndex QPushButton:hover { color: #1555B6; background: #F2F7FF; border-color: #B6CDEE; }
#DiagnosisIndex QPushButton:pressed { background: #DCEAFF; }
#DiagnosisIndex QPushButton:focus { border-color: #75A5F0; }
#DiagnosisIndex QPushButton[variant="primary"] { color: #FFFFFF; background: #1769E8; border-color: #1769E8; }
#DiagnosisIndex QPushButton[variant="primary"]:hover { background: #155BCC; }
#DiagnosisIndex QPushButton[consultationTool="true"] { color: #1555B6; border-color: #C2D5EF; }
#DiagnosisIndex QPushButton[consultationDanger="true"] { color: #BE4B58; border-color: #EBCDD2; }
#DiagnosisIndex QPushButton:disabled, #DiagnosisIndex QPushButton[consultationDanger="true"]:disabled {
color: #8A97A9; background: #F6F8FC; border-color: #E2E9F2;
#DiagnosisIndex QPushButton:hover { color: $ds_accent; background: $ds_surface_alt; border-color: $ds_line_strong; }
#DiagnosisIndex QPushButton:pressed { background: $ds_accent_soft; }
#DiagnosisIndex QPushButton:focus { border-color: $ds_focus; }
#DiagnosisIndex QPushButton[variant="primary"] { color: $ds_surface; background: $ds_accent; border-color: $ds_accent; }
#DiagnosisIndex QPushButton[variant="primary"]:hover { background: $ds_accent_hover; }
#DiagnosisIndex QPushButton[variant="primary"]:pressed { background: $ds_accent_pressed; }
#DiagnosisIndex QPushButton[variant="primary"]:focus { border-color: $ds_focus; }
#DiagnosisIndex QPushButton[consultationTool="true"] { color: $ds_text; border-color: transparent; }
#DiagnosisIndex QPushButton[consultationTool="true"]:hover { color: $ds_accent; background: $ds_accent_soft; }
#DiagnosisIndex QPushButton[consultationDanger="true"] { color: $ds_danger; background: $ds_danger_soft; border-color: transparent; }
#DiagnosisIndex QPushButton[consultationDanger="true"]:hover { border-color: $ds_danger; }
#DiagnosisIndex QPushButton[consultationTool="true"]:focus,
#DiagnosisIndex QPushButton[consultationDanger="true"]:focus { border-color: $ds_focus; }
#DiagnosisIndex QPushButton:disabled, #DiagnosisIndex QPushButton[consultationDanger="true"]:disabled,
#DiagnosisIndex QPushButton[variant="primary"]:disabled, #DiagnosisIndex QPushButton[consultationTool="true"]:disabled {
color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line;
}
#DiagnosisIndex QLineEdit, #DiagnosisIndex QComboBox, #DiagnosisIndex QDateEdit, #DiagnosisIndex QSpinBox {
min-height: 32px; padding: 0 10px; color: #273244; background: #FFFFFF;
border: 1px solid #DBE5F2; border-radius: 6px; selection-background-color: #DCEAFF;
min-height: 32px; padding: 0 10px; color: $ds_text; background: $ds_surface;
border: 1px solid $ds_line; border-radius: $ds_radius_control; selection-background-color: $ds_accent_soft;
font-size: 13px;
}
#DiagnosisIndex QLineEdit:focus, #DiagnosisIndex QComboBox:focus,
#DiagnosisIndex QDateEdit:focus, #DiagnosisIndex QSpinBox:focus { border-color: #75A5F0; }
#DiagnosisIndex QDateEdit:focus, #DiagnosisIndex QSpinBox:focus { border-color: $ds_focus; }
#DiagnosisIndex QLineEdit QToolButton {
min-width: 0; min-height: 0; padding: 0; border: 0; background: transparent;
}
@@ -62,70 +70,77 @@ _QSS = """
width: 22px; border: 0; background: transparent;
}
#DiagnosisIndex QComboBox QAbstractItemView {
color: #273244; background: #FFFFFF; border: 1px solid #DBE5F2;
selection-background-color: #EAF2FF; selection-color: #1555B6; outline: 0;
color: $ds_text; background: $ds_surface; border: 1px solid $ds_line;
selection-background-color: $ds_accent_soft; selection-color: $ds_accent; outline: 0;
}
#DiagnosisIndex QWidget#DiagnosisStatusSearch QLineEdit,
#DiagnosisIndex QWidget#DiagnosisStatusSearch QPushButton { min-height: 39px; max-height: 39px; }
#DiagnosisIndex QToolButton { min-width: 0; min-height: 0; border: 0; padding: 0; background: transparent; }
#DiagnosisIndex QToolButton[diagnosisChip="true"] {
min-height: 32px; max-height: 32px; padding: 0 14px; border: 1px solid transparent;
border-radius: 5px; color: #5D6B80; background: transparent; font-size: 13px;
border-radius: $ds_radius_control; color: $ds_muted; background: transparent; font-size: 13px;
}
#DiagnosisIndex QToolButton[diagnosisChip="true"]:hover { background: #F2F7FF; color: #1555B6; }
#DiagnosisIndex QToolButton[diagnosisChip="true"]:checked { background: #1769E8; color: #FFFFFF; }
#DiagnosisIndex QToolButton[dateChoice="true"] { padding: 0 17px; border-color: #E1E9F4; }
#DiagnosisIndex QToolButton[dateChoice="true"]:checked { border-color: #1769E8; }
#DiagnosisIndex QToolButton[diagnosisChip="true"]:hover { background: $ds_surface_alt; color: $ds_accent; }
#DiagnosisIndex QToolButton[diagnosisChip="true"]:checked { background: $ds_accent_soft; color: $ds_accent; font-weight: 600; }
#DiagnosisIndex QToolButton[dateChoice="true"] { padding: 0 17px; background: $ds_surface_alt; border-color: transparent; }
#DiagnosisIndex QToolButton[dateChoice="true"]:checked { background: $ds_accent_soft; border-color: transparent; }
#DiagnosisIndex QToolButton[diagnosisChip="true"]:focus { border-color: $ds_focus; }
#DiagnosisIndex QToolButton[statusTab="true"] {
min-height: 44px; max-height: 44px; padding: 0 20px; border: 0;
border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
}
#DiagnosisIndex QToolButton[statusTab="true"]:checked {
color: #1769E8; background: transparent; border-bottom-color: #1769E8;
color: $ds_accent; background: transparent; border-bottom-color: $ds_accent;
}
#DiagnosisIndex QToolButton[statusTab="true"]:focus { background: $ds_accent_soft; }
#DiagnosisIndex QToolButton#DiagnosisMoreFilter {
min-height: 32px; padding: 0 6px; color: #5D6B80; font-size: 13px;
min-height: 32px; padding: 0 6px; color: $ds_muted; font-size: 13px;
}
#DiagnosisIndex QToolButton#DiagnosisMoreFilter:hover { color: #1769E8; background: #F2F7FF; }
#DiagnosisIndex QFrame#DiagnosisFilterDivider { min-width: 1px; max-width: 1px; min-height: 20px; background: #E1E9F4; border: 0; }
#DiagnosisIndex QToolButton#DiagnosisMoreFilter:hover { color: $ds_accent; background: $ds_surface_alt; }
#DiagnosisIndex QFrame#DiagnosisFilterDivider { min-width: 1px; max-width: 1px; min-height: 20px; background: $ds_line; border: 0; }
#DiagnosisIndex QFrame#DiagnosisDateRange {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 6px;
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_control;
}
#DiagnosisIndex QDateEdit[diagnosisRangePart="true"] { min-height: 30px; padding: 0 4px; border: 0; }
#DiagnosisIndex QTableView {
background: #FFFFFF; alternate-background-color: #FFFFFF; border: 0; border-radius: 0;
gridline-color: #E6EDF6; selection-background-color: #EAF2FF; selection-color: #273244;
background: $ds_surface; alternate-background-color: $ds_surface; border: 0; border-radius: 0;
gridline-color: $ds_line; selection-background-color: $ds_accent_soft; selection-color: $ds_text;
}
#DiagnosisIndex QTableView QHeaderView::section {
min-height: 41px; padding: 0; background: #F5F8FD; color: #5D6B80;
border: 0; border-bottom: 1px solid #E1E9F4;
min-height: 41px; padding: 0; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#DiagnosisIndex QToolButton[rowLink], #DiagnosisIndex QToolButton[appointmentCancel="true"] {
color: #1769E8; min-height: 26px; padding: 0 4px; border: 0; background: transparent; font-size: 13px;
color: $ds_accent; min-height: 26px; padding: 0 4px; border: 1px solid transparent;
border-radius: $ds_radius_small; background: transparent; font-size: 13px;
}
#DiagnosisIndex QToolButton[appointmentCancel="true"] { color: #BE4B58; }
#DiagnosisIndex QToolButton[rowLink]:hover { color: #1555B6; background: #DCEAFF; border-radius: 4px; }
#DiagnosisIndex QToolButton[appointmentCancel="true"] { color: $ds_danger; }
#DiagnosisIndex QToolButton[appointmentCancel="true"]:hover { background: $ds_danger_soft; }
#DiagnosisIndex QToolButton[rowLink]:hover { color: $ds_accent; background: $ds_accent_soft; border-radius: $ds_radius_small; }
#DiagnosisIndex QToolButton[rowLink]:focus,
#DiagnosisIndex QToolButton[appointmentCancel="true"]:focus { border-color: $ds_focus; }
#DiagnosisIndex QToolButton[rowLink="muted"], #DiagnosisIndex QLabel[fixedMuted="true"] {
color: #5D6B80; font-size: 13px;
color: $ds_muted; font-size: 13px;
}
#DiagnosisIndex QToolButton#DiagnosisRowMore { padding-right: 18px; }
#DiagnosisIndex QWidget#DiagnosisFixedCell { background: transparent; }
#DiagnosisIndex QLabel#DiagnosisTableEmpty { color: #5D6B80; background: #FFFFFF; }
#DiagnosisIndex QLabel#DiagnosisTableEmpty[stateKind="error"] { color: #BE4B58; }
#DiagnosisIndex QTableView#DiagnosisFixedTable { border-left: 1px solid #E1E9F4; }
#DiagnosisIndex QWidget#DiagnosisPager { background: #FFFFFF; border-top: 1px solid #E6EDF6; }
#DiagnosisIndex QLabel#DiagnosisTableEmpty { color: $ds_muted; background: $ds_surface; }
#DiagnosisIndex QLabel#DiagnosisTableEmpty[stateKind="error"] { color: $ds_danger; }
#DiagnosisIndex QTableView#DiagnosisFixedTable { border-left: 1px solid $ds_line; }
#DiagnosisIndex QWidget#DiagnosisPager { background: $ds_surface; border-top: 1px solid $ds_line; }
#DiagnosisIndex QToolButton[pagerButton="true"] {
min-width: 30px; max-width: 30px; min-height: 30px; max-height: 30px;
border: 1px solid #DBE5F2; border-radius: 5px; color: #5D6B80; background: #FFFFFF;
border: 1px solid $ds_line; border-radius: $ds_radius_control; color: $ds_muted; background: $ds_surface;
}
#DiagnosisIndex QToolButton[pagerButton="true"][active="true"] { color: #FFFFFF; background: #1769E8; border-color: #1769E8; }
#DiagnosisIndex QToolButton[pagerButton="true"]:disabled { color: #A4B0C0; background: #F6F8FC; }
#DiagnosisIndex QToolButton[pagerButton="true"][active="true"] { color: $ds_accent; background: $ds_accent_soft; border-color: transparent; font-weight: 600; }
#DiagnosisIndex QToolButton[pagerButton="true"]:focus { border-color: $ds_focus; }
#DiagnosisIndex QToolButton[pagerButton="true"]:disabled { color: $ds_disabled; background: $ds_disabled_surface; }
#DiagnosisIndex QComboBox#DiagnosisPageSize { min-width: 95px; min-height: 30px; }
#DiagnosisIndex QSpinBox#DiagnosisPageJumper { min-height: 30px; padding: 0 8px; }
#DiagnosisIndex QScrollBar:vertical { background: #F4F7FC; width: 7px; margin: 0; }
#DiagnosisIndex QScrollBar:horizontal { background: #F4F7FC; height: 7px; margin: 0; }
#DiagnosisIndex QScrollBar::handle { background: #C8D5E6; border-radius: 3px; min-width: 24px; min-height: 24px; }
#DiagnosisIndex QScrollBar:vertical { background: $ds_canvas; width: 7px; margin: 0; }
#DiagnosisIndex QScrollBar:horizontal { background: $ds_canvas; height: 7px; margin: 0; }
#DiagnosisIndex QScrollBar::handle { background: $ds_line_strong; border-radius: 3px; min-width: 24px; min-height: 24px; }
#DiagnosisIndex QScrollBar::add-line, #DiagnosisIndex QScrollBar::sub-line { width: 0; height: 0; }
#DiagnosisIndex QScrollBar::add-page, #DiagnosisIndex QScrollBar::sub-page { background: transparent; }
"""
@@ -0,0 +1,76 @@
"""Clinical desktop design tokens, shared by native pages and dialog chrome.
Keep data-series colours and video pixels outside this palette. Existing scoped
QSS can adopt the system without changing selectors, layout or permissions.
New rules should use the named ``$ds_*`` tokens rather than legacy colours.
"""
from __future__ import annotations
import re
from string import Template
PALETTE = {
"canvas": "#F5F7FA",
"surface": "#FFFFFF",
"surface_alt": "#F7F9FC",
"sidebar": "#F0F3F8",
"line": "#E6EAF0",
"line_strong": "#D4DCE8",
"heading": "#223047",
"text": "#344258",
"muted": "#647287",
"disabled": "#8B96A6",
"disabled_surface": "#F0F2F5",
"accent": "#4267B2",
"accent_hover": "#355995",
"accent_pressed": "#2C4C82",
"accent_soft": "#EAF0FB",
"focus": "#6D8CCB",
"success": "#287B65",
"success_soft": "#EDF7F2",
"warning": "#96601D",
"warning_soft": "#FBF4E8",
"danger": "#B54A59",
"danger_soft": "#FCF0F2",
}
RADII = {"small": 6, "control": 10, "panel": 16, "window": 20}
SPACING = {"small": 8, "control": 12, "group": 16, "section": 24}
TOKENS = {f"ds_{name}": value for name, value in PALETTE.items()}
TOKENS.update({f"ds_radius_{name}": f"{value}px" for name, value in RADII.items()})
TOKENS.update({f"ds_space_{name}": f"{value}px" for name, value in SPACING.items()})
# Explicit migration of the two existing native palettes. This adapter only
# touches six-digit colour literals; selectors and metrics stay page-owned.
_LEGACY_ROLES = {
"accent": ("1769E8", "4F63D9", "5761F4", "5267DF"),
"accent_hover": ("155BCC", "1555B6", "4156C4", "4356C4", "4055CA"),
"accent_pressed": ("124EA9", "354BB4"),
"accent_soft": ("EAF2FF", "EEF1FA", "EEF0FF", "F0F2FF", "DCEAFF", "EDF0FC"),
"focus": ("75A5F0", "8B9AD9"),
"canvas": ("F3F7FD", "F4F6FA", "F6F6F6"),
"surface_alt": ("F7F7F7", "F7FAFE", "F5F8FD", "F7F9FE", "F2F7FF"),
"sidebar": ("EDF4FF",),
"line": ("DBE5F2", "EDEDEE", "E5ECF6", "E6EDF6", "E7EDF7", "EDF0F5", "E7EBF2", "E6EAF5"),
"line_strong": ("E4E4E5", "C8D5E6", "C9DCF7", "ADC8F0", "B6CDEE"),
"heading": ("1A1C1F", "202C3F", "111F46"),
"text": ("273244", "263551", "24334A", "233149", "3F4E75"),
"muted": ("606163", "6A6B6D", "5D6B80", "7886AA", "708097"),
"disabled": ("8E8F90", "8A97A9", "9AA6B7"),
"disabled_surface": ("F2F2F2", "F0F0F0"),
"success_soft": ("EEF7F3", "EAF9F3"),
"warning": ("A9691D", "9C681F"),
"warning_soft": ("FCF5E9", "FFF5E6", "FFF6E7"),
"danger": ("BE4B58", "B84652"),
"danger_soft": ("FFF0F2", "FFF1F3"),
}
_LEGACY = {colour.lower(): PALETTE[role] for role, colours in _LEGACY_ROLES.items() for colour in colours}
_HEX = re.compile(r"#([0-9a-fA-F]{6})(?![0-9a-fA-F])")
def clinical_stylesheet(source: str) -> str:
"""Resolve clinical tokens and migrate known legacy light-theme colours."""
resolved = Template(source).safe_substitute(TOKENS)
return _HEX.sub(lambda match: _LEGACY.get(match[1].lower(), match[0]), resolved)
@@ -64,6 +64,7 @@ from PySide6.QtWidgets import (
)
from .chat_items import ChatItem, parse_chat_item
from .design_system import PALETTE, clinical_stylesheet
from .diagnosis_editors import FlowLayout
from .diagnosis_media import shared_image_manager
from .diagnosis_terms import FIELD_DICTIONARIES, format_timestamp, shared_terms
@@ -80,10 +81,7 @@ QFrame#DiagnosisDrawer {
border-left: 1px solid #EDEDEE;
}
QFrame#DiagnosisDrawerHeader {
background-color: qlineargradient(
x1:0, y1:0, x2:0, y2:1,
stop:0 #FFFFFF, stop:1 #F7F7F7
);
background-color: #FFFFFF;
border-bottom: 1px solid #EDEDEE;
}
QFrame#DiagnosisDrawerFooter {
@@ -105,7 +103,7 @@ QLabel#DiagnosisDrawerModeBadge,
QLabel#DiagnosisReadonlyStatus,
QLabel[diagnosisTag="true"] {
padding: 4px 9px;
border-radius: 9px;
border-radius: $ds_radius_small;
font-size: 12px;
font-weight: 500;
}
@@ -159,8 +157,8 @@ QDialog QPushButton:pressed {
border-color: #354BB4;
}
QDialog QPushButton:disabled {
color: #E4E4E5;
background-color: #FFFFFF;
color: $ds_disabled;
background-color: $ds_disabled_surface;
border-color: #EDEDEE;
}
QDialog QPushButton[variant="primary"] {
@@ -176,9 +174,9 @@ QDialog QPushButton[variant="primary"]:focus {
border-color: #4156C4;
}
QDialog QPushButton[variant="primary"]:disabled {
color: #FFFFFF;
background-color: #F0F0F0;
border-color: #F0F0F0;
color: $ds_disabled;
background-color: $ds_disabled_surface;
border-color: $ds_line;
}
QDialog QPushButton[variant="secondary"] {
color: #4F63D9;
@@ -267,9 +265,9 @@ QDialog#DiagnosisDialogRoot QPushButton#DiagnosisSaveButton:focus {
border-color: #4156C4;
}
QDialog#DiagnosisDialogRoot QPushButton#DiagnosisSaveButton:disabled {
color: #FFFFFF;
background-color: #F0F0F0;
border-color: #F0F0F0;
color: $ds_disabled;
background-color: $ds_disabled_surface;
border-color: $ds_line;
}
QDialog#DiagnosisDialogRoot QPushButton#DiagnosisFooterCloseButton {
color: #606163;
@@ -383,10 +381,10 @@ QFrame#DiagnosisFormHost {
QFrame[diagnosisSection="true"] {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 12px;
border-radius: 16px;
}
QLabel[diagnosisFieldLabel="true"] {
color: #1A1C1F;
color: $ds_muted;
font-size: 12px;
font-weight: 500;
}
@@ -426,7 +424,7 @@ QDoubleSpinBox[diagnosisField="true"]:focus,
QSpinBox[diagnosisField="true"]:focus,
QTimeEdit[diagnosisField="true"]:focus {
border: 1px solid #8B9AD9;
background-color: #F7F7F7;
background-color: $ds_surface;
}
QLineEdit[diagnosisField="true"][invalid="true"],
QComboBox[diagnosisField="true"][invalid="true"],
@@ -452,8 +450,8 @@ QLabel#DiagnosisSectionTitle {
background-color: transparent;
border: 0;
padding: 0;
font-size: 13px;
font-weight: 500;
font-size: 14px;
font-weight: 600;
letter-spacing: 0.02em;
}
QFrame#DiagnosisSectionAccent {
@@ -470,9 +468,9 @@ QFrame#DiagnosisReadonlyPage {
background-color: #F6F6F6;
}
QFrame#DiagnosisReadonlyHero {
background-color: #F7F7F7;
border: 1px solid #F0F0F0;
border-radius: 12px;
background-color: $ds_surface;
border: 1px solid $ds_line;
border-radius: $ds_radius_panel;
}
QLabel#DiagnosisReadonlyTitle {
color: #1A1C1F;
@@ -542,7 +540,7 @@ QFrame#DiagnosisReadonlyCaseCard,
QFrame[diagnosisReadonlyCard="true"] {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 14px;
border-radius: 16px;
}
QLabel#DiagnosisReadonlyCardTitle {
color: #1A1C1F;
@@ -771,7 +769,7 @@ QWidget[diagnosisChoiceHost="true"] QPushButton {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 999px;
border-radius: 10px;
font-size: 12px;
}
QWidget[diagnosisChoiceHost="true"] QPushButton:hover,
@@ -1068,6 +1066,7 @@ _DIAGNOSIS_BLUE_REPLACEMENTS = (
)
for _source_color, _theme_color in _DIAGNOSIS_BLUE_REPLACEMENTS:
DIAGNOSIS_QSS = DIAGNOSIS_QSS.replace(_source_color, _theme_color)
DIAGNOSIS_QSS = clinical_stylesheet(DIAGNOSIS_QSS)
def _text(value: Any, default: str = "—") -> str:
@@ -1147,12 +1146,19 @@ class DiagnosisSwitch(QAbstractButton):
track = QRectF(1, 3, self.width() - 2, self.height() - 6)
checked = self.isChecked()
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#4F63D9" if checked else "#E4E4E5"))
painter.setBrush(QColor(PALETTE["accent"] if checked else PALETTE["line_strong"]))
if not self.isEnabled():
painter.setOpacity(0.6)
painter.drawRoundedRect(track, track.height() / 2, track.height() / 2)
diameter = track.height() - 4
x = track.right() - diameter - 2 if checked else track.left() + 2
painter.setBrush(QColor("#FFFFFF"))
painter.drawEllipse(QRectF(x, track.top() + 2, diameter, diameter))
if self.hasFocus():
painter.setOpacity(1)
painter.setPen(QPen(QColor(PALETTE["focus"]), 1))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.drawRoundedRect(QRectF(self.rect()).adjusted(0.5, 0.5, -0.5, -0.5), 11, 11)
painter.end()
@@ -1190,13 +1196,19 @@ class SaveStateButton(QPushButton):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
enabled = self.isEnabled()
idle_color = PALETTE["accent_pressed"] if self.isDown() else PALETTE["accent"]
color = {
"success": "#287B65",
"error": "#BE4B58",
}.get(self._state, "#4F63D9" if enabled else "#8E8F90")
"success": PALETTE["success"],
"error": PALETTE["danger"],
"loading": PALETTE["accent"],
}.get(self._state, idle_color if enabled else PALETTE["disabled_surface"])
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor(color))
painter.drawRoundedRect(QRectF(self.rect()).adjusted(1, 1, -1, -1), 10, 10)
if self.hasFocus():
painter.setPen(QPen(QColor(PALETTE["focus"]), 1))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.drawRoundedRect(QRectF(self.rect()).adjusted(0.5, 0.5, -0.5, -0.5), 10, 10)
label = {
"loading": "正在保存",
"success": "保存成功",
@@ -1220,7 +1232,9 @@ class SaveStateButton(QPushButton):
else:
painter.drawLine(x + 3, center_y - 5, x + 12, center_y + 5)
painter.drawLine(x + 12, center_y - 5, x + 3, center_y + 5)
painter.setPen(QColor("#FFFFFF"))
painter.setPen(QColor(
PALETTE["disabled"] if not enabled and self._state == "idle" else PALETTE["surface"]
))
painter.drawText(
QRect(x + icon_width, 0, metrics.horizontalAdvance(label), self.height()),
Qt.AlignmentFlag.AlignCenter,
@@ -1815,10 +1829,10 @@ class MessageStrip(QFrame):
self.glyph = QLabel("i")
self.glyph.setFixedWidth(18)
self.glyph.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.glyph.setStyleSheet("font-weight:700; color:#4F63D9;")
self.glyph.setStyleSheet(clinical_stylesheet("font-weight:700; color:$ds_accent;"))
self.label = QLabel()
self.label.setWordWrap(True)
self.label.setStyleSheet("color:#1A1C1F; font-size:13px;")
self.label.setStyleSheet(clinical_stylesheet("color:$ds_text; font-size:13px;"))
layout.addWidget(self.glyph)
layout.addWidget(self.label, 1)
self.action_button = QPushButton()
@@ -1894,7 +1908,7 @@ class LoadingOverlay(QFrame):
layout.setSpacing(8)
self.glyph = _LoadingSpinner(self)
label = QLabel(text)
label.setStyleSheet("color:#606163; font-size:13px;")
label.setStyleSheet(clinical_stylesheet("color:$ds_muted; font-size:13px;"))
layout.addWidget(self.glyph)
layout.addWidget(label)
self.hide()
@@ -1985,15 +1999,15 @@ class RecordTable(QTableWidget):
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
)
if column_index in danger_columns:
item.setForeground(QColor("#BE4B58"))
item.setForeground(QColor(PALETTE["danger"]))
kind = semantic.get(column_index)
if kind:
palette = {
"success": ("#287B65", "#EAF9F3"),
"warning": ("#A9691D", "#FFF5E6"),
"danger": ("#BE4B58", "#FFF1F3"),
"info": ("#4F63D9", "#EEF1FA"),
"neutral": ("#6A6B6D", "#F7F7F7"),
"success": (PALETTE["success"], PALETTE["success_soft"]),
"warning": (PALETTE["warning"], PALETTE["warning_soft"]),
"danger": (PALETTE["danger"], PALETTE["danger_soft"]),
"info": (PALETTE["accent"], PALETTE["accent_soft"]),
"neutral": (PALETTE["muted"], PALETTE["surface_alt"]),
}
foreground, background = palette.get(kind, palette["neutral"])
item.setForeground(QColor(foreground))
@@ -2033,20 +2047,20 @@ class BloodTrendChart(QWidget):
plot = self.rect().adjusted(48, 24, -22, -38)
values = [value for value in (*self._fasting, *self._postprandial) if value is not None]
if not values or plot.width() <= 0 or plot.height() <= 0:
painter.setPen(QColor("#606163"))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(self.rect(), Qt.AlignmentFlag.AlignCenter, "当前时间范围暂无血糖数据")
painter.end()
return
upper = max(12.0, max(values) * 1.15)
painter.setPen(QPen(QColor("#EDEDEE"), 1))
painter.setPen(QPen(QColor(PALETTE["line"]), 1))
for step in range(5):
y = plot.bottom() - round(plot.height() * step / 4)
painter.drawLine(plot.left(), y, plot.right(), y)
painter.setPen(QColor("#606163"))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(
4, y - 8, 40, 16, Qt.AlignmentFlag.AlignRight, f"{upper * step / 4:.0f}"
)
painter.setPen(QPen(QColor("#EDEDEE"), 1))
painter.setPen(QPen(QColor(PALETTE["line"]), 1))
count = max(1, len(self._dates) - 1)
def point(index: int, value: float) -> QPointF:
@@ -2076,7 +2090,7 @@ class BloodTrendChart(QWidget):
painter.setPen(QColor("#A9691D"))
painter.drawText(plot.left() + 100, 4, 110, 18, Qt.AlignmentFlag.AlignLeft, "● 餐后血糖")
if self._dates:
painter.setPen(QColor("#606163"))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(
plot.left(),
plot.bottom() + 8,
@@ -2279,7 +2293,7 @@ class DailyRecordPanel(QFrame):
self.todo_table.setMinimumHeight(180)
todo_layout.addWidget(self.todo_table)
self.todo_summary = QLabel("共 0 条")
self.todo_summary.setStyleSheet("color:#606163; font-size:13px;")
self.todo_summary.setStyleSheet(clinical_stylesheet("color:$ds_muted; font-size:13px;"))
todo_layout.addWidget(self.todo_summary, 0, Qt.AlignmentFlag.AlignRight)
root.addWidget(todo_card)
self.clear()
@@ -2437,8 +2451,8 @@ class DailyRecordPanel(QFrame):
for row_index, (metric, label) in enumerate(self.METRICS):
label_item = QTableWidgetItem(label)
label_item.setFont(label_font)
label_item.setForeground(QColor("#606163"))
label_item.setBackground(QColor("#F7F7F7"))
label_item.setForeground(QColor(PALETTE["muted"]))
label_item.setBackground(QColor(PALETTE["surface_alt"]))
self.matrix.setItem(row_index, 0, label_item)
for date_index, date in enumerate(dates, 1):
b = blood.get(date)
@@ -2491,11 +2505,11 @@ class DailyRecordPanel(QFrame):
item = QTableWidgetItem(value)
item.setTextAlignment(Qt.AlignmentFlag.AlignCenter)
if high:
item.setForeground(QColor("#BE4B58"))
item.setBackground(QColor("#FFF1F3"))
item.setForeground(QColor(PALETTE["danger"]))
item.setBackground(QColor(PALETTE["danger_soft"]))
elif value.endswith("· 自录"):
item.setForeground(QColor("#1A1C1F"))
item.setBackground(QColor("#F7F7F7"))
item.setForeground(QColor(PALETTE["text"]))
item.setBackground(QColor(PALETTE["surface_alt"]))
edit_kind = ""
edit_source: Any = None
if metric in {"fasting", "postprandial", "other", "bp", "western", "insulin"}:
@@ -3022,7 +3036,7 @@ class ChatPanel(QWidget):
toolbar_layout.setContentsMargins(0, 0, 0, 0)
toolbar_layout.setSpacing(8)
archive = QLabel("仅展示服务端已归档消息(only_archived=1)")
archive.setStyleSheet("color:#606163;font-size:12px;")
archive.setStyleSheet(clinical_stylesheet("color:$ds_muted;font-size:12px;"))
toolbar_layout.addWidget(archive)
toolbar_layout.addStretch(1)
self.sync_button = QPushButton("同步最新(后台异步)")
@@ -3298,7 +3312,7 @@ class CaseGrid(QFrame):
if group_index:
divider = QFrame()
divider.setFrameShape(QFrame.Shape.HLine)
divider.setStyleSheet("border:0; border-top:1px dashed #E4E4E5;")
divider.setStyleSheet(clinical_stylesheet("border:0; border-top:1px solid $ds_line;"))
self.root.addWidget(divider)
group_title = QLabel(f"● {group_name}")
group_title.setProperty("diagnosisCaseGroup", True)
@@ -3456,11 +3470,11 @@ def readonly_card(title: str, object_name: str, body: QWidget) -> QFrame:
def set_tag_item(item: QTableWidgetItem, kind: str) -> None:
palette = {
"success": ("#287B65", "#EAF9F3"),
"warning": ("#A9691D", "#FFF5E6"),
"danger": ("#BE4B58", "#FFF1F3"),
"info": ("#4F63D9", "#EEF1FA"),
"neutral": ("#6A6B6D", "#F7F7F7"),
"success": (PALETTE["success"], PALETTE["success_soft"]),
"warning": (PALETTE["warning"], PALETTE["warning_soft"]),
"danger": (PALETTE["danger"], PALETTE["danger_soft"]),
"info": (PALETTE["accent"], PALETTE["accent_soft"]),
"neutral": (PALETTE["muted"], PALETTE["surface_alt"]),
}
foreground, background = palette.get(kind, palette["neutral"])
item.setForeground(QColor(foreground))
@@ -67,21 +67,22 @@ from ..core.appointment_modes import (
can_appointment_video,
)
from . import icons
from .design_system import PALETTE, clinical_stylesheet
from .reception_style import TECH_BLUE, body_family, heading_family
from .widgets import display_text, first_value, gender_text, get_value
PRIMARY = QColor("#4F63D9")
TEXT = QColor("#1A1C1F")
SECONDARY = QColor("#606163")
PLACEHOLDER = QColor("#8E8F90")
PRIMARY = QColor(PALETTE["accent"])
TEXT = QColor(PALETTE["text"])
SECONDARY = QColor(PALETTE["muted"])
PLACEHOLDER = QColor(PALETTE["disabled"])
_INVALID_INDEX = QModelIndex()
# The last two columns form the compact frozen pane. Video status and ending
# time occupy separate lines; actions keep two inline links plus 更多, with
# the remaining actions in its menu so clinical columns retain more space.
_TABLE_COLUMN_WIDTHS = (48, 70, 60, 100, 175, 88, 120, 100, 72, 110, 96, 160)
_BLUE_COLUMN_WIDTHS = (48, 70, 82, 102, 244, 90, 84, 90, 88, 122, 92, 158)
_BLUE_WARNING = QColor("#A9691D")
_BLUE_DANGER = QColor("#BE4B58")
_BLUE_WARNING = QColor(PALETTE["warning"])
_BLUE_DANGER = QColor(PALETTE["danger"])
def _blue_font(pixels: int = 13, *, medium: bool = False) -> QFont:
@@ -248,14 +249,14 @@ class _DiagnosisActionMenu(QMenu):
return
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
painter.fillRect(rect, QColor("#FFFFFF"))
painter.fillRect(rect, QColor(PALETTE["surface"]))
item_rect = rect
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#F7F7F7") if self.activeAction() is action else QColor("#FFFFFF"))
painter.setBrush(QColor(PALETTE["surface_alt"]) if self.activeAction() is action else QColor(PALETTE["surface"]))
painter.drawRoundedRect(item_rect, 3, 3)
icon_rect = QRect(item_rect.left() + 8, item_rect.center().y() - 9, 18, 18)
action.icon().paint(painter, icon_rect)
painter.setPen(QColor("#BE4B58" if action.isEnabled() else "#8E8F90"))
painter.setPen(QColor(PALETTE["danger"] if action.isEnabled() else PALETTE["disabled"]))
painter.drawText(
item_rect.adjusted(34, 0, -10, 0),
Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft,
@@ -823,6 +824,8 @@ class DiagnosisTableModel(QAbstractTableModel):
default="",
)
return f"最近渠道:{channel}" if channel else ""
if column == 6:
return DiagnosisTableModel._display(row, column)
if column == 7:
return display_text(first_value(row, "assistant_name"), "")
if column == 9:
@@ -849,7 +852,7 @@ class DiagnosisHeader(QHeaderView):
def paintSection(self, painter: QPainter, rect: QRect, logical_index: int) -> None: # noqa: N802
if self.tech_blue:
painter.save()
painter.fillRect(rect, QColor("#F5F8FD"))
painter.fillRect(rect, QColor(PALETTE["surface_alt"]))
painter.setPen(QPen(QColor(TECH_BLUE["line"]), 1))
painter.drawLine(rect.bottomLeft(), rect.bottomRight())
painter.setFont(_blue_font())
@@ -870,7 +873,7 @@ class DiagnosisHeader(QHeaderView):
painter.save()
painter.setPen(Qt.PenStyle.NoPen)
primary = QColor(TECH_BLUE["accent"]) if self.tech_blue else PRIMARY
secondary = QColor(TECH_BLUE["muted"]) if self.tech_blue else QColor("#606163")
secondary = QColor(TECH_BLUE["muted"]) if self.tech_blue else QColor(PALETTE["muted"])
painter.setBrush(primary if direction == "asc" else secondary)
painter.drawPolygon(
QPolygon(
@@ -953,7 +956,7 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
painter,
option.rect,
"已确认" if _confirmed(record) else "未确认",
QColor("#287B65") if _confirmed(record) else QColor("#A9691D"),
QColor(PALETTE["success"]) if _confirmed(record) else QColor(PALETTE["warning"]),
)
elif index.column() == 6:
self._paint_followup(painter, option.rect, record)
@@ -1023,16 +1026,16 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
) -> None:
hovered = model.hover_row == row
base = (
QColor("#EEF1FA")
QColor(PALETTE["accent_soft"])
if selected
else QColor("#F7F7F7" if hovered else "#F7F7F7" if row % 2 else "#FFFFFF")
else QColor(PALETTE["surface_alt"] if hovered or row % 2 else PALETTE["surface"])
)
special = not _confirmed(record) or not _has_appointment(record)
painter.fillRect(rect, base)
if special and column == 0:
stripe = QColor("#A9691D") if not _confirmed(record) else QColor("#4F63D9")
stripe = QColor(PALETTE["warning"]) if not _confirmed(record) else QColor(PALETTE["accent"])
painter.fillRect(QRect(rect.left(), rect.top(), 3, rect.height()), stripe)
painter.setPen(QPen(QColor("#EDEDEE"), 1))
painter.setPen(QPen(QColor(PALETTE["line"]), 1))
painter.drawLine(QLine(rect.bottomLeft(), rect.bottomRight()))
@staticmethod
@@ -1070,8 +1073,8 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
painter,
QRect(left, content.center().y() - 10, 31, 20),
"NEW",
QColor("#BE4B58"),
QColor("#FFFFFF"),
QColor(PALETTE["danger"]),
QColor(PALETTE["surface"]),
10,
)
@@ -1081,17 +1084,17 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
self._draw_text(painter, content, "未挂号", PLACEHOLDER, 13)
return
rows = _appointments(record)
painter.setPen(QPen(QColor("#EDEDEE"), 1))
painter.setBrush(QColor("#FFFFFF"))
painter.setPen(QPen(QColor(PALETTE["line"]), 1))
painter.setBrush(QColor(PALETTE["surface"]))
painter.drawRoundedRect(content, 6, 6)
y = content.top() + 4
for position, appointment in enumerate(rows or [{}]):
status = _as_int(first_value(appointment, "status", "appointment_status"), -1)
label, fg, bg = {
1: ("已预约", QColor("#4F63D9"), QColor("#EEF1FA")),
3: ("已完成", QColor("#287B65"), QColor("#E8F6F1")),
4: ("已过号", QColor("#A9691D"), QColor("#FFF4D8")),
}.get(status, ("未知", SECONDARY, QColor("#F7F7F7")))
1: ("已预约", QColor(PALETTE["accent"]), QColor(PALETTE["accent_soft"])),
3: ("已完成", QColor(PALETTE["success"]), QColor(PALETTE["success_soft"])),
4: ("已过号", QColor(PALETTE["warning"]), QColor(PALETTE["warning_soft"])),
}.get(status, ("未知", SECONDARY, QColor(PALETTE["surface_alt"])))
self._draw_tag(painter, QRect(content.left() + 6, y, 46, 20), label, bg, fg, 12)
doctor = display_text(first_value(appointment, "doctor_name"), "-")
time_text = display_text(first_value(appointment, "time_text", "appointment_time"), "-")
@@ -1106,12 +1109,12 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
painter,
QRect(content.left() + 6, y + 19, max(20, content.width() - 12), 17),
time_text,
QColor("#A9691D") if status == 4 else SECONDARY,
QColor(PALETTE["warning"]) if status == 4 else SECONDARY,
13,
)
y += 42
if position < len(rows) - 1:
painter.setPen(QPen(QColor("#EDEDEE"), 1, Qt.PenStyle.DashLine))
painter.setPen(QPen(QColor(PALETTE["line"]), 1, Qt.PenStyle.DashLine))
painter.drawLine(content.left() + 6, y - 2, content.right() - 6, y - 2)
channel = first_value(
record,
@@ -1153,7 +1156,7 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
painter,
QRect(content.left(), content.top() + 38, 72, 18),
"处方已作废",
QColor("#F7F7F7"),
QColor(PALETTE["surface_alt"]),
SECONDARY,
11,
outlined=True,
@@ -1166,11 +1169,11 @@ class DiagnosisItemDelegate(QStyledItemDelegate):
else:
days = _as_int(value)
color = (
QColor("#287B65")
QColor(PALETTE["success"])
if days <= 2
else QColor("#A9691D")
else QColor(PALETTE["warning"])
if days <= 6
else QColor("#BE4B58")
else QColor(PALETTE["danger"])
)
text, bold = str(days), days > 6
self._draw_text(
@@ -1320,6 +1323,8 @@ class _TechBlueDiagnosisDelegate(DiagnosisItemDelegate):
painter, content, "已确认" if _confirmed(record) else "未确认", pixels=13,
color="text" if _confirmed(record) else _BLUE_WARNING.name(),
)
elif column == 6:
self._followup(painter, content, display_text(index.data(), "—"))
elif column == 8:
prescribed = _as_bool(first_value(record, "has_prescription"))
self._text(painter, content, "已开方" if prescribed else "未开方",
@@ -1348,6 +1353,28 @@ class _TechBlueDiagnosisDelegate(DiagnosisItemDelegate):
medium=column == 2)
painter.restore()
@staticmethod
def _followup(painter: QPainter, rect: QRect, text: str) -> None:
"""Break at the date/time boundary, never in the middle of a number.
Keep the established row metrics. Long time ranges or doctor names
elide within their line; the model tooltip retains the complete text.
"""
painter.setFont(_blue_font(13))
painter.setPen(QColor(TECH_BLUE["muted"]))
metrics = painter.fontMetrics()
lines = text.splitlines()
if lines and metrics.horizontalAdvance(lines[0]) > rect.width():
lines[:1] = lines[0].split(maxsplit=1)
line_height = metrics.height()
top = rect.top() + max(0, (rect.height() - line_height * len(lines)) // 2)
for offset, line in enumerate(lines):
painter.drawText(
QRect(rect.left(), top + offset * line_height, rect.width(), line_height),
int(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter | Qt.TextFlag.TextSingleLine),
metrics.elidedText(line, Qt.TextElideMode.ElideRight, rect.width()),
)
def _appointments(self, painter: QPainter, rect: QRect, record: Any) -> None:
content = rect.adjusted(8, 0, -8, 0)
if not _has_appointment(record):
@@ -1688,7 +1715,9 @@ class DiagnosisTableHost(QFrame):
self.main.horizontalHeader().sectionResized.connect(self._columns_resized)
self._fixed_render_signature: tuple[Any, ...] | None = None
if tech_blue:
self.setStyleSheet(_TECH_BLUE_TABLE_QSS.replace("BODY_FAMILY", body_family()))
self.setStyleSheet(clinical_stylesheet(
_TECH_BLUE_TABLE_QSS.replace("BODY_FAMILY", body_family())
))
def set_rows(self, rows: Iterable[Any]) -> None:
previous_id = DiagnosisTableModel.record_id(self.main.current_data())
@@ -1904,6 +1933,7 @@ class DiagnosisTableHost(QFrame):
.replace("#8E8F90", TECH_BLUE["muted"])
+ f'QMenu {{ font-family: "{body_family()}"; font-weight: 400; }}'
)
menu.setStyleSheet(clinical_stylesheet(menu.styleSheet()))
for label, action, _semantic in demoted_actions:
_add_menu_action(
menu,
@@ -2630,19 +2660,19 @@ DIAGNOSIS_INDEX_QSS += """
#DiagnosisIndex QFrame#DiagnosisFilterCard,
#DiagnosisIndex QFrame#DiagnosisListCard {
border: 1px solid #EDEDEE;
border-radius: 13px;
border-radius: $ds_radius_panel;
}
#DiagnosisIndex QLineEdit,
#DiagnosisIndex QComboBox,
#DiagnosisIndex QDateEdit,
#DiagnosisIndex QSpinBox,
#DiagnosisIndex QPushButton {
border-radius: 8px;
border-radius: $ds_radius_control;
}
#DiagnosisIndex QToolButton[diagnosisChip="true"] { border-radius: 8px; }
#DiagnosisIndex QToolButton[diagnosisChip="true"] { border-radius: $ds_radius_small; }
#DiagnosisIndex QFrame#DiagnosisListToolbar {
border-top-left-radius: 13px;
border-top-right-radius: 13px;
border-top-left-radius: $ds_radius_panel;
border-top-right-radius: $ds_radius_panel;
}
#DiagnosisIndex QToolButton[diagnosisChip="true"]:checked[semantic="primary"],
#DiagnosisIndex QToolButton[diagnosisChip="true"]:checked[semantic="info"],
@@ -2650,7 +2680,27 @@ DIAGNOSIS_INDEX_QSS += """
#DiagnosisIndex QPushButton[variant="success"] {
color: #FFFFFF;
}
#DiagnosisIndex QLineEdit:focus,
#DiagnosisIndex QComboBox:focus,
#DiagnosisIndex QDateEdit:focus,
#DiagnosisIndex QSpinBox:focus,
#DiagnosisIndex QPushButton:focus {
border-color: $ds_focus;
}
#DiagnosisIndex QPushButton[variant="primary"]:pressed {
color: $ds_surface;
background-color: $ds_accent_pressed;
border-color: $ds_accent_pressed;
}
#DiagnosisIndex QPushButton:disabled,
#DiagnosisIndex QPushButton[variant="primary"]:disabled,
#DiagnosisIndex QPushButton[variant="success"]:disabled {
color: $ds_disabled;
background-color: $ds_disabled_surface;
border-color: $ds_line;
}
"""
DIAGNOSIS_INDEX_QSS = clinical_stylesheet(DIAGNOSIS_INDEX_QSS)
__all__ = [
@@ -32,6 +32,8 @@ from PySide6.QtWidgets import (
QWidget,
)
from .design_system import clinical_stylesheet
try:
from PySide6.QtMultimedia import QAudioOutput, QMediaPlayer
from PySide6.QtMultimediaWidgets import QVideoWidget
@@ -223,7 +225,7 @@ class InlineRecordingPlayer(QWidget):
self.setMinimumHeight(158)
self.setMaximumHeight(180)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.setStyleSheet(_INLINE_PLAYER_QSS)
self.setStyleSheet(clinical_stylesheet(_INLINE_PLAYER_QSS))
root = QVBoxLayout(self)
root.setContentsMargins(1, 1, 1, 5)
@@ -466,11 +468,11 @@ class RecordingPlaybackCell(QWidget):
separator = QFrame()
separator.setObjectName("DiagnosisRecordingAlternateSeparator")
separator.setFrameShape(QFrame.Shape.HLine)
separator.setStyleSheet("color:#EDEDEE;")
separator.setStyleSheet(clinical_stylesheet("color:$ds_line;"))
layout.addWidget(separator)
label = QLabel("备用地址")
label.setObjectName("DiagnosisRecordingAlternateLabel")
label.setStyleSheet("color:#606163; font-size:12px;")
label.setStyleSheet(clinical_stylesheet("color:$ds_muted; font-size:12px;"))
layout.addWidget(label)
links = QHBoxLayout()
links.setContentsMargins(0, 0, 0, 0)
@@ -490,7 +492,7 @@ class RecordingPlaybackCell(QWidget):
layout.addLayout(links)
self.link_status = QLabel("")
self.link_status.setObjectName("DiagnosisRecordingLinkStatus")
self.link_status.setStyleSheet("color:#BE4B58; font-size:11px;")
self.link_status.setStyleSheet(clinical_stylesheet("color:$ds_danger; font-size:11px;"))
self.link_status.setWordWrap(True)
self.link_status.hide()
layout.addWidget(self.link_status)
@@ -807,7 +809,7 @@ class ImagePreviewDialog(QDialog):
self.setObjectName("DiagnosisImagePreview")
self.setWindowTitle(title)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
self.setStyleSheet(_IMAGE_PREVIEW_QSS)
self.setStyleSheet(clinical_stylesheet(_IMAGE_PREVIEW_QSS))
self.resize(880, 660)
root = QVBoxLayout(self)
@@ -62,6 +62,7 @@ from shiboken6 import isValid
from .. import icons
from ..chat_items import parse_chat_item as _parse_chat_item
from ..design_system import clinical_stylesheet
from ..diagnosis_drawer import CaseGrid, _RemoteImageButton
from ..diagnosis_index_widgets import FlowWidget
from ..diagnosis_media import (
@@ -94,6 +95,9 @@ from ..widgets import (
show_toast,
)
from .ai_consult_charts import GlucoseChartData
from .ai_consult_drug_names import TCM as DRUG_TCM
from .ai_consult_drug_names import WESTERN as DRUG_WESTERN
from .ai_consult_drug_names import summarize_drugs
from .ai_consult_metric_state import (
ABNORMAL_COLOR,
NORMAL_COLOR,
@@ -101,7 +105,6 @@ from .ai_consult_metric_state import (
combined_metric_state,
risk_color,
)
from .ai_consult_drug_names import TCM as DRUG_TCM, WESTERN as DRUG_WESTERN, summarize_drugs
from .ai_consult_metric_text import MetricTextState, metric_text_context, metric_text_html
from .ai_consult_report_visuals import (
ReportVisual,
@@ -114,10 +117,10 @@ from .prescription_ai import (
diagnosis_ai_task,
)
AI_CONSULT_QSS = """
AI_CONSULT_QSS = clinical_stylesheet("""
QDialog#AiConsultDialog {
color: #1A1C1F;
background-color: #F7F7F7; font-size: 14px;
color: $ds_text;
background-color: $ds_canvas; font-size: 14px;
}
QDialog#AiConsultDialog QScrollArea,
QDialog#AiConsultDialog QScrollArea > QWidget,
@@ -149,7 +152,7 @@ QDialog#AiConsultDialog QScrollBar::sub-page:vertical {
background-color: transparent;
}
QDialog#AiConsultDialog QFrame#AiConsultShell {
background-color: #F7F7F7;
background-color: $ds_canvas;
border: 0;
}
QDialog#AiConsultDialog QLabel#AiConsultCrumb {
@@ -171,7 +174,7 @@ QDialog#AiConsultDialog QPushButton#AiConsultBack {
color: #1A1C1F;
background-color: #F0F0F0;
border: 0;
border-radius: 8px;
border-radius: $ds_radius_control;
font-weight: 500;
}
QDialog#AiConsultDialog QPushButton#AiConsultBack:hover { background-color: #EEF1FA; }
@@ -183,7 +186,7 @@ QDialog#AiConsultDialog QFrame#AiConsultHero {
QDialog#AiConsultDialog QLabel#AiConsultAvatar {
color: #FFFFFF;
background-color: #4F63D9;
border-radius: 22px;
border-radius: $ds_radius_control;
font-size: 16px;
font-weight: 600;
}
@@ -201,7 +204,7 @@ QDialog#AiConsultDialog QLabel#AiConsultMeta {
QDialog#AiConsultDialog QLabel#AiConsultChip {
color: #6A6B6D;
background-color: #F7F7F7;
border-radius: 8px;
border-radius: $ds_radius_small;
padding: 4px 8px;
font-size: 13px;
}
@@ -240,7 +243,7 @@ QDialog#AiConsultDialog QPushButton#AiConsultChatFilter {
color: #4F63D9;
background-color: #FFFFFF;
border: 1px solid #E1E5F4;
border-radius: 8px;
border-radius: $ds_radius_control;
font-size: 13px;
}
QDialog#AiConsultDialog QPushButton#AiConsultChatFilter:hover {
@@ -275,7 +278,7 @@ QDialog#AiConsultDialog QLabel#AiConsultRole {
max-width: 30px;
min-height: 30px;
max-height: 30px;
border-radius: 15px;
border-radius: $ds_radius_small;
color: #FFFFFF;
font-size: 13px;
font-weight: 500;
@@ -331,7 +334,7 @@ QDialog#AiConsultDialog QLabel#AiConsultClinicalMeta {
QDialog#AiConsultDialog QLabel#AiConsultClinicalBadge {
color: #4F63D9;
background-color: #EEF1FA;
border-radius: 7px;
border-radius: $ds_radius_small;
padding: 4px 8px;
font-size: 13px;
font-weight: 500;
@@ -346,10 +349,10 @@ QDialog#AiConsultDialog QLabel#AiConsultClinicalSectionTitle {
color: #1A1C1F;
background-color: transparent;
font-size: 14px;
font-weight: 500;
font-weight: 600;
}
QDialog#AiConsultDialog QLabel#AiConsultClinicalSummaryBody {
color: #1A1C1F;
color: $ds_text;
background-color: transparent;
font-size: 14px;
font-weight: 400;
@@ -411,7 +414,7 @@ QDialog#AiConsultDialog QLabel#AiConsultHypothesisTag {
QDialog#AiConsultDialog QLabel#AiConsultClinicalBody,
QDialog#AiConsultDialog QLabel#AiConsultWorkflowBody,
QDialog#AiConsultDialog QLabel#AiConsultRiskBody {
color: #1A1C1F;
color: $ds_text;
background-color: transparent;
font-size: 14px;
font-weight: 400;
@@ -456,23 +459,23 @@ QDialog#AiConsultDialog QLabel#AiConsultRiskTitle {
font-weight: 600;
}
QDialog#AiConsultDialog QLabel#AiConsultRiskBody {
color: #1A1C1F; font-size: 14px;
color: $ds_text; font-size: 14px;
}
QDialog#AiConsultDialog QLabel#AiConsultRiskTitle {
color: #BE4B58;
}
QDialog#AiConsultDialog QLabel#AiConsultRiskBody {
color: #1A1C1F; font-size: 14px;
color: $ds_text; font-size: 14px;
}
/* 结构化报告:正文按阅读节奏排版,不再每句话套一个方框。 */
QDialog#AiConsultDialog QFrame#AiConsultReportIntro {
background-color: #F7F7F7;
background-color: $ds_accent_soft;
border: 1px solid #EDEDEE;
border-left: 3px solid #4F63D9;
border-radius: 9px;
border-radius: $ds_radius_control;
}
QDialog#AiConsultDialog QLabel#AiConsultReportIntroBody {
color: #1A1C1F;
color: $ds_text;
background-color: transparent;
font-size: 14px;
font-weight: 400;
@@ -497,7 +500,7 @@ QDialog#AiConsultDialog QLabel#AiConsultReportSectionTitle {
color: #1A1C1F;
background-color: transparent;
font-size: 15px;
font-weight: 500;
font-weight: 600;
}
QDialog#AiConsultDialog QFrame#AiConsultReportRule {
background-color: #EDEDEE;
@@ -518,7 +521,7 @@ QDialog#AiConsultDialog QLabel#AiConsultReportBullet {
font-weight: 500;
}
QDialog#AiConsultDialog QLabel#AiConsultReportBody {
color: #1A1C1F;
color: $ds_text;
background-color: transparent;
font-size: 14px;
font-weight: 400;
@@ -541,18 +544,18 @@ QDialog#AiConsultDialog QLabel#AiConsultClinicalDisclaimer {
font-weight: 400;
}
QDialog#AiConsultDialog QFrame#AiConsultReportProvenance {
background-color: #F7F8FC;
border: 1px solid #E4E8F2;
border-radius: 9px;
background-color: $ds_surface_alt;
border: 1px solid $ds_line;
border-radius: $ds_radius_control;
}
QDialog#AiConsultDialog QLabel#AiConsultReportProvenanceTitle {
color: #27336B;
color: $ds_heading;
background-color: transparent;
font-size: 12px;
font-weight: 600;
}
QDialog#AiConsultDialog QLabel#AiConsultReportProvenanceLine {
color: #555B68;
color: $ds_muted;
background-color: transparent;
font-size: 12px;
}
@@ -647,7 +650,7 @@ QDialog#AiConsultDialog QLabel#AiConsultSection {
font-weight: 500;
}
QDialog#AiConsultDialog QLabel#AiConsultBody {
color: #1A1C1F;
color: $ds_text;
background-color: transparent;
font-size: 14px;
line-height: 1.6;
@@ -681,7 +684,7 @@ QDialog#AiConsultDialog QLabel#AiConsultInsightPlaceholder {
QDialog#AiConsultDialog QLabel#AiConsultTag[level="high"] {
color: #BE4B58;
background-color: #FFF1F3;
border-radius: 8px;
border-radius: $ds_radius_small;
padding: 2px 8px;
font-size: 13px;
font-weight: 600;
@@ -689,7 +692,7 @@ QDialog#AiConsultDialog QLabel#AiConsultTag[level="high"] {
QDialog#AiConsultDialog QLabel#AiConsultTag[level="medium"] {
color: #A9691D;
background-color: #FFF5E6;
border-radius: 8px;
border-radius: $ds_radius_small;
padding: 2px 8px;
font-size: 13px;
font-weight: 500;
@@ -697,7 +700,7 @@ QDialog#AiConsultDialog QLabel#AiConsultTag[level="medium"] {
QDialog#AiConsultDialog QLabel#AiConsultTag[level="low"] {
color: #287B65;
background-color: #EAF9F3;
border-radius: 8px;
border-radius: $ds_radius_small;
padding: 2px 8px;
font-size: 13px;
font-weight: 500;
@@ -705,7 +708,7 @@ QDialog#AiConsultDialog QLabel#AiConsultTag[level="low"] {
QDialog#AiConsultDialog QLabel#AiConsultTag[level="warn"] {
color: #BE4B58;
background-color: #FFF1F3;
border-radius: 8px;
border-radius: $ds_radius_small;
padding: 2px 8px;
font-size: 13px;
font-weight: 600;
@@ -713,7 +716,7 @@ QDialog#AiConsultDialog QLabel#AiConsultTag[level="warn"] {
QDialog#AiConsultDialog QLabel#AiConsultTag[level="unknown"] {
color: #6A6B6D;
background-color: #F0F0F0;
border-radius: 8px;
border-radius: $ds_radius_small;
padding: 2px 8px;
font-size: 13px;
}
@@ -739,7 +742,7 @@ QDialog#AiConsultDialog QLineEdit#AiConsultInput {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 12px;
border-radius: $ds_radius_control;
font-size: 14px;
}
QDialog#AiConsultDialog QLineEdit#AiConsultInput:focus {
@@ -763,7 +766,7 @@ QDialog#AiConsultDialog QPushButton#AiConsultIconButton {
max-height: 36px;
padding: 0;
border: 0;
border-radius: 18px;
border-radius: $ds_radius_control;
background-color: #F7F7F7;
}
QDialog#AiConsultDialog QPushButton#AiConsultIconButton:hover { background-color: #EEF1FA; }
@@ -774,7 +777,7 @@ QDialog#AiConsultDialog QPushButton#AiConsultSend {
max-height: 40px;
padding: 0;
border: 0;
border-radius: 20px;
border-radius: $ds_radius_control;
background-color: #4F63D9;
}
QDialog#AiConsultDialog QPushButton#AiConsultSend:hover { background-color: #4156C4; }
@@ -783,7 +786,7 @@ QDialog#AiConsultDialog QLabel#AiConsultSideTitle {
color: #1A1C1F;
background-color: transparent;
font-size: 16px;
font-weight: 500;
font-weight: 600;
}
QDialog#AiConsultDialog QLabel#AiConsultSideSubtitle {
color: #6A6B6D;
@@ -871,7 +874,7 @@ QDialog#AiConsultDialog QPushButton#AiConsultSideClose {
max-height: 28px;
padding: 0;
border: 0;
border-radius: 8px;
border-radius: $ds_radius_control;
color: #606163;
background-color: transparent;
font-size: 16px;
@@ -917,10 +920,10 @@ QDialog#AiConsultDialog QLabel#AiConsultRecordTitle {
color: #1A1C1F;
background-color: transparent;
font-size: 13px;
font-weight: 500;
font-weight: 600;
}
QDialog#AiConsultDialog QLabel#AiConsultRecordBody {
color: #1A1C1F;
color: $ds_text;
background-color: transparent;
font-size: 14px;
}
@@ -951,7 +954,7 @@ QDialog#AiConsultDialog QPushButton#AiConsultMediaOpen {
color: #4F63D9;
background-color: #EEF1FA;
border: 0;
border-radius: 8px;
border-radius: $ds_radius_control;
font-weight: 500;
}
QDialog#AiConsultDialog QPushButton#AiConsultRecordRetry:hover,
@@ -1000,10 +1003,11 @@ QDialog#AiConsultDialog QLabel#AiConsultDataLabel {
font-size: 13px;
}
QDialog#AiConsultDialog QLabel#AiConsultDataValue {
color: #1A1C1F;
color: $ds_text;
font-size: 13px;
}
"""
QDialog#AiConsultDialog QPushButton:focus { border-color: $ds_focus; }
""")
QUICK_PROMPTS: tuple[tuple[str, str], ...] = (
("总结当前病情", "请根据当前病历总结患者病情、证候与风险。"),
@@ -1053,8 +1057,8 @@ _DOCTOR_DOCUMENT_CSS = (
# 模型回复几乎都是“分节标题 + 两层要点”的长文。早期样式里标题只比正文大 1px、
# 段落与列表项的间距也几乎相同,整段读起来就是一堵字墙。这里把层级、行距和分节
# 留白拉开:标题明显更大更重,顶层小节之间留出整行空白,嵌套要点单独收紧缩进。
_AI_DOCUMENT_CSS = (
"body { color:#1A1C1F; font-size:14px; line-height:200%; } "
_AI_DOCUMENT_CSS = clinical_stylesheet(
"body { color:$ds_text; font-size:14px; line-height:200%; } "
"h1,h2 { color:#1A1C1F; font-size:17px; margin:22px 0 10px; line-height:160%; } "
"h3,h4 { color:#1A1C1F; font-size:15px; margin:18px 0 8px; line-height:160%; } "
"p { margin:10px 0; line-height:200%; } "
@@ -2219,15 +2223,12 @@ def _escape_html(value: str) -> str:
)
class _FlowRow(QWidget):
class _FlowRow(FlowWidget):
"""Keep patient metadata readable when the details pane is narrow."""
def __init__(self, parent: QWidget | None = None) -> None:
super().__init__(parent)
self._layout = QHBoxLayout(self)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(8)
self._layout.setAlignment(
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
)
super().__init__(parent, horizontal_spacing=8, vertical_spacing=6)
self._layout = self.flow
def add(self, widget: QWidget) -> None:
self._layout.addWidget(widget)
@@ -2810,7 +2811,7 @@ class _DrugSummaryStrip(QFrame):
layout.addLayout(row)
@staticmethod
def for_text(text: str, parent: QWidget | None = None) -> "_DrugSummaryStrip | None":
def for_text(text: str, parent: QWidget | None = None) -> _DrugSummaryStrip | None:
summary = summarize_drugs(text)
return _DrugSummaryStrip(summary, parent) if any(summary.values()) else None
@@ -3454,11 +3455,11 @@ class _ChatBubble(QWidget):
avatar.setAlignment(Qt.AlignmentFlag.AlignCenter)
_style_surface(avatar)
if role == "doctor":
avatar.setStyleSheet("background-color:#4F63D9; color:#FFFFFF; border-radius:15px;")
avatar.setStyleSheet(clinical_stylesheet("background-color:#4F63D9; color:#FFFFFF; border-radius:6px;"))
elif role == "ai":
avatar.setStyleSheet("background-color:#EEF1FA; color:#4F63D9; border-radius:15px;")
avatar.setStyleSheet(clinical_stylesheet("background-color:#EEF1FA; color:#4F63D9; border-radius:6px;"))
else:
avatar.setStyleSheet("background-color:#6A6B6D; color:#FFFFFF; border-radius:15px;")
avatar.setStyleSheet(clinical_stylesheet("background-color:#6A6B6D; color:#FFFFFF; border-radius:6px;"))
bubble = QFrame()
_style_surface(bubble)
if role == "doctor":
@@ -3629,10 +3630,10 @@ class _ChatBubble(QWidget):
toggle.setCursor(Qt.CursorShape.PointingHandCursor)
toggle.setAccessibleName("展开资料提交回执")
toggle.setStyleSheet(
"QPushButton {color:#65718A;font-size:12px;text-align:left;"
clinical_stylesheet("QPushButton {color:$ds_muted;font-size:12px;text-align:left;"
"background:transparent;border:0;padding:4px 0;}"
"QPushButton:hover {color:#4F63D9;}"
"QPushButton:focus {border-bottom:1px solid #4F63D9;}"
"QPushButton:focus {border-bottom:1px solid #4F63D9;}")
)
layout.addWidget(toggle)
label = QLabel(receipt)
@@ -3643,7 +3644,7 @@ class _ChatBubble(QWidget):
Qt.TextInteractionFlag.TextSelectableByMouse
| Qt.TextInteractionFlag.TextSelectableByKeyboard
)
label.setStyleSheet("color:#65718A;font-size:12px;")
label.setStyleSheet(clinical_stylesheet("color:$ds_muted;font-size:12px;"))
label.hide()
layout.addWidget(label)
self._inner.insertWidget(0, receipt)
@@ -3688,7 +3689,7 @@ class _ChatBubble(QWidget):
label.setTextFormat(Qt.TextFormat.PlainText)
label.setWordWrap(True)
label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
label.setStyleSheet("color:#BE4B58;background:#FEF3F2;border-radius:6px;padding:8px;")
label.setStyleSheet(clinical_stylesheet("color:#BE4B58;background:#FEF3F2;border-radius:6px;padding:8px;"))
self._inner.insertWidget(self._inner.indexOf(self.body), label)
self._stream_failure_label = label
label.setText(f"本次回复未完成\n{text}")
@@ -4949,8 +4950,9 @@ class AiConsultDialog(QDialog):
button.setObjectName("AiConsultChipButton")
button.setCursor(Qt.CursorShape.PointingHandCursor)
button.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
task_key = QUICK_PROMPT_TASKS.get(label, "")
button.clicked.connect(
lambda _checked=False, text=prompt, task=QUICK_PROMPT_TASKS.get(label, ""):
lambda _checked=False, text=prompt, task=task_key:
self._ask(text, replace_active=True, task=task)
)
chips.addWidget(button, 1)
@@ -43,6 +43,7 @@ from doctor_workstation.services.app_update import (
validate_installer_download_policy,
validate_windows_installer,
)
from doctor_workstation.ui.design_system import clinical_stylesheet
from doctor_workstation.ui.widgets import friendly_error, show_toast
LOGGER = logging.getLogger(__name__)
@@ -129,11 +130,11 @@ class AppUpdateDialog(QDialog):
self.badge = QLabel("必须更新后才能继续使用" if offer.force else "发现新版本")
self.badge.setObjectName("UpdateBadge")
self.badge.setStyleSheet(
self.badge.setStyleSheet(clinical_stylesheet(
"color:#A9691D;background:#FFF5E6;border-radius:8px;padding:4px 10px;font-weight:600;"
if offer.force
else "color:#4F63D9;background:#EEF1FA;border-radius:8px;padding:4px 10px;font-weight:600;"
)
))
root.addWidget(self.badge, 0, Qt.AlignmentFlag.AlignLeft)
self.headline = QLabel(title or "医生工作站有新版本")
@@ -146,7 +147,7 @@ class AppUpdateDialog(QDialog):
latest = offer.latest_version or "新版本"
self.version_label = QLabel(f"当前版本 {current} → 最新版本 {latest}")
self.version_label.setObjectName("UpdateVersionLabel")
self.version_label.setStyleSheet("color:#606163;")
self.version_label.setStyleSheet(clinical_stylesheet("color:$ds_muted;"))
root.addWidget(self.version_label)
self.notes = QTextEdit()
@@ -160,7 +161,7 @@ class AppUpdateDialog(QDialog):
self.status_label = QLabel("")
self.status_label.setObjectName("UpdateStatus")
self.status_label.setWordWrap(True)
self.status_label.setStyleSheet("color:#1A1C1F;")
self.status_label.setStyleSheet(clinical_stylesheet("color:$ds_heading;"))
self.status_label.hide()
root.addWidget(self.status_label)
@@ -175,7 +176,7 @@ class AppUpdateDialog(QDialog):
self.progress_text = QLabel("")
self.progress_text.setObjectName("UpdateProgressText")
self.progress_text.setStyleSheet("color:#606163;font-size:12px;")
self.progress_text.setStyleSheet(clinical_stylesheet("color:$ds_muted;font-size:12px;"))
self.progress_text.hide()
root.addWidget(self.progress_text)
@@ -225,7 +226,7 @@ class AppUpdateDialog(QDialog):
def show_download_progress(self, received: int, total: int) -> None:
self.progress.show()
self.progress_text.show()
self.status_label.setStyleSheet("color:#1A1C1F;")
self.status_label.setStyleSheet(clinical_stylesheet("color:$ds_heading;"))
self.status_label.setText("正在下载安装包…")
self.status_label.show()
if total > 0:
@@ -237,7 +238,7 @@ class AppUpdateDialog(QDialog):
self.progress_text.setText(_format_bytes(received))
def show_status(self, message: str, *, determinate: bool = False) -> None:
self.status_label.setStyleSheet("color:#1A1C1F;")
self.status_label.setStyleSheet(clinical_stylesheet("color:$ds_heading;"))
self.status_label.setText(message)
self.status_label.show()
self.progress.show()
@@ -251,7 +252,7 @@ class AppUpdateDialog(QDialog):
def show_error(self, message: str) -> None:
self._busy = False
self.status_label.setText(message)
self.status_label.setStyleSheet("color:#BE4B58;")
self.status_label.setStyleSheet(clinical_stylesheet("color:$ds_danger;"))
self.status_label.show()
self.progress.hide()
self.progress_text.hide()
@@ -48,6 +48,7 @@ from PySide6.QtWidgets import (
)
from ...core.appointment_modes import appointment_type_description, appointment_type_value
from ..design_system import clinical_stylesheet
from ..diagnosis_drawer import (
DIAGNOSIS_QSS,
CaseGrid,
@@ -97,6 +98,7 @@ from .issued_prescription_ai import can_open_issued_ai, present_issued_prescript
from .local_audio_queue import LocalAudioQueueDialog
from .prescription_ai import can_open_diagnosis_ai_report, present_diagnosis_ai_report
class _UploadProgressRelay(QObject):
"""把后台线程中的分片上传进度转回界面线程(信号跨线程自动排队)。"""
@@ -1541,16 +1543,16 @@ class DiagnosisDialog(QDialog):
"""上传本地回放时的进度条:按分片实时更新,医生能看到上传在进行、进行到哪。"""
frame = QFrame()
frame.setObjectName("DiagnosisVideoUploadProgress")
frame.setStyleSheet(
frame.setStyleSheet(clinical_stylesheet(
"QFrame#DiagnosisVideoUploadProgress { background-color: #EEF1FA;"
" border: 1px solid #C9D1F3; border-radius: 8px; }"
"QFrame#DiagnosisVideoUploadProgress QLabel { color: #3347B8; background: transparent;"
" border: 1px solid $ds_line_strong; border-radius: $ds_radius_control; }"
"QFrame#DiagnosisVideoUploadProgress QLabel { color: $ds_accent_hover; background: transparent;"
" font-size: 13px; font-weight: 500; }"
"QFrame#DiagnosisVideoUploadProgress QProgressBar { background-color: #FFFFFF;"
" border: 0; border-radius: 4px; min-height: 8px; max-height: 8px; }"
"QFrame#DiagnosisVideoUploadProgress QProgressBar::chunk { background-color: #4F63D9;"
" border-radius: 4px; }"
)
))
row = QVBoxLayout(frame)
row.setContentsMargins(12, 8, 12, 10)
row.setSpacing(6)
@@ -21,6 +21,8 @@ from typing import Any
from PySide6.QtGui import QFont
from ..design_system import PALETTE
DARK: dict[str, str] = {
# ground and cards
"canvas": "#080D18",
@@ -62,23 +64,23 @@ DARK: dict[str, str] = {
}
LIGHT: dict[str, str] = {
"canvas": "#F1F5FC",
"canvas_soft": "#E7EEFA",
"surface": "#FFFFFF",
"surface_2": "#F5F8FE",
"raised": "#E8EFFA",
"line": "#D5E1F2",
"line_soft": "#E3EBF8",
"heading": "#0A182E",
"text": "#2A3C56",
"muted": "#54697F",
"faint": "#7A8DA3",
"selected_text": "#0A182E",
"accent": "#1A5FD0",
"accent_text": "#124DAE",
"accent_pressed": "#0E3F90",
"selection": "#E8EFFA",
"selection_line": "#AEC7EE",
"canvas": PALETTE["canvas"],
"canvas_soft": PALETTE["surface_alt"],
"surface": PALETTE["surface"],
"surface_2": PALETTE["surface_alt"],
"raised": PALETTE["sidebar"],
"line": PALETTE["line_strong"],
"line_soft": PALETTE["line"],
"heading": PALETTE["heading"],
"text": PALETTE["text"],
"muted": PALETTE["muted"],
"faint": PALETTE["disabled"],
"selected_text": PALETTE["heading"],
"accent": PALETTE["accent"],
"accent_text": PALETTE["accent_hover"],
"accent_pressed": PALETTE["accent_pressed"],
"selection": PALETTE["accent_soft"],
"selection_line": PALETTE["focus"],
"qwen": "#0C89AC",
"qwen_text": "#086C88",
"qwen_dim": "#E2F5FA",
@@ -29,6 +29,7 @@ from ...services.local_audio_queue import (
LocalAudioUploadManager,
get_local_audio_upload_manager,
)
from ..design_system import clinical_stylesheet
from ..widgets import run_async
_STATUS_LABELS = {
@@ -174,7 +175,7 @@ class LocalAudioQueueDialog(QDialog):
self.setModal(True)
self.setMinimumSize(760, 480)
self.resize(1160, 620)
self.setStyleSheet(_LOCAL_AUDIO_QSS)
self.setStyleSheet(clinical_stylesheet(_LOCAL_AUDIO_QSS))
self._build_ui()
self.poll_timer = QTimer(self)
@@ -28,8 +28,8 @@ from PySide6.QtCore import (
QDate,
QEvent,
QIODevice,
QModelIndex,
QMarginsF,
QModelIndex,
QObject,
QPoint,
QRectF,
@@ -98,6 +98,7 @@ from PySide6.QtWidgets import (
)
from .. import icons
from ..design_system import clinical_stylesheet
from ..diagnosis_terms import shared_terms
from ..infinite_list import InfiniteList
from ..theme import main_window_target_rect
@@ -116,9 +117,9 @@ from ..widgets import (
)
from .diagnosis import DiagnosisDialog as _StructuredDiagnosisDialog
PRESCRIPTION_DRAWER_QSS = r"""
PRESCRIPTION_DRAWER_QSS = clinical_stylesheet(r"""
QFrame#PrescriptionDrawerSurface {
color: #1A1C1F;
color: $ds_text;
background-color: #FFFFFF;
border-left: 1px solid #EDEDEE;
font-size: 14px;
@@ -145,7 +146,7 @@ QLabel#PrescriptionLockTag {
color: #BE4B58;
background-color: #FEF0F0;
border: 1px solid #FDE2E2;
border-radius: 4px;
border-radius: $ds_radius_small;
padding: 2px 8px;
font-size: 13px;
}
@@ -175,7 +176,7 @@ QLabel#PrescriptionDrawerMode {
color: #4F63D9;
background-color: #EEF1FA;
border: 1px solid #EDEDEE;
border-radius: 5px;
border-radius: $ds_radius_small;
padding: 4px 9px;
font-size: 13px;
font-weight: 500;
@@ -189,7 +190,7 @@ QPushButton#PrescriptionDrawerClose {
color: #606163;
background-color: transparent;
border: 0;
border-radius: 7px;
border-radius: $ds_radius_control;
font-size: 22px;
font-weight: 400;
}
@@ -208,12 +209,12 @@ QWidget#PrescriptionDrawerContent {
QFrame#PrescriptionFormSection {
background-color: #F7F7F7;
border: 1px solid #EDEDEE;
border-radius: 10px;
border-radius: $ds_radius_panel;
}
QLabel#PrescriptionSectionTitle {
color: #1A1C1F;
font-size: 15px;
font-weight: 500;
font-weight: 600;
}
QLabel#PrescriptionSectionHint {
color: #6A6B6D;
@@ -242,7 +243,7 @@ QLabel#PrescriptionUsageAux {
QFrame#PrescriptionRpToolbar {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 10px;
border-radius: $ds_radius_panel;
}
QFrame#PrescriptionRpMarker {
background-color: #4F63D9;
@@ -262,12 +263,12 @@ QLabel#PrescriptionRpLock {
color: #BE4B58;
background-color: #FEF3F2;
border: 1px solid #FECDCA;
border-radius: 5px;
border-radius: $ds_radius_small;
padding: 5px 8px;
font-size: 13px;
}
QLabel#PrescriptionFormulaTag {
border-radius: 4px;
border-radius: $ds_radius_small;
padding: 3px 8px;
font-size: 13px;
font-weight: 500;
@@ -328,7 +329,7 @@ QFrame#PrescriptionDrawerSurface QDoubleSpinBox {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
padding: 0 11px;
selection-background-color: #C9D1F3;
selection-color: #1A1C1F; font-size: 14px;
@@ -338,7 +339,7 @@ QFrame#PrescriptionDrawerSurface QComboBox {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
padding-left: 11px;
padding-right: 28px;
selection-background-color: #C9D1F3;
@@ -379,7 +380,7 @@ QFrame#PrescriptionDatePicker {
min-height: 32px;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
}
QFrame#PrescriptionDatePicker:hover {
border-color: #8B9AD9;
@@ -446,7 +447,7 @@ QFrame#PrescriptionDrawerSurface QPushButton {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
font-weight: 500;
}
QFrame#PrescriptionDrawerSurface QPushButton:hover {
@@ -468,7 +469,7 @@ QFrame#PrescriptionDrawerSurface QPushButton#PrescriptionDrawerClose {
color: #606163;
background-color: transparent;
border: 0;
border-radius: 7px;
border-radius: $ds_radius_control;
font-size: 22px;
font-weight: 400;
}
@@ -496,23 +497,23 @@ QFrame#PrescriptionDrawerSurface QPushButton[variant="primary"]:hover {
border-color: #4156C4;
}
QFrame#PrescriptionDrawerSurface QPushButton[variant="success"] {
color: #FFFFFF;
background-color: #287B65;
border-color: #287B65;
color: $ds_accent;
background-color: $ds_accent_soft;
border-color: $ds_line;
}
QFrame#PrescriptionDrawerSurface QPushButton[variant="success"]:hover {
background-color: #287B65;
border-color: #287B65;
background-color: $ds_accent_soft;
border-color: $ds_focus;
}
QFrame#PrescriptionDrawerSurface QPushButton[variant="warning"] {
color: #A9691D;
color: $ds_accent;
background-color: #FFFFFF;
border-color: #A9691D;
border-color: $ds_accent;
}
QFrame#PrescriptionDrawerSurface QPushButton[variant="warning"]:hover {
color: #FFFFFF;
background-color: #A9691D;
border-color: #A9691D;
color: $ds_accent_hover;
background-color: $ds_accent_soft;
border-color: $ds_focus;
}
QFrame#PrescriptionDrawerSurface QPushButton[variant="secondary"] {
color: #4F63D9;
@@ -615,7 +616,8 @@ QFrame#PrescriptionDrawerSurface QFrame#MessageBanner[kind="danger"] {
QFrame#PrescriptionDrawerSurface QFrame#MessageBanner[kind="danger"] QLabel {
color: #BE4B58;
}
"""
QFrame#PrescriptionDrawerSurface QPushButton:focus { border: 1px solid $ds_focus; }
""")
_CHEVRON_PATH: Path | None = None
@@ -647,7 +649,7 @@ def _prescription_drawer_qss() -> str:
def _prescription_calendar_qss() -> str:
return """
return clinical_stylesheet("""
QCalendarWidget {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
@@ -672,13 +674,13 @@ QCalendarWidget QAbstractItemView:enabled {
selection-color: #1A1C1F;
outline: 0;
}
"""
""")
PRESCRIPTION_DIALOG_QSS = """
PRESCRIPTION_DIALOG_QSS = clinical_stylesheet("""
QDialog#PrescriptionDialogSurface {
color: #1A1C1F;
background-color: #F7F7F7;
background-color: $ds_canvas;
font-size: 14px;
}
QDialog#PrescriptionDialogSurface QLabel {
@@ -740,7 +742,7 @@ QDialog#PrescriptionDialogSurface QTextBrowser {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
selection-background-color: #EEF1FA;
selection-color: #1A1C1F; font-size: 14px;
}
@@ -768,7 +770,7 @@ QDialog#PrescriptionDialogSurface QPushButton {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
font-weight: 500;
}
QDialog#PrescriptionDialogSurface QPushButton:hover {
@@ -798,7 +800,7 @@ QDialog#PrescriptionDialogSurface QPushButton:disabled {
QDialog#PrescriptionDialogSurface QTabWidget::pane {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 9px;
border-radius: $ds_radius_panel;
top: -1px;
}
QDialog#PrescriptionDialogSurface QTabBar::tab {
@@ -852,7 +854,8 @@ QDialog#PrescriptionDialogSurface QScrollBar::add-line:vertical,
QDialog#PrescriptionDialogSurface QScrollBar::sub-line:vertical {
height: 0;
}
"""
QDialog#PrescriptionDialogSurface QPushButton:focus { border: 1px solid $ds_focus; }
""")
def _apply_prescription_dialog_style(dialog: QDialog) -> None:
@@ -1531,9 +1534,9 @@ class RemoteMedicineComboBox(QComboBox):
popup = self._completer.popup()
popup.setItemDelegate(_MedicineSuggestionDelegate(popup))
popup.setStyleSheet(
"QListView { background-color: #FFFFFF; border: 1px solid #E4E7ED; border-radius: 6px;"
clinical_stylesheet("QListView { background-color: #FFFFFF; border: 1px solid #E4E7ED; border-radius: 6px;"
" padding: 4px 0; font-size: 14px; outline: 0; }"
"QListView::item:selected, QListView::item:hover { background-color: #F5F7FA; }"
"QListView::item:selected, QListView::item:hover { background-color: #F5F7FA; }")
)
self.lineEdit().setCompleter(self._completer)
self.lineEdit().installEventFilter(self)
@@ -5292,8 +5295,8 @@ class PrescriptionDetailDialog(QDialog):
self.preview.setObjectName("PrescriptionPaperPreview")
self.preview.setOpenExternalLinks(False)
self.preview.setStyleSheet(
"QTextBrowser#PrescriptionPaperPreview {"
"background-color:#F7F7F7; border:1px solid #E4E4E5; padding:0;}"
clinical_stylesheet("QTextBrowser#PrescriptionPaperPreview {"
"background-color:#F7F7F7; border:1px solid #E4E4E5; padding:0;}")
)
self.preview.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.preview.setDocument(self.document)
@@ -5301,8 +5304,8 @@ class PrescriptionDetailDialog(QDialog):
self.user_preview.setObjectName("PrescriptionUserPaperPreview")
self.user_preview.setOpenExternalLinks(False)
self.user_preview.setStyleSheet(
"QTextBrowser#PrescriptionUserPaperPreview {"
"background-color:#F7F7F7; border:1px solid #E4E4E5; padding:0;}"
clinical_stylesheet("QTextBrowser#PrescriptionUserPaperPreview {"
"background-color:#F7F7F7; border:1px solid #E4E4E5; padding:0;}")
)
self.user_preview.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.user_preview.setDocument(self.user_document)
@@ -5320,8 +5323,8 @@ class PrescriptionDetailDialog(QDialog):
self.case_preview.setObjectName("CaseRecordPaperPreview")
self.case_preview.setOpenExternalLinks(False)
self.case_preview.setStyleSheet(
"QTextBrowser#CaseRecordPaperPreview {"
"background-color:#F7F7F7; border:1px solid #E4E4E5; padding:0;}"
clinical_stylesheet("QTextBrowser#CaseRecordPaperPreview {"
"background-color:#F7F7F7; border:1px solid #E4E4E5; padding:0;}")
)
self.case_preview.setDocument(self.case_document)
case_index = self.tabs.addTab(self.case_preview, "详细病历")
@@ -26,6 +26,7 @@ from PySide6.QtWidgets import (
QWidget,
)
from ..design_system import clinical_stylesheet
from ..report_provenance import report_provenance_lines
from ..theme import apply_reading_rhythm
from ..widgets import (
@@ -169,10 +170,10 @@ def diagnosis_ai_task(prompt: str) -> str:
return "custom"
PRESCRIPTION_AI_QSS = """
PRESCRIPTION_AI_QSS = clinical_stylesheet("""
QDialog#PrescriptionAiDialog {
color: #1A1C1F;
background-color: #F7F7F7;
color: $ds_text;
background-color: $ds_canvas;
font-size: 13px;
}
@@ -182,7 +183,7 @@ QDialog#PrescriptionAiDialog QPushButton {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 7px;
border-radius: $ds_radius_control;
font-weight: 500;
}
QDialog#PrescriptionAiDialog QPushButton:hover {
@@ -224,7 +225,7 @@ QLabel#PrescriptionAiSubtitle {
QFrame#PrescriptionAiSnapshot {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 10px;
border-radius: $ds_radius_panel;
}
QLabel#PrescriptionAiSnapshotLabel {
color: #1A1C1F;
@@ -232,20 +233,20 @@ QLabel#PrescriptionAiSnapshotLabel {
font-weight: 600;
}
QLabel#PrescriptionAiSnapshotBody {
color: #1A1C1F;
font-size: 13px;
color: $ds_text;
font-size: 14px;
line-height: 1.65;
}
QFrame#PrescriptionAiSummary {
background-color: #F0F0F0;
background-color: $ds_accent_soft;
border: 0;
border-left: 3px solid #4F63D9;
border-radius: 0 9px 9px 0;
border-radius: $ds_radius_control;
}
QFrame#PrescriptionAiCaution {
background-color: #FFF9EE;
border: 1px solid #F3DFB5;
border-radius: 9px;
border-radius: $ds_radius_control;
}
QLabel#PrescriptionAiSectionTitle {
color: #1A1C1F;
@@ -253,17 +254,17 @@ QLabel#PrescriptionAiSectionTitle {
font-weight: 600;
}
QLabel#PrescriptionAiBody {
color: #1A1C1F;
font-size: 13px;
color: $ds_text;
font-size: 14px;
line-height: 1.75;
}
QTextBrowser#PrescriptionAiAnswer {
color: #1A1C1F;
color: $ds_text;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 10px;
padding: 12px 14px;
selection-color: #1A1C1F;
border-radius: $ds_radius_panel;
padding: 16px 18px;
selection-color: $ds_text;
selection-background-color: #EEF1FA;
}
QLabel#PrescriptionAiMuted {
@@ -279,7 +280,7 @@ QFrame#PrescriptionAiMeta {
QDialog#PrescriptionAiDialog QTabWidget::pane {
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 10px;
border-radius: $ds_radius_panel;
top: -1px;
}
QDialog#PrescriptionAiDialog QTabBar::tab {
@@ -309,7 +310,7 @@ QDialog#PrescriptionAiDialog QTextEdit {
color: #1A1C1F;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 8px;
border-radius: $ds_radius_control;
padding: 10px;
selection-background-color: #EEF1FA;
}
@@ -330,10 +331,12 @@ QDialog#PrescriptionAiDialog QScrollBar::add-line:vertical,
QDialog#PrescriptionAiDialog QScrollBar::sub-line:vertical {
height: 0;
}
"""
QDialog#PrescriptionAiDialog QPushButton:focus { border: 1px solid $ds_focus; }
QDialog#PrescriptionAiDialog QPushButton:disabled { color: $ds_disabled; background-color: $ds_disabled_surface; border-color: $ds_line; }
""")
_AI_ANSWER_DOCUMENT_CSS = (
"body { color:#1A1C1F; font-size:14px; line-height:1.72; } "
_AI_ANSWER_DOCUMENT_CSS = clinical_stylesheet(
"body { color:$ds_text; font-size:14px; line-height:1.72; } "
"h1 { color:#1A1C1F; font-size:20px; margin:14px 0 8px; line-height:1.4; } "
"h2 { color:#1A1C1F; font-size:17px; margin:14px 0 7px; line-height:1.42; } "
"h3,h4 { color:#1A1C1F; font-size:15px; margin:12px 0 6px; line-height:1.45; } "
@@ -801,7 +804,7 @@ class PrescriptionAiReportDialog(QDialog):
self.report_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.host = QWidget()
self.host_layout = QVBoxLayout(self.host)
self.host_layout.setContentsMargins(4, 4, 12, 8)
self.host_layout.setContentsMargins(18, 14, 20, 16)
self.host_layout.setSpacing(12)
self.report_scroll.setWidget(self.host)
self.tabs.widget(0).layout().addWidget(self.report_scroll)
@@ -1455,7 +1458,7 @@ class PrescriptionAiReportDialog(QDialog):
label.setTextFormat(Qt.TextFormat.PlainText)
label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
label.setWordWrap(True)
label.setStyleSheet("color: #555B68; font-size: 12px; padding: 10px 14px; background: #F7F8FC; border: 1px solid #E4E8F2; border-radius: 8px;")
label.setStyleSheet(clinical_stylesheet("color: $ds_muted; font-size: 12px; padding: 10px 14px; background: $ds_surface_alt; border: 1px solid $ds_line; border-radius: $ds_radius_control;"))
self.host_layout.addWidget(label)
def reject(self) -> None:
@@ -8,6 +8,7 @@ from PySide6.QtCore import QObject, QSize, Qt, Signal
from PySide6.QtWidgets import QApplication, QPushButton, QWidget
from . import icons
from .design_system import PALETTE, clinical_stylesheet
class FilterDisclosure(QObject):
@@ -35,17 +36,17 @@ class FilterDisclosure(QObject):
self.button.setCursor(Qt.CursorShape.PointingHandCursor)
self.button.setFixedHeight(32)
self.button.setIconSize(QSize(14, 14))
self.button.setStyleSheet("""
self.button.setStyleSheet(clinical_stylesheet("""
QPushButton#FilterDisclosureButton {
color: #1769E8; background: #FFFFFF; border: 1px solid #DBE5F2;
border-radius: 6px; padding: 0 11px; min-height: 30px; max-height: 30px;
border-radius: $ds_radius_control; padding: 0 11px; min-height: 30px; max-height: 30px;
min-width: 92px; font-size: 13px; font-weight: 400;
}
QPushButton#FilterDisclosureButton:hover { background: #F3F7FD; border-color: #ADC8F2; }
QPushButton#FilterDisclosureButton:checked { background: #EAF2FF; border-color: #ADC8F2; }
QPushButton#FilterDisclosureButton:focus { border-color: #1769E8; }
QPushButton#FilterDisclosureButton:disabled { color: #8B97A8; border-color: #E3E9F1; }
""")
QPushButton#FilterDisclosureButton:hover { background: $ds_canvas; border-color: $ds_line_strong; }
QPushButton#FilterDisclosureButton:checked { background: $ds_accent_soft; border-color: $ds_line_strong; }
QPushButton#FilterDisclosureButton:focus { border-color: $ds_focus; }
QPushButton#FilterDisclosureButton:disabled { color: $ds_disabled; border-color: $ds_line; }
"""))
self.button.toggled.connect(self.set_expanded)
self._apply()
@@ -78,4 +79,4 @@ class FilterDisclosure(QObject):
self.button.setAccessibleName(label)
self.button.setAccessibleDescription("显示或收起检索条件和统计信息;收起保留当前筛选条件")
self.button.setToolTip("收起保留当前筛选条件" if self._expanded else "展开检索条件和统计信息,当前筛选条件保持不变")
self.button.setIcon(icons.icon("chevron_up" if self._expanded else "chevron_down", "#1769E8", 14))
self.button.setIcon(icons.icon("chevron_up" if self._expanded else "chevron_down", PALETTE["accent"], 14))
@@ -16,6 +16,7 @@ from PySide6.QtWidgets import (
QWidget,
)
from .design_system import clinical_stylesheet
from .widgets import first_value, get_value, page_items, page_total, run_async
@@ -54,16 +55,16 @@ class InfiniteList(QWidget):
layout = QHBoxLayout(self)
layout.setContentsMargins(12, 0, 12, 0)
self.summary_label = QLabel("", self)
self.summary_label.setStyleSheet(
self.summary_label.setStyleSheet(clinical_stylesheet(
"color: #5D6B80; font-size: 12px; background: transparent;"
)
))
layout.addWidget(self.summary_label)
layout.addStretch(1)
self.retry_button = QPushButton("加载失败,点击重试", self)
self.retry_button.setFlat(True)
self.retry_button.setStyleSheet(
self.retry_button.setStyleSheet(clinical_stylesheet(
"color: #1769E8; font-size: 12px; padding: 0 4px; border: none; background: transparent; min-height: 20px; max-height: 20px; min-width: 0;"
)
))
self.retry_button.hide()
self.retry_button.clicked.connect(self.retry)
layout.addWidget(self.retry_button)
+79 -243
View File
@@ -5,26 +5,21 @@ from __future__ import annotations
from contextlib import suppress
from typing import Any
from PySide6.QtCore import QPoint, QPointF, QRectF, QSettings, Qt, QTimer, Signal
from PySide6.QtCore import QEvent, QPoint, QPointF, QRectF, QSettings, Qt, QTimer, Signal
from PySide6.QtGui import (
QBrush,
QColor,
QFont,
QIcon,
QLinearGradient,
QPainter,
QPainterPath,
QPen,
QPixmap,
QPolygonF,
QRadialGradient,
QResizeEvent,
)
from PySide6.QtWidgets import (
QApplication,
QCheckBox,
QFrame,
QGraphicsDropShadowEffect,
QHBoxLayout,
QLabel,
QLayout,
@@ -45,6 +40,7 @@ from doctor_workstation import __version__
from doctor_workstation.resources import app_icon_path, brand_lockup_path
from . import icons
from .design_system import PALETTE, clinical_stylesheet
from .widgets import BusyOverlay, MessageBanner, friendly_error, invoke, run_async
@@ -127,7 +123,7 @@ def _round_pen(color: QColor | str, width: float) -> QPen:
class _BrandPanel(QWidget):
"""The quiet medical illustration and copy from the supplied login artwork."""
"""A flat, readable introduction to the clinician's daily workflow."""
def __init__(self, parent: QWidget | None = None) -> None:
super().__init__(parent)
@@ -137,228 +133,76 @@ class _BrandPanel(QWidget):
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self._brand_lockup = QPixmap(str(brand_lockup_path()))
@staticmethod
def _draw_cube(painter: QPainter, center: QPointF, size: float, kind: str) -> None:
x, y = center.x(), center.y()
top = QPolygonF(
[
QPointF(x, y - size * 0.58),
QPointF(x + size * 0.48, y - size * 0.34),
QPointF(x, y - size * 0.10),
QPointF(x - size * 0.48, y - size * 0.34),
]
)
left = QPolygonF(
[
QPointF(x - size * 0.48, y - size * 0.34),
QPointF(x, y - size * 0.10),
QPointF(x, y + size * 0.48),
QPointF(x - size * 0.48, y + size * 0.24),
]
)
right = QPolygonF(
[
QPointF(x, y - size * 0.10),
QPointF(x + size * 0.48, y - size * 0.34),
QPointF(x + size * 0.48, y + size * 0.24),
QPointF(x, y + size * 0.48),
]
)
painter.setPen(QPen(QColor(185, 196, 247, 205), 1.2))
painter.setBrush(QColor(235, 239, 255, 218))
painter.drawPolygon(top)
painter.setBrush(QColor(210, 218, 255, 205))
painter.drawPolygon(left)
painter.setBrush(QColor(224, 230, 255, 220))
painter.drawPolygon(right)
painter.setPen(_round_pen(QColor(137, 154, 248, 135), 2.2))
if kind == "plus":
painter.drawLine(
QPointF(x - size * 0.12, y + size * 0.05),
QPointF(x + size * 0.15, y - size * 0.02),
)
painter.drawLine(
QPointF(x + size * 0.02, y - size * 0.13),
QPointF(x + size * 0.02, y + size * 0.17),
)
else:
shield = QPainterPath(QPointF(x, y - size * 0.16))
shield.lineTo(x + size * 0.15, y - size * 0.08)
shield.lineTo(x + size * 0.10, y + size * 0.17)
shield.lineTo(x, y + size * 0.26)
shield.lineTo(x - size * 0.10, y + size * 0.17)
shield.lineTo(x - size * 0.15, y - size * 0.08)
shield.closeSubpath()
painter.drawPath(shield)
def _draw_illustration(
self, painter: QPainter, width: float, height: float
) -> None:
ox = max(250.0, width - 500.0)
oy = max(365.0, height - 500.0)
glow = QRadialGradient(QPointF(width - 170, oy + 230), 280)
glow.setColorAt(0.0, QColor(102, 120, 255, 62))
glow.setColorAt(1.0, QColor(102, 120, 255, 0))
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(glow)
painter.drawEllipse(QPointF(width - 170, oy + 230), 280, 280)
painter.setPen(QPen(QColor(166, 180, 241, 78), 1))
for offset in (0, 72, 144):
painter.drawLine(
QPointF(ox - 80, oy + 280 + offset),
QPointF(width + 20, oy + 170 + offset),
)
painter.drawLine(QPointF(ox + 10, oy + 400), QPointF(ox + 10, oy + 80))
painter.drawLine(QPointF(ox + 170, oy + 430), QPointF(ox + 170, oy + 35))
base = QRectF(ox + 80, oy + 365, 430, 88)
base_gradient = QLinearGradient(base.topLeft(), base.bottomRight())
base_gradient.setColorAt(0.0, QColor(246, 248, 255, 228))
base_gradient.setColorAt(1.0, QColor(186, 199, 255, 184))
painter.setBrush(base_gradient)
painter.setPen(QPen(QColor(166, 181, 248, 158), 1))
painter.drawEllipse(base)
painter.setBrush(QColor(249, 250, 255, 225))
painter.drawEllipse(QRectF(base.x() + 42, base.y() - 12, base.width() - 84, 70))
painter.save()
painter.translate(35, 40)
screen = QPolygonF(
[
QPointF(ox + 130, oy + 60),
QPointF(ox + 435, oy + 100),
QPointF(ox + 435, oy + 365),
QPointF(ox + 130, oy + 310),
]
)
painter.setBrush(QColor(218, 225, 255, 205))
painter.setPen(QPen(QColor(145, 163, 242, 170), 1.3))
painter.drawPolygon(screen)
inner = QPolygonF(
[
QPointF(ox + 141, oy + 80),
QPointF(ox + 425, oy + 117),
QPointF(ox + 425, oy + 345),
QPointF(ox + 141, oy + 295),
]
)
painter.setBrush(QColor(255, 255, 255, 225))
painter.drawPolygon(inner)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor(174, 189, 252, 180))
painter.drawRoundedRect(QRectF(ox + 148, oy + 89, 270, 15), 7, 7)
for dot_x in (156, 173, 190):
painter.setBrush(QColor(255, 255, 255, 200))
painter.drawEllipse(QPointF(ox + dot_x, oy + 96.5), 3.5, 3.5)
cards = (
QRectF(ox + 150, oy + 135, 82, 80),
QRectF(ox + 241, oy + 142, 72, 73),
QRectF(ox + 322, oy + 151, 95, 72),
QRectF(ox + 151, oy + 232, 264, 50),
QRectF(ox + 151, oy + 291, 264, 42),
)
painter.setPen(QPen(QColor(188, 199, 246, 160), 1))
painter.setBrush(QColor(249, 250, 255, 228))
for card in cards:
painter.drawRoundedRect(card, 7, 7)
painter.setPen(_round_pen(QColor(117, 137, 236, 165), 4))
for idx, bar_height in enumerate((20, 36, 51)):
x = ox + 164 + idx * 17
painter.drawLine(QPointF(x, oy + 200), QPointF(x, oy + 200 - bar_height))
painter.setBrush(QColor(112, 132, 235, 160))
painter.setPen(Qt.PenStyle.NoPen)
painter.drawEllipse(QPointF(ox + 277, oy + 167), 10, 10)
painter.drawRoundedRect(QRectF(ox + 259, oy + 180, 36, 20), 10, 10)
painter.setPen(_round_pen(QColor(137, 153, 235, 150), 5))
for y, length in ((170, 54), (186, 42), (249, 89), (307, 72)):
painter.drawLine(
QPointF(ox + 340, oy + y), QPointF(ox + 340 + length, oy + y + 5)
)
self._draw_cube(painter, QPointF(ox + 352, oy - 25), 76, "plus")
self._draw_cube(painter, QPointF(ox - 8, oy + 210), 76, "shield")
painter.restore()
def paintEvent(self, event: Any) -> None: # noqa: N802 - Qt API
del event
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing)
bounds = QRectF(self.rect()).adjusted(0.5, 0.5, -0.5, -0.5)
background = QLinearGradient(bounds.topLeft(), bounds.bottomRight())
background.setColorAt(0.0, QColor("#FFFFFF"))
background.setColorAt(0.7, QColor("#FFFFFF"))
background.setColorAt(1.0, QColor("#F7F7F7"))
painter.setBrush(background)
painter.setPen(QPen(QColor("#EDEDEE"), 1))
painter.drawRoundedRect(bounds, 24, 24)
width, height = float(self.width()), float(self.height())
self._draw_illustration(painter, width, height)
left = 64.0 if width >= 620 else 38.0
if not self._brand_lockup.isNull():
logo_width = 180.0
logo_height = logo_width * (
self._brand_lockup.height() / self._brand_lockup.width()
)
painter.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform)
painter.drawPixmap(
QRectF(left, 24, logo_width, logo_height),
self._brand_lockup,
QRectF(self._brand_lockup.rect()),
)
tag_rect = QRectF(left, 238, 119, 40)
bounds = QRectF(self.rect()).adjusted(1, 1, -1, -1)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#EEF1FA"))
painter.drawRoundedRect(tag_rect, 11, 11)
painter.setFont(_font(17, QFont.Weight.Medium))
painter.setPen(QColor("#4F63D9"))
painter.drawText(tag_rect, Qt.AlignmentFlag.AlignCenter, "医生工作站")
painter.setBrush(QColor(PALETTE["sidebar"]))
painter.drawRoundedRect(bounds, 20, 20)
left = 36.0
width = max(240.0, self.width() - 72.0)
if not self._brand_lockup.isNull():
brand = self._brand_lockup.scaled(
226, 58, Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation,
)
painter.drawPixmap(QPointF(left, 36), brand)
else:
painter.setFont(_font(22, QFont.Weight.DemiBold))
painter.setPen(QColor(PALETTE["heading"]))
painter.drawText(QPointF(left, 70), "甄养堂 · 医生工作站")
copy_left = left + 4
painter.setFont(_font(48, QFont.Weight.Medium))
painter.setPen(QColor("#1A1C1F"))
painter.drawText(QPointF(copy_left, 354), "把诊间工作,")
painter.drawText(QPointF(copy_left, 424), "留在一个")
prefix_width = painter.fontMetrics().horizontalAdvance("留在一个")
highlight = QLinearGradient(
copy_left + prefix_width,
0,
copy_left + prefix_width + 264,
0,
)
highlight.setColorAt(0.0, QColor("#4F63D9"))
highlight.setColorAt(1.0, QColor("#4F63D9"))
painter.setPen(QPen(QBrush(highlight), 1))
painter.drawText(QPointF(copy_left + prefix_width, 424), "安静的界面里")
suffix_x = (
copy_left
+ prefix_width
+ painter.fontMetrics().horizontalAdvance("安静的界面里")
)
painter.setPen(QColor("#1A1C1F"))
painter.drawText(QPointF(suffix_x, 424), "。")
heading_y = max(158.0, min(218.0, self.height() * .27))
painter.setPen(QColor(PALETTE["muted"]))
painter.setFont(_font(13, QFont.Weight.Medium))
painter.drawText(QPointF(left, heading_y - 36), "医 生 工 作 台")
painter.setPen(QColor(PALETTE["heading"]))
painter.setFont(_font(30, QFont.Weight.DemiBold))
painter.drawText(QPointF(left, heading_y), "让诊疗有序,")
painter.drawText(QPointF(left, heading_y + 44), "让沟通更专注。")
painter.setFont(_font(14))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(QPointF(left, heading_y + 82), "从接诊、病历到处方,在一个工作台完成。")
body_left = left + 6
painter.setFont(_font(20))
painter.setPen(QColor("#606163"))
painter.drawText(
QPointF(body_left, 492), "接诊、问诊、患者与处方信息统一呈现,"
)
painter.drawText(QPointF(body_left, 525), "帮助医生专注于每一次沟通。")
row_y = heading_y + 122
for index, (title, detail) in enumerate((
("今日接诊", "快速找到待接诊患者与预约安排"),
("诊疗记录", "病历、随访与面诊资料集中查看"),
("处方协作", "开方与审核流程清晰衔接"),
), start=1):
row = QRectF(left, row_y, width, 66)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor(PALETTE["surface"]))
painter.drawRoundedRect(row, 12, 12)
painter.setFont(_font(13, QFont.Weight.DemiBold))
painter.setPen(QColor(PALETTE["accent"]))
painter.drawText(QRectF(left + 16, row_y, 28, 66), Qt.AlignmentFlag.AlignCenter, f"0{index}")
painter.setFont(_font(15, QFont.Weight.Medium))
painter.setPen(QColor(PALETTE["heading"]))
painter.drawText(QPointF(left + 58, row_y + 27), title)
painter.setFont(_font(12))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(QPointF(left + 58, row_y + 47), detail)
row_y += 78
if self.height() > row_y + 50:
painter.setFont(_font(12))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(QPointF(left, self.height() - 28), "仅供获授权的医疗人员使用")
painter.end()
painter.setFont(_font(16))
painter.setPen(QColor("#6A6B6D"))
painter.drawText(
QPointF(body_left, height - 85), "本工作站仅供获授权的医疗人员使用"
)
painter.drawText(QPointF(body_left, height - 59), "请勿在公共设备保存账号信息")
class _PasswordField(QFrame):
"""Keep the grouped password control visibly focused for keyboard users."""
def eventFilter(self, watched: Any, event: QEvent) -> bool: # noqa: N802
if event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut):
self.setProperty("focused", event.type() == QEvent.Type.FocusIn)
self.style().unpolish(self)
self.style().polish(self)
self.update()
return super().eventFilter(watched, event)
class _RevealButton(QToolButton):
@@ -392,8 +236,8 @@ class _ServerButton(QPushButton):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
rect = QRectF(self.rect()).adjusted(0.75, 0.75, -0.75, -0.75)
painter.setBrush(QColor("#FFFFFF") if self.underMouse() else QColor("#FFFFFF"))
painter.setPen(QPen(QColor("#E4E4E5"), 1.5))
painter.setBrush(QColor(PALETTE["accent_soft"] if self.underMouse() else PALETTE["surface"]))
painter.setPen(QPen(QColor(PALETTE["focus"] if self.hasFocus() else PALETTE["line_strong"]), 1))
painter.drawRoundedRect(rect, 12, 12)
color = QColor("#1A1C1F" if self.isEnabled() else "#8E8F90")
painter.setPen(_round_pen("#6A6B6D", 1.8))
@@ -536,7 +380,7 @@ class LoginWindow(QMainWindow):
border: 1px solid #E4E4E5;
border-radius: 12px;
}
QFrame#PasswordField:focus-within { border-color: #8B9AD9; }
QFrame#PasswordField[focused="true"] { border-color: #8B9AD9; }
QFrame#LoginCard QCheckBox {
color: #606163;
spacing: 13px;
@@ -606,6 +450,9 @@ class LoginWindow(QMainWindow):
self.login_root.addWidget(self.brand_panel, 60)
self.login_root.addWidget(self._build_login_area(), 40)
self._restore_settings()
for widget in (canvas, *canvas.findChildren(QWidget)):
if widget.styleSheet():
widget.setStyleSheet(clinical_stylesheet(widget.styleSheet()))
def resizeEvent(self, event: QResizeEvent) -> None: # noqa: N802 - Qt API
"""Preserve the reference composition while remaining usable on small screens."""
@@ -625,18 +472,15 @@ class LoginWindow(QMainWindow):
# Keep the form fully visible when the 60/40 desktop split would
# otherwise crop its fixed-width card. Small windows focus on login.
self.brand_panel.setVisible(width >= 1120)
compact_height = event.size().height() < 720
self.card.setMinimumHeight(580 if compact_height else 620)
self.login_area_layout.setContentsMargins(
0, min(104, max(24, (event.size().height() - 694) // 2)), 0, 12
0, 12 if compact_height else min(104, max(24, (event.size().height() - 694) // 2)), 0, 12
)
super().resizeEvent(event)
def _build_brand_panel(self) -> QWidget:
panel = _BrandPanel()
shadow = QGraphicsDropShadowEffect(panel)
shadow.setBlurRadius(32)
shadow.setOffset(0, 10)
shadow.setColor(QColor(67, 82, 154, 18))
panel.setGraphicsEffect(shadow)
return panel
def _build_login_area(self) -> QWidget:
@@ -660,11 +504,6 @@ class LoginWindow(QMainWindow):
self.card.setFixedWidth(480)
self.card.setMinimumHeight(620)
self.card.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum)
card_shadow = QGraphicsDropShadowEffect(self.card)
card_shadow.setBlurRadius(38)
card_shadow.setOffset(0, 16)
card_shadow.setColor(QColor(59, 77, 139, 24))
self.card.setGraphicsEffect(card_shadow)
card_layout = QVBoxLayout(self.card)
card_layout.setSizeConstraint(QLayout.SizeConstraint.SetDefaultConstraint)
card_layout.setContentsMargins(47, 42, 47, 26)
@@ -673,13 +512,13 @@ class LoginWindow(QMainWindow):
title = QLabel("欢迎回来")
title.setObjectName("LoginTitle")
title.setStyleSheet("color:#1A1C1F; font-size:30px; font-weight:500;")
title.setStyleSheet("color:#1A1C1F; font-size:26px; font-weight:600;")
title.setContentsMargins(1, -3, 0, 3)
title.setFixedHeight(46)
card_layout.addWidget(title)
subtitle = QLabel("使用医生账号登录工作站")
subtitle.setProperty("role", "muted")
subtitle.setStyleSheet("color:#606163; font-size:18px;")
subtitle.setStyleSheet("color:#606163; font-size:15px;")
subtitle.setContentsMargins(1, 8, 0, 0)
subtitle.setFixedHeight(27)
card_layout.addWidget(subtitle)
@@ -710,7 +549,7 @@ class LoginWindow(QMainWindow):
password_label.setFixedHeight(24)
card_layout.addWidget(password_label)
card_layout.addSpacing(11)
password_field = QFrame()
password_field = _PasswordField()
password_field.setObjectName("PasswordField")
password_field.setFixedHeight(54)
password_row = QHBoxLayout(password_field)
@@ -721,6 +560,7 @@ class LoginWindow(QMainWindow):
self.password_edit.setEchoMode(QLineEdit.EchoMode.Password)
self.password_edit.setPlaceholderText("请输入密码")
self.password_edit.setAccessibleName("登录密码")
self.password_edit.installEventFilter(password_field)
self.password_edit.setTextMargins(0, -2, 0, 2)
self.password_edit.returnPressed.connect(self.submit)
password_row.addWidget(self.password_edit, 1)
@@ -730,6 +570,7 @@ class LoginWindow(QMainWindow):
self.reveal_button.setCheckable(True)
self.reveal_button.setFixedSize(87, 52)
self.reveal_button.setToolTip("显示或隐藏密码")
self.reveal_button.installEventFilter(password_field)
self.reveal_button.toggled.connect(self._toggle_password)
password_row.addWidget(self.reveal_button)
card_layout.addWidget(password_field)
@@ -758,11 +599,6 @@ class LoginWindow(QMainWindow):
self.login_button = QPushButton("登录工作站")
self.login_button.setProperty("variant", "primary")
self.login_button.setFixedHeight(58)
login_shadow = QGraphicsDropShadowEffect(self.login_button)
login_shadow.setBlurRadius(20)
login_shadow.setOffset(0, 7)
login_shadow.setColor(QColor(82, 101, 246, 45))
self.login_button.setGraphicsEffect(login_shadow)
self.login_button.clicked.connect(self.submit)
card_layout.addWidget(self.login_button)
self.debug_settings_section = QWidget()
+160 -24
View File
@@ -37,8 +37,10 @@ from PySide6.QtCore import (
QTimer,
)
from PySide6.QtWidgets import (
QAbstractItemView,
QAbstractScrollArea,
QGraphicsOpacityEffect,
QPlainTextEdit,
QStackedWidget,
QWidget,
)
@@ -75,15 +77,35 @@ def reduced_motion() -> bool:
return os.getenv("QT_QPA_PLATFORM", "").strip().lower() == "offscreen"
def _own(target: QWidget, key: str, animation: QPropertyAnimation) -> QPropertyAnimation:
"""Park an animation on its target so Python does not collect it early."""
def _stop(target: QObject, key: str) -> None:
"""Retire a replaced animation without firing its completion callback."""
running: dict[str, QPropertyAnimation] = getattr(target, "_doctor_motion", None) or {}
previous = running.get(key)
running = getattr(target, "_doctor_motion", {})
previous = running.pop(key, None)
if previous is not None:
previous.stop()
previous.setParent(None)
previous.deleteLater()
def _own(target: QObject, key: str, animation: QPropertyAnimation) -> QPropertyAnimation:
"""Park an animation on its target so Python does not collect it early."""
_stop(target, key)
running: dict[str, QPropertyAnimation] = getattr(target, "_doctor_motion", {})
running[key] = animation
target._doctor_motion = running
def release() -> None:
if running.get(key) is animation:
running.pop(key)
# A callback can hold the last Python reference to the owner. Detach
# first so releasing that callback during deferred deletion cannot
# recursively delete this animation through its former parent.
animation.setParent(None)
animation.deleteLater()
animation.finished.connect(release)
return animation
@@ -107,7 +129,10 @@ def animate(
from inside its own ``finished`` emission.
"""
animation_owner = owner if owner is not None else target
animation_key = key or prop.decode()
if reduced_motion():
_stop(animation_owner, animation_key)
target.setProperty(prop.decode() if isinstance(prop, bytes) else prop, end)
if on_finished is not None:
on_finished()
@@ -117,18 +142,24 @@ def animate(
animation.setEasingCurve(easing)
animation.setStartValue(start)
animation.setEndValue(end)
_own(animation_owner, animation_key, animation)
if on_finished is not None:
animation.finished.connect(on_finished)
_own(owner if owner is not None else target, key or prop.decode(), animation)
animation.start(QAbstractAnimation.DeletionPolicy.KeepWhenStopped)
return animation
def _opacity_effect(widget: QWidget) -> QGraphicsOpacityEffect:
def _opacity_effect(widget: QWidget) -> QGraphicsOpacityEffect | None:
effect = widget.graphicsEffect()
if not isinstance(effect, QGraphicsOpacityEffect):
# Do not replace a caller's shadow or opacity effect: Qt deletes it when
# another effect is attached. Only effects created here belong to a fade.
if effect is not None and effect is not getattr(widget, "_doctor_opacity_effect", None):
return None
if effect is None:
effect = QGraphicsOpacityEffect(widget)
effect.setOpacity(1.0)
widget.setGraphicsEffect(effect)
widget._doctor_opacity_effect = effect
effect.setEnabled(True)
return effect
@@ -146,9 +177,17 @@ def _drop_effect(widget: QWidget) -> None:
signal that is still being delivered.
"""
effect = getattr(widget, "_doctor_opacity_effect", None)
revision = getattr(widget, "_doctor_fade_revision", 0)
def detach() -> None:
try:
if isinstance(widget.graphicsEffect(), QGraphicsOpacityEffect):
if (
effect is not None
and widget.graphicsEffect() is effect
and getattr(widget, "_doctor_fade_revision", 0) == revision
):
widget._doctor_opacity_effect = None
widget.setGraphicsEffect(None)
except RuntimeError: # the widget went away while the fade was running
pass
@@ -156,6 +195,13 @@ def _drop_effect(widget: QWidget) -> None:
QTimer.singleShot(0, detach)
def _restart_fade(widget: QWidget) -> None:
_stop(widget, "fade")
# A completed fade may still have deferred cleanup waiting in the queue.
# It must not remove an effect now being used by a subsequent fade.
widget._doctor_fade_revision = getattr(widget, "_doctor_fade_revision", 0) + 1
def fade_in(
widget: QWidget,
*,
@@ -165,10 +211,20 @@ def fade_in(
) -> None:
"""Fade a widget up to full opacity, showing it first if needed."""
existing = widget.graphicsEffect()
if existing is not None and existing is getattr(widget, "_doctor_opacity_effect", None):
start = float(existing.opacity())
_restart_fade(widget)
if reduced_motion():
if existing is not None and existing is getattr(widget, "_doctor_opacity_effect", None):
existing.setOpacity(1.0)
_drop_effect(widget)
widget.show()
return
effect = _opacity_effect(widget)
if effect is None:
widget.show()
return
effect.setOpacity(start)
widget.show()
animate(
@@ -193,9 +249,11 @@ def fade_out(
) -> None:
"""Fade a widget down, optionally hiding it when the fade completes."""
_restart_fade(widget)
if reduced_motion():
if hide:
widget.hide()
_drop_effect(widget)
if on_finished is not None:
on_finished()
return
@@ -208,6 +266,9 @@ def fade_out(
if on_finished is not None:
on_finished()
if effect is None:
done()
return
animate(
effect,
b"opacity",
@@ -229,13 +290,17 @@ def enter(widget: QWidget, *, duration: int = BASE, rise: int = RISE) -> None:
the user has to wait out.
"""
previous = getattr(widget, "_doctor_motion", {}).get("enter")
origin = previous.endValue() if previous is not None else widget.pos()
if reduced_motion():
widget.show()
_stop(widget, "enter")
widget.move(origin)
fade_in(widget, duration=duration)
return
fade_in(widget, duration=duration)
if rise:
origin = widget.pos()
widget.move(origin + QPoint(0, rise))
if previous is None:
widget.move(origin + QPoint(0, rise))
animate(
widget,
b"pos",
@@ -260,7 +325,7 @@ def switch_stack(stack: QStackedWidget, index: int, *, rise: int = RISE) -> None
return
stack.setCurrentIndex(index)
page = stack.currentWidget()
if page is None or reduced_motion():
if page is None:
return
enter(page, rise=rise)
@@ -274,50 +339,121 @@ SCROLL_STEP = 120
SCROLL_MS = 190
class _ScrollAnimation(QPropertyAnimation):
"""Identify animation writes so direct scrollbar changes can interrupt us."""
writing = False
def updateCurrentValue(self, value: Any) -> None: # noqa: N802 - Qt API
self.writing = True
try:
super().updateCurrentValue(value)
finally:
self.writing = False
class _SmoothScroller(QObject):
"""Animate a scroll area's wheel movement instead of jumping to it."""
_INTERRUPT_EVENTS = frozenset(
{
QEvent.Type.KeyPress,
QEvent.Type.MouseButtonPress,
QEvent.Type.TouchBegin,
QEvent.Type.Hide,
}
)
def __init__(self, area: QAbstractScrollArea, *, orientation: Qt.Orientation) -> None:
super().__init__(area)
self._area = area
self._orientation = orientation
self._bar = (
area.verticalScrollBar()
if orientation is Qt.Orientation.Vertical
else area.horizontalScrollBar()
)
self._target = self._bar.value()
self._animation = QPropertyAnimation(self._bar, b"value", self)
self._animation = _ScrollAnimation(self._bar, b"value", self)
self._animation.setEasingCurve(EASE_ENTER)
self._animation.setDuration(SCROLL_MS)
# Keyboard, programmatic and drag movements must not be fought over: when
# nothing is animating, the wheel target follows wherever the bar went.
self._bar.valueChanged.connect(self._sync_target)
self._bar.sliderPressed.connect(self._cancel)
self._bar.actionTriggered.connect(self._cancel)
self._bar.rangeChanged.connect(self._cancel)
self._bar.installEventFilter(self)
area.installEventFilter(self)
area.viewport().installEventFilter(self)
def _cancel(self, *_: Any) -> None:
self._animation.stop()
self._target = self._bar.value()
def _sync_target(self, value: int) -> None:
if self._animation.state() != QAbstractAnimation.State.Running:
if not self._animation.writing:
self._animation.stop()
self._target = value
def _uses_pixels(self) -> bool:
if isinstance(self._area, QAbstractItemView):
mode = (
self._area.verticalScrollMode()
if self._orientation == Qt.Orientation.Vertical
else self._area.horizontalScrollMode()
)
return mode == QAbstractItemView.ScrollMode.ScrollPerPixel
# QPlainTextEdit's vertical scrollbar counts text blocks, not pixels.
return not (
isinstance(self._area, QPlainTextEdit) and self._orientation == Qt.Orientation.Vertical
)
def eventFilter(self, watched: QObject, event: QEvent) -> bool: # noqa: N802 - Qt API
del watched
if event.type() is not QEvent.Type.Wheel or reduced_motion():
event_type = event.type()
if event_type in self._INTERRUPT_EVENTS:
self._cancel()
return False
delta = event.angleDelta().y() or event.angleDelta().x()
if not delta or event.modifiers() & Qt.KeyboardModifier.ControlModifier:
if event_type != QEvent.Type.Wheel:
return False
horizontal = self._orientation == Qt.Orientation.Horizontal
shifted = bool(event.modifiers() & Qt.KeyboardModifier.ShiftModifier)
delta = event.angleDelta().x() if horizontal else event.angleDelta().y()
if horizontal and shifted and not delta:
delta = event.angleDelta().y()
if (
watched is not self._area.viewport()
or reduced_motion()
or not self._uses_pixels()
or not event.pixelDelta().isNull()
or event.phase() != Qt.ScrollPhase.NoScrollPhase
or event.modifiers()
& (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier)
or (shifted and not horizontal)
or not delta
):
# Trackpads already provide continuous motion and native momentum.
# Mixing another easing curve into it adds lag and fights gestures.
self._cancel()
return False
lower, upper = self._bar.minimum(), self._bar.maximum()
# Re-clamp first: the range can shrink underneath a running animation
# when the content behind it reloads, which would otherwise leave the
# pending target past the end of the new content.
self._target = max(lower, min(upper, self._target))
target = self._target - round(delta / 120.0 * SCROLL_STEP)
current = self._bar.value()
step = -round(delta / 120.0 * SCROLL_STEP)
# Reverse immediately from the visible position, not the end of a
# backlog of wheel notches still travelling in the opposite direction.
origin = current if (self._target - current) * step < 0 else self._target
target = origin + step
target = max(lower, min(upper, target))
# At either end, hand the wheel back so an enclosing scroll area still
# gets it - swallowing it there is what makes nested panes feel stuck.
if target == self._target:
return False
return target != current
self._target = target
self._animation.stop()
self._animation.setStartValue(self._bar.value())
self._animation.setStartValue(current)
self._animation.setEndValue(target)
self._animation.start()
return True
@@ -328,7 +464,7 @@ def install_smooth_scroll(
*,
orientation: Qt.Orientation = Qt.Orientation.Vertical,
) -> None:
"""Give a scroll area eased wheel scrolling."""
"""Ease discrete wheels on pixel-based areas; preserve native gestures."""
if getattr(area, "_doctor_smooth_scroll", None) is not None:
return
+120 -119
View File
@@ -50,6 +50,7 @@ from ...core.appointment_modes import (
)
from .. import icons
from ..appointment_drawer import AppointmentDrawer
from ..design_system import PALETTE, clinical_stylesheet
from ..dialogs import DiagnosisDialog, present_ai_consult, present_order_detail
from ..dialogs.ai_consult import can_open_ai_consult
from ..dialogs.prescription import PrescriptionOrderListDialog
@@ -110,97 +111,97 @@ FULFILLMENT_TEXT = {
}
_SEMANTIC_COLORS = {
"primary": "#4F63D9",
"success": "#287B65",
"warning": "#A9691D",
"danger": "#BE4B58",
"info": "#4F63D9",
"muted": "#606163",
"primary": PALETTE["accent"],
"success": PALETTE["success"],
"warning": PALETTE["warning"],
"danger": PALETTE["danger"],
"info": PALETTE["accent"],
"muted": PALETTE["muted"],
}
PATIENTS_LIGHT_QSS = """
PATIENTS_LIGHT_QSS = clinical_stylesheet("""
#PatientsPage QWidget#PageHeader QLabel[role="pageTitle"] {
color: #1A1C1F;
color: $ds_heading;
font-size: 20px;
font-weight: 600;
}
#PatientsPage QWidget#PageHeader QLabel[role="muted"] {
color: #606163;
color: $ds_muted;
font-size: 13px;
}
#PatientsPage QPushButton[patientSearchAction="true"] {
min-height: 32px;
max-height: 32px;
color: #FFFFFF;
background-color: #4F63D9;
border: 1px solid #4F63D9;
color: $ds_surface;
background-color: $ds_accent;
border: 1px solid $ds_accent;
border-radius: 7px;
font-weight: 500;
}
#PatientsPage QPushButton[patientSearchAction="true"]:hover {
background-color: #4156C4;
border-color: #4156C4;
background-color: $ds_accent_hover;
border-color: $ds_accent_hover;
}
#PatientsPage QFrame[patientListFilter="true"] {
min-height: 88px;
max-height: 88px;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
background-color: $ds_surface;
border: 1px solid $ds_line;
border-radius: 12px;
}
#PatientsPage QFrame[patientListFilter="true"] QLineEdit,
#PatientsPage QFrame[patientListFilter="true"] QDateEdit {
min-height: 32px;
max-height: 32px;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
background-color: $ds_surface;
border: 1px solid $ds_line;
border-radius: 7px; font-size: 14px;
}
#PatientsPage QFrame[patientListFilter="true"] QPushButton {
min-height: 32px; max-height: 32px;
}
#PatientsPage QFrame[patientListFilter="true"] QDateEdit:disabled {
color: #8E8F90; background-color: #F7F7F7;
color: $ds_disabled; background-color: $ds_surface_alt;
}
#PatientsPage QPushButton[patientStatusChip="true"] {
min-height: 32px;
max-height: 32px;
padding: 0 10px;
color: #606163;
background-color: #F7F7F7;
color: $ds_muted;
background-color: $ds_surface_alt;
border: 1px solid transparent;
border-radius: 5px;
}
#PatientsPage QPushButton[patientStatusChip="true"]:hover {
color: #4F63D9;
background-color: #EEF1FA;
color: $ds_accent;
background-color: $ds_accent_soft;
}
#PatientsPage QPushButton[patientStatusChip="true"]:checked {
color: #4F63D9;
background-color: #EEF1FA;
border: 1px solid #8B9AD9;
color: $ds_accent;
background-color: $ds_accent_soft;
border: 1px solid $ds_focus;
}
#PatientsPage QPushButton[patientQuickDate="true"] {
min-height: 32px;
max-height: 32px;
padding: 0 9px;
color: #1A1C1F;
color: $ds_heading;
background-color: transparent;
border: 1px solid transparent;
border-radius: 7px;
}
#PatientsPage QPushButton[patientQuickDate="true"]:hover {
color: #4F63D9;
background-color: #EEF1FA;
color: $ds_accent;
background-color: $ds_accent_soft;
}
#PatientsPage QPushButton[patientQuickDate="true"]:checked {
color: #4F63D9;
background-color: #EEF1FA;
border-color: #8B9AD9;
color: $ds_accent;
background-color: $ds_accent_soft;
border-color: $ds_focus;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs::pane {
border: 0;
border-top: 1px solid #EDEDEE;
border-top: 1px solid $ds_line;
background-color: transparent;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab {
@@ -208,124 +209,124 @@ PATIENTS_LIGHT_QSS = """
min-height: 34px;
padding: 0 6px;
margin-right: 8px;
color: #606163;
color: $ds_muted;
background: transparent;
border: 0;
border-bottom: 2px solid transparent;
font-weight: 400;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab:selected {
color: #4F63D9;
border-bottom-color: #4F63D9;
color: $ds_accent;
border-bottom-color: $ds_accent;
font-weight: 500;
}
#PatientsPage QPushButton[summaryCard="true"] {
min-height: 42px;
max-height: 42px;
padding: 0 11px;
color: #1A1C1F;
background-color: #F7F7F7;
border: 1px solid #EDEDEE;
color: $ds_heading;
background-color: $ds_surface_alt;
border: 1px solid $ds_line;
border-radius: 9px;
text-align: left;
font-weight: 500;
}
#PatientsPage QPushButton[summaryCard="true"]:hover {
color: #4F63D9;
background-color: #EEF1FA;
border-color: #8B9AD9;
color: $ds_accent;
background-color: $ds_accent_soft;
border-color: $ds_focus;
}
#PatientsPage QPushButton[rowAction="true"] {
min-height: 26px;
max-height: 26px;
padding: 0 7px;
color: #4F63D9;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
color: $ds_accent;
background-color: $ds_surface;
border: 1px solid $ds_line;
border-radius: 6px;
font-size: 13px;
font-weight: 400;
}
#PatientsPage QPushButton[rowAction="true"]:hover {
background-color: #EEF1FA;
border-color: #8B9AD9;
background-color: $ds_accent_soft;
border-color: $ds_focus;
}
#PatientsPage QPushButton[rowAction="true"][variant="danger"] {
color: #BE4B58;
background-color: #FFF7F8;
border-color: #F4C4CC;
color: $ds_danger;
background-color: $ds_danger_soft;
border-color: $ds_danger_soft;
}
#PatientsPage QTableWidget#PatientTable QHeaderView::section {
min-height: 34px;
background-color: #F7F7F7; font-size: 13px;
background-color: $ds_surface_alt; font-size: 13px;
}
#PatientsPage QTableWidget#PatientTable::item { padding: 5px 7px; }
#PatientsPage QTableWidget#PatientTable {
gridline-color: #EDEDEE;
selection-background-color: #EEF1FA;
selection-color: #1A1C1F; font-size: 14px;
gridline-color: $ds_line;
selection-background-color: $ds_accent_soft;
selection-color: $ds_heading; font-size: 14px;
}
#PatientsPage QCheckBox[patientSelector="true"]::indicator {
width: 13px;
height: 13px;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
background-color: $ds_surface;
border: 1px solid $ds_line;
border-radius: 2px;
}
#PatientsPage QCheckBox[patientSelector="true"]::indicator:checked {
background-color: #4F63D9;
border-color: #4F63D9;
background-color: $ds_accent;
border-color: $ds_accent;
}
#PatientsPage QPushButton[variant="ghost"]:checked {
color: #4F63D9;
background-color: #EEF1FA;
border: 1px solid #4F63D9;
color: $ds_accent;
background-color: $ds_accent_soft;
border: 1px solid $ds_accent;
}
#PatientsPage QPushButton[variant="ghost"]:checked:hover { background-color: #EEF1FA; }
#PatientsPage QPushButton[variant="ghost"]:checked:hover { background-color: $ds_accent_soft; }
#PatientsPage QPushButton[statusKind="info"]:checked {
color: #4F63D9;
border-color: #4F63D9;
color: $ds_accent;
border-color: $ds_accent;
}
#PatientsPage QPushButton[statusKind="warning"]:checked {
color: #A9691D;
border-color: #A9691D;
color: $ds_warning;
border-color: $ds_warning;
}
#PatientsPage QPushButton[statusKind="success"]:checked {
color: #287B65;
border-color: #287B65;
color: $ds_success;
border-color: $ds_success;
}
#PatientsPage QPushButton[statusKind="danger"]:checked {
color: #BE4B58;
border-color: #BE4B58;
color: $ds_danger;
border-color: $ds_danger;
}
#PatientsPage QLabel[metricKind="primary"] { color: #4F63D9; }
#PatientsPage QLabel[metricKind="info"] { color: #4F63D9; }
#PatientsPage QLabel[metricKind="success"] { color: #287B65; }
#PatientsPage QLabel[metricKind="warning"] { color: #A9691D; }
#PatientsPage QLabel[metricKind="danger"] { color: #BE4B58; }
#PatientsPage QLabel[metricKind="primary"] { color: $ds_accent; }
#PatientsPage QLabel[metricKind="info"] { color: $ds_accent; }
#PatientsPage QLabel[metricKind="success"] { color: $ds_success; }
#PatientsPage QLabel[metricKind="warning"] { color: $ds_warning; }
#PatientsPage QLabel[metricKind="danger"] { color: $ds_danger; }
#PatientsPage QTabWidget#PatientWorkspaceTabs::pane {
background-color: transparent;
border: 0;
top: -1px;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab {
color: #606163;
color: $ds_muted;
background-color: transparent;
border: 0;
border-bottom: 2px solid transparent;
font-weight: 400;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab:hover {
color: #4F63D9;
background-color: #EEF1FA;
color: $ds_accent;
background-color: $ds_accent_soft;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab:selected {
color: #4F63D9;
color: $ds_accent;
background-color: transparent;
border-bottom-color: #4F63D9;
border-bottom-color: $ds_accent;
font-weight: 500;
}
"""
""")
def _style_table_cell(table: SortableTable, row: int, column: int, kind: str) -> None:
@@ -1282,7 +1283,7 @@ class _PatientDateEdit(QDateEdit):
def paintEvent(self, event: Any) -> None:
super().paintEvent(event)
painter = QPainter(self)
glyph = icons.pixmap("calendar", "#5D6B80" if self.isEnabled() else "#8A97A9", 15)
glyph = icons.pixmap("calendar", PALETTE["muted"] if self.isEnabled() else PALETTE["disabled"], 15)
painter.drawPixmap(QRectF(self.width() - 24, (self.height() - 15) / 2, 15, 15), glyph, QRectF(glyph.rect()))
painter.end()
@@ -1300,18 +1301,18 @@ class _PatientSummaryButton(QPushButton):
label, _, count = self.text().partition("\n")
left = max(18, (self.width() - 204) // 2)
icon_rect = QRectF(left, (self.height() - 36) / 2, 36, 36)
glyph = icons.pixmap("calendar", "#1769E8", 36)
glyph = icons.pixmap("calendar", PALETTE["accent"], 36)
painter.drawPixmap(icon_rect, glyph, QRectF(glyph.rect()))
font = QFont(body_family())
font.setPixelSize(13)
painter.setFont(font)
painter.setPen(QColor("#5D6B80"))
painter.setPen(QColor(PALETTE["muted"]))
text_rect = self.rect().adjusted(left + 46, 10, -12, -32)
painter.drawText(text_rect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
painter.fontMetrics().elidedText(label, Qt.TextElideMode.ElideRight, text_rect.width()))
font.setPixelSize(16)
painter.setFont(font)
painter.setPen(QColor("#273244"))
painter.setPen(QColor(PALETTE["text"]))
painter.drawText(self.rect().adjusted(left + 46, 31, -12, -9),
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, count)
painter.end()
@@ -1324,11 +1325,11 @@ class _PatientInfoDelegate(QStyledItemDelegate):
painter.save()
selected = bool(option.state & QStyle.StateFlag.State_Selected)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
painter.fillRect(option.rect, QColor("#EAF2FF" if selected else "#F6F9FE" if hovered else "#FFFFFF"))
painter.setPen(QColor("#E6EDF6"))
painter.fillRect(option.rect, QColor(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
painter.setPen(QColor(PALETTE["line"]))
painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
if selected and index.column() == 0:
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor("#1769E8"))
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor(PALETTE["accent"]))
if index.column() in (0, 9):
painter.restore()
return
@@ -1337,9 +1338,9 @@ class _PatientInfoDelegate(QStyledItemDelegate):
font = QFont(body_family())
font.setPixelSize(14)
painter.setFont(font)
painter.setPen(QColor("#273244"))
painter.setPen(QColor(PALETTE["text"]))
def draw(text: str, target: Any, color: str = "#273244", centered: bool = False) -> None:
def draw(text: str, target: Any, color: str = PALETTE["text"], centered: bool = False) -> None:
painter.setPen(QColor(color))
text = painter.fontMetrics().elidedText(text, Qt.TextElideMode.ElideRight, target.width())
alignment = Qt.AlignmentFlag.AlignVCenter | (Qt.AlignmentFlag.AlignHCenter if centered else Qt.AlignmentFlag.AlignLeft)
@@ -1359,17 +1360,17 @@ class _PatientInfoDelegate(QStyledItemDelegate):
doctor = display_text(first_value(row, "appointment_doctor_name"), "")
status, _kind = _patient_status(row)
if not doctor:
draw(status, rect, "#5D6B80")
draw(status, rect, PALETTE["muted"])
else:
draw(doctor, top)
font.setPixelSize(13)
painter.setFont(font)
color, fill = ("#A9691D", "#FFF7EA") if status == "已过号" else ("#1769E8", "#F0F6FF")
color, fill = (PALETTE["warning"], PALETTE["warning_soft"]) if status == "已过号" else (PALETTE["accent"], PALETTE["accent_soft"])
if status == "已取消":
color, fill = "#5D6B80", "#F5F7FA"
color, fill = PALETTE["muted"], PALETTE["canvas"]
badge = QRectF(bottom.x(), bottom.y() + 1, min(bottom.width(), painter.fontMetrics().horizontalAdvance(status) + 10), 20)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setPen(QColor("#E7CDA8" if status == "已过号" else "#C7DAF7"))
painter.setPen(QColor(PALETTE["warning_soft"] if status == "已过号" else PALETTE["line_strong"]))
painter.setBrush(QColor(fill))
painter.drawRoundedRect(badge, 3, 3)
draw(status, badge.toRect(), color, True)
@@ -1385,7 +1386,7 @@ class _PatientInfoDelegate(QStyledItemDelegate):
draw(value, rect)
else:
text = str(index.data(Qt.ItemDataRole.DisplayRole) or "")
draw(text, rect, "#A9691D" if index.column() == 6 and text == "待确认" else "#273244", index.column() == 5)
draw(text, rect, PALETTE["warning"] if index.column() == 6 and text == "待确认" else PALETTE["text"], index.column() == 5)
painter.restore()
@@ -1493,7 +1494,7 @@ class PatientListWorkspace(QWidget):
self.keyword_edit.setMaximumWidth(360)
self.keyword_edit.setPlaceholderText("患者姓名 / 手机号 / 助理 / 医生")
self.keyword_edit.setClearButtonEnabled(True)
self.keyword_edit.addAction(icons.icon("search", "#5D6B80", 16), QLineEdit.ActionPosition.LeadingPosition)
self.keyword_edit.addAction(icons.icon("search", PALETTE["muted"], 16), QLineEdit.ActionPosition.LeadingPosition)
self.keyword_edit.returnPressed.connect(self.search)
search_row.addWidget(self.keyword_edit, 1)
self.status_label = QLabel("患者状态:")
@@ -1846,7 +1847,7 @@ class PatientListWorkspace(QWidget):
)
host = RowActions(row_actions, self.table)
if host.more_button is not None:
host.more_button.setIcon(icons.icon("chevron_down", "#5D6B80", 12))
host.more_button.setIcon(icons.icon("chevron_down", PALETTE["muted"], 12))
host.more_button.setIconSize(QSize(12, 12))
host.more_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
host.more_button.setLayoutDirection(Qt.LayoutDirection.RightToLeft)
@@ -2079,7 +2080,7 @@ class _OrderComboBox(QComboBox):
def paintEvent(self, event: Any) -> None:
super().paintEvent(event)
painter = QPainter(self)
glyph = icons.pixmap("chevron_down", "#5D6B80", 14)
glyph = icons.pixmap("chevron_down", PALETTE["muted"], 14)
painter.drawPixmap(QRectF(self.width() - 24, (self.height() - 14) / 2, 14, 14), glyph, QRectF(glyph.rect()))
painter.end()
@@ -2088,7 +2089,7 @@ class _OrderActionButton(QToolButton):
def paintEvent(self, event: Any) -> None:
super().paintEvent(event)
painter = QPainter(self)
glyph = icons.pixmap("chevron_down", "#5D6B80" if self.isEnabled() else "#97A4B6", 14)
glyph = icons.pixmap("chevron_down", PALETTE["muted"] if self.isEnabled() else PALETTE["disabled"], 14)
painter.drawPixmap(QRectF(self.width() - 23, (self.height() - 14) / 2, 14, 14), glyph, QRectF(glyph.rect()))
painter.end()
@@ -2107,18 +2108,18 @@ class _OrderInfoDelegate(QStyledItemDelegate):
painter.setClipRect(option.rect)
selected = bool(option.state & QStyle.StateFlag.State_Selected)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
painter.fillRect(option.rect, QColor("#F5F8FF" if selected else "#F8FAFE" if hovered else "#FFFFFF"))
painter.setPen(QColor("#E6EDF6"))
painter.fillRect(option.rect, QColor(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
painter.setPen(QColor(PALETTE["line"]))
painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
if selected and index.column() == 0:
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor("#1769E8"))
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor(PALETTE["accent"]))
rect = option.rect.adjusted(16, 0, -12, -1)
font = QFont(body_family())
font.setPixelSize(14)
painter.setFont(font)
text = str(index.data(Qt.ItemDataRole.DisplayRole) or "—")
def draw(value: str, target: Any, color: str = "#273244", right: bool = False) -> None:
def draw(value: str, target: Any, color: str = PALETTE["text"], right: bool = False) -> None:
painter.setPen(QColor(color))
value = painter.fontMetrics().elidedText(value, Qt.TextElideMode.ElideRight, target.width())
painter.drawText(target, Qt.AlignmentFlag.AlignVCenter | (Qt.AlignmentFlag.AlignRight if right else Qt.AlignmentFlag.AlignLeft), value)
@@ -2138,7 +2139,7 @@ class _OrderInfoDelegate(QStyledItemDelegate):
font.setWeight(QFont.Weight.Normal)
font.setPixelSize(13)
painter.setFont(font)
draw(secondary, bottom, "#5D6B80")
draw(secondary, bottom, PALETTE["muted"])
else:
draw(text, rect)
elif column in (9, 11):
@@ -2147,7 +2148,7 @@ class _OrderInfoDelegate(QStyledItemDelegate):
draw(primary, top)
font.setPixelSize(13)
painter.setFont(font)
draw(("(" if column == 9 else "") + secondary, bottom, "#5D6B80")
draw(("(" if column == 9 else "") + secondary, bottom, PALETTE["muted"])
else:
draw(text, rect)
elif column in (4, 5, 6):
@@ -2158,10 +2159,10 @@ class _OrderInfoDelegate(QStyledItemDelegate):
else:
kind = "blue" if raw in {3, 5, 6, 7, 8, 11} else "danger" if raw in {4, 9, 10} else "warning" if raw in {1, 2, 12} else "neutral"
foreground, background, border = {
"blue": ("#1769E8", "#F2F7FF", "#CEE0FA"),
"warning": ("#AD640C", "#FFFAF2", "#F2DABD"),
"danger": ("#BE4657", "#FFF5F6", "#F0D0D7"),
"neutral": ("#5D6B80", "#F6F8FC", "#E2E9F2"),
"blue": (PALETTE["accent"], PALETTE["accent_soft"], PALETTE["line_strong"]),
"warning": (PALETTE["warning"], PALETTE["warning_soft"], PALETTE["warning_soft"]),
"danger": (PALETTE["danger"], PALETTE["danger_soft"], PALETTE["danger_soft"]),
"neutral": (PALETTE["muted"], PALETTE["disabled_surface"], PALETTE["line"]),
}[kind]
font.setPixelSize(13)
painter.setFont(font)
@@ -2275,7 +2276,7 @@ class PatientOrdersWorkspace(QWidget):
self.keyword_edit.setMinimumWidth(240)
self.keyword_edit.setPlaceholderText("订单号 / 患者 / 手机号 / 处方ID / 诊单ID")
self.keyword_edit.setClearButtonEnabled(True)
self.keyword_edit.addAction(icons.icon("search", "#5D6B80", 16), QLineEdit.ActionPosition.LeadingPosition)
self.keyword_edit.addAction(icons.icon("search", PALETTE["muted"], 16), QLineEdit.ActionPosition.LeadingPosition)
self.keyword_edit.returnPressed.connect(self.search)
self.filter_top_row.addWidget(self.keyword_edit, 1)
self.audit_host = QWidget()
@@ -2747,11 +2748,11 @@ class _ProgressInfoDelegate(QStyledItemDelegate):
painter.setClipRect(option.rect)
selected = bool(option.state & QStyle.StateFlag.State_Selected)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
painter.fillRect(option.rect, QColor("#F2F7FF" if selected else "#F8FAFE" if hovered else "#FFFFFF"))
painter.setPen(QColor("#E6EDF6"))
painter.fillRect(option.rect, QColor(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
painter.setPen(QColor(PALETTE["line"]))
painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
if selected and index.column() == 0:
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor("#1769E8"))
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor(PALETTE["accent"]))
rect = option.rect.adjusted(16, 0, -16, -1)
font = QFont(body_family())
font.setPixelSize(14)
@@ -2762,20 +2763,20 @@ class _ProgressInfoDelegate(QStyledItemDelegate):
painter.setFont(font)
raw_text = index.data(Qt.ItemDataRole.DisplayRole)
text = "" if raw_text is None else str(raw_text)
color = "#273244"
color = PALETTE["text"]
if not self.schedule and index.column() == 5 and text and text != "—":
row = index.data(Qt.ItemDataRole.UserRole)
status = str(first_value(row, "queue_status", default="") or "").lower()
color = {
"consulting": "#1769E8", "next": "#1555B6",
"waiting": "#AD640C", "missed": "#BE4657",
}.get(status, "#5D6B80")
"consulting": PALETTE["accent"], "next": PALETTE["accent_hover"],
"waiting": PALETTE["warning"], "missed": PALETTE["danger"],
}.get(status, PALETTE["muted"])
painter.setPen(QColor(color))
alignment = Qt.AlignmentFlag.AlignVCenter
alignment |= Qt.AlignmentFlag.AlignHCenter if self.schedule and 1 <= index.column() <= 5 else Qt.AlignmentFlag.AlignLeft
painter.drawText(rect, alignment, painter.fontMetrics().elidedText(text, Qt.TextElideMode.ElideRight, rect.width()))
if option.state & QStyle.StateFlag.State_HasFocus:
painter.setPen(QColor("#75A5F0"))
painter.setPen(QColor(PALETTE["focus"]))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.drawRect(option.rect.adjusted(1, 1, -2, -2))
painter.restore()
@@ -2875,7 +2876,7 @@ class PatientProgressWorkspace(QWidget):
row = QHBoxLayout(frame)
row.setContentsMargins(0, 0, 0, 0)
row.setSpacing(0)
divider = QFrame()
divider = QFrame(frame)
divider.setObjectName("ProgressMetricDivider")
divider.setFixedSize(1, 60)
divider.setVisible(key != "total")
@@ -24,6 +24,7 @@ from PySide6.QtWidgets import (
)
from .. import motion
from ..design_system import PALETTE
from ..dialogs.prescription import PrescriptionTemplateDialog
from ..dialogs.prescription_ai import PrescriptionAiReportDialog, can_open_ai_explain
from ..filter_disclosure import FilterDisclosure
@@ -119,7 +120,7 @@ def _metric_card(title: str, kind: str = "accent", glyph: str = "layers") -> Met
icon.setProperty("metricIcon", True)
icon.setAlignment(Qt.AlignmentFlag.AlignCenter)
icon.setFixedSize(32, 32)
color = "#1769E8" if kind == "accent" else "#60789F"
color = PALETTE["accent"] if kind == "accent" else PALETTE["muted"]
icon.setPixmap(_painted_icon(glyph, color, 25).pixmap(25, 25))
card.layout().addWidget(icon)
return card
@@ -543,7 +544,7 @@ class PrescriptionLibraryPage(QWidget):
name_item = self.table.item(row_index, 1)
if name_item is not None:
name_item.setForeground(QColor("#1A1C1F"))
name_item.setForeground(QColor(PALETTE["heading"]))
font = name_item.font()
font.setWeight(QFont.Weight.Medium)
name_item.setFont(font)
@@ -50,6 +50,7 @@ from PySide6.QtWidgets import (
)
from .. import icons, motion
from ..design_system import PALETTE, clinical_stylesheet
from ..dialogs.issued_prescription_ai import (
PrescriptionAiStatisticsDialog,
agreement_safe_batch,
@@ -229,11 +230,11 @@ _ROLE_AVATAR = Qt.ItemDataRole.UserRole + 11
_ROLE_LEAD_ICON = Qt.ItemDataRole.UserRole + 12
_TAG_PALETTE = {
"accent": ("#4F63D9", "#EEF1FA"),
"success": ("#287B65", "#E7F8F1"),
"warning": ("#A9691D", "#FFF5DF"),
"danger": ("#BE4B58", "#FFF0F2"),
"neutral": ("#606163", "#F7F7F7"),
"accent": (PALETTE["accent"], PALETTE["accent_soft"]),
"success": (PALETTE["success"], PALETTE["success_soft"]),
"warning": (PALETTE["warning"], PALETTE["warning_soft"]),
"danger": (PALETTE["danger"], PALETTE["danger_soft"]),
"neutral": (PALETTE["muted"], PALETTE["surface_alt"]),
}
@@ -293,7 +294,7 @@ class _RowDecorationDelegate(QStyledItemDelegate):
glyph,
QRectF(glyph.rect()),
)
painter.setPen(QColor("#1A1C1F"))
painter.setPen(QColor(PALETTE["heading"]))
painter.setFont(style_option.font)
text_rect = rect.adjusted(28, 0, -8, 0)
painter.drawText(
@@ -306,17 +307,17 @@ class _RowDecorationDelegate(QStyledItemDelegate):
else:
initial = str(avatar)[:1] or "医"
circle = QRectF(rect.left() + 8, rect.center().y() - 10, 20, 20)
painter.setPen(QPen(QColor("#EDEDEE"), 1.0))
painter.setBrush(QColor("#F7F7F7"))
painter.setPen(QPen(QColor(PALETTE["line"]), 1.0))
painter.setBrush(QColor(PALETTE["surface_alt"]))
painter.drawEllipse(circle.adjusted(0.5, 0.5, -0.5, -0.5))
initial_font = QFont(style_option.font)
initial_font.setPixelSize(10)
initial_font.setWeight(QFont.Weight.Medium)
painter.setFont(initial_font)
painter.setPen(QColor("#6A6B6D"))
painter.setPen(QColor(PALETTE["muted"]))
painter.drawText(circle, Qt.AlignmentFlag.AlignCenter, initial)
painter.setFont(style_option.font)
painter.setPen(QColor("#1A1C1F"))
painter.setPen(QColor(PALETTE["heading"]))
name_rect = rect.adjusted(35, 0, -8, 0)
painter.drawText(
name_rect,
@@ -509,11 +510,11 @@ class _PrescriptionNumberDelegate(QStyledItemDelegate):
text_option.setWrapMode(QTextOption.WrapMode.WrapAtWordBoundaryOrAnywhere)
document.setDefaultTextOption(text_option)
paragraphs = [
f'<p style="margin:0;color:#1A1C1F;font-size:14px;font-weight:500">{escape(number)}</p>',
f'<p style="margin:2px 0 0;color:#606163;font-size:12px;font-weight:400">ID: {escape(record_id)}</p>',
f'<p style="margin:0;color:{PALETTE["heading"]};font-size:14px;font-weight:500">{escape(number)}</p>',
f'<p style="margin:2px 0 0;color:{PALETTE["muted"]};font-size:12px;font-weight:400">ID: {escape(record_id)}</p>',
]
paragraphs.extend(
'<p style="margin:2px 0 0;color:#BE4B58;font-size:13px;font-weight:400">'
f'<p style="margin:2px 0 0;color:{PALETTE["danger"]};font-size:13px;font-weight:400">'
+ escape(warning)
+ "</p>"
for warning in _order_warnings(row)
@@ -603,14 +604,14 @@ class _DoctorOptionDelegate(QStyledItemDelegate):
rect = option.rect.adjusted(2, 1, -2, -1)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#EAF2FF" if checked else "#F3F7FD" if hovered else "#FFFFFF"))
painter.setBrush(QColor(PALETTE["accent_soft"] if checked else PALETTE["canvas"] if hovered else PALETTE["surface"]))
painter.drawRoundedRect(rect, 5, 5)
box = QRectF(rect.left() + 10, rect.center().y() - 8, 16, 16)
painter.setPen(QPen(QColor("#1769E8" if checked else "#B8C7DA"), 1))
painter.setBrush(QColor("#1769E8" if checked else "#FFFFFF"))
painter.setPen(QPen(QColor(PALETTE["accent"] if checked else PALETTE["line_strong"]), 1))
painter.setBrush(QColor(PALETTE["accent"] if checked else PALETTE["surface"]))
painter.drawRoundedRect(box, 3, 3)
if checked:
pen = QPen(QColor("#FFFFFF"), 2)
pen = QPen(QColor(PALETTE["surface"]), 2)
pen.setCapStyle(Qt.PenCapStyle.RoundCap)
painter.setPen(pen)
x, y = int(box.x()), int(box.y())
@@ -619,16 +620,16 @@ class _DoctorOptionDelegate(QStyledItemDelegate):
font = QFont(body_family())
font.setPixelSize(13)
painter.setFont(font)
painter.setPen(QColor("#273244"))
painter.setPen(QColor(PALETTE["text"]))
text_rect = rect.adjusted(38, 0, -54, 0)
label = painter.fontMetrics().elidedText(str(index.data() or ""), Qt.TextElideMode.ElideRight, text_rect.width())
painter.drawText(text_rect, Qt.AlignmentFlag.AlignVCenter, label)
if checked:
painter.setPen(QColor("#1769E8"))
painter.setPen(QColor(PALETTE["accent"]))
painter.drawText(rect.adjusted(0, 0, -12, 0), Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter, "已选")
if option.state & QStyle.StateFlag.State_HasFocus:
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.setPen(QPen(QColor("#ADC8F2"), 1))
painter.setPen(QPen(QColor(PALETTE["line_strong"]), 1))
painter.drawRoundedRect(rect, 5, 5)
painter.restore()
@@ -674,18 +675,18 @@ class _DoctorSelectionDialog(QDialog):
self.setObjectName("DoctorSelectionDialog")
self.setWindowTitle("选择医生")
self.resize(420, 500)
self.setStyleSheet("""
QDialog#DoctorSelectionDialog { background: #FFFFFF; color: #273244; }
QListWidget#DoctorOptionsList { background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 6px; padding: 3px; }
QLabel#DoctorSelectionCount { color: #1769E8; font-size: 13px; }
QDialog#DoctorSelectionDialog QLineEdit { border: 1px solid #DBE5F2; border-radius: 6px; }
QDialog#DoctorSelectionDialog QLineEdit:focus { border-color: #1769E8; }
QDialog#DoctorSelectionDialog QPushButton { background: #FFFFFF; color: #273244; border: 1px solid #DBE5F2; border-radius: 6px; }
QDialog#DoctorSelectionDialog QPushButton:hover { background: #F3F7FD; border-color: #ADC8F2; }
QDialog#DoctorSelectionDialog QPushButton:disabled { color: #8A97A9; }
QDialog#DoctorSelectionDialog QPushButton#ConfirmDoctorSelection { background: #1769E8; color: #FFFFFF; border-color: #1769E8; }
QDialog#DoctorSelectionDialog QPushButton#ConfirmDoctorSelection:hover { background: #125DCE; border-color: #125DCE; }
""")
self.setStyleSheet(clinical_stylesheet("""
QDialog#DoctorSelectionDialog { background: $ds_surface; color: $ds_text; }
QListWidget#DoctorOptionsList { background: $ds_surface; border: 1px solid $ds_line; border-radius: 6px; padding: 3px; }
QLabel#DoctorSelectionCount { color: $ds_accent; font-size: 13px; }
QDialog#DoctorSelectionDialog QLineEdit { border: 1px solid $ds_line; border-radius: 6px; }
QDialog#DoctorSelectionDialog QLineEdit:focus { border-color: $ds_accent; }
QDialog#DoctorSelectionDialog QPushButton { background: $ds_surface; color: $ds_text; border: 1px solid $ds_line; border-radius: 6px; }
QDialog#DoctorSelectionDialog QPushButton:hover { background: $ds_canvas; border-color: $ds_line_strong; }
QDialog#DoctorSelectionDialog QPushButton:disabled { color: $ds_disabled; }
QDialog#DoctorSelectionDialog QPushButton#ConfirmDoctorSelection { background: $ds_accent; color: $ds_surface; border-color: $ds_accent; }
QDialog#DoctorSelectionDialog QPushButton#ConfirmDoctorSelection:hover { background: $ds_accent_hover; border-color: $ds_accent_hover; }
"""))
layout = QVBoxLayout(self)
layout.setContentsMargins(16, 16, 16, 16)
layout.setSpacing(10)
@@ -793,9 +794,9 @@ class DoctorMultiSelect(QWidget):
self.button.setText("、".join(names[:2]) + (f" 等{len(names)}人" if len(names) > 2 else ""))
def _blue_prescription_icon(kind: str, color: str = "#1769E8", size: int = 15) -> QIcon:
def _blue_prescription_icon(kind: str, color: str = PALETTE["accent"], size: int = 15) -> QIcon:
result = QIcon(icons.icon(kind, color, size))
result.addPixmap(icons.pixmap(kind, "#A4ADBA", size), QIcon.Mode.Disabled)
result.addPixmap(icons.pixmap(kind, PALETTE["disabled"], size), QIcon.Mode.Disabled)
return result
@@ -803,7 +804,7 @@ class _PrescriptionCombo(QComboBox):
def paintEvent(self, event: Any) -> None:
super().paintEvent(event)
painter = QPainter(self)
glyph = icons.pixmap("chevron_down", "#5D6B80", 14)
glyph = icons.pixmap("chevron_down", PALETTE["muted"], 14)
painter.drawPixmap(QRectF(self.width() - 25, (self.height() - 14) / 2, 14, 14), glyph, QRectF(glyph.rect()))
painter.end()
@@ -812,7 +813,7 @@ class _PrescriptionDateTime(QDateTimeEdit):
def paintEvent(self, event: Any) -> None:
super().paintEvent(event)
painter = QPainter(self)
glyph = icons.pixmap("calendar", "#5D6B80" if self.isEnabled() else "#8A97A9", 14)
glyph = icons.pixmap("calendar", PALETTE["muted"] if self.isEnabled() else PALETTE["disabled"], 14)
painter.drawPixmap(QRectF(self.width() - 25, (self.height() - 14) / 2, 14, 14), glyph, QRectF(glyph.rect()))
painter.end()
@@ -825,7 +826,7 @@ class _PrescriptionDoctorButton(QPushButton):
option.text = self.fontMetrics().elidedText(self.text(), Qt.TextElideMode.ElideRight, max(1, self.width() - 48))
painter = QPainter(self)
self.style().drawControl(QStyle.ControlElement.CE_PushButton, option, painter, self)
glyph = icons.pixmap("chevron_down", "#5D6B80", 14)
glyph = icons.pixmap("chevron_down", PALETTE["muted"], 14)
painter.drawPixmap(QRectF(self.width() - 25, (self.height() - 14) / 2, 14, 14), glyph, QRectF(glyph.rect()))
painter.end()
@@ -837,13 +838,13 @@ class _PrescriptionDoctorButton(QPushButton):
def _prescription_cell_background(painter: QPainter, option: Any, index: QModelIndex) -> None:
selected = bool(option.state & QStyle.StateFlag.State_Selected)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
painter.fillRect(option.rect, QColor("#F2F7FF" if selected else "#F8FAFE" if hovered else "#FFFFFF"))
painter.setPen(QColor("#E6EDF6"))
painter.fillRect(option.rect, QColor(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
painter.setPen(QColor(PALETTE["line"]))
painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
if selected and index.column() == 0:
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor("#1769E8"))
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor(PALETTE["accent"]))
if option.state & QStyle.StateFlag.State_HasFocus:
painter.setPen(QColor("#75A5F0"))
painter.setPen(QColor(PALETTE["focus"]))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.drawRect(option.rect.adjusted(1, 1, -2, -2))
@@ -875,7 +876,7 @@ class _PrescriptionInfoDelegate(QStyledItemDelegate):
font = QFont(body_family())
font.setPixelSize(14)
painter.setFont(font)
painter.setPen(QColor("#273244"))
painter.setPen(QColor(PALETTE["text"]))
text = str(index.data(Qt.ItemDataRole.DisplayRole) or "")
column = index.column()
if column == 0:
@@ -888,9 +889,9 @@ class _PrescriptionInfoDelegate(QStyledItemDelegate):
elif column in (3, 6):
kind = index.data(_ROLE_TAG_KIND)
foreground, background = {
"accent": ("#1769E8", "#EDF4FF"), "success": ("#1769E8", "#EDF4FF"),
"warning": ("#AD640C", "#FFF5E5"), "danger": ("#BE4657", "#FFF0F2"),
}.get(kind, ("#5D6B80", "#F5F8FD"))
"accent": (PALETTE["accent"], PALETTE["accent_soft"]), "success": (PALETTE["accent"], PALETTE["accent_soft"]),
"warning": (PALETTE["warning"], PALETTE["warning_soft"]), "danger": (PALETTE["danger"], PALETTE["danger_soft"]),
}.get(kind, (PALETTE["muted"], PALETTE["surface_alt"]))
font.setPixelSize(13)
painter.setFont(font)
label = painter.fontMetrics().elidedText(text, Qt.TextElideMode.ElideRight, max(1, rect.width() - 12))
@@ -918,7 +919,7 @@ class _PrescriptionInfoDelegate(QStyledItemDelegate):
font = QFont(body_family())
font.setPixelSize(13)
painter.setFont(font)
painter.setPen(QColor("#5D6B80"))
painter.setPen(QColor(PALETTE["muted"]))
second_rect = first_rect.translated(0, 26)
painter.drawText(second_rect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, painter.fontMetrics().elidedText(secondary, Qt.TextElideMode.ElideRight, rect.width()))
else:
@@ -942,11 +943,11 @@ class _PrescriptionNumberBlueDelegate(_PrescriptionNumberDelegate):
text_option.setWrapMode(QTextOption.WrapMode.WrapAtWordBoundaryOrAnywhere)
document.setDefaultTextOption(text_option)
paragraphs = [
f'<p style="margin:0;color:#273244;font-size:14px;font-weight:400">{escape(number)}</p>',
f'<p style="margin:6px 0 0;color:#5D6B80;font-size:13px;font-weight:400">ID: {escape(record_id)}</p>',
f'<p style="margin:0;color:{PALETTE["text"]};font-size:14px;font-weight:400">{escape(number)}</p>',
f'<p style="margin:6px 0 0;color:{PALETTE["muted"]};font-size:13px;font-weight:400">ID: {escape(record_id)}</p>',
]
paragraphs.extend(
'<p style="margin:6px 0 0;color:#BE4657;font-size:13px;font-weight:400">' + escape(warning) + "</p>"
f'<p style="margin:6px 0 0;color:{PALETTE["danger"]};font-size:13px;font-weight:400">' + escape(warning) + "</p>"
for warning in _order_warnings(row)
)
document.setHtml("".join(paragraphs))
@@ -976,7 +977,7 @@ class _PrescriptionBlueTable(SortableTable):
for button in widget.findChildren(QPushButton):
kind = {"查看处方": "eye", "编辑处方": "pencil", "删除处方": "trash"}.get(button.accessibleName())
if kind:
button.setIcon(_blue_prescription_icon(kind, "#BE4657" if kind == "trash" else "#1769E8"))
button.setIcon(_blue_prescription_icon(kind, PALETTE["danger"] if kind == "trash" else PALETTE["accent"]))
class PrescriptionsPage(QWidget):
@@ -1060,7 +1061,7 @@ class PrescriptionsPage(QWidget):
self.add_button.setObjectName("PrescriptionAddButton")
self.add_button.setMinimumWidth(122)
self.add_button.setProperty("variant", "primary")
self.add_button.setIcon(_blue_prescription_icon("plus", "#FFFFFF"))
self.add_button.setIcon(_blue_prescription_icon("plus", PALETTE["surface"]))
self.add_button.setIconSize(QSize(15, 15))
self.add_button.setCursor(Qt.CursorShape.PointingHandCursor)
self.add_button.setVisible(has_permission(permissions, "cf.prescription/add"))
@@ -1079,7 +1080,7 @@ class PrescriptionsPage(QWidget):
self.table_card = table_card
root.addWidget(table_card, 1)
for button, kind in ((self.view_button, "eye"), (self.edit_button, "pencil"), (self.delete_button, "trash")):
button.setIcon(_blue_prescription_icon(kind, "#BE4657" if kind == "trash" else "#1769E8"))
button.setIcon(_blue_prescription_icon(kind, PALETTE["danger"] if kind == "trash" else PALETTE["accent"]))
self._load_doctor_options()
def _build_filters(self) -> QWidget:
@@ -1226,7 +1227,7 @@ class PrescriptionsPage(QWidget):
refresh = QPushButton("刷新")
refresh.setProperty("variant", "ghost")
refresh.setCursor(Qt.CursorShape.PointingHandCursor)
refresh.setIcon(_blue_prescription_icon("refresh", "#5D6B80"))
refresh.setIcon(_blue_prescription_icon("refresh", PALETTE["muted"]))
refresh.setIconSize(QSize(15, 15))
refresh.clicked.connect(self.refresh)
toolbar.addWidget(refresh)
@@ -1287,7 +1288,7 @@ class PrescriptionsPage(QWidget):
self.table.setItemDelegate(_PrescriptionInfoDelegate(self.table))
self.table.setItemDelegateForColumn(1, _PrescriptionNumberBlueDelegate(self.table))
self.table.horizontalHeader().sectionResized.connect(self._number_column_resized)
self.table.horizontalHeaderItem(0).setIcon(_blue_prescription_icon("checkbox", "#8A97A9", 14))
self.table.horizontalHeaderItem(0).setIcon(_blue_prescription_icon("checkbox", PALETTE["disabled"], 14))
self.table.horizontalHeaderItem(0).setTextAlignment(Qt.AlignmentFlag.AlignCenter)
self.table.itemSelectionChanged.connect(self._selection_changed)
self.table.itemDoubleClicked.connect(lambda _item: self._view_selected())
@@ -1537,7 +1538,7 @@ class PrescriptionsPage(QWidget):
sn_item = self.table.item(row_index, 1)
if sn_item is not None:
sn_item.setForeground(QColor("#1A1C1F"))
sn_item.setForeground(QColor(PALETTE["heading"]))
font = sn_item.font()
font.setWeight(QFont.Weight.Normal)
sn_item.setFont(font)
@@ -75,6 +75,7 @@ from PySide6.QtWidgets import (
from ...core.appointment_modes import appointment_type_description, appointment_type_value
from .. import icons
from ..design_system import PALETTE, clinical_stylesheet
from ..diagnosis_drawer import DailyRecordPanel
from ..diagnosis_editors import FlowLayout
from ..dialogs import DiagnosisDialog
@@ -2020,7 +2021,7 @@ def _painted_reception_tab_icon(kind: str, size: int = 16) -> QIcon:
outline (bubble / chart page / capsule / clipboard / calendar-clock).
"""
return icons.icon(kind, "#5D6B80", size)
return icons.icon(kind, PALETTE["muted"], size)
def _painted_reception_action_icon(kind: str, color: str, size: int = 14) -> QIcon:
@@ -2882,7 +2883,7 @@ class _ReceptionSparkIcon(QWidget):
del event
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
glyph = icons.pixmap("ai", "#1769E8", 18)
glyph = icons.pixmap("ai", PALETTE["accent"], 18)
painter.drawPixmap(QRectF(0, 0, 18, 18), glyph, QRectF(glyph.rect()))
painter.end()
@@ -2896,9 +2897,9 @@ class _ReceptionAiSectionIcon(QWidget):
#: Section tone -> (plate, glyph tint, shared glyph name).
_TONES = {
"diagnosis": ("#EAF2FF", "#1769E8", "report"),
"risk": ("#EAF2FF", "#1769E8", "alert"),
"treatment": ("#EAF2FF", "#1769E8", "meds"),
"diagnosis": (PALETTE["accent_soft"], PALETTE["accent"], "report"),
"risk": (PALETTE["accent_soft"], PALETTE["accent"], "alert"),
"treatment": (PALETTE["accent_soft"], PALETTE["accent"], "meds"),
}
def __init__(self, tone: str, parent: QWidget | None = None) -> None:
@@ -2949,9 +2950,9 @@ class _ReceptionAssistantIcon(QWidget):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#1769E8"))
painter.setBrush(QColor(PALETTE["accent"]))
painter.drawRoundedRect(QRectF(1, 1, 22, 22), 4, 4)
painter.setPen(QColor("#FFFFFF"))
painter.setPen(QColor(PALETTE["surface"]))
font = painter.font()
font.setPixelSize(11)
font.setBold(True)
@@ -2975,7 +2976,7 @@ class _ReceptionSendButton(QPushButton):
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setPen(
QPen(
QColor("#FFFFFF"),
QColor(PALETTE["surface"]),
1.8,
Qt.PenStyle.SolidLine,
Qt.PenCapStyle.RoundCap,
@@ -3053,7 +3054,7 @@ class _ReceptionDateButton(QPushButton):
super().paintEvent(event)
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
color = QColor("#5D6B80")
color = QColor(PALETTE["muted"])
painter.setPen(
QPen(
color,
@@ -3087,7 +3088,7 @@ class _ReceptionAiExpandButton(QPushButton):
del event
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
color = QColor("#1769E8" if self.isEnabled() else "#8E8F90")
color = QColor(PALETTE["accent"] if self.isEnabled() else PALETTE["disabled"])
painter.setPen(
QPen(
color,
@@ -3120,7 +3121,7 @@ class _ReceptionAiModelCombo(QComboBox):
super().paintEvent(event)
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
color = QColor("#273244" if self.isEnabled() else "#8E8F90")
color = QColor(PALETTE["text"] if self.isEnabled() else PALETTE["disabled"])
painter.setPen(
QPen(
color,
@@ -3162,7 +3163,7 @@ class _ReceptionAiAnalysisDialog(QDialog):
self.resize(920, 760)
self.setMinimumSize(720, 560)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
self.setStyleSheet(RECEPTION_AI_DIALOG_QSS)
self.setStyleSheet(clinical_stylesheet(RECEPTION_AI_DIALOG_QSS))
root = QVBoxLayout(self)
root.setContentsMargins(18, 18, 18, 18)
@@ -3365,7 +3366,11 @@ class _ReceptionAiAnalysisDialog(QDialog):
source_label.setTextFormat(Qt.TextFormat.PlainText)
source_label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
source_label.setWordWrap(True)
source_label.setStyleSheet("color: #555B68; font-size: 12px; padding: 10px 14px; background: #F7F8FC; border: 1px solid #E4E8F2; border-radius: 8px;")
source_label.setStyleSheet(clinical_stylesheet(
"color: $ds_muted; font-size: 12px; padding: 10px 14px; "
"background: $ds_surface_alt; border: 1px solid $ds_line; "
"border-radius: $ds_radius_control;"
))
body_layout.addWidget(source_label)
self.source_label = source_label
body_layout.addStretch(1)
@@ -3614,9 +3619,9 @@ class _VitalMetricIcon(QWidget):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#EAF2FF"))
painter.setBrush(QColor(PALETTE["accent_soft"]))
painter.drawRoundedRect(QRectF(0, 0, 22, 22), 6, 6)
glyph = icons.pixmap(self._GLYPHS.get(self._kind, "pulse"), "#1769E8", 15)
glyph = icons.pixmap(self._GLYPHS.get(self._kind, "pulse"), PALETTE["accent"], 15)
painter.drawPixmap(QRectF(3.5, 3.5, 15, 15), glyph, QRectF(glyph.rect()))
painter.end()
@@ -3636,7 +3641,7 @@ class _LifestyleIcon(QWidget):
del event
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
glyph = icons.pixmap(self._GLYPHS.get(self._kind, "exercise"), "#5D6B80", 16)
glyph = icons.pixmap(self._GLYPHS.get(self._kind, "exercise"), PALETTE["muted"], 16)
painter.drawPixmap(QRectF(0, 0, 16, 16), glyph, QRectF(glyph.rect()))
painter.end()
@@ -3672,7 +3677,7 @@ class _GenderMark(QWidget):
return
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
pen = QPen(QColor("#5D6B80"), 1.35)
pen = QPen(QColor(PALETTE["muted"]), 1.35)
pen.setCapStyle(Qt.PenCapStyle.RoundCap)
pen.setJoinStyle(Qt.PenJoinStyle.RoundJoin)
painter.setPen(pen)
@@ -3737,7 +3742,7 @@ class _ReceptionQueueSpinner(QWidget):
del event
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
pen = QPen(QColor("#1769E8"), 2.2)
pen = QPen(QColor(PALETTE["accent"]), 2.2)
pen.setCapStyle(Qt.PenCapStyle.RoundCap)
painter.setPen(pen)
painter.drawArc(QRectF(2, 2, 14, 14), self._angle * 16, 250 * 16)
@@ -3873,15 +3878,15 @@ class QueueRow(QWidget):
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
rect = QRectF(self.rect()).adjusted(0.5, 0.5, -0.5, -0.5)
if self._selected:
painter.setBrush(QColor("#EAF2FF"))
painter.setPen(QPen(QColor("#E5ECF6"), 1))
painter.setBrush(QColor(PALETTE["accent_soft"]))
painter.setPen(QPen(QColor(PALETTE["line"]), 1))
else:
painter.setBrush(QColor("#FFFFFF"))
painter.setPen(QPen(QColor("#E5ECF6"), 1))
painter.drawRoundedRect(rect, 6, 6)
painter.setBrush(QColor(PALETTE["surface"]))
painter.setPen(QPen(QColor(PALETTE["line"]), 1))
painter.drawRoundedRect(rect, 10, 10)
if self._selected:
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#1769E8"))
painter.setBrush(QColor(PALETTE["accent"]))
painter.drawRoundedRect(QRectF(1.2, 1, 3.2, self.height() - 2), 1.6, 1.6)
@@ -4074,7 +4079,7 @@ class ReceptionDailyRecordsPanel(DailyRecordPanel):
font = item.font()
font.setWeight(QFont.Weight.DemiBold if high else QFont.Weight.Normal)
item.setFont(font)
item.setForeground(QBrush(QColor("#BE4B58" if high else "#273244")))
item.setForeground(QBrush(QColor(PALETTE["danger"] if high else PALETTE["text"])))
item.setBackground(
QBrush(
QColor(
@@ -4103,9 +4108,11 @@ class ReceptionPage(QWidget):
super().__init__(parent)
self.setObjectName("ReceptionPage")
self.setStyleSheet(
(RECEPTION_QSS + RECEPTION_WORKSPACE_QSS).replace("$body_family", body_family())
.replace("$heading_family", heading_family())
.replace("$number_family", number_family())
clinical_stylesheet(
(RECEPTION_QSS + RECEPTION_WORKSPACE_QSS).replace("$body_family", body_family())
.replace("$heading_family", heading_family())
.replace("$number_family", number_family())
)
)
self.repository = repository
self.permissions = permissions
@@ -4262,7 +4269,7 @@ class ReceptionPage(QWidget):
header_layout.addWidget(title)
header_layout.addStretch(1)
self.refresh_button = QPushButton("", header)
self.refresh_button.setIcon(icons.icon("refresh", "#5D6B80", 18))
self.refresh_button.setIcon(icons.icon("refresh", PALETTE["muted"], 18))
self.refresh_button.setObjectName("ReceptionRefreshButton")
self.refresh_button.setFixedSize(34, 32)
self.refresh_button.setAccessibleName("刷新接诊台")
@@ -4454,7 +4461,7 @@ class ReceptionPage(QWidget):
self.video_button.clicked.connect(self._request_video)
actions.addWidget(self.video_button)
self.more_button = QPushButton(hero)
self.more_button.setIcon(icons.icon("more", "#5D6B80", 16))
self.more_button.setIcon(icons.icon("more", PALETTE["muted"], 16))
self.more_button.setIconSize(QSize(16, 16))
self.more_button.setToolTip("更多操作")
self.more_button.setAccessibleName("更多操作")
@@ -5286,7 +5293,9 @@ class ReceptionPage(QWidget):
self.ai_source_label.setTextFormat(Qt.TextFormat.PlainText)
self.ai_source_label.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
self.ai_source_label.setWordWrap(True)
self.ai_source_label.setStyleSheet("color: #5B6474; font-size: 11px;")
self.ai_source_label.setStyleSheet(clinical_stylesheet(
"color: $ds_muted; font-size: 12px;"
))
analysis_layout.addWidget(self.ai_source_label)
self.ai_detail_actions_host = QWidget(analysis_card)
@@ -1,119 +1,126 @@
"""Scoped surfaces for the approved patient order-management workspace."""
from string import Template
from .reception_style import body_family
def patient_orders_stylesheet() -> str:
return Template(_ORDERS).substitute(body=body_family())
_ORDERS = """
#PatientOrdersWorkspace { background: transparent; color: #273244; }
#OrderWorkspaceContent, #OrderWorkspaceScroll { background: transparent; border: 0; }
#PatientOrdersWorkspace QLabel, #PatientOrdersWorkspace QPushButton,
#PatientOrdersWorkspace QToolButton, #PatientOrdersWorkspace QLineEdit,
#PatientOrdersWorkspace QComboBox, #PatientOrdersWorkspace QDateEdit,
#PatientOrdersWorkspace QCheckBox, #PatientOrdersWorkspace QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
}
#PatientOrdersWorkspace QLabel[role="muted"] { font-size: 13px; color: #5D6B80; }
#PatientOrdersWorkspace QFrame#OrderFilterCard,
#PatientOrdersWorkspace QFrame#OrderSummaryStrip,
#PatientOrdersWorkspace QFrame#OrderTableCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
}
#PatientOrdersWorkspace QPushButton, #PatientOrdersWorkspace QToolButton {
min-height: 38px; max-height: 38px; padding: 0 16px; border: 1px solid #DBE5F2;
border-radius: 5px; background: #FFFFFF; color: #273244;
}
#PatientOrdersWorkspace QPushButton:hover, #PatientOrdersWorkspace QToolButton:hover {
background: #F2F7FF; border-color: #B6CDEE; color: #1555B6;
}
#PatientOrdersWorkspace QPushButton:pressed, #PatientOrdersWorkspace QToolButton:pressed { background: #DCEAFF; }
#PatientOrdersWorkspace QPushButton:focus, #PatientOrdersWorkspace QToolButton:focus { border-color: #75A5F0; }
#PatientOrdersWorkspace QPushButton#OrderSearchButton,
#PatientOrdersWorkspace QPushButton#OrderDetailButton {
color: #FFFFFF; background: #1769E8; border-color: #1769E8;
}
#PatientOrdersWorkspace QPushButton#OrderSearchButton:hover,
#PatientOrdersWorkspace QPushButton#OrderDetailButton:hover { background: #155BCC; border-color: #155BCC; }
#PatientOrdersWorkspace QPushButton:disabled, #PatientOrdersWorkspace QToolButton:disabled {
color: #97A4B6; background: #F6F8FC; border-color: #E2E9F2;
}
#PatientOrdersWorkspace QLineEdit, #PatientOrdersWorkspace QComboBox,
#PatientOrdersWorkspace QDateEdit {
min-height: 38px; max-height: 38px; padding: 0 10px; font-size: 13px;
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 5px;
selection-background-color: #DCEAFF; selection-color: #273244;
}
#PatientOrdersWorkspace QLineEdit:focus, #PatientOrdersWorkspace QComboBox:focus,
#PatientOrdersWorkspace QDateEdit:focus { border-color: #75A5F0; }
#PatientOrdersWorkspace QLineEdit QToolButton {
min-height: 0; max-height: 24px; min-width: 0; border: 0; padding: 0; background: transparent;
}
#PatientOrdersWorkspace QComboBox { padding-right: 30px; }
#PatientOrdersWorkspace QComboBox::drop-down { border: 0; width: 28px; background: transparent; }
#PatientOrdersWorkspace QComboBox::down-arrow { image: none; width: 0; height: 0; }
#PatientOrdersWorkspace QComboBox QAbstractItemView {
font-family: "$body"; font-size: 13px; color: #273244; background: #FFFFFF;
border: 1px solid #DBE5F2; outline: 0; selection-background-color: #EAF2FF; selection-color: #1555B6;
}
#PatientOrdersWorkspace QComboBox QAbstractItemView::item { min-height: 30px; padding: 3px 10px; }
#PatientOrdersWorkspace QDateEdit { padding-right: 26px; }
#PatientOrdersWorkspace QDateEdit::drop-down { border: 0; width: 24px; background: transparent; }
#PatientOrdersWorkspace QDateEdit::down-arrow { image: none; width: 0; height: 0; }
#PatientOrdersWorkspace QDateEdit:disabled { color: #8A97A9; background: #F6F8FC; border-color: #E2E9F2; }
#PatientOrdersWorkspace QCalendarWidget {
font-family: "$body"; font-size: 13px; background: #FFFFFF; color: #273244;
}
#PatientOrdersWorkspace QCalendarWidget QWidget#qt_calendar_navigationbar { background: #F5F8FD; }
#PatientOrdersWorkspace QCalendarWidget QToolButton {
min-height: 28px; max-height: 28px; padding: 0 8px; border: 0; background: transparent;
font-family: "$body"; font-size: 13px; color: #273244;
}
#PatientOrdersWorkspace QCalendarWidget QToolButton:hover { background: #EAF2FF; }
#PatientOrdersWorkspace QCalendarWidget QAbstractItemView {
font-family: "$body"; font-size: 13px; background: #FFFFFF; alternate-background-color: #FFFFFF;
color: #273244; selection-background-color: #1769E8; selection-color: #FFFFFF; outline: 0;
}
#PatientOrdersWorkspace QCheckBox { spacing: 9px; font-size: 13px; }
#PatientOrdersWorkspace QCheckBox::indicator {
width: 15px; height: 15px; border: 1px solid #C5D5EB; border-radius: 3px; background: #FFFFFF;
}
#PatientOrdersWorkspace QCheckBox::indicator:checked { background: #1769E8; border-color: #1769E8; }
#PatientOrdersWorkspace QCheckBox::indicator:hover { border-color: #75A5F0; }
#PatientOrdersWorkspace QCheckBox:focus { color: #1555B6; }
#PatientOrdersWorkspace QFrame#OrderMetricCell { background: transparent; border: 0; }
#PatientOrdersWorkspace QFrame#OrderMetricDivider { border: 0; background: #DBE5F2; }
#PatientOrdersWorkspace QLabel[orderMetricCaption="true"] { color: #5D6B80; font-size: 13px; }
#PatientOrdersWorkspace QLabel[orderMetricValue="true"] { color: #273244; font-size: 18px; font-weight: 500; }
#PatientOrdersWorkspace QLabel#OrderAmountMetric { color: #1769E8; }
#PatientOrdersWorkspace QLabel[role="sectionTitle"] { font-size: 14px; font-weight: 600; }
#PatientOrdersWorkspace QTableWidget#OrderTable {
border: 1px solid #E6EDF6; border-radius: 0; background: #FFFFFF; alternate-background-color: #FFFFFF;
selection-background-color: #F5F8FF; selection-color: #273244; gridline-color: #E6EDF6;
}
#PatientOrdersWorkspace QTableWidget#OrderTable::item { padding: 0; border: 0; }
#PatientOrdersWorkspace QTableWidget#OrderTable QHeaderView::section {
min-height: 44px; padding: 0 16px; background: #F8FAFD; color: #5D6B80;
border: 0; border-bottom: 1px solid #E1E9F4;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PatientOrdersWorkspace QWidget#OrderActionBar { background: #FFFFFF; }
#PatientOrdersWorkspace QToolButton#OrderActionButton { padding-right: 28px; }
#PatientOrdersWorkspace QToolButton#OrderActionButton::menu-indicator { image: none; width: 0; height: 0; }
#PatientOrdersWorkspace QWidget#InfiniteList { background: #FFFFFF; border-top: 1px solid #E6EDF6; }
#PatientOrdersWorkspace QMenu, QMenu#OrderActionMenu {
font-family: "$body"; font-size: 13px; color: #273244; background: #FFFFFF;
border: 1px solid #DBE5F2; padding: 5px;
}
#PatientOrdersWorkspace QMenu::item, QMenu#OrderActionMenu::item { padding: 8px 24px; }
#PatientOrdersWorkspace QMenu::item:selected, QMenu#OrderActionMenu::item:selected { color: #1555B6; background: #EAF2FF; }
#PatientOrdersWorkspace QScrollBar:vertical { background: #F4F7FC; width: 7px; margin: 0; }
#PatientOrdersWorkspace QScrollBar:horizontal { background: #F4F7FC; height: 7px; margin: 0; }
#PatientOrdersWorkspace QScrollBar::handle { background: #C8D5E6; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PatientOrdersWorkspace QScrollBar::add-line, #PatientOrdersWorkspace QScrollBar::sub-line { width: 0; height: 0; }
#PatientOrdersWorkspace QScrollBar::add-page, #PatientOrdersWorkspace QScrollBar::sub-page { background: transparent; }
"""
"""Scoped surfaces for the approved patient order-management workspace."""
from string import Template
from .design_system import clinical_stylesheet
from .reception_style import body_family
def patient_orders_stylesheet() -> str:
return clinical_stylesheet(Template(_ORDERS).safe_substitute(body=body_family()))
_ORDERS = """
#PatientOrdersWorkspace { background: transparent; color: $ds_text; }
#OrderWorkspaceContent, #OrderWorkspaceScroll { background: transparent; border: 0; }
#PatientOrdersWorkspace QLabel, #PatientOrdersWorkspace QPushButton,
#PatientOrdersWorkspace QToolButton, #PatientOrdersWorkspace QLineEdit,
#PatientOrdersWorkspace QComboBox, #PatientOrdersWorkspace QDateEdit,
#PatientOrdersWorkspace QCheckBox, #PatientOrdersWorkspace QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#PatientOrdersWorkspace QLabel[role="muted"] { font-size: 13px; color: $ds_muted; }
#PatientOrdersWorkspace QFrame#OrderFilterCard,
#PatientOrdersWorkspace QFrame#OrderTableCard {
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PatientOrdersWorkspace QFrame#OrderSummaryStrip { background: transparent; border: 0; }
#PatientOrdersWorkspace QPushButton, #PatientOrdersWorkspace QToolButton {
min-height: 38px; max-height: 38px; padding: 0 16px; border: 1px solid transparent;
border-radius: $ds_radius_control; background: $ds_surface_alt; color: $ds_text;
}
#PatientOrdersWorkspace QPushButton:hover, #PatientOrdersWorkspace QToolButton:hover {
background: $ds_surface_alt; border-color: $ds_line_strong; color: $ds_accent;
}
#PatientOrdersWorkspace QPushButton:pressed, #PatientOrdersWorkspace QToolButton:pressed { background: $ds_accent_soft; }
#PatientOrdersWorkspace QPushButton:focus, #PatientOrdersWorkspace QToolButton:focus { border-color: $ds_focus; }
#PatientOrdersWorkspace QPushButton#OrderSearchButton,
#PatientOrdersWorkspace QPushButton#OrderDetailButton {
color: $ds_surface; background: $ds_accent; border-color: $ds_accent;
}
#PatientOrdersWorkspace QPushButton#OrderSearchButton:hover,
#PatientOrdersWorkspace QPushButton#OrderDetailButton:hover { background: $ds_accent_hover; border-color: $ds_accent_hover; }
#PatientOrdersWorkspace QPushButton#OrderSearchButton:pressed,
#PatientOrdersWorkspace QPushButton#OrderDetailButton:pressed { background: $ds_accent_pressed; border-color: $ds_accent_pressed; }
#PatientOrdersWorkspace QPushButton#OrderSearchButton:focus,
#PatientOrdersWorkspace QPushButton#OrderDetailButton:focus { border-color: $ds_focus; }
#PatientOrdersWorkspace QPushButton:disabled, #PatientOrdersWorkspace QToolButton:disabled,
#PatientOrdersWorkspace QPushButton#OrderSearchButton:disabled,
#PatientOrdersWorkspace QPushButton#OrderDetailButton:disabled {
color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line;
}
#PatientOrdersWorkspace QLineEdit, #PatientOrdersWorkspace QComboBox,
#PatientOrdersWorkspace QDateEdit {
min-height: 38px; max-height: 38px; padding: 0 10px; font-size: 13px;
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_control;
selection-background-color: $ds_accent_soft; selection-color: $ds_text;
}
#PatientOrdersWorkspace QLineEdit:focus, #PatientOrdersWorkspace QComboBox:focus,
#PatientOrdersWorkspace QDateEdit:focus { border-color: $ds_focus; }
#PatientOrdersWorkspace QLineEdit QToolButton {
min-height: 0; max-height: 24px; min-width: 0; border: 0; padding: 0; background: transparent;
}
#PatientOrdersWorkspace QComboBox { padding-right: 30px; }
#PatientOrdersWorkspace QComboBox::drop-down { border: 0; width: 28px; background: transparent; }
#PatientOrdersWorkspace QComboBox::down-arrow { image: none; width: 0; height: 0; }
#PatientOrdersWorkspace QComboBox QAbstractItemView {
font-family: "$body"; font-size: 13px; color: $ds_text; background: $ds_surface;
border: 1px solid $ds_line; outline: 0; selection-background-color: $ds_accent_soft; selection-color: $ds_accent;
}
#PatientOrdersWorkspace QComboBox QAbstractItemView::item { min-height: 30px; padding: 3px 10px; }
#PatientOrdersWorkspace QDateEdit { padding-right: 26px; }
#PatientOrdersWorkspace QDateEdit::drop-down { border: 0; width: 24px; background: transparent; }
#PatientOrdersWorkspace QDateEdit::down-arrow { image: none; width: 0; height: 0; }
#PatientOrdersWorkspace QDateEdit:disabled { color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line; }
#PatientOrdersWorkspace QCalendarWidget {
font-family: "$body"; font-size: 13px; background: $ds_surface; color: $ds_text;
}
#PatientOrdersWorkspace QCalendarWidget QWidget#qt_calendar_navigationbar { background: $ds_surface_alt; }
#PatientOrdersWorkspace QCalendarWidget QToolButton {
min-height: 28px; max-height: 28px; padding: 0 8px; border: 0; background: transparent;
font-family: "$body"; font-size: 13px; color: $ds_text;
}
#PatientOrdersWorkspace QCalendarWidget QToolButton:hover { background: $ds_accent_soft; }
#PatientOrdersWorkspace QCalendarWidget QAbstractItemView {
font-family: "$body"; font-size: 13px; background: $ds_surface; alternate-background-color: $ds_surface;
color: $ds_text; selection-background-color: $ds_accent; selection-color: $ds_surface; outline: 0;
}
#PatientOrdersWorkspace QCheckBox { spacing: 9px; font-size: 13px; }
#PatientOrdersWorkspace QCheckBox::indicator {
width: 15px; height: 15px; border: 1px solid $ds_line_strong; border-radius: 3px; background: $ds_surface;
}
#PatientOrdersWorkspace QCheckBox::indicator:checked { background: $ds_accent; border-color: $ds_accent; }
#PatientOrdersWorkspace QCheckBox::indicator:hover { border-color: $ds_focus; }
#PatientOrdersWorkspace QCheckBox:focus { color: $ds_accent; }
#PatientOrdersWorkspace QFrame#OrderMetricCell { background: transparent; border: 0; }
#PatientOrdersWorkspace QFrame#OrderMetricDivider { border: 0; background: $ds_line; }
#PatientOrdersWorkspace QLabel[orderMetricCaption="true"] { color: $ds_muted; font-size: 13px; }
#PatientOrdersWorkspace QLabel[orderMetricValue="true"] { color: $ds_text; font-size: 18px; font-weight: 500; }
#PatientOrdersWorkspace QLabel#OrderAmountMetric { color: $ds_accent; }
#PatientOrdersWorkspace QLabel[role="sectionTitle"] { font-size: 14px; font-weight: 600; }
#PatientOrdersWorkspace QTableWidget#OrderTable {
border: 0; border-radius: 0; background: $ds_surface; alternate-background-color: $ds_surface;
selection-background-color: $ds_accent_soft; selection-color: $ds_text; gridline-color: $ds_line;
}
#PatientOrdersWorkspace QTableWidget#OrderTable::item { padding: 0; border: 0; }
#PatientOrdersWorkspace QTableWidget#OrderTable QHeaderView::section {
min-height: 44px; padding: 0 16px; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PatientOrdersWorkspace QWidget#OrderActionBar { background: $ds_surface; }
#PatientOrdersWorkspace QToolButton#OrderActionButton { padding-right: 28px; }
#PatientOrdersWorkspace QToolButton#OrderActionButton::menu-indicator { image: none; width: 0; height: 0; }
#PatientOrdersWorkspace QWidget#InfiniteList { background: $ds_surface; border-top: 1px solid $ds_line; }
#PatientOrdersWorkspace QMenu, QMenu#OrderActionMenu {
font-family: "$body"; font-size: 13px; color: $ds_text; background: $ds_surface;
border: 1px solid $ds_line; padding: 5px;
}
#PatientOrdersWorkspace QMenu::item, QMenu#OrderActionMenu::item { padding: 8px 24px; }
#PatientOrdersWorkspace QMenu::item:selected, QMenu#OrderActionMenu::item:selected { color: $ds_accent; background: $ds_accent_soft; }
#PatientOrdersWorkspace QScrollBar:vertical { background: $ds_canvas; width: 7px; margin: 0; }
#PatientOrdersWorkspace QScrollBar:horizontal { background: $ds_canvas; height: 7px; margin: 0; }
#PatientOrdersWorkspace QScrollBar::handle { background: $ds_line_strong; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PatientOrdersWorkspace QScrollBar::add-line, #PatientOrdersWorkspace QScrollBar::sub-line { width: 0; height: 0; }
#PatientOrdersWorkspace QScrollBar::add-page, #PatientOrdersWorkspace QScrollBar::sub-page { background: transparent; }
"""
@@ -1,54 +1,55 @@
"""Local typography and surfaces for the approved consultation-progress page."""
from string import Template
from .reception_style import body_family
def patient_progress_stylesheet() -> str:
return Template(_PROGRESS).substitute(body=body_family())
_PROGRESS = """
#PatientProgressWorkspace { background: transparent; color: #273244; }
#ProgressWorkspaceContent, #ProgressWorkspaceScroll { background: transparent; border: 0; }
#PatientProgressWorkspace QLabel, #PatientProgressWorkspace QPushButton,
#PatientProgressWorkspace QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
}
#PatientProgressWorkspace QLabel[role="muted"] { font-size: 13px; color: #5D6B80; }
#PatientProgressWorkspace QLabel[role="sectionTitle"] { font-size: 14px; font-weight: 600; }
#PatientProgressWorkspace QLabel#EmptyStateGlyph {
font-size: 24px; color: #1769E8; background: #F2F7FF;
border: 1px solid #DBE5F2; border-radius: 22px;
}
#PatientProgressWorkspace QFrame#ProgressOverviewCard,
#PatientProgressWorkspace QFrame#ProgressScheduleCard,
#PatientProgressWorkspace QFrame#ProgressQueueCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
}
#PatientProgressWorkspace QFrame#ProgressMetricCell { background: transparent; border: 0; }
#PatientProgressWorkspace QFrame#ProgressMetricDivider { background: #DBE5F2; border: 0; }
#PatientProgressWorkspace QLabel[progressMetricValue="true"] { font-size: 18px; font-weight: 500; color: #273244; }
#PatientProgressWorkspace QLabel#ProgressTotalMetric { color: #1769E8; }
#PatientProgressWorkspace QSplitter#ProgressSplitter { background: transparent; }
#PatientProgressWorkspace QSplitter#ProgressSplitter::handle { background: transparent; }
#PatientProgressWorkspace QSplitter#ProgressSplitter::handle:hover { background: #EAF2FF; }
#PatientProgressWorkspace QTableWidget#ProgressScheduleTable,
#PatientProgressWorkspace QTableWidget#ProgressQueueTable {
border: 0; border-radius: 0; background: #FFFFFF; alternate-background-color: #FFFFFF;
selection-background-color: #F2F7FF; selection-color: #273244; gridline-color: #E6EDF6;
}
#PatientProgressWorkspace QTableWidget::item { border: 0; padding: 0; }
#PatientProgressWorkspace QHeaderView::section {
min-height: 0; padding: 0 16px; background: #F5F8FD; color: #5D6B80;
border: 0; border-bottom: 1px solid #E1E9F4;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PatientProgressWorkspace QWidget#InfiniteList { background: #FFFFFF; border-top: 1px solid #E6EDF6; }
#PatientProgressWorkspace QScrollBar:vertical { background: #F4F7FC; width: 7px; margin: 0; }
#PatientProgressWorkspace QScrollBar:horizontal { background: #F4F7FC; height: 7px; margin: 0; }
#PatientProgressWorkspace QScrollBar::handle { background: #C8D5E6; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PatientProgressWorkspace QScrollBar::add-line, #PatientProgressWorkspace QScrollBar::sub-line { width: 0; height: 0; }
#PatientProgressWorkspace QScrollBar::add-page, #PatientProgressWorkspace QScrollBar::sub-page { background: transparent; }
"""
"""Local typography and surfaces for the approved consultation-progress page."""
from string import Template
from .design_system import clinical_stylesheet
from .reception_style import body_family
def patient_progress_stylesheet() -> str:
return clinical_stylesheet(Template(_PROGRESS).safe_substitute(body=body_family()))
_PROGRESS = """
#PatientProgressWorkspace { background: transparent; color: $ds_text; }
#ProgressWorkspaceContent, #ProgressWorkspaceScroll { background: transparent; border: 0; }
#PatientProgressWorkspace QLabel, #PatientProgressWorkspace QPushButton,
#PatientProgressWorkspace QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#PatientProgressWorkspace QLabel[role="muted"] { font-size: 13px; color: $ds_muted; }
#PatientProgressWorkspace QLabel[role="sectionTitle"] { font-size: 14px; font-weight: 600; }
#PatientProgressWorkspace QLabel#EmptyStateGlyph {
font-size: 24px; color: $ds_accent; background: $ds_surface_alt;
border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PatientProgressWorkspace QFrame#ProgressScheduleCard,
#PatientProgressWorkspace QFrame#ProgressQueueCard {
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PatientProgressWorkspace QFrame#ProgressOverviewCard { background: transparent; border: 0; }
#PatientProgressWorkspace QFrame#ProgressMetricCell { background: transparent; border: 0; }
#PatientProgressWorkspace QFrame#ProgressMetricDivider { background: $ds_line; border: 0; }
#PatientProgressWorkspace QLabel[progressMetricValue="true"] { font-size: 18px; font-weight: 500; color: $ds_text; }
#PatientProgressWorkspace QLabel#ProgressTotalMetric { color: $ds_accent; }
#PatientProgressWorkspace QSplitter#ProgressSplitter { background: transparent; }
#PatientProgressWorkspace QSplitter#ProgressSplitter::handle { background: transparent; }
#PatientProgressWorkspace QSplitter#ProgressSplitter::handle:hover { background: $ds_accent_soft; }
#PatientProgressWorkspace QTableWidget#ProgressScheduleTable,
#PatientProgressWorkspace QTableWidget#ProgressQueueTable {
border: 0; border-radius: 0; background: $ds_surface; alternate-background-color: $ds_surface;
selection-background-color: $ds_accent_soft; selection-color: $ds_text; gridline-color: $ds_line;
}
#PatientProgressWorkspace QTableWidget::item { border: 0; padding: 0; }
#PatientProgressWorkspace QHeaderView::section {
min-height: 0; padding: 0 16px; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PatientProgressWorkspace QWidget#InfiniteList { background: $ds_surface; border-top: 1px solid $ds_line; }
#PatientProgressWorkspace QScrollBar:vertical { background: $ds_canvas; width: 7px; margin: 0; }
#PatientProgressWorkspace QScrollBar:horizontal { background: $ds_canvas; height: 7px; margin: 0; }
#PatientProgressWorkspace QScrollBar::handle { background: $ds_line_strong; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PatientProgressWorkspace QScrollBar::add-line, #PatientProgressWorkspace QScrollBar::sub-line { width: 0; height: 0; }
#PatientProgressWorkspace QScrollBar::add-page, #PatientProgressWorkspace QScrollBar::sub-page { background: transparent; }
"""
+154 -141
View File
@@ -1,141 +1,154 @@
"""Scoped technology-blue surfaces for the approved patient-list workspace."""
from string import Template
from .reception_style import body_family, heading_family
def patients_chrome_stylesheet() -> str:
return Template(_CHROME).substitute(body=body_family(), heading=heading_family())
def patient_list_stylesheet() -> str:
return Template(_LIST).substitute(body=body_family())
_CHROME = """
#PatientsPage { background: #F3F7FD; }
#PatientsPage QWidget#PageHeader QLabel {
font-family: "$body"; font-size: 13px; font-weight: 400; color: #5D6B80;
}
#PatientsPage QWidget#PageHeader QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: #202C3F;
}
#PatientsPage QPushButton#PatientRefreshButton {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
min-height: 38px; max-height: 38px; padding: 0 20px;
border: 1px solid #DBE5F2; border-radius: 5px; background: #FFFFFF;
}
#PatientsPage QPushButton#PatientRefreshButton:hover { background: #F2F7FF; border-color: #B6CDEE; }
#PatientsPage QTabWidget#PatientWorkspaceTabs::pane { border: 0; background: transparent; top: 0; }
#PatientsPage QTabWidget#PatientWorkspaceTabs > QTabBar::tab {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
min-width: 84px; min-height: 42px; padding: 0 10px; margin-right: 22px;
border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs > QTabBar::tab:selected {
color: #1769E8; border-bottom-color: #1769E8; background: transparent;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs > QTabBar::tab:hover { color: #1769E8; background: #EAF2FF; }
"""
_LIST = """
#PatientListWorkspace { background: transparent; color: #273244; }
#PatientWorkspaceContent, #PatientWorkspaceScroll { background: transparent; border: 0; }
#PatientListWorkspace QLabel, #PatientListWorkspace QPushButton,
#PatientListWorkspace QToolButton, #PatientListWorkspace QDateEdit,
#PatientListWorkspace QTableWidget, #PatientSearchToolbar QLineEdit,
#PatientSearchToolbar QPushButton {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
}
#PatientListWorkspace QLabel[role="muted"], #PatientListWorkspace QLabel[filterLabel="true"] {
color: #5D6B80; font-size: 13px;
}
#PatientListWorkspace QFrame#PatientFilterCard,
#PatientListWorkspace QFrame#PatientSummaryStrip,
#PatientListWorkspace QFrame#PatientListCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
}
#PatientListWorkspace QPushButton, #PatientSearchToolbar QPushButton {
min-height: 38px; max-height: 38px; padding: 0 16px;
border: 1px solid #DBE5F2; border-radius: 5px; background: #FFFFFF;
}
#PatientListWorkspace QPushButton:hover, #PatientSearchToolbar QPushButton:hover {
color: #1555B6; background: #F2F7FF; border-color: #B6CDEE;
}
#PatientListWorkspace QPushButton:pressed, #PatientSearchToolbar QPushButton:pressed { background: #DCEAFF; }
#PatientListWorkspace QPushButton:focus, #PatientSearchToolbar QPushButton:focus { border-color: #75A5F0; }
#PatientSearchToolbar QPushButton#PatientSearchButton {
min-height: 38px; max-height: 38px; color: #FFFFFF; background: #1769E8; border-color: #1769E8;
}
#PatientSearchToolbar QPushButton#PatientSearchButton:hover { background: #155BCC; }
#PatientSearchToolbar QLineEdit {
min-height: 38px; max-height: 38px; padding: 0 8px; background: #FFFFFF;
border: 1px solid #DBE5F2; border-radius: 5px; selection-background-color: #DCEAFF;
}
#PatientSearchToolbar QLineEdit:focus { border-color: #75A5F0; }
#PatientSearchToolbar QLineEdit QToolButton { border: 0; padding: 0; background: transparent; }
#PatientListWorkspace QPushButton[patientStatusChip="true"] {
min-height: 44px; max-height: 44px; padding: 0 16px; font-size: 13px;
color: #273244; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
}
#PatientListWorkspace QPushButton[patientStatusChip="true"]:checked {
color: #1769E8; border-bottom-color: #1769E8; background: transparent;
}
#PatientListWorkspace QPushButton[patientStatusChip="true"]:hover { color: #1769E8; background: #F2F7FF; }
#PatientListWorkspace QPushButton[patientQuickDate="true"] { padding: 0 12px; font-size: 13px; }
#PatientListWorkspace QPushButton[patientQuickDate="true"]:checked,
#PatientListWorkspace QPushButton#PatientCustomDateButton:checked {
color: #FFFFFF; background: #1769E8; border: 1px solid #1769E8;
}
#PatientListWorkspace QDateEdit {
min-height: 38px; max-height: 38px; padding: 0 8px; font-size: 13px;
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 5px;
selection-background-color: #DCEAFF;
}
#PatientListWorkspace QDateEdit:focus { border-color: #75A5F0; }
#PatientListWorkspace QDateEdit:disabled {
color: #8A97A9; background: #F6F8FC; border-color: #E2E9F2;
}
#PatientListWorkspace QDateEdit::drop-down { border: 0; width: 20px; background: transparent; }
#PatientListWorkspace QDateEdit::down-arrow { image: none; width: 0; height: 0; }
#PatientListWorkspace QPushButton[summaryCard="true"] {
min-height: 64px; max-height: 64px; padding: 0; background: transparent; border: 0; border-radius: 5px;
}
#PatientListWorkspace QPushButton[summaryCard="true"]:hover { background: #F2F7FF; }
#PatientListWorkspace QFrame#PatientSummaryDivider { border: 0; background: #E1E9F4; }
#PatientListWorkspace QWidget#PatientListHeading { background: transparent; }
#PatientListWorkspace QLabel[role="sectionTitle"] { font-size: 14px; font-weight: 600; color: #273244; }
#PatientListWorkspace QTableWidget#PatientTable {
background: #FFFFFF; alternate-background-color: #FFFFFF; border: 0; border-radius: 0;
selection-background-color: #EAF2FF; selection-color: #273244; gridline-color: #E6EDF6;
}
#PatientListWorkspace QTableWidget#PatientTable::item { padding: 0; border: 0; }
#PatientListWorkspace QTableWidget#PatientTable QHeaderView::section {
min-height: 41px; padding: 0 10px; background: #F5F8FD; color: #5D6B80;
border: 0; border-top: 1px solid #E6EDF6; border-bottom: 1px solid #E1E9F4;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PatientListWorkspace QWidget#RowActions, #PatientListWorkspace QWidget#PatientSelectorHost { background: transparent; }
#PatientListWorkspace QPushButton[rowAction="true"],
#PatientListWorkspace QToolButton#RowActionsMore {
min-height: 28px; max-height: 28px; padding: 0 5px; border: 0;
border-radius: 4px; background: transparent; color: #1769E8; font-size: 13px;
}
#PatientListWorkspace QToolButton#RowActionsMore { color: #273244; padding-right: 16px; }
#PatientListWorkspace QPushButton[rowAction="true"]:hover,
#PatientListWorkspace QToolButton#RowActionsMore:hover { background: #DCEAFF; }
#PatientListWorkspace QMenu { background: #FFFFFF; color: #273244; border: 1px solid #DBE5F2; padding: 4px; }
#PatientListWorkspace QMenu::item { padding: 7px 22px; font-size: 13px; }
#PatientListWorkspace QMenu::item:selected { background: #EAF2FF; color: #1555B6; }
#PatientListWorkspace QCheckBox[patientSelector="true"]::indicator {
width: 13px; height: 13px; background: #FFFFFF; border: 1px solid #CBDAED; border-radius: 3px;
}
#PatientListWorkspace QCheckBox[patientSelector="true"]::indicator:checked { background: #1769E8; border-color: #1769E8; }
#PatientListWorkspace QWidget#InfiniteList { background: #FFFFFF; border-top: 1px solid #E6EDF6; }
#PatientListWorkspace QScrollBar:vertical { background: #F4F7FC; width: 7px; margin: 0; }
#PatientListWorkspace QScrollBar:horizontal { background: #F4F7FC; height: 7px; margin: 0; }
#PatientListWorkspace QScrollBar::handle { background: #C8D5E6; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PatientListWorkspace QScrollBar::add-line, #PatientListWorkspace QScrollBar::sub-line { width: 0; height: 0; }
#PatientListWorkspace QScrollBar::add-page, #PatientListWorkspace QScrollBar::sub-page { background: transparent; }
"""
"""Quiet clinical surfaces for the patient-list workspace."""
from string import Template
from .design_system import clinical_stylesheet
from .reception_style import body_family, heading_family
def patients_chrome_stylesheet() -> str:
return clinical_stylesheet(Template(_CHROME).safe_substitute(body=body_family(), heading=heading_family()))
def patient_list_stylesheet() -> str:
return clinical_stylesheet(Template(_LIST).safe_substitute(body=body_family()))
_CHROME = """
#PatientsPage { background: $ds_canvas; }
#PatientsPage QWidget#PageHeader QLabel {
font-family: "$body"; font-size: 13px; font-weight: 400; color: $ds_muted;
}
#PatientsPage QWidget#PageHeader QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: $ds_heading;
}
#PatientsPage QPushButton#PatientRefreshButton {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
min-height: 38px; max-height: 38px; padding: 0 20px;
border: 1px solid transparent; border-radius: $ds_radius_control; background: $ds_surface_alt;
}
#PatientsPage QPushButton#PatientRefreshButton:hover { background: $ds_surface_alt; border-color: $ds_line_strong; }
#PatientsPage QPushButton#PatientRefreshButton:pressed { background: $ds_accent_soft; }
#PatientsPage QPushButton#PatientRefreshButton:focus { border-color: $ds_focus; }
#PatientsPage QPushButton#PatientRefreshButton:disabled { color: $ds_disabled; background: $ds_disabled_surface; }
#PatientsPage QTabWidget#PatientWorkspaceTabs::pane { border: 0; background: transparent; top: 0; }
#PatientsPage QTabWidget#PatientWorkspaceTabs > QTabBar::tab {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
min-width: 84px; min-height: 42px; padding: 0 10px; margin-right: 22px;
border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs > QTabBar::tab:selected {
color: $ds_accent; border-bottom-color: $ds_accent; background: transparent;
}
#PatientsPage QTabWidget#PatientWorkspaceTabs > QTabBar::tab:hover { color: $ds_accent; background: $ds_accent_soft; }
"""
_LIST = """
#PatientListWorkspace { background: transparent; color: $ds_text; }
#PatientWorkspaceContent, #PatientWorkspaceScroll { background: transparent; border: 0; }
#PatientListWorkspace QLabel, #PatientListWorkspace QPushButton,
#PatientListWorkspace QToolButton, #PatientListWorkspace QDateEdit,
#PatientListWorkspace QTableWidget, #PatientSearchToolbar QLineEdit,
#PatientSearchToolbar QPushButton {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#PatientListWorkspace QLabel[role="muted"], #PatientListWorkspace QLabel[filterLabel="true"] {
color: $ds_muted; font-size: 13px;
}
#PatientListWorkspace QFrame#PatientFilterCard,
#PatientListWorkspace QFrame#PatientListCard {
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PatientListWorkspace QFrame#PatientSummaryStrip { background: transparent; border: 0; }
#PatientListWorkspace QPushButton, #PatientSearchToolbar QPushButton {
min-height: 38px; max-height: 38px; padding: 0 16px;
border: 1px solid transparent; border-radius: $ds_radius_control; background: $ds_surface_alt;
}
#PatientListWorkspace QPushButton:hover, #PatientSearchToolbar QPushButton:hover {
color: $ds_accent; background: $ds_surface_alt; border-color: $ds_line_strong;
}
#PatientListWorkspace QPushButton:pressed, #PatientSearchToolbar QPushButton:pressed { background: $ds_accent_soft; }
#PatientListWorkspace QPushButton:focus, #PatientSearchToolbar QPushButton:focus { border-color: $ds_focus; }
#PatientSearchToolbar QPushButton#PatientSearchButton {
min-height: 38px; max-height: 38px; color: $ds_surface; background: $ds_accent; border-color: $ds_accent;
}
#PatientSearchToolbar QPushButton#PatientSearchButton:hover { background: $ds_accent_hover; }
#PatientSearchToolbar QPushButton#PatientSearchButton:pressed { background: $ds_accent_pressed; }
#PatientSearchToolbar QPushButton#PatientSearchButton:focus { border-color: $ds_focus; }
#PatientSearchToolbar QLineEdit {
min-height: 38px; max-height: 38px; padding: 0 8px; background: $ds_surface;
border: 1px solid $ds_line; border-radius: $ds_radius_control; selection-background-color: $ds_accent_soft;
}
#PatientSearchToolbar QLineEdit:focus { border-color: $ds_focus; }
#PatientSearchToolbar QLineEdit QToolButton { border: 0; padding: 0; background: transparent; }
#PatientListWorkspace QPushButton[patientStatusChip="true"] {
min-height: 44px; max-height: 44px; padding: 0 16px; font-size: 13px;
color: $ds_text; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent;
}
#PatientListWorkspace QPushButton[patientStatusChip="true"]:checked {
color: $ds_accent; border-bottom-color: $ds_accent; background: transparent;
}
#PatientListWorkspace QPushButton[patientStatusChip="true"]:hover { color: $ds_accent; background: $ds_surface_alt; }
#PatientListWorkspace QPushButton[patientStatusChip="true"]:focus { background: $ds_accent_soft; }
#PatientListWorkspace QPushButton[patientQuickDate="true"] { padding: 0 12px; font-size: 13px; }
#PatientListWorkspace QPushButton[patientQuickDate="true"]:checked,
#PatientListWorkspace QPushButton#PatientCustomDateButton:checked {
color: $ds_accent; background: $ds_accent_soft; border: 1px solid transparent; font-weight: 600;
}
#PatientListWorkspace QPushButton[patientQuickDate="true"]:focus,
#PatientListWorkspace QPushButton#PatientCustomDateButton:focus { border-color: $ds_focus; }
#PatientListWorkspace QDateEdit {
min-height: 38px; max-height: 38px; padding: 0 8px; font-size: 13px;
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_control;
selection-background-color: $ds_accent_soft;
}
#PatientListWorkspace QDateEdit:focus { border-color: $ds_focus; }
#PatientListWorkspace QDateEdit:disabled {
color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line;
}
#PatientListWorkspace QDateEdit::drop-down { border: 0; width: 20px; background: transparent; }
#PatientListWorkspace QDateEdit::down-arrow { image: none; width: 0; height: 0; }
#PatientListWorkspace QPushButton[summaryCard="true"] {
min-height: 64px; max-height: 64px; padding: 0; background: transparent;
border: 1px solid transparent; border-radius: $ds_radius_control;
}
#PatientListWorkspace QPushButton[summaryCard="true"]:hover { background: $ds_surface_alt; }
#PatientListWorkspace QPushButton[summaryCard="true"]:focus { border-color: $ds_focus; }
#PatientListWorkspace QFrame#PatientSummaryDivider { border: 0; background: $ds_line; }
#PatientListWorkspace QWidget#PatientListHeading { background: transparent; }
#PatientListWorkspace QLabel[role="sectionTitle"] { font-size: 14px; font-weight: 600; color: $ds_text; }
#PatientListWorkspace QTableWidget#PatientTable {
background: $ds_surface; alternate-background-color: $ds_surface; border: 0; border-radius: 0;
selection-background-color: $ds_accent_soft; selection-color: $ds_text; gridline-color: $ds_line;
}
#PatientListWorkspace QTableWidget#PatientTable::item { padding: 0; border: 0; }
#PatientListWorkspace QTableWidget#PatientTable QHeaderView::section {
min-height: 41px; padding: 0 10px; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-top: 1px solid $ds_line; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PatientListWorkspace QWidget#RowActions, #PatientListWorkspace QWidget#PatientSelectorHost { background: transparent; }
#PatientListWorkspace QPushButton[rowAction="true"],
#PatientListWorkspace QToolButton#RowActionsMore {
min-height: 28px; max-height: 28px; padding: 0 5px; border: 1px solid transparent;
border-radius: $ds_radius_small; background: transparent; color: $ds_accent; font-size: 13px;
}
#PatientListWorkspace QToolButton#RowActionsMore { color: $ds_text; padding-right: 16px; }
#PatientListWorkspace QPushButton[rowAction="true"]:hover,
#PatientListWorkspace QToolButton#RowActionsMore:hover { background: $ds_accent_soft; }
#PatientListWorkspace QPushButton[rowAction="true"]:focus,
#PatientListWorkspace QToolButton#RowActionsMore:focus { border-color: $ds_focus; }
#PatientListWorkspace QMenu { background: $ds_surface; color: $ds_text; border: 1px solid $ds_line; padding: 4px; }
#PatientListWorkspace QMenu::item { padding: 7px 22px; font-size: 13px; }
#PatientListWorkspace QMenu::item:selected { background: $ds_accent_soft; color: $ds_accent; }
#PatientListWorkspace QCheckBox[patientSelector="true"]::indicator {
width: 13px; height: 13px; background: $ds_surface; border: 1px solid $ds_line_strong; border-radius: 3px;
}
#PatientListWorkspace QCheckBox[patientSelector="true"]::indicator:checked { background: $ds_accent; border-color: $ds_accent; }
#PatientListWorkspace QWidget#InfiniteList { background: $ds_surface; border-top: 1px solid $ds_line; }
#PatientListWorkspace QScrollBar:vertical { background: $ds_canvas; width: 7px; margin: 0; }
#PatientListWorkspace QScrollBar:horizontal { background: $ds_canvas; height: 7px; margin: 0; }
#PatientListWorkspace QScrollBar::handle { background: $ds_line_strong; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PatientListWorkspace QScrollBar::add-line, #PatientListWorkspace QScrollBar::sub-line { width: 0; height: 0; }
#PatientListWorkspace QScrollBar::add-page, #PatientListWorkspace QScrollBar::sub-page { background: transparent; }
"""
@@ -1,410 +1,419 @@
"""Local technology-blue rendering for the approved prescription library."""
from __future__ import annotations
from collections.abc import Iterable, Sequence
from string import Template
from typing import Any
from PySide6.QtCore import QEvent, QModelIndex, QRectF, QSize, Qt, QTimer
from PySide6.QtGui import QColor, QFont, QFontMetrics, QIcon, QPainter
from PySide6.QtWidgets import (
QComboBox,
QPushButton,
QStyle,
QStyledItemDelegate,
QToolTip,
QWidget,
)
from .reception_style import body_family, heading_family
from .widgets import SortableTable, TableColumn, first_value
def library_stylesheet() -> str:
return Template(_LIBRARY).substitute(body=body_family(), heading=heading_family())
def _library_icon(kind: str, color: str = "#1769E8", size: int = 15) -> QIcon:
# Defer the page helper lookup so importing this module alone does not
# recurse through pages.__init__ and the library page's own style import.
from .pages.prescriptions import _painted_icon
result = QIcon()
for mode, tint in (
(QIcon.Mode.Normal, color),
(QIcon.Mode.Active, color),
(QIcon.Mode.Selected, color),
(QIcon.Mode.Disabled, "#A4ADBA"),
):
pixmap = _painted_icon(kind, tint, size).pixmap(QSize(size, size))
for state in (QIcon.State.Off, QIcon.State.On):
result.addPixmap(pixmap, mode, state)
return result
class LibraryComboBox(QComboBox):
"""Keep native combo interaction while painting the local caret."""
def paintEvent(self, event: Any) -> None: # noqa: N802 - Qt virtual
super().paintEvent(event)
painter = QPainter(self)
try:
rect = QRectF(self.width() - 25, (self.height() - 14) / 2, 14, 14)
mode = QIcon.Mode.Normal if self.isEnabled() else QIcon.Mode.Disabled
_library_icon("chevron_down", "#5D6B80", 14).paint(painter, rect.toRect(), mode=mode)
finally:
painter.end()
class LibraryTable(SortableTable):
"""Fit readable columns while preserving actions and selected template IDs."""
_FLEX_COLUMNS = ((1, 2), (4, 5), (5, 2))
def __init__(self, columns: Sequence[TableColumn], parent: QWidget | None = None) -> None:
super().__init__(columns, parent)
self.horizontalHeader().setStretchLastSection(False)
self._minimum_widths = tuple(column.width for column in self.columns)
self._manual_widths: dict[int, int] = {}
self._fitting_columns = False
self._fit_timer = QTimer(self)
self._fit_timer.setSingleShot(True)
self._fit_timer.timeout.connect(self._fit_columns)
self.horizontalHeader().sectionResized.connect(self._column_resized)
self.viewport().installEventFilter(self)
def eventFilter(self, watched: Any, event: QEvent) -> bool: # noqa: N802
if watched is self.viewport() and event.type() in {QEvent.Type.Resize, QEvent.Type.Show}:
self._schedule_column_fit()
return super().eventFilter(watched, event)
def _schedule_column_fit(self) -> None:
if not self._fit_timer.isActive():
self._fit_timer.start(0)
def _column_resized(self, column: int, _old_size: int, size: int) -> None:
if self._fitting_columns:
return
self._manual_widths[column] = max(self._minimum_widths[column], size)
self._schedule_column_fit()
def _fit_columns(self) -> None:
widths = [self._manual_widths.get(column, minimum)
for column, minimum in enumerate(self._minimum_widths)]
extra = max(0, self.viewport().width() - sum(widths))
flexible = [(column, weight) for column, weight in self._FLEX_COLUMNS
if column not in self._manual_widths]
# If every text column was manually sized, keep those preferences as
# minimums and let the herb preview absorb any remaining wide-screen space.
flexible = flexible or [(4, 1)]
total_weight = sum(weight for _column, weight in flexible)
for column, weight in flexible:
widths[column] += extra * weight // total_weight
widths[flexible[0][0]] += max(0, self.viewport().width() - sum(widths))
if widths == [self.columnWidth(column) for column in range(self.columnCount())]:
return
self._fitting_columns = True
try:
for column, width in enumerate(widths):
self.setColumnWidth(column, width)
finally:
self._fitting_columns = False
def set_rows(self, rows: Iterable[Any]) -> None:
selected_id = first_value(self.current_data(), "id", "template_id", default=None)
super().set_rows(rows)
# The shared table restores an unsorted row index after enabling sort.
# Locate the same source object in the finished visual order instead.
if selected_id is not None:
for row_index in range(self.rowCount()):
item = self.item(row_index, 0)
row = item.data(Qt.ItemDataRole.UserRole) if item is not None else None
row_id = first_value(row, "id", "template_id", default=None)
if row_id is not None and str(row_id) == str(selected_id):
self.selectRow(row_index)
return
self.clearSelection()
self.setCurrentCell(-1, -1)
def setCellWidget(self, row: int, column: int, widget: QWidget | None) -> None: # noqa: N802
super().setCellWidget(row, column, widget)
if widget is None or column != 9:
return
widget.setObjectName("PrescriptionLibraryTableCellHost")
widget.setAutoFillBackground(False)
glyphs = {
"查看处方模板": "eye",
"AI 解释": "spark",
"编辑处方模板": "pencil",
"删除处方模板": "trash",
}
for button in widget.findChildren(QPushButton):
if not button.property("rowAction"):
continue
glyph = glyphs.get(button.accessibleName()) or glyphs.get(button.toolTip())
if glyph is not None:
color = "#BE4657" if button.property("danger") else "#1769E8"
button.setIcon(_library_icon(glyph, color, button.iconSize().width()))
def _library_font(size: int = 14, *, medium: bool = False) -> QFont:
font = QFont(heading_family() if medium else body_family())
font.setPixelSize(size)
font.setWeight(QFont.Weight.Medium if medium else QFont.Weight.Normal)
return font
def _elide(text: str, metrics: QFontMetrics, width: int) -> str:
return metrics.elidedText(text, Qt.TextElideMode.ElideRight, max(1, width))
def _herb_lines(text: str, metrics: QFontMetrics, width: int) -> list[str]:
"""Wrap between complete herb entries; elide only the displayed lines."""
entries = text.split("、")
first = entries[0]
next_index = 1
while next_index < min(2, len(entries)):
candidate = first + "、" + entries[next_index]
if metrics.horizontalAdvance(candidate) > width:
break
first = candidate
next_index += 1
lines = [_elide(first, metrics, width)]
if next_index < len(entries):
lines.append(_elide("、".join(entries[next_index:]), metrics, width))
return lines
def _name_lines(text: str, metrics: QFontMetrics, width: int) -> list[str]:
if metrics.horizontalAdvance(text) <= width:
return [text]
split = 1
while split < len(text) and metrics.horizontalAdvance(text[: split + 1]) <= width:
split += 1
return [_elide(text[:split], metrics, width), _elide(text[split:], metrics, width)]
class LibraryItemDelegate(QStyledItemDelegate):
"""Paint the ten existing columns without changing display or source roles."""
def sizeHint(self, option: Any, index: QModelIndex) -> QSize: # noqa: N802
size = super().sizeHint(option, index)
size.setHeight(78)
return size
def helpEvent(self, event: Any, view: Any, option: Any, index: QModelIndex) -> bool: # noqa: N802
if event is not None and index.isValid() and index.column() != 9:
text = index.data(Qt.ItemDataRole.ToolTipRole) or index.data(Qt.ItemDataRole.DisplayRole)
if text:
QToolTip.showText(event.globalPos(), str(text), view)
return True
return super().helpEvent(event, view, option, index)
@staticmethod
def _paint_lines(
painter: QPainter,
rect: QRectF,
lines: list[str],
*,
secondary_muted: bool = False,
) -> None:
line_height = 26
top = rect.center().y() - len(lines) * line_height / 2
for line_index, line in enumerate(lines):
if secondary_muted and line_index:
painter.setFont(_library_font(13))
painter.setPen(QColor("#5D6B80"))
line_rect = QRectF(rect.left(), top + line_index * line_height, rect.width(), line_height)
painter.drawText(line_rect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, line)
def paint(self, painter: QPainter, option: Any, index: QModelIndex) -> None:
painter.save()
try:
painter.setClipRect(option.rect)
selected = bool(option.state & QStyle.StateFlag.State_Selected)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
background = "#F2F7FF" if selected else "#F8FAFE" if hovered else "#FFFFFF"
painter.fillRect(option.rect, QColor(background))
painter.setPen(QColor("#E6EDF6"))
painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
if selected and index.column() == 0:
stripe = QRectF(option.rect.left(), option.rect.top(), 3, option.rect.height() - 1)
painter.fillRect(stripe, QColor("#1769E8"))
if option.state & QStyle.StateFlag.State_HasFocus:
painter.setPen(QColor("#75A5F0"))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.drawRect(option.rect.adjusted(1, 1, -2, -2))
column = index.column()
if column == 9:
return
rect = QRectF(option.rect.adjusted(12, 0, -12, -1))
if rect.width() <= 0:
return
value = index.data(Qt.ItemDataRole.DisplayRole)
text = "" if value is None else str(value)
font = _library_font(medium=column == 1)
painter.setFont(font)
painter.setPen(QColor("#273244"))
metrics = QFontMetrics(font)
width = int(rect.width())
if column == 2:
painter.setFont(_library_font(13))
metrics = painter.fontMetrics()
label = _elide(text, metrics, width - 12)
pill_width = min(rect.width(), metrics.horizontalAdvance(label) + 14)
pill = QRectF(rect.center().x() - pill_width / 2, rect.center().y() - 12, pill_width, 24)
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor("#EAF2FF"))
painter.drawRoundedRect(pill, 4, 4)
painter.setPen(QColor("#1769E8"))
painter.drawText(pill, Qt.AlignmentFlag.AlignCenter, label)
elif column == 6:
glyph = "users" if text == "所有人可见" else "lock"
icon_rect = QRectF(rect.left(), rect.center().y() - 7, 14, 14)
_library_icon(glyph, "#5D6B80", 14).paint(painter, icon_rect.toRect())
label_rect = rect.adjusted(22, 0, 0, 0)
painter.drawText(
label_rect,
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
_elide(text, metrics, int(label_rect.width())),
)
elif column == 4:
self._paint_lines(painter, rect, _herb_lines(text, metrics, width))
elif column == 8:
parts = text.splitlines() if "\n" in text else text.rsplit(" ", 1)
lines = [_elide(parts[0], metrics, width)]
if len(parts) > 1:
lines.append(_elide(" ".join(parts[1:]), QFontMetrics(_library_font(13)), width))
self._paint_lines(painter, rect, lines, secondary_muted=True)
elif column == 1:
self._paint_lines(painter, rect, _name_lines(text, metrics, width))
else:
alignment = Qt.AlignmentFlag.AlignCenter if column in (0, 3, 5) else (
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
)
painter.drawText(rect, alignment, _elide(text, metrics, width))
finally:
painter.restore()
_LIBRARY = """
#PrescriptionLibraryPage { background: #F3F7FD; color: #273244; }
#PrescriptionLibraryPage QWidget#PrescriptionLibraryContent,
#PrescriptionLibraryPage QScrollArea#PrescriptionLibraryScroll,
#PrescriptionLibraryPage QScrollArea#PrescriptionLibraryToolbarScroll {
background: transparent; border: 0;
}
#PrescriptionLibraryPage QLabel, #PrescriptionLibraryPage QPushButton,
#PrescriptionLibraryPage QLineEdit, #PrescriptionLibraryPage QComboBox,
#PrescriptionLibraryPage QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
}
#PrescriptionLibraryPage QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: #202C3F;
}
#PrescriptionLibraryPage QLabel[role="muted"] { color: #5D6B80; font-size: 13px; }
#PrescriptionLibraryPage QFrame#MetricCard,
#PrescriptionLibraryPage QFrame#PrescriptionLibraryFilterBar,
#PrescriptionLibraryPage QFrame#PrescriptionLibraryTableCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
}
#PrescriptionLibraryPage QFrame#MetricCard QLabel[role="metricTitle"] {
font-family: "$body"; color: #5D6B80; font-size: 13px; font-weight: 400;
}
#PrescriptionLibraryPage QFrame#MetricCard QLabel[role="metricValue"] {
font-family: "$heading"; color: #273244; font-size: 18px; font-weight: 600;
}
#PrescriptionLibraryPage QFrame#MetricCard QLabel[metricIcon="true"] {
border: 0; border-radius: 0; background: transparent;
}
#PrescriptionLibraryPage QPushButton {
min-height: 38px; max-height: 38px; padding: 0 16px; border-radius: 5px;
border: 1px solid #DBE5F2; background: #FFFFFF; color: #273244;
}
#PrescriptionLibraryPage QPushButton:hover { background: #F2F7FF; border-color: #B6CDEE; color: #1555B6; }
#PrescriptionLibraryPage QPushButton:pressed { background: #DCEAFF; }
#PrescriptionLibraryPage QPushButton:focus { border-color: #75A5F0; }
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton {
background: #1769E8; border-color: #1769E8; color: #FFFFFF;
}
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:hover,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:hover {
background: #155BCC; border-color: #155BCC;
}
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:pressed,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:pressed {
background: #124EA9; border-color: #124EA9;
}
#PrescriptionLibraryPage QPushButton[variant="danger"] { color: #BE4657; border-color: #E9D8DE; }
#PrescriptionLibraryPage QPushButton:disabled,
#PrescriptionLibraryPage QPushButton[variant="danger"]:disabled {
color: #97A4B6; background: #F6F8FC; border-color: #E2E9F2;
}
#PrescriptionLibraryPage QLineEdit, #PrescriptionLibraryPage QComboBox {
min-height: 38px; max-height: 38px; padding: 0 12px; border: 1px solid #DBE5F2;
border-radius: 5px; background: #FFFFFF; color: #273244;
selection-background-color: #DCEAFF; selection-color: #273244;
}
#PrescriptionLibraryPage QLineEdit:focus, #PrescriptionLibraryPage QComboBox:focus { border-color: #75A5F0; }
#PrescriptionLibraryPage QLineEdit QToolButton { border: 0; background: transparent; padding: 0; }
#PrescriptionLibraryPage QComboBox { padding-right: 30px; font-size: 13px; }
#PrescriptionLibraryPage QComboBox::drop-down { width: 28px; border: 0; background: transparent; }
#PrescriptionLibraryPage QComboBox::down-arrow { image: none; width: 0; height: 0; }
#PrescriptionLibraryPage QComboBox:disabled { color: #97A4B6; background: #F6F8FC; }
#PrescriptionLibraryPage QComboBox QAbstractItemView {
font-family: "$body"; font-size: 13px; color: #273244; background: #FFFFFF;
border: 1px solid #DBE5F2; outline: 0; selection-background-color: #EAF2FF; selection-color: #1555B6;
}
#PrescriptionLibraryPage QComboBox QAbstractItemView::item { min-height: 30px; padding: 3px 10px; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar { background: transparent; border: 0; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton { padding: 0 12px; font-size: 13px; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"] {
min-width: 80px; min-height: 40px; max-height: 40px; padding: 0 10px; margin-right: 8px;
background: transparent; border: 0; border-bottom: 2px solid transparent;
border-radius: 0; color: #273244; font-size: 14px;
}
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"]:checked {
color: #1769E8; border-bottom-color: #1769E8;
}
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"]:hover {
color: #1555B6; background: #F2F7FF;
}
#PrescriptionLibraryPage QTableWidget {
border: 0; background: #FFFFFF; alternate-background-color: #FFFFFF;
selection-background-color: #F2F7FF; selection-color: #273244; gridline-color: #E6EDF6;
}
#PrescriptionLibraryPage QTableWidget::item { padding: 0; border: 0; }
#PrescriptionLibraryPage QHeaderView::section {
min-height: 0; padding: 0 12px; background: #F5F8FD; color: #5D6B80;
border: 0; border-bottom: 1px solid #DBE5F2;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PrescriptionLibraryPage QWidget#PrescriptionLibraryTableCellHost { background: transparent; border: 0; }
#PrescriptionLibraryPage QPushButton[rowAction="true"] {
min-width: 28px; max-width: 28px; min-height: 28px; max-height: 28px;
padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent;
}
#PrescriptionLibraryPage QPushButton[rowAction="true"]:hover { background: #EAF2FF; border-color: #B6CDEE; }
#PrescriptionLibraryPage QPushButton[rowAction="true"]:focus { border-color: #75A5F0; }
#PrescriptionLibraryPage QPushButton[rowAction="true"][danger="true"]:hover { background: #FFF0F2; border-color: #EAC8D0; }
#PrescriptionLibraryPage QPushButton[rowAction="true"]:disabled { background: transparent; border-color: transparent; color: #A4ADBA; }
#PrescriptionLibraryPage QWidget#InfiniteList { background: #FFFFFF; border-top: 1px solid #E6EDF6; }
#PrescriptionLibraryPage QLabel#EmptyStateGlyph {
font-size: 24px; color: #1769E8; background: #F2F7FF;
border: 1px solid #DBE5F2; border-radius: 22px;
}
#PrescriptionLibraryPage QWidget#EmptyState QLabel[role="muted"] { min-width: 300px; }
#PrescriptionLibraryPage QScrollBar:vertical { background: #F4F7FC; width: 7px; margin: 0; }
#PrescriptionLibraryPage QScrollBar:horizontal { background: #F4F7FC; height: 7px; margin: 0; }
#PrescriptionLibraryPage QScrollBar::handle { background: #C8D5E6; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PrescriptionLibraryPage QScrollBar::add-line, #PrescriptionLibraryPage QScrollBar::sub-line { width: 0; height: 0; }
#PrescriptionLibraryPage QScrollBar::add-page, #PrescriptionLibraryPage QScrollBar::sub-page { background: transparent; }
"""
__all__ = ["library_stylesheet", "LibraryComboBox", "LibraryTable", "LibraryItemDelegate"]
"""Shared clinical tokens for the prescription library and its native delegates."""
from __future__ import annotations
from collections.abc import Iterable, Sequence
from string import Template
from typing import Any
from PySide6.QtCore import QEvent, QModelIndex, QRectF, QSize, Qt, QTimer
from PySide6.QtGui import QColor, QFont, QFontMetrics, QIcon, QPainter
from PySide6.QtWidgets import (
QComboBox,
QPushButton,
QStyle,
QStyledItemDelegate,
QToolTip,
QWidget,
)
from .design_system import PALETTE, RADII, clinical_stylesheet
from .reception_style import body_family, heading_family
from .widgets import SortableTable, TableColumn, first_value
def library_stylesheet() -> str:
return clinical_stylesheet(Template(_LIBRARY).safe_substitute(body=body_family(), heading=heading_family()))
def _library_icon(kind: str, color: str = PALETTE["accent"], size: int = 15) -> QIcon:
# Defer the page helper lookup so importing this module alone does not
# recurse through pages.__init__ and the library page's own style import.
from .pages.prescriptions import _painted_icon
result = QIcon()
for mode, tint in (
(QIcon.Mode.Normal, color),
(QIcon.Mode.Active, color),
(QIcon.Mode.Selected, color),
(QIcon.Mode.Disabled, PALETTE["disabled"]),
):
pixmap = _painted_icon(kind, tint, size).pixmap(QSize(size, size))
for state in (QIcon.State.Off, QIcon.State.On):
result.addPixmap(pixmap, mode, state)
return result
class LibraryComboBox(QComboBox):
"""Keep native combo interaction while painting the local caret."""
def paintEvent(self, event: Any) -> None: # noqa: N802 - Qt virtual
super().paintEvent(event)
painter = QPainter(self)
try:
rect = QRectF(self.width() - 25, (self.height() - 14) / 2, 14, 14)
mode = QIcon.Mode.Normal if self.isEnabled() else QIcon.Mode.Disabled
_library_icon("chevron_down", PALETTE["muted"], 14).paint(painter, rect.toRect(), mode=mode)
finally:
painter.end()
class LibraryTable(SortableTable):
"""Fit readable columns while preserving actions and selected template IDs."""
_FLEX_COLUMNS = ((1, 2), (4, 5), (5, 2))
def __init__(self, columns: Sequence[TableColumn], parent: QWidget | None = None) -> None:
super().__init__(columns, parent)
self.horizontalHeader().setStretchLastSection(False)
self._minimum_widths = tuple(column.width for column in self.columns)
self._manual_widths: dict[int, int] = {}
self._fitting_columns = False
self._fit_timer = QTimer(self)
self._fit_timer.setSingleShot(True)
self._fit_timer.timeout.connect(self._fit_columns)
self.horizontalHeader().sectionResized.connect(self._column_resized)
self.viewport().installEventFilter(self)
def eventFilter(self, watched: Any, event: QEvent) -> bool: # noqa: N802
if watched is self.viewport() and event.type() in {QEvent.Type.Resize, QEvent.Type.Show}:
self._schedule_column_fit()
return super().eventFilter(watched, event)
def _schedule_column_fit(self) -> None:
if not self._fit_timer.isActive():
self._fit_timer.start(0)
def _column_resized(self, column: int, _old_size: int, size: int) -> None:
if self._fitting_columns:
return
self._manual_widths[column] = max(self._minimum_widths[column], size)
self._schedule_column_fit()
def _fit_columns(self) -> None:
widths = [self._manual_widths.get(column, minimum)
for column, minimum in enumerate(self._minimum_widths)]
extra = max(0, self.viewport().width() - sum(widths))
flexible = [(column, weight) for column, weight in self._FLEX_COLUMNS
if column not in self._manual_widths]
# If every text column was manually sized, keep those preferences as
# minimums and let the herb preview absorb any remaining wide-screen space.
flexible = flexible or [(4, 1)]
total_weight = sum(weight for _column, weight in flexible)
for column, weight in flexible:
widths[column] += extra * weight // total_weight
widths[flexible[0][0]] += max(0, self.viewport().width() - sum(widths))
if widths == [self.columnWidth(column) for column in range(self.columnCount())]:
return
self._fitting_columns = True
try:
for column, width in enumerate(widths):
self.setColumnWidth(column, width)
finally:
self._fitting_columns = False
def set_rows(self, rows: Iterable[Any]) -> None:
selected_id = first_value(self.current_data(), "id", "template_id", default=None)
super().set_rows(rows)
# The shared table restores an unsorted row index after enabling sort.
# Locate the same source object in the finished visual order instead.
if selected_id is not None:
for row_index in range(self.rowCount()):
item = self.item(row_index, 0)
row = item.data(Qt.ItemDataRole.UserRole) if item is not None else None
row_id = first_value(row, "id", "template_id", default=None)
if row_id is not None and str(row_id) == str(selected_id):
self.selectRow(row_index)
return
self.clearSelection()
self.setCurrentCell(-1, -1)
def setCellWidget(self, row: int, column: int, widget: QWidget | None) -> None: # noqa: N802
super().setCellWidget(row, column, widget)
if widget is None or column != 9:
return
widget.setObjectName("PrescriptionLibraryTableCellHost")
widget.setAutoFillBackground(False)
glyphs = {
"查看处方模板": "eye",
"AI 解释": "spark",
"编辑处方模板": "pencil",
"删除处方模板": "trash",
}
for button in widget.findChildren(QPushButton):
if not button.property("rowAction"):
continue
glyph = glyphs.get(button.accessibleName()) or glyphs.get(button.toolTip())
if glyph is not None:
color = PALETTE["danger"] if button.property("danger") else PALETTE["accent"]
button.setIcon(_library_icon(glyph, color, button.iconSize().width()))
def _library_font(size: int = 14, *, medium: bool = False) -> QFont:
font = QFont(heading_family() if medium else body_family())
font.setPixelSize(size)
font.setWeight(QFont.Weight.Medium if medium else QFont.Weight.Normal)
return font
def _elide(text: str, metrics: QFontMetrics, width: int) -> str:
return metrics.elidedText(text, Qt.TextElideMode.ElideRight, max(1, width))
def _herb_lines(text: str, metrics: QFontMetrics, width: int) -> list[str]:
"""Wrap between complete herb entries; elide only the displayed lines."""
entries = text.split("、")
first = entries[0]
next_index = 1
while next_index < min(2, len(entries)):
candidate = first + "、" + entries[next_index]
if metrics.horizontalAdvance(candidate) > width:
break
first = candidate
next_index += 1
lines = [_elide(first, metrics, width)]
if next_index < len(entries):
lines.append(_elide("、".join(entries[next_index:]), metrics, width))
return lines
def _name_lines(text: str, metrics: QFontMetrics, width: int) -> list[str]:
if metrics.horizontalAdvance(text) <= width:
return [text]
split = 1
while split < len(text) and metrics.horizontalAdvance(text[: split + 1]) <= width:
split += 1
return [_elide(text[:split], metrics, width), _elide(text[split:], metrics, width)]
class LibraryItemDelegate(QStyledItemDelegate):
"""Paint the ten existing columns without changing display or source roles."""
def sizeHint(self, option: Any, index: QModelIndex) -> QSize: # noqa: N802
size = super().sizeHint(option, index)
size.setHeight(78)
return size
def helpEvent(self, event: Any, view: Any, option: Any, index: QModelIndex) -> bool: # noqa: N802
if event is not None and index.isValid() and index.column() != 9:
text = index.data(Qt.ItemDataRole.ToolTipRole) or index.data(Qt.ItemDataRole.DisplayRole)
if text:
QToolTip.showText(event.globalPos(), str(text), view)
return True
return super().helpEvent(event, view, option, index)
@staticmethod
def _paint_lines(
painter: QPainter,
rect: QRectF,
lines: list[str],
*,
secondary_muted: bool = False,
) -> None:
line_height = 26
top = rect.center().y() - len(lines) * line_height / 2
for line_index, line in enumerate(lines):
if secondary_muted and line_index:
painter.setFont(_library_font(13))
painter.setPen(QColor(PALETTE["muted"]))
line_rect = QRectF(rect.left(), top + line_index * line_height, rect.width(), line_height)
painter.drawText(line_rect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, line)
def paint(self, painter: QPainter, option: Any, index: QModelIndex) -> None:
painter.save()
try:
painter.setClipRect(option.rect)
selected = bool(option.state & QStyle.StateFlag.State_Selected)
hovered = bool(option.state & QStyle.StateFlag.State_MouseOver)
background = PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]
painter.fillRect(option.rect, QColor(background))
painter.setPen(QColor(PALETTE["line"]))
painter.drawLine(option.rect.bottomLeft(), option.rect.bottomRight())
if selected and index.column() == 0:
stripe = QRectF(option.rect.left(), option.rect.top(), 3, option.rect.height() - 1)
painter.fillRect(stripe, QColor(PALETTE["accent"]))
if option.state & QStyle.StateFlag.State_HasFocus:
painter.setPen(QColor(PALETTE["focus"]))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.drawRect(option.rect.adjusted(1, 1, -2, -2))
column = index.column()
if column == 9:
return
rect = QRectF(option.rect.adjusted(12, 0, -12, -1))
if rect.width() <= 0:
return
value = index.data(Qt.ItemDataRole.DisplayRole)
text = "" if value is None else str(value)
font = _library_font(medium=column == 1)
painter.setFont(font)
painter.setPen(QColor(PALETTE["text"]))
metrics = QFontMetrics(font)
width = int(rect.width())
if column == 2:
painter.setFont(_library_font(13))
metrics = painter.fontMetrics()
label = _elide(text, metrics, width - 12)
pill_width = min(rect.width(), metrics.horizontalAdvance(label) + 14)
pill = QRectF(rect.center().x() - pill_width / 2, rect.center().y() - 12, pill_width, 24)
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(QColor(PALETTE["accent_soft"]))
painter.drawRoundedRect(pill, RADII["small"], RADII["small"])
painter.setPen(QColor(PALETTE["accent"]))
painter.drawText(pill, Qt.AlignmentFlag.AlignCenter, label)
elif column == 6:
glyph = "users" if text == "所有人可见" else "lock"
icon_rect = QRectF(rect.left(), rect.center().y() - 7, 14, 14)
_library_icon(glyph, PALETTE["muted"], 14).paint(painter, icon_rect.toRect())
label_rect = rect.adjusted(22, 0, 0, 0)
painter.drawText(
label_rect,
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
_elide(text, metrics, int(label_rect.width())),
)
elif column == 4:
self._paint_lines(painter, rect, _herb_lines(text, metrics, width))
elif column == 8:
parts = text.splitlines() if "\n" in text else text.rsplit(" ", 1)
lines = [_elide(parts[0], metrics, width)]
if len(parts) > 1:
lines.append(_elide(" ".join(parts[1:]), QFontMetrics(_library_font(13)), width))
self._paint_lines(painter, rect, lines, secondary_muted=True)
elif column == 1:
self._paint_lines(painter, rect, _name_lines(text, metrics, width))
else:
alignment = Qt.AlignmentFlag.AlignCenter if column in (0, 3, 5) else (
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
)
painter.drawText(rect, alignment, _elide(text, metrics, width))
finally:
painter.restore()
_LIBRARY = """
#PrescriptionLibraryPage { background: $ds_canvas; color: $ds_text; }
#PrescriptionLibraryPage QWidget#PrescriptionLibraryContent,
#PrescriptionLibraryPage QScrollArea#PrescriptionLibraryScroll,
#PrescriptionLibraryPage QScrollArea#PrescriptionLibraryToolbarScroll {
background: transparent; border: 0;
}
#PrescriptionLibraryPage QLabel, #PrescriptionLibraryPage QPushButton,
#PrescriptionLibraryPage QLineEdit, #PrescriptionLibraryPage QComboBox,
#PrescriptionLibraryPage QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#PrescriptionLibraryPage QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: $ds_heading;
}
#PrescriptionLibraryPage QLabel[role="muted"] { color: $ds_muted; font-size: 13px; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryFilterBar,
#PrescriptionLibraryPage QFrame#PrescriptionLibraryTableCard {
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PrescriptionLibraryPage QFrame#MetricCard { background: $ds_surface; border: 0; border-radius: $ds_radius_panel; }
#PrescriptionLibraryPage QFrame#MetricCard QLabel[role="metricTitle"] {
font-family: "$body"; color: $ds_muted; font-size: 13px; font-weight: 400;
}
#PrescriptionLibraryPage QFrame#MetricCard QLabel[role="metricValue"] {
font-family: "$heading"; color: $ds_text; font-size: 18px; font-weight: 600;
}
#PrescriptionLibraryPage QFrame#MetricCard QLabel[metricIcon="true"] {
border: 0; border-radius: 0; background: transparent;
}
#PrescriptionLibraryPage QPushButton {
min-height: 38px; max-height: 38px; padding: 0 16px; border-radius: $ds_radius_control;
border: 1px solid transparent; background: $ds_surface_alt; color: $ds_text;
}
#PrescriptionLibraryPage QPushButton:hover { background: $ds_surface_alt; border-color: $ds_line_strong; color: $ds_accent; }
#PrescriptionLibraryPage QPushButton:pressed { background: $ds_accent_soft; }
#PrescriptionLibraryPage QPushButton:focus { border-color: $ds_focus; }
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton {
background: $ds_accent; border-color: $ds_accent; color: $ds_surface;
}
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:hover,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:hover {
background: $ds_accent_hover; border-color: $ds_accent_hover;
}
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:pressed,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:pressed {
background: $ds_accent_pressed; border-color: $ds_accent_pressed;
}
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:focus,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:focus { border-color: $ds_focus; }
#PrescriptionLibraryPage QPushButton[variant="danger"] { color: $ds_danger; background: $ds_danger_soft; border-color: transparent; }
#PrescriptionLibraryPage QPushButton[variant="danger"]:hover { border-color: $ds_danger; }
#PrescriptionLibraryPage QPushButton[variant="danger"]:focus { border-color: $ds_focus; }
#PrescriptionLibraryPage QPushButton:disabled,
#PrescriptionLibraryPage QPushButton[variant="danger"]:disabled,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:disabled,
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:disabled {
color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line;
}
#PrescriptionLibraryPage QLineEdit, #PrescriptionLibraryPage QComboBox {
min-height: 38px; max-height: 38px; padding: 0 12px; border: 1px solid $ds_line;
border-radius: $ds_radius_control; background: $ds_surface; color: $ds_text;
selection-background-color: $ds_accent_soft; selection-color: $ds_text;
}
#PrescriptionLibraryPage QLineEdit:focus, #PrescriptionLibraryPage QComboBox:focus { border-color: $ds_focus; }
#PrescriptionLibraryPage QLineEdit QToolButton { border: 0; background: transparent; padding: 0; }
#PrescriptionLibraryPage QComboBox { padding-right: 30px; font-size: 13px; }
#PrescriptionLibraryPage QComboBox::drop-down { width: 28px; border: 0; background: transparent; }
#PrescriptionLibraryPage QComboBox::down-arrow { image: none; width: 0; height: 0; }
#PrescriptionLibraryPage QComboBox:disabled { color: $ds_disabled; background: $ds_disabled_surface; }
#PrescriptionLibraryPage QComboBox QAbstractItemView {
font-family: "$body"; font-size: 13px; color: $ds_text; background: $ds_surface;
border: 1px solid $ds_line; outline: 0; selection-background-color: $ds_accent_soft; selection-color: $ds_accent;
}
#PrescriptionLibraryPage QComboBox QAbstractItemView::item { min-height: 30px; padding: 3px 10px; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar { background: transparent; border: 0; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton { padding: 0 12px; font-size: 13px; }
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"] {
min-width: 80px; min-height: 40px; max-height: 40px; padding: 0 10px; margin-right: 8px;
background: transparent; border: 0; border-bottom: 2px solid transparent;
border-radius: 0; color: $ds_text; font-size: 14px;
}
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"]:checked {
color: $ds_accent; border-bottom-color: $ds_accent;
}
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"]:hover {
color: $ds_accent; background: $ds_surface_alt;
}
#PrescriptionLibraryPage QFrame#PrescriptionLibraryToolbar QPushButton[toolbarTab="true"]:focus { background: $ds_accent_soft; }
#PrescriptionLibraryPage QTableWidget {
border: 0; background: $ds_surface; alternate-background-color: $ds_surface;
selection-background-color: $ds_accent_soft; selection-color: $ds_text; gridline-color: $ds_line;
}
#PrescriptionLibraryPage QTableWidget::item { padding: 0; border: 0; }
#PrescriptionLibraryPage QHeaderView::section {
min-height: 0; padding: 0 12px; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PrescriptionLibraryPage QWidget#PrescriptionLibraryTableCellHost { background: transparent; border: 0; }
#PrescriptionLibraryPage QPushButton[rowAction="true"] {
min-width: 28px; max-width: 28px; min-height: 28px; max-height: 28px;
padding: 0; border: 1px solid transparent; border-radius: $ds_radius_small; background: transparent;
}
#PrescriptionLibraryPage QPushButton[rowAction="true"]:hover { background: $ds_accent_soft; border-color: $ds_line_strong; }
#PrescriptionLibraryPage QPushButton[rowAction="true"]:focus { border-color: $ds_focus; }
#PrescriptionLibraryPage QPushButton[rowAction="true"][danger="true"]:hover { background: $ds_danger_soft; border-color: $ds_danger_soft; }
#PrescriptionLibraryPage QPushButton[rowAction="true"][danger="true"]:focus { border-color: $ds_focus; }
#PrescriptionLibraryPage QPushButton[rowAction="true"]:disabled { background: transparent; border-color: transparent; color: $ds_disabled; }
#PrescriptionLibraryPage QWidget#InfiniteList { background: $ds_surface; border-top: 1px solid $ds_line; }
#PrescriptionLibraryPage QLabel#EmptyStateGlyph {
font-size: 24px; color: $ds_accent; background: $ds_surface_alt;
border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PrescriptionLibraryPage QWidget#EmptyState QLabel[role="muted"] { min-width: 300px; }
#PrescriptionLibraryPage QScrollBar:vertical { background: $ds_canvas; width: 7px; margin: 0; }
#PrescriptionLibraryPage QScrollBar:horizontal { background: $ds_canvas; height: 7px; margin: 0; }
#PrescriptionLibraryPage QScrollBar::handle { background: $ds_line_strong; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PrescriptionLibraryPage QScrollBar::add-line, #PrescriptionLibraryPage QScrollBar::sub-line { width: 0; height: 0; }
#PrescriptionLibraryPage QScrollBar::add-page, #PrescriptionLibraryPage QScrollBar::sub-page { background: transparent; }
"""
__all__ = ["library_stylesheet", "LibraryComboBox", "LibraryTable", "LibraryItemDelegate"]
@@ -1,107 +1,115 @@
"""Scoped surfaces and real fonts for the approved issued-prescription page."""
from string import Template
from .reception_style import body_family, heading_family
def prescriptions_stylesheet() -> str:
return Template(_PRESCRIPTIONS).substitute(body=body_family(), heading=heading_family())
_PRESCRIPTIONS = """
#PrescriptionsPage { background: #F3F7FD; color: #273244; }
#PrescriptionWorkspaceContent, #PrescriptionWorkspaceScroll { background: transparent; border: 0; }
#PrescriptionsPage QLabel, #PrescriptionsPage QPushButton, #PrescriptionsPage QLineEdit,
#PrescriptionsPage QComboBox, #PrescriptionsPage QDateTimeEdit, #PrescriptionsPage QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: #273244;
}
#PrescriptionsPage QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: #202C3F;
}
#PrescriptionsPage QLabel[role="sectionTitle"] {
font-family: "$heading"; font-size: 14px; font-weight: 600;
}
#PrescriptionsPage QLabel[role="muted"], #PrescriptionsPage QLabel#PrescriptionCountBadge {
color: #5D6B80; font-size: 13px; background: transparent; border: 0; padding: 0;
}
#PrescriptionsPage QFrame#PrescriptionFilterBar, #PrescriptionsPage QFrame#PrescriptionTableCard {
background: #FFFFFF; border: 1px solid #DBE5F2; border-radius: 8px;
}
#PrescriptionsPage QFrame#PrescriptionToolbar { background: transparent; border: 0; }
#PrescriptionsPage QPushButton {
min-height: 38px; max-height: 38px; padding: 0 16px; border-radius: 5px;
border: 1px solid #DBE5F2; background: #FFFFFF; color: #273244;
}
#PrescriptionsPage QPushButton:hover { background: #F2F7FF; border-color: #B6CDEE; color: #1555B6; }
#PrescriptionsPage QPushButton:pressed { background: #DCEAFF; }
#PrescriptionsPage QPushButton:focus { border-color: #75A5F0; }
#PrescriptionsPage QPushButton#PrescriptionAddButton, #PrescriptionsPage QPushButton#PrescriptionQueryButton {
background: #1769E8; color: #FFFFFF; border-color: #1769E8;
}
#PrescriptionsPage QPushButton#PrescriptionAddButton:hover, #PrescriptionsPage QPushButton#PrescriptionQueryButton:hover {
background: #155BCC; border-color: #155BCC;
}
#PrescriptionsPage QPushButton#PrescriptionAddButton:pressed, #PrescriptionsPage QPushButton#PrescriptionQueryButton:pressed {
background: #124EA9; border-color: #124EA9;
}
#PrescriptionsPage QPushButton[variant="danger"] { color: #BE4657; background: #FFFFFF; border-color: #E9D8DE; }
#PrescriptionsPage QPushButton:disabled, #PrescriptionsPage QPushButton[variant="danger"]:disabled {
color: #97A4B6; background: #F6F8FC; border-color: #E2E9F2;
}
#PrescriptionsPage QLineEdit, #PrescriptionsPage QComboBox, #PrescriptionsPage QDateTimeEdit {
min-height: 38px; max-height: 38px; padding: 0 12px; border: 1px solid #DBE5F2;
border-radius: 5px; background: #FFFFFF; color: #273244;
selection-background-color: #DCEAFF; selection-color: #273244;
}
#PrescriptionsPage QLineEdit:focus, #PrescriptionsPage QComboBox:focus, #PrescriptionsPage QDateTimeEdit:focus { border-color: #75A5F0; }
#PrescriptionsPage QLineEdit QToolButton { min-width: 0; min-height: 0; border: 0; background: transparent; padding: 0; }
#PrescriptionsPage QComboBox, #PrescriptionsPage QDateTimeEdit { padding-right: 30px; font-size: 13px; }
#PrescriptionsPage QComboBox::drop-down, #PrescriptionsPage QDateTimeEdit::drop-down { width: 28px; border: 0; background: transparent; }
#PrescriptionsPage QComboBox::down-arrow, #PrescriptionsPage QDateTimeEdit::down-arrow { image: none; width: 0; height: 0; }
#PrescriptionsPage QDateTimeEdit:disabled { color: #8A97A9; background: #F6F8FC; border-color: #E2E9F2; }
#PrescriptionsPage QPushButton#PrescriptionDoctorButton { text-align: left; padding-right: 30px; font-size: 13px; }
#PrescriptionsPage QComboBox QAbstractItemView {
font-family: "$body"; font-size: 13px; color: #273244; background: #FFFFFF;
border: 1px solid #DBE5F2; outline: 0; selection-background-color: #EAF2FF; selection-color: #1555B6;
}
#PrescriptionsPage QComboBox QAbstractItemView::item { min-height: 30px; padding: 3px 10px; }
#PrescriptionsPage QCalendarWidget { font-family: "$body"; font-size: 13px; background: #FFFFFF; color: #273244; }
#PrescriptionsPage QCalendarWidget QWidget#qt_calendar_navigationbar { background: #F5F8FD; }
#PrescriptionsPage QCalendarWidget QToolButton { min-height: 28px; border: 0; padding: 0 8px; color: #273244; background: transparent; }
#PrescriptionsPage QCalendarWidget QAbstractItemView { color: #273244; background: #FFFFFF; selection-background-color: #1769E8; selection-color: #FFFFFF; outline: 0; }
#PrescriptionsPage QFrame#PrescriptionToolbar QPushButton { padding: 0 12px; font-size: 13px; }
#PrescriptionsPage QTableWidget#PrescriptionTable {
border: 0; background: #FFFFFF; alternate-background-color: #FFFFFF;
selection-background-color: #F2F7FF; selection-color: #273244; gridline-color: #E6EDF6;
}
#PrescriptionsPage QTableWidget#PrescriptionTable::item { border: 0; padding: 0; }
#PrescriptionsPage QHeaderView::section {
min-height: 0; padding: 0 12px; background: #F5F8FD; color: #5D6B80;
border: 0; border-bottom: 1px solid #DBE5F2;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PrescriptionsPage QWidget#PrescriptionTableCellHost { border: 0; background: transparent; }
#PrescriptionsPage QPushButton[rowAction="true"] {
min-width: 28px; max-width: 28px; min-height: 28px; max-height: 28px;
padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent;
}
#PrescriptionsPage QPushButton[rowAction="true"][labeled="true"] {
min-width: 64px; max-width: 64px; color: #1769E8; font-size: 13px; padding: 0;
}
#PrescriptionsPage QPushButton[rowAction="true"]:hover { background: #EAF2FF; border-color: #B6CDEE; }
#PrescriptionsPage QPushButton[rowAction="true"]:focus { border-color: #75A5F0; }
#PrescriptionsPage QPushButton[rowAction="true"][danger="true"]:hover { background: #FFF0F2; border-color: #EAC8D0; }
#PrescriptionsPage QPushButton[rowAction="true"]:disabled,
#PrescriptionsPage QPushButton[rowAction="true"][labeled="true"]:disabled {
background: transparent; border-color: transparent; color: #A4ADBA;
}
#PrescriptionsPage QWidget#InfiniteList { background: #FFFFFF; border-top: 1px solid #E6EDF6; }
#PrescriptionsPage QLabel#EmptyStateGlyph { font-size: 24px; color: #1769E8; background: #F2F7FF; border: 1px solid #DBE5F2; border-radius: 22px; }
#PrescriptionsPage QWidget#EmptyState QLabel[role="muted"] { min-width: 300px; }
#PrescriptionsPage QScrollBar:vertical { background: #F4F7FC; width: 7px; margin: 0; }
#PrescriptionsPage QScrollBar:horizontal { background: #F4F7FC; height: 7px; margin: 0; }
#PrescriptionsPage QScrollBar::handle { background: #C8D5E6; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PrescriptionsPage QScrollBar::add-line, #PrescriptionsPage QScrollBar::sub-line { width: 0; height: 0; }
#PrescriptionsPage QScrollBar::add-page, #PrescriptionsPage QScrollBar::sub-page { background: transparent; }
"""
"""Scoped surfaces and real fonts for the approved issued-prescription page."""
from string import Template
from .design_system import clinical_stylesheet
from .reception_style import body_family, heading_family
def prescriptions_stylesheet() -> str:
return clinical_stylesheet(Template(_PRESCRIPTIONS).safe_substitute(body=body_family(), heading=heading_family()))
_PRESCRIPTIONS = """
#PrescriptionsPage { background: $ds_canvas; color: $ds_text; }
#PrescriptionWorkspaceContent, #PrescriptionWorkspaceScroll { background: transparent; border: 0; }
#PrescriptionsPage QLabel, #PrescriptionsPage QPushButton, #PrescriptionsPage QLineEdit,
#PrescriptionsPage QComboBox, #PrescriptionsPage QDateTimeEdit, #PrescriptionsPage QTableWidget {
font-family: "$body"; font-size: 14px; font-weight: 400; color: $ds_text;
}
#PrescriptionsPage QLabel[role="pageTitle"] {
font-family: "$heading"; font-size: 20px; font-weight: 600; color: $ds_heading;
}
#PrescriptionsPage QLabel[role="sectionTitle"] {
font-family: "$heading"; font-size: 14px; font-weight: 600;
}
#PrescriptionsPage QLabel[role="muted"], #PrescriptionsPage QLabel#PrescriptionCountBadge {
color: $ds_muted; font-size: 13px; background: transparent; border: 0; padding: 0;
}
#PrescriptionsPage QFrame#PrescriptionFilterBar, #PrescriptionsPage QFrame#PrescriptionTableCard {
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
}
#PrescriptionsPage QFrame#PrescriptionToolbar { background: transparent; border: 0; }
#PrescriptionsPage QPushButton {
min-height: 38px; max-height: 38px; padding: 0 16px; border-radius: $ds_radius_control;
border: 1px solid transparent; background: $ds_surface_alt; color: $ds_text;
}
#PrescriptionsPage QPushButton:hover { background: $ds_surface_alt; border-color: $ds_line_strong; color: $ds_accent; }
#PrescriptionsPage QPushButton:pressed { background: $ds_accent_soft; }
#PrescriptionsPage QPushButton:focus { border-color: $ds_focus; }
#PrescriptionsPage QPushButton#PrescriptionAddButton, #PrescriptionsPage QPushButton#PrescriptionQueryButton {
background: $ds_accent; color: $ds_surface; border-color: $ds_accent;
}
#PrescriptionsPage QPushButton#PrescriptionAddButton:hover, #PrescriptionsPage QPushButton#PrescriptionQueryButton:hover {
background: $ds_accent_hover; border-color: $ds_accent_hover;
}
#PrescriptionsPage QPushButton#PrescriptionAddButton:pressed, #PrescriptionsPage QPushButton#PrescriptionQueryButton:pressed {
background: $ds_accent_pressed; border-color: $ds_accent_pressed;
}
#PrescriptionsPage QPushButton#PrescriptionAddButton:focus,
#PrescriptionsPage QPushButton#PrescriptionQueryButton:focus { border-color: $ds_focus; }
#PrescriptionsPage QPushButton[variant="danger"] { color: $ds_danger; background: $ds_danger_soft; border-color: transparent; }
#PrescriptionsPage QPushButton[variant="danger"]:hover { border-color: $ds_danger; }
#PrescriptionsPage QPushButton[variant="danger"]:focus { border-color: $ds_focus; }
#PrescriptionsPage QPushButton:disabled, #PrescriptionsPage QPushButton[variant="danger"]:disabled,
#PrescriptionsPage QPushButton#PrescriptionAddButton:disabled,
#PrescriptionsPage QPushButton#PrescriptionQueryButton:disabled {
color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line;
}
#PrescriptionsPage QLineEdit, #PrescriptionsPage QComboBox, #PrescriptionsPage QDateTimeEdit {
min-height: 38px; max-height: 38px; padding: 0 12px; border: 1px solid $ds_line;
border-radius: $ds_radius_control; background: $ds_surface; color: $ds_text;
selection-background-color: $ds_accent_soft; selection-color: $ds_text;
}
#PrescriptionsPage QLineEdit:focus, #PrescriptionsPage QComboBox:focus, #PrescriptionsPage QDateTimeEdit:focus { border-color: $ds_focus; }
#PrescriptionsPage QLineEdit QToolButton { min-width: 0; min-height: 0; border: 0; background: transparent; padding: 0; }
#PrescriptionsPage QComboBox, #PrescriptionsPage QDateTimeEdit { padding-right: 30px; font-size: 13px; }
#PrescriptionsPage QComboBox::drop-down, #PrescriptionsPage QDateTimeEdit::drop-down { width: 28px; border: 0; background: transparent; }
#PrescriptionsPage QComboBox::down-arrow, #PrescriptionsPage QDateTimeEdit::down-arrow { image: none; width: 0; height: 0; }
#PrescriptionsPage QDateTimeEdit:disabled { color: $ds_disabled; background: $ds_disabled_surface; border-color: $ds_line; }
#PrescriptionsPage QPushButton#PrescriptionDoctorButton { text-align: left; padding-right: 30px; font-size: 13px; }
#PrescriptionsPage QComboBox QAbstractItemView {
font-family: "$body"; font-size: 13px; color: $ds_text; background: $ds_surface;
border: 1px solid $ds_line; outline: 0; selection-background-color: $ds_accent_soft; selection-color: $ds_accent;
}
#PrescriptionsPage QComboBox QAbstractItemView::item { min-height: 30px; padding: 3px 10px; }
#PrescriptionsPage QCalendarWidget { font-family: "$body"; font-size: 13px; background: $ds_surface; color: $ds_text; }
#PrescriptionsPage QCalendarWidget QWidget#qt_calendar_navigationbar { background: $ds_surface_alt; }
#PrescriptionsPage QCalendarWidget QToolButton { min-height: 28px; border: 0; padding: 0 8px; color: $ds_text; background: transparent; }
#PrescriptionsPage QCalendarWidget QAbstractItemView { color: $ds_text; background: $ds_surface; selection-background-color: $ds_accent; selection-color: $ds_surface; outline: 0; }
#PrescriptionsPage QFrame#PrescriptionToolbar QPushButton { padding: 0 12px; font-size: 13px; }
#PrescriptionsPage QTableWidget#PrescriptionTable {
border: 0; background: $ds_surface; alternate-background-color: $ds_surface;
selection-background-color: $ds_accent_soft; selection-color: $ds_text; gridline-color: $ds_line;
}
#PrescriptionsPage QTableWidget#PrescriptionTable::item { border: 0; padding: 0; }
#PrescriptionsPage QHeaderView::section {
min-height: 0; padding: 0 12px; background: $ds_surface_alt; color: $ds_muted;
border: 0; border-bottom: 1px solid $ds_line;
font-family: "$body"; font-size: 13px; font-weight: 400;
}
#PrescriptionsPage QWidget#PrescriptionTableCellHost { border: 0; background: transparent; }
#PrescriptionsPage QPushButton[rowAction="true"] {
min-width: 28px; max-width: 28px; min-height: 28px; max-height: 28px;
padding: 0; border: 1px solid transparent; border-radius: $ds_radius_small; background: transparent;
}
#PrescriptionsPage QPushButton[rowAction="true"][labeled="true"] {
min-width: 64px; max-width: 64px; color: $ds_accent; font-size: 13px; padding: 0;
}
#PrescriptionsPage QPushButton[rowAction="true"]:hover { background: $ds_accent_soft; border-color: $ds_line_strong; }
#PrescriptionsPage QPushButton[rowAction="true"]:focus { border-color: $ds_focus; }
#PrescriptionsPage QPushButton[rowAction="true"][danger="true"]:hover { background: $ds_danger_soft; border-color: $ds_danger_soft; }
#PrescriptionsPage QPushButton[rowAction="true"][danger="true"]:focus { border-color: $ds_focus; }
#PrescriptionsPage QPushButton[rowAction="true"]:disabled,
#PrescriptionsPage QPushButton[rowAction="true"][labeled="true"]:disabled {
background: transparent; border-color: transparent; color: $ds_disabled;
}
#PrescriptionsPage QWidget#InfiniteList { background: $ds_surface; border-top: 1px solid $ds_line; }
#PrescriptionsPage QLabel#EmptyStateGlyph { font-size: 24px; color: $ds_accent; background: $ds_surface_alt; border: 1px solid $ds_line; border-radius: $ds_radius_panel; }
#PrescriptionsPage QWidget#EmptyState QLabel[role="muted"] { min-width: 300px; }
#PrescriptionsPage QScrollBar:vertical { background: $ds_canvas; width: 7px; margin: 0; }
#PrescriptionsPage QScrollBar:horizontal { background: $ds_canvas; height: 7px; margin: 0; }
#PrescriptionsPage QScrollBar::handle { background: $ds_line_strong; border-radius: 3px; min-width: 24px; min-height: 24px; }
#PrescriptionsPage QScrollBar::add-line, #PrescriptionsPage QScrollBar::sub-line { width: 0; height: 0; }
#PrescriptionsPage QScrollBar::add-page, #PrescriptionsPage QScrollBar::sub-page { background: transparent; }
"""
@@ -4,23 +4,24 @@ from __future__ import annotations
from PySide6.QtWidgets import QApplication
from .design_system import PALETTE
from .theme import _register_preferred_cjk_fonts
TECH_BLUE = {
"accent": "#1769E8",
"accent_hover": "#155BCC",
"accent_pressed": "#124EA9",
"selection": "#EAF2FF",
"selected_text": "#1555B6",
"canvas": "#F3F7FD",
"sidebar": "#EDF4FF",
"surface": "#FFFFFF",
"raised": "#F7FAFE",
"line": "#DBE5F2",
"text": "#273244",
"heading": "#202C3F",
"muted": "#5D6B80",
"focus": "#75A5F0",
"accent": PALETTE["accent"],
"accent_hover": PALETTE["accent_hover"],
"accent_pressed": PALETTE["accent_pressed"],
"selection": PALETTE["accent_soft"],
"selected_text": PALETTE["accent_hover"],
"canvas": PALETTE["canvas"],
"sidebar": PALETTE["sidebar"],
"surface": PALETTE["surface"],
"raised": PALETTE["surface_alt"],
"line": PALETTE["line"],
"text": PALETTE["text"],
"heading": PALETTE["heading"],
"muted": PALETTE["muted"],
"focus": PALETTE["focus"],
}
@@ -170,8 +170,8 @@ QWidget#ReceptionPage QStackedWidget#ReceptionNarrowWorkspace {
}
QWidget#ReceptionPage QFrame#ReceptionQueuePanel {
background-color: #FFFFFF;
border: 1px solid #E5ECF6;
border-radius: 8px;
border: 1px solid #EDF0F5;
border-radius: 16px;
}
QWidget#ReceptionPage QLabel#ReceptionQueueTitle {
font-size: 18px;
@@ -200,8 +200,8 @@ QWidget#ReceptionPage QFrame#ReceptionHero,
QWidget#ReceptionPage QFrame#ReceptionClinicalCard {
min-height: 0;
background-color: #FFFFFF;
border: 1px solid #E5ECF6;
border-radius: 8px;
border: 1px solid #EDF0F5;
border-radius: 16px;
}
QWidget#ReceptionPage QLabel#ReceptionPatientName {
font-size: 20px;
@@ -223,8 +223,8 @@ QWidget#ReceptionPage QTabBar#ReceptionWorkspaceTabs {
background-color: #FFFFFF;
border: 0;
border-bottom: 1px solid #E5ECF6;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs::tab,
QWidget#ReceptionPage QTabBar#ReceptionWorkspaceTabs::tab {
@@ -295,8 +295,8 @@ QWidget#ReceptionPage QFrame#ReceptionPatientSummaryCard,
QWidget#ReceptionPage QFrame#ReceptionVitalsCard,
QWidget#ReceptionPage QFrame#ReceptionLabsCard {
background-color: #FFFFFF;
border: 1px solid #E5ECF6;
border-radius: 8px;
border: 1px solid #EDF0F5;
border-radius: 16px;
}
QWidget#ReceptionPage QLabel#ReceptionPatientSummaryValue {
color: #24334A;
@@ -367,8 +367,8 @@ QWidget#ReceptionPage QLabel[receptionMetricState="true"][alert="true"][warning=
QWidget#ReceptionPage QFrame#ReceptionAiAnalysisCard,
QWidget#ReceptionPage QFrame#ReceptionAiAssistantCard {
background-color: #FFFFFF;
border: 1px solid #DCE5F0;
border-radius: 8px;
border: 1px solid $ds_line;
border-radius: $ds_radius_panel;
}
QWidget#ReceptionPage QLabel#ReceptionAiTitle,
QWidget#ReceptionPage QPushButton#ReceptionAiTitle {
@@ -405,4 +405,37 @@ QWidget#ReceptionPage QScrollArea#ReceptionInsightsScroll QScrollBar::add-line:v
QWidget#ReceptionPage QScrollArea#ReceptionInsightsScroll QScrollBar::sub-line:vertical {
height: 0;
}
QWidget#ReceptionPage QLineEdit#ReceptionQueueSearch,
QWidget#ReceptionPage QPushButton#ReceptionDateButton,
QWidget#ReceptionPage QPushButton#ReceptionQueueFilterToggle,
QWidget#ReceptionPage QPushButton#ReceptionVideoButton,
QWidget#ReceptionPage QPushButton#ReceptionNotifyButton,
QWidget#ReceptionPage QPushButton#ReceptionHistoryButton,
QWidget#ReceptionPage QPushButton#ReceptionImButton,
QWidget#ReceptionPage QPushButton#ReceptionMoreButton,
QWidget#ReceptionPage QPushButton#ReceptionCompleteButton,
QWidget#ReceptionPage QPushButton[receptionAiPrompt="true"] {
border-radius: $ds_radius_control;
}
QWidget#ReceptionPage QPushButton:focus,
QWidget#ReceptionPage QLineEdit:focus,
QWidget#ReceptionPage QComboBox:focus,
QWidget#ReceptionPage QTextEdit:focus {
border-color: $ds_focus;
}
QWidget#ReceptionPage QPushButton#ReceptionVideoButton:pressed {
color: $ds_surface;
background-color: $ds_accent_pressed;
border-color: $ds_accent_pressed;
}
QWidget#ReceptionPage QLabel[receptionMetricState="true"] {
border-radius: $ds_radius_small;
}
QWidget#ReceptionPage QFrame#ReceptionLabCell,
QWidget#ReceptionPage QWidget#ReceptionCaseField {
border-bottom-color: $ds_line;
}
QWidget#ReceptionPage QLabel#ReceptionPatientSummaryValue[missing="true"] {
color: $ds_muted;
}
"""
+11 -10
View File
@@ -59,6 +59,7 @@ from .chat_notifications import (
ChatNotification,
ChatNotificationCenter,
)
from .design_system import PALETTE, clinical_stylesheet
from .dialogs.ai_consult import can_open_ai_consult
from .dialogs.ai_consult_picker import select_and_present_ai_consult
from .dialogs.diagnosis import DiagnosisDialog
@@ -72,7 +73,7 @@ from .pages import (
ReceptionPage,
)
from .reception_style import TECH_BLUE, body_family, heading_family, number_family
from .theme import COLORS, TYPE, crisp_pixmap
from .theme import COLORS, METRICS, TYPE, crisp_pixmap
from .widgets import (
EmptyState,
StatusBadge,
@@ -93,8 +94,8 @@ _SHELL_DESIGN_SIZE = QSize(1710, 920)
_SHELL_MINIMUM_SIZE = QSize(1024, 640)
_RECEPTION_SIDEBAR_WIDTH = 208
_RECEPTION_TOPBAR_HEIGHT = 76
_RECEPTION_SIDEBAR_COLOR = "#F3F7FD"
_RECEPTION_CHROME_LINE = "#E7EDF7"
_RECEPTION_SIDEBAR_COLOR = PALETTE["sidebar"]
_RECEPTION_CHROME_LINE = PALETTE["line"]
# Approved pages share one chrome state, so navigation among them keeps it intact.
_TECH_BLUE_PAGES = frozenset({"appointments", "consultations", "patients", "prescriptions", "prescription_library", "reception"})
@@ -1005,7 +1006,7 @@ class ShellWindow(QMainWindow):
chrome_widgets.extend(self.topbar.findChildren(_PaintedIconButton))
chrome_widgets.append(self.tabs_menu_button)
self._legacy_chrome_styles = {
widget: widget.styleSheet() for widget in chrome_widgets
widget: clinical_stylesheet(widget.styleSheet()) for widget in chrome_widgets
}
self._register_pages()
self.search_shortcut = QShortcut(QKeySequence("Ctrl+K"), self)
@@ -1268,7 +1269,7 @@ class ShellWindow(QMainWindow):
color: #606163;
background-color: #FFFFFF;
border: 1px solid #EDEDEE;
border-radius: 999px;
border-radius: 10px;
padding: 4px 10px;
font-size: 13px;
font-weight: 500;
@@ -1693,7 +1694,7 @@ class ShellWindow(QMainWindow):
font-family: "{body_family()}"; font-weight: 400;
min-height: 44px; max-height: 44px;
border: 0; border-left: 5px solid transparent;
border-radius: 6px;
border-radius: {METRICS["r_md"]};
padding: 0 16px; font-size: {TYPE['fs_body']};
color: {TECH_BLUE['text']};
}}
@@ -1711,7 +1712,7 @@ class ShellWindow(QMainWindow):
}}
QPushButton#ShellNavButton[collapsed="true"] {{ padding: 0; }}
QFrame#ShellAssistantCard {{
background-color: {TECH_BLUE['surface']}; border-radius: 8px;
background-color: {TECH_BLUE['surface']}; border-radius: {METRICS["r_lg"]};
border: 1px solid {_RECEPTION_CHROME_LINE};
}}
QLabel#ShellAssistantName {{
@@ -1723,7 +1724,7 @@ class ShellWindow(QMainWindow):
QPushButton#ShellAssistantButton, QPushButton#ShellSettingsButton {{
font-family: "{body_family()}"; font-weight: 400; font-size: {TYPE['fs_body']};
}}
QPushButton#ShellAssistantButton {{ border-radius: 6px; }}
QPushButton#ShellAssistantButton {{ border-radius: {METRICS["r_md"]}; }}
QPushButton#ShellSettingsButton {{
min-height: 50px; max-height: 50px;
text-align: left; padding: 0 32px;
@@ -1738,7 +1739,7 @@ class ShellWindow(QMainWindow):
border-radius: 0;
border-bottom: 1px solid {_RECEPTION_CHROME_LINE};
}}
QFrame#ShellGlobalSearch {{ border: 1px solid {_RECEPTION_CHROME_LINE}; border-radius: 5px; }}
QFrame#ShellGlobalSearch {{ background-color: {PALETTE["surface_alt"]}; border: 1px solid transparent; border-radius: {METRICS["r_md"]}; }}
QFrame#ShellUserSeparator {{ background: {_RECEPTION_CHROME_LINE}; border: 0; }}
QLabel#ShellShortcutHint {{
font-family: "{number_family()}"; font-size: {TYPE['fs_small']};
@@ -1767,7 +1768,7 @@ class ShellWindow(QMainWindow):
if isinstance(widget, _PaintedIconButton):
side = 50 if widget in (self.refresh_button, self.notification_button, self.settings_button) else 34
stylesheet += f"QToolButton#ShellPaintedIconButton {{ min-width: {side - 2}px; max-width: {side - 2}px; min-height: {side - 2}px; max-height: {side - 2}px; }}"
widget.setStyleSheet(stylesheet)
widget.setStyleSheet(clinical_stylesheet(stylesheet))
self._set_reception_geometry(active)
for widget in (
+67 -70
View File
@@ -41,46 +41,46 @@ from doctor_workstation.resources import resource_path
# ``motion`` deliberately imports nothing from this module, so this stays a
# one-way dependency: tokens here, animation there.
from . import motion
from .design_system import PALETTE, RADII, SPACING, clinical_stylesheet
# Neutral reading colors follow the installed Codex light chrome defaults.
# Shared reading colors keep native pages and dialog chrome consistent.
# Brand accents are independent of reading ink; use opaque text for stable contrast.
# The legacy teal/ink aliases remain for existing callers.
COLORS = {
"canvas": "#F4F6FA",
"canvas_mid": "#FFFFFF",
"canvas_glow": "#EEF1FA",
"surface": "#FFFFFF",
"surface_alt": "#F7F7F7",
"raised": "#F7F7F7",
"glass": "#FFFFFF",
"glass_alt": "#F7F7F7",
"line": "#EDEDEE",
"line_soft": "#E4E4E5",
"text": "#1A1C1F",
"text_soft": "#606163",
"muted": "#6A6B6D",
"disabled_surface": "#F2F2F2",
"disabled_text": "#8E8F90",
"indigo": "#4F63D9",
"indigo_hover": "#4156C4",
"indigo_pressed": "#354BB4",
"indigo_pale": "#EEF1FA",
"focus": "#8B9AD9",
"selection": "#EEF1FA",
"success": "#287B65",
"success_pale": "#EEF7F3",
"warning": "#A9691D",
"warning_pale": "#FCF5E9",
"danger": "#BE4B58",
"danger_pale": "#FCF0F2",
"info": "#4F63D9",
"info_pale": "#EEF1FA",
# Backward-compatible names used by older UI code and integrations.
"ink": "#1A1C1F",
"ink_soft": "#606163",
"teal": "#4F63D9",
"teal_dark": "#354BB4",
"teal_pale": "#EEF1FA",
"canvas": PALETTE["canvas"],
"canvas_mid": PALETTE["surface"],
"canvas_glow": PALETTE["accent_soft"],
"surface": PALETTE["surface"],
"surface_alt": PALETTE["surface_alt"],
"raised": PALETTE["surface_alt"],
"glass": PALETTE["surface"],
"glass_alt": PALETTE["surface_alt"],
"line": PALETTE["line"],
"line_soft": PALETTE["line_strong"],
"text": PALETTE["heading"],
"text_soft": PALETTE["text"],
"muted": PALETTE["muted"],
"disabled_surface": PALETTE["disabled_surface"],
"disabled_text": PALETTE["disabled"],
"indigo": PALETTE["accent"],
"indigo_hover": PALETTE["accent_hover"],
"indigo_pressed": PALETTE["accent_pressed"],
"indigo_pale": PALETTE["accent_soft"],
"focus": PALETTE["focus"],
"selection": PALETTE["accent_soft"],
"success": PALETTE["success"],
"success_pale": PALETTE["success_soft"],
"warning": PALETTE["warning"],
"warning_pale": PALETTE["warning_soft"],
"danger": PALETTE["danger"],
"danger_pale": PALETTE["danger_soft"],
"info": PALETTE["accent"],
"info_pale": PALETTE["accent_soft"],
"ink": PALETTE["heading"],
"ink_soft": PALETTE["text"],
"teal": PALETTE["accent"],
"teal_dark": PALETTE["accent_pressed"],
"teal_pale": PALETTE["accent_soft"],
}
@@ -122,11 +122,11 @@ METRICS = {
# ``outer - gap``. Where the gap is bigger than the outer radius the inner
# element is far enough from the corner that its own radius is free.
"r_xs": "4px", # chips, badges, tiny status pills
"r_sm": "6px", # inline row actions, tags
"r_md": "8px", # buttons, inputs, combo boxes
"r_lg": "12px", # cards, filter bars, panels
"r_xl": "16px", # the shell surfaces the cards sit on
"pad_control": "12px", # horizontal padding inside default controls
"r_sm": f"{RADII['small']}px", # inline row actions, tags
"r_md": f"{RADII['control']}px", # buttons, inputs, combo boxes
"r_lg": f"{RADII['panel']}px", # cards, filter bars, panels
"r_xl": f"{RADII['window']}px", # the shell surfaces the cards sit on
"pad_control": f"{SPACING['control']}px", # horizontal padding inside default controls
"pad_compact": "9px",
}
@@ -176,7 +176,7 @@ QDialog[businessDialog="true"] QFrame#DialogSurface,
QDialog[businessDialog="true"] QFrame[dialogSurface="true"] {
background-color: $surface;
border: 1px solid $line;
border-radius: 14px;
border-radius: $r_lg;
}
QDialog[businessDialog="true"] QFrame#DialogHeader,
QDialog[businessDialog="true"] QFrame[dialogRole="header"] {
@@ -275,18 +275,18 @@ QFrame#Card, QFrame#Panel, QFrame#FilterBar, QFrame#DetailPanel,
QFrame[glass="true"] {
background-color: $glass;
border: 1px solid $line;
border-radius: 12px;
border-radius: $r_lg;
}
QFrame#FilterBar { background-color: $surface; }
QFrame#SubtleCard {
background-color: $glass_alt;
border: 1px solid $line;
border-radius: 12px;
border-radius: $r_lg;
}
QFrame#MetricCard {
background-color: $surface;
border: 1px solid $line;
border-radius: 11px;
border-radius: $r_md;
}
QFrame#MetricCard:hover { border-color: $line_soft; background-color: $surface_alt; }
QFrame#MetricCard QLabel[role="metricTitle"] { color: $muted; font-size: $fs_caption; }
@@ -297,7 +297,7 @@ QFrame#ReceptionAiCard {
min-height: 132px;
background-color: #FFFFFF;
border: 1px solid $line_soft;
border-radius: 13px;
border-radius: $r_lg;
}
QLabel#ReceptionAiTitle {
color: $indigo_pressed;
@@ -313,7 +313,7 @@ QLabel#MetricGlyph {
color: $indigo;
background-color: $indigo_pale;
border: 1px solid $line_soft;
border-radius: 11px;
border-radius: $r_md;
font-size: $fs_section;
font-weight: $fw_heading;
}
@@ -329,7 +329,7 @@ QGroupBox {
margin-top: 12px;
padding-top: 12px;
border: 1px solid $line;
border-radius: 12px;
border-radius: $r_lg;
background-color: $glass;
font-weight: $fw_control;
}
@@ -351,7 +351,7 @@ QPushButton {
}
QPushButton:hover {
background-color: $raised;
border-color: $indigo_hover;
border-color: $line_soft;
}
QPushButton:pressed {
background-color: $indigo_pale;
@@ -401,7 +401,7 @@ QPushButton[variant="primary"]:disabled {
QPushButton[variant="secondary"] {
color: $indigo_hover;
background-color: $indigo_pale;
border-color: $line_soft;
border-color: $indigo_pale;
}
QPushButton[variant="secondary"]:hover {
color: $indigo_pressed;
@@ -462,7 +462,7 @@ QToolButton#RowActionsMore::menu-indicator { width: 0; height: 0; image: none; }
QFrame#NoteAttachmentTile {
background-color: $surface;
border: 1px solid $line;
border-radius: 10px;
border-radius: $r_md;
}
QPushButton#NoteAttachmentPreview {
min-height: 132px;
@@ -470,7 +470,7 @@ QPushButton#NoteAttachmentPreview {
color: $muted;
background-color: $surface_alt;
border: 1px solid $line;
border-radius: 8px;
border-radius: $r_md;
font-weight: $fw_control;
}
QPushButton#NoteAttachmentPreview:hover {
@@ -558,7 +558,7 @@ QPushButton[variant="chip"] {
color: $text_soft;
background-color: $surface_alt;
border-color: $line;
border-radius: 8px;
border-radius: $r_md;
}
QPushButton[variant="chip"]:hover {
color: $text;
@@ -653,7 +653,7 @@ QComboBox QAbstractItemView {
background-color: $raised;
alternate-background-color: $surface_alt;
border: 1px solid $line;
border-radius: 10px;
border-radius: $r_md;
padding: 5px;
outline: 0;
selection-background-color: $indigo_pressed;
@@ -692,7 +692,7 @@ QAbstractItemView, QTableWidget, QTableView, QListWidget, QListView, QTreeWidget
background-color: $surface;
alternate-background-color: $surface_alt;
border: 0;
border-radius: 12px;
border-radius: $r_lg;
gridline-color: $line;
selection-background-color: $selection;
selection-color: $text;
@@ -729,17 +729,17 @@ QListWidget::item:selected, QListView::item:selected,
QTreeWidget::item:selected, QTreeView::item:selected {
background-color: $indigo_pale;
color: $indigo_pressed;
border-radius: 8px;
border-radius: $r_md;
}
QListWidget::item:hover, QListView::item:hover,
QTreeWidget::item:hover, QTreeView::item:hover {
background-color: $surface_alt;
border-radius: 8px;
border-radius: $r_md;
}
QTabWidget::pane {
border: 1px solid $line;
border-radius: 12px;
border-radius: $r_lg;
background-color: $glass;
}
QTabBar::tab {
@@ -749,7 +749,7 @@ QTabBar::tab {
color: $muted;
background-color: transparent;
border: 1px solid transparent;
border-radius: 9px;
border-radius: $r_md;
font-weight: $fw_control;
}
QTabBar::tab:hover { color: $text; background-color: $surface_alt; }
@@ -792,7 +792,7 @@ QMenu {
color: $text;
background-color: $raised;
border: 1px solid $line_soft;
border-radius: 10px;
border-radius: $r_md;
padding: 6px;
}
QMenu::item {
@@ -815,7 +815,7 @@ QCalendarWidget {
color: $text;
background-color: $surface;
border: 1px solid $line;
border-radius: 12px;
border-radius: $r_lg;
}
QCalendarWidget QWidget#qt_calendar_navigationbar {
background-color: $raised;
@@ -914,7 +914,7 @@ QWidget#Pager QLabel#PagerActive {
color: #FFFFFF;
background-color: $indigo;
border: 1px solid $indigo;
border-radius: 8px;
border-radius: $r_md;
font-size: $fs_caption;
font-weight: $fw_control;
}
@@ -937,7 +937,7 @@ QLabel#EmptyStateGlyph {
QFrame#MessageBanner {
border: 1px solid $line;
border-radius: 10px;
border-radius: $r_md;
color: $text_soft;
}
QFrame#MessageBanner QLabel { background-color: transparent; }
@@ -955,7 +955,7 @@ QLabel#Toast {
color: $text;
background-color: $raised;
border: 1px solid $line_soft;
border-radius: 11px;
border-radius: $r_md;
padding: 11px 16px;
font-weight: $fw_control;
}
@@ -995,13 +995,9 @@ QLabel#UserAvatar {
font-weight: $fw_heading;
}
QWidget#LoginBrandPanel {
background-color: qlineargradient(
x1: 0, y1: 0, x2: 1, y2: 1,
stop: 0 $surface,
stop: 1 $canvas_glow
);
background-color: $surface_alt;
border: 1px solid $line_soft;
border-radius: 22px;
border-radius: $r_lg;
}
QFrame#LoginCard {
background-color: $glass;
@@ -1043,6 +1039,7 @@ QToolTip {
}
"""
).substitute(_QSS_TOKENS)
GLOBAL_QSS = clinical_stylesheet(GLOBAL_QSS)
#: Per-block reading rhythm, in device pixels. ``(top, bottom, line%)``.
+2 -1
View File
@@ -44,6 +44,7 @@ from doctor_workstation.core.errors import (
)
from . import icons, motion
from .design_system import PALETTE
AuthenticationExpiredHandler = Callable[[AuthenticationExpiredError], bool]
_AUTHENTICATION_EXPIRED_HANDLER: AuthenticationExpiredHandler | None = None
@@ -798,7 +799,7 @@ class _BusyTrack(QWidget):
chunk_width = max(36, int(rect.width() * 0.32))
span = rect.width() + chunk_width
x = int(self._phase * span) - chunk_width
painter.setBrush(QColor("#4F63D9"))
painter.setBrush(QColor(PALETTE["accent"]))
painter.drawRoundedRect(x, 0, chunk_width, rect.height(), 3, 3)
+387
View File
@@ -0,0 +1,387 @@
"""Bounded, Qt-independent AI requests for one authenticated IM window.
Only server-archived clinical context is submitted. This module never sends IM
messages and never shares the ordered call/recording lifecycle worker.
"""
from __future__ import annotations
import re
from collections import deque
from collections.abc import Callable, Mapping
from dataclasses import dataclass, field
from threading import BoundedSemaphore, Event, RLock, Thread
from time import monotonic
from typing import Any
from uuid import UUID, uuid4
MAX_RESULT_CHARS = 65_536
MAX_SYNC_STEPS = 24
SYNC_TIMEOUT_SECONDS = 45.0
_WORKER_SLOTS = BoundedSemaphore(4)
_CANCEL_SLOTS = BoundedSemaphore(4)
_ACTIONS = frozenset({"summary", "followup", "reply"})
def _integer(value: Any, *, minimum: int) -> int | None:
if isinstance(value, bool) or not isinstance(value, (int, str)):
return None
if isinstance(value, str) and re.fullmatch(r"0|[1-9][0-9]{0,18}", value) is None:
return None
number = int(value)
return number if minimum <= number < 2**63 else None
def _request_uuid(value: Any) -> bool:
if not isinstance(value, str) or len(value) != 36:
return False
try:
return str(UUID(value)) == value.lower()
except (ValueError, AttributeError):
return False
def task_prompt(action: str, doctor_account: str) -> tuple[str, str]:
"""Keep instructions separate from clinical source text and under API limits."""
if action not in _ACTIONS or not re.fullmatch(r"doctor_[1-9][0-9]{0,18}", doctor_account):
raise ValueError("AI 操作或当前医生账号无效")
shared = (
f"这是 IM 问诊辅助,本次医生 IM 账号为 {doctor_account}。"
"优先依据该医生与本患者最近已归档对话,结合服务端授权病历;"
"其他医生及历史记录仅作背景,不能当成本次已确认事实。"
"若未找到本次对话请明确说明,不猜测最新诉求。"
"区分已知、明确否认与未知,保留日期及不确定性;"
"不补问脉象,不编造事实、不自动确诊、不新增或更改药物剂量。"
)
instructions = {
"summary": "请用简短条目总结本次病情、病程、现用治疗与待核实事项,供医生交接复核。",
"followup": (
"请建议最多5条优先追问,直接给出可向患者询问的自然短句,"
"每条可附简短目的;避免重复已回答的问题,不做通用问卷。"
),
"reply": (
"请起草一段医生可审阅后发给患者的简短自然回复,围绕该对话最近的患者问题。"
"不冒称已检查、已预约或已开处方,不承诺疗效,不让患者自行停换药。"
"只给回复草稿,不写分析过程;任何缺失资料通过必要的问题核实。"
),
}
prompt = shared + instructions[action] + "此内容须由医生复核,不能自动发送。"
if len(prompt) > 500:
raise ValueError("AI 提示词超过接口长度限制")
return ("summary" if action == "summary" else "custom"), prompt
def _warnings(value: Any) -> list[str]:
if not isinstance(value, (list, tuple)):
return []
warnings = []
for row in value[:20]:
if isinstance(row, str):
text = row
elif isinstance(row, Mapping):
text = row.get("message") or row.get("label")
if not text and row.get("code"):
text = (
"请复核回答中的脉象判断;本流程不采集脉象。"
if row["code"] == "PULSE_EXCLUDED_FROM_ASSESSMENT"
else "请对照原始记录复核,回答中的事实、否认或未知状态可能不一致。"
)
else:
continue
if isinstance(text, str) and text.strip():
rendered = text.strip()[:400]
if rendered not in warnings:
warnings.append(rendered)
return warnings
class _RequestError(Exception):
"""A deliberately safe, user-facing failure message."""
@dataclass
class _Job:
identity: dict[str, Any]
action: str
cancelled: Event = field(default_factory=Event)
completed: bool = False
succeeded: bool = False
stream_started: bool = False
cancel_sent: bool = False
class ImAiController:
"""One live request, a coalesced mailbox, and bounded daemon workers.
Qt polls ``take_result`` every 60 ms. Worker threads only mutate plain data;
they never touch a QObject. A cancelled worker must retire before a retry
starts, so rapid clicks cannot create an unbounded collection of requests.
"""
def __init__(
self,
repository: Any,
*,
diagnosis_id: Any,
appointment_id: Any,
doctor_account: str,
enabled: bool = False,
clock: Callable[[], float] = monotonic,
max_sync_steps: int = MAX_SYNC_STEPS,
sync_timeout: float = SYNC_TIMEOUT_SECONDS,
) -> None:
self.repository = repository
self.diagnosis_id = _integer(diagnosis_id, minimum=1)
self.appointment_id = _integer(appointment_id, minimum=0)
self.doctor_account = str(doctor_account)
self.enabled = (
enabled is True
and repository is not None
and self.diagnosis_id is not None
and self.appointment_id is not None
and re.fullmatch(r"doctor_[1-9][0-9]{0,18}", self.doctor_account) is not None
)
self.session_id = str(uuid4())
self._clock = clock
self._max_sync_steps = max(1, min(MAX_SYNC_STEPS, max_sync_steps))
self._sync_timeout = max(0.01, min(SYNC_TIMEOUT_SECONDS, sync_timeout))
self._lock = RLock()
self._closed = False
self._current: _Job | None = None
self._running: _Job | None = None
self._worker: Thread | None = None
self._mailbox: dict[str, Any] | None = None
self._seen: deque[str] = deque(maxlen=256)
@property
def config(self) -> dict[str, Any]:
return {
"version": 1,
"enabled": self.enabled and not self._closed,
"sessionId": self.session_id,
**({} if self.enabled else {"reason": "当前账号或问诊暂不能使用 AI 辅助。"}),
}
def _valid_identity(self, message: Mapping[str, Any]) -> bool:
return (
self.enabled
and not self._closed
and message.get("source") == "doctor-call"
and message.get("sessionId") == self.session_id
and _request_uuid(message.get("requestId"))
and isinstance(message.get("contextKey"), str)
and 0 < len(message["contextKey"]) <= 128
and _integer(message.get("diagnosisId"), minimum=1) == self.diagnosis_id
and _integer(message.get("appointmentId"), minimum=0) == self.appointment_id
and isinstance(message.get("action"), str)
and message["action"] in _ACTIONS
)
def handle(self, message: Mapping[str, Any]) -> bool:
with self._lock:
if not self._valid_identity(message):
return False
event = message.get("event")
identity = {key: message[key] for key in (
"sessionId", "requestId", "contextKey", "diagnosisId", "appointmentId", "action"
)}
if event == "im-ai-cancel":
if self._current is None or self._current.identity != identity:
return False
self._cancel(self._current)
return True
if event != "im-ai-request" or message["requestId"] in self._seen:
return False
self._seen.append(message["requestId"])
job = _Job(identity, message["action"])
if self._running is not None:
self._cancel(self._running)
self._current = job
self._publish(job, "error", message="上次请求正在结束,请稍后重试。", terminal=True)
return True
self._current = job
if not _WORKER_SLOTS.acquire(blocking=False):
self._publish(job, "error", message="AI 正在处理其他请求,请稍后重试。", terminal=True)
return True
self._running = job
self._publish(job, "loading", message="正在同步当前聊天记录…")
self._worker = Thread(target=self._run, args=(job,), name="im-ai", daemon=True)
try:
self._worker.start()
except RuntimeError:
self._running = None
_WORKER_SLOTS.release()
self._publish(job, "error", message="AI 请求暂时无法启动,请稍后重试。", terminal=True)
return True
def _publish(self, job: _Job, status: str, *, terminal: bool = False, **fields: Any) -> None:
with self._lock:
if self._closed or self._current is not job or job.cancelled.is_set() or job.completed:
return
if terminal:
job.completed = True
job.succeeded = status == "success"
self._mailbox = {**job.identity, "status": status, **fields}
def take_result(self) -> dict[str, Any] | None:
with self._lock:
result, self._mailbox = self._mailbox, None
return None if self._closed else result
def _sync(self, job: _Job) -> bool:
deadline = self._clock() + self._sync_timeout
token = ""
for _ in range(self._max_sync_steps):
if job.cancelled.is_set():
return False
if self._clock() >= deadline:
raise _RequestError("聊天同步超时,尚未生成,请稍后重试。")
result = self.repository.sync_im_chat_messages(
self.diagnosis_id, scope="current", sync_token=token
)
if job.cancelled.is_set():
return False
if self._clock() >= deadline:
raise _RequestError("聊天同步超时,尚未生成,请稍后重试。")
if not isinstance(result, Mapping) or result.get("errors"):
raise _RequestError("当前聊天记录未能完整同步,尚未生成,请稍后重试。")
if result.get("completed") is True:
return True
token = result.get("sync_token", "")
if not isinstance(token, str) or re.fullmatch(r"[a-f0-9]{48}", token) is None:
raise _RequestError("聊天同步进度无效,请更新客户端或稍后重试。")
raise _RequestError("聊天记录仍在同步,尚未生成,请稍后重试。")
def _run(self, job: _Job) -> None:
try:
if not self._sync(job):
return
task, prompt = task_prompt(job.action, self.doctor_account)
with self._lock:
if job.cancelled.is_set() or self._closed:
return
job.stream_started = True
self._publish(job, "loading", message="聊天已同步,正在整理病历资料…")
if job.cancelled.is_set():
return
text = ""
events = self.repository.stream_diagnosis_ai(
self.diagnosis_id, prompt, task=task,
request_id=job.identity["requestId"], cancelled=job.cancelled.is_set,
)
try:
for event in events:
if job.cancelled.is_set():
return
if not isinstance(event, Mapping):
continue
kind = event.get("event")
if kind == "delta":
delta = event.get("text", "")
if not isinstance(delta, str) or len(text) + len(delta) > MAX_RESULT_CHARS:
raise _RequestError("AI 内容超过显示上限,已停止接收,请缩小问题后重试。")
text += delta
self._publish(job, "streaming", text=text, message="正在生成,内容尚未完成。")
elif kind in {"start", "progress"}:
message = str(event.get("message") or "正在整理资料并生成…")[:240]
self._publish(job, "streaming" if text else "loading", text=text, message=message)
elif kind == "done":
result_id = event.get("diagnosis_id")
if result_id is not None and _integer(result_id, minimum=1) != self.diagnosis_id:
raise _RequestError("AI 返回的问诊上下文不匹配,结果未采用。")
answer = event.get("answer", event.get("content", text))
if not isinstance(answer, str) or not answer.strip():
raise _RequestError("AI 未返回完整内容,请重试。")
if len(answer) > MAX_RESULT_CHARS:
raise _RequestError("AI 内容超过显示上限,结果未采用,请缩小问题后重试。")
self._publish(
job, "success", terminal=True, text=answer,
message="已生成,请由医生复核后使用。",
modelLabel=str(event.get("model_label") or "")[:100],
warnings=_warnings(event.get("clinical_review_warnings")),
)
return
elif kind == "error":
raise _RequestError("AI 请求未完成,请检查权限或稍后重试。")
if not job.cancelled.is_set():
raise _RequestError("AI 连接提前结束,内容未完成,请重试。")
finally:
close = getattr(events, "close", None)
if callable(close):
close()
except Exception as error:
message = str(error) if isinstance(error, _RequestError) else (
"AI 请求失败,请检查权限或稍后重试。" if job.stream_started
else "当前聊天同步失败,尚未生成,请检查权限或稍后重试。"
)
self._publish(job, "error", message=message, terminal=True)
if job.stream_started and not job.cancelled.is_set() and not job.succeeded:
self._request_cancel(job)
finally:
with self._lock:
if self._running is job:
self._running = None
_WORKER_SLOTS.release()
def _cancel(self, job: _Job) -> None:
if job.completed or job.cancelled.is_set():
return
job.cancelled.set()
if self._current is job and not self._closed:
self._mailbox = {
**job.identity, "status": "cancelled",
"message": ("已停止本次接收,上游是否结束尚未确认。" if job.stream_started
else "已取消,尚未向 AI 提交请求。"),
}
if job.stream_started:
self._request_cancel(job)
def _request_cancel(self, job: _Job) -> None:
with self._lock:
if job.cancel_sent:
return
job.cancel_sent = True
if not _CANCEL_SLOTS.acquire(blocking=False):
return
def send() -> None:
try:
result = self.repository.cancel_diagnosis_ai(self.diagnosis_id, job.identity["requestId"])
if not isinstance(result, Mapping):
return
message = "已发送取消请求,上游是否结束尚未确认。"
terminal = result.get("upstream_terminal_status")
if result.get("upstream_terminal_confirmed") is True and terminal in {"stopped", "succeeded", "failed"}:
message = "本次接收已停止,上游工作流已结束。"
elif result.get("upstream_stop_confirmed") is True:
message = "上游已接受停止请求,是否结束尚未确认。"
with self._lock:
if not self._closed and self._current is job and job.cancelled.is_set():
self._mailbox = {**job.identity, "status": "cancelled", "message": message}
except Exception:
pass # Keep the visible unconfirmed cancellation; never expose transport details.
finally:
_CANCEL_SLOTS.release()
try:
Thread(target=send, name="im-ai-cancel", daemon=True).start()
except RuntimeError:
_CANCEL_SLOTS.release()
def close(self) -> None:
with self._lock:
if self._closed:
return
self._closed = True
self._mailbox = None
if self._running is not None:
self._cancel(self._running)
def wait(self, timeout: float = 1.0) -> bool:
"""Bounded diagnostic/test helper; never called by the Qt GUI."""
worker = self._worker
if worker is not None:
worker.join(max(0.0, min(timeout, 5.0)))
return worker is None or not worker.is_alive()
@@ -413,6 +413,7 @@ class VideoCallLauncher:
patient_name: str = "患者",
patient_case: Mapping[str, Any] | None = None,
on_open_diagnosis: Callable[[], None] | None = None,
can_ai_assistant: bool = False,
) -> Any:
request = self.prepare(
ticket,
@@ -432,6 +433,7 @@ class VideoCallLauncher:
patient_name=patient_name,
patient_case=patient_case,
on_open_diagnosis=on_open_diagnosis,
can_ai_assistant=can_ai_assistant is True,
)
@@ -450,6 +452,7 @@ def launch_video_call(
patient_name: str = "患者",
patient_case: Mapping[str, Any] | None = None,
on_open_diagnosis: Callable[[], None] | None = None,
can_ai_assistant: bool = False,
) -> Any:
"""Normalize a ticket and open a call with the requested backend."""
@@ -468,4 +471,5 @@ def launch_video_call(
patient_name=patient_name,
patient_case=patient_case,
on_open_diagnosis=on_open_diagnosis,
can_ai_assistant=can_ai_assistant is True,
)
@@ -28,6 +28,7 @@ from ..services.local_audio_queue import (
LocalAudioUploadManager,
get_local_audio_upload_manager,
)
from .im_ai import ImAiController
from .launcher import (
VideoCallRequest,
VideoTicketError,
@@ -320,6 +321,8 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
patient_name: str = "患者",
patient_case: Mapping[str, Any] | None = None,
on_open_diagnosis: Callable[[], None] | None = None,
can_ai_assistant: bool = False,
repository: Any = None,
) -> None:
super().__init__()
self.request = request
@@ -349,6 +352,18 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
self._call_cycle_closed = False
self._start_requested = False
self._shutdown_requested = False
self._im_ai = ImAiController(
repository,
diagnosis_id=request.diagnosis_id,
appointment_id=request.appointment_id,
doctor_account=request.user_id,
enabled=can_ai_assistant is True and self.open_im,
)
self._im_ai_timer = QTimer(self)
self._im_ai_timer.setInterval(60)
self._im_ai_timer.timeout.connect(self._flush_im_ai)
if self._im_ai.enabled:
self._im_ai_timer.start()
self._screenshot_preview_size = ScreenshotPreviewSize()
self._local_audio_capture: _LocalAudioCapture | None = None
self._local_audio_store: LocalAudioQueueStore | None = None
@@ -483,6 +498,7 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
"patientName": self.patient_name,
"patientCase": self.patient_case,
"mode": "chat" if self.open_im else "video",
"imAi": self._im_ai.config,
}
config_json = json.dumps(config, ensure_ascii=True, separators=(",", ":"))
script = f"""
@@ -524,11 +540,23 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
self._injected = result is not False
if not self._injected:
self._request_companion_shutdown("bridge-api-missing")
return
if not self._im_ai_context_is_trusted():
return
# open() may finish IM login before runJavaScript returns. Only
# acknowledge readiness after the native request gate is open.
session_id = json.dumps(self._im_ai.session_id, ensure_ascii=True)
self._page.runJavaScript(
f"window.doctorConsultation?.imAiReady?.({session_id});"
)
def _handle_bridge_message(self, message: Mapping[str, Any]) -> None:
if self._closing:
return
event = str(message.get("event", ""))
if event in {"im-ai-request", "im-ai-cancel"}:
self._handle_im_ai_message(message)
return
if event == "screenshot-preview":
visible = message.get("visible")
if isinstance(visible, bool):
@@ -622,6 +650,35 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
if not self.open_im or self._shutdown_requested:
self._close_from_companion("companion-error")
def _im_ai_context_is_trusted(self) -> bool:
return (
not self._closing
and not self._released
and not self._shutdown_requested
and self._injected
and self._policy.allows_main_document(self._page.url().toString())
)
def _handle_im_ai_message(self, message: Mapping[str, Any]) -> None:
if self._im_ai_context_is_trusted():
self._im_ai.handle(message)
def _flush_im_ai(self) -> None:
if not self._im_ai_context_is_trusted():
return
result = self._im_ai.take_result()
if result is not None:
payload = json.dumps(result, ensure_ascii=True, separators=(",", ":"))
self._page.runJavaScript(f"window.doctorConsultation?.imAiResult?.({payload});")
def _close_im_ai(self) -> None:
controller = getattr(self, "_im_ai", None)
if controller is not None:
controller.close()
timer = getattr(self, "_im_ai_timer", None)
if timer is not None:
timer.stop()
def _open_diagnosis_safely(self) -> None:
if self._closing or self._on_open_diagnosis is None:
return
@@ -1197,6 +1254,7 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
def _request_companion_shutdown(self, reason: str) -> None:
"""Let MediaRecorder finish and upload before WebEngine is destroyed."""
_EmbeddedVideoWindow._close_im_ai(self)
self._close_reason = reason
if self._closing or self._released:
return
@@ -1241,6 +1299,7 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
def _begin_shutdown(self) -> None:
if self._closing:
return
_EmbeddedVideoWindow._close_im_ai(self)
self._on_compact_close = None
self._closing = True
self._media_active = False
@@ -1342,6 +1401,7 @@ class VideoCallWindow:
patient_name: str = "患者",
patient_case: Mapping[str, Any] | None = None,
on_open_diagnosis: Callable[[], None] | None = None,
can_ai_assistant: bool = False,
) -> None:
del browser_opener # Reserved for a future authenticated handoff implementation.
try:
@@ -1360,6 +1420,7 @@ class VideoCallWindow:
self.open_im = bool(open_im)
self.patient_name = str(patient_name or "患者").strip() or "患者"
self.patient_case = dict(patient_case or {})
self.can_ai_assistant = can_ai_assistant is True
self.on_open_diagnosis = on_open_diagnosis
self.logger = logger or _LOGGER
self.location = resolve_companion_location(
@@ -1391,6 +1452,8 @@ class VideoCallWindow:
patient_name=self.patient_name,
patient_case=self.patient_case,
on_open_diagnosis=self.on_open_diagnosis,
can_ai_assistant=self.can_ai_assistant,
repository=self.repository,
)
except Exception:
self.lifecycle.end("window-open-failed")
@@ -1436,6 +1499,7 @@ def open_video_call(
patient_name: str = "患者",
patient_case: Mapping[str, Any] | None = None,
on_open_diagnosis: Callable[[], None] | None = None,
can_ai_assistant: bool = False,
) -> VideoCallWindow:
"""Create and immediately open a trusted embedded video window."""
@@ -1452,6 +1516,7 @@ def open_video_call(
patient_name=patient_name,
patient_case=patient_case,
on_open_diagnosis=on_open_diagnosis,
can_ai_assistant=can_ai_assistant,
).open()