Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cc37531a1 | ||
|
|
621b7ddd39 |
@@ -38,4 +38,3 @@ app/.test-tmp-stream/
|
||||
TUICallKit-Vue3/.env
|
||||
/.codegraph
|
||||
app/artifacts/
|
||||
/artifacts
|
||||
|
||||
@@ -1595,26 +1595,17 @@ async function goMorePage() {
|
||||
uni.navigateTo({ url: buildMorePageUrl() })
|
||||
}
|
||||
|
||||
function goEndlessGamePage() {
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.navigateToMiniProgram({
|
||||
appId: 'wx0c2a9d5ebad26a3f',
|
||||
path: 'tongji/endless-game/index',
|
||||
envVersion: 'release',
|
||||
fail(err) {
|
||||
if (err?.errMsg?.includes('cancel')) return
|
||||
uni.showToast({ title: '暂时无法打开课堂', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
function openGamePage(url) {
|
||||
uni.navigateTo({
|
||||
url: '/tongji/endless-game/index',
|
||||
url,
|
||||
fail() {
|
||||
uni.showToast({ title: '暂时无法打开游戏', icon: 'none' })
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
|
||||
function goEndlessGamePage() {
|
||||
openGamePage('/tongji/endless-game/index')
|
||||
}
|
||||
|
||||
function navToUser() {
|
||||
|
||||
@@ -308,63 +308,8 @@ function computeOutPellet(data: Record<string, any>): string {
|
||||
return formatNum(perDose * getDoseCount(data))
|
||||
}
|
||||
|
||||
/** 辅方出丸 = 辅方服用天数 × 每日次数 × 每袋用量 × 每次袋数;仅浓缩水丸且确有辅方药材时计算。 */
|
||||
function computeAuxOutPellet(data: Record<string, any>): string {
|
||||
if ((data.prescription_type || '浓缩水丸') !== '浓缩水丸' || !getAuxHerbs(data).length) return ''
|
||||
let raw = data.aux_usage
|
||||
if (typeof raw === 'string') {
|
||||
try {
|
||||
raw = JSON.parse(raw)
|
||||
} catch {
|
||||
raw = null
|
||||
}
|
||||
}
|
||||
const aux = normalizeAuxUsageForm(raw, '浓缩水丸')
|
||||
const days = Number(aux.usage_days)
|
||||
const times = Number(aux.times_per_day)
|
||||
const doseG = Number(aux.dosage_amount)
|
||||
const bags = Number(aux.dosage_bag_count) > 0 ? Number(aux.dosage_bag_count) : 1
|
||||
return days > 0 && times > 0 && doseG > 0 ? formatNum(days * times * doseG * bags) : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并业务订单的服用参数覆盖:已签署(CA 冻结)处方在订单中修改的次数/天数/袋数记在订单 usage_override,
|
||||
* 只作用于该订单的页面与药房下单,签署原文不变。与服务端 PrescriptionOrderLogic::applyUsageOverride 一致。
|
||||
*/
|
||||
export function applyOrderUsageOverride<T extends Record<string, any>>(rx: T, rawOverride: unknown): T {
|
||||
let override: unknown = rawOverride
|
||||
if (typeof override === 'string') {
|
||||
try {
|
||||
override = JSON.parse(override)
|
||||
} catch {
|
||||
override = null
|
||||
}
|
||||
}
|
||||
if (!override || typeof override !== 'object' || Array.isArray(override)) return rx
|
||||
const o = override as Record<string, any>
|
||||
const out: Record<string, any> = { ...rx }
|
||||
for (const key of ['times_per_day', 'usage_days', 'dosage_bag_count']) {
|
||||
if (o[key] != null && Number.isFinite(Number(o[key]))) out[key] = Number(o[key])
|
||||
}
|
||||
if (o.aux_usage && typeof o.aux_usage === 'object') {
|
||||
let aux = out.aux_usage
|
||||
if (typeof aux === 'string') {
|
||||
try {
|
||||
aux = JSON.parse(aux)
|
||||
} catch {
|
||||
aux = null
|
||||
}
|
||||
}
|
||||
out.aux_usage = { ...(aux && typeof aux === 'object' ? aux : {}), ...o.aux_usage }
|
||||
}
|
||||
out.usage_overridden = 1
|
||||
return out as T
|
||||
}
|
||||
|
||||
export function rxOutPelletText(data: Record<string, any> | null | undefined): string {
|
||||
if (!data) return ''
|
||||
const out = computeOutPellet(data)
|
||||
const aux = computeAuxOutPellet(data)
|
||||
if (out && aux) return `主方 ${out}克,辅方 ${aux}克`
|
||||
return out ? `${out}克` : ''
|
||||
}
|
||||
|
||||
@@ -701,16 +701,16 @@
|
||||
{{ requiresOriginalEsignPdf(savedPrescription.esign) ? '下载已签原始 PDF' : '下载PDF' }}
|
||||
</el-button>
|
||||
<el-tooltip
|
||||
v-if="savedPrescription.void_status !== 1 && savedPrescription.can_void !== false"
|
||||
:disabled="!hasLinkedPrescriptionOrder"
|
||||
content="作废后,关联的业务订单会在同诊单重新开方时自动关联到新处方"
|
||||
v-if="savedPrescription.void_status !== 1 && !approvedPreviewOnly"
|
||||
:disabled="!hasPrescriptionOrderBlockVoid"
|
||||
content="该处方已存在业务订单,无法作废,请前往已开处方里修改"
|
||||
placement="top"
|
||||
>
|
||||
<span class="inline-block">
|
||||
<el-button
|
||||
v-perms="['tcm.prescription/void']"
|
||||
type="danger"
|
||||
plain
|
||||
:disabled="hasPrescriptionOrderBlockVoid"
|
||||
:loading="voiding"
|
||||
@click="handleVoid"
|
||||
>
|
||||
@@ -1080,8 +1080,8 @@ const approvedPreviewOnly = computed(() => {
|
||||
return Number(s.audit_status) === 1 && Number(s.void_status) !== 1
|
||||
})
|
||||
|
||||
/** 已有关联业务订单(与列表 has_prescription_order 一致):作废时提示订单将随重新开方迁移 */
|
||||
const hasLinkedPrescriptionOrder = computed(() => {
|
||||
/** 已有关联业务订单(与列表 has_prescription_order 一致)则禁止作废 */
|
||||
const hasPrescriptionOrderBlockVoid = computed(() => {
|
||||
const s = savedPrescription.value
|
||||
if (!s) return false
|
||||
return Number(s.has_prescription_order) === 1
|
||||
@@ -2165,10 +2165,12 @@ const formatVoidTime = (ts: number | null | undefined) => {
|
||||
const handleVoid = async () => {
|
||||
const id = savedPrescription.value?.id
|
||||
if (!id) return
|
||||
if (Number(savedPrescription.value?.has_prescription_order) === 1) {
|
||||
feedback.msgWarning('该处方已存在业务订单,无法作废')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await feedback.confirm(Number(savedPrescription.value?.has_prescription_order) === 1
|
||||
? '确定要作废该处方吗?作废后不可恢复;已提交洛阳药房的订单会先撤销药房订单,关联的业务订单将退回待审核,同诊单重新开方后自动关联到新处方。'
|
||||
: '确定要作废该处方吗?作废后不可恢复。')
|
||||
await feedback.confirm('确定要作废该处方吗?作废后不可恢复。')
|
||||
voiding.value = true
|
||||
await prescriptionVoid({ id })
|
||||
feedback.msgSuccess('作废成功')
|
||||
|
||||
@@ -570,8 +570,8 @@
|
||||
size="small"
|
||||
link
|
||||
:loading="unlinkPayOrderId === Number(row.id)"
|
||||
:disabled="unlinkPayOrderId !== null || ![2, 4, 5].includes(Number(row.status))"
|
||||
:title="Number(row.status) === 4 ? '解除已退款收款记录的关联,已付金额不变' : '解除关联并更新已付金额,总金额不变'"
|
||||
:disabled="unlinkPayOrderId !== null || ![2, 5].includes(Number(row.status))"
|
||||
:title="Number(row.status) === 4 ? '已退款收款记录不可移除' : '解除关联并更新已付金额,总金额不变'"
|
||||
@click="confirmUnlinkPayOrder(row)"
|
||||
>移除</el-button>
|
||||
</template>
|
||||
@@ -964,22 +964,6 @@
|
||||
:rules="patchUsageRules"
|
||||
label-width="108px"
|
||||
>
|
||||
<el-alert
|
||||
v-if="usageFrozenBySignature"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-3"
|
||||
title="处方已电子签署:此处修改只作用于本订单的页面与药房下单,CA 签署的处方原件不变。"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="daysLocked"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-3"
|
||||
title="订单已发货,服用天数不可修改;次数、袋数仍可修改。"
|
||||
/>
|
||||
<div v-if="detailHasAuxHerbs" class="text-xs font-medium text-gray-500 mb-3">主方</div>
|
||||
<el-form-item
|
||||
v-if="detailPrescription?.prescription_type === '浓缩水丸'"
|
||||
@@ -1004,7 +988,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="patchUsageForm.usage_days"
|
||||
:disabled="daysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -1039,7 +1022,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="patchUsageForm.aux_usage_days"
|
||||
:disabled="daysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -1055,7 +1037,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="patchUsageForm.medication_days"
|
||||
:disabled="daysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -1189,7 +1170,7 @@ async function confirmUnlinkPayOrder(row: { id: number; order_no?: string; amoun
|
||||
const orderId = Number(detailData.value?.id)
|
||||
const payOrderId = Number(row.id)
|
||||
if (!canUnlinkPayOrder.value || !orderId || !payOrderId || unlinkPayOrderId.value !== null) return
|
||||
if (![2, 4, 5].includes(Number(row.status))) return
|
||||
if (![2, 5].includes(Number(row.status))) return
|
||||
|
||||
unlinkPayOrderId.value = payOrderId
|
||||
try {
|
||||
@@ -1372,14 +1353,7 @@ const detailLinkedAppointmentChannelText = computed(() => {
|
||||
|
||||
const detailRxHerbs = computed(() => normalizeSlipHerbs(detailPrescription.value?.herbs))
|
||||
|
||||
const detailHasAuxHerbs = computed(() => prescriptionHasAuxFormula(detailPrescription.value as any))
|
||||
/** 已发货的订单服用天数锁定(服务端 days_locked,同样拦截保存) */
|
||||
const daysLocked = computed(() => detailData.value?.days_locked === true)
|
||||
/** 处方已进入电子签署(内容冻结),服用参数改写为订单级覆盖值 */
|
||||
const usageFrozenBySignature = computed(() => {
|
||||
const esign = (detailPrescription.value as any)?.esign
|
||||
return esign?.required === true && esign?.status !== 'pending'
|
||||
})
|
||||
const detailHasAuxHerbs = computed(() => prescriptionHasAuxFormula(detailPrescription.value as any))
|
||||
|
||||
/** 详情:辅方用法(aux_usage JSON 经规范化后的对象,与处方类型一致) */
|
||||
const detailAuxUsage = computed(() => {
|
||||
|
||||
@@ -283,7 +283,7 @@
|
||||
审核
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canVoidPrescription(row)"
|
||||
v-if="canVoidPendingPrescription(row)"
|
||||
v-perms="['tcm.prescription/void']"
|
||||
type="danger"
|
||||
link
|
||||
@@ -440,26 +440,16 @@
|
||||
@click="handleReissue(slipView)"
|
||||
>重新开方</el-button>
|
||||
<el-button v-if="!requiresOriginalEsignPdf(slipView?.esign)" :icon="Printer" size="small" @click="handlePrintSlip">打印</el-button>
|
||||
<el-dropdown
|
||||
trigger="click"
|
||||
:disabled="viewDetailLoading || downloadingSlip"
|
||||
@command="handleDownloadSlip"
|
||||
<el-button
|
||||
type="primary"
|
||||
:icon="Download"
|
||||
size="small"
|
||||
:loading="downloadingSlip"
|
||||
:disabled="viewDetailLoading || (requiresOriginalEsignPdf(slipView?.esign) && !slipView?.esign?.can_download)"
|
||||
@click="handleDownloadSlip"
|
||||
>
|
||||
<el-button type="primary" :icon="Download" size="small" :loading="downloadingSlip">
|
||||
下载 PDF (A4)
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-if="requiresOriginalEsignPdf(slipView?.esign)"
|
||||
command="esign"
|
||||
:disabled="!slipView?.esign?.can_download"
|
||||
>CA 签署处方 PDF</el-dropdown-item>
|
||||
<el-dropdown-item command="internal">药房联 PDF</el-dropdown-item>
|
||||
<el-dropdown-item command="user">处方联 PDF</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
{{ requiresOriginalEsignPdf(slipView?.esign) ? '下载已签原始 PDF' : '下载 PDF (A4)' }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 状态提示(不进入打印区) -->
|
||||
@@ -1760,7 +1750,7 @@ import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import { usePrescriptionEsignConfig } from '@/hooks/usePrescriptionEsignConfig'
|
||||
import { canApprovePrescriptionEsign, downloadOriginalEsignPdf, pendingPrescriptionReviewLabel, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, pendingPrescriptionReviewLabel, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { prescriptionListSigningStatus } from './components/prescription-list-signing-status'
|
||||
import { Search, Download, Printer, EditPen } from '@element-plus/icons-vue'
|
||||
@@ -2038,10 +2028,7 @@ const patchPatientForm = reactive({
|
||||
const patchPatientRules: FormRules = {
|
||||
patient_name: [{ required: true, message: '请输入患者姓名', trigger: 'blur' }],
|
||||
gender: [{ required: true, message: '请选择性别', trigger: 'change' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{ pattern: /^(?:1[3-9]\d{9}|0\d{2,3}-?\d{7,8})$/, message: '请输入 11 位手机号或带区号的座机号', trigger: 'blur' }
|
||||
]
|
||||
phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
function openPatchPatientDialog(row: Record<string, unknown>) {
|
||||
@@ -2872,25 +2859,18 @@ function handlePrintSlip() {
|
||||
})
|
||||
}
|
||||
|
||||
/* === 下载 PDF(A4):CA 签署原件,或按当前笺面样式导出药房联 / 处方联 === */
|
||||
async function handleDownloadSlip(command: 'esign' | 'internal' | 'user') {
|
||||
if (downloadingSlip.value || !slipView.value) return
|
||||
if (command === 'esign') {
|
||||
downloadingSlip.value = true
|
||||
try {
|
||||
await downloadOriginalEsignPdf(Number(slipView.value.id))
|
||||
} catch (e: any) {
|
||||
feedback.msgError(e?.message || '下载签署文件失败')
|
||||
} finally {
|
||||
downloadingSlip.value = false
|
||||
}
|
||||
return
|
||||
}
|
||||
// 切到对应联次再截图,导出与页面一致的样式(含医师 / 药师签章)。
|
||||
if (prescriptionTabType.value !== command) {
|
||||
prescriptionTabType.value = command
|
||||
await nextTick()
|
||||
}
|
||||
/* === 下载 PDF(A4) === */
|
||||
async function handleDownloadSlip() {
|
||||
if (downloadingSlip.value) return
|
||||
downloadingSlip.value = true
|
||||
try {
|
||||
if (await downloadPrescriptionPdfIfRequired(Number(slipView.value?.id))) return
|
||||
} catch (e: any) {
|
||||
feedback.msgError(e?.message || '下载签署文件失败')
|
||||
return
|
||||
} finally {
|
||||
downloadingSlip.value = false
|
||||
}
|
||||
const node = getRxPaperEl()
|
||||
if (!node) {
|
||||
feedback.msgWarning('处方笺尚未渲染完成')
|
||||
@@ -2977,8 +2957,7 @@ async function handleDownloadSlip(command: 'esign' | 'internal' | 'user') {
|
||||
const name = (slipView.value as any)?.patient_name || '处方'
|
||||
const id = (slipView.value as any)?.id || ''
|
||||
const date = (slipView.value as any)?.prescription_date || ''
|
||||
const copy = command === 'internal' ? '药房联' : '处方联'
|
||||
pdf.save(`${copy}-${name}${date ? '-' + date : ''}${id ? '-' + id : ''}.pdf`)
|
||||
pdf.save(`处方-${name}${date ? '-' + date : ''}${id ? '-' + id : ''}.pdf`)
|
||||
} catch (e: any) {
|
||||
console.error('下载处方 PDF 失败:', e)
|
||||
feedback.msgError(e?.message || '下载失败,请重试')
|
||||
@@ -3359,20 +3338,17 @@ type VoidablePrescriptionRow = Parameters<typeof isPendingPrescriptionAudit>[0]
|
||||
can_review_prescription?: boolean
|
||||
}
|
||||
|
||||
/** 作废不再限于待审核:签署、审核通过或已有业务订单后也可作废(以服务端 can_void 为准) */
|
||||
function canVoidPrescription(row: VoidablePrescriptionRow) {
|
||||
return Number(row.void_status) !== 1 && row.can_void === true
|
||||
function canVoidPendingPrescription(row: VoidablePrescriptionRow) {
|
||||
return isPendingPrescriptionAudit(row) && row.can_void === true
|
||||
}
|
||||
|
||||
async function voidPendingPrescription(row: VoidablePrescriptionRow) {
|
||||
const id = Number(row.id)
|
||||
if (!Number.isSafeInteger(id) || id <= 0 || voidingPrescriptionId.value || !canVoidPrescription(row)) return
|
||||
if (!Number.isSafeInteger(id) || id <= 0 || voidingPrescriptionId.value || !canVoidPendingPrescription(row)) return
|
||||
voidingPrescriptionId.value = id
|
||||
try {
|
||||
await feedback.confirm(Number((row as { has_prescription_order?: number }).has_prescription_order) === 1
|
||||
? '确定作废这张处方吗?已提交洛阳药房的订单会先撤销药房订单;关联的业务订单将退回待审核,同诊单重新开方后自动关联到新处方。'
|
||||
: '确定作废这张处方吗?作废后可重新开方。')
|
||||
await prescriptionVoid({ id })
|
||||
await feedback.confirm('确定作废这张处方吗?作废后可重新开方。')
|
||||
await prescriptionVoid({ id, pending_only: true })
|
||||
row.void_status = 1
|
||||
row.can_void = false
|
||||
row.can_submit_for_review = false
|
||||
@@ -4107,10 +4083,10 @@ function openNewPrescription(source?: Record<string, any>) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 已作废处方(含他人所开、他人作废)均可由有开方权限的账号重新开方;新处方以当前账号为开方医生 */
|
||||
function canReissuePrescription(row: { creator_id?: number | string; void_status?: number | string }) {
|
||||
const doctorId = Number(userStore.userInfo?.id)
|
||||
return Number(row.void_status) === 1 && doctorId > 0 && hasPermission(['cf.prescription/add'])
|
||||
return Number(row.void_status) === 1 && doctorId > 0 && Number(row.creator_id) === doctorId
|
||||
&& hasPermission(['cf.prescription/add'])
|
||||
}
|
||||
|
||||
async function handleReissue(row: { id?: number | string; creator_id?: number | string; void_status?: number | string }) {
|
||||
|
||||
@@ -990,7 +990,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="editForm.medication_days"
|
||||
:disabled="editDaysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -1810,24 +1809,14 @@
|
||||
>
|
||||
下载图片
|
||||
</el-button>
|
||||
<el-dropdown
|
||||
trigger="click"
|
||||
:disabled="prescriptionSlipExporting"
|
||||
@command="downloadPrescriptionSlipPdf"
|
||||
<el-button
|
||||
size="small"
|
||||
:loading="prescriptionSlipExporting"
|
||||
:disabled="requiresOriginalEsignPdf(prescriptionViewData.esign) && !prescriptionViewData.esign?.can_download"
|
||||
@click="downloadPrescriptionSlipPdf"
|
||||
>
|
||||
<el-button size="small" type="primary" :loading="prescriptionSlipExporting">下载 PDF (A4)</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-if="requiresOriginalEsignPdf(prescriptionViewData.esign)"
|
||||
command="esign"
|
||||
:disabled="!prescriptionViewData.esign?.can_download"
|
||||
>CA 签署处方 PDF</el-dropdown-item>
|
||||
<el-dropdown-item command="internal">药房联 PDF(当前页面样式)</el-dropdown-item>
|
||||
<el-dropdown-item command="user">处方联 PDF(当前页面样式)</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
{{ requiresOriginalEsignPdf(prescriptionViewData.esign) ? '下载已签原始 PDF' : '下载PDF' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -2166,12 +2155,11 @@ import {
|
||||
getDoctors,
|
||||
getAssistants
|
||||
} from '@/api/tcm'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import { applyOrderUsageOverride } from '@/components/prescription-slip/utils'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { canApprovePrescriptionEsign, downloadOriginalEsignPdf, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
import { getDictData } from '@/api/app'
|
||||
@@ -3555,9 +3543,6 @@ async function goEditOrderNextStep() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 已发货订单服用天数锁定(来自订单详情 days_locked,服务端同样拦截) */
|
||||
const editDaysLocked = ref(false)
|
||||
|
||||
async function openEdit(row: {
|
||||
id: number
|
||||
creator_id?: number
|
||||
@@ -3631,8 +3616,7 @@ async function openEdit(row: {
|
||||
|
||||
editForm.shipping_address = d.shipping_address || ''
|
||||
editForm.is_follow_up = d.is_follow_up ? 1 : 0
|
||||
editForm.medication_days = d.medication_days > 0 ? d.medication_days : undefined
|
||||
editDaysLocked.value = d.days_locked === true
|
||||
editForm.medication_days = d.medication_days > 0 ? d.medication_days : undefined
|
||||
editForm.dose_count = d.dose_count > 0 ? d.dose_count : 1
|
||||
editForm.dose_unit = d.dose_unit || '剂'
|
||||
editForm.prev_staff = d.prev_staff || ''
|
||||
@@ -5013,8 +4997,7 @@ async function openPrescriptionView(row: any) {
|
||||
const base = res?.data ?? res ?? null
|
||||
if (base) {
|
||||
const md = row.medication_days
|
||||
// 已签署处方在本订单修改过的服用参数(订单 usage_override),笺面按本订单生效值显示;CA 签署原件不变。
|
||||
const merged: Record<string, unknown> = applyOrderUsageOverride({ ...base }, row.usage_override)
|
||||
const merged: Record<string, unknown> = { ...base }
|
||||
if (md != null && String(md).trim() !== '') {
|
||||
merged.medication_days = md
|
||||
}
|
||||
@@ -5147,8 +5130,7 @@ async function capturePrescriptionSlipCanvas(): Promise<HTMLCanvasElement> {
|
||||
function slipDownloadBaseName() {
|
||||
const name = prescriptionViewData.value?.patient_name
|
||||
const safe = typeof name === 'string' && name.trim() ? name.trim().replace(/[\\/:*?"<>|]/g, '_') : '未命名'
|
||||
const copy = prescriptionTabType.value === 'internal' ? '药房联' : '处方联'
|
||||
return `${copy}_${safe}_${Date.now()}`
|
||||
return `处方_${safe}_${Date.now()}`
|
||||
}
|
||||
|
||||
async function downloadPrescriptionSlipImage() {
|
||||
@@ -5168,19 +5150,11 @@ async function downloadPrescriptionSlipImage() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 下载 PDF:CA 签署原件,或按当前页面样式导出药房联 / 处方联(含本订单生效的服用参数与签章) */
|
||||
async function downloadPrescriptionSlipPdf(command: 'esign' | 'internal' | 'user' = 'internal') {
|
||||
async function downloadPrescriptionSlipPdf() {
|
||||
if (!prescriptionViewData.value) return
|
||||
prescriptionSlipExporting.value = true
|
||||
try {
|
||||
if (command === 'esign') {
|
||||
await downloadOriginalEsignPdf(Number(prescriptionViewData.value.id))
|
||||
return
|
||||
}
|
||||
if (prescriptionTabType.value !== command) {
|
||||
prescriptionTabType.value = command
|
||||
await nextTick()
|
||||
}
|
||||
if (await downloadPrescriptionPdfIfRequired(Number(prescriptionViewData.value.id))) return
|
||||
const canvas = await capturePrescriptionSlipCanvas()
|
||||
const imgData = canvas.toDataURL('image/jpeg', 0.95)
|
||||
/**
|
||||
|
||||
@@ -1570,7 +1570,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="editForm.medication_days"
|
||||
:disabled="editDaysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -2324,7 +2323,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="patchUsageForm.usage_days"
|
||||
:disabled="patchUsageDaysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -2359,7 +2357,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="patchUsageForm.aux_usage_days"
|
||||
:disabled="patchUsageDaysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -2375,7 +2372,6 @@
|
||||
<div class="flex items-center gap-1 w-full">
|
||||
<el-input-number
|
||||
v-model="patchUsageForm.medication_days"
|
||||
:disabled="patchUsageDaysLocked"
|
||||
:min="1"
|
||||
:max="999"
|
||||
:step="1"
|
||||
@@ -2413,24 +2409,14 @@
|
||||
>
|
||||
下载图片
|
||||
</el-button>
|
||||
<el-dropdown
|
||||
trigger="click"
|
||||
:disabled="prescriptionSlipExporting"
|
||||
@command="downloadPrescriptionSlipPdf"
|
||||
<el-button
|
||||
size="small"
|
||||
:loading="prescriptionSlipExporting"
|
||||
:disabled="requiresOriginalEsignPdf(prescriptionViewData.esign) && !prescriptionViewData.esign?.can_download"
|
||||
@click="downloadPrescriptionSlipPdf"
|
||||
>
|
||||
<el-button size="small" type="primary" :loading="prescriptionSlipExporting">下载 PDF (A4)</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-if="requiresOriginalEsignPdf(prescriptionViewData.esign)"
|
||||
command="esign"
|
||||
:disabled="!prescriptionViewData.esign?.can_download"
|
||||
>CA 签署处方 PDF</el-dropdown-item>
|
||||
<el-dropdown-item command="internal">药房联 PDF(当前页面样式)</el-dropdown-item>
|
||||
<el-dropdown-item command="user">处方联 PDF(当前页面样式)</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
{{ requiresOriginalEsignPdf(prescriptionViewData.esign) ? '下载已签原始 PDF' : '下载PDF' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -2733,12 +2719,11 @@ import {
|
||||
supplyModeLabel,
|
||||
supplyModeTagType
|
||||
} from './components/prescription-order-utils'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import { applyOrderUsageOverride } from '@/components/prescription-slip/utils'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { canApprovePrescriptionEsign, downloadOriginalEsignPdf, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
import { getDictData } from '@/api/app'
|
||||
@@ -3799,9 +3784,7 @@ const detailLinkedAppointmentResolvedFromTag = computed(() => {
|
||||
|
||||
const detailRxHerbs = computed(() => normalizeSlipHerbs(detailPrescription.value?.herbs))
|
||||
|
||||
const detailHasAuxHerbs = computed(() => prescriptionHasAuxFormula(detailPrescription.value as any))
|
||||
/** 已发货订单服用天数锁定(服务端 days_locked,同样拦截保存) */
|
||||
const patchUsageDaysLocked = computed(() => detailData.value?.days_locked === true)
|
||||
const detailHasAuxHerbs = computed(() => prescriptionHasAuxFormula(detailPrescription.value as any))
|
||||
|
||||
const detailAuxUsage = computed(() => {
|
||||
const rx = detailPrescription.value as any
|
||||
@@ -4537,9 +4520,6 @@ async function goEditOrderNextStep() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 已发货订单服用天数锁定(来自订单详情 days_locked,服务端同样拦截) */
|
||||
const editDaysLocked = ref(false)
|
||||
|
||||
async function openEdit(row: {
|
||||
id: number
|
||||
creator_id?: number
|
||||
@@ -4613,8 +4593,7 @@ async function openEdit(row: {
|
||||
|
||||
editForm.shipping_address = d.shipping_address || ''
|
||||
editForm.is_follow_up = d.is_follow_up ? 1 : 0
|
||||
editForm.medication_days = d.medication_days > 0 ? d.medication_days : undefined
|
||||
editDaysLocked.value = d.days_locked === true
|
||||
editForm.medication_days = d.medication_days > 0 ? d.medication_days : undefined
|
||||
editForm.dose_count = d.dose_count > 0 ? d.dose_count : 1
|
||||
editForm.dose_unit = d.dose_unit || '剂'
|
||||
editForm.prev_staff = d.prev_staff || ''
|
||||
@@ -5771,8 +5750,7 @@ async function openPrescriptionView(row: any) {
|
||||
const base = res?.data ?? res ?? null
|
||||
if (base) {
|
||||
const md = row.medication_days
|
||||
// 已签署处方在本订单修改过的服用参数(订单 usage_override),笺面按本订单生效值显示;CA 签署原件不变。
|
||||
const merged: Record<string, unknown> = applyOrderUsageOverride({ ...base }, row.usage_override)
|
||||
const merged: Record<string, unknown> = { ...base }
|
||||
if (md != null && String(md).trim() !== '') {
|
||||
merged.medication_days = md
|
||||
}
|
||||
@@ -5902,8 +5880,7 @@ async function capturePrescriptionSlipCanvas(): Promise<HTMLCanvasElement> {
|
||||
function slipDownloadBaseName() {
|
||||
const name = prescriptionViewData.value?.patient_name
|
||||
const safe = typeof name === 'string' && name.trim() ? name.trim().replace(/[\\/:*?"<>|]/g, '_') : '未命名'
|
||||
const copy = prescriptionTabType.value === 'internal' ? '药房联' : '处方联'
|
||||
return `${copy}_${safe}_${Date.now()}`
|
||||
return `处方_${safe}_${Date.now()}`
|
||||
}
|
||||
|
||||
async function downloadPrescriptionSlipImage() {
|
||||
@@ -5923,19 +5900,11 @@ async function downloadPrescriptionSlipImage() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 下载 PDF:CA 签署原件,或按当前页面样式导出药房联 / 处方联(含本订单生效的服用参数与签章) */
|
||||
async function downloadPrescriptionSlipPdf(command: 'esign' | 'internal' | 'user' = 'internal') {
|
||||
async function downloadPrescriptionSlipPdf() {
|
||||
if (!prescriptionViewData.value) return
|
||||
prescriptionSlipExporting.value = true
|
||||
try {
|
||||
if (command === 'esign') {
|
||||
await downloadOriginalEsignPdf(Number(prescriptionViewData.value.id))
|
||||
return
|
||||
}
|
||||
if (prescriptionTabType.value !== command) {
|
||||
prescriptionTabType.value = command
|
||||
await nextTick()
|
||||
}
|
||||
if (await downloadPrescriptionPdfIfRequired(Number(prescriptionViewData.value.id))) return
|
||||
const canvas = await capturePrescriptionSlipCanvas()
|
||||
const imgData = canvas.toDataURL('image/jpeg', 0.95)
|
||||
/**
|
||||
|
||||
@@ -1425,7 +1425,7 @@ test('list upload can retry and opens signing without exposing audit to the phar
|
||||
assert.match(messages[0], /请完成医师签署/)
|
||||
})
|
||||
|
||||
test('issued prescriptions can be voided in any review state when the server allows it', async () => {
|
||||
test('issued prescriptions can void pending drafts with permission and keep the record', async () => {
|
||||
const calls = []
|
||||
const messages = []
|
||||
let cancel = true
|
||||
@@ -1443,26 +1443,24 @@ test('issued prescriptions can be voided in any review state when the server all
|
||||
msgSuccess: (message) => messages.push(message)
|
||||
}
|
||||
}
|
||||
const { canVoidPrescription, voidPendingPrescription } = pageDeclarations(
|
||||
const { canVoidPendingPrescription, voidPendingPrescription } = pageDeclarations(
|
||||
'views/consumer/prescription/index.vue',
|
||||
['canVoidPrescription', 'voidPendingPrescription'], globals
|
||||
['isPendingPrescriptionAudit', 'canVoidPendingPrescription', 'voidPendingPrescription'], globals
|
||||
)
|
||||
assert.equal(canVoidPrescription(row), true)
|
||||
// 审核通过(药师已签署)后仍可作废;以服务端 can_void 为准。
|
||||
assert.equal(canVoidPrescription({ ...row, audit_status: 1 }), true)
|
||||
for (const other of [{ void_status: 1 }, { can_void: false }]) {
|
||||
assert.equal(canVoidPendingPrescription(row), true)
|
||||
for (const other of [{ audit_status: 1 }, { audit_status: 2 }, { void_status: 1 }, { can_void: false }]) {
|
||||
await voidPendingPrescription({ ...row, ...other })
|
||||
}
|
||||
await voidPendingPrescription(row)
|
||||
assert.deepEqual(calls, [])
|
||||
cancel = false
|
||||
await voidPendingPrescription(row)
|
||||
assert.equal(canVoidPrescription(row), true)
|
||||
assert.equal(canVoidPendingPrescription(row), true)
|
||||
await Promise.all([voidPendingPrescription(row), voidPendingPrescription(row)])
|
||||
assert.deepEqual(calls, [{ id: 17 }, { id: 17 }])
|
||||
assert.deepEqual(calls, [{ id: 17, pending_only: true }, { id: 17, pending_only: true }])
|
||||
assert.equal(row.void_status, 1)
|
||||
assert.equal(row.can_submit_for_review, false)
|
||||
assert.equal(canVoidPrescription(row), false)
|
||||
assert.equal(canVoidPendingPrescription(row), false)
|
||||
assert.equal(refreshes, 1)
|
||||
assert.deepEqual(messages, ['处方已作废'])
|
||||
})
|
||||
@@ -1506,9 +1504,8 @@ test('issued prescriptions reopen a voided record as a new prescription with fre
|
||||
['resetForm', 'fillPrescriptionContents', 'openNewPrescription', 'handleAdd', 'canReissuePrescription', 'handleReissue', 'handleSubmit'], globals
|
||||
)
|
||||
assert.equal(canReissuePrescription(source), true)
|
||||
// 他人所开、已作废的处方也可由有开方权限的账号重新开方。
|
||||
assert.equal(canReissuePrescription({ ...source, creator_id: 9 }), true)
|
||||
await handleReissue({ ...source, void_status: 0 })
|
||||
await handleReissue({ ...source, creator_id: 9 })
|
||||
permitted = false
|
||||
await handleReissue(source)
|
||||
assert.deepEqual(reads, [])
|
||||
|
||||
@@ -7,5 +7,5 @@ __version__ = "1.5.6"
|
||||
|
||||
# 调试模式开启时,登录页显示“演示模式”和“服务器设置”。
|
||||
# 正式发布请保持 False;此时程序只使用下面配置的线上域名。
|
||||
DEBUG_MODE = False
|
||||
DEBUG_MODE = True
|
||||
ONLINE_API_BASE_URL = "https://admin.zhenyangtang.com.cn"
|
||||
|
||||
@@ -16,11 +16,6 @@ from PySide6.QtGui import QGuiApplication, QIcon
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QDialog,
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
@@ -35,14 +30,15 @@ from doctor_workstation.services import (
|
||||
TokenStore,
|
||||
build_repository,
|
||||
)
|
||||
from doctor_workstation.ui import LoginWindow, ShellWindow, apply_theme
|
||||
from doctor_workstation.ui import LoginWindow, ShellWindow, SpatialShellWindow, apply_theme
|
||||
from doctor_workstation.ui.dialogs.app_update import AppUpdateSession
|
||||
from doctor_workstation.ui.dialogs.video_cockpit import VideoCockpitDemoDialog as DemoVideoDialog
|
||||
from doctor_workstation.ui.widgets import (
|
||||
first_value,
|
||||
friendly_error,
|
||||
gender_text,
|
||||
get_value,
|
||||
has_permission,
|
||||
has_permission,
|
||||
run_async,
|
||||
set_authentication_expired_handler,
|
||||
show_toast,
|
||||
@@ -295,109 +291,6 @@ class _UnconfiguredRepository:
|
||||
return None
|
||||
|
||||
|
||||
class DemoVideoDialog(QDialog):
|
||||
"""Non-network video-room preview used only by the explicit demo mode."""
|
||||
|
||||
def __init__(self, patient_name: str, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self._seconds = 0
|
||||
self.setWindowTitle("视频面诊 · 演示模式")
|
||||
self.setMinimumSize(760, 520)
|
||||
self.resize(980, 660)
|
||||
self.setModal(False)
|
||||
self.setStyleSheet(
|
||||
"QDialog{background:#F7F9FE;color:#111F46;}"
|
||||
"QLabel{color:#111F46;}"
|
||||
"QFrame#RemoteStage{background:#0E1421;border:1px solid #29334F;border-radius:16px;}"
|
||||
"QFrame#RemoteStage QLabel{color:#F7F9FE;}"
|
||||
"QFrame#LocalStage{background:#151D31;border:1px solid #3F4E75;border-radius:12px;}"
|
||||
"QPushButton{min-width:96px;min-height:40px;padding:0 16px;border-radius:9px;"
|
||||
"background:#FFFFFF;color:#3F4E75;border:1px solid #E6EAF5;font-weight:600;}"
|
||||
"QPushButton:hover{color:#4451E2;background:#F0F2FF;border-color:#5761F4;}"
|
||||
"QPushButton:checked{color:#FFFFFF;background:#5761F4;border-color:#5761F4;}"
|
||||
"QPushButton#Hangup{color:#FFFFFF;background:#C23D4E;border-color:#C23D4E;}"
|
||||
"QPushButton#Hangup:hover{background:#D94857;border-color:#D94857;}"
|
||||
)
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(22, 18, 22, 22)
|
||||
root.setSpacing(14)
|
||||
header = QHBoxLayout()
|
||||
title = QLabel(f"与 {patient_name or '患者'} 的视频面诊")
|
||||
title.setStyleSheet("font-size:18px;font-weight:700;")
|
||||
header.addWidget(title)
|
||||
header.addStretch(1)
|
||||
demo = QLabel("● 演示模式 · 未连接腾讯云")
|
||||
demo.setStyleSheet("color:#707584;font-size:12px;")
|
||||
header.addWidget(demo)
|
||||
self.duration_label = QLabel("00:00")
|
||||
self.duration_label.setStyleSheet("font-weight:700;")
|
||||
header.addWidget(self.duration_label)
|
||||
root.addLayout(header)
|
||||
|
||||
stage = QFrame()
|
||||
stage.setObjectName("RemoteStage")
|
||||
stage_layout = QVBoxLayout(stage)
|
||||
stage_layout.setContentsMargins(22, 22, 22, 22)
|
||||
stage_layout.addStretch(1)
|
||||
avatar = QLabel((patient_name or "患")[:1])
|
||||
avatar.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
avatar.setFixedSize(104, 104)
|
||||
avatar.setStyleSheet(
|
||||
"background:#F0F2FF;color:#5761F4;border-radius:52px;font-size:42px;font-weight:700;"
|
||||
)
|
||||
stage_layout.addWidget(avatar, 0, Qt.AlignmentFlag.AlignHCenter)
|
||||
waiting = QLabel("等待患者接听…")
|
||||
waiting.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
waiting.setStyleSheet("font-size:17px;font-weight:600;")
|
||||
stage_layout.addWidget(waiting)
|
||||
hint = QLabel("生产模式将通过后端短时 UserSig 初始化腾讯 TUICallKit")
|
||||
hint.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
hint.setStyleSheet("color:#A4ADC3;font-size:12px;")
|
||||
stage_layout.addWidget(hint)
|
||||
stage_layout.addStretch(1)
|
||||
|
||||
local = QFrame(stage)
|
||||
local.setObjectName("LocalStage")
|
||||
local.setGeometry(24, 24, 178, 112)
|
||||
local_layout = QVBoxLayout(local)
|
||||
local_label = QLabel("医生画面")
|
||||
local_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
local_label.setStyleSheet("color:#D9E0F2;font-weight:600;")
|
||||
local_layout.addWidget(local_label)
|
||||
root.addWidget(stage, 1)
|
||||
|
||||
controls = QHBoxLayout()
|
||||
controls.addStretch(1)
|
||||
self.mic_button = QPushButton("麦克风 开")
|
||||
self.mic_button.setCheckable(True)
|
||||
self.mic_button.toggled.connect(
|
||||
lambda muted: self.mic_button.setText("麦克风 关" if muted else "麦克风 开")
|
||||
)
|
||||
controls.addWidget(self.mic_button)
|
||||
self.camera_button = QPushButton("摄像头 开")
|
||||
self.camera_button.setCheckable(True)
|
||||
self.camera_button.toggled.connect(
|
||||
lambda off: self.camera_button.setText("摄像头 关" if off else "摄像头 开")
|
||||
)
|
||||
controls.addWidget(self.camera_button)
|
||||
hangup = QPushButton("结束面诊")
|
||||
hangup.setObjectName("Hangup")
|
||||
hangup.clicked.connect(self.close)
|
||||
controls.addWidget(hangup)
|
||||
controls.addStretch(1)
|
||||
root.addLayout(controls)
|
||||
|
||||
self._timer = QTimer(self)
|
||||
self._timer.timeout.connect(self._tick)
|
||||
self._timer.start(1000)
|
||||
|
||||
def _tick(self) -> None:
|
||||
self._seconds += 1
|
||||
minutes, seconds = divmod(self._seconds, 60)
|
||||
self.duration_label.setText(f"{minutes:02d}:{seconds:02d}")
|
||||
|
||||
|
||||
class ApplicationController(QObject):
|
||||
"""Own windows, repositories and the authenticated application lifecycle."""
|
||||
|
||||
@@ -414,8 +307,8 @@ class ApplicationController(QObject):
|
||||
self.current_repository: Any = None
|
||||
self.current_demo_mode = self.debug_mode and config.demo_mode
|
||||
self.video_calls: dict[str, Any] = {}
|
||||
self.video_pending: dict[str, object] = {}
|
||||
self._pending_im_request: tuple[str, object] | None = None
|
||||
self.video_pending: dict[str, object] = {}
|
||||
self._pending_im_request: tuple[str, object] | None = None
|
||||
self.demo_video_dialogs: dict[str, DemoVideoDialog] = {}
|
||||
self._video_preview_state: dict[str, Any] | None = None
|
||||
self._video_preview_generation = 0
|
||||
@@ -696,7 +589,7 @@ class ApplicationController(QObject):
|
||||
self._authentication_expiry_in_progress = False
|
||||
self.current_demo_mode = demo_mode
|
||||
set_authentication_expired_handler(self._on_authentication_expired)
|
||||
self.shell_window = ShellWindow(repository, payload, session.permissions)
|
||||
self.shell_window = SpatialShellWindow(repository, payload, session.permissions)
|
||||
self.shell_window.logout_requested.connect(self._logout)
|
||||
self.shell_window.close_requested.connect(self.request_quit)
|
||||
self.shell_window.video_requested.connect(self._request_video)
|
||||
@@ -790,8 +683,8 @@ class ApplicationController(QObject):
|
||||
call.close()
|
||||
self._wait_for_video_lifecycle(calls, timeout=1.25)
|
||||
self.video_calls.clear()
|
||||
self.video_pending.clear()
|
||||
self._pending_im_request = None
|
||||
self.video_pending.clear()
|
||||
self._pending_im_request = None
|
||||
for dialog in tuple(self.demo_video_dialogs.values()):
|
||||
dialog.close()
|
||||
self.demo_video_dialogs.clear()
|
||||
@@ -821,8 +714,8 @@ class ApplicationController(QObject):
|
||||
if parent is None or self.current_repository is None:
|
||||
return
|
||||
patient_id = payload.get("patient_id")
|
||||
diagnosis_id = payload.get("diagnosis_id")
|
||||
appointment_id = int(payload.get("appointment_id") or 0)
|
||||
diagnosis_id = payload.get("diagnosis_id")
|
||||
appointment_id = int(payload.get("appointment_id") or 0)
|
||||
patient_name = str(payload.get("patient_name") or "患者")
|
||||
open_im = str(payload.get("mode") or "video").lower() == "im"
|
||||
fallback_record = payload.get("record")
|
||||
@@ -830,16 +723,16 @@ class ApplicationController(QObject):
|
||||
show_toast(parent, "患者或诊单信息不完整,无法发起视频。", "danger", 4200)
|
||||
return
|
||||
|
||||
call_key = f"{diagnosis_id}:{appointment_id}"
|
||||
if open_im and self._pending_im_request is not None:
|
||||
pending_key, pending_marker = self._pending_im_request
|
||||
if pending_key != call_key:
|
||||
# Retire a previous selection before any early return, including
|
||||
# when the selected IM window is already open.
|
||||
if self.video_pending.get(pending_key) is pending_marker:
|
||||
self.video_pending.pop(pending_key, None)
|
||||
self._pending_im_request = None
|
||||
existing_call = self.video_calls.get(call_key)
|
||||
call_key = f"{diagnosis_id}:{appointment_id}"
|
||||
if open_im and self._pending_im_request is not None:
|
||||
pending_key, pending_marker = self._pending_im_request
|
||||
if pending_key != call_key:
|
||||
# Retire a previous selection before any early return, including
|
||||
# when the selected IM window is already open.
|
||||
if self.video_pending.get(pending_key) is pending_marker:
|
||||
self.video_pending.pop(pending_key, None)
|
||||
self._pending_im_request = None
|
||||
existing_call = self.video_calls.get(call_key)
|
||||
if open_im and existing_call is not None and getattr(existing_call, "open_im", False):
|
||||
qt_window = getattr(existing_call, "qt_window", None)
|
||||
if qt_window is not None:
|
||||
@@ -885,18 +778,18 @@ class ApplicationController(QObject):
|
||||
)
|
||||
repository = self.current_repository
|
||||
marker = object()
|
||||
self.video_pending[call_key] = marker
|
||||
if open_im:
|
||||
self._pending_im_request = (call_key, marker)
|
||||
self.video_pending[call_key] = marker
|
||||
if open_im:
|
||||
self._pending_im_request = (call_key, marker)
|
||||
|
||||
def get_video_context() -> tuple[Any, dict[str, str]]:
|
||||
ticket = repository.get_call_ticket(
|
||||
patient_id=int(patient_id),
|
||||
diagnosis_id=int(diagnosis_id),
|
||||
appointment_id=appointment_id,
|
||||
)
|
||||
if appointment_id and int(ticket.raw.get("appointment_id") or 0) != appointment_id:
|
||||
raise ValueError("通话凭证与本次挂号不匹配,请重新打开聊天窗口。")
|
||||
diagnosis_id=int(diagnosis_id),
|
||||
appointment_id=appointment_id,
|
||||
)
|
||||
if appointment_id and int(ticket.raw.get("appointment_id") or 0) != appointment_id:
|
||||
raise ValueError("通话凭证与本次挂号不匹配,请重新打开聊天窗口。")
|
||||
detail: Any = {}
|
||||
detail_loader = getattr(repository, "patient_detail", None)
|
||||
if callable(detail_loader):
|
||||
@@ -957,12 +850,12 @@ class ApplicationController(QObject):
|
||||
parent: QWidget,
|
||||
error: Exception,
|
||||
) -> None:
|
||||
if self.video_pending.get(call_key) is not marker:
|
||||
return
|
||||
self.video_pending.pop(call_key, None)
|
||||
if self._pending_im_request == (call_key, marker):
|
||||
self._pending_im_request = None
|
||||
if self.shell_window is parent:
|
||||
if self.video_pending.get(call_key) is not marker:
|
||||
return
|
||||
self.video_pending.pop(call_key, None)
|
||||
if self._pending_im_request == (call_key, marker):
|
||||
self._pending_im_request = None
|
||||
if self.shell_window is parent:
|
||||
show_toast(
|
||||
parent,
|
||||
f"视频准备失败:{friendly_error(error)}",
|
||||
@@ -983,11 +876,11 @@ class ApplicationController(QObject):
|
||||
patient_name: str = "患者",
|
||||
patient_case: Mapping[str, Any] | None = None,
|
||||
) -> None:
|
||||
if self.video_pending.get(call_key) is not marker:
|
||||
return
|
||||
self.video_pending.pop(call_key, None)
|
||||
if self._pending_im_request == (call_key, marker):
|
||||
self._pending_im_request = None
|
||||
if self.video_pending.get(call_key) is not marker:
|
||||
return
|
||||
self.video_pending.pop(call_key, None)
|
||||
if self._pending_im_request == (call_key, marker):
|
||||
self._pending_im_request = None
|
||||
if (
|
||||
self.shell_window is None
|
||||
or self.current_repository is not repository
|
||||
@@ -1012,13 +905,13 @@ 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)
|
||||
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)
|
||||
),
|
||||
)
|
||||
except Exception as error:
|
||||
@@ -1040,7 +933,7 @@ class ApplicationController(QObject):
|
||||
)
|
||||
)
|
||||
|
||||
def _open_video_diagnosis(self, diagnosis_id: Any, *, call_key: str) -> None:
|
||||
def _open_video_diagnosis(self, diagnosis_id: Any, *, call_key: str) -> None:
|
||||
"""Open the diagnosis while keeping its live video visible as a preview."""
|
||||
|
||||
shell = self.shell_window
|
||||
@@ -1049,7 +942,7 @@ class ApplicationController(QObject):
|
||||
dialog = shell.open_diagnosis_by_id(diagnosis_id, modeless=True)
|
||||
if dialog is None:
|
||||
return
|
||||
call = self.video_calls.get(call_key)
|
||||
call = self.video_calls.get(call_key)
|
||||
video_window = getattr(call, "qt_window", None)
|
||||
if video_window is not None:
|
||||
self._show_video_preview(video_window, dialog)
|
||||
@@ -1082,8 +975,8 @@ class ApplicationController(QObject):
|
||||
preview_height = min(380, max(320, round(preview_width * 0.66)))
|
||||
margin = 18
|
||||
|
||||
if callable(getattr(video_window, "setProperty", None)):
|
||||
video_window.setProperty("doctorSkipOpenGeometry", True)
|
||||
if callable(getattr(video_window, "setProperty", None)):
|
||||
video_window.setProperty("doctorSkipOpenGeometry", True)
|
||||
video_window.showNormal()
|
||||
video_window.setMinimumSize(440, 300)
|
||||
video_window.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint, True)
|
||||
@@ -1102,14 +995,14 @@ class ApplicationController(QObject):
|
||||
lambda _result, expected=generation: self._restore_video_preview(expected)
|
||||
)
|
||||
try:
|
||||
set_close_handler = getattr(video_window, "set_compact_close_handler", None)
|
||||
if callable(set_close_handler):
|
||||
set_close_handler(lambda expected=generation: self._restore_video_preview(expected))
|
||||
set_close_handler = getattr(video_window, "set_compact_close_handler", None)
|
||||
if callable(set_close_handler):
|
||||
set_close_handler(lambda expected=generation: self._restore_video_preview(expected))
|
||||
video_window.raise_()
|
||||
dialog.raise_()
|
||||
dialog.activateWindow()
|
||||
except RuntimeError:
|
||||
self._restore_video_preview(generation, activate=False)
|
||||
self._restore_video_preview(generation, activate=False)
|
||||
|
||||
def _restore_video_preview(
|
||||
self,
|
||||
@@ -1126,12 +1019,12 @@ class ApplicationController(QObject):
|
||||
self._video_preview_generation += 1
|
||||
window = state.get("window")
|
||||
try:
|
||||
set_close_handler = getattr(window, "set_compact_close_handler", None)
|
||||
if callable(set_close_handler):
|
||||
set_close_handler(None)
|
||||
restore_screenshot = getattr(window, "restore_screenshot_preview", None)
|
||||
if callable(restore_screenshot):
|
||||
restore_screenshot()
|
||||
set_close_handler = getattr(window, "set_compact_close_handler", None)
|
||||
if callable(set_close_handler):
|
||||
set_close_handler(None)
|
||||
restore_screenshot = getattr(window, "restore_screenshot_preview", None)
|
||||
if callable(restore_screenshot):
|
||||
restore_screenshot()
|
||||
window.setWindowFlag(
|
||||
Qt.WindowType.WindowStaysOnTopHint,
|
||||
bool(state.get("stays_on_top")),
|
||||
@@ -1147,8 +1040,8 @@ class ApplicationController(QObject):
|
||||
window.raise_()
|
||||
if activate:
|
||||
window.activateWindow()
|
||||
if callable(getattr(window, "setProperty", None)):
|
||||
window.setProperty("doctorSkipOpenGeometry", False)
|
||||
if callable(getattr(window, "setProperty", None)):
|
||||
window.setProperty("doctorSkipOpenGeometry", False)
|
||||
except (AttributeError, RuntimeError):
|
||||
return
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from .login import LoginWindow
|
||||
from .shell import ShellWindow
|
||||
from .shell_spatial import SpatialShellWindow
|
||||
from .theme import apply_theme
|
||||
|
||||
__all__ = ["LoginWindow", "ShellWindow", "apply_theme"]
|
||||
__all__ = ["LoginWindow", "ShellWindow", "SpatialShellWindow", "apply_theme"]
|
||||
|
||||
@@ -41,10 +41,10 @@ from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from ..core.appointment_modes import APPOINTMENT_MODES
|
||||
from .design_system import clinical_stylesheet
|
||||
from .theme import main_window_target_rect
|
||||
from .widgets import (
|
||||
from ..core.appointment_modes import APPOINTMENT_MODES
|
||||
from .design_system import PALETTE, clinical_stylesheet
|
||||
from .theme import main_window_target_rect
|
||||
from .widgets import (
|
||||
display_text,
|
||||
first_value,
|
||||
friendly_error,
|
||||
@@ -640,7 +640,7 @@ class _Spinner(QWidget):
|
||||
del event
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
pen = QPen(QColor("#4F63D9"), 3)
|
||||
pen = QPen(QColor(PALETTE["accent"]), 3)
|
||||
pen.setCapStyle(Qt.PenCapStyle.RoundCap)
|
||||
painter.setPen(pen)
|
||||
painter.drawArc(self.rect().adjusted(4, 4, -4, -4), self._angle * 16, 255 * 16)
|
||||
|
||||
@@ -31,22 +31,27 @@ _QSS = """
|
||||
background: $ds_surface; border: 1px solid $ds_line; border-radius: $ds_radius_panel;
|
||||
}
|
||||
#AppointmentsPage QPushButton {
|
||||
min-height: 30px; padding: 0 12px; border: 1px solid transparent;
|
||||
border-radius: $ds_radius_control; background: $ds_surface_alt;
|
||||
min-height: 32px; padding: 0 13px; border: 1px solid $ds_line_strong;
|
||||
border-radius: $ds_radius_control; background: $ds_surface; color: $ds_text;
|
||||
font-weight: 500;
|
||||
}
|
||||
#AppointmentsPage QPushButton:hover { color: $ds_accent; background: $ds_surface_alt; border-color: $ds_line_strong; }
|
||||
#AppointmentsPage QPushButton:pressed { background: $ds_accent_soft; }
|
||||
#AppointmentsPage QPushButton:hover { color: $ds_accent; background: $ds_accent_soft; border-color: #9CCFC7; }
|
||||
#AppointmentsPage QPushButton:pressed { background: #D7EFEA; }
|
||||
#AppointmentsPage QPushButton:focus { border-color: $ds_focus; }
|
||||
#AppointmentsPage QPushButton[variant="primary"] {
|
||||
background: $ds_accent; color: $ds_surface; border-color: $ds_accent;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $ds_accent);
|
||||
color: $ds_surface; border-color: $ds_accent;
|
||||
}
|
||||
#AppointmentsPage QPushButton[variant="primary"]:hover {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $ds_accent_hover);
|
||||
border-color: $ds_accent_hover;
|
||||
}
|
||||
#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: $ds_danger; background: $ds_danger_soft; border-color: transparent;
|
||||
color: $ds_danger; background: $ds_danger_soft; border-color: #F5C8CD;
|
||||
}
|
||||
#AppointmentsPage QPushButton[variant="danger"]:hover { background: $ds_danger_soft; }
|
||||
#AppointmentsPage QPushButton[variant="danger"]:hover { background: #FBDCE0; border-color: #E79DA6; }
|
||||
#AppointmentsPage QPushButton[variant="danger"]:pressed { border-color: $ds_danger; }
|
||||
#AppointmentsPage QPushButton[variant="ghost"] { background: transparent; border-color: transparent; }
|
||||
#AppointmentsPage QPushButton[variant="ghost"]:hover { background: $ds_accent_soft; }
|
||||
@@ -101,9 +106,20 @@ _QSS = """
|
||||
min-height: 36px; max-height: 36px; padding: 0 17px; font-size: 13px;
|
||||
}
|
||||
#AppointmentsPage QFrame#AppointmentToolbar QPushButton[variant="secondary"]:enabled {
|
||||
color: $ds_text; border-color: transparent;
|
||||
color: $ds_text;
|
||||
background: $ds_surface;
|
||||
border: 1px solid $ds_line_strong;
|
||||
border-radius: $ds_radius_control;
|
||||
}
|
||||
#AppointmentsPage QFrame#AppointmentToolbar QPushButton[variant="secondary"]:enabled:hover {
|
||||
color: $ds_accent;
|
||||
background: $ds_accent_soft;
|
||||
border-color: #8FC8C0;
|
||||
}
|
||||
#AppointmentsPage QFrame#AppointmentToolbar QPushButton[variant="secondary"]:enabled:pressed {
|
||||
background: #D6ECE8;
|
||||
border-color: $ds_accent;
|
||||
}
|
||||
#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: $ds_surface; alternate-background-color: $ds_surface; border: 0; border-radius: 0;
|
||||
|
||||
@@ -42,56 +42,58 @@ _MAX_CARDS = 5
|
||||
_POLL_INTERVAL_MS = 5_000
|
||||
|
||||
CHAT_NOTIFICATION_QSS = """
|
||||
/* W8 原语 C:右下角黑曜翡翠临床实时提醒浮卡 + 香槟鎏金切边 */
|
||||
QFrame#ChatNotifyCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #BBF0CE;
|
||||
border-radius: 12px;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #103231, stop:1 #071919);
|
||||
border: 1px solid rgba(223, 199, 147, 136);
|
||||
border-radius: 13px;
|
||||
}
|
||||
QFrame#ChatNotifyCard[kind="left"] { border-color: #E4E4E5; }
|
||||
QFrame#ChatNotifyCard[kind="complete"] { border-color: #8B9AD9; }
|
||||
QFrame#ChatNotifyCard[kind="left"] { border-color: rgba(164, 196, 192, 90); }
|
||||
QFrame#ChatNotifyCard[kind="complete"] { border-color: rgba(84, 230, 193, 140); }
|
||||
QLabel#ChatNotifyBadge {
|
||||
min-width: 34px;
|
||||
max-width: 34px;
|
||||
min-height: 34px;
|
||||
max-height: 34px;
|
||||
color: #FFFFFF;
|
||||
background-color: #287B65;
|
||||
border-radius: 9px;
|
||||
font-size: 15px;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #19B2A8, stop:1 #0B6E68);
|
||||
border: 1px solid rgba(223, 199, 147, 120);
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
QLabel#ChatNotifyBadge[kind="left"] { background-color: #6A6B6D; }
|
||||
QLabel#ChatNotifyBadge[kind="complete"] { background-color: #4F63D9; }
|
||||
QLabel#ChatNotifyTitle { color: #1A1C1F; font-size: 13px; font-weight: 700; }
|
||||
QLabel#ChatNotifyDesc { color: #1A1C1F; font-size: 12px; }
|
||||
QLabel#ChatNotifyTime { color: #6A6B6D; font-size: 11px; }
|
||||
QLabel#ChatNotifyBadge[kind="left"] { background-color: #355250; }
|
||||
QLabel#ChatNotifyBadge[kind="complete"] { background-color: #B8924A; }
|
||||
QLabel#ChatNotifyTitle { color: #DFC793; font-size: 13px; font-weight: 700; }
|
||||
QLabel#ChatNotifyDesc { color: #EEF8F7; font-size: 12px; }
|
||||
QLabel#ChatNotifyTime { color: #8EB5B1; font-size: 11px; }
|
||||
QPushButton#ChatNotifyOpen {
|
||||
min-height: 26px;
|
||||
padding: 0 10px;
|
||||
color: #4F63D9;
|
||||
background-color: #EEF1FA;
|
||||
border: 1px solid #EDEDEE;
|
||||
min-height: 28px;
|
||||
padding: 0 12px;
|
||||
color: #FFFFFF;
|
||||
background-color: rgba(24, 176, 165, 86);
|
||||
border: 1px solid rgba(223, 199, 147, 128);
|
||||
border-radius: 7px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QPushButton#ChatNotifyOpen:hover {
|
||||
color: #4156C4;
|
||||
background-color: #EEF1FA;
|
||||
border-color: #8B9AD9;
|
||||
color: #FFFFFF;
|
||||
background-color: #0B6E68;
|
||||
border-color: #DFC793;
|
||||
}
|
||||
QPushButton#ChatNotifyClose {
|
||||
min-width: 22px;
|
||||
max-width: 22px;
|
||||
min-height: 22px;
|
||||
max-height: 22px;
|
||||
color: #6A6B6D;
|
||||
color: #93B8B4;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
}
|
||||
QPushButton#ChatNotifyClose:hover { color: #1A1C1F; background-color: #F7F7F7; }
|
||||
QPushButton#ChatNotifyClose:hover { color: #FFFFFF; background-color: rgba(255, 255, 255, 28); }
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
"""Ctrl+K 悬浮智诊命令中枢(Command Palette):键盘优先的现代桌面快捷导航与患者检索."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from PySide6.QtCore import QEvent, QRectF, QSize, Qt
|
||||
from PySide6.QtGui import (
|
||||
QColor,
|
||||
QKeyEvent,
|
||||
QLinearGradient,
|
||||
QPainter,
|
||||
)
|
||||
from PySide6.QtWidgets import (
|
||||
QDialog,
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QListWidget,
|
||||
QListWidgetItem,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from . import icons, motion
|
||||
from .design_system import clinical_stylesheet
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CommandEntry:
|
||||
"""命令中枢中的单条可执行指令。"""
|
||||
|
||||
key: str
|
||||
title: str
|
||||
subtitle: str
|
||||
icon_kind: str
|
||||
category: str
|
||||
shortcut: str
|
||||
action: Callable[[], None]
|
||||
|
||||
|
||||
_PALETTE_QSS = clinical_stylesheet(
|
||||
r"""
|
||||
QDialog#CommandPaletteDialog {
|
||||
background: transparent;
|
||||
}
|
||||
QFrame#CommandPaletteCard {
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid #B7D3CE;
|
||||
border-radius: 16px;
|
||||
}
|
||||
QFrame#CommandPaletteHeader {
|
||||
background-color: #F7FBFA;
|
||||
border: 0;
|
||||
border-bottom: 1px solid $ds_line;
|
||||
border-top-left-radius: 16px;
|
||||
border-top-right-radius: 16px;
|
||||
}
|
||||
QLineEdit#CommandPaletteInput {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
color: $ds_heading;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
padding: 4px 2px;
|
||||
selection-background-color: $ds_accent_soft;
|
||||
selection-color: $ds_heading;
|
||||
}
|
||||
QLabel#CommandPaletteEsc {
|
||||
color: $ds_muted;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line_strong;
|
||||
border-radius: 6px;
|
||||
padding: 2px 7px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QListWidget#CommandPaletteList {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
QListWidget#CommandPaletteList::item {
|
||||
border: 1px solid transparent;
|
||||
border-radius: 10px;
|
||||
padding: 8px 10px;
|
||||
margin: 2px 0;
|
||||
color: $ds_heading;
|
||||
}
|
||||
QListWidget#CommandPaletteList::item:hover {
|
||||
background-color: #F2FAF9;
|
||||
border-color: #D5E8E5;
|
||||
}
|
||||
QListWidget#CommandPaletteList::item:selected {
|
||||
background-color: $ds_accent_soft;
|
||||
border-color: #A9D6CF;
|
||||
color: $ds_accent_hover;
|
||||
}
|
||||
QFrame#CommandPaletteFooter {
|
||||
background-color: #F7FBFA;
|
||||
border: 0;
|
||||
border-top: 1px solid $ds_line;
|
||||
border-bottom-left-radius: 16px;
|
||||
border-bottom-right-radius: 16px;
|
||||
}
|
||||
QLabel#CommandPaletteHint {
|
||||
color: $ds_muted;
|
||||
font-size: 12px;
|
||||
}
|
||||
QPushButton#CommandPaletteClose {
|
||||
min-width: 28px;
|
||||
max-width: 28px;
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
padding: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
background: transparent;
|
||||
color: $ds_muted;
|
||||
}
|
||||
QPushButton#CommandPaletteClose:hover {
|
||||
background-color: $ds_danger_soft;
|
||||
color: $ds_danger;
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
class _PaletteCard(QFrame):
|
||||
"""带微妙顶缘香槟鎏金高光的悬浮命令卡片。"""
|
||||
|
||||
def paintEvent(self, event: Any) -> None: # noqa: N802
|
||||
super().paintEvent(event)
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
bar = QRectF(18.0, 1.0, max(0.0, self.width() - 36.0), 2.0)
|
||||
grad = QLinearGradient(bar.topLeft(), bar.topRight())
|
||||
grad.setColorAt(0.0, QColor(11, 110, 104, 0))
|
||||
grad.setColorAt(0.28, QColor(24, 168, 158, 180))
|
||||
grad.setColorAt(0.50, QColor(223, 199, 147, 210))
|
||||
grad.setColorAt(0.72, QColor(24, 168, 158, 180))
|
||||
grad.setColorAt(1.0, QColor(11, 110, 104, 0))
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(grad)
|
||||
painter.drawRoundedRect(bar, 1.0, 1.0)
|
||||
painter.end()
|
||||
|
||||
|
||||
class CommandPaletteDialog(QDialog):
|
||||
"""桌面端全局 Ctrl+K 悬浮命令与患者检索面板。"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
entries: list[CommandEntry],
|
||||
*,
|
||||
on_search_patient: Callable[[str], None] | None = None,
|
||||
initial_query: str = "",
|
||||
parent: QWidget | None = None,
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("CommandPaletteDialog")
|
||||
self.setProperty("doctorSkipOpenGeometry", True)
|
||||
self.setWindowFlags(
|
||||
Qt.WindowType.FramelessWindowHint
|
||||
| Qt.WindowType.Dialog
|
||||
| Qt.WindowType.NoDropShadowWindowHint
|
||||
)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True)
|
||||
self.setModal(True)
|
||||
self.setStyleSheet(_PALETTE_QSS)
|
||||
|
||||
self._entries = list(entries)
|
||||
self._on_search_patient = on_search_patient
|
||||
self._visible_actions: list[Callable[[], None]] = []
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(12, 12, 12, 12)
|
||||
|
||||
self.card = _PaletteCard(self)
|
||||
self.card.setObjectName("CommandPaletteCard")
|
||||
self.card.setFixedWidth(568)
|
||||
card_layout = QVBoxLayout(self.card)
|
||||
card_layout.setContentsMargins(0, 0, 0, 0)
|
||||
card_layout.setSpacing(0)
|
||||
|
||||
# 顶部搜索栏
|
||||
header = QFrame(self.card)
|
||||
header.setObjectName("CommandPaletteHeader")
|
||||
header.setFixedHeight(56)
|
||||
header_layout = QHBoxLayout(header)
|
||||
header_layout.setContentsMargins(16, 0, 14, 0)
|
||||
header_layout.setSpacing(10)
|
||||
|
||||
search_icon = QLabel(header)
|
||||
search_icon.setPixmap(icons.pixmap("search", "accent", 18))
|
||||
header_layout.addWidget(search_icon)
|
||||
|
||||
self.input = QLineEdit(header)
|
||||
self.input.setObjectName("CommandPaletteInput")
|
||||
self.input.setPlaceholderText("输入页面名称、快捷指令,或患者姓名/手机号回车搜索...")
|
||||
self.input.setText(initial_query)
|
||||
self.input.textChanged.connect(self._rebuild_list)
|
||||
self.input.installEventFilter(self)
|
||||
header_layout.addWidget(self.input, 1)
|
||||
|
||||
esc_hint = QLabel("ESC", header)
|
||||
esc_hint.setObjectName("CommandPaletteEsc")
|
||||
esc_hint.setFixedHeight(24)
|
||||
header_layout.addWidget(esc_hint, 0, Qt.AlignmentFlag.AlignVCenter)
|
||||
|
||||
close_btn = QPushButton(header)
|
||||
close_btn.setObjectName("CommandPaletteClose")
|
||||
close_btn.setIcon(icons.icon("close", "muted", 14))
|
||||
close_btn.setIconSize(QSize(14, 14))
|
||||
close_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
close_btn.clicked.connect(self.reject)
|
||||
header_layout.addWidget(close_btn)
|
||||
card_layout.addWidget(header)
|
||||
|
||||
# 指令列表
|
||||
self.list_widget = QListWidget(self.card)
|
||||
self.list_widget.setObjectName("CommandPaletteList")
|
||||
self.list_widget.setFixedHeight(296)
|
||||
self.list_widget.setIconSize(QSize(18, 18))
|
||||
self.list_widget.setSpacing(2)
|
||||
self.list_widget.itemActivated.connect(self._activate_item)
|
||||
self.list_widget.itemClicked.connect(self._activate_item)
|
||||
card_layout.addWidget(self.list_widget)
|
||||
|
||||
# 底部键盘引导条
|
||||
footer = QFrame(self.card)
|
||||
footer.setObjectName("CommandPaletteFooter")
|
||||
footer.setFixedHeight(36)
|
||||
footer_layout = QHBoxLayout(footer)
|
||||
footer_layout.setContentsMargins(16, 0, 16, 0)
|
||||
hint = QLabel("↑↓ 选择 · Enter 执行 · Esc 关闭", footer)
|
||||
hint.setObjectName("CommandPaletteHint")
|
||||
footer_layout.addWidget(hint)
|
||||
footer_layout.addStretch(1)
|
||||
brand = QLabel("甄养堂 · 智诊指令中枢", footer)
|
||||
brand.setObjectName("CommandPaletteHint")
|
||||
footer_layout.addWidget(brand)
|
||||
card_layout.addWidget(footer)
|
||||
|
||||
root.addWidget(self.card)
|
||||
self.adjustSize()
|
||||
self._rebuild_list(initial_query)
|
||||
|
||||
def showEvent(self, event: Any) -> None: # noqa: N802
|
||||
super().showEvent(event)
|
||||
parent = self.parentWidget()
|
||||
if parent is not None:
|
||||
host = parent.window().frameGeometry()
|
||||
x = host.center().x() - self.width() // 2
|
||||
y = host.top() + max(72, round(host.height() * 0.14))
|
||||
self.move(x, y)
|
||||
self.input.setFocus(Qt.FocusReason.PopupFocusReason)
|
||||
self.input.selectAll()
|
||||
motion.fade_in(self.card, duration=motion.FAST)
|
||||
|
||||
def paintEvent(self, event: Any) -> None: # noqa: N802
|
||||
del event
|
||||
# 柔和冷青科技外光环,在透明无边框弹窗周围营造立体层次
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
card_rect = QRectF(self.card.geometry())
|
||||
for expand, alpha in ((8.0, 14), (5.0, 22), (2.0, 32)):
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor(11, 46, 44, alpha))
|
||||
painter.drawRoundedRect(
|
||||
card_rect.adjusted(-expand, -expand + 2.0, expand, expand + 4.0),
|
||||
16.0 + expand * 0.4,
|
||||
16.0 + expand * 0.4,
|
||||
)
|
||||
painter.end()
|
||||
|
||||
def _rebuild_list(self, raw_query: str) -> None:
|
||||
query = raw_query.strip()
|
||||
lowered = query.lower()
|
||||
self.list_widget.clear()
|
||||
self._visible_actions.clear()
|
||||
|
||||
if query and self._on_search_patient is not None:
|
||||
item = QListWidgetItem(
|
||||
icons.icon("search", "accent", 18),
|
||||
f"检索患者「{query}」 — 直达患者与问诊列表",
|
||||
)
|
||||
self.list_widget.addItem(item)
|
||||
self._visible_actions.append(
|
||||
lambda q=query, cb=self._on_search_patient: cb(q)
|
||||
)
|
||||
|
||||
for entry in self._entries:
|
||||
haystack = f"{entry.title} {entry.subtitle} {entry.category}".lower()
|
||||
if lowered and lowered not in haystack:
|
||||
continue
|
||||
label = f"{entry.title} · {entry.subtitle}"
|
||||
if entry.shortcut:
|
||||
label = f"{label} [{entry.shortcut}]"
|
||||
item = QListWidgetItem(icons.icon(entry.icon_kind, "accent", 18), label)
|
||||
self.list_widget.addItem(item)
|
||||
self._visible_actions.append(entry.action)
|
||||
|
||||
if self.list_widget.count() > 0:
|
||||
self.list_widget.setCurrentRow(0)
|
||||
|
||||
def _activate_item(self, item: QListWidgetItem | None) -> None:
|
||||
if item is None:
|
||||
return
|
||||
row = self.list_widget.row(item)
|
||||
if 0 <= row < len(self._visible_actions):
|
||||
action = self._visible_actions[row]
|
||||
self.accept()
|
||||
action()
|
||||
|
||||
def eventFilter(self, watched: Any, event: QEvent) -> bool: # noqa: N802
|
||||
if watched is self.input and event.type() == QEvent.Type.KeyPress:
|
||||
assert isinstance(event, QKeyEvent)
|
||||
key = event.key()
|
||||
if key in (Qt.Key.Key_Down, Qt.Key.Key_Up):
|
||||
count = self.list_widget.count()
|
||||
if count > 0:
|
||||
step = 1 if key == Qt.Key.Key_Down else -1
|
||||
current = self.list_widget.currentRow()
|
||||
self.list_widget.setCurrentRow((current + step) % count)
|
||||
return True
|
||||
if key in (Qt.Key.Key_Return, Qt.Key.Key_Enter):
|
||||
self._activate_item(self.list_widget.currentItem())
|
||||
return True
|
||||
if key == Qt.Key.Key_Escape:
|
||||
self.reject()
|
||||
return True
|
||||
return super().eventFilter(watched, event)
|
||||
|
||||
|
||||
__all__ = ["CommandEntry", "CommandPaletteDialog"]
|
||||
@@ -36,19 +36,26 @@ _QSS = """
|
||||
background: transparent; border: 0; border-top: 1px solid $ds_line; border-radius: 0;
|
||||
}
|
||||
#DiagnosisIndex QPushButton {
|
||||
min-height: 34px; padding: 0 13px; border: 1px solid transparent;
|
||||
border-radius: $ds_radius_control; background: $ds_surface_alt;
|
||||
min-height: 34px; padding: 0 13px; border: 1px solid $ds_line_strong;
|
||||
border-radius: $ds_radius_control; background: $ds_surface; color: $ds_text; font-weight: 500;
|
||||
}
|
||||
#DiagnosisIndex QPushButton:hover { color: $ds_accent; background: $ds_surface_alt; border-color: $ds_line_strong; }
|
||||
#DiagnosisIndex QPushButton:pressed { background: $ds_accent_soft; }
|
||||
#DiagnosisIndex QPushButton:hover { color: $ds_accent; background: $ds_accent_soft; border-color: #9CCFC7; }
|
||||
#DiagnosisIndex QPushButton:pressed { background: #D7EFEA; }
|
||||
#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"] {
|
||||
color: $ds_surface;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $ds_accent);
|
||||
border-color: $ds_accent;
|
||||
}
|
||||
#DiagnosisIndex QPushButton[variant="primary"]:hover {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $ds_accent_hover);
|
||||
border-color: $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[consultationTool="true"] { color: $ds_text; border-color: $ds_line_strong; background: $ds_surface; }
|
||||
#DiagnosisIndex QPushButton[consultationTool="true"]:hover { color: $ds_accent; background: $ds_accent_soft; border-color: #9CCFC7; }
|
||||
#DiagnosisIndex QPushButton[consultationDanger="true"] { color: $ds_danger; background: $ds_danger_soft; border-color: #F5C8CD; }
|
||||
#DiagnosisIndex QPushButton[consultationDanger="true"]:hover { border-color: $ds_danger; }
|
||||
#DiagnosisIndex QPushButton[consultationTool="true"]:focus,
|
||||
#DiagnosisIndex QPushButton[consultationDanger="true"]:focus { border-color: $ds_focus; }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Clinical desktop design tokens, shared by native pages and dialog chrome.
|
||||
"""Clinical desktop design tokens — 御瓷智医 (Luxury Precision MedTech).
|
||||
|
||||
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.
|
||||
Fuses medical trust, precision technology, quiet luxury (champagne gold micro-accents)
|
||||
and contemporary editorial clarity. Shared by native pages, shell chrome, drawers and
|
||||
dialogs. New rules should use the named ``$ds_*`` tokens rather than legacy colours.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -11,60 +11,80 @@ import re
|
||||
from string import Template
|
||||
|
||||
PALETTE = {
|
||||
"canvas": "#F5F7FA",
|
||||
# 三阶珍珠青瓷中性面:低眩光护眼,同时具备精密医疗仪器与高定材质层次
|
||||
"canvas": "#EFF4F3",
|
||||
"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",
|
||||
"surface_alt": "#F6FAFA",
|
||||
"sidebar": "#E6EEED",
|
||||
"line": "#DCE6E4",
|
||||
"line_strong": "#C3D3D0",
|
||||
# 曜青深墨文字阶梯:锐利、高级、高对比度
|
||||
"heading": "#0F2120",
|
||||
"text": "#263938",
|
||||
"muted": "#5C7270",
|
||||
"disabled": "#95A8A6",
|
||||
"disabled_surface": "#EDF2F1",
|
||||
# 唯一品牌主色:甄养堂精密医疗翡翠青 (Jade Teal)
|
||||
"accent": "#0B6E68",
|
||||
"accent_hover": "#085954",
|
||||
"accent_pressed": "#064743",
|
||||
"accent_soft": "#E6F4F2",
|
||||
"focus": "#18A89E",
|
||||
# 贵气时尚微点缀:香槟鎏金 (Champagne Gold — 克制用于徽标切边、AI 科技星芒、尊享标识)
|
||||
"gold": "#B8924A",
|
||||
"gold_light": "#DFC793",
|
||||
"gold_soft": "#FAF5EA",
|
||||
# 深曜青科技底(用于 AI 科技卡与登录页品牌沉浸区)
|
||||
"obsidian": "#0D2424",
|
||||
"obsidian_alt": "#143534",
|
||||
# 语义临床色
|
||||
"success": "#0E8A63",
|
||||
"success_soft": "#E6F7F1",
|
||||
"warning": "#B56B00",
|
||||
"warning_soft": "#FEF5E6",
|
||||
"danger": "#C83B4B",
|
||||
"danger_soft": "#FDEEEF",
|
||||
}
|
||||
|
||||
RADII = {"small": 6, "control": 10, "panel": 16, "window": 20}
|
||||
RADII = {"small": 6, "control": 8, "panel": 12, "window": 16}
|
||||
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"),
|
||||
"accent": ("4267B2", "1769E8", "4F63D9", "5761F4", "5267DF", "1555B6"),
|
||||
"accent_hover": ("355995", "155BCC", "4156C4", "4356C4", "4055CA"),
|
||||
"accent_pressed": ("2C4C82", "124EA9", "354BB4"),
|
||||
"accent_soft": (
|
||||
"EAF0FB", "EAF2FF", "EEF1FA", "EEF0FF", "F0F2FF", "DCEAFF", "EDF0FC",
|
||||
"F0F5FD", "D6E5FB", "E3E8F8",
|
||||
),
|
||||
"focus": ("6D8CCB", "75A5F0", "8B9AD9"),
|
||||
"canvas": ("F5F7FA", "F3F7FD", "F4F6FA", "F6F6F6"),
|
||||
"surface_alt": ("F7F9FC", "F7F7F7", "F7FAFE", "F5F8FD", "F7F9FE", "F2F7FF"),
|
||||
"sidebar": ("F0F3F8", "EDF4FF"),
|
||||
"line": (
|
||||
"E6EAF0", "DBE5F2", "EDEDEE", "E5ECF6", "E6EDF6", "E7EDF7", "EDF0F5",
|
||||
"E7EBF2", "E6EAF5", "EDF1F7", "DEE4F6",
|
||||
),
|
||||
"line_strong": (
|
||||
"D4DCE8", "E4E4E5", "C8D5E6", "C9DCF7", "ADC8F0", "B6CDEE", "C4D2E5",
|
||||
"CEDBEB", "A7B1C9", "8894B2",
|
||||
),
|
||||
"heading": ("223047", "1A1C1F", "202C3F", "111F46", "20354E"),
|
||||
"text": ("344258", "273244", "263551", "24334A", "233149", "3F4E75"),
|
||||
"muted": ("647287", "606163", "6A6B6D", "5D6B80", "7886AA", "708097", "697386"),
|
||||
"disabled": ("8B96A6", "8E8F90", "8A97A9", "9AA6B7"),
|
||||
"disabled_surface": ("F0F2F5", "F2F2F2", "F0F0F0"),
|
||||
"success": ("287B65",),
|
||||
"success_soft": ("EDF7F2", "EEF7F3", "EAF9F3", "E8F6F1", "F0FDF4", "ECFDF5"),
|
||||
"warning": ("96601D", "A9691D", "9C681F", "B96C00"),
|
||||
"warning_soft": ("FBF4E8", "FCF5E9", "FFF5E6", "FFF6E7", "FFF9EF", "FFF7E9", "FFFBEB"),
|
||||
"danger": ("B54A59", "BE4B58", "B84652", "C43E55"),
|
||||
"danger_soft": ("FCF0F2", "FFF0F2", "FFF1F3", "FFF4F5", "FFF7F8", "FEF2F2"),
|
||||
}
|
||||
_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])")
|
||||
|
||||
@@ -414,6 +414,21 @@ QTimeEdit[diagnosisField="true"] {
|
||||
QDoubleSpinBox[diagnosisField="true"] {
|
||||
padding-right: 4px;
|
||||
}
|
||||
QComboBox[diagnosisField="true"]::drop-down,
|
||||
QDateEdit[diagnosisField="true"]::drop-down,
|
||||
QTimeEdit[diagnosisField="true"]::drop-down {
|
||||
width: 26px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
QDoubleSpinBox[diagnosisField="true"]::up-button,
|
||||
QDoubleSpinBox[diagnosisField="true"]::down-button,
|
||||
QSpinBox[diagnosisField="true"]::up-button,
|
||||
QSpinBox[diagnosisField="true"]::down-button {
|
||||
width: 18px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
QPlainTextEdit[diagnosisField="true"] {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ _INVALID_INDEX = QModelIndex()
|
||||
# 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_COLUMN_WIDTHS = (46, 62, 70, 88, 244, 70, 84, 76, 70, 92, 86, 152)
|
||||
_BLUE_WARNING = QColor(PALETTE["warning"])
|
||||
_BLUE_DANGER = QColor(PALETTE["danger"])
|
||||
|
||||
@@ -454,9 +454,10 @@ def prescription_action(record: Any, *, force_open: bool = False) -> tuple[str,
|
||||
|
||||
|
||||
def can_void_prescription(record: Any) -> bool:
|
||||
# 已有业务订单、已审核签署的处方也可作废:订单随同诊单重新开方自动关联新处方;权限与药房锁由服务端判定。
|
||||
_, mode = prescription_action(record)
|
||||
return mode in {"edit", "view"}
|
||||
return mode in {"edit", "view"} and not _as_bool(
|
||||
first_value(record, "has_prescription_order", default=False)
|
||||
)
|
||||
|
||||
|
||||
def _prescription_action_label(record: Any, *, force_open: bool = False) -> str:
|
||||
|
||||
@@ -94,6 +94,7 @@ from ..widgets import (
|
||||
run_async,
|
||||
show_toast,
|
||||
)
|
||||
from ..window_primitives import ClinicalAccentBar
|
||||
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
|
||||
@@ -4781,7 +4782,9 @@ class AiConsultDialog(QDialog):
|
||||
_style_surface(shell)
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
root.addWidget(shell)
|
||||
root.setSpacing(0)
|
||||
root.addWidget(ClinicalAccentBar(self))
|
||||
root.addWidget(shell, 1)
|
||||
layout = QVBoxLayout(shell)
|
||||
layout.setContentsMargins(18, 14, 18, 14)
|
||||
layout.setSpacing(12)
|
||||
|
||||
@@ -99,6 +99,7 @@ from ..widgets import (
|
||||
page_total,
|
||||
run_async,
|
||||
)
|
||||
from ..window_primitives import ClinicalAccentBar
|
||||
from .issued_prescription_ai import can_open_issued_ai, present_issued_prescription_ai
|
||||
from .local_audio_queue import LocalAudioQueueDialog
|
||||
from .prescription_ai import can_open_diagnosis_ai_report, present_diagnosis_ai_report
|
||||
@@ -1233,21 +1234,105 @@ class DiagnosisDialog(QDialog):
|
||||
panel_layout = QVBoxLayout(self.drawer_panel)
|
||||
panel_layout.setContentsMargins(0, 0, 0, 0)
|
||||
panel_layout.setSpacing(0)
|
||||
panel_layout.addWidget(ClinicalAccentBar(self.drawer_panel))
|
||||
panel_layout.addWidget(self._build_drawer_header())
|
||||
self.drawer_banner = MessageStrip()
|
||||
self.drawer_banner.setContentsMargins(16, 8, 16, 0)
|
||||
self.drawer_banner.action_requested.connect(self._retry_current)
|
||||
panel_layout.addWidget(self.drawer_banner)
|
||||
# W5 四诊病历工作室:左侧章节大纲定位轨 + 右侧主编辑工作区
|
||||
studio_body = QHBoxLayout()
|
||||
studio_body.setContentsMargins(0, 0, 0, 0)
|
||||
studio_body.setSpacing(0)
|
||||
self.studio_outline = QFrame(self.drawer_panel)
|
||||
self.studio_outline.setObjectName("DiagnosisStudioOutline")
|
||||
self.studio_outline.setFixedWidth(136)
|
||||
self.studio_outline.setStyleSheet(
|
||||
clinical_stylesheet(
|
||||
r"""
|
||||
QFrame#DiagnosisStudioOutline {
|
||||
background-color: #F4F9F8;
|
||||
border-right: 1px solid $ds_line;
|
||||
}
|
||||
QPushButton[studioOutlineBtn="true"] {
|
||||
min-height: 34px;
|
||||
max-height: 34px;
|
||||
padding: 0 10px;
|
||||
text-align: left;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: $ds_text;
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QPushButton[studioOutlineBtn="true"]:hover {
|
||||
background-color: #E7F4F2;
|
||||
color: $ds_accent;
|
||||
}
|
||||
QPushButton[studioOutlineBtn="true"]:checked {
|
||||
background-color: #FFFFFF;
|
||||
border-color: #BEE0DA;
|
||||
color: $ds_accent;
|
||||
font-weight: 600;
|
||||
}
|
||||
"""
|
||||
)
|
||||
)
|
||||
self._studio_outline_layout = QVBoxLayout(self.studio_outline)
|
||||
self._studio_outline_layout.setContentsMargins(10, 12, 10, 12)
|
||||
self._studio_outline_layout.setSpacing(4)
|
||||
self._studio_outline_buttons: list[QPushButton] = []
|
||||
studio_body.addWidget(self.studio_outline)
|
||||
|
||||
self.tabs = DiagnosisTabWidget()
|
||||
self.tabs.setObjectName("DiagnosisDrawerTabs")
|
||||
self._build_drawer_tabs()
|
||||
self.tabs.currentChanged.connect(self._tab_changed)
|
||||
panel_layout.addWidget(self.tabs, 1)
|
||||
self.tabs.currentChanged.connect(self._sync_studio_outline_selection)
|
||||
studio_body.addWidget(self.tabs, 1)
|
||||
panel_layout.addLayout(studio_body, 1)
|
||||
panel_layout.addWidget(self._build_drawer_footer())
|
||||
self.drawer_loading = LoadingOverlay(self.drawer_panel)
|
||||
layout.addWidget(self.drawer_panel)
|
||||
self._rebuild_studio_outline()
|
||||
return overlay
|
||||
|
||||
def _rebuild_studio_outline(self) -> None:
|
||||
"""同步左侧章节大纲按钮,使医生可按临床模块一键直达定位。"""
|
||||
|
||||
if not hasattr(self, "_studio_outline_layout"):
|
||||
return
|
||||
while self._studio_outline_layout.count():
|
||||
item = self._studio_outline_layout.takeAt(0)
|
||||
widget = item.widget()
|
||||
if widget is not None:
|
||||
widget.hide()
|
||||
widget.setParent(None)
|
||||
widget.deleteLater()
|
||||
self._studio_outline_buttons.clear()
|
||||
caption = QLabel("四诊病历大纲", self.studio_outline)
|
||||
caption.setStyleSheet("color: #5F7A78; font-size: 11px; font-weight: 600; padding: 2px 6px 6px;")
|
||||
self._studio_outline_layout.addWidget(caption)
|
||||
for index in range(self.tabs.count()):
|
||||
label = self.tabs.tabText(index)
|
||||
btn = QPushButton(f"{index + 1:02d} {label}", self.studio_outline)
|
||||
btn.setProperty("studioOutlineBtn", True)
|
||||
btn.setCheckable(True)
|
||||
btn.setChecked(index == self.tabs.currentIndex())
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn.clicked.connect(lambda _checked=False, i=index: self.tabs.setCurrentIndex(i))
|
||||
self._studio_outline_layout.addWidget(btn)
|
||||
self._studio_outline_buttons.append(btn)
|
||||
self._studio_outline_layout.addStretch(1)
|
||||
self.studio_outline.setVisible(self.tabs.count() > 1)
|
||||
|
||||
def _sync_studio_outline_selection(self, index: int) -> None:
|
||||
if len(self._studio_outline_buttons) != self.tabs.count():
|
||||
self._rebuild_studio_outline()
|
||||
for i, btn in enumerate(self._studio_outline_buttons):
|
||||
btn.setChecked(i == index)
|
||||
|
||||
def _build_drawer_header(self) -> QFrame:
|
||||
header = QFrame()
|
||||
header.setObjectName("DiagnosisDrawerHeader")
|
||||
@@ -1861,6 +1946,7 @@ class DiagnosisDialog(QDialog):
|
||||
target = index
|
||||
self.tabs.setCurrentIndex(target)
|
||||
self.tabs.blockSignals(blocked)
|
||||
self._rebuild_studio_outline()
|
||||
section_codes = {key: codes for key, _label, codes in _TAB_DEFINITIONS}
|
||||
for key, section in self._readonly_sections.items():
|
||||
section.setVisible(self._tab_allowed(section_codes.get(key, ())))
|
||||
|
||||
@@ -24,43 +24,43 @@ from PySide6.QtGui import QFont
|
||||
from ..design_system import PALETTE
|
||||
|
||||
DARK: dict[str, str] = {
|
||||
# ground and cards
|
||||
"canvas": "#080D18",
|
||||
"canvas_soft": "#0C1322",
|
||||
"surface": "#0F1726",
|
||||
"surface_2": "#131D2E",
|
||||
"raised": "#1A2637",
|
||||
"line": "#22304A",
|
||||
"line_soft": "#18233A",
|
||||
# 御瓷暗曜科技面:深翡翠黑曜石底 + 精密青玉科技主色 + 香槟鎏金微光
|
||||
"canvas": "#071212",
|
||||
"canvas_soft": "#0A1A1A",
|
||||
"surface": "#0E2121",
|
||||
"surface_2": "#122929",
|
||||
"raised": "#183534",
|
||||
"line": "#214240",
|
||||
"line_soft": "#173130",
|
||||
# type
|
||||
"heading": "#E8EFFB",
|
||||
"text": "#B6C5DA",
|
||||
"muted": "#8195AF",
|
||||
"faint": "#6A7F99",
|
||||
"selected_text": "#E8EFFB",
|
||||
"heading": "#ECF6F5",
|
||||
"text": "#BAD0CE",
|
||||
"muted": "#82A09D",
|
||||
"faint": "#64827F",
|
||||
"selected_text": "#ECF6F5",
|
||||
# interface colour
|
||||
"accent": "#2E7BF6",
|
||||
"accent_text": "#6BA5FF",
|
||||
"accent_pressed": "#1A5FD0",
|
||||
"selection": "#142645",
|
||||
"selection_line": "#1B3E77",
|
||||
"accent": "#16A89E",
|
||||
"accent_text": "#5BE0D6",
|
||||
"accent_pressed": "#0E857D",
|
||||
"selection": "#123433",
|
||||
"selection_line": "#1F5C58",
|
||||
# model hues
|
||||
"qwen": "#17BFDD",
|
||||
"qwen_text": "#55D8EE",
|
||||
"qwen_dim": "#10303C",
|
||||
"openai": "#9B7BFF",
|
||||
"openai_text": "#B69FFF",
|
||||
"openai_dim": "#241F48",
|
||||
"qwen": "#22C7D6",
|
||||
"qwen_text": "#69E3EE",
|
||||
"qwen_dim": "#103238",
|
||||
"openai": "#D4AF6A",
|
||||
"openai_text": "#EAD09B",
|
||||
"openai_dim": "#2D2719",
|
||||
# severity
|
||||
"amber": "#F5B942",
|
||||
"amber_text": "#F8C661",
|
||||
"amber_dim": "#2C2415",
|
||||
"rose": "#F4697A",
|
||||
"rose_text": "#F88694",
|
||||
"rose_dim": "#2C1620",
|
||||
"ok": "#2E7BF6",
|
||||
"zebra": "#0E1626",
|
||||
"grid_line": "#191F2C",
|
||||
"amber": "#F2B644",
|
||||
"amber_text": "#F7C96E",
|
||||
"amber_dim": "#2E2514",
|
||||
"rose": "#F06A7B",
|
||||
"rose_text": "#F78D9B",
|
||||
"rose_dim": "#2E171E",
|
||||
"ok": "#16A89E",
|
||||
"zebra": "#0C1D1D",
|
||||
"grid_line": "#172E2D",
|
||||
}
|
||||
|
||||
LIGHT: dict[str, str] = {
|
||||
@@ -81,21 +81,21 @@ LIGHT: dict[str, str] = {
|
||||
"accent_pressed": PALETTE["accent_pressed"],
|
||||
"selection": PALETTE["accent_soft"],
|
||||
"selection_line": PALETTE["focus"],
|
||||
"qwen": "#0C89AC",
|
||||
"qwen_text": "#086C88",
|
||||
"qwen_dim": "#E2F5FA",
|
||||
"openai": "#6B4AE0",
|
||||
"openai_text": "#5537C6",
|
||||
"openai_dim": "#EDE8FE",
|
||||
"amber": "#B4791A",
|
||||
"amber_text": "#8F5F0B",
|
||||
"amber_dim": "#FCF2DF",
|
||||
"rose": "#D0435A",
|
||||
"rose_text": "#AE3149",
|
||||
"rose_dim": "#FCE9EC",
|
||||
"ok": "#1A5FD0",
|
||||
"zebra": "#FAFBFE",
|
||||
"grid_line": "#DDE4EE",
|
||||
"qwen": "#0B8894",
|
||||
"qwen_text": "#086A74",
|
||||
"qwen_dim": "#E3F5F7",
|
||||
"openai": "#A37E38",
|
||||
"openai_text": "#826124",
|
||||
"openai_dim": "#FAF4E7",
|
||||
"amber": "#B56B00",
|
||||
"amber_text": "#8F5400",
|
||||
"amber_dim": "#FEF5E6",
|
||||
"rose": "#C83B4B",
|
||||
"rose_text": "#A62B3A",
|
||||
"rose_dim": "#FDEEEF",
|
||||
"ok": PALETTE["accent"],
|
||||
"zebra": "#F8FBFB",
|
||||
"grid_line": PALETTE["line"],
|
||||
}
|
||||
|
||||
CONSOLE: dict[str, str] = dict(DARK)
|
||||
|
||||
@@ -33,7 +33,6 @@ from PySide6.QtCore import (
|
||||
QObject,
|
||||
QPoint,
|
||||
QRectF,
|
||||
QRegularExpression,
|
||||
QSize,
|
||||
Qt,
|
||||
QTimer,
|
||||
@@ -53,7 +52,6 @@ from PySide6.QtGui import (
|
||||
QPainter,
|
||||
QPdfWriter,
|
||||
QPen,
|
||||
QRegularExpressionValidator,
|
||||
QStandardItem,
|
||||
QStandardItemModel,
|
||||
QTextDocument,
|
||||
@@ -100,7 +98,7 @@ from PySide6.QtWidgets import (
|
||||
)
|
||||
from shiboken6 import isValid
|
||||
|
||||
from ...core.esign import certificate_identity_number, esign_config, esign_status
|
||||
from ...core.esign import esign_config, esign_status
|
||||
from .. import icons
|
||||
from ..design_system import clinical_stylesheet
|
||||
from ..diagnosis_terms import shared_terms
|
||||
@@ -119,6 +117,7 @@ from ..widgets import (
|
||||
run_async,
|
||||
show_toast,
|
||||
)
|
||||
from ..window_primitives import ClinicalAccentBar
|
||||
from .diagnosis import DiagnosisDialog as _StructuredDiagnosisDialog
|
||||
from .prescription_esign import (
|
||||
PRESCRIPTION_UPLOAD_BEFORE_SIGNING_PROMPT,
|
||||
@@ -995,7 +994,6 @@ _REISSUE_FIELDS = (
|
||||
"herbs", "dose_count", "dose_unit", "dosage_amount", "dosage_unit", "dosage_bag_count",
|
||||
"need_decoction", "bags_per_dose", "usage_days", "times_per_day", "usage_instruction",
|
||||
"usage_time", "usage_way", "dietary_taboo", "usage_notes", "aux_usage", "ai_assisted",
|
||||
"patient_id_card",
|
||||
)
|
||||
|
||||
|
||||
@@ -1007,21 +1005,10 @@ def can_void_issued_prescription(prescription: Any) -> bool:
|
||||
return not prescription_is_voided(prescription) and _bool(get_value(prescription, "can_void"))
|
||||
|
||||
|
||||
_PRESCRIPTION_PHONE = re.compile(r"1[3-9][0-9]{9}|0[0-9]{2,3}-?[0-9]{7,8}")
|
||||
|
||||
|
||||
def prescription_phone_error(value: Any) -> str:
|
||||
"""处方笺手机号:11 位手机号或带区号座机;为空表示沿用原号码。与服务端规则一致。"""
|
||||
phone = str(value or "").strip()
|
||||
if not phone or _PRESCRIPTION_PHONE.fullmatch(phone):
|
||||
return ""
|
||||
return "手机号格式不正确,请输入 11 位手机号或带区号的座机号(如 0571-88888888)"
|
||||
|
||||
|
||||
def can_reissue_prescription(prescription: Any, current_user: Any, permissions: Any) -> bool:
|
||||
# 已作废处方(含他人作废、他人所开)均可由有开方权限的账号重新开方;新处方以当前账号为开方医生并由其签署。
|
||||
actor_id = _int(first_value(current_user, "id", "user_id", "admin_id"))
|
||||
return (prescription_is_voided(prescription) and actor_id > 0
|
||||
creator_id = _int(first_value(prescription, "creator_id", "doctor_id"))
|
||||
return (prescription_is_voided(prescription) and actor_id > 0 and actor_id == creator_id
|
||||
and has_permission(permissions, PRESCRIBE_PERMISSIONS))
|
||||
|
||||
|
||||
@@ -3132,9 +3119,13 @@ class PrescriptionEditorDialog(QDialog):
|
||||
surface_layout = QVBoxLayout(self.drawer_surface)
|
||||
surface_layout.setContentsMargins(0, 0, 0, 0)
|
||||
surface_layout.setSpacing(0)
|
||||
surface_layout.addWidget(ClinicalAccentBar(self.drawer_surface))
|
||||
self.workspace_splitter.addWidget(self.drawer_surface)
|
||||
self.live_preview_pane = self._build_live_preview_pane()
|
||||
self.workspace_splitter.addWidget(self.live_preview_pane)
|
||||
self.workspace_splitter.setStretchFactor(0, 1)
|
||||
self.workspace_splitter.setStretchFactor(1, 0)
|
||||
self.workspace_splitter.setStretchFactor(1, 2)
|
||||
self.workspace_splitter.setStretchFactor(2, 1)
|
||||
|
||||
self.header = self._build_header()
|
||||
surface_layout.addWidget(self.header)
|
||||
@@ -3217,6 +3208,188 @@ class PrescriptionEditorDialog(QDialog):
|
||||
self._load_editor_context()
|
||||
self.save_button.setEnabled(not self._esign_content_locked())
|
||||
self._load_esign_config()
|
||||
self._bind_live_preview_signals()
|
||||
self._refresh_live_preview()
|
||||
|
||||
def _build_live_preview_pane(self) -> QFrame:
|
||||
"""W6 智能开方工作台右侧:实时宣纸仿真处方笺预览 + CA 双签合规进度轨。"""
|
||||
|
||||
pane = QFrame(self.workspace_splitter)
|
||||
pane.setObjectName("PrescriptionLivePreviewPane")
|
||||
pane.setMinimumWidth(310)
|
||||
pane.setMaximumWidth(400)
|
||||
pane.setStyleSheet(
|
||||
clinical_stylesheet(
|
||||
r"""
|
||||
QFrame#PrescriptionLivePreviewPane {
|
||||
background-color: #EEF5F3;
|
||||
border-left: 1px solid #C6DAD6;
|
||||
}
|
||||
QFrame#LiveRxPaperCard {
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFEFA, stop:1 #FAF7EE);
|
||||
border: 1px solid #DFD4BC;
|
||||
border-radius: 13px;
|
||||
}
|
||||
QFrame#LiveEsignTrackCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: 12px;
|
||||
}
|
||||
QLabel#LiveRxStepDone {
|
||||
background-color: #E5F4F2;
|
||||
border: 1px solid #A8D6CF;
|
||||
border-radius: 7px;
|
||||
color: #0B6E68;
|
||||
padding: 5px 8px;
|
||||
font-size: 11.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QLabel#LiveRxStepPending {
|
||||
background-color: #F4F9F8;
|
||||
border: 1px solid #D7E5E2;
|
||||
border-radius: 7px;
|
||||
color: #5F7A78;
|
||||
padding: 5px 8px;
|
||||
font-size: 11.5px;
|
||||
}
|
||||
"""
|
||||
)
|
||||
)
|
||||
layout = QVBoxLayout(pane)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
layout.addWidget(ClinicalAccentBar(pane))
|
||||
|
||||
inner = QVBoxLayout()
|
||||
inner.setContentsMargins(14, 14, 14, 14)
|
||||
inner.setSpacing(12)
|
||||
|
||||
paper = QFrame(pane)
|
||||
paper.setObjectName("LiveRxPaperCard")
|
||||
paper_layout = QVBoxLayout(paper)
|
||||
paper_layout.setContentsMargins(16, 14, 16, 14)
|
||||
paper_layout.setSpacing(8)
|
||||
|
||||
emblem = QLabel("ZHENYANGTANG · 实时电子处方笺", paper)
|
||||
emblem.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
emblem.setStyleSheet("color: #8D7240; font-size: 11px; letter-spacing: 1px;")
|
||||
paper_layout.addWidget(emblem)
|
||||
|
||||
title = QLabel("甄养堂互联网医院 · 中医专科处方", paper)
|
||||
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
title.setStyleSheet("color: #102625; font-size: 14px; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid #E3D8BF;")
|
||||
paper_layout.addWidget(title)
|
||||
|
||||
self._live_rx_patient = QLabel("患者:— | 剂型:—", paper)
|
||||
self._live_rx_patient.setWordWrap(True)
|
||||
self._live_rx_patient.setStyleSheet("color: #274140; font-size: 12px;")
|
||||
paper_layout.addWidget(self._live_rx_patient)
|
||||
|
||||
self._live_rx_diag = QLabel("辨证诊断:—", paper)
|
||||
self._live_rx_diag.setWordWrap(True)
|
||||
self._live_rx_diag.setStyleSheet("color: #0B6E68; font-size: 12px; font-weight: 600;")
|
||||
paper_layout.addWidget(self._live_rx_diag)
|
||||
|
||||
rp_mark = QLabel("Rp", paper)
|
||||
rp_mark.setStyleSheet("color: #0B6E68; font-size: 20px; font-weight: 700;")
|
||||
paper_layout.addWidget(rp_mark)
|
||||
|
||||
self._live_rx_herbs = QLabel("请在左侧录入药材配方,右侧实时同步处方笺排版…", paper)
|
||||
self._live_rx_herbs.setWordWrap(True)
|
||||
self._live_rx_herbs.setAlignment(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft)
|
||||
self._live_rx_herbs.setStyleSheet("color: #102625; font-size: 12.5px; line-height: 1.55;")
|
||||
paper_layout.addWidget(self._live_rx_herbs, 1)
|
||||
|
||||
self._live_rx_footer = QLabel("共 0 味", paper)
|
||||
self._live_rx_footer.setStyleSheet("color: #5F7A78; font-size: 12px; padding-top: 8px; border-top: 1px dashed #DFD4BC;")
|
||||
paper_layout.addWidget(self._live_rx_footer)
|
||||
inner.addWidget(paper, 1)
|
||||
|
||||
esign_card = QFrame(pane)
|
||||
esign_card.setObjectName("LiveEsignTrackCard")
|
||||
e_layout = QVBoxLayout(esign_card)
|
||||
e_layout.setContentsMargins(12, 11, 12, 11)
|
||||
e_layout.setSpacing(7)
|
||||
e_title = QLabel("CA 合规电子双签进度轨", esign_card)
|
||||
e_title.setStyleSheet("color: #102625; font-size: 12.5px; font-weight: 600;")
|
||||
e_layout.addWidget(e_title)
|
||||
step1 = QLabel("1. 医师编排配方与电子签章", esign_card)
|
||||
step1.setObjectName("LiveRxStepDone")
|
||||
step2 = QLabel("2. 自动推送药师审方队列", esign_card)
|
||||
step2.setObjectName("LiveRxStepPending")
|
||||
step3 = QLabel("3. 双签归档生成 PDF 原件", esign_card)
|
||||
step3.setObjectName("LiveRxStepPending")
|
||||
for s in (step1, step2, step3):
|
||||
e_layout.addWidget(s)
|
||||
inner.addWidget(esign_card)
|
||||
layout.addLayout(inner, 1)
|
||||
# 默认在大屏模式下自动联动展示,窄屏保持简洁抽屉宽度兼容既有测试
|
||||
pane.hide()
|
||||
return pane
|
||||
|
||||
def _bind_live_preview_signals(self) -> None:
|
||||
if hasattr(self, "herbs") and hasattr(self.herbs, "changed"):
|
||||
self.herbs.changed.connect(self._refresh_live_preview)
|
||||
for attr in ("patient_name", "clinical_diagnosis", "prescription_type", "usage_days"):
|
||||
widget = getattr(self, attr, None)
|
||||
if widget is None:
|
||||
continue
|
||||
for sig_name in ("textChanged", "currentTextChanged", "valueChanged"):
|
||||
sig = getattr(widget, sig_name, None)
|
||||
if sig is not None:
|
||||
sig.connect(self._refresh_live_preview)
|
||||
break
|
||||
|
||||
def _refresh_live_preview(self) -> None:
|
||||
if not hasattr(self, "_live_rx_herbs"):
|
||||
return
|
||||
patient = self.patient_name.text().strip() if hasattr(self, "patient_name") else ""
|
||||
rx_type = ""
|
||||
if hasattr(self, "prescription_type") and hasattr(self.prescription_type, "currentText"):
|
||||
rx_type = self.prescription_type.currentText().strip()
|
||||
if not rx_type:
|
||||
rx_type = str(first_value(self._source, "prescription_type", default="")).strip()
|
||||
self._live_rx_patient.setText(
|
||||
f"患者:{patient or '未填写'} | 剂型:{rx_type or '默认'}"
|
||||
)
|
||||
diag = ""
|
||||
if hasattr(self, "clinical_diagnosis"):
|
||||
diag = (
|
||||
self.clinical_diagnosis.toPlainText().strip()
|
||||
if hasattr(self.clinical_diagnosis, "toPlainText")
|
||||
else self.clinical_diagnosis.text().strip()
|
||||
)
|
||||
self._live_rx_diag.setText(f"辨证诊断:{diag or '待补充临床辨证'}")
|
||||
herbs_list: list[Any] = []
|
||||
if hasattr(self, "herbs") and callable(getattr(self.herbs, "values", None)):
|
||||
herbs_list = list(self.herbs.values())
|
||||
if herbs_list:
|
||||
lines: list[str] = []
|
||||
for idx, item in enumerate(herbs_list, start=1):
|
||||
name = str(first_value(item, "name", "drug_name", "medicine_name", default="")).strip()
|
||||
dose = str(first_value(item, "dosage", "dose", "weight", default="")).strip()
|
||||
unit = str(first_value(item, "unit", default="g")).strip() or "g"
|
||||
if name:
|
||||
lines.append(f"{idx:02d}. {name} {dose}{unit if dose else ''}")
|
||||
self._live_rx_herbs.setText("\n".join(lines) if lines else "暂无有效药味")
|
||||
days = self.usage_days.value() if hasattr(self, "usage_days") else 0
|
||||
suffix = f" · 服用 {days} 天" if days else ""
|
||||
self._live_rx_footer.setText(f"已配 {len(lines)} 味{suffix} · 实时同步")
|
||||
else:
|
||||
self._live_rx_herbs.setText("请在左侧录入药材配方,右侧实时同步处方笺排版…")
|
||||
self._live_rx_footer.setText("共 0 味")
|
||||
|
||||
def toggle_live_preview(self) -> None:
|
||||
"""一键展开或收起右侧实时仿真处方笺与 CA 双签进度轨。"""
|
||||
|
||||
if not hasattr(self, "live_preview_pane"):
|
||||
return
|
||||
showing = not self.live_preview_pane.isVisible()
|
||||
self.live_preview_pane.setVisible(showing)
|
||||
if showing:
|
||||
self._refresh_live_preview()
|
||||
if self.width() < 1180:
|
||||
self.resize(1220, self.height())
|
||||
|
||||
def _void_busy_changed(self, busy: bool) -> None:
|
||||
self.cancel_button.setEnabled(not busy)
|
||||
@@ -3280,6 +3453,20 @@ class PrescriptionEditorDialog(QDialog):
|
||||
mode.setObjectName("PrescriptionDrawerMode")
|
||||
layout.addWidget(mode)
|
||||
layout.addStretch(1)
|
||||
self.live_preview_toggle = QPushButton("实时处方笺预览", header)
|
||||
self.live_preview_toggle.setObjectName("PrescriptionLivePreviewToggle")
|
||||
self.live_preview_toggle.setCheckable(True)
|
||||
self.live_preview_toggle.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.live_preview_toggle.setToolTip("展开或收起右侧实时仿真处方笺与 CA 双签进度轨")
|
||||
self.live_preview_toggle.setStyleSheet(
|
||||
"QPushButton#PrescriptionLivePreviewToggle {"
|
||||
" min-height: 30px; max-height: 30px; padding: 0 11px; border-radius: 7px;"
|
||||
" background: #F2F9F8; border: 1px solid #C2DBD7; color: #0B6E68; font-size: 12px; font-weight: 600; }"
|
||||
"QPushButton#PrescriptionLivePreviewToggle:checked {"
|
||||
" background: #0B6E68; border-color: #0B6E68; color: #FFFFFF; }"
|
||||
)
|
||||
self.live_preview_toggle.clicked.connect(self.toggle_live_preview)
|
||||
layout.addWidget(self.live_preview_toggle, 0, Qt.AlignmentFlag.AlignVCenter)
|
||||
close_button = QPushButton("×", header)
|
||||
close_button.setObjectName("PrescriptionDrawerClose")
|
||||
close_button.setToolTip("关闭")
|
||||
@@ -3465,24 +3652,12 @@ class PrescriptionEditorDialog(QDialog):
|
||||
self.age.setRange(0, 150)
|
||||
self.visit_no = QLineEdit()
|
||||
self.visit_no.setPlaceholderText("自动生成或手动输入")
|
||||
# 手机号写入处方笺;身份证号写回关联诊单(服务端校验格式与重复,并按出生日期更新年龄)。
|
||||
self.phone = QLineEdit()
|
||||
self.phone.setPlaceholderText("11 位手机号或带区号座机,如 0571-88888888")
|
||||
self.phone.setMaxLength(20)
|
||||
# 输入时只允许数字与连字符;格式在保存时按 prescription_phone_error 校验。
|
||||
self.phone.setValidator(QRegularExpressionValidator(QRegularExpression(r"[0-9-]{0,20}"), self.phone))
|
||||
self.id_card = QLineEdit()
|
||||
self.id_card.setPlaceholderText("15 或 18 位身份证号,保存后同步到诊单")
|
||||
self.id_card.setMaxLength(18)
|
||||
self.id_card.setValidator(QRegularExpressionValidator(QRegularExpression(r"[0-9]{0,17}[0-9Xx]?"), self.id_card))
|
||||
self.date_edit = PrescriptionDateEdit(QDate.currentDate())
|
||||
|
||||
name_grid = QGridLayout()
|
||||
self._prepare_grid(name_grid, 2)
|
||||
self._place_field(name_grid, 0, 0, "患者姓名", self.patient_name, required=True)
|
||||
self._place_field(name_grid, 0, 1, "门诊号", self.visit_no)
|
||||
self._place_field(name_grid, 1, 0, "手机号", self.phone)
|
||||
self._place_field(name_grid, 1, 1, "身份证号", self.id_card)
|
||||
layout.addLayout(name_grid)
|
||||
self._register_responsive_grid(name_grid, 2)
|
||||
|
||||
@@ -3881,8 +4056,6 @@ class PrescriptionEditorDialog(QDialog):
|
||||
appointment_id=_int(source.get("appointment_id"), 0),
|
||||
)
|
||||
self.visit_no.setText(visit_no)
|
||||
self.phone.setText(str(source.get("phone") or "").strip())
|
||||
self.id_card.setText(str(source.get("patient_id_card") or source.get("id_card") or "").strip())
|
||||
self._set_gender(source.get("gender", 1))
|
||||
self.age.setValue(_int(source.get("age"), 0))
|
||||
date_value = QDate.fromString(
|
||||
@@ -4329,8 +4502,6 @@ class PrescriptionEditorDialog(QDialog):
|
||||
"need_decoction": int(self.need_decoction.isChecked()),
|
||||
"bags_per_dose": self.bags_per_dose.value(),
|
||||
"patient_name": self.patient_name.text().strip(),
|
||||
"phone": self.phone.text().strip(),
|
||||
"id_card": self.id_card.text().strip().upper(),
|
||||
"gender": self._gender_value(),
|
||||
"age": self.age.value(),
|
||||
"visit_no": self.visit_no.text().strip(),
|
||||
@@ -4428,21 +4599,6 @@ class PrescriptionEditorDialog(QDialog):
|
||||
self.validation.show_message(message, "warning")
|
||||
widget.setFocus()
|
||||
return
|
||||
original_phone = str(self._source.get("phone") or "").strip()
|
||||
phone_error = "" if payload.get("phone") == original_phone else prescription_phone_error(payload.get("phone"))
|
||||
if phone_error:
|
||||
self.tabs.setCurrentIndex(0)
|
||||
self.validation.show_message(phone_error, "warning")
|
||||
self.phone.setFocus()
|
||||
return
|
||||
if payload.get("id_card"):
|
||||
try:
|
||||
payload["id_card"] = certificate_identity_number(payload["id_card"])
|
||||
except ValueError as error:
|
||||
self.tabs.setCurrentIndex(0)
|
||||
self.validation.show_message(str(error), "warning")
|
||||
self.id_card.setFocus()
|
||||
return
|
||||
length_checks = (
|
||||
(
|
||||
payload["clinical_diagnosis"],
|
||||
@@ -5106,14 +5262,6 @@ def render_prescription_html(
|
||||
bags = positive_number(source.get("dosage_bag_count"), 1)
|
||||
if prescription_type == "浓缩水丸" and days and times and amount:
|
||||
out_pellet = f"{number_text(days * times * amount * bags)}克"
|
||||
# 有辅方药材时同时给出辅方出丸(辅方服用天数 × 每日次数 × 每袋用量 × 每次袋数),与管理后台一致。
|
||||
aux_days = positive_number(aux_usage.get("usage_days"), 0)
|
||||
aux_times = positive_number(aux_usage.get("times_per_day"), 0)
|
||||
aux_amount = positive_number(aux_usage.get("dosage_amount"), 0)
|
||||
aux_bags = positive_number(aux_usage.get("dosage_bag_count"), 1)
|
||||
if aux and aux_days and aux_times and aux_amount:
|
||||
aux_pellet = number_text(aux_days * aux_times * aux_amount * aux_bags)
|
||||
out_pellet = f"主方 {out_pellet},辅方 {aux_pellet}克"
|
||||
elif herbs:
|
||||
total_weight = sum(_float(row.get("dosage")) for row in herbs) * dose_count
|
||||
out_pellet = f"{number_text(total_weight)}克"
|
||||
@@ -6005,11 +6153,17 @@ class PrescriptionDetailDialog(QDialog):
|
||||
self.resize(1240, 800)
|
||||
# 与「处方电子签署」一致:左侧三联预览,右侧签署流程与操作。
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(20, 20, 20, 20)
|
||||
self.workspace_splitter = QSplitter(Qt.Orientation.Horizontal, self)
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
root.setSpacing(0)
|
||||
root.addWidget(ClinicalAccentBar(self))
|
||||
body_wrap = QWidget(self)
|
||||
body_layout = QVBoxLayout(body_wrap)
|
||||
body_layout.setContentsMargins(20, 16, 20, 20)
|
||||
self.workspace_splitter = QSplitter(Qt.Orientation.Horizontal, body_wrap)
|
||||
self.workspace_splitter.setChildrenCollapsible(False)
|
||||
self.workspace_splitter.setHandleWidth(12)
|
||||
root.addWidget(self.workspace_splitter)
|
||||
body_layout.addWidget(self.workspace_splitter)
|
||||
root.addWidget(body_wrap, 1)
|
||||
|
||||
preview_panel = QWidget(self.workspace_splitter)
|
||||
preview_panel.setMinimumWidth(370)
|
||||
|
||||
@@ -48,7 +48,15 @@ from ...core.esign import (
|
||||
signed_pdf_bytes,
|
||||
)
|
||||
from ..design_system import clinical_stylesheet
|
||||
from ..widgets import MessageBanner, first_value, friendly_error, has_permission, run_async, show_toast
|
||||
from ..widgets import (
|
||||
MessageBanner,
|
||||
first_value,
|
||||
friendly_error,
|
||||
has_permission,
|
||||
run_async,
|
||||
show_toast,
|
||||
)
|
||||
from ..window_primitives import ClinicalAccentBar
|
||||
from .esign_doctor import EsignDoctorDialog
|
||||
from .esign_webview import create_identity_view
|
||||
|
||||
@@ -404,11 +412,17 @@ class PrescriptionEsignDialog(QDialog):
|
||||
from .prescription import PrescriptionSigningPreview
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(20, 20, 20, 20)
|
||||
self.workspace_splitter = QSplitter(Qt.Orientation.Horizontal, self)
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
root.setSpacing(0)
|
||||
root.addWidget(ClinicalAccentBar(self))
|
||||
body_wrap = QWidget(self)
|
||||
body_layout = QVBoxLayout(body_wrap)
|
||||
body_layout.setContentsMargins(20, 16, 20, 20)
|
||||
self.workspace_splitter = QSplitter(Qt.Orientation.Horizontal, body_wrap)
|
||||
self.workspace_splitter.setChildrenCollapsible(False)
|
||||
self.workspace_splitter.setHandleWidth(12)
|
||||
root.addWidget(self.workspace_splitter)
|
||||
body_layout.addWidget(self.workspace_splitter)
|
||||
root.addWidget(body_wrap, 1)
|
||||
|
||||
self.prescription_preview = PrescriptionSigningPreview(self.repository, prescription, parent=self.workspace_splitter)
|
||||
self.prescription_preview.setMinimumWidth(370)
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
"""W4 视频问诊双屏协同驾驶舱(演示预览与原生临床速记协同视窗)。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtCore import Qt, QTimer
|
||||
from PySide6.QtWidgets import (
|
||||
QDialog,
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPlainTextEdit,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from ..window_primitives import ClinicalAccentBar
|
||||
|
||||
|
||||
class VideoCockpitDemoDialog(QDialog):
|
||||
"""W4 视频问诊双屏协同驾驶舱:左深曜影院画布 + 底部毛玻璃控坞 + 右伴随四诊速记侧栏。"""
|
||||
|
||||
def __init__(self, patient_name: str, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self._seconds = 0
|
||||
self._tongue_count = 0
|
||||
self.setWindowTitle("视频面诊 · 双屏协同驾驶舱")
|
||||
self.setMinimumSize(860, 560)
|
||||
self.resize(1120, 700)
|
||||
self.setModal(False)
|
||||
self.setStyleSheet(
|
||||
"QDialog{background:#071515;color:#EFF9F8;}"
|
||||
"QFrame#VideoTopHud{background:rgba(12,38,37,220);border:1px solid rgba(223,199,147,90);border-radius:12px;}"
|
||||
"QFrame#RemoteStage{background:qradialgradient(cx:0.5,cy:0.4,radius:0.8,fx:0.5,fy:0.4,stop:0 #153E3C,stop:0.65 #081A1A,stop:1 #040D0D);"
|
||||
"border:1px solid rgba(223,199,147,60);border-radius:16px;}"
|
||||
"QFrame#RemoteStage QLabel{color:#EFF9F8;}"
|
||||
"QFrame#LocalStage{background:qlineargradient(x1:0,y1:0,x2:1,y2:1,stop:0 #184644,stop:1 #0B2524);"
|
||||
"border:1.5px solid #DFC793;border-radius:12px;}"
|
||||
"QFrame#VideoDock{background:rgba(9,28,28,235);border:1px solid rgba(223,199,147,110);border-radius:24px;}"
|
||||
"QFrame#VideoCompanionRail{background:#F5FAF9;border-left:1px solid #C6DAD6;}"
|
||||
"QFrame#VideoCompanionRail QLabel{color:#102625;}"
|
||||
"QPlainTextEdit#VideoQuickNotes{background:#FFFFFF;border:1px solid #C4D8D4;border-radius:10px;padding:8px;color:#102625;font-size:13px;}"
|
||||
"QPushButton{min-width:88px;min-height:36px;padding:0 14px;border-radius:18px;"
|
||||
"background:rgba(255,255,255,22);color:#F0FAF9;border:1px solid rgba(255,255,255,48);font-weight:600;}"
|
||||
"QPushButton:hover{background:rgba(24,176,165,70);border-color:#DFC793;color:#FFFFFF;}"
|
||||
"QPushButton:checked{background:rgba(223,199,147,60);border-color:#DFC793;color:#DFC793;}"
|
||||
"QPushButton#TongueBtn{background:rgba(223,199,147,48);border-color:#DFC793;color:#DFC793;}"
|
||||
"QPushButton#Hangup{color:#FFFFFF;background:#D63F4F;border-color:#D63F4F;}"
|
||||
"QPushButton#Hangup:hover{background:#B92E3D;border-color:#B92E3D;}"
|
||||
)
|
||||
|
||||
root_col = QVBoxLayout(self)
|
||||
root_col.setContentsMargins(0, 0, 0, 0)
|
||||
root_col.setSpacing(0)
|
||||
root_col.addWidget(ClinicalAccentBar(self))
|
||||
|
||||
outer = QHBoxLayout()
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
|
||||
left_wrap = QWidget(self)
|
||||
left_layout = QVBoxLayout(left_wrap)
|
||||
left_layout.setContentsMargins(16, 14, 16, 16)
|
||||
left_layout.setSpacing(12)
|
||||
|
||||
top_hud = QFrame(left_wrap)
|
||||
top_hud.setObjectName("VideoTopHud")
|
||||
header = QHBoxLayout(top_hud)
|
||||
header.setContentsMargins(14, 9, 14, 9)
|
||||
title = QLabel(f"● 视频面诊 · {patient_name or '患者'}", top_hud)
|
||||
title.setStyleSheet("font-size:15px;font-weight:700;color:#F4FAF9;")
|
||||
header.addWidget(title)
|
||||
header.addStretch(1)
|
||||
demo = QLabel("本地加密录音就绪 · 演示模式", top_hud)
|
||||
demo.setStyleSheet("color:#9FC5C1;font-size:12px;")
|
||||
header.addWidget(demo)
|
||||
self.duration_label = QLabel("00:00", top_hud)
|
||||
self.duration_label.setStyleSheet("font-weight:700;color:#DFC793;padding-left:10px;")
|
||||
header.addWidget(self.duration_label)
|
||||
left_layout.addWidget(top_hud)
|
||||
|
||||
stage = QFrame(left_wrap)
|
||||
stage.setObjectName("RemoteStage")
|
||||
stage_layout = QVBoxLayout(stage)
|
||||
stage_layout.setContentsMargins(22, 22, 22, 22)
|
||||
stage_layout.addStretch(1)
|
||||
avatar = QLabel((patient_name or "患")[:1], stage)
|
||||
avatar.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
avatar.setFixedSize(96, 96)
|
||||
avatar.setStyleSheet(
|
||||
"background:rgba(24,176,165,48);color:#FFFFFF;border:2px solid #DFC793;"
|
||||
"border-radius:48px;font-size:38px;font-weight:700;"
|
||||
)
|
||||
stage_layout.addWidget(avatar, 0, Qt.AlignmentFlag.AlignHCenter)
|
||||
waiting = QLabel("等待患者接入高清视频画面…", stage)
|
||||
waiting.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
waiting.setStyleSheet("font-size:16px;font-weight:600;margin-top:8px;")
|
||||
stage_layout.addWidget(waiting)
|
||||
hint = QLabel("生产模式通过后端短时 UserSig 驱动 TRTC,支持舌象高清抓拍与实时转写", stage)
|
||||
hint.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
hint.setStyleSheet("color:#91BDB8;font-size:12px;")
|
||||
stage_layout.addWidget(hint)
|
||||
self._tongue_status = QLabel("", stage)
|
||||
self._tongue_status.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self._tongue_status.setStyleSheet("color:#DFC793;font-size:12px;font-weight:600;margin-top:6px;")
|
||||
stage_layout.addWidget(self._tongue_status)
|
||||
stage_layout.addStretch(1)
|
||||
|
||||
local = QFrame(stage)
|
||||
local.setObjectName("LocalStage")
|
||||
local.setGeometry(20, 20, 176, 108)
|
||||
local_layout = QVBoxLayout(local)
|
||||
local_label = QLabel("陈医生(本机画面)", local)
|
||||
local_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
local_label.setStyleSheet("color:#EFF9F8;font-weight:600;font-size:12px;")
|
||||
local_layout.addWidget(local_label)
|
||||
left_layout.addWidget(stage, 1)
|
||||
|
||||
dock = QFrame(left_wrap)
|
||||
dock.setObjectName("VideoDock")
|
||||
controls = QHBoxLayout(dock)
|
||||
controls.setContentsMargins(14, 7, 14, 7)
|
||||
controls.setSpacing(10)
|
||||
self.mic_button = QPushButton("麦克风 开", dock)
|
||||
self.mic_button.setCheckable(True)
|
||||
self.mic_button.toggled.connect(
|
||||
lambda muted: self.mic_button.setText("麦克风 关" if muted else "麦克风 开")
|
||||
)
|
||||
controls.addWidget(self.mic_button)
|
||||
self.camera_button = QPushButton("摄像头 开", dock)
|
||||
self.camera_button.setCheckable(True)
|
||||
self.camera_button.toggled.connect(
|
||||
lambda off: self.camera_button.setText("摄像头 关" if off else "摄像头 开")
|
||||
)
|
||||
controls.addWidget(self.camera_button)
|
||||
tongue_btn = QPushButton("舌象高清抓拍", dock)
|
||||
tongue_btn.setObjectName("TongueBtn")
|
||||
tongue_btn.clicked.connect(self._capture_demo_tongue)
|
||||
controls.addWidget(tongue_btn)
|
||||
hangup = QPushButton("结束面诊", dock)
|
||||
hangup.setObjectName("Hangup")
|
||||
hangup.clicked.connect(self.close)
|
||||
controls.addWidget(hangup)
|
||||
left_layout.addWidget(dock, 0, Qt.AlignmentFlag.AlignHCenter)
|
||||
outer.addWidget(left_wrap, 1)
|
||||
|
||||
rail = QFrame(self)
|
||||
rail.setObjectName("VideoCompanionRail")
|
||||
rail.setFixedWidth(340)
|
||||
rail_layout = QVBoxLayout(rail)
|
||||
rail_layout.setContentsMargins(16, 16, 16, 16)
|
||||
rail_layout.setSpacing(10)
|
||||
rail_title = QLabel("伴随四诊速记(双屏协同)", rail)
|
||||
rail_title.setStyleSheet("font-size:15px;font-weight:700;color:#102625;")
|
||||
rail_layout.addWidget(rail_title)
|
||||
rail_hint = QLabel("面诊过程中实时记录主诉与舌脉,结束后自动带入病历草稿。", rail)
|
||||
rail_hint.setWordWrap(True)
|
||||
rail_hint.setStyleSheet("font-size:12px;color:#5F7A78;")
|
||||
rail_layout.addWidget(rail_hint)
|
||||
self.quick_notes = QPlainTextEdit(rail)
|
||||
self.quick_notes.setObjectName("VideoQuickNotes")
|
||||
self.quick_notes.setPlaceholderText("在此速记本次视频面诊的主诉、舌质舌苔、脉象与调方思路…")
|
||||
rail_layout.addWidget(self.quick_notes, 1)
|
||||
ai_hint_box = QFrame(rail)
|
||||
ai_hint_box.setStyleSheet(
|
||||
"QFrame{background:#EAF6F4;border:1px solid #B7DDD6;border-radius:10px;padding:8px;}"
|
||||
)
|
||||
ai_hint_l = QVBoxLayout(ai_hint_box)
|
||||
ai_hint_l.setContentsMargins(10, 8, 10, 8)
|
||||
ai_lbl = QLabel("AI 问诊提醒:建议核实近期夜间睡眠与餐后 2h 血糖峰值。", ai_hint_box)
|
||||
ai_lbl.setWordWrap(True)
|
||||
ai_lbl.setStyleSheet("color:#0B6E68;font-size:12px;font-weight:500;")
|
||||
ai_hint_l.addWidget(ai_lbl)
|
||||
rail_layout.addWidget(ai_hint_box)
|
||||
outer.addWidget(rail)
|
||||
root_col.addLayout(outer, 1)
|
||||
|
||||
self._timer = QTimer(self)
|
||||
self._timer.timeout.connect(self._tick)
|
||||
self._timer.start(1000)
|
||||
|
||||
def _capture_demo_tongue(self) -> None:
|
||||
self._tongue_count += 1
|
||||
self._tongue_status.setText(f"✓ 已抓拍第 {self._tongue_count} 帧高清舌象并准备归档")
|
||||
|
||||
def _tick(self) -> None:
|
||||
self._seconds += 1
|
||||
minutes, seconds = divmod(self._seconds, 60)
|
||||
self.duration_label.setText(f"{minutes:02d}:{seconds:02d}")
|
||||
|
||||
|
||||
__all__ = ["VideoCockpitDemoDialog"]
|
||||
@@ -69,6 +69,7 @@ ROLES = {
|
||||
"strong": COLORS["text"],
|
||||
"accent": COLORS["indigo"],
|
||||
"on_accent": "#FFFFFF",
|
||||
"gold": COLORS["gold"],
|
||||
"success": COLORS["success"],
|
||||
"warning": COLORS["warning"],
|
||||
"danger": COLORS["danger"],
|
||||
@@ -124,8 +125,41 @@ def _dot(p: QPainter, cx: float, cy: float, r: float) -> None:
|
||||
p.setPen(pen)
|
||||
|
||||
|
||||
def _tint_brush(p: QPainter, alpha: int = 38) -> QColor:
|
||||
"""Return a translucent duotone fill derived from the active stroke colour."""
|
||||
|
||||
tint = QColor(p.pen().color())
|
||||
tint.setAlpha(alpha)
|
||||
return tint
|
||||
|
||||
|
||||
def _duotone_path(p: QPainter, path: QPainterPath, alpha: int = 38) -> None:
|
||||
"""Draw a closed path with a subtle duotone tint fill beneath its crisp stroke."""
|
||||
|
||||
p.save()
|
||||
p.setBrush(_tint_brush(p, alpha))
|
||||
p.drawPath(path)
|
||||
p.restore()
|
||||
|
||||
|
||||
def _duotone_rounded_rect(
|
||||
p: QPainter, rect: QRectF, rx: float, ry: float, alpha: int = 38
|
||||
) -> None:
|
||||
p.save()
|
||||
p.setBrush(_tint_brush(p, alpha))
|
||||
p.drawRoundedRect(rect, rx, ry)
|
||||
p.restore()
|
||||
|
||||
|
||||
def _duotone_circle(p: QPainter, cx: float, cy: float, r: float, alpha: int = 38) -> None:
|
||||
p.save()
|
||||
p.setBrush(_tint_brush(p, alpha))
|
||||
p.drawEllipse(QPointF(cx, cy), r, r)
|
||||
p.restore()
|
||||
|
||||
|
||||
def _page(p: QPainter, *, fold: bool = True) -> None:
|
||||
"""Shared document silhouette so every file-like glyph has one outline."""
|
||||
"""Shared document silhouette with subtle duotone glass tint."""
|
||||
|
||||
path = QPainterPath(QPointF(14.0, 2.5))
|
||||
path.lineTo(QPointF(6.5, 2.5))
|
||||
@@ -136,13 +170,13 @@ def _page(p: QPainter, *, fold: bool = True) -> None:
|
||||
path.quadTo(QPointF(19.0, 21.5), QPointF(19.0, 20.0))
|
||||
path.lineTo(QPointF(19.0, 7.5))
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
_duotone_path(p, path, 34)
|
||||
if fold:
|
||||
_polyline(p, (14.0, 2.5), (14.0, 7.5), (19.0, 7.5))
|
||||
|
||||
|
||||
def _sparkle(p: QPainter, cx: float, cy: float, r: float) -> None:
|
||||
"""Four-point concave star - the one AI mark used across the product."""
|
||||
def _sparkle(p: QPainter, cx: float, cy: float, r: float, *, alpha: int = 56) -> None:
|
||||
"""Four-point concave star - the precision AI mark with luminous duotone core."""
|
||||
|
||||
path = QPainterPath(QPointF(cx, cy - r))
|
||||
path.quadTo(QPointF(cx, cy), QPointF(cx + r, cy))
|
||||
@@ -150,11 +184,11 @@ def _sparkle(p: QPainter, cx: float, cy: float, r: float) -> None:
|
||||
path.quadTo(QPointF(cx, cy), QPointF(cx - r, cy))
|
||||
path.quadTo(QPointF(cx, cy), QPointF(cx, cy - r))
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
_duotone_path(p, path, alpha)
|
||||
|
||||
|
||||
def _panel(p: QPainter) -> None:
|
||||
p.drawRoundedRect(QRectF(2.5, 4.0, 19.0, 16.0), 3.0, 3.0)
|
||||
_duotone_rounded_rect(p, QRectF(2.5, 4.0, 19.0, 16.0), 3.0, 3.0, 28)
|
||||
_line(p, 9.5, 4.0, 9.5, 20.0)
|
||||
|
||||
|
||||
@@ -163,18 +197,20 @@ def _panel(p: QPainter) -> None:
|
||||
|
||||
@_glyph("reception", "workbench", "monitor")
|
||||
def _reception(p: QPainter, w: float) -> None:
|
||||
p.drawRoundedRect(QRectF(2.5, 3.5, 19.0, 13.5), 3.0, 3.0)
|
||||
_polyline(p, (6.0, 10.5), (8.8, 10.5), (10.6, 7.5), (13.4, 13.5), (15.2, 10.5), (18.0, 10.5))
|
||||
_duotone_rounded_rect(p, QRectF(2.5, 3.5, 19.0, 13.5), 3.2, 3.2, 38)
|
||||
_polyline(p, (5.8, 10.5), (8.6, 10.5), (10.5, 7.2), (13.4, 13.6), (15.3, 10.5), (18.2, 10.5))
|
||||
_line(p, 12.0, 17.0, 12.0, 20.5)
|
||||
_line(p, 8.0, 20.5, 16.0, 20.5)
|
||||
|
||||
|
||||
@_glyph("appointments", "calendar")
|
||||
def _calendar(p: QPainter, w: float) -> None:
|
||||
p.drawRoundedRect(QRectF(3.0, 5.0, 18.0, 16.5), 3.0, 3.0)
|
||||
_duotone_rounded_rect(p, QRectF(3.0, 5.0, 18.0, 16.5), 3.2, 3.2, 36)
|
||||
_line(p, 3.0, 10.0, 21.0, 10.0)
|
||||
_line(p, 8.0, 2.75, 8.0, 7.0)
|
||||
_line(p, 16.0, 2.75, 16.0, 7.0)
|
||||
_line(p, 8.0, 2.75, 8.0, 6.8)
|
||||
_line(p, 16.0, 2.75, 16.0, 6.8)
|
||||
_line(p, 7.5, 14.0, 11.5, 14.0)
|
||||
_line(p, 7.5, 17.4, 15.0, 17.4)
|
||||
|
||||
|
||||
@_glyph("prescription_library", "library", "layers")
|
||||
@@ -184,7 +220,7 @@ def _layers(p: QPainter, w: float) -> None:
|
||||
path.lineTo(QPointF(12.0, 11.5))
|
||||
path.lineTo(QPointF(3.0, 7.0))
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
_duotone_path(p, path, 48)
|
||||
_polyline(p, (3.0, 12.0), (12.0, 16.5), (21.0, 12.0))
|
||||
_polyline(p, (3.0, 16.75), (12.0, 21.25), (21.0, 16.75))
|
||||
|
||||
@@ -197,12 +233,12 @@ def _file_check(p: QPainter, w: float) -> None:
|
||||
|
||||
@_glyph("patients", "users")
|
||||
def _users(p: QPainter, w: float) -> None:
|
||||
_circle(p, 9.0, 8.0, 3.5)
|
||||
_duotone_circle(p, 9.0, 8.0, 3.5, 42)
|
||||
path = QPainterPath(QPointF(2.5, 20.5))
|
||||
path.quadTo(QPointF(2.5, 14.5), QPointF(9.0, 14.5))
|
||||
path.quadTo(QPointF(15.5, 14.5), QPointF(15.5, 20.5))
|
||||
p.drawPath(path)
|
||||
_circle(p, 17.6, 8.0, 2.8)
|
||||
_duotone_circle(p, 17.6, 8.0, 2.8, 28)
|
||||
tail = QPainterPath(QPointF(17.0, 13.9))
|
||||
tail.quadTo(QPointF(21.5, 14.6), QPointF(21.5, 20.5))
|
||||
p.drawPath(tail)
|
||||
@@ -221,7 +257,7 @@ def _message(p: QPainter, w: float) -> None:
|
||||
path.quadTo(QPointF(3.5, 16.5), QPointF(3.5, 13.5))
|
||||
path.lineTo(QPointF(3.5, 6.5))
|
||||
path.quadTo(QPointF(3.5, 3.5), QPointF(6.5, 3.5))
|
||||
p.drawPath(path)
|
||||
_duotone_path(p, path, 38)
|
||||
_line(p, 7.75, 8.25, 16.25, 8.25)
|
||||
_line(p, 7.75, 11.75, 13.0, 11.75)
|
||||
|
||||
@@ -275,10 +311,23 @@ def _ai(p: QPainter, w: float) -> None:
|
||||
|
||||
@_glyph("fullscreen", "expand-corners", "maximize")
|
||||
def _fullscreen(p: QPainter, w: float) -> None:
|
||||
_polyline(p, (9.0, 3.5), (3.5, 3.5), (3.5, 9.0))
|
||||
_polyline(p, (15.0, 3.5), (20.5, 3.5), (20.5, 9.0))
|
||||
_polyline(p, (3.5, 15.0), (3.5, 20.5), (9.0, 20.5))
|
||||
_polyline(p, (20.5, 15.0), (20.5, 20.5), (15.0, 20.5))
|
||||
# 标准现代桌面端圆角单窗最大化图标,取代生硬的四角取景框
|
||||
p.drawRoundedRect(QRectF(4.5, 4.5, 15.0, 15.0), 2.8, 2.8)
|
||||
|
||||
|
||||
@_glyph("restore", "unmaximize")
|
||||
def _restore(p: QPainter, w: float) -> None:
|
||||
# 标准现代桌面端双窗还原图标
|
||||
p.drawRoundedRect(QRectF(4.25, 7.25, 12.25, 12.25), 2.4, 2.4)
|
||||
back = QPainterPath(QPointF(7.75, 7.25))
|
||||
back.lineTo(QPointF(7.75, 6.2))
|
||||
back.quadTo(QPointF(7.75, 4.25), QPointF(9.7, 4.25))
|
||||
back.lineTo(QPointF(17.8, 4.25))
|
||||
back.quadTo(QPointF(19.75, 4.25), QPointF(19.75, 6.2))
|
||||
back.lineTo(QPointF(19.75, 14.3))
|
||||
back.quadTo(QPointF(19.75, 16.25), QPointF(17.8, 16.25))
|
||||
back.lineTo(QPointF(16.5, 16.25))
|
||||
p.drawPath(back)
|
||||
|
||||
|
||||
@_glyph("minimize")
|
||||
@@ -318,17 +367,27 @@ def _bell(p: QPainter, w: float) -> None:
|
||||
path.lineTo(QPointF(6.75, 10.75))
|
||||
path.arcTo(QRectF(6.75, 5.0, 10.5, 11.5), 180.0, -180.0)
|
||||
path.lineTo(QPointF(17.25, 17.5))
|
||||
p.drawPath(path)
|
||||
path.closeSubpath()
|
||||
_duotone_path(p, path, 36)
|
||||
_line(p, 4.5, 17.5, 19.5, 17.5)
|
||||
p.drawArc(QRectF(10.0, 17.4, 4.0, 3.6), 180 * 16, 180 * 16)
|
||||
|
||||
|
||||
@_glyph("settings", "sliders")
|
||||
def _settings(p: QPainter, w: float) -> None:
|
||||
_line(p, 3.5, 8.5, 20.5, 8.5)
|
||||
_line(p, 3.5, 15.5, 20.5, 15.5)
|
||||
_circle(p, 9.0, 8.5, 2.4)
|
||||
_circle(p, 15.0, 15.5, 2.4)
|
||||
# 精密八齿圆润齿轮 + 双色调内核,替代锯齿硬编码多边形与简陋滑块
|
||||
_duotone_circle(p, 12.0, 12.0, 5.4, 34)
|
||||
_circle(p, 12.0, 12.0, 2.35)
|
||||
for step in range(8):
|
||||
angle = step * math.pi / 4.0
|
||||
cos_a, sin_a = math.cos(angle), math.sin(angle)
|
||||
_line(
|
||||
p,
|
||||
12.0 + 5.7 * cos_a,
|
||||
12.0 + 5.7 * sin_a,
|
||||
12.0 + 8.6 * cos_a,
|
||||
12.0 + 8.6 * sin_a,
|
||||
)
|
||||
|
||||
|
||||
# --- Row and toolbar actions ---------------------------------------------
|
||||
@@ -339,8 +398,8 @@ def _eye(p: QPainter, w: float) -> None:
|
||||
path = QPainterPath(QPointF(2.5, 12.0))
|
||||
path.quadTo(QPointF(12.0, 2.5), QPointF(21.5, 12.0))
|
||||
path.quadTo(QPointF(12.0, 21.5), QPointF(2.5, 12.0))
|
||||
p.drawPath(path)
|
||||
_circle(p, 12.0, 12.0, 3.0)
|
||||
_duotone_path(p, path, 28)
|
||||
_duotone_circle(p, 12.0, 12.0, 3.0, 48)
|
||||
|
||||
|
||||
@_glyph("pencil", "edit")
|
||||
@@ -569,13 +628,13 @@ def _qr(p: QPainter, w: float) -> None:
|
||||
|
||||
@_glyph("video", "call")
|
||||
def _video(p: QPainter, w: float) -> None:
|
||||
p.drawRoundedRect(QRectF(2.5, 6.0, 13.5, 12.0), 3.0, 3.0)
|
||||
_duotone_rounded_rect(p, QRectF(2.5, 6.0, 13.5, 12.0), 3.0, 3.0, 38)
|
||||
path = QPainterPath(QPointF(16.0, 10.5))
|
||||
path.lineTo(QPointF(21.5, 7.25))
|
||||
path.lineTo(QPointF(21.5, 16.75))
|
||||
path.lineTo(QPointF(16.0, 13.5))
|
||||
path.closeSubpath()
|
||||
p.drawPath(path)
|
||||
_duotone_path(p, path, 32)
|
||||
|
||||
|
||||
# --- Clinical measures ----------------------------------------------------
|
||||
@@ -596,14 +655,14 @@ def _height(p: QPainter, w: float) -> None:
|
||||
|
||||
@_glyph("weight", "scale")
|
||||
def _weight(p: QPainter, w: float) -> None:
|
||||
p.drawRoundedRect(QRectF(3.0, 5.0, 18.0, 14.5), 3.5, 3.5)
|
||||
_duotone_rounded_rect(p, QRectF(3.0, 5.0, 18.0, 14.5), 3.5, 3.5, 34)
|
||||
p.drawArc(QRectF(7.0, 10.0, 10.0, 10.0), 25 * 16, 130 * 16)
|
||||
_line(p, 12.0, 15.0, 9.9, 10.9)
|
||||
|
||||
|
||||
@_glyph("bmi", "body")
|
||||
def _bmi(p: QPainter, w: float) -> None:
|
||||
_circle(p, 12.0, 5.0, 2.75)
|
||||
_duotone_circle(p, 12.0, 5.0, 2.75, 42)
|
||||
_line(p, 12.0, 7.75, 12.0, 15.0)
|
||||
_line(p, 7.25, 11.0, 16.75, 11.0)
|
||||
_polyline(p, (8.5, 20.75), (12.0, 15.0), (15.5, 20.75))
|
||||
@@ -611,8 +670,10 @@ def _bmi(p: QPainter, w: float) -> None:
|
||||
|
||||
@_glyph("blood_pressure", "gauge", "bp")
|
||||
def _blood_pressure(p: QPainter, w: float) -> None:
|
||||
p.drawArc(QRectF(3.0, 5.5, 18.0, 18.0), 0, 180 * 16)
|
||||
_line(p, 3.0, 14.5, 21.0, 14.5)
|
||||
arc_path = QPainterPath(QPointF(3.0, 14.5))
|
||||
arc_path.arcTo(QRectF(3.0, 5.5, 18.0, 18.0), 180, -180)
|
||||
arc_path.closeSubpath()
|
||||
_duotone_path(p, arc_path, 34)
|
||||
_line(p, 12.0, 14.5, 16.4, 9.4)
|
||||
_dot(p, 12.0, 14.5, 1.15)
|
||||
|
||||
@@ -625,7 +686,7 @@ def _pulse(p: QPainter, w: float) -> None:
|
||||
heart.cubicTo(QPointF(13.5, 4.8), QPointF(16.8, 4.0), QPointF(19.3, 6.7))
|
||||
heart.cubicTo(QPointF(21.8, 9.6), QPointF(20.8, 13.6), QPointF(12.0, 20.25))
|
||||
heart.closeSubpath()
|
||||
p.drawPath(heart)
|
||||
_duotone_path(p, heart, 36)
|
||||
_polyline(
|
||||
p, (5.6, 12.4), (9.0, 12.4), (10.6, 9.7), (13.2, 15.1), (14.7, 12.4), (18.4, 12.4)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
"""桌面端全局精工交互引擎:统一手型光标、Windows 11 DWM 视窗融合与优雅按压手感."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import QEvent, QObject, Qt
|
||||
from PySide6.QtWidgets import (
|
||||
QAbstractButton,
|
||||
QApplication,
|
||||
QComboBox,
|
||||
QDialog,
|
||||
QFileDialog,
|
||||
QInputDialog,
|
||||
QMessageBox,
|
||||
QTabBar,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from .design_system import PALETTE
|
||||
|
||||
# Windows 11 DWM 窗口装饰属性常量
|
||||
_DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
||||
_DWMWA_WINDOW_CORNER_PREFERENCE = 33
|
||||
_DWMWA_BORDER_COLOR = 34
|
||||
_DWMWA_CAPTION_COLOR = 35
|
||||
_DWMWA_TEXT_COLOR = 36
|
||||
_DWMWCP_ROUND = 2
|
||||
|
||||
|
||||
def _colorref(hex_color: str) -> int:
|
||||
"""将 ``#RRGGBB`` 转为 Win32 DWM 所需的 ``0x00BBGGRR`` 整型。"""
|
||||
|
||||
clean = hex_color.lstrip("#")
|
||||
red, green, blue = (int(clean[i : i + 2], 16) for i in (0, 2, 4))
|
||||
return (blue << 16) | (green << 8) | red
|
||||
|
||||
|
||||
def apply_luxury_dwm_chrome(widget: QWidget, *, dark: bool = False) -> bool:
|
||||
"""在 Windows 11 上同步原生子视窗标题栏、圆角偏好与边框至「御瓷智医」色系。"""
|
||||
|
||||
if sys.platform != "win32":
|
||||
return False
|
||||
if widget.windowFlags() & Qt.WindowType.FramelessWindowHint:
|
||||
return False
|
||||
try:
|
||||
handle = int(widget.winId())
|
||||
except Exception:
|
||||
return False
|
||||
if not handle:
|
||||
return False
|
||||
try:
|
||||
dwm = ctypes.windll.dwmapi
|
||||
except (AttributeError, OSError):
|
||||
return False
|
||||
|
||||
caption_hex = PALETTE["obsidian"] if dark else PALETTE["surface"]
|
||||
text_hex = "#F2FAF9" if dark else PALETTE["heading"]
|
||||
border_hex = PALETTE["gold"] if dark else PALETTE["line_strong"]
|
||||
|
||||
dark_val = ctypes.c_int(1 if dark else 0)
|
||||
corner_val = ctypes.c_int(_DWMWCP_ROUND)
|
||||
caption_val = ctypes.c_uint(_colorref(caption_hex))
|
||||
text_val = ctypes.c_uint(_colorref(text_hex))
|
||||
border_val = ctypes.c_uint(_colorref(border_hex))
|
||||
|
||||
applied = False
|
||||
for attr, value in (
|
||||
(_DWMWA_USE_IMMERSIVE_DARK_MODE, dark_val),
|
||||
(_DWMWA_WINDOW_CORNER_PREFERENCE, corner_val),
|
||||
(_DWMWA_CAPTION_COLOR, caption_val),
|
||||
(_DWMWA_TEXT_COLOR, text_val),
|
||||
(_DWMWA_BORDER_COLOR, border_val),
|
||||
):
|
||||
try:
|
||||
res = dwm.DwmSetWindowAttribute(
|
||||
ctypes.c_void_p(handle),
|
||||
ctypes.c_int(attr),
|
||||
ctypes.byref(value),
|
||||
ctypes.sizeof(value),
|
||||
)
|
||||
applied = applied or res == 0
|
||||
except OSError:
|
||||
continue
|
||||
return applied
|
||||
|
||||
|
||||
class _TactileInteractionFilter(QObject):
|
||||
"""全局轻量事件过滤器:自动补齐手型光标与子视窗 DWM 高定视觉融合。"""
|
||||
|
||||
_INTERACTIVE_TYPES = (QAbstractButton, QTabBar, QComboBox)
|
||||
_WATCHED_EVENTS = frozenset({QEvent.Type.Polish, QEvent.Type.EnabledChange, QEvent.Type.Show})
|
||||
|
||||
def eventFilter(self, watched: QObject, event: QEvent) -> bool: # noqa: N802
|
||||
try:
|
||||
event_type = event.type()
|
||||
except RuntimeError:
|
||||
return False
|
||||
if event_type not in self._WATCHED_EVENTS:
|
||||
return False
|
||||
|
||||
if isinstance(watched, self._INTERACTIVE_TYPES):
|
||||
if event_type in (QEvent.Type.Polish, QEvent.Type.EnabledChange):
|
||||
if watched.isEnabled():
|
||||
if watched.cursor().shape() == Qt.CursorShape.ArrowCursor:
|
||||
watched.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
else:
|
||||
if watched.cursor().shape() == Qt.CursorShape.PointingHandCursor:
|
||||
watched.setCursor(Qt.CursorShape.ArrowCursor)
|
||||
return False
|
||||
|
||||
if (
|
||||
event_type is QEvent.Type.Show
|
||||
and isinstance(watched, QDialog)
|
||||
and not isinstance(watched, (QFileDialog, QMessageBox, QInputDialog))
|
||||
and not watched.testAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
):
|
||||
name = watched.objectName() or ""
|
||||
is_dark = any(tag in name for tag in ("Video", "IssuedPrescriptionAi", "AiConsult"))
|
||||
apply_luxury_dwm_chrome(watched, dark=is_dark)
|
||||
# W8 原语 B:自动为所有标准业务弹窗顶部注入 3px 翡翠-鎏金饰线(避免重复插入)
|
||||
if (
|
||||
not (watched.windowFlags() & Qt.WindowType.FramelessWindowHint)
|
||||
and not getattr(watched, "_doctor_accent_bar_injected", False)
|
||||
):
|
||||
from PySide6.QtWidgets import QVBoxLayout
|
||||
|
||||
from .window_primitives import ClinicalAccentBar
|
||||
|
||||
layout = watched.layout()
|
||||
if isinstance(layout, QVBoxLayout) and not watched.findChildren(ClinicalAccentBar):
|
||||
watched._doctor_accent_bar_injected = True # type: ignore[attr-defined]
|
||||
layout.insertWidget(0, ClinicalAccentBar(watched))
|
||||
return False
|
||||
|
||||
|
||||
def install_tactile_interactions(app: QApplication) -> None:
|
||||
"""幂等安装全局精工交互过滤器。"""
|
||||
|
||||
if getattr(app, "_doctor_tactile_interaction_filter", None) is not None:
|
||||
return
|
||||
flt = _TactileInteractionFilter(app)
|
||||
app.installEventFilter(flt)
|
||||
app._doctor_tactile_interaction_filter = flt
|
||||
|
||||
|
||||
__all__ = ["apply_luxury_dwm_chrome", "install_tactile_interactions"]
|
||||
@@ -5,15 +5,18 @@ from __future__ import annotations
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
|
||||
from PySide6.QtCore import QEvent, QPoint, QPointF, QRectF, QSettings, Qt, QTimer, Signal
|
||||
from PySide6.QtCore import QEvent, QPoint, QPointF, QRectF, QSettings, QSize, Qt, QTimer, Signal
|
||||
from PySide6.QtGui import (
|
||||
QColor,
|
||||
QFont,
|
||||
QIcon,
|
||||
QLinearGradient,
|
||||
QMouseEvent,
|
||||
QPainter,
|
||||
QPainterPath,
|
||||
QPen,
|
||||
QPixmap,
|
||||
QRadialGradient,
|
||||
QResizeEvent,
|
||||
)
|
||||
from PySide6.QtWidgets import (
|
||||
@@ -123,7 +126,7 @@ def _round_pen(color: QColor | str, width: float) -> QPen:
|
||||
|
||||
|
||||
class _BrandPanel(QWidget):
|
||||
"""A flat, readable introduction to the clinician's daily workflow."""
|
||||
"""御瓷智医 · 深曜翡翠科技医疗奢雅品牌沉浸区."""
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
@@ -138,60 +141,237 @@ class _BrandPanel(QWidget):
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
bounds = QRectF(self.rect()).adjusted(1, 1, -1, -1)
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
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), "甄养堂 · 医生工作站")
|
||||
|
||||
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), "让沟通更专注。")
|
||||
clip = QPainterPath()
|
||||
clip.addRoundedRect(bounds, 20, 20)
|
||||
painter.setClipPath(clip)
|
||||
|
||||
# 深曜翡翠渐变底 + 右上角精密青玉科技辉光
|
||||
bg = QLinearGradient(bounds.topLeft(), bounds.bottomRight())
|
||||
bg.setColorAt(0.0, QColor("#0E3F3C"))
|
||||
bg.setColorAt(0.52, QColor("#092726"))
|
||||
bg.setColorAt(1.0, QColor("#061717"))
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(bg)
|
||||
painter.drawRect(bounds)
|
||||
|
||||
glow = QRadialGradient(
|
||||
QPointF(bounds.right() - 70.0, bounds.top() + 90.0),
|
||||
max(280.0, bounds.width() * 0.55),
|
||||
)
|
||||
glow.setColorAt(0.0, QColor(24, 184, 173, 74))
|
||||
glow.setColorAt(0.55, QColor(14, 120, 114, 24))
|
||||
glow.setColorAt(1.0, QColor(14, 120, 114, 0))
|
||||
painter.setBrush(glow)
|
||||
painter.drawRect(bounds)
|
||||
|
||||
# 精密医疗科技同心轨道 + 微光心电脉搏线
|
||||
ring_center = QPointF(bounds.right() - 48.0, bounds.top() + 86.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(QPen(QColor(223, 199, 147, 36), 1.0))
|
||||
painter.drawEllipse(ring_center, 155.0, 155.0)
|
||||
dash_pen = QPen(QColor(110, 224, 214, 34), 1.0, Qt.PenStyle.DashLine)
|
||||
painter.setPen(dash_pen)
|
||||
painter.drawEllipse(ring_center, 230.0, 230.0)
|
||||
|
||||
pulse_y = bounds.bottom() - 96.0
|
||||
pulse = QPainterPath(QPointF(bounds.left(), pulse_y))
|
||||
pulse.lineTo(QPointF(bounds.left() + bounds.width() * 0.36, pulse_y))
|
||||
pulse.lineTo(QPointF(bounds.left() + bounds.width() * 0.43, pulse_y - 38.0))
|
||||
pulse.lineTo(QPointF(bounds.left() + bounds.width() * 0.50, pulse_y + 30.0))
|
||||
pulse.lineTo(QPointF(bounds.left() + bounds.width() * 0.56, pulse_y - 16.0))
|
||||
pulse.lineTo(QPointF(bounds.left() + bounds.width() * 0.61, pulse_y))
|
||||
pulse.lineTo(QPointF(bounds.right(), pulse_y))
|
||||
painter.setPen(QPen(QColor(110, 224, 214, 40), 1.4))
|
||||
painter.drawPath(pulse)
|
||||
|
||||
# 顶部 1px 香槟鎏金奢雅边框
|
||||
painter.setPen(QPen(QColor(223, 199, 147, 72), 1.0))
|
||||
painter.drawRoundedRect(bounds, 20, 20)
|
||||
|
||||
left = 40.0
|
||||
width = max(240.0, self.width() - 80.0)
|
||||
|
||||
# 甄养堂高定翡翠鎏金徽标 + 精致反白品牌锁标
|
||||
emblem = QRectF(left, 36.0, 44.0, 44.0)
|
||||
em_grad = QLinearGradient(emblem.topLeft(), emblem.bottomRight())
|
||||
em_grad.setColorAt(0.0, QColor("#18B0A5"))
|
||||
em_grad.setColorAt(1.0, QColor("#09615C"))
|
||||
painter.setBrush(em_grad)
|
||||
painter.setPen(QPen(QColor(PALETTE["gold_light"]), 1.2))
|
||||
painter.drawRoundedRect(emblem, 12.0, 12.0)
|
||||
|
||||
painter.save()
|
||||
painter.translate(emblem.topLeft())
|
||||
painter.scale(44.0 / 38.0, 44.0 / 38.0)
|
||||
drop = QPainterPath(QPointF(19.0, 7.6))
|
||||
drop.cubicTo(QPointF(14.8, 13.2), QPointF(11.2, 17.8), QPointF(11.2, 22.4))
|
||||
drop.cubicTo(QPointF(11.2, 26.8), QPointF(14.7, 30.4), QPointF(19.0, 30.4))
|
||||
drop.cubicTo(QPointF(23.3, 30.4), QPointF(26.8, 26.8), QPointF(26.8, 22.4))
|
||||
drop.cubicTo(QPointF(26.8, 17.8), QPointF(23.2, 13.2), QPointF(19.0, 7.6))
|
||||
drop.closeSubpath()
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor("#FFFFFF"))
|
||||
painter.drawPath(drop)
|
||||
mini_pulse = QPainterPath(QPointF(13.5, 22.4))
|
||||
mini_pulse.lineTo(QPointF(16.2, 22.4))
|
||||
mini_pulse.lineTo(QPointF(17.8, 18.8))
|
||||
mini_pulse.lineTo(QPointF(20.0, 25.6))
|
||||
mini_pulse.lineTo(QPointF(21.6, 22.4))
|
||||
mini_pulse.lineTo(QPointF(24.5, 22.4))
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(_round_pen("#0B6E68", 2.0))
|
||||
painter.drawPath(mini_pulse)
|
||||
painter.restore()
|
||||
|
||||
painter.setFont(_font(20, QFont.Weight.DemiBold))
|
||||
painter.setPen(QColor("#FFFFFF"))
|
||||
painter.drawText(QPointF(left + 58.0, 56.0), "甄养堂")
|
||||
painter.setFont(_font(11, QFont.Weight.Medium))
|
||||
painter.setPen(QColor(PALETTE["gold_light"]))
|
||||
painter.drawText(QPointF(left + 58.0, 74.0), "DIABETES TELEHEALTH · 糖尿病专科工作站")
|
||||
|
||||
heading_y = max(162.0, min(214.0, self.height() * 0.27))
|
||||
painter.setPen(QColor("#7CE4DB"))
|
||||
painter.setFont(_font(12, QFont.Weight.Medium))
|
||||
painter.drawText(QPointF(left, heading_y - 34), "PRECISION CLINICAL WORKSTATION")
|
||||
painter.setPen(QColor("#FFFFFF"))
|
||||
painter.setFont(_font(31, 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), "从接诊、病历到处方,在一个工作台完成。")
|
||||
painter.setPen(QColor("#A4C9C5"))
|
||||
painter.drawText(QPointF(left, heading_y + 82), "融合智能辨证、纵向血糖洞察与合规双签的一体化医疗桌面。")
|
||||
|
||||
row_y = heading_y + 122
|
||||
for index, (title, detail) in enumerate((
|
||||
("今日接诊", "快速找到待接诊患者与预约安排"),
|
||||
("诊疗记录", "病历、随访与面诊资料集中查看"),
|
||||
("处方协作", "开方与审核流程清晰衔接"),
|
||||
("今日接诊 · 三栏直览", "待诊队列、四诊病历与视频房间同屏高效衔接"),
|
||||
("AI 临床辨证辅助", "多模态聚合历次复诊与血糖波动,梳理随访要点"),
|
||||
("处方协作 · CA 合规双签", "经验方一键复用,开方与药师审核签署全流程留痕"),
|
||||
), start=1):
|
||||
row = QRectF(left, row_y, width, 66)
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor(PALETTE["surface"]))
|
||||
painter.setPen(QPen(QColor(223, 199, 147, 52), 1.0))
|
||||
painter.setBrush(QColor(255, 255, 255, 16))
|
||||
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}")
|
||||
badge_rect = QRectF(left + 14, row_y + 17, 32, 32)
|
||||
painter.setPen(QPen(QColor(223, 199, 147, 96), 1.0))
|
||||
painter.setBrush(QColor(223, 199, 147, 24))
|
||||
painter.drawRoundedRect(badge_rect, 8, 8)
|
||||
painter.setFont(_font(12, QFont.Weight.DemiBold))
|
||||
painter.setPen(QColor(PALETTE["gold_light"]))
|
||||
painter.drawText(badge_rect, 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.setPen(QColor("#F4FAF9"))
|
||||
painter.drawText(QPointF(left + 60, row_y + 28), title)
|
||||
painter.setFont(_font(12))
|
||||
painter.setPen(QColor(PALETTE["muted"]))
|
||||
painter.drawText(QPointF(left + 58, row_y + 47), detail)
|
||||
painter.setPen(QColor("#9AC0BC"))
|
||||
painter.drawText(QPointF(left + 60, row_y + 49), detail)
|
||||
row_y += 78
|
||||
if self.height() > row_y + 50:
|
||||
if self.height() > row_y + 48:
|
||||
painter.setFont(_font(12))
|
||||
painter.setPen(QColor(PALETTE["muted"]))
|
||||
painter.drawText(QPointF(left, self.height() - 28), "仅供获授权的医疗人员使用")
|
||||
painter.setPen(QColor("#749E99"))
|
||||
painter.drawText(QPointF(left, self.height() - 28), "仅供获授权的执业医疗人员使用 · 端到端加密传输")
|
||||
painter.end()
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802 - Qt API
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
handle = self.window().windowHandle()
|
||||
if handle is not None and handle.startSystemMove():
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
|
||||
class _LoginWindowControlButton(QToolButton):
|
||||
"""登录悬浮窗右上角原生桌面最小化/关闭按钮。"""
|
||||
|
||||
def __init__(self, kind: str, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self._kind = kind
|
||||
self.setObjectName("LoginWindowControl")
|
||||
self.setProperty("windowControl", kind)
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.setAutoRaise(True)
|
||||
self.setFixedSize(34, 34)
|
||||
self.setIcon(icons.icon(kind, "muted", 16))
|
||||
self.setIconSize(QSize(16, 16))
|
||||
|
||||
def enterEvent(self, event: Any) -> None: # noqa: N802 - Qt API
|
||||
if self._kind == "close":
|
||||
self.setIcon(icons.icon("close", "inverse", 16))
|
||||
else:
|
||||
self.setIcon(icons.icon(self._kind, "heading", 16))
|
||||
super().enterEvent(event)
|
||||
|
||||
def leaveEvent(self, event: Any) -> None: # noqa: N802 - Qt API
|
||||
self.setIcon(icons.icon(self._kind, "muted", 16))
|
||||
super().leaveEvent(event)
|
||||
|
||||
|
||||
class _LoginWindowShell(QWidget):
|
||||
"""无边框奢雅青瓷圆角悬浮视窗,支持原生拖动与边缘缩放。"""
|
||||
|
||||
_RESIZE_MARGIN = 8
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setMouseTracking(True)
|
||||
|
||||
def paintEvent(self, event: Any) -> None: # noqa: N802 - Qt API
|
||||
del event
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
bounds = QRectF(self.rect()).adjusted(0.5, 0.5, -0.5, -0.5)
|
||||
painter.setBrush(QColor(PALETTE["canvas"]))
|
||||
painter.setPen(QPen(QColor("#B5CAC6"), 1.0))
|
||||
painter.drawRoundedRect(bounds, 18.0, 18.0)
|
||||
painter.end()
|
||||
|
||||
def _resize_edges(self, position: QPointF) -> Qt.Edge:
|
||||
edges = Qt.Edge(0)
|
||||
if position.x() <= self._RESIZE_MARGIN:
|
||||
edges |= Qt.Edge.LeftEdge
|
||||
elif position.x() >= self.width() - self._RESIZE_MARGIN:
|
||||
edges |= Qt.Edge.RightEdge
|
||||
if position.y() <= self._RESIZE_MARGIN:
|
||||
edges |= Qt.Edge.TopEdge
|
||||
elif position.y() >= self.height() - self._RESIZE_MARGIN:
|
||||
edges |= Qt.Edge.BottomEdge
|
||||
return edges
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802 - Qt API
|
||||
edges = self._resize_edges(event.position())
|
||||
if edges in (
|
||||
Qt.Edge.LeftEdge | Qt.Edge.TopEdge,
|
||||
Qt.Edge.RightEdge | Qt.Edge.BottomEdge,
|
||||
):
|
||||
self.setCursor(Qt.CursorShape.SizeFDiagCursor)
|
||||
elif edges in (
|
||||
Qt.Edge.LeftEdge | Qt.Edge.BottomEdge,
|
||||
Qt.Edge.RightEdge | Qt.Edge.TopEdge,
|
||||
):
|
||||
self.setCursor(Qt.CursorShape.SizeBDiagCursor)
|
||||
elif edges in (Qt.Edge.LeftEdge, Qt.Edge.RightEdge):
|
||||
self.setCursor(Qt.CursorShape.SizeHorCursor)
|
||||
elif edges in (Qt.Edge.TopEdge, Qt.Edge.BottomEdge):
|
||||
self.setCursor(Qt.CursorShape.SizeVerCursor)
|
||||
else:
|
||||
self.unsetCursor()
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802 - Qt API
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
handle = self.window().windowHandle()
|
||||
if handle is not None:
|
||||
edges = self._resize_edges(event.position())
|
||||
if edges and handle.startSystemResize(edges):
|
||||
event.accept()
|
||||
return
|
||||
if handle.startSystemMove():
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
|
||||
class _PasswordField(QFrame):
|
||||
"""Keep the grouped password control visibly focused for keyboard users."""
|
||||
@@ -318,25 +498,48 @@ class LoginWindow(QMainWindow):
|
||||
|
||||
self.setWindowTitle("甄养堂 · 医生工作站 - 甄养堂医生工作站")
|
||||
self.setWindowIcon(self._window_icon())
|
||||
self.setWindowFlag(Qt.WindowType.FramelessWindowHint, True)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True)
|
||||
self.setStyleSheet("QMainWindow { background: transparent; }")
|
||||
self.setMinimumSize(860, 590)
|
||||
self.resize(1280, 800)
|
||||
|
||||
canvas = QWidget()
|
||||
canvas = _LoginWindowShell(self)
|
||||
canvas.setObjectName("LoginCanvas")
|
||||
canvas.setStyleSheet(
|
||||
"""
|
||||
QWidget#LoginCanvas {
|
||||
color: #1A1C1F;
|
||||
background-color: #F4F6FA;
|
||||
background-color: transparent;
|
||||
font-size: 16px;
|
||||
}
|
||||
QToolButton#LoginWindowControl {
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
}
|
||||
QToolButton#LoginWindowControl:hover {
|
||||
background-color: #E2ECEA;
|
||||
border-color: #C7DCD8;
|
||||
}
|
||||
QToolButton#LoginWindowControl:pressed {
|
||||
background-color: #D6E4E1;
|
||||
}
|
||||
QToolButton#LoginWindowControl[windowControl="close"]:hover {
|
||||
background-color: #D63F4F;
|
||||
border-color: #D63F4F;
|
||||
}
|
||||
QToolButton#LoginWindowControl[windowControl="close"]:pressed {
|
||||
background-color: #B92E3D;
|
||||
border-color: #B92E3D;
|
||||
}
|
||||
QWidget#LoginBrandPanel {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
}
|
||||
QFrame#LoginCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #EDEDEE;
|
||||
border: 1px solid #D3E1DF;
|
||||
border-radius: 20px;
|
||||
}
|
||||
QFrame#LoginCard QFrame#SubtleCard {
|
||||
@@ -407,22 +610,25 @@ class LoginWindow(QMainWindow):
|
||||
padding: 0;
|
||||
}
|
||||
QFrame#LoginCard QPushButton[variant="primary"] {
|
||||
min-height: 58px;
|
||||
max-height: 58px;
|
||||
min-height: 54px;
|
||||
max-height: 54px;
|
||||
color: #FFFFFF;
|
||||
background-color: #4F63D9;
|
||||
border: 0;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #14968D, stop:1 $ds_accent);
|
||||
border: 1px solid $ds_accent;
|
||||
border-radius: 12px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QFrame#LoginCard QPushButton#ServerSettingsToggle {
|
||||
min-height: 56px;
|
||||
max-height: 56px;
|
||||
min-height: 52px;
|
||||
max-height: 52px;
|
||||
padding: 0;
|
||||
}
|
||||
QFrame#LoginCard QPushButton[variant="primary"]:hover {
|
||||
background-color: #4156C4;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #0F8078, stop:1 $ds_accent_hover);
|
||||
}
|
||||
QFrame#LoginCard QPushButton[variant="primary"]:pressed {
|
||||
background-color: $ds_accent_pressed;
|
||||
}
|
||||
QFrame#LoginCard QPushButton[variant="secondary"] {
|
||||
color: #1A1C1F;
|
||||
@@ -449,6 +655,26 @@ class LoginWindow(QMainWindow):
|
||||
self.brand_panel = self._build_brand_panel()
|
||||
self.login_root.addWidget(self.brand_panel, 60)
|
||||
self.login_root.addWidget(self._build_login_area(), 40)
|
||||
|
||||
# 悬浮于无边框登录视窗右上角的原生最小化/关闭控件,不占用表单区纵向高度
|
||||
self.window_controls_host = QWidget(canvas)
|
||||
self.window_controls_host.setObjectName("LoginWindowControls")
|
||||
controls_layout = QHBoxLayout(self.window_controls_host)
|
||||
controls_layout.setContentsMargins(0, 0, 0, 0)
|
||||
controls_layout.setSpacing(6)
|
||||
self.minimize_button = _LoginWindowControlButton("minimize", self.window_controls_host)
|
||||
self.minimize_button.setToolTip("最小化")
|
||||
self.minimize_button.setAccessibleName("最小化登录窗口")
|
||||
self.minimize_button.clicked.connect(self.showMinimized)
|
||||
controls_layout.addWidget(self.minimize_button)
|
||||
self.close_button = _LoginWindowControlButton("close", self.window_controls_host)
|
||||
self.close_button.setToolTip("关闭")
|
||||
self.close_button.setAccessibleName("关闭登录窗口")
|
||||
self.close_button.clicked.connect(self.close)
|
||||
controls_layout.addWidget(self.close_button)
|
||||
self.window_controls_host.adjustSize()
|
||||
self.window_controls_host.raise_()
|
||||
|
||||
self._restore_settings()
|
||||
for widget in (canvas, *canvas.findChildren(QWidget)):
|
||||
if widget.styleSheet():
|
||||
@@ -478,6 +704,12 @@ class LoginWindow(QMainWindow):
|
||||
0, 12 if compact_height else min(104, max(24, (event.size().height() - 694) // 2)), 0, 12
|
||||
)
|
||||
super().resizeEvent(event)
|
||||
if hasattr(self, "window_controls_host"):
|
||||
self.window_controls_host.move(
|
||||
max(12, self.width() - self.window_controls_host.width() - 16),
|
||||
14,
|
||||
)
|
||||
self.window_controls_host.raise_()
|
||||
|
||||
def _build_brand_panel(self) -> QWidget:
|
||||
panel = _BrandPanel()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -48,10 +48,10 @@ from ...core.appointment_modes import (
|
||||
appointment_type_description,
|
||||
appointment_type_value,
|
||||
)
|
||||
from ...core.esign import esign_status
|
||||
from ...core.esign import esign_status
|
||||
from .. import icons
|
||||
from ..appointment_drawer import AppointmentDrawer
|
||||
from ..design_system import PALETTE, clinical_stylesheet
|
||||
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
|
||||
@@ -68,7 +68,9 @@ from ..patient_orders_style import patient_orders_stylesheet
|
||||
from ..patient_progress_style import patient_progress_stylesheet
|
||||
from ..patients_style import patient_list_stylesheet, patients_chrome_stylesheet
|
||||
from ..reception_style import body_family, heading_family
|
||||
from ..state import PatientContextStore
|
||||
from ..theme import mark_business_dialog
|
||||
from ..visuals.context_bridge_bar import SpatialContextBridgeBar
|
||||
from ..widgets import (
|
||||
EmptyState,
|
||||
MessageBanner,
|
||||
@@ -119,97 +121,97 @@ FULFILLMENT_TEXT = {
|
||||
}
|
||||
|
||||
_SEMANTIC_COLORS = {
|
||||
"primary": PALETTE["accent"],
|
||||
"success": PALETTE["success"],
|
||||
"warning": PALETTE["warning"],
|
||||
"danger": PALETTE["danger"],
|
||||
"info": PALETTE["accent"],
|
||||
"muted": PALETTE["muted"],
|
||||
"primary": PALETTE["accent"],
|
||||
"success": PALETTE["success"],
|
||||
"warning": PALETTE["warning"],
|
||||
"danger": PALETTE["danger"],
|
||||
"info": PALETTE["accent"],
|
||||
"muted": PALETTE["muted"],
|
||||
}
|
||||
|
||||
PATIENTS_LIGHT_QSS = clinical_stylesheet("""
|
||||
PATIENTS_LIGHT_QSS = clinical_stylesheet("""
|
||||
#PatientsPage QWidget#PageHeader QLabel[role="pageTitle"] {
|
||||
color: $ds_heading;
|
||||
color: $ds_heading;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
#PatientsPage QWidget#PageHeader QLabel[role="muted"] {
|
||||
color: $ds_muted;
|
||||
color: $ds_muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
#PatientsPage QPushButton[patientSearchAction="true"] {
|
||||
min-height: 32px;
|
||||
max-height: 32px;
|
||||
color: $ds_surface;
|
||||
background-color: $ds_accent;
|
||||
border: 1px solid $ds_accent;
|
||||
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: $ds_accent_hover;
|
||||
border-color: $ds_accent_hover;
|
||||
background-color: $ds_accent_hover;
|
||||
border-color: $ds_accent_hover;
|
||||
}
|
||||
#PatientsPage QFrame[patientListFilter="true"] {
|
||||
min-height: 88px;
|
||||
max-height: 88px;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
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: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
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: $ds_disabled; background-color: $ds_surface_alt;
|
||||
color: $ds_disabled; background-color: $ds_surface_alt;
|
||||
}
|
||||
#PatientsPage QPushButton[patientStatusChip="true"] {
|
||||
min-height: 32px;
|
||||
max-height: 32px;
|
||||
padding: 0 10px;
|
||||
color: $ds_muted;
|
||||
background-color: $ds_surface_alt;
|
||||
color: $ds_muted;
|
||||
background-color: $ds_surface_alt;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 5px;
|
||||
}
|
||||
#PatientsPage QPushButton[patientStatusChip="true"]:hover {
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
}
|
||||
#PatientsPage QPushButton[patientStatusChip="true"]:checked {
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
border: 1px solid $ds_focus;
|
||||
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: $ds_heading;
|
||||
color: $ds_heading;
|
||||
background-color: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 7px;
|
||||
}
|
||||
#PatientsPage QPushButton[patientQuickDate="true"]:hover {
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
}
|
||||
#PatientsPage QPushButton[patientQuickDate="true"]:checked {
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
border-color: $ds_focus;
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
border-color: $ds_focus;
|
||||
}
|
||||
#PatientsPage QTabWidget#PatientWorkspaceTabs::pane {
|
||||
border: 0;
|
||||
border-top: 1px solid $ds_line;
|
||||
border-top: 1px solid $ds_line;
|
||||
background-color: transparent;
|
||||
}
|
||||
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab {
|
||||
@@ -217,124 +219,124 @@ PATIENTS_LIGHT_QSS = clinical_stylesheet("""
|
||||
min-height: 34px;
|
||||
padding: 0 6px;
|
||||
margin-right: 8px;
|
||||
color: $ds_muted;
|
||||
color: $ds_muted;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
font-weight: 400;
|
||||
}
|
||||
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab:selected {
|
||||
color: $ds_accent;
|
||||
border-bottom-color: $ds_accent;
|
||||
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: $ds_heading;
|
||||
background-color: $ds_surface_alt;
|
||||
border: 1px solid $ds_line;
|
||||
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: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
border-color: $ds_focus;
|
||||
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: $ds_accent;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
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: $ds_accent_soft;
|
||||
border-color: $ds_focus;
|
||||
background-color: $ds_accent_soft;
|
||||
border-color: $ds_focus;
|
||||
}
|
||||
#PatientsPage QPushButton[rowAction="true"][variant="danger"] {
|
||||
color: $ds_danger;
|
||||
background-color: $ds_danger_soft;
|
||||
border-color: $ds_danger_soft;
|
||||
color: $ds_danger;
|
||||
background-color: $ds_danger_soft;
|
||||
border-color: $ds_danger_soft;
|
||||
}
|
||||
#PatientsPage QTableWidget#PatientTable QHeaderView::section {
|
||||
min-height: 34px;
|
||||
background-color: $ds_surface_alt; font-size: 13px;
|
||||
background-color: $ds_surface_alt; font-size: 13px;
|
||||
}
|
||||
#PatientsPage QTableWidget#PatientTable::item { padding: 5px 7px; }
|
||||
#PatientsPage QTableWidget#PatientTable {
|
||||
gridline-color: $ds_line;
|
||||
selection-background-color: $ds_accent_soft;
|
||||
selection-color: $ds_heading; 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: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: 2px;
|
||||
}
|
||||
#PatientsPage QCheckBox[patientSelector="true"]::indicator:checked {
|
||||
background-color: $ds_accent;
|
||||
border-color: $ds_accent;
|
||||
background-color: $ds_accent;
|
||||
border-color: $ds_accent;
|
||||
}
|
||||
#PatientsPage QPushButton[variant="ghost"]:checked {
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
border: 1px solid $ds_accent;
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
border: 1px solid $ds_accent;
|
||||
}
|
||||
#PatientsPage QPushButton[variant="ghost"]:checked:hover { background-color: $ds_accent_soft; }
|
||||
#PatientsPage QPushButton[variant="ghost"]:checked:hover { background-color: $ds_accent_soft; }
|
||||
#PatientsPage QPushButton[statusKind="info"]:checked {
|
||||
color: $ds_accent;
|
||||
border-color: $ds_accent;
|
||||
color: $ds_accent;
|
||||
border-color: $ds_accent;
|
||||
}
|
||||
#PatientsPage QPushButton[statusKind="warning"]:checked {
|
||||
color: $ds_warning;
|
||||
border-color: $ds_warning;
|
||||
color: $ds_warning;
|
||||
border-color: $ds_warning;
|
||||
}
|
||||
#PatientsPage QPushButton[statusKind="success"]:checked {
|
||||
color: $ds_success;
|
||||
border-color: $ds_success;
|
||||
color: $ds_success;
|
||||
border-color: $ds_success;
|
||||
}
|
||||
#PatientsPage QPushButton[statusKind="danger"]:checked {
|
||||
color: $ds_danger;
|
||||
border-color: $ds_danger;
|
||||
color: $ds_danger;
|
||||
border-color: $ds_danger;
|
||||
}
|
||||
#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 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: $ds_muted;
|
||||
color: $ds_muted;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
font-weight: 400;
|
||||
}
|
||||
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab:hover {
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
color: $ds_accent;
|
||||
background-color: $ds_accent_soft;
|
||||
}
|
||||
#PatientsPage QTabWidget#PatientWorkspaceTabs QTabBar::tab:selected {
|
||||
color: $ds_accent;
|
||||
color: $ds_accent;
|
||||
background-color: transparent;
|
||||
border-bottom-color: $ds_accent;
|
||||
border-bottom-color: $ds_accent;
|
||||
font-weight: 500;
|
||||
}
|
||||
""")
|
||||
""")
|
||||
|
||||
|
||||
def _style_table_cell(table: SortableTable, row: int, column: int, kind: str) -> None:
|
||||
@@ -513,8 +515,8 @@ class _LegacyAppointmentDialog(QDialog):
|
||||
form = QFormLayout()
|
||||
form.setVerticalSpacing(10)
|
||||
self.appointment_type = QComboBox()
|
||||
for label, value in APPOINTMENT_MODES:
|
||||
self.appointment_type.addItem(label, value)
|
||||
for label, value in APPOINTMENT_MODES:
|
||||
self.appointment_type.addItem(label, value)
|
||||
form.addRow("预约类型 *", self.appointment_type)
|
||||
self.channel_source = QComboBox()
|
||||
self.channel_source.addItem("正在加载渠道…", "")
|
||||
@@ -1291,7 +1293,7 @@ class _PatientDateEdit(QDateEdit):
|
||||
def paintEvent(self, event: Any) -> None:
|
||||
super().paintEvent(event)
|
||||
painter = QPainter(self)
|
||||
glyph = icons.pixmap("calendar", PALETTE["muted"] if self.isEnabled() else PALETTE["disabled"], 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()
|
||||
|
||||
@@ -1309,18 +1311,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", PALETTE["accent"], 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(PALETTE["muted"]))
|
||||
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(PALETTE["text"]))
|
||||
painter.setPen(QColor(PALETTE["text"]))
|
||||
painter.drawText(self.rect().adjusted(left + 46, 31, -12, -9),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, count)
|
||||
painter.end()
|
||||
@@ -1333,11 +1335,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(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
|
||||
painter.setPen(QColor(PALETTE["line"]))
|
||||
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(PALETTE["accent"]))
|
||||
painter.fillRect(option.rect.adjusted(0, 0, -option.rect.width() + 3, 0), QColor(PALETTE["accent"]))
|
||||
if index.column() in (0, 9):
|
||||
painter.restore()
|
||||
return
|
||||
@@ -1346,9 +1348,9 @@ class _PatientInfoDelegate(QStyledItemDelegate):
|
||||
font = QFont(body_family())
|
||||
font.setPixelSize(14)
|
||||
painter.setFont(font)
|
||||
painter.setPen(QColor(PALETTE["text"]))
|
||||
painter.setPen(QColor(PALETTE["text"]))
|
||||
|
||||
def draw(text: str, target: Any, color: str = PALETTE["text"], 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)
|
||||
@@ -1368,33 +1370,33 @@ class _PatientInfoDelegate(QStyledItemDelegate):
|
||||
doctor = display_text(first_value(row, "appointment_doctor_name"), "")
|
||||
status, _kind = _patient_status(row)
|
||||
if not doctor:
|
||||
draw(status, rect, PALETTE["muted"])
|
||||
draw(status, rect, PALETTE["muted"])
|
||||
else:
|
||||
draw(doctor, top)
|
||||
font.setPixelSize(13)
|
||||
painter.setFont(font)
|
||||
color, fill = (PALETTE["warning"], PALETTE["warning_soft"]) if status == "已过号" else (PALETTE["accent"], PALETTE["accent_soft"])
|
||||
color, fill = (PALETTE["warning"], PALETTE["warning_soft"]) if status == "已过号" else (PALETTE["accent"], PALETTE["accent_soft"])
|
||||
if status == "已取消":
|
||||
color, fill = PALETTE["muted"], PALETTE["canvas"]
|
||||
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(PALETTE["warning_soft"] if status == "已过号" else PALETTE["line_strong"]))
|
||||
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)
|
||||
elif index.column() == 4:
|
||||
value = display_text(first_value(row, "appointment_time_text"))
|
||||
date_text, separator, time_text = value.partition(" ")
|
||||
if separator and time_text:
|
||||
draw(date_text, top)
|
||||
has_appointment = _as_int(first_value(row, "appointment_id", default=0)) > 0
|
||||
mode = appointment_type_description(appointment_type_value(row)) if has_appointment else ""
|
||||
draw(f"{time_text} · {mode}" if mode else time_text, bottom)
|
||||
elif index.column() == 4:
|
||||
value = display_text(first_value(row, "appointment_time_text"))
|
||||
date_text, separator, time_text = value.partition(" ")
|
||||
if separator and time_text:
|
||||
draw(date_text, top)
|
||||
has_appointment = _as_int(first_value(row, "appointment_id", default=0)) > 0
|
||||
mode = appointment_type_description(appointment_type_value(row)) if has_appointment else ""
|
||||
draw(f"{time_text} · {mode}" if mode else time_text, bottom)
|
||||
else:
|
||||
draw(value, rect)
|
||||
else:
|
||||
text = str(index.data(Qt.ItemDataRole.DisplayRole) or "")
|
||||
draw(text, rect, PALETTE["warning"] if index.column() == 6 and text == "待确认" else PALETTE["text"], index.column() == 5)
|
||||
draw(text, rect, PALETTE["warning"] if index.column() == 6 and text == "待确认" else PALETTE["text"], index.column() == 5)
|
||||
painter.restore()
|
||||
|
||||
|
||||
@@ -1466,15 +1468,15 @@ class PatientListWorkspace(QWidget):
|
||||
target.addWidget(self.custom_date_button)
|
||||
self.filter_card.setFixedHeight(194 if narrow else 148)
|
||||
self._narrow_dates = narrow
|
||||
# Keep readable data and complete actions; narrow windows scroll horizontally.
|
||||
widths = (46, 154, 100, 172, 136, 72, 108, 122, 138, 194)
|
||||
# 优化列宽配比(总计 1106px),确保 1440px 视窗下右侧「操作」及「更多」按钮不被裁切
|
||||
widths = (40, 140, 86, 156, 126, 62, 92, 104, 124, 176)
|
||||
for column, width in enumerate(widths):
|
||||
if column != 1:
|
||||
self.table.setColumnWidth(column, width)
|
||||
header = self.table.horizontalHeader()
|
||||
header.setSectionResizeMode(1, QHeaderView.ResizeMode.Interactive if self.width() < 1230 else QHeaderView.ResizeMode.Stretch)
|
||||
if self.width() < 1230:
|
||||
self.table.setColumnWidth(1, 154)
|
||||
header.setSectionResizeMode(1, QHeaderView.ResizeMode.Interactive if self.width() < 1180 else QHeaderView.ResizeMode.Stretch)
|
||||
if self.width() < 1180:
|
||||
self.table.setColumnWidth(1, 140)
|
||||
|
||||
def _build_filters(self) -> QWidget:
|
||||
card = QFrame()
|
||||
@@ -1502,7 +1504,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", PALETTE["muted"], 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("患者状态:")
|
||||
@@ -1855,7 +1857,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", PALETTE["muted"], 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)
|
||||
@@ -2004,15 +2006,15 @@ class PatientListWorkspace(QWidget):
|
||||
self.custom_date_button.setChecked(True)
|
||||
self.search()
|
||||
|
||||
def reset_filters(self, *, keyword: str = "", refresh: bool = True) -> None:
|
||||
self.keyword_edit.setText(keyword.strip())
|
||||
def reset_filters(self, *, keyword: str = "", refresh: bool = True) -> None:
|
||||
self.keyword_edit.setText(keyword.strip())
|
||||
self.status_combo.setCurrentIndex(0)
|
||||
for key, button in self.status_buttons.items():
|
||||
button.setChecked(key == "")
|
||||
self.set_date_mode("all", refresh=False)
|
||||
self._page = 1
|
||||
if refresh:
|
||||
self.refresh()
|
||||
self._page = 1
|
||||
if refresh:
|
||||
self.refresh()
|
||||
|
||||
def search(self) -> None:
|
||||
if self._date_mode != "all" and self.start_date.date() > self.end_date.date():
|
||||
@@ -2090,7 +2092,7 @@ class _OrderComboBox(QComboBox):
|
||||
def paintEvent(self, event: Any) -> None:
|
||||
super().paintEvent(event)
|
||||
painter = QPainter(self)
|
||||
glyph = icons.pixmap("chevron_down", PALETTE["muted"], 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()
|
||||
|
||||
@@ -2099,7 +2101,7 @@ class _OrderActionButton(QToolButton):
|
||||
def paintEvent(self, event: Any) -> None:
|
||||
super().paintEvent(event)
|
||||
painter = QPainter(self)
|
||||
glyph = icons.pixmap("chevron_down", PALETTE["muted"] if self.isEnabled() else PALETTE["disabled"], 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()
|
||||
|
||||
@@ -2118,18 +2120,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(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
|
||||
painter.setPen(QColor(PALETTE["line"]))
|
||||
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(PALETTE["accent"]))
|
||||
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 = PALETTE["text"], 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)
|
||||
@@ -2149,7 +2151,7 @@ class _OrderInfoDelegate(QStyledItemDelegate):
|
||||
font.setWeight(QFont.Weight.Normal)
|
||||
font.setPixelSize(13)
|
||||
painter.setFont(font)
|
||||
draw(secondary, bottom, PALETTE["muted"])
|
||||
draw(secondary, bottom, PALETTE["muted"])
|
||||
else:
|
||||
draw(text, rect)
|
||||
elif column in (9, 11):
|
||||
@@ -2158,7 +2160,7 @@ class _OrderInfoDelegate(QStyledItemDelegate):
|
||||
draw(primary, top)
|
||||
font.setPixelSize(13)
|
||||
painter.setFont(font)
|
||||
draw(("(" if column == 9 else "") + secondary, bottom, PALETTE["muted"])
|
||||
draw(("(" if column == 9 else "") + secondary, bottom, PALETTE["muted"])
|
||||
else:
|
||||
draw(text, rect)
|
||||
elif column in (4, 5, 6):
|
||||
@@ -2169,10 +2171,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": (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"]),
|
||||
"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)
|
||||
@@ -2286,7 +2288,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", PALETTE["muted"], 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()
|
||||
@@ -2759,11 +2761,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(PALETTE["accent_soft"] if selected else PALETTE["surface_alt"] if hovered else PALETTE["surface"]))
|
||||
painter.setPen(QColor(PALETTE["line"]))
|
||||
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(PALETTE["accent"]))
|
||||
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)
|
||||
@@ -2774,20 +2776,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 = PALETTE["text"]
|
||||
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": PALETTE["accent"], "next": PALETTE["accent_hover"],
|
||||
"waiting": PALETTE["warning"], "missed": PALETTE["danger"],
|
||||
}.get(status, PALETTE["muted"])
|
||||
"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(PALETTE["focus"]))
|
||||
painter.setPen(QColor(PALETTE["focus"]))
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.drawRect(option.rect.adjusted(1, 1, -2, -2))
|
||||
painter.restore()
|
||||
@@ -2887,7 +2889,7 @@ class PatientProgressWorkspace(QWidget):
|
||||
row = QHBoxLayout(frame)
|
||||
row.setContentsMargins(0, 0, 0, 0)
|
||||
row.setSpacing(0)
|
||||
divider = QFrame(frame)
|
||||
divider = QFrame(frame)
|
||||
divider.setObjectName("ProgressMetricDivider")
|
||||
divider.setFixedSize(1, 60)
|
||||
divider.setVisible(key != "total")
|
||||
@@ -3025,7 +3027,7 @@ class PatientProgressWorkspace(QWidget):
|
||||
"appointment_time",
|
||||
"预约时间",
|
||||
95,
|
||||
lambda value, row: f"{display_text(value)[:5]} · {appointment_type_description(appointment_type_value(row))}",
|
||||
lambda value, row: f"{display_text(value)[:5]} · {appointment_type_description(appointment_type_value(row))}",
|
||||
),
|
||||
TableColumn(
|
||||
"ahead_count",
|
||||
@@ -3194,13 +3196,15 @@ class PatientsPage(QWidget):
|
||||
self._detail_generation = 0
|
||||
self._edit_generation = 0
|
||||
self._assistant_generation = 0
|
||||
self._order_review_generation = 0
|
||||
self._order_review_generation = 0
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(28, 8, 26, 8)
|
||||
root.setSpacing(0)
|
||||
self.header = PageHeader("我的患者", "患者、挂号与诊单按当前角色和部门数据范围展示。")
|
||||
self.header.set_compact(True)
|
||||
self._root_layout = root
|
||||
root.setContentsMargins(28, 8, 26, 8)
|
||||
root.setSpacing(0)
|
||||
self.patient_context_store: PatientContextStore | None = None
|
||||
self.header = PageHeader("我的患者", "患者、挂号与诊单按当前角色和部门数据范围展示。")
|
||||
self.header.set_compact(True)
|
||||
self.scope_badge = StatusBadge("按权限加载", "neutral")
|
||||
self.header.add_action(self.scope_badge)
|
||||
self.refresh_button = QPushButton("刷新")
|
||||
@@ -3211,40 +3215,40 @@ class PatientsPage(QWidget):
|
||||
root.addWidget(self.header)
|
||||
|
||||
self.tabs = QTabWidget()
|
||||
self.tabs.setObjectName("PatientWorkspaceTabs")
|
||||
self.tabs.setMinimumHeight(0)
|
||||
self.patient_workspace = PatientListWorkspace(repository, permissions)
|
||||
self.order_workspace = PatientOrdersWorkspace(repository, permissions)
|
||||
self.tabs.setObjectName("PatientWorkspaceTabs")
|
||||
self.tabs.setMinimumHeight(0)
|
||||
self.patient_workspace = PatientListWorkspace(repository, permissions)
|
||||
self.order_workspace = PatientOrdersWorkspace(repository, permissions)
|
||||
self.progress_workspace = PatientProgressWorkspace(repository)
|
||||
self.tabs.addTab(self.patient_workspace, "患者列表")
|
||||
self.tabs.addTab(self.order_workspace, "订单管理")
|
||||
self.tabs.addTab(self.progress_workspace, "面诊进度")
|
||||
root.addWidget(self.tabs, 1)
|
||||
|
||||
# Each tab keeps its own disclosure state and the existing filter values.
|
||||
# The patient search toolbar stays with its filters at every window width.
|
||||
self.filter_disclosures = (
|
||||
FilterDisclosure(self, [
|
||||
self.patient_workspace.search_toolbar,
|
||||
self.patient_workspace.filter_card,
|
||||
self.patient_workspace.summary_strip,
|
||||
]),
|
||||
FilterDisclosure(self, [
|
||||
self.order_workspace.filter_card,
|
||||
self.order_workspace.summary_strip,
|
||||
]),
|
||||
FilterDisclosure(self, [
|
||||
self.progress_workspace.overview_card,
|
||||
self.progress_workspace.schedule_card,
|
||||
]),
|
||||
)
|
||||
for index, disclosure in enumerate(self.filter_disclosures):
|
||||
disclosure.button.setProperty("workspaceIndex", index)
|
||||
self.header.add_action(disclosure.button)
|
||||
self._progress_splitter_sizes = [302, 222]
|
||||
self.progress_workspace.splitter.splitterMoved.connect(self._remember_progress_sizes)
|
||||
self.filter_disclosures[2].expanded_changed.connect(self._progress_details_changed)
|
||||
self._progress_details_changed(False)
|
||||
self.tabs.addTab(self.progress_workspace, "面诊进度")
|
||||
root.addWidget(self.tabs, 1)
|
||||
|
||||
# Each tab keeps its own disclosure state and the existing filter values.
|
||||
# The patient search toolbar stays with its filters at every window width.
|
||||
self.filter_disclosures = (
|
||||
FilterDisclosure(self, [
|
||||
self.patient_workspace.search_toolbar,
|
||||
self.patient_workspace.filter_card,
|
||||
self.patient_workspace.summary_strip,
|
||||
]),
|
||||
FilterDisclosure(self, [
|
||||
self.order_workspace.filter_card,
|
||||
self.order_workspace.summary_strip,
|
||||
]),
|
||||
FilterDisclosure(self, [
|
||||
self.progress_workspace.overview_card,
|
||||
self.progress_workspace.schedule_card,
|
||||
]),
|
||||
)
|
||||
for index, disclosure in enumerate(self.filter_disclosures):
|
||||
disclosure.button.setProperty("workspaceIndex", index)
|
||||
self.header.add_action(disclosure.button)
|
||||
self._progress_splitter_sizes = [302, 222]
|
||||
self.progress_workspace.splitter.splitterMoved.connect(self._remember_progress_sizes)
|
||||
self.filter_disclosures[2].expanded_changed.connect(self._progress_details_changed)
|
||||
self._progress_details_changed(False)
|
||||
|
||||
self.patient_workspace.diagnosis_requested.connect(self._open_diagnosis)
|
||||
self.patient_workspace.ai_consult_requested.connect(self._open_ai_consult)
|
||||
@@ -3260,54 +3264,82 @@ class PatientsPage(QWidget):
|
||||
self.order_workspace.scope_changed.connect(self._set_scope)
|
||||
self.progress_workspace.diagnosis_requested.connect(self._open_order_diagnosis)
|
||||
self.progress_workspace.scope_changed.connect(self._set_scope)
|
||||
self.spatial_bridge = SpatialContextBridgeBar(
|
||||
"慢病全周期档案 · 患者列表、履约订单与面诊随访进度",
|
||||
on_filter_patient=self.search_patient,
|
||||
parent=self,
|
||||
)
|
||||
self.spatial_bridge.setVisible(False)
|
||||
root.insertWidget(1, self.spatial_bridge)
|
||||
if hasattr(self.patient_workspace, 'table'):
|
||||
self.patient_workspace.table.itemSelectionChanged.connect(self._sync_selected_patient_to_store)
|
||||
self.tabs.currentChanged.connect(self._workspace_changed)
|
||||
self._workspace_changed(0)
|
||||
|
||||
def set_patient_context_store(self, store: PatientContextStore) -> None:
|
||||
self.patient_context_store = store
|
||||
self._root_layout.setContentsMargins(2, 2, 2, 4)
|
||||
self._root_layout.setSpacing(10)
|
||||
self.header.setVisible(False)
|
||||
self.spatial_bridge.bind_store(store)
|
||||
self.spatial_bridge.add_action_widget(self.refresh_button)
|
||||
for disclosure in self.filter_disclosures:
|
||||
self.spatial_bridge.add_action_widget(disclosure.button)
|
||||
self._workspace_changed(self.tabs.currentIndex(), refresh=False)
|
||||
self.spatial_bridge.setVisible(True)
|
||||
|
||||
def _sync_selected_patient_to_store(self) -> None:
|
||||
if self.patient_context_store is None:
|
||||
return
|
||||
row = self.patient_workspace.table.current_data()
|
||||
if row is not None:
|
||||
self.patient_context_store.update_from_row(row)
|
||||
|
||||
def _set_scope(self, text: str) -> None:
|
||||
current = self.tabs.currentWidget()
|
||||
if current is self.sender() or getattr(current, "scope", None) == text:
|
||||
self.scope_badge.set_status(text, "neutral")
|
||||
|
||||
def _workspace_changed(self, index: int, *, refresh: bool = True) -> None:
|
||||
for workspace_index, disclosure in enumerate(self.filter_disclosures):
|
||||
disclosure.button.setVisible(workspace_index == index)
|
||||
self.scope_badge.setVisible(False)
|
||||
def _workspace_changed(self, index: int, *, refresh: bool = True) -> None:
|
||||
for workspace_index, disclosure in enumerate(self.filter_disclosures):
|
||||
disclosure.button.setVisible(workspace_index == index)
|
||||
self.scope_badge.setVisible(False)
|
||||
self.progress_workspace.set_active(index == 2 and self.isVisible())
|
||||
workspace = self.tabs.widget(index)
|
||||
scope = getattr(workspace, "scope", "按权限加载")
|
||||
self.scope_badge.set_status(str(scope), "neutral")
|
||||
reload_workspace = getattr(workspace, "refresh", None)
|
||||
if refresh and callable(reload_workspace) and self.isVisible():
|
||||
reload_workspace()
|
||||
reload_workspace = getattr(workspace, "refresh", None)
|
||||
if refresh and callable(reload_workspace) and self.isVisible():
|
||||
reload_workspace()
|
||||
|
||||
@property
|
||||
def filter_disclosure(self) -> FilterDisclosure:
|
||||
return self.filter_disclosures[self.tabs.currentIndex()]
|
||||
|
||||
def _remember_progress_sizes(self, _position: int, _index: int) -> None:
|
||||
if self.filter_disclosures[2].expanded:
|
||||
self._progress_splitter_sizes = self.progress_workspace.splitter.sizes()
|
||||
|
||||
def _progress_details_changed(self, expanded: bool) -> None:
|
||||
splitter = self.progress_workspace.splitter
|
||||
# A hidden schedule must release the splitter's old two-panel minimum.
|
||||
splitter.setMinimumHeight(536 if expanded else 222)
|
||||
if expanded:
|
||||
splitter.setSizes(self._progress_splitter_sizes)
|
||||
@property
|
||||
def filter_disclosure(self) -> FilterDisclosure:
|
||||
return self.filter_disclosures[self.tabs.currentIndex()]
|
||||
|
||||
def _remember_progress_sizes(self, _position: int, _index: int) -> None:
|
||||
if self.filter_disclosures[2].expanded:
|
||||
self._progress_splitter_sizes = self.progress_workspace.splitter.sizes()
|
||||
|
||||
def _progress_details_changed(self, expanded: bool) -> None:
|
||||
splitter = self.progress_workspace.splitter
|
||||
# A hidden schedule must release the splitter's old two-panel minimum.
|
||||
splitter.setMinimumHeight(536 if expanded else 222)
|
||||
if expanded:
|
||||
splitter.setSizes(self._progress_splitter_sizes)
|
||||
|
||||
def search_patient(self, query: str) -> None:
|
||||
"""Search the patient workspace using its normal permission-scoped endpoint."""
|
||||
blocked = self.tabs.blockSignals(True)
|
||||
try:
|
||||
self.tabs.setCurrentWidget(self.patient_workspace)
|
||||
finally:
|
||||
self.tabs.blockSignals(blocked)
|
||||
self._workspace_changed(0, refresh=False)
|
||||
# A global search starts a fresh result list, even for the same keyword.
|
||||
self.patient_workspace.pager.invalidate()
|
||||
self.patient_workspace.reset_filters(keyword=query, refresh=False)
|
||||
self.refresh()
|
||||
|
||||
def search_patient(self, query: str) -> None:
|
||||
"""Search the patient workspace using its normal permission-scoped endpoint."""
|
||||
blocked = self.tabs.blockSignals(True)
|
||||
try:
|
||||
self.tabs.setCurrentWidget(self.patient_workspace)
|
||||
finally:
|
||||
self.tabs.blockSignals(blocked)
|
||||
self._workspace_changed(0, refresh=False)
|
||||
# A global search starts a fresh result list, even for the same keyword.
|
||||
self.patient_workspace.pager.invalidate()
|
||||
self.patient_workspace.reset_filters(keyword=query, refresh=False)
|
||||
self.refresh()
|
||||
|
||||
def refresh(self) -> None:
|
||||
workspace = self.tabs.currentWidget()
|
||||
refresh = getattr(workspace, "refresh", None)
|
||||
@@ -3657,69 +3689,69 @@ class PatientsPage(QWidget):
|
||||
if generation == self._edit_generation:
|
||||
self.order_workspace.banner.show_message(friendly_error(error), "danger")
|
||||
|
||||
def _submit_order_audit(self, order_id: int, *, prescription: bool, action: str) -> None:
|
||||
label = "处方审核" if prescription else "支付单审核"
|
||||
remark, accepted = QInputDialog.getText(self, label, "审核备注:")
|
||||
if not accepted:
|
||||
return
|
||||
if action == "reject" and not remark.strip():
|
||||
show_toast(self, "驳回时必须填写审核意见。", "danger")
|
||||
return
|
||||
method = "audit_patient_order_prescription" if prescription else "audit_patient_order_payment"
|
||||
self._run_action(
|
||||
"正在处理订单…",
|
||||
lambda: _invoke_first(
|
||||
self.repository, (method,), order_id=order_id, action=action, remark=remark.strip()
|
||||
),
|
||||
success=f"{label}已提交。",
|
||||
)
|
||||
|
||||
def _check_order_signature_before_approval(self, row: Any, order_id: int) -> None:
|
||||
status_method = getattr(self.repository, "get_prescription_esign_status", None)
|
||||
if not callable(status_method):
|
||||
self._submit_order_audit(order_id, prescription=True, action="approve")
|
||||
return
|
||||
prescription_id = _as_int(first_value(row, "prescription_id"))
|
||||
if prescription_id <= 0:
|
||||
self.order_workspace.banner.show_message("找不到此订单的处方,请刷新订单后重试。", "warning")
|
||||
return
|
||||
self._order_review_generation += 1
|
||||
generation = self._order_review_generation
|
||||
self.order_workspace.banner.show_message("正在核对关联处方的签署状态…", "info")
|
||||
|
||||
def failed(error: Exception) -> None:
|
||||
if self._order_review_generation == generation:
|
||||
self.order_workspace.banner.show_message(f"未能核对签署状态。{friendly_error(error)}", "warning")
|
||||
|
||||
def checked(state: dict[str, Any]) -> None:
|
||||
if self._order_review_generation != generation:
|
||||
return
|
||||
def _submit_order_audit(self, order_id: int, *, prescription: bool, action: str) -> None:
|
||||
label = "处方审核" if prescription else "支付单审核"
|
||||
remark, accepted = QInputDialog.getText(self, label, "审核备注:")
|
||||
if not accepted:
|
||||
return
|
||||
if action == "reject" and not remark.strip():
|
||||
show_toast(self, "驳回时必须填写审核意见。", "danger")
|
||||
return
|
||||
method = "audit_patient_order_prescription" if prescription else "audit_patient_order_payment"
|
||||
self._run_action(
|
||||
"正在处理订单…",
|
||||
lambda: _invoke_first(
|
||||
self.repository, (method,), order_id=order_id, action=action, remark=remark.strip()
|
||||
),
|
||||
success=f"{label}已提交。",
|
||||
)
|
||||
|
||||
def _check_order_signature_before_approval(self, row: Any, order_id: int) -> None:
|
||||
status_method = getattr(self.repository, "get_prescription_esign_status", None)
|
||||
if not callable(status_method):
|
||||
self._submit_order_audit(order_id, prescription=True, action="approve")
|
||||
return
|
||||
prescription_id = _as_int(first_value(row, "prescription_id"))
|
||||
if prescription_id <= 0:
|
||||
self.order_workspace.banner.show_message("找不到此订单的处方,请刷新订单后重试。", "warning")
|
||||
return
|
||||
self._order_review_generation += 1
|
||||
generation = self._order_review_generation
|
||||
self.order_workspace.banner.show_message("正在核对关联处方的签署状态…", "info")
|
||||
|
||||
def failed(error: Exception) -> None:
|
||||
if self._order_review_generation == generation:
|
||||
self.order_workspace.banner.show_message(f"未能核对签署状态。{friendly_error(error)}", "warning")
|
||||
|
||||
def checked(state: dict[str, Any]) -> None:
|
||||
if self._order_review_generation != generation:
|
||||
return
|
||||
if review_submission_time(row, state) == 0:
|
||||
self.order_workspace.banner.show_message("请开方医生上传处方后再审核。", "warning")
|
||||
return
|
||||
verified = state["required"] and state["status"] == "signed" and state["can_download"]
|
||||
historical = not state["required"] and state["status"] == "legacy" and not state["can_download"]
|
||||
verified = state["required"] and state["status"] == "signed" and state["can_download"]
|
||||
historical = not state["required"] and state["status"] == "legacy" and not state["can_download"]
|
||||
if verified and state.get("review_required") is True and not review_signature_time(state):
|
||||
self.order_workspace.banner.show_message("请先在管理后台完成药师审核签署,再提交审核通过。", "warning")
|
||||
return
|
||||
if verified or historical:
|
||||
self.order_workspace.banner.clear()
|
||||
self._submit_order_audit(order_id, prescription=True, action="approve")
|
||||
return
|
||||
if verified or historical:
|
||||
self.order_workspace.banner.clear()
|
||||
self._submit_order_audit(order_id, prescription=True, action="approve")
|
||||
return
|
||||
if can_continue_prescription_esign(state, self.permissions, row):
|
||||
dialog = PrescriptionEsignDialog(self.repository, {"id": prescription_id, "esign": state}, parent=self)
|
||||
dialog.exec()
|
||||
self.order_workspace.banner.show_message("请在签署验签通过后,再点击处方审核。", "info")
|
||||
self.order_workspace.refresh(silent=True)
|
||||
else:
|
||||
message = state.get("message") or (
|
||||
"签署原件暂不可用,请联系管理员核验。" if state["status"] == "signed"
|
||||
else "请开方医生完成处方签署并通过验签,再审核通过。"
|
||||
)
|
||||
self.order_workspace.banner.show_message(str(message), "warning")
|
||||
|
||||
run_async(lambda: esign_status(status_method(prescription_id)), on_success=checked, on_error=failed)
|
||||
|
||||
dialog = PrescriptionEsignDialog(self.repository, {"id": prescription_id, "esign": state}, parent=self)
|
||||
dialog.exec()
|
||||
self.order_workspace.banner.show_message("请在签署验签通过后,再点击处方审核。", "info")
|
||||
self.order_workspace.refresh(silent=True)
|
||||
else:
|
||||
message = state.get("message") or (
|
||||
"签署原件暂不可用,请联系管理员核验。" if state["status"] == "signed"
|
||||
else "请开方医生完成处方签署并通过验签,再审核通过。"
|
||||
)
|
||||
self.order_workspace.banner.show_message(str(message), "warning")
|
||||
|
||||
run_async(lambda: esign_status(status_method(prescription_id)), on_success=checked, on_error=failed)
|
||||
|
||||
def _handle_order_action(self, key: str, row: Any) -> None:
|
||||
allowed_keys = {item[0] for item in self.order_workspace._available_actions(row)}
|
||||
if key not in allowed_keys:
|
||||
@@ -3735,20 +3767,20 @@ class PatientsPage(QWidget):
|
||||
call: Any
|
||||
success = "订单已更新。"
|
||||
if key in {"audit_prescription", "audit_payment"}:
|
||||
self._order_review_generation += 1
|
||||
prescription = key == "audit_prescription"
|
||||
label = "处方审核" if prescription else "支付单审核"
|
||||
self._order_review_generation += 1
|
||||
prescription = key == "audit_prescription"
|
||||
label = "处方审核" if prescription else "支付单审核"
|
||||
action_label, accepted = QInputDialog.getItem(
|
||||
self, label, "审核结果:", ["通过", "驳回"], 0, False
|
||||
)
|
||||
if not accepted:
|
||||
return
|
||||
action = "approve" if action_label == "通过" else "reject"
|
||||
if prescription and action == "approve":
|
||||
self._check_order_signature_before_approval(row, order_id)
|
||||
else:
|
||||
self._submit_order_audit(order_id, prescription=prescription, action=action)
|
||||
return
|
||||
if prescription and action == "approve":
|
||||
self._check_order_signature_before_approval(row, order_id)
|
||||
else:
|
||||
self._submit_order_audit(order_id, prescription=prescription, action=action)
|
||||
return
|
||||
elif key in {"revoke_rx_audit", "revoke_pay_audit", "withdraw", "upload_pharmacy"}:
|
||||
labels = {
|
||||
"revoke_rx_audit": "撤回处方审核",
|
||||
@@ -3891,7 +3923,7 @@ class PatientsPage(QWidget):
|
||||
self.refresh()
|
||||
|
||||
def hideEvent(self, event: Any) -> None:
|
||||
self._order_review_generation += 1
|
||||
self._order_review_generation += 1
|
||||
self.progress_workspace.set_active(False)
|
||||
super().hideEvent(event)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from PySide6.QtWidgets import (
|
||||
)
|
||||
|
||||
from .. import motion
|
||||
from ..design_system import PALETTE
|
||||
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
|
||||
@@ -36,6 +36,8 @@ from ..prescription_library_style import (
|
||||
library_stylesheet,
|
||||
)
|
||||
from ..reception_style import body_family
|
||||
from ..state import PatientContextStore
|
||||
from ..visuals.context_bridge_bar import SpatialContextBridgeBar
|
||||
from ..widgets import (
|
||||
EmptyState,
|
||||
MessageBanner,
|
||||
@@ -120,7 +122,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 = PALETTE["accent"] if kind == "accent" else PALETTE["muted"]
|
||||
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
|
||||
@@ -153,7 +155,9 @@ class PrescriptionLibraryPage(QWidget):
|
||||
self._page_size = 15
|
||||
|
||||
outer = QVBoxLayout(self)
|
||||
self._outer_layout = outer
|
||||
outer.setContentsMargins(28, 16, 26, 8)
|
||||
self.patient_context_store: PatientContextStore | None = None
|
||||
self.scroll = QScrollArea()
|
||||
self.scroll.setObjectName("PrescriptionLibraryScroll")
|
||||
self.scroll.setWidgetResizable(True)
|
||||
@@ -163,7 +167,7 @@ class PrescriptionLibraryPage(QWidget):
|
||||
self.content.setObjectName("PrescriptionLibraryContent")
|
||||
root = QVBoxLayout(self.content)
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
root.setSpacing(10)
|
||||
root.setSpacing(10)
|
||||
self.scroll.setWidget(self.content)
|
||||
outer.addWidget(self.scroll)
|
||||
header = PageHeader(
|
||||
@@ -188,8 +192,8 @@ class PrescriptionLibraryPage(QWidget):
|
||||
header.add_action(self.new_button)
|
||||
root.addWidget(header)
|
||||
|
||||
self.metrics_panel = QWidget(self.content)
|
||||
metrics = QHBoxLayout(self.metrics_panel)
|
||||
self.metrics_panel = QWidget(self.content)
|
||||
metrics = QHBoxLayout(self.metrics_panel)
|
||||
metrics.setContentsMargins(0, 0, 0, 0)
|
||||
metrics.setSpacing(16)
|
||||
self.metric_cards = {
|
||||
@@ -200,7 +204,7 @@ class PrescriptionLibraryPage(QWidget):
|
||||
}
|
||||
for metric in self.metric_cards.values():
|
||||
metrics.addWidget(metric)
|
||||
root.addWidget(self.metrics_panel)
|
||||
root.addWidget(self.metrics_panel)
|
||||
|
||||
self.hint_banner = MessageBanner(parent=self)
|
||||
self.hint_banner.show_message(
|
||||
@@ -260,10 +264,16 @@ class PrescriptionLibraryPage(QWidget):
|
||||
grid.setColumnStretch(1, 1)
|
||||
grid.setColumnStretch(2, 1)
|
||||
grid.setColumnStretch(3, 1)
|
||||
root.addWidget(filters)
|
||||
self.filter_disclosure = FilterDisclosure(self, [self.metrics_panel, filters])
|
||||
header.add_action(self.filter_disclosure.button)
|
||||
header.set_compact()
|
||||
root.addWidget(filters)
|
||||
self.filter_disclosure = FilterDisclosure(self, [self.metrics_panel, filters])
|
||||
header.add_action(self.filter_disclosure.button)
|
||||
header.set_compact()
|
||||
self.spatial_bridge = SpatialContextBridgeBar(
|
||||
"专科经方与协定处方智库 · 支持 AI 配伍解析与快速调取",
|
||||
parent=self.content,
|
||||
)
|
||||
self.spatial_bridge.setVisible(False)
|
||||
root.insertWidget(1, self.spatial_bridge)
|
||||
|
||||
self.banner = MessageBanner()
|
||||
root.addWidget(self.banner)
|
||||
@@ -399,7 +409,7 @@ class PrescriptionLibraryPage(QWidget):
|
||||
if hasattr(self, "filter_grid"):
|
||||
compact_height = self.height() < 760
|
||||
self.layout().setContentsMargins(28, 16, 26, 8)
|
||||
self.content.layout().setSpacing(8 if compact_height else 10)
|
||||
self.content.layout().setSpacing(8 if compact_height else 10)
|
||||
self._reflow_filters()
|
||||
|
||||
def _reflow_filters(self) -> None:
|
||||
@@ -544,7 +554,7 @@ class PrescriptionLibraryPage(QWidget):
|
||||
|
||||
name_item = self.table.item(row_index, 1)
|
||||
if name_item is not None:
|
||||
name_item.setForeground(QColor(PALETTE["heading"]))
|
||||
name_item.setForeground(QColor(PALETTE["heading"]))
|
||||
font = name_item.font()
|
||||
font.setWeight(QFont.Weight.Medium)
|
||||
name_item.setFont(font)
|
||||
@@ -671,6 +681,16 @@ class PrescriptionLibraryPage(QWidget):
|
||||
role_ids = [role_ids]
|
||||
return any(str(role) in {"0", "3"} for role in role_ids)
|
||||
|
||||
def set_patient_context_store(self, store: PatientContextStore) -> None:
|
||||
self.patient_context_store = store
|
||||
self._outer_layout.setContentsMargins(2, 2, 2, 4)
|
||||
self.header.setVisible(False)
|
||||
self.spatial_bridge.bind_store(store)
|
||||
if has_permission(self.permissions, 'wcf.prescription/add'):
|
||||
self.spatial_bridge.add_action_widget(self.new_button)
|
||||
self.spatial_bridge.add_action_widget(self.filter_disclosure.button)
|
||||
self.spatial_bridge.setVisible(True)
|
||||
|
||||
def _new_template(self) -> None:
|
||||
if not has_permission(self.permissions, "wcf.prescription/add"):
|
||||
return
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -92,7 +92,10 @@ from ..filter_disclosure import FilterDisclosure
|
||||
from ..reception_style import body_family, heading_family, number_family
|
||||
from ..reception_workspace import RECEPTION_WORKSPACE_QSS, ReceptionWorkbench
|
||||
from ..report_provenance import report_provenance_lines
|
||||
from ..state import PatientContextStore
|
||||
from ..theme import mark_business_dialog
|
||||
from ..viewmodels.cockpit_vm import derive_cockpit_snapshot
|
||||
from ..visuals.reception_cockpit import ReceptionDigitalTwinCockpit
|
||||
from ..widgets import (
|
||||
EmptyState,
|
||||
MessageBanner,
|
||||
@@ -1177,13 +1180,47 @@ QWidget#ReceptionPage QPushButton#ReceptionHistoryButton,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionImButton,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionMoreButton,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionCompleteButton {
|
||||
min-height: 38px;
|
||||
max-height: 38px;
|
||||
padding: 0 12px;
|
||||
min-height: 36px;
|
||||
max-height: 36px;
|
||||
padding: 0 13px;
|
||||
font-size: 13px;
|
||||
border-radius: 5px;
|
||||
font-weight: 500;
|
||||
border-radius: 8px;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionNotifyButton:enabled,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionHistoryButton:enabled,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionMoreButton:enabled {
|
||||
color: #16302E;
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #C6D8D5;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionNotifyButton:enabled:hover,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionHistoryButton:enabled:hover,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionMoreButton:enabled:hover {
|
||||
color: #0B6E68;
|
||||
background-color: #EAF6F4;
|
||||
border-color: #8FC8C0;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionNotifyButton:enabled:pressed,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionHistoryButton:enabled:pressed,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionMoreButton:enabled:pressed {
|
||||
background-color: #D7EDE9;
|
||||
border-color: #0B6E68;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionCompleteButton:enabled {
|
||||
color: #C93B4E;
|
||||
background-color: #FFF6F7;
|
||||
border: 1px solid #F0BDC5;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionCompleteButton:enabled:hover {
|
||||
color: #B42C3F;
|
||||
background-color: #FDE8EB;
|
||||
border-color: #DF8F9C;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionCompleteButton:enabled:pressed {
|
||||
background-color: #FAD6DC;
|
||||
border-color: #C93B4E;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionCompleteButton:enabled { background-color: #FFFFFF; }
|
||||
QWidget#ReceptionPage QPushButton#ReceptionMoreButton { padding: 0 6px; }
|
||||
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs {
|
||||
border-top-left-radius: 0;
|
||||
@@ -2419,15 +2456,21 @@ class _ReceptionCompleteButton(QPushButton):
|
||||
super().__init__("结束问诊", parent)
|
||||
self.setObjectName("ReceptionCompleteButton")
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.setIcon(icons.icon("check_circle", "danger", 15))
|
||||
self.setIconSize(QSize(15, 15))
|
||||
|
||||
def changeEvent(self, event: QEvent) -> None: # noqa: N802 - Qt API
|
||||
super().changeEvent(event)
|
||||
if event.type() == QEvent.Type.EnabledChange:
|
||||
enabled = self.isEnabled()
|
||||
self.setCursor(
|
||||
Qt.CursorShape.PointingHandCursor
|
||||
if self.isEnabled()
|
||||
if enabled
|
||||
else Qt.CursorShape.ArrowCursor
|
||||
)
|
||||
self.setIcon(
|
||||
icons.icon("check_circle", "danger" if enabled else "disabled", 15)
|
||||
)
|
||||
|
||||
|
||||
class _NoteAttachmentPreview(QPushButton):
|
||||
@@ -4112,6 +4155,7 @@ class ReceptionPage(QWidget):
|
||||
"""Run the complete same-day reception workflow without blocking Qt."""
|
||||
|
||||
video_requested = Signal(dict)
|
||||
cockpit_snapshot_updated = Signal(object)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -4225,8 +4269,48 @@ class ReceptionPage(QWidget):
|
||||
)
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
self._root_layout = root
|
||||
root.setContentsMargins(12, 16, 12, 12)
|
||||
root.setSpacing(0)
|
||||
self.patient_context_store: PatientContextStore | None = None
|
||||
self._workspace_mode = "chart"
|
||||
self._latest_daily_blood: list[Any] = []
|
||||
|
||||
self.view_mode_stack = QStackedWidget(self)
|
||||
self.view_mode_stack.setObjectName("ReceptionViewModeStack")
|
||||
|
||||
chart_page = QWidget(self.view_mode_stack)
|
||||
chart_page.setObjectName("ReceptionChartModePage")
|
||||
chart_layout = QVBoxLayout(chart_page)
|
||||
chart_layout.setContentsMargins(0, 0, 0, 0)
|
||||
chart_layout.setSpacing(8)
|
||||
|
||||
self._return_to_cockpit_bar = QFrame(chart_page)
|
||||
self._return_to_cockpit_bar.setObjectName("ReceptionReturnCockpitBar")
|
||||
self._return_to_cockpit_bar.setFixedHeight(38)
|
||||
self._return_to_cockpit_bar.setVisible(False)
|
||||
self._return_to_cockpit_bar.setStyleSheet(
|
||||
"QFrame#ReceptionReturnCockpitBar {"
|
||||
" background-color: #FFFFFF; border: 1px solid #DCE7E4; border-radius: 19px; }"
|
||||
)
|
||||
ret_layout = QHBoxLayout(self._return_to_cockpit_bar)
|
||||
ret_layout.setContentsMargins(10, 4, 14, 4)
|
||||
ret_layout.setSpacing(10)
|
||||
back_cockpit_btn = QPushButton("← 返回三焦全息驾驶舱", self._return_to_cockpit_bar)
|
||||
back_cockpit_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
back_cockpit_btn.setStyleSheet(
|
||||
"QPushButton { background-color: #0E6F5C; color: #FFFFFF; border: 0;"
|
||||
" border-radius: 14px; padding: 0 14px; min-height: 28px; max-height: 28px;"
|
||||
" font-size: 12px; font-weight: 600; }"
|
||||
"QPushButton:hover { background-color: #0A5949; }"
|
||||
)
|
||||
back_cockpit_btn.clicked.connect(lambda: self.set_workspace_mode("cockpit"))
|
||||
ret_layout.addWidget(back_cockpit_btn)
|
||||
ret_hint = QLabel("当前处于「六维结构化病历与附件归档」详细视图", self._return_to_cockpit_bar)
|
||||
ret_hint.setStyleSheet("color: #5E7471; font-size: 12px; background: transparent; border: 0;")
|
||||
ret_layout.addWidget(ret_hint)
|
||||
ret_layout.addStretch(1)
|
||||
chart_layout.addWidget(self._return_to_cockpit_bar)
|
||||
|
||||
splitter = QSplitter(Qt.Orientation.Horizontal)
|
||||
splitter.setChildrenCollapsible(False)
|
||||
@@ -4238,7 +4322,23 @@ class ReceptionPage(QWidget):
|
||||
splitter.setStretchFactor(1, 1)
|
||||
splitter.setHandleWidth(12)
|
||||
splitter.setSizes([286, 1185])
|
||||
root.addWidget(splitter, 1)
|
||||
chart_layout.addWidget(splitter, 1)
|
||||
|
||||
self.view_mode_stack.addWidget(chart_page)
|
||||
self._chart_mode_page = chart_page
|
||||
|
||||
self.cockpit_view = ReceptionDigitalTwinCockpit(self.view_mode_stack)
|
||||
self.cockpit_view.appointment_selected.connect(self._select_record_from_cockpit)
|
||||
self.cockpit_view.filter_status_requested.connect(self._set_queue_filter)
|
||||
self.cockpit_view.refresh_requested.connect(self._refresh_workspace)
|
||||
self.cockpit_view.start_video_requested.connect(self._request_video)
|
||||
self.cockpit_view.edit_diagnosis_requested.connect(self._edit_diagnosis)
|
||||
self.cockpit_view.notify_assistant_requested.connect(self._notify_assistant)
|
||||
self.cockpit_view.complete_visit_requested.connect(self._complete_appointment)
|
||||
self.cockpit_view.open_chart_tab_requested.connect(self._open_structured_chart_tab)
|
||||
self.view_mode_stack.addWidget(self.cockpit_view)
|
||||
|
||||
root.addWidget(self.view_mode_stack, 1)
|
||||
|
||||
self.poll_timer = QTimer(self)
|
||||
self.poll_timer.setInterval(5_000)
|
||||
@@ -4258,6 +4358,111 @@ class ReceptionPage(QWidget):
|
||||
if panel.minimumWidth() != width:
|
||||
panel.setFixedWidth(width)
|
||||
|
||||
def set_patient_context_store(self, store: PatientContextStore) -> None:
|
||||
"""Attach the Spatial Shell context store and default to Digital Twin Cockpit."""
|
||||
|
||||
self.patient_context_store = store
|
||||
self._root_layout.setContentsMargins(0, 2, 0, 2)
|
||||
self._queue_filter_status = None
|
||||
for st_key, btn in self._queue_filter_buttons.items():
|
||||
btn.setChecked(st_key is None)
|
||||
self._sync_queue_filter_summary()
|
||||
self.set_workspace_mode("cockpit")
|
||||
self._sync_cockpit_and_context()
|
||||
|
||||
def set_workspace_mode(self, mode: str) -> None:
|
||||
normalized = "cockpit" if str(mode).strip().lower() == "cockpit" else "chart"
|
||||
self._workspace_mode = normalized
|
||||
if normalized == "cockpit":
|
||||
self.view_mode_stack.setCurrentWidget(self.cockpit_view)
|
||||
self._return_to_cockpit_bar.setVisible(False)
|
||||
else:
|
||||
self.view_mode_stack.setCurrentWidget(self._chart_mode_page)
|
||||
self._return_to_cockpit_bar.setVisible(self.patient_context_store is not None)
|
||||
if self.patient_context_store is not None:
|
||||
self.patient_context_store.set_cockpit_mode(normalized)
|
||||
|
||||
def _open_structured_chart_tab(self, tab_index: int = 0) -> None:
|
||||
self.set_workspace_mode("chart")
|
||||
if hasattr(self, "detail_tabs") and 0 <= tab_index < self.detail_tabs.count():
|
||||
self.detail_tabs.setCurrentIndex(tab_index)
|
||||
|
||||
def _select_record_from_cockpit(self, record: Any) -> None:
|
||||
rec_id = _record_id(record)
|
||||
if rec_id is not None:
|
||||
for idx in range(self.queue_list.count()):
|
||||
item = self.queue_list.item(idx)
|
||||
item_rec = item.data(Qt.ItemDataRole.UserRole)
|
||||
if _same_id(_record_id(item_rec), rec_id):
|
||||
if self.queue_list.currentRow() != idx:
|
||||
self.queue_list.setCurrentRow(idx)
|
||||
else:
|
||||
self._select_record(record)
|
||||
return
|
||||
self._select_record(record)
|
||||
|
||||
def select_cockpit_ai_model(self, model_key: str) -> None:
|
||||
if model_key in AI_ANALYSIS_MODELS:
|
||||
self._ai_analysis_active_model = model_key
|
||||
if hasattr(self, "ai_analysis_model_selector"):
|
||||
idx = self.ai_analysis_model_selector.findData(model_key)
|
||||
if idx >= 0 and self.ai_analysis_model_selector.currentIndex() != idx:
|
||||
self.ai_analysis_model_selector.setCurrentIndex(idx)
|
||||
self._sync_ai_analysis_view()
|
||||
self._sync_cockpit_and_context()
|
||||
|
||||
def _sync_cockpit_and_context(self) -> None:
|
||||
"""Synchronize the 3-column Digital Twin Cockpit and global PatientContextStore."""
|
||||
|
||||
if not hasattr(self, "cockpit_view"):
|
||||
return
|
||||
detail = self._selected_detail or {}
|
||||
appointment = get_value(detail, "appointment", None) or self._selected_record or {}
|
||||
patient = get_value(detail, "patient", None) or {}
|
||||
diagnosis = get_value(detail, "diagnosis", None) or {}
|
||||
|
||||
self.cockpit_view.set_queue_records(
|
||||
self._queue_records,
|
||||
self._selected_appointment_id,
|
||||
active_filter_status=self._queue_filter_status,
|
||||
queue_date=self._queue_date,
|
||||
)
|
||||
doc_name = display_text(
|
||||
first_value(
|
||||
appointment,
|
||||
"doctor_name",
|
||||
default=first_value(self.current_user, "name", "real_name", default="主诊中医师"),
|
||||
)
|
||||
)
|
||||
asst_name = display_text(first_value(appointment, "assistant_name", default=""), "")
|
||||
self.cockpit_view.set_care_team_context(
|
||||
doctor_name=doc_name,
|
||||
assistant_name=asst_name,
|
||||
can_edit=bool(self._can_edit and self._selected_appointment_id is not None),
|
||||
can_notify=bool(self._selected_appointment_id is not None),
|
||||
can_complete=bool(
|
||||
hasattr(self, "complete_button") and self.complete_button.isEnabled()
|
||||
),
|
||||
)
|
||||
|
||||
if self.patient_context_store is not None:
|
||||
if self._selected_appointment_id is not None and appointment:
|
||||
self.patient_context_store.update_from_reception(appointment, patient, diagnosis)
|
||||
elif not self._queue_records:
|
||||
self.patient_context_store.clear()
|
||||
|
||||
ai_payload = self._ai_analysis_payloads.get(self._ai_analysis_active_model)
|
||||
vm = derive_cockpit_snapshot(
|
||||
appointment,
|
||||
patient,
|
||||
diagnosis,
|
||||
daily_records=self._latest_daily_blood,
|
||||
ai_payload=ai_payload,
|
||||
active_ai_model=self._ai_analysis_active_model,
|
||||
)
|
||||
self.cockpit_view.set_snapshot(vm)
|
||||
self.cockpit_snapshot_updated.emit(vm)
|
||||
|
||||
def _ensure_diagnosis_dialog(self) -> DiagnosisDialog:
|
||||
dialog = getattr(self, "diagnosis_dialog", None)
|
||||
if dialog is None:
|
||||
@@ -4448,7 +4653,7 @@ class ReceptionPage(QWidget):
|
||||
actions = QHBoxLayout()
|
||||
hero.actions_layout = actions
|
||||
actions.setContentsMargins(0, 0, 0, 0)
|
||||
actions.setSpacing(14)
|
||||
actions.setSpacing(10)
|
||||
actions.addStretch(1)
|
||||
action_group = QVBoxLayout()
|
||||
hero.action_group = action_group
|
||||
@@ -4468,14 +4673,20 @@ class ReceptionPage(QWidget):
|
||||
self.complete_button.setVisible(self._can_complete)
|
||||
self.notify_button = QPushButton("通知医助", hero)
|
||||
self.notify_button.setObjectName("ReceptionNotifyButton")
|
||||
self.notify_button.setIcon(icons.icon("notification", "accent", 15))
|
||||
self.notify_button.setIconSize(QSize(15, 15))
|
||||
self.notify_button.clicked.connect(self._notify_assistant)
|
||||
actions.addWidget(self.notify_button)
|
||||
self.history_button = QPushButton("查看历史", hero)
|
||||
self.history_button.setObjectName("ReceptionHistoryButton")
|
||||
self.history_button.setIcon(icons.icon("followup", "muted", 15))
|
||||
self.history_button.setIconSize(QSize(15, 15))
|
||||
self.history_button.clicked.connect(lambda: self.detail_tabs.setCurrentIndex(4))
|
||||
actions.addWidget(self.history_button)
|
||||
self.video_button = QPushButton("IM 问诊", hero)
|
||||
self.video_button.setObjectName("ReceptionImButton")
|
||||
self.video_button.setIcon(icons.icon("message", "inverse", 15))
|
||||
self.video_button.setIconSize(QSize(15, 15))
|
||||
self.video_button.setToolTip("打开患者 IM,可发送消息并从会话中发起视频")
|
||||
self.video_button.setProperty("variant", "primary")
|
||||
self.video_button.clicked.connect(self._request_video)
|
||||
@@ -4486,7 +4697,7 @@ class ReceptionPage(QWidget):
|
||||
self.more_button.setToolTip("更多操作")
|
||||
self.more_button.setAccessibleName("更多操作")
|
||||
self.more_button.setObjectName("ReceptionMoreButton")
|
||||
self.more_button.setFixedWidth(46)
|
||||
self.more_button.setFixedWidth(40)
|
||||
hero.more_control = self.more_button
|
||||
more_menu = QMenu(self.more_button)
|
||||
edit_action = more_menu.addAction("编辑病历")
|
||||
@@ -4500,7 +4711,7 @@ class ReceptionPage(QWidget):
|
||||
consult_action.triggered.connect(self._open_ai_consult)
|
||||
self.more_button.setMenu(more_menu)
|
||||
actions.addWidget(self.more_button)
|
||||
actions.addSpacing(16)
|
||||
actions.addSpacing(8)
|
||||
hero.complete_gap = actions.itemAt(actions.count() - 1).spacerItem()
|
||||
actions.addWidget(self.complete_button)
|
||||
|
||||
@@ -4572,11 +4783,33 @@ class ReceptionPage(QWidget):
|
||||
history_card.setObjectName("ReceptionHistoryCard")
|
||||
history_layout = QVBoxLayout(history_card)
|
||||
history_layout.setContentsMargins(0, 0, 0, 0)
|
||||
history_layout.setSpacing(14)
|
||||
history_layout.setSpacing(11)
|
||||
history_head = QHBoxLayout()
|
||||
history_head.setContentsMargins(0, 0, 0, 0)
|
||||
history_head.setSpacing(8)
|
||||
history_title = QLabel("病情与用药", history_card)
|
||||
history_title.setObjectName("ReceptionCaseHeading")
|
||||
history_layout.addWidget(history_title)
|
||||
history_head.addWidget(history_title)
|
||||
history_head.addStretch(1)
|
||||
self.inline_edit_record_button = QPushButton("编辑四诊", history_card)
|
||||
self.inline_edit_record_button.setObjectName("ReceptionInlineAction")
|
||||
self.inline_edit_record_button.setIcon(icons.icon("edit", "accent", 14))
|
||||
self.inline_edit_record_button.setIconSize(QSize(14, 14))
|
||||
self.inline_edit_record_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.inline_edit_record_button.setVisible(self._can_edit)
|
||||
self.inline_edit_record_button.clicked.connect(self._edit_diagnosis)
|
||||
history_head.addWidget(self.inline_edit_record_button)
|
||||
self.inline_ai_consult_button = QPushButton("AI 辨证", history_card)
|
||||
self.inline_ai_consult_button.setObjectName("ReceptionInlineAiAction")
|
||||
self.inline_ai_consult_button.setIcon(icons.icon("ai", "gold", 14))
|
||||
self.inline_ai_consult_button.setIconSize(QSize(14, 14))
|
||||
self.inline_ai_consult_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.inline_ai_consult_button.setVisible(self._can_ai_assistant)
|
||||
self.inline_ai_consult_button.clicked.connect(self._open_ai_consult)
|
||||
history_head.addWidget(self.inline_ai_consult_button)
|
||||
history_layout.addLayout(history_head)
|
||||
self.case_labels: dict[str, QLabel] = {}
|
||||
self._case_field_frames: dict[str, QFrame] = {}
|
||||
|
||||
def add_case_field(
|
||||
target: QVBoxLayout,
|
||||
@@ -4587,10 +4820,17 @@ class ReceptionPage(QWidget):
|
||||
) -> None:
|
||||
field = QFrame(history_card)
|
||||
field.setObjectName("ReceptionCaseField")
|
||||
if key == "chief":
|
||||
field.setProperty("chiefFocus", True)
|
||||
if stacked:
|
||||
field_layout = QVBoxLayout(field)
|
||||
field_layout.setContentsMargins(0, 0, 0, 0)
|
||||
field_layout.setSpacing(6)
|
||||
field_layout.setContentsMargins(
|
||||
12 if key == "chief" else 0,
|
||||
9 if key == "chief" else 0,
|
||||
12 if key == "chief" else 0,
|
||||
9 if key == "chief" else 6,
|
||||
)
|
||||
field_layout.setSpacing(5)
|
||||
title_label = QLabel(caption, field)
|
||||
title_label.setProperty("receptionBlockTitle", True)
|
||||
field_layout.addWidget(title_label)
|
||||
@@ -4599,7 +4839,7 @@ class ReceptionPage(QWidget):
|
||||
field_layout.addWidget(value_label)
|
||||
else:
|
||||
field_layout = QHBoxLayout(field)
|
||||
field_layout.setContentsMargins(0, 0, 0, 0)
|
||||
field_layout.setContentsMargins(0, 0, 0, 6)
|
||||
field_layout.setSpacing(10)
|
||||
title_label = QLabel(caption, field)
|
||||
title_label.setProperty("receptionInlineCaption", True)
|
||||
@@ -4611,6 +4851,7 @@ class ReceptionPage(QWidget):
|
||||
value_label.setProperty("receptionInlineValue", True)
|
||||
field_layout.addWidget(value_label, 1)
|
||||
self.case_labels[key] = value_label
|
||||
self._case_field_frames[key] = field
|
||||
target.addWidget(field)
|
||||
|
||||
add_case_field(history_layout, "chief", "本次主诉", stacked=True)
|
||||
@@ -4653,13 +4894,47 @@ class ReceptionPage(QWidget):
|
||||
history_layout.addWidget(lifestyle_field)
|
||||
|
||||
add_case_field(history_layout, "diet", "饮食习惯")
|
||||
|
||||
# W2 Bento 驾驶舱:将未填写的可选病史自动折叠为快捷补录胶囊,消除满屏空白「—」占位行
|
||||
self._missing_fields_host = QFrame(history_card)
|
||||
self._missing_fields_host.setObjectName("ReceptionMissingFieldsBar")
|
||||
missing_outer = QVBoxLayout(self._missing_fields_host)
|
||||
missing_outer.setContentsMargins(0, 4, 0, 0)
|
||||
missing_outer.setSpacing(6)
|
||||
missing_caption = QLabel("待补录病史(点击快捷补录)", self._missing_fields_host)
|
||||
missing_caption.setProperty("receptionInlineCaption", True)
|
||||
missing_outer.addWidget(missing_caption)
|
||||
missing_row = QHBoxLayout()
|
||||
missing_row.setContentsMargins(0, 0, 0, 0)
|
||||
missing_row.setSpacing(6)
|
||||
self._missing_field_pills: dict[str, QPushButton] = {}
|
||||
for key, label in (
|
||||
("course", "+ 患病时长"),
|
||||
("past", "+ 既往史"),
|
||||
("family", "+ 家族史"),
|
||||
("allergy", "+ 过敏史"),
|
||||
("diet", "+ 饮食习惯"),
|
||||
):
|
||||
pill = QPushButton(label, self._missing_fields_host)
|
||||
pill.setProperty("receptionQuickFill", True)
|
||||
pill.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
pill.setEnabled(self._can_edit)
|
||||
pill.setToolTip(f"打开四诊病历补录{label[2:]}")
|
||||
pill.clicked.connect(self._edit_diagnosis)
|
||||
self._missing_field_pills[key] = pill
|
||||
missing_row.addWidget(pill)
|
||||
missing_row.addStretch(1)
|
||||
missing_outer.addLayout(missing_row)
|
||||
self._missing_fields_host.hide()
|
||||
history_layout.addWidget(self._missing_fields_host)
|
||||
|
||||
history_layout.addStretch(1)
|
||||
consultation_layout.addWidget(history_card, 1)
|
||||
|
||||
right_clinical = QWidget(consultation_page)
|
||||
right_layout = QVBoxLayout(right_clinical)
|
||||
right_layout.setContentsMargins(0, 0, 0, 0)
|
||||
right_layout.setSpacing(10)
|
||||
right_layout.setSpacing(8)
|
||||
|
||||
self.patient_summary_card, self.patient_summary_labels = self._field_card(
|
||||
"患者基本信息",
|
||||
@@ -4681,8 +4956,8 @@ class ReceptionPage(QWidget):
|
||||
vitals_card.setMinimumHeight(0)
|
||||
vitals_card.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
|
||||
vitals_layout = QVBoxLayout(vitals_card)
|
||||
vitals_layout.setContentsMargins(14, 14, 14, 14)
|
||||
vitals_layout.setSpacing(8)
|
||||
vitals_layout.setContentsMargins(12, 10, 12, 10)
|
||||
vitals_layout.setSpacing(6)
|
||||
vitals_title = QLabel("生命体征", vitals_card)
|
||||
vitals_title.setProperty("receptionBlockTitle", True)
|
||||
vitals_layout.addWidget(vitals_title)
|
||||
@@ -4746,8 +5021,8 @@ class ReceptionPage(QWidget):
|
||||
labs_card = QFrame(right_clinical)
|
||||
labs_card.setObjectName("ReceptionLabsCard")
|
||||
labs_layout = QVBoxLayout(labs_card)
|
||||
labs_layout.setContentsMargins(14, 14, 14, 14)
|
||||
labs_layout.setSpacing(9)
|
||||
labs_layout.setContentsMargins(12, 10, 12, 10)
|
||||
labs_layout.setSpacing(6)
|
||||
labs_title = QLabel("检查结果", labs_card)
|
||||
labs_title.setProperty("receptionBlockTitle", True)
|
||||
labs_layout.addWidget(labs_title)
|
||||
@@ -4757,7 +5032,7 @@ class ReceptionPage(QWidget):
|
||||
self._show_missing_labs = False
|
||||
labs_grid.setContentsMargins(0, 0, 0, 0)
|
||||
labs_grid.setHorizontalSpacing(7)
|
||||
labs_grid.setVerticalSpacing(7)
|
||||
labs_grid.setVerticalSpacing(5)
|
||||
self.lab_labels: dict[str, QLabel] = {}
|
||||
self.lab_state_labels: dict[str, QLabel] = {}
|
||||
lab_definitions = (
|
||||
@@ -5702,6 +5977,7 @@ class ReceptionPage(QWidget):
|
||||
self.ai_analysis_card.setProperty("analysisState", state)
|
||||
self.ai_analysis_card.style().unpolish(self.ai_analysis_card)
|
||||
self.ai_analysis_card.style().polish(self.ai_analysis_card)
|
||||
self._sync_cockpit_and_context()
|
||||
|
||||
def _render_ai_analysis_payload(
|
||||
self,
|
||||
@@ -7463,6 +7739,7 @@ class ReceptionPage(QWidget):
|
||||
)
|
||||
else:
|
||||
self._clear_selection()
|
||||
self._sync_cockpit_and_context()
|
||||
return
|
||||
chosen = records[row_to_select]
|
||||
if selected_id is not None and _same_id(_record_id(chosen), selected_id):
|
||||
@@ -7471,6 +7748,7 @@ class ReceptionPage(QWidget):
|
||||
self._load_detail(chosen, silent=True, clear=False)
|
||||
else:
|
||||
self._select_record(chosen, silent=True, read_only_refresh=workspace_refresh)
|
||||
self._sync_cockpit_and_context()
|
||||
|
||||
def _update_queue_filter_counts(self, result: Any, records: list[Any]) -> None:
|
||||
extend = get_value(result, "extend", None)
|
||||
@@ -8624,6 +8902,7 @@ class ReceptionPage(QWidget):
|
||||
}
|
||||
for key, value in case_values.items():
|
||||
self.case_labels[key].setText(display_text(value))
|
||||
self._sync_case_field_folding()
|
||||
self._set_patient_summary_value("course", case_values["course"])
|
||||
self._set_patient_summary_value(
|
||||
"diagnosis", case_value("clinical_diagnosis", "diagnosis_name", "disease_name")
|
||||
@@ -9057,6 +9336,24 @@ class ReceptionPage(QWidget):
|
||||
button.setText("预览")
|
||||
show_toast(self, f"图片预览失败:{friendly_error(error)}", "danger", 5200)
|
||||
|
||||
def _sync_case_field_folding(self) -> None:
|
||||
"""将未录入的可选病史字段折叠为底部快捷补录胶囊,保持主病历画布清爽高密。"""
|
||||
|
||||
if not hasattr(self, "_missing_field_pills"):
|
||||
return
|
||||
any_missing = False
|
||||
for key, pill in self._missing_field_pills.items():
|
||||
label = self.case_labels.get(key)
|
||||
frame = self._case_field_frames.get(key)
|
||||
text = (label.text().strip() if label is not None else "")
|
||||
is_empty = text in {"", "—", "-"}
|
||||
if frame is not None:
|
||||
frame.setVisible(not is_empty)
|
||||
pill.setVisible(is_empty)
|
||||
if is_empty:
|
||||
any_missing = True
|
||||
self._missing_fields_host.setVisible(any_missing)
|
||||
|
||||
def _reset_detail_content(self, seed: Any = None) -> None:
|
||||
for cancel_event in self._patient_ai_generation_cancel_events.values():
|
||||
cancel_event.set()
|
||||
@@ -9245,6 +9542,7 @@ class ReceptionPage(QWidget):
|
||||
self.add_tongue_button.setEnabled(note_enabled)
|
||||
self.add_report_button.setEnabled(note_enabled)
|
||||
self.save_note_button.setEnabled(note_enabled)
|
||||
self._sync_cockpit_and_context()
|
||||
|
||||
def _detail_error(
|
||||
self, error: Exception, generation: int, appointment_id: int | None = None
|
||||
@@ -9372,6 +9670,7 @@ class ReceptionPage(QWidget):
|
||||
self._reset_detail_content()
|
||||
self.detail_banner.clear()
|
||||
self.detail_stack.setCurrentIndex(0)
|
||||
self._sync_cockpit_and_context()
|
||||
|
||||
def _selection_context(self) -> tuple[int, int, int | None, int | None] | None:
|
||||
appointment_id = self._selected_appointment_id
|
||||
|
||||
@@ -26,20 +26,25 @@ _ORDERS = """
|
||||
}
|
||||
#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;
|
||||
min-height: 36px; max-height: 36px; padding: 0 15px; border: 1px solid $ds_line_strong;
|
||||
border-radius: $ds_radius_control; background: $ds_surface; color: $ds_text; font-weight: 500;
|
||||
}
|
||||
#PatientOrdersWorkspace QPushButton:hover, #PatientOrdersWorkspace QToolButton:hover {
|
||||
background: $ds_surface_alt; border-color: $ds_line_strong; color: $ds_accent;
|
||||
background: $ds_accent_soft; border-color: #9CCFC7; color: $ds_accent;
|
||||
}
|
||||
#PatientOrdersWorkspace QPushButton:pressed, #PatientOrdersWorkspace QToolButton:pressed { background: $ds_accent_soft; }
|
||||
#PatientOrdersWorkspace QPushButton:pressed, #PatientOrdersWorkspace QToolButton:pressed { background: #D7EFEA; }
|
||||
#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;
|
||||
color: $ds_surface;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $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#OrderDetailButton:hover {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $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,
|
||||
|
||||
@@ -61,18 +61,22 @@ _LIST = """
|
||||
}
|
||||
#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;
|
||||
min-height: 36px; max-height: 36px; padding: 0 15px;
|
||||
border: 1px solid $ds_line_strong; border-radius: $ds_radius_control; background: $ds_surface; font-weight: 500;
|
||||
}
|
||||
#PatientListWorkspace QPushButton:hover, #PatientSearchToolbar QPushButton:hover {
|
||||
color: $ds_accent; background: $ds_surface_alt; border-color: $ds_line_strong;
|
||||
color: $ds_accent; background: $ds_accent_soft; border-color: #9CCFC7;
|
||||
}
|
||||
#PatientListWorkspace QPushButton:pressed, #PatientSearchToolbar QPushButton:pressed { background: $ds_accent_soft; }
|
||||
#PatientListWorkspace QPushButton:pressed, #PatientSearchToolbar QPushButton:pressed { background: #D7EFEA; }
|
||||
#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;
|
||||
min-height: 36px; max-height: 36px; color: $ds_surface;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $ds_accent);
|
||||
border-color: $ds_accent;
|
||||
}
|
||||
#PatientSearchToolbar QPushButton#PatientSearchButton:hover {
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $ds_accent_hover);
|
||||
}
|
||||
#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 {
|
||||
|
||||
@@ -323,19 +323,21 @@ _LIBRARY = """
|
||||
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;
|
||||
min-height: 36px; max-height: 36px; padding: 0 15px; border-radius: $ds_radius_control;
|
||||
border: 1px solid $ds_line_strong; background: $ds_surface; color: $ds_text; font-weight: 500;
|
||||
}
|
||||
#PrescriptionLibraryPage QPushButton:hover { background: $ds_surface_alt; border-color: $ds_line_strong; color: $ds_accent; }
|
||||
#PrescriptionLibraryPage QPushButton:pressed { background: $ds_accent_soft; }
|
||||
#PrescriptionLibraryPage QPushButton:hover { background: $ds_accent_soft; border-color: #9CCFC7; color: $ds_accent; }
|
||||
#PrescriptionLibraryPage QPushButton:pressed { background: #D7EFEA; }
|
||||
#PrescriptionLibraryPage QPushButton:focus { border-color: $ds_focus; }
|
||||
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton,
|
||||
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton {
|
||||
background: $ds_accent; border-color: $ds_accent; color: $ds_surface;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $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;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $ds_accent_hover);
|
||||
border-color: $ds_accent_hover;
|
||||
}
|
||||
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryAddButton:pressed,
|
||||
#PrescriptionLibraryPage QPushButton#PrescriptionLibraryQueryButton:pressed {
|
||||
@@ -343,7 +345,7 @@ _LIBRARY = """
|
||||
}
|
||||
#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"] { color: $ds_danger; background: $ds_danger_soft; border-color: #F5C8CD; }
|
||||
#PrescriptionLibraryPage QPushButton[variant="danger"]:hover { border-color: $ds_danger; }
|
||||
#PrescriptionLibraryPage QPushButton[variant="danger"]:focus { border-color: $ds_focus; }
|
||||
#PrescriptionLibraryPage QPushButton:disabled,
|
||||
|
||||
@@ -31,24 +31,26 @@ _PRESCRIPTIONS = """
|
||||
}
|
||||
#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;
|
||||
min-height: 36px; max-height: 36px; padding: 0 15px; border-radius: $ds_radius_control;
|
||||
border: 1px solid $ds_line_strong; background: $ds_surface; color: $ds_text; font-weight: 500;
|
||||
}
|
||||
#PrescriptionsPage QPushButton:hover { background: $ds_surface_alt; border-color: $ds_line_strong; color: $ds_accent; }
|
||||
#PrescriptionsPage QPushButton:pressed { background: $ds_accent_soft; }
|
||||
#PrescriptionsPage QPushButton:hover { background: $ds_accent_soft; border-color: #9CCFC7; color: $ds_accent; }
|
||||
#PrescriptionsPage QPushButton:pressed { background: #D7EFEA; }
|
||||
#PrescriptionsPage QPushButton:focus { border-color: $ds_focus; }
|
||||
#PrescriptionsPage QPushButton#PrescriptionAddButton, #PrescriptionsPage QPushButton#PrescriptionQueryButton {
|
||||
background: $ds_accent; color: $ds_surface; border-color: $ds_accent;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $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;
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $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"] { color: $ds_danger; background: $ds_danger_soft; border-color: #F5C8CD; }
|
||||
#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,
|
||||
|
||||
@@ -169,23 +169,24 @@ QWidget#ReceptionPage QStackedWidget#ReceptionNarrowWorkspace {
|
||||
border: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionQueuePanel {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #EDF0F5;
|
||||
border-radius: 16px;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: $ds_radius_panel;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueTitle {
|
||||
font-size: 18px;
|
||||
color: $ds_heading;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueName {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueMeta,
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueTime,
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueSubline,
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueSummary {
|
||||
color: #5D6B80;
|
||||
color: $ds_muted;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
@@ -193,79 +194,137 @@ QWidget#ReceptionPage QLabel#ReceptionQueueMetric {
|
||||
font-size: 13px;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionQueueMetric[tone="description"] {
|
||||
color: #5D6B80;
|
||||
color: $ds_muted;
|
||||
font-size: 12px;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionHero,
|
||||
QWidget#ReceptionPage QFrame#ReceptionClinicalCard {
|
||||
min-height: 0;
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #EDF0F5;
|
||||
border-radius: 16px;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: $ds_radius_panel;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionPatientName {
|
||||
color: $ds_heading;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionPatientMeta {
|
||||
color: #5D6B80;
|
||||
color: $ds_muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionAvatar {
|
||||
color: #1555B6;
|
||||
background-color: #EAF2FF;
|
||||
color: $ds_accent;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #E9F6F4, stop:1 #CDEAE5);
|
||||
border: 1px solid #DFC793;
|
||||
border-radius: 12px;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs,
|
||||
QWidget#ReceptionPage QTabBar#ReceptionWorkspaceTabs {
|
||||
background-color: #FFFFFF;
|
||||
background-color: $ds_surface_alt;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #E5ECF6;
|
||||
border-top-left-radius: 16px;
|
||||
border-top-right-radius: 16px;
|
||||
border-bottom: 1px solid $ds_line;
|
||||
border-top-left-radius: $ds_radius_panel;
|
||||
border-top-right-radius: $ds_radius_panel;
|
||||
}
|
||||
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs::tab,
|
||||
QWidget#ReceptionPage QTabBar#ReceptionWorkspaceTabs::tab {
|
||||
min-height: 40px;
|
||||
margin: 0;
|
||||
padding: 0 14px;
|
||||
color: #5D6B80;
|
||||
padding: 0 15px;
|
||||
color: $ds_muted;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
border-radius: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
font-weight: 500;
|
||||
}
|
||||
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs::tab:first {
|
||||
margin-left: 0;
|
||||
padding-left: 14px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs::tab:hover,
|
||||
QWidget#ReceptionPage QTabBar#ReceptionWorkspaceTabs::tab:hover {
|
||||
color: #1769E8;
|
||||
background-color: #F3F7FD;
|
||||
color: $ds_accent;
|
||||
background-color: rgba(11, 110, 104, 14);
|
||||
}
|
||||
QWidget#ReceptionPage QTabBar#ReceptionDetailTabs::tab:selected,
|
||||
QWidget#ReceptionPage QTabBar#ReceptionWorkspaceTabs::tab:selected {
|
||||
color: #1769E8;
|
||||
color: $ds_accent;
|
||||
background-color: transparent;
|
||||
border-bottom: 2px solid #1769E8;
|
||||
font-weight: 500;
|
||||
border-bottom: 2px solid $ds_accent;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionHistoryCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QWidget#ReceptionCaseField {
|
||||
QWidget#ReceptionPage QWidget#ReceptionCaseField,
|
||||
QWidget#ReceptionPage QFrame#ReceptionCaseField {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #EDF1F7;
|
||||
border-bottom: 1px solid $ds_line;
|
||||
border-radius: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionCaseField[chiefFocus="true"] {
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #EEF9F7, stop:1 #FFFFFF);
|
||||
border: 1px solid #C6E3DE;
|
||||
border-left: 3px solid $ds_accent;
|
||||
border-radius: 10px;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionInlineAction {
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
padding: 0 10px;
|
||||
border-radius: 7px;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line_strong;
|
||||
color: $ds_accent;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionInlineAction:hover {
|
||||
background-color: $ds_accent_soft;
|
||||
border-color: #8FC8C0;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionInlineAiAction {
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
padding: 0 10px;
|
||||
border-radius: 7px;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #123433, stop:1 #091E1E);
|
||||
border: 1px solid rgba(223, 199, 147, 120);
|
||||
color: #DFC793;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionInlineAiAction:hover {
|
||||
background-color: #174240;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionMissingFieldsBar {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton[receptionQuickFill="true"] {
|
||||
min-height: 26px;
|
||||
max-height: 26px;
|
||||
padding: 0 10px;
|
||||
border-radius: 13px;
|
||||
background-color: $ds_surface_alt;
|
||||
border: 1px dashed $ds_line_strong;
|
||||
color: $ds_muted;
|
||||
font-size: 11.5px;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton[receptionQuickFill="true"]:hover {
|
||||
background-color: $ds_accent_soft;
|
||||
border: 1px solid $ds_accent;
|
||||
color: $ds_accent;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionCaseHeading {
|
||||
color: #202C3F;
|
||||
font-size: 16px;
|
||||
@@ -294,17 +353,17 @@ QWidget#ReceptionPage QLabel[receptionLifestyleChip="true"] {
|
||||
QWidget#ReceptionPage QFrame#ReceptionPatientSummaryCard,
|
||||
QWidget#ReceptionPage QFrame#ReceptionVitalsCard,
|
||||
QWidget#ReceptionPage QFrame#ReceptionLabsCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #EDF0F5;
|
||||
border-radius: 16px;
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: $ds_radius_panel;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionPatientSummaryValue {
|
||||
color: #24334A;
|
||||
color: $ds_heading;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionPatientSummaryValue[missing="true"] {
|
||||
color: #697386;
|
||||
color: $ds_muted;
|
||||
font-weight: 400;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionMetricCell,
|
||||
@@ -316,76 +375,109 @@ QWidget#ReceptionPage QFrame#ReceptionMetricCell[firstMetric="true"] {
|
||||
QWidget#ReceptionPage QLabel[receptionMetricCaption="true"],
|
||||
QWidget#ReceptionPage QLabel[receptionMetricUnit="true"],
|
||||
QWidget#ReceptionPage QLabel[receptionBmiState="true"] {
|
||||
color: #5D6B80;
|
||||
color: $ds_muted;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionMetricCell QLabel[receptionMetricValue="true"] {
|
||||
color: $ds_heading;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
font-weight: 600;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionLabCell {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
background-color: #FFFFFF;
|
||||
background-color: $ds_surface;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #EDF1F7;
|
||||
border-bottom: 1px solid $ds_line;
|
||||
border-radius: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionLabCell QLabel[receptionMetricValue="true"] {
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
font-weight: 500;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton#ReceptionMissingLabsButton {
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
padding: 0;
|
||||
color: #1769E8;
|
||||
color: $ds_accent;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel[receptionMetricState="true"] {
|
||||
min-height: 18px;
|
||||
padding: 0 5px;
|
||||
background-color: #F0F5FD;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 0 6px;
|
||||
background-color: $ds_accent_soft;
|
||||
border: 1px solid #C5E2DE;
|
||||
border-radius: $ds_radius_small;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
font-weight: 500;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel[receptionMetricState="true"][alert="true"] {
|
||||
color: #BE4B58;
|
||||
background-color: #FFF4F5;
|
||||
color: $ds_danger;
|
||||
background-color: $ds_danger_soft;
|
||||
border-color: #F5C8CD;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel[receptionMetricState="true"][alert="true"][warning="true"] {
|
||||
color: #A9691D;
|
||||
background-color: #FFF9EF;
|
||||
border-radius: 4px;
|
||||
color: $ds_warning;
|
||||
background-color: $ds_warning_soft;
|
||||
border-color: #F7DFB7;
|
||||
border-radius: $ds_radius_small;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionAiAnalysisCard,
|
||||
QWidget#ReceptionPage QFrame#ReceptionAiAssistantCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid $ds_line;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #103231, stop:0.6 #092020, stop:1 #061515);
|
||||
border: 1px solid rgba(223, 199, 147, 108);
|
||||
border-radius: $ds_radius_panel;
|
||||
}
|
||||
QWidget#ReceptionPage QFrame#ReceptionAiAnalysisCard QLabel,
|
||||
QWidget#ReceptionPage QFrame#ReceptionAiAssistantCard QLabel {
|
||||
color: #DDF0ED;
|
||||
background: transparent;
|
||||
}
|
||||
QWidget#ReceptionPage QStackedWidget#ReceptionAiAnalysisStack,
|
||||
QWidget#ReceptionPage QStackedWidget#ReceptionAiAnalysisStack > QWidget,
|
||||
QWidget#ReceptionPage QWidget#ReceptionAiAnalysisSections {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionAiTitle,
|
||||
QWidget#ReceptionPage QPushButton#ReceptionAiTitle {
|
||||
color: #DFC793;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
font-weight: 600;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
}
|
||||
QWidget#ReceptionPage QLabel#ReceptionAiAnalysisSnapshotMeta,
|
||||
QWidget#ReceptionPage QLabel#ReceptionAiAssistantHint {
|
||||
color: #5D6B80;
|
||||
font-size: 13px;
|
||||
color: #93B8B4;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
QWidget#ReceptionPage QComboBox#ReceptionAiAnalysisModelSelector {
|
||||
background-color: rgba(255, 255, 255, 22);
|
||||
border: 1px solid rgba(223, 199, 147, 92);
|
||||
border-radius: 7px;
|
||||
color: #F2FAF9;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton[receptionAiPrompt="true"] {
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
padding: 0 8px;
|
||||
padding: 0 9px;
|
||||
font-size: 12px;
|
||||
border-radius: 6px;
|
||||
border-radius: 7px;
|
||||
background-color: rgba(24, 176, 165, 42);
|
||||
border: 1px solid rgba(84, 230, 193, 96);
|
||||
color: #A8F3DF;
|
||||
}
|
||||
QWidget#ReceptionPage QPushButton[receptionAiPrompt="true"]:hover {
|
||||
background-color: rgba(24, 176, 165, 86);
|
||||
color: #FFFFFF;
|
||||
}
|
||||
QWidget#ReceptionPage QScrollArea#ReceptionInsightsScroll {
|
||||
background-color: transparent;
|
||||
|
||||
+2715
-2281
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
"""Cross-page reactive state stores for Clinical OS 3.0."""
|
||||
|
||||
from .patient_context_store import PatientContextStore, PatientSnapshot
|
||||
|
||||
__all__ = ["PatientContextStore", "PatientSnapshot"]
|
||||
@@ -0,0 +1,265 @@
|
||||
"""Global clinical patient context bus shared across spatial workstation views."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
|
||||
from ..widgets import display_text, first_value, gender_text
|
||||
|
||||
|
||||
def _safe_int(value: Any, default: int = 0) -> int:
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
|
||||
|
||||
def _mask_phone(raw: Any) -> str:
|
||||
text = str(raw or "").strip()
|
||||
if not text or text == "—":
|
||||
return "—"
|
||||
if "*" in text:
|
||||
return text
|
||||
digits = "".join(ch for ch in text if ch.isdigit())
|
||||
if len(digits) >= 7:
|
||||
return f"{digits[:3]}****{digits[-4:]}"
|
||||
return text
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PatientSnapshot:
|
||||
"""Immutable active-patient summary surfaced in the spatial shell header."""
|
||||
|
||||
appointment_id: int = 0
|
||||
diagnosis_id: int = 0
|
||||
patient_id: int = 0
|
||||
patient_name: str = "未选择患者"
|
||||
gender_age: str = ""
|
||||
phone: str = "—"
|
||||
course_text: str = ""
|
||||
clinical_diagnosis: str = "待选择接诊患者"
|
||||
chief_complaint: str = ""
|
||||
status_code: int = 0
|
||||
status_text: str = "待接诊"
|
||||
assistant_name: str = "—"
|
||||
doctor_name: str = "—"
|
||||
appointment_time: str = ""
|
||||
raw_record: dict[str, Any] = field(default_factory=dict, compare=False)
|
||||
|
||||
@property
|
||||
def has_patient(self) -> bool:
|
||||
return bool(
|
||||
self.appointment_id > 0
|
||||
or self.diagnosis_id > 0
|
||||
or self.patient_id > 0
|
||||
or (self.patient_name and self.patient_name not in {"—", "未选择患者"})
|
||||
)
|
||||
|
||||
@property
|
||||
def subtitle_line(self) -> str:
|
||||
parts = [
|
||||
part
|
||||
for part in (
|
||||
self.gender_age,
|
||||
self.clinical_diagnosis if self.clinical_diagnosis != "—" else "",
|
||||
f"病程 {self.course_text}" if self.course_text and self.course_text != "—" else "",
|
||||
self.appointment_time,
|
||||
)
|
||||
if part
|
||||
]
|
||||
return " · ".join(parts[:3]) if parts else "从今日门诊计划或挂号队列选择患者"
|
||||
|
||||
|
||||
class PatientContextStore(QObject):
|
||||
"""Reactive store broadcasting active patient and bottom-sheet state across pages."""
|
||||
|
||||
active_patient_changed = Signal(object)
|
||||
active_appointment_changed = Signal(int)
|
||||
bottom_sheet_mode_changed = Signal(bool)
|
||||
cockpit_mode_changed = Signal(str)
|
||||
|
||||
def __init__(self, parent: QObject | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self._current_patient = PatientSnapshot()
|
||||
self._bottom_sheet_expanded = False
|
||||
self._cockpit_mode = "cockpit"
|
||||
|
||||
@property
|
||||
def current_patient(self) -> PatientSnapshot:
|
||||
return self._current_patient
|
||||
|
||||
@property
|
||||
def bottom_sheet_expanded(self) -> bool:
|
||||
return self._bottom_sheet_expanded
|
||||
|
||||
@property
|
||||
def cockpit_mode(self) -> str:
|
||||
return self._cockpit_mode
|
||||
|
||||
def set_bottom_sheet_expanded(self, expanded: bool) -> None:
|
||||
target = bool(expanded)
|
||||
if self._bottom_sheet_expanded == target:
|
||||
return
|
||||
self._bottom_sheet_expanded = target
|
||||
self.bottom_sheet_mode_changed.emit(target)
|
||||
|
||||
def toggle_bottom_sheet(self) -> bool:
|
||||
self.set_bottom_sheet_expanded(not self._bottom_sheet_expanded)
|
||||
return self._bottom_sheet_expanded
|
||||
|
||||
def set_cockpit_mode(self, mode: str) -> None:
|
||||
normalized = "chart" if str(mode).strip().lower() == "chart" else "cockpit"
|
||||
if self._cockpit_mode == normalized:
|
||||
return
|
||||
self._cockpit_mode = normalized
|
||||
self.cockpit_mode_changed.emit(normalized)
|
||||
|
||||
def clear(self) -> None:
|
||||
empty = PatientSnapshot()
|
||||
if self._current_patient == empty:
|
||||
return
|
||||
self._current_patient = empty
|
||||
self.active_patient_changed.emit(empty)
|
||||
self.active_appointment_changed.emit(0)
|
||||
|
||||
def set_snapshot(self, snapshot: PatientSnapshot) -> None:
|
||||
previous_appointment = self._current_patient.appointment_id
|
||||
if self._current_patient == snapshot:
|
||||
return
|
||||
self._current_patient = snapshot
|
||||
self.active_patient_changed.emit(snapshot)
|
||||
if snapshot.appointment_id != previous_appointment:
|
||||
self.active_appointment_changed.emit(snapshot.appointment_id)
|
||||
|
||||
def update_from_reception(
|
||||
self,
|
||||
appointment: Any,
|
||||
patient: Any = None,
|
||||
diagnosis: Any = None,
|
||||
) -> PatientSnapshot:
|
||||
"""Build and publish a rich snapshot from reception detail payloads."""
|
||||
|
||||
sources = (diagnosis or {}, patient or {}, appointment or {})
|
||||
name = display_text(
|
||||
first_value(
|
||||
appointment,
|
||||
"patient_name",
|
||||
"name",
|
||||
default=first_value(patient, "name", "patient_name", default="患者"),
|
||||
)
|
||||
)
|
||||
raw_gender = next(
|
||||
(
|
||||
first_value(src, "gender_desc", "gender", default=None)
|
||||
for src in sources
|
||||
if first_value(src, "gender_desc", "gender", default=None) not in (None, "")
|
||||
),
|
||||
"",
|
||||
)
|
||||
gender = gender_text(raw_gender) if raw_gender not in (None, "") else ""
|
||||
age = first_value(
|
||||
diagnosis,
|
||||
"age",
|
||||
default=first_value(patient, "age", default=first_value(appointment, "age", default="")),
|
||||
)
|
||||
gender_age = " · ".join(
|
||||
part
|
||||
for part in (
|
||||
gender if gender and gender != "—" else "",
|
||||
f"{age}岁" if age not in (None, "", "—") else "",
|
||||
)
|
||||
if part
|
||||
)
|
||||
phone = _mask_phone(
|
||||
first_value(
|
||||
patient,
|
||||
"phone",
|
||||
"mobile",
|
||||
default=first_value(appointment, "patient_phone", "phone", default="—"),
|
||||
)
|
||||
)
|
||||
course = display_text(
|
||||
first_value(
|
||||
diagnosis,
|
||||
"disease_course_text",
|
||||
"diabetes_history_text",
|
||||
"diabetes_discovery_year_text",
|
||||
default="",
|
||||
),
|
||||
"",
|
||||
)
|
||||
clinical_diag = display_text(
|
||||
first_value(
|
||||
diagnosis,
|
||||
"clinical_diagnosis",
|
||||
"diagnosis_name",
|
||||
"disease_name",
|
||||
default="中医糖代谢调理",
|
||||
)
|
||||
)
|
||||
chief = display_text(
|
||||
first_value(diagnosis, "chief_complaint", "complaint", default=""),
|
||||
"",
|
||||
)
|
||||
status_code = _safe_int(first_value(appointment, "status", default=1), 1)
|
||||
status_map = {1: "待接诊", 2: "已取消", 3: "已完成", 4: "已过号"}
|
||||
status_text = display_text(
|
||||
first_value(
|
||||
appointment,
|
||||
"status_desc",
|
||||
"status_text",
|
||||
default=status_map.get(status_code, "待接诊"),
|
||||
)
|
||||
)
|
||||
appt_id = _safe_int(first_value(appointment, "id", "appointment_id", default=0))
|
||||
diag_id = _safe_int(
|
||||
first_value(
|
||||
diagnosis,
|
||||
"id",
|
||||
"diagnosis_id",
|
||||
default=first_value(appointment, "diagnosis_id", "patient_id", default=0),
|
||||
)
|
||||
)
|
||||
pat_id = _safe_int(
|
||||
first_value(
|
||||
appointment,
|
||||
"source_patient_id",
|
||||
"patient_id",
|
||||
default=first_value(patient, "id", "source_patient_id", default=0),
|
||||
)
|
||||
)
|
||||
raw: dict[str, Any] = {}
|
||||
if isinstance(appointment, dict):
|
||||
raw.update(appointment)
|
||||
snapshot = PatientSnapshot(
|
||||
appointment_id=appt_id,
|
||||
diagnosis_id=diag_id,
|
||||
patient_id=pat_id,
|
||||
patient_name=name,
|
||||
gender_age=gender_age,
|
||||
phone=phone,
|
||||
course_text=course,
|
||||
clinical_diagnosis=clinical_diag,
|
||||
chief_complaint=chief,
|
||||
status_code=status_code,
|
||||
status_text=status_text,
|
||||
assistant_name=display_text(first_value(appointment, "assistant_name", default="—")),
|
||||
doctor_name=display_text(first_value(appointment, "doctor_name", default="—")),
|
||||
appointment_time=display_text(
|
||||
first_value(appointment, "appointment_time_text", "appointment_time", default=""),
|
||||
"",
|
||||
),
|
||||
raw_record=raw,
|
||||
)
|
||||
self.set_snapshot(snapshot)
|
||||
return snapshot
|
||||
|
||||
def update_from_row(self, row: Any) -> PatientSnapshot:
|
||||
"""Build and publish a lightweight snapshot when selecting a list/table row."""
|
||||
|
||||
if not row:
|
||||
return self._current_patient
|
||||
return self.update_from_reception(row, row, row)
|
||||
@@ -40,7 +40,7 @@ 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 . import interactions, motion
|
||||
from .design_system import PALETTE, RADII, SPACING, clinical_stylesheet
|
||||
|
||||
# Shared reading colors keep native pages and dialog chrome consistent.
|
||||
@@ -81,6 +81,11 @@ COLORS = {
|
||||
"teal": PALETTE["accent"],
|
||||
"teal_dark": PALETTE["accent_pressed"],
|
||||
"teal_pale": PALETTE["accent_soft"],
|
||||
"gold": PALETTE["gold"],
|
||||
"gold_light": PALETTE["gold_light"],
|
||||
"gold_soft": PALETTE["gold_soft"],
|
||||
"obsidian": PALETTE["obsidian"],
|
||||
"obsidian_alt": PALETTE["obsidian_alt"],
|
||||
}
|
||||
|
||||
|
||||
@@ -375,12 +380,12 @@ QPushButton:disabled {
|
||||
|
||||
QPushButton[variant="primary"] {
|
||||
color: #FFFFFF;
|
||||
background-color: $indigo;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #12857D, stop:1 $indigo);
|
||||
border-color: $indigo;
|
||||
}
|
||||
QPushButton[variant="primary"]:hover,
|
||||
QPushButton[variant="primary"]:checked:hover {
|
||||
background-color: $indigo_hover;
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #0E726B, stop:1 $indigo_hover);
|
||||
border-color: $indigo_hover;
|
||||
}
|
||||
QPushButton[variant="primary"]:pressed,
|
||||
@@ -389,7 +394,7 @@ QPushButton[variant="primary"]:checked {
|
||||
border-color: $indigo_pressed;
|
||||
}
|
||||
QPushButton[variant="primary"]:focus {
|
||||
border: 1px solid $indigo_pressed;
|
||||
border: 1px solid $focus;
|
||||
background-color: $indigo_hover;
|
||||
}
|
||||
QPushButton[variant="primary"]:disabled {
|
||||
@@ -401,12 +406,12 @@ QPushButton[variant="primary"]:disabled {
|
||||
QPushButton[variant="secondary"] {
|
||||
color: $indigo_hover;
|
||||
background-color: $indigo_pale;
|
||||
border-color: $indigo_pale;
|
||||
border-color: #C4E2DD;
|
||||
}
|
||||
QPushButton[variant="secondary"]:hover {
|
||||
color: $indigo_pressed;
|
||||
background-color: $raised;
|
||||
border-color: $indigo_hover;
|
||||
background-color: #D7EFEA;
|
||||
border-color: #9CCFC7;
|
||||
}
|
||||
QPushButton[variant="secondary"]:pressed,
|
||||
QPushButton[variant="secondary"]:checked {
|
||||
@@ -616,7 +621,7 @@ QLineEdit, QTextEdit, QPlainTextEdit, QComboBox, QDateEdit, QDateTimeEdit,
|
||||
QTimeEdit, QSpinBox, QDoubleSpinBox, QKeySequenceEdit {
|
||||
min-height: $h_default;
|
||||
padding: 0 $pad_control;
|
||||
border: 1px solid $line;
|
||||
border: 1px solid $line_soft;
|
||||
border-radius: $r_md;
|
||||
background-color: $surface;
|
||||
color: $text;
|
||||
@@ -626,11 +631,11 @@ QTimeEdit, QSpinBox, QDoubleSpinBox, QKeySequenceEdit {
|
||||
QTextEdit, QPlainTextEdit { padding: 7px $pad_control; }
|
||||
QLineEdit:hover, QTextEdit:hover, QPlainTextEdit:hover, QComboBox:hover,
|
||||
QDateEdit:hover, QDateTimeEdit:hover, QTimeEdit:hover, QSpinBox:hover,
|
||||
QDoubleSpinBox:hover, QKeySequenceEdit:hover { border-color: $indigo_hover; }
|
||||
QDoubleSpinBox:hover, QKeySequenceEdit:hover { border-color: #8FBDB6; }
|
||||
QLineEdit:focus, QTextEdit:focus, QPlainTextEdit:focus, QComboBox:focus,
|
||||
QDateEdit:focus, QDateTimeEdit:focus, QTimeEdit:focus, QSpinBox:focus,
|
||||
QDoubleSpinBox:focus, QKeySequenceEdit:focus {
|
||||
border: 1px solid $indigo;
|
||||
border: 1.5px solid $focus;
|
||||
background-color: $surface;
|
||||
}
|
||||
QLineEdit:read-only, QTextEdit:read-only, QPlainTextEdit:read-only {
|
||||
@@ -1500,15 +1505,28 @@ def _size_new_window_to_main(window: QWidget) -> None:
|
||||
|
||||
target_width = target.width()
|
||||
target_height = target.height()
|
||||
if window.minimumWidth() > target_width:
|
||||
window.setMinimumWidth(target_width)
|
||||
if window.minimumHeight() > target_height:
|
||||
window.setMinimumHeight(target_height)
|
||||
if window.maximumWidth() < target_width:
|
||||
window.setMaximumWidth(target_width)
|
||||
if window.maximumHeight() < target_height:
|
||||
window.setMaximumHeight(target_height)
|
||||
window.resize(target_width, target_height)
|
||||
# 紧凑业务轻弹窗(如二维码、完成确认、收退款、更新等)保持自身合理尺寸并居中,
|
||||
# 仅大型工作台窗口(宽>=760 且高>=640)扩展至主视窗 85%,避免小窗被强行撑大造成内容错位。
|
||||
current_size = window.size()
|
||||
hint_size = window.sizeHint()
|
||||
desired_w = max(current_size.width(), hint_size.width(), window.minimumWidth())
|
||||
desired_h = max(current_size.height(), hint_size.height(), window.minimumHeight())
|
||||
is_compact_dialog = isinstance(window, QDialog) and (desired_w < 760 or desired_h < 640)
|
||||
if is_compact_dialog:
|
||||
final_width = min(desired_w, target_width)
|
||||
final_height = min(desired_h, target_height)
|
||||
else:
|
||||
final_width = target_width
|
||||
final_height = target_height
|
||||
if window.minimumWidth() > final_width:
|
||||
window.setMinimumWidth(final_width)
|
||||
if window.minimumHeight() > final_height:
|
||||
window.setMinimumHeight(final_height)
|
||||
if window.maximumWidth() < final_width:
|
||||
window.setMaximumWidth(final_width)
|
||||
if window.maximumHeight() < final_height:
|
||||
window.setMaximumHeight(final_height)
|
||||
window.resize(final_width, final_height)
|
||||
frame = window.frameGeometry()
|
||||
window.move(
|
||||
target.center().x() - frame.width() // 2,
|
||||
@@ -1583,6 +1601,7 @@ class _BusinessDialogStyleFilter(QObject):
|
||||
|
||||
|
||||
def _install_business_dialog_styling(app: QApplication) -> None:
|
||||
interactions.install_tactile_interactions(app)
|
||||
existing = getattr(app, "_doctor_business_dialog_style_filter", None)
|
||||
if existing is not None:
|
||||
return
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Presentation view-models for the Clinical OS 3.0 workstation."""
|
||||
|
||||
from .cockpit_vm import (
|
||||
AuroraCardVM,
|
||||
CareJourneyVM,
|
||||
CockpitSnapshotVM,
|
||||
DiurnalSlot,
|
||||
DiurnalStabilityVM,
|
||||
GlycemicProgressionVM,
|
||||
JourneyDayCell,
|
||||
JourneyPhaseSpan,
|
||||
ObsidianAuroraVM,
|
||||
ProgressionPoint,
|
||||
SyndromeTwinVM,
|
||||
TwinCalloutNode,
|
||||
VitalMiniBrick,
|
||||
derive_cockpit_snapshot,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"AuroraCardVM",
|
||||
"CareJourneyVM",
|
||||
"CockpitSnapshotVM",
|
||||
"DiurnalSlot",
|
||||
"DiurnalStabilityVM",
|
||||
"GlycemicProgressionVM",
|
||||
"JourneyDayCell",
|
||||
"JourneyPhaseSpan",
|
||||
"ObsidianAuroraVM",
|
||||
"ProgressionPoint",
|
||||
"SyndromeTwinVM",
|
||||
"TwinCalloutNode",
|
||||
"VitalMiniBrick",
|
||||
"derive_cockpit_snapshot",
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
"""Hardware-antialiased QPainter medical micro-charts & digital twin widgets."""
|
||||
|
||||
from .aurora_sheet import ArcRhythmGaugeWidget, AuroraGlassCardWidget, CollapsibleObsidianSheet
|
||||
from .context_bridge_bar import SpatialContextBridgeBar
|
||||
from .diurnal_strip import DiurnalStabilityCard
|
||||
from .journey_track import CareJourneyCard
|
||||
from .pill_chart import PillProgressionCard
|
||||
from .reception_cockpit import ReceptionDigitalTwinCockpit
|
||||
from .twin_stage import ClinicalTwinStageWidget
|
||||
from .week_strip import WeekCalendarStripWidget
|
||||
|
||||
__all__ = [
|
||||
"ArcRhythmGaugeWidget",
|
||||
"AuroraGlassCardWidget",
|
||||
"CareJourneyCard",
|
||||
"ClinicalTwinStageWidget",
|
||||
"CollapsibleObsidianSheet",
|
||||
"DiurnalStabilityCard",
|
||||
"PillProgressionCard",
|
||||
"ReceptionDigitalTwinCockpit",
|
||||
"SpatialContextBridgeBar",
|
||||
"WeekCalendarStripWidget",
|
||||
]
|
||||
@@ -0,0 +1,522 @@
|
||||
"""Pull-Up Deep Obsidian Aurora-Glass AI Sheet bound strictly to real AI reports."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, Qt, Signal
|
||||
from PySide6.QtGui import (
|
||||
QColor,
|
||||
QFont,
|
||||
QMouseEvent,
|
||||
QPainter,
|
||||
QPainterPath,
|
||||
QPen,
|
||||
QRadialGradient,
|
||||
QTextOption,
|
||||
)
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QSizePolicy,
|
||||
QToolTip,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from ..reception_style import body_family, heading_family, number_family
|
||||
from ..viewmodels.cockpit_vm import AuroraCardVM, ObsidianAuroraVM
|
||||
|
||||
|
||||
class AuroraGlassCardWidget(QWidget):
|
||||
"""Frosted dark Aurora-Mesh card displaying real backend AI narrative & risks."""
|
||||
|
||||
clicked = Signal()
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("AuroraGlassCardWidget")
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.setMinimumSize(196, 152)
|
||||
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
self.setFixedHeight(162)
|
||||
self._vm: AuroraCardVM | None = None
|
||||
self._hovered = False
|
||||
|
||||
def set_view_model(self, vm: AuroraCardVM) -> None:
|
||||
self._vm = vm
|
||||
self.setToolTip(vm.body_text)
|
||||
self.update()
|
||||
|
||||
def enterEvent(self, event: object) -> None: # noqa: N802
|
||||
self._hovered = True
|
||||
self.update()
|
||||
super().enterEvent(event) # type: ignore[arg-type]
|
||||
|
||||
def leaveEvent(self, event: object) -> None: # noqa: N802
|
||||
self._hovered = False
|
||||
self.update()
|
||||
super().leaveEvent(event) # type: ignore[arg-type]
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
self.clicked.emit()
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect()).adjusted(1.0, 1.0, -1.0, -1.0)
|
||||
path = QPainterPath()
|
||||
path.addRoundedRect(rect, 20.0, 20.0)
|
||||
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(path, QColor(32, 40, 39, 240))
|
||||
|
||||
vm = self._vm
|
||||
tint = vm.tint if vm else "cyan"
|
||||
glow1 = QRadialGradient(
|
||||
QPointF(rect.left() + rect.width() * 0.75, rect.top() + rect.height() * 0.32),
|
||||
rect.width() * 0.72,
|
||||
)
|
||||
if tint == "cyan":
|
||||
glow1.setColorAt(0.0, QColor(88, 168, 182, 98))
|
||||
glow1.setColorAt(0.55, QColor(58, 118, 130, 52))
|
||||
glow1.setColorAt(1.0, QColor(28, 38, 38, 0))
|
||||
accent_c = QColor("#A9DCE4")
|
||||
elif tint == "olive":
|
||||
glow1.setColorAt(0.0, QColor(148, 162, 72, 96))
|
||||
glow1.setColorAt(0.55, QColor(96, 112, 48, 52))
|
||||
glow1.setColorAt(1.0, QColor(28, 38, 32, 0))
|
||||
accent_c = QColor("#DCE694")
|
||||
else:
|
||||
glow1.setColorAt(0.0, QColor(206, 128, 86, 102))
|
||||
glow1.setColorAt(0.55, QColor(142, 84, 58, 54))
|
||||
glow1.setColorAt(1.0, QColor(38, 30, 28, 0))
|
||||
accent_c = QColor("#F2C4A8")
|
||||
|
||||
painter.fillPath(path, glow1)
|
||||
painter.setPen(QPen(QColor(255, 255, 255, 78 if self._hovered else 42), 1.0))
|
||||
painter.drawPath(path)
|
||||
|
||||
if vm is None:
|
||||
return
|
||||
|
||||
left = rect.left() + 16.0
|
||||
right = rect.right() - 16.0
|
||||
avail_w = max(120.0, right - left)
|
||||
|
||||
# Header: Accent dot + Title + Status Badge Pill
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(accent_c)
|
||||
painter.drawEllipse(QPointF(left + 5, rect.top() + 21), 4.0, 4.0)
|
||||
|
||||
t_font = QFont(heading_family())
|
||||
t_font.setPixelSize(14)
|
||||
t_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(t_font)
|
||||
painter.setPen(QColor("#F6FAF9"))
|
||||
painter.drawText(
|
||||
QRectF(left + 15, rect.top() + 11, avail_w - 86, 20),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.title,
|
||||
)
|
||||
|
||||
b_font = QFont(body_family())
|
||||
b_font.setPixelSize(10)
|
||||
b_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(b_font)
|
||||
bw = float(painter.fontMetrics().horizontalAdvance(vm.badge_text) + 16)
|
||||
b_rect = QRectF(right - bw, rect.top() + 12, bw, 19)
|
||||
bp = QPainterPath()
|
||||
bp.addRoundedRect(b_rect, 9.5, 9.5)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(bp, QColor(255, 255, 255, 28))
|
||||
painter.setPen(accent_c)
|
||||
painter.drawText(b_rect, Qt.AlignmentFlag.AlignCenter, vm.badge_text)
|
||||
|
||||
s_font = QFont(body_family())
|
||||
s_font.setPixelSize(11)
|
||||
painter.setFont(s_font)
|
||||
painter.setPen(QColor(215, 230, 227, 160))
|
||||
painter.drawText(
|
||||
QRectF(left + 15, rect.top() + 31, avail_w - 16, 15),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.subtitle,
|
||||
)
|
||||
|
||||
# Divider line
|
||||
painter.setPen(QPen(QColor(255, 255, 255, 24), 1.0))
|
||||
painter.drawLine(QPointF(left, rect.top() + 51), QPointF(right, rect.top() + 51))
|
||||
|
||||
# Real AI Narrative Body (clean wrapped clinical text, max 4 lines)
|
||||
body_font = QFont(body_family())
|
||||
body_font.setPixelSize(12)
|
||||
painter.setFont(body_font)
|
||||
painter.setPen(QColor("#EEF5F3"))
|
||||
body_box = QRectF(left, rect.top() + 57, avail_w, 74)
|
||||
opt = QTextOption(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
|
||||
opt.setWrapMode(QTextOption.WrapMode.WordWrap)
|
||||
text_to_draw = vm.body_text
|
||||
if len(text_to_draw) > 108:
|
||||
text_to_draw = f"{text_to_draw[:106]}…"
|
||||
painter.drawText(body_box, text_to_draw, opt)
|
||||
|
||||
# Footer metadata
|
||||
painter.setFont(s_font)
|
||||
painter.setPen(QColor(210, 226, 223, 155))
|
||||
painter.drawText(
|
||||
QRectF(left, rect.bottom() - 23, avail_w * 0.62, 16),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.foot_left,
|
||||
)
|
||||
painter.setPen(accent_c)
|
||||
painter.drawText(
|
||||
QRectF(right - avail_w * 0.38, rect.bottom() - 23, avail_w * 0.38, 16),
|
||||
Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.foot_right,
|
||||
)
|
||||
|
||||
|
||||
class ArcRhythmGaugeWidget(QWidget):
|
||||
"""Objective 6-dimension Clinical Record Completeness speedometer gauge."""
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("ArcRhythmGaugeWidget")
|
||||
self.setMouseTracking(True)
|
||||
self.setFixedSize(202, 162)
|
||||
self._value_text = "0/6"
|
||||
self._unit_text = "项"
|
||||
self._caption = "病历实采完备度"
|
||||
self._ratio = 0.08
|
||||
self._tooltip = ""
|
||||
|
||||
def set_gauge(
|
||||
self,
|
||||
value_text: str,
|
||||
unit_text: str,
|
||||
caption: str,
|
||||
ratio: float,
|
||||
tooltip: str = "",
|
||||
) -> None:
|
||||
self._value_text = value_text
|
||||
self._unit_text = unit_text
|
||||
self._caption = caption
|
||||
self._ratio = max(0.05, min(1.0, ratio))
|
||||
self._tooltip = tooltip
|
||||
self.setToolTip(tooltip)
|
||||
self.update()
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if self._tooltip:
|
||||
QToolTip.showText(event.globalPosition().toPoint(), self._tooltip, self)
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect())
|
||||
cx = rect.center().x()
|
||||
cy = rect.top() + 92.0
|
||||
radius = 66.0
|
||||
arc_box = QRectF(cx - radius, cy - radius, radius * 2.0, radius * 2.0)
|
||||
|
||||
hemi = QRadialGradient(QPointF(cx, cy), radius)
|
||||
hemi.setColorAt(0.0, QColor(255, 255, 255, 24))
|
||||
hemi.setColorAt(1.0, QColor(255, 255, 255, 0))
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(hemi)
|
||||
painter.drawPie(arc_box.adjusted(10, 10, -10, -10), 0, 180 * 16)
|
||||
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(QPen(QColor(255, 255, 255, 42), 3.0, Qt.PenStyle.SolidLine, Qt.PenCapStyle.RoundCap))
|
||||
painter.drawArc(arc_box, 0, 180 * 16)
|
||||
|
||||
span_deg = self._ratio * 180.0
|
||||
painter.setPen(QPen(QColor("#8CE0CB"), 3.4, Qt.PenStyle.SolidLine, Qt.PenCapStyle.RoundCap))
|
||||
painter.drawArc(arc_box, int(180 * 16), int(-span_deg * 16))
|
||||
|
||||
# 6 dimension ticks along semi-circle
|
||||
for step in range(7):
|
||||
angle_rad = math.pi - (step / 6.0) * math.pi
|
||||
p1 = QPointF(cx + math.cos(angle_rad) * (radius - 8), cy - math.sin(angle_rad) * (radius - 8))
|
||||
p2 = QPointF(cx + math.cos(angle_rad) * (radius - 14), cy - math.sin(angle_rad) * (radius - 14))
|
||||
painter.setPen(QPen(QColor(255, 255, 255, 78), 1.2))
|
||||
painter.drawLine(p1, p2)
|
||||
|
||||
needle_rad = math.pi - self._ratio * math.pi
|
||||
tip = QPointF(cx + math.cos(needle_rad) * (radius - 5), cy - math.sin(needle_rad) * (radius - 5))
|
||||
arc_dot = QPointF(cx + math.cos(needle_rad) * radius, cy - math.sin(needle_rad) * radius)
|
||||
painter.setPen(QPen(QColor(255, 255, 255, 210), 1.6))
|
||||
painter.drawLine(QPointF(cx, cy), tip)
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor("#FFFFFF"))
|
||||
painter.drawEllipse(QPointF(cx, cy), 3.5, 3.5)
|
||||
painter.drawEllipse(arc_dot, 4.0, 4.0)
|
||||
|
||||
cap_font = QFont(body_family())
|
||||
cap_font.setPixelSize(11)
|
||||
painter.setFont(cap_font)
|
||||
painter.setPen(QColor(210, 224, 222, 185))
|
||||
painter.drawText(QRectF(0, cy + 7, rect.width(), 16), Qt.AlignmentFlag.AlignCenter, self._caption)
|
||||
|
||||
val_font = QFont(number_family())
|
||||
val_font.setPixelSize(27)
|
||||
val_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(val_font)
|
||||
painter.setPen(QColor("#FFFFFF"))
|
||||
vw = float(painter.fontMetrics().horizontalAdvance(self._value_text))
|
||||
total_w = vw + 26.0
|
||||
vx = cx - total_w * 0.5
|
||||
painter.drawText(
|
||||
QRectF(vx, cy + 24, vw + 4, 34),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
self._value_text,
|
||||
)
|
||||
|
||||
painter.setFont(cap_font)
|
||||
painter.setPen(QColor(210, 224, 222, 170))
|
||||
painter.drawText(QRectF(vx + vw + 5, cy + 31, 30, 22), Qt.AlignmentFlag.AlignLeft, self._unit_text)
|
||||
|
||||
|
||||
class CollapsibleObsidianSheet(QWidget):
|
||||
"""Bottom pull-up obsidian sheet displaying real Qwen / OpenAI / Doubao clinical reports."""
|
||||
|
||||
expanded_changed = Signal(bool)
|
||||
open_ai_report_requested = Signal()
|
||||
open_ai_consult_requested = Signal()
|
||||
model_selected = Signal(str)
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("CollapsibleObsidianSheet")
|
||||
self.setMouseTracking(True)
|
||||
self._expanded = False
|
||||
self._handle_rect = QRectF()
|
||||
self._vm: ObsidianAuroraVM | None = None
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(22, 24, 22, 14)
|
||||
root.setSpacing(10)
|
||||
|
||||
top_bar = QHBoxLayout()
|
||||
top_bar.setContentsMargins(0, 0, 0, 0)
|
||||
top_bar.setSpacing(10)
|
||||
|
||||
self.title_label = QLabel("AI 病历循证分析舱", self)
|
||||
self.title_label.setStyleSheet(
|
||||
"color: #F6FAF9; font-size: 15px; font-weight: 600; background: transparent;"
|
||||
)
|
||||
top_bar.addWidget(self.title_label)
|
||||
|
||||
self.summary_label = QLabel("选择患者后自动读取千问 / OpenAI / 豆包实采病历分析报告", self)
|
||||
self.summary_label.setStyleSheet(
|
||||
"color: rgba(220, 234, 231, 185); font-size: 12px; background: transparent;"
|
||||
)
|
||||
self.summary_label.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
|
||||
top_bar.addWidget(self.summary_label, 1)
|
||||
|
||||
self._model_buttons: dict[str, QPushButton] = {}
|
||||
for m_key, m_text in (("qwen", "千问"), ("openai", "OpenAI"), ("doubao", "豆包")):
|
||||
btn = QPushButton(m_text, self)
|
||||
btn.setCheckable(True)
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn.setFixedHeight(26)
|
||||
btn.clicked.connect(lambda _c=False, k=m_key: self._choose_model(k))
|
||||
self._model_buttons[m_key] = btn
|
||||
top_bar.addWidget(btn)
|
||||
self._sync_model_pill_styles("qwen")
|
||||
|
||||
self.report_button = QPushButton("完整循证报告", self)
|
||||
self.report_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.report_button.setFixedHeight(28)
|
||||
self.report_button.setStyleSheet(
|
||||
"QPushButton { background: rgba(255,255,255,22); color: #F2F7F6;"
|
||||
" border: 1px solid rgba(255,255,255,48); border-radius: 14px; padding: 0 13px; font-size: 12px; }"
|
||||
"QPushButton:hover { background: rgba(255,255,255,40); }"
|
||||
)
|
||||
self.report_button.clicked.connect(self.open_ai_report_requested.emit)
|
||||
top_bar.addWidget(self.report_button)
|
||||
|
||||
self.consult_button = QPushButton("AI 深度对话", self)
|
||||
self.consult_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.consult_button.setFixedHeight(28)
|
||||
self.consult_button.setStyleSheet(
|
||||
"QPushButton { background: #0E6F5C; color: #FFFFFF;"
|
||||
" border: 0; border-radius: 14px; padding: 0 14px; font-size: 12px; font-weight: 600; }"
|
||||
"QPushButton:hover { background: #138770; }"
|
||||
)
|
||||
self.consult_button.clicked.connect(self.open_ai_consult_requested.emit)
|
||||
top_bar.addWidget(self.consult_button)
|
||||
|
||||
self.toggle_button = QPushButton("展开分析舱 ▲", self)
|
||||
self.toggle_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.toggle_button.setFixedHeight(28)
|
||||
self.toggle_button.setStyleSheet(
|
||||
"QPushButton { background: rgba(223,199,147,26); color: #EAD7AC;"
|
||||
" border: 1px solid rgba(223,199,147,90); border-radius: 14px; padding: 0 12px; font-size: 12px; font-weight: 600; }"
|
||||
"QPushButton:hover { background: rgba(223,199,147,48); }"
|
||||
)
|
||||
self.toggle_button.clicked.connect(self.toggle_expanded)
|
||||
top_bar.addWidget(self.toggle_button)
|
||||
root.addLayout(top_bar)
|
||||
|
||||
self.body_widget = QWidget(self)
|
||||
body_layout = QHBoxLayout(self.body_widget)
|
||||
body_layout.setContentsMargins(0, 4, 0, 2)
|
||||
body_layout.setSpacing(14)
|
||||
|
||||
left_col = QWidget(self.body_widget)
|
||||
left_col.setFixedWidth(196)
|
||||
left_layout = QVBoxLayout(left_col)
|
||||
left_layout.setContentsMargins(0, 0, 0, 0)
|
||||
left_layout.setSpacing(8)
|
||||
self._param_rows: list[tuple[QLabel, QLabel]] = []
|
||||
for _ in range(3):
|
||||
pill = QFrame(left_col)
|
||||
pill.setFixedHeight(46)
|
||||
pill.setStyleSheet(
|
||||
"QFrame { background: rgba(255,255,255,14); border: 1px solid rgba(255,255,255,24); border-radius: 13px; }"
|
||||
)
|
||||
pl = QHBoxLayout(pill)
|
||||
pl.setContentsMargins(13, 0, 13, 0)
|
||||
k_lbl = QLabel("状态", pill)
|
||||
k_lbl.setStyleSheet("color: rgba(225,236,234,195); font-size: 12px; border: 0; background: transparent;")
|
||||
sep_lbl = QLabel("|", pill)
|
||||
sep_lbl.setStyleSheet("color: rgba(255,255,255,55); border: 0; background: transparent;")
|
||||
v_lbl = QLabel("—", pill)
|
||||
v_lbl.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
|
||||
v_lbl.setStyleSheet("color: #FFFFFF; font-size: 12px; font-weight: 600; border: 0; background: transparent;")
|
||||
pl.addWidget(k_lbl)
|
||||
pl.addStretch(1)
|
||||
pl.addWidget(sep_lbl)
|
||||
pl.addSpacing(5)
|
||||
pl.addWidget(v_lbl)
|
||||
left_layout.addWidget(pill)
|
||||
self._param_rows.append((k_lbl, v_lbl))
|
||||
left_layout.addStretch(1)
|
||||
body_layout.addWidget(left_col)
|
||||
|
||||
self.aurora_cards = [AuroraGlassCardWidget(self.body_widget) for _ in range(3)]
|
||||
for card in self.aurora_cards:
|
||||
card.clicked.connect(self.open_ai_report_requested.emit)
|
||||
body_layout.addWidget(card, 1)
|
||||
|
||||
self.gauge = ArcRhythmGaugeWidget(self.body_widget)
|
||||
body_layout.addWidget(self.gauge)
|
||||
|
||||
root.addWidget(self.body_widget)
|
||||
self._apply_expanded_geometry()
|
||||
|
||||
def _sync_model_pill_styles(self, active_key: str) -> None:
|
||||
for key, btn in self._model_buttons.items():
|
||||
checked = key == active_key
|
||||
btn.setChecked(checked)
|
||||
if checked:
|
||||
btn.setStyleSheet(
|
||||
"QPushButton { background: #FFFFFF; color: #101817; border: 0;"
|
||||
" border-radius: 13px; padding: 0 11px; font-size: 11px; font-weight: 600; }"
|
||||
)
|
||||
else:
|
||||
btn.setStyleSheet(
|
||||
"QPushButton { background: rgba(255,255,255,14); color: rgba(230,240,238,180);"
|
||||
" border: 1px solid rgba(255,255,255,26); border-radius: 13px; padding: 0 11px; font-size: 11px; }"
|
||||
"QPushButton:hover { background: rgba(255,255,255,28); }"
|
||||
)
|
||||
|
||||
def _choose_model(self, key: str) -> None:
|
||||
self._sync_model_pill_styles(key)
|
||||
self.model_selected.emit(key)
|
||||
|
||||
@property
|
||||
def is_expanded(self) -> bool:
|
||||
return self._expanded
|
||||
|
||||
def set_expanded(self, expanded: bool) -> None:
|
||||
target = bool(expanded)
|
||||
if self._expanded == target:
|
||||
return
|
||||
self._expanded = target
|
||||
self._apply_expanded_geometry()
|
||||
self.expanded_changed.emit(target)
|
||||
|
||||
def toggle_expanded(self) -> None:
|
||||
self.set_expanded(not self._expanded)
|
||||
|
||||
def _apply_expanded_geometry(self) -> None:
|
||||
self.body_widget.setVisible(self._expanded)
|
||||
self.toggle_button.setText("收起分析舱 ▼" if self._expanded else "展开分析舱 ▲")
|
||||
self.setFixedHeight(238 if self._expanded else 64)
|
||||
self.update()
|
||||
|
||||
def set_view_model(self, vm: ObsidianAuroraVM) -> None:
|
||||
self._vm = vm
|
||||
self._sync_model_pill_styles(vm.active_model_key)
|
||||
self.title_label.setText(vm.program_title)
|
||||
self.summary_label.setText(vm.ai_summary_line)
|
||||
for (k_lbl, v_lbl), (k_txt, v_txt) in zip(self._param_rows, vm.params, strict=False):
|
||||
k_lbl.setText(k_txt)
|
||||
v_lbl.setText(v_txt)
|
||||
for card, c_vm in zip(self.aurora_cards, vm.cards, strict=False):
|
||||
card.set_view_model(c_vm)
|
||||
self.gauge.set_gauge(
|
||||
vm.gauge_value,
|
||||
vm.gauge_unit,
|
||||
vm.gauge_caption,
|
||||
vm.gauge_ratio,
|
||||
vm.gauge_tooltip,
|
||||
)
|
||||
self.update()
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if event.button() == Qt.MouseButton.LeftButton and self._handle_rect.contains(event.position()):
|
||||
self.toggle_expanded()
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if self._handle_rect.contains(event.position()):
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
else:
|
||||
self.setCursor(Qt.CursorShape.ArrowCursor)
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect())
|
||||
sheet_top = 12.0
|
||||
cx = rect.center().x()
|
||||
self._handle_rect = QRectF(cx - 38.0, 0.0, 76.0, 22.0)
|
||||
|
||||
body_rect = QRectF(0.0, sheet_top, rect.width(), rect.height() - sheet_top)
|
||||
path = QPainterPath()
|
||||
path.addRoundedRect(body_rect, 24.0, 24.0)
|
||||
painter.fillPath(path, QColor("#0E1413"))
|
||||
|
||||
notch = QPainterPath()
|
||||
notch.moveTo(cx - 34.0, sheet_top + 1.0)
|
||||
notch.cubicTo(cx - 20.0, sheet_top + 1.0, cx - 18.0, 2.0, cx, 2.0)
|
||||
notch.cubicTo(cx + 18.0, 2.0, cx + 20.0, sheet_top + 1.0, cx + 34.0, sheet_top + 1.0)
|
||||
notch.closeSubpath()
|
||||
painter.fillPath(notch, QColor("#0E1413"))
|
||||
|
||||
painter.setPen(QPen(QColor("#DCE8E5"), 1.7, Qt.PenStyle.SolidLine, Qt.PenCapStyle.RoundCap))
|
||||
ay = 10.0
|
||||
if self._expanded:
|
||||
painter.drawLine(QPointF(cx - 5.0, ay - 2.0), QPointF(cx, ay + 2.5))
|
||||
painter.drawLine(QPointF(cx, ay + 2.5), QPointF(cx + 5.0, ay - 2.0))
|
||||
else:
|
||||
painter.drawLine(QPointF(cx - 5.0, ay + 2.5), QPointF(cx, ay - 2.0))
|
||||
painter.drawLine(QPointF(cx, ay - 2.0), QPointF(cx + 5.0, ay + 2.5))
|
||||
@@ -0,0 +1,110 @@
|
||||
"""Reusable Alveo × Serene spatial action & patient-focus bridge bar for subpages."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton, QWidget
|
||||
|
||||
from ..state import PatientContextStore, PatientSnapshot
|
||||
|
||||
BRIDGE_QSS = """
|
||||
QFrame#SpatialContextBridgeBar {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #E2ECE9;
|
||||
border-radius: 20px;
|
||||
}
|
||||
QPushButton#BridgeFocusPatientPill {
|
||||
min-height: 30px;
|
||||
max-height: 30px;
|
||||
padding: 0 14px;
|
||||
border-radius: 15px;
|
||||
background-color: #F2F6F5;
|
||||
border: 1px solid #DCE7E4;
|
||||
color: #213735;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QPushButton#BridgeFocusPatientPill:hover {
|
||||
background-color: #E3F3EE;
|
||||
border-color: #9BCBC0;
|
||||
color: #0E6F5C;
|
||||
}
|
||||
QPushButton#BridgeFocusPatientPill:checked {
|
||||
background-color: #0E6F5C;
|
||||
border-color: #0E6F5C;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
class SpatialContextBridgeBar(QFrame):
|
||||
"""Compact rounded Bento bar syncing cross-page patient filtering & page actions."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
summary_text: str,
|
||||
*,
|
||||
on_filter_patient: Callable[[str], None] | None = None,
|
||||
parent: QWidget | None = None,
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("SpatialContextBridgeBar")
|
||||
self.setStyleSheet(BRIDGE_QSS)
|
||||
self.setMinimumHeight(52)
|
||||
self._store: PatientContextStore | None = None
|
||||
self._on_filter_patient = on_filter_patient
|
||||
|
||||
self.bar_layout = QHBoxLayout(self)
|
||||
self.bar_layout.setContentsMargins(16, 8, 16, 8)
|
||||
self.bar_layout.setSpacing(10)
|
||||
|
||||
self.summary_label = QLabel(summary_text, self)
|
||||
self.summary_label.setStyleSheet(
|
||||
"color: #556B68; font-size: 12px; font-weight: 500; background: transparent; border: 0;"
|
||||
)
|
||||
self.bar_layout.addWidget(self.summary_label)
|
||||
|
||||
self.focus_patient_button = QPushButton("聚焦当前患者", self)
|
||||
self.focus_patient_button.setObjectName("BridgeFocusPatientPill")
|
||||
self.focus_patient_button.setCheckable(True)
|
||||
self.focus_patient_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.focus_patient_button.setVisible(False)
|
||||
self.focus_patient_button.clicked.connect(self._toggle_patient_focus)
|
||||
self.bar_layout.addWidget(self.focus_patient_button)
|
||||
|
||||
self.bar_layout.addStretch(1)
|
||||
|
||||
self.actions_host = QWidget(self)
|
||||
self.actions_layout = QHBoxLayout(self.actions_host)
|
||||
self.actions_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.actions_layout.setSpacing(8)
|
||||
self.bar_layout.addWidget(self.actions_host)
|
||||
|
||||
def add_action_widget(self, widget: QWidget) -> None:
|
||||
widget.setParent(self.actions_host)
|
||||
widget.show()
|
||||
self.actions_layout.addWidget(widget)
|
||||
|
||||
def bind_store(self, store: PatientContextStore) -> None:
|
||||
self._store = store
|
||||
store.active_patient_changed.connect(self._on_patient_changed)
|
||||
self._on_patient_changed(store.current_patient)
|
||||
|
||||
def _on_patient_changed(self, snapshot: PatientSnapshot) -> None:
|
||||
if self._on_filter_patient is None or not snapshot or not snapshot.has_patient:
|
||||
self.focus_patient_button.setVisible(False)
|
||||
self.focus_patient_button.setChecked(False)
|
||||
return
|
||||
self.focus_patient_button.setVisible(True)
|
||||
self.focus_patient_button.setText(f"仅看当前患者:{snapshot.patient_name}")
|
||||
|
||||
def _toggle_patient_focus(self, checked: bool) -> None:
|
||||
if self._on_filter_patient is None or self._store is None:
|
||||
return
|
||||
snap = self._store.current_patient
|
||||
if checked and snap.has_patient:
|
||||
self._on_filter_patient(snap.patient_name)
|
||||
else:
|
||||
self._on_filter_patient("")
|
||||
@@ -0,0 +1,271 @@
|
||||
"""Real postprandial 2h blood glucose, 14-day check-in strip, and 3 vital bricks."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, QSize, Qt
|
||||
from PySide6.QtGui import QColor, QFont, QMouseEvent, QPainter, QPainterPath, QPen
|
||||
from PySide6.QtWidgets import QToolTip, QWidget
|
||||
|
||||
from ..reception_style import body_family, heading_family, number_family
|
||||
from ..viewmodels.cockpit_vm import DiurnalSlot, DiurnalStabilityVM, VitalMiniBrick
|
||||
|
||||
|
||||
class DiurnalStabilityCard(QWidget):
|
||||
"""Render real 2h postprandial glucose, 14-day daily records, and BP/BMI/Meds bricks."""
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("DiurnalStabilityCard")
|
||||
self.setMouseTracking(True)
|
||||
self.setMinimumHeight(218)
|
||||
self._vm: DiurnalStabilityVM | None = None
|
||||
self._slot_rects: list[tuple[QRectF, DiurnalSlot]] = []
|
||||
self._brick_rects: list[tuple[QRectF, VitalMiniBrick]] = []
|
||||
|
||||
def sizeHint(self) -> QSize: # noqa: N802
|
||||
return QSize(330, 300)
|
||||
|
||||
def set_view_model(self, vm: DiurnalStabilityVM) -> None:
|
||||
self._vm = vm
|
||||
self.update()
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
pos = event.position()
|
||||
for rect, slot in self._slot_rects:
|
||||
if rect.adjusted(-1, -6, 1, 6).contains(pos) and slot.tooltip:
|
||||
QToolTip.showText(event.globalPosition().toPoint(), slot.tooltip, self)
|
||||
super().mouseMoveEvent(event)
|
||||
return
|
||||
for rect, brick in self._brick_rects:
|
||||
if rect.contains(pos) and brick.tooltip:
|
||||
QToolTip.showText(event.globalPosition().toPoint(), brick.tooltip, self)
|
||||
break
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect()).adjusted(1.0, 1.0, -1.0, -1.0)
|
||||
card_path = QPainterPath()
|
||||
card_path.addRoundedRect(rect, 22.0, 22.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(card_path, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E3ECE9"), 1.0))
|
||||
painter.drawPath(card_path)
|
||||
|
||||
vm = self._vm
|
||||
if vm is None:
|
||||
return
|
||||
|
||||
compact = rect.height() < 262.0
|
||||
pad_x = 18.0
|
||||
pad_y = 11.0 if compact else 15.0
|
||||
left = rect.left() + pad_x
|
||||
right = rect.right() - pad_x
|
||||
avail_w = max(120.0, right - left)
|
||||
|
||||
# 1. Title + Reference / Alert Badge
|
||||
title_font = QFont(heading_family())
|
||||
title_font.setPixelSize(14 if compact else 15)
|
||||
title_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(title_font)
|
||||
painter.setPen(QColor("#111F1D"))
|
||||
painter.drawText(
|
||||
QRectF(left, rect.top() + pad_y, 175, 22),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.title,
|
||||
)
|
||||
|
||||
badge_font = QFont(body_family())
|
||||
badge_font.setPixelSize(11)
|
||||
badge_font.setWeight(QFont.Weight.Medium)
|
||||
painter.setFont(badge_font)
|
||||
badge_w = min(132.0, float(painter.fontMetrics().horizontalAdvance(vm.mode_badge) + 18))
|
||||
badge_rect = QRectF(right - badge_w, rect.top() + pad_y, badge_w, 22)
|
||||
badge_path = QPainterPath()
|
||||
badge_path.addRoundedRect(badge_rect, 11.0, 11.0)
|
||||
is_high_badge = "偏高" in vm.mode_badge
|
||||
painter.fillPath(badge_path, QColor("#FCEBE6" if is_high_badge else "#E2F3EE"))
|
||||
painter.setPen(QColor("#D96243" if is_high_badge else "#0E6F5C"))
|
||||
painter.drawText(badge_rect, Qt.AlignmentFlag.AlignCenter, vm.mode_badge)
|
||||
|
||||
# 2. Primary Value + unit + caption
|
||||
is_numeric = any(ch.isdigit() for ch in vm.primary_value)
|
||||
num_font = QFont(number_family() if is_numeric else heading_family())
|
||||
num_font.setPixelSize((29 if compact else 34) if is_numeric else (21 if compact else 24))
|
||||
num_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(num_font)
|
||||
painter.setPen(QColor("#0F1D1B") if vm.primary_value not in {"—", "未记录"} else QColor("#7D918E"))
|
||||
num_w = float(painter.fontMetrics().horizontalAdvance(vm.primary_value))
|
||||
metric_y = rect.top() + (34.0 if compact else 44.0)
|
||||
painter.drawText(
|
||||
QRectF(left, metric_y, num_w + 4, 36 if compact else 40),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.primary_value,
|
||||
)
|
||||
|
||||
unit_w = 0.0
|
||||
if vm.unit:
|
||||
unit_font = QFont(body_family())
|
||||
unit_font.setPixelSize(13 if compact else 14)
|
||||
painter.setFont(unit_font)
|
||||
painter.setPen(QColor("#5C726F"))
|
||||
unit_w = float(painter.fontMetrics().horizontalAdvance(vm.unit))
|
||||
painter.drawText(
|
||||
QRectF(left + num_w + 4, metric_y + (5 if compact else 8), unit_w + 6, 26),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.unit,
|
||||
)
|
||||
|
||||
small_font = QFont(body_family())
|
||||
small_font.setPixelSize(11)
|
||||
painter.setFont(small_font)
|
||||
painter.setPen(QColor("#7D918E"))
|
||||
cap_x = left + num_w + unit_w + (10 if vm.unit else 8)
|
||||
if right - cap_x > 50:
|
||||
elided_cap = painter.fontMetrics().elidedText(
|
||||
vm.caption, Qt.TextElideMode.ElideRight, int(right - cap_x)
|
||||
)
|
||||
painter.drawText(
|
||||
QRectF(cap_x, metric_y + (6 if compact else 10), right - cap_x, 24),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
elided_cap,
|
||||
)
|
||||
|
||||
# 3. Clinical Glycemic Range Track (4.4 — 7.8 — 11.1 mmol/L)
|
||||
track_y = metric_y + (38.0 if compact else 48.0)
|
||||
track_rect = QRectF(left, track_y, avail_w, 6.0)
|
||||
track_bg = QPainterPath()
|
||||
track_bg.addRoundedRect(track_rect, 3.0, 3.0)
|
||||
painter.fillPath(track_bg, QColor("#EDF2F0"))
|
||||
|
||||
safe_track = QRectF(left, track_y, avail_w * 0.78, 6.0)
|
||||
safe_path = QPainterPath()
|
||||
safe_path.addRoundedRect(safe_track, 3.0, 3.0)
|
||||
painter.fillPath(safe_path, QColor("#C6E8DF" if vm.has_marker else "#E2ECE9"))
|
||||
|
||||
if vm.has_marker:
|
||||
dot_x = left + avail_w * max(0.06, min(0.95, vm.range_marker_ratio))
|
||||
painter.setPen(QPen(QColor("#FFFFFF"), 2.0))
|
||||
painter.setBrush(QColor("#E06D4C" if is_high_badge else "#111918"))
|
||||
painter.drawEllipse(QPointF(dot_x, track_y + 3.0), 5.2, 5.2)
|
||||
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(QColor("#7D918E"))
|
||||
painter.drawText(QRectF(left, track_y + 9, 45, 14), Qt.AlignmentFlag.AlignLeft, vm.range_min_text)
|
||||
painter.drawText(
|
||||
QRectF(left + avail_w * 0.25, track_y + 9, avail_w * 0.50, 14),
|
||||
Qt.AlignmentFlag.AlignCenter,
|
||||
vm.range_target_text,
|
||||
)
|
||||
painter.drawText(QRectF(right - 45, track_y + 9, 45, 14), Qt.AlignmentFlag.AlignRight, vm.range_max_text)
|
||||
|
||||
# 4. Real 14-Day Check-In Strip
|
||||
strip_header_y = track_y + (24.0 if compact else 30.0)
|
||||
sub_bold = QFont(body_family())
|
||||
sub_bold.setPixelSize(11)
|
||||
sub_bold.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(sub_bold)
|
||||
painter.setPen(QColor("#243735"))
|
||||
painter.drawText(
|
||||
QRectF(left, strip_header_y, avail_w * 0.54, 16),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.overnight_title,
|
||||
)
|
||||
painter.setFont(small_font)
|
||||
has_alert = any(s.state == "alert" for s in vm.slots)
|
||||
painter.setPen(QColor("#D96243") if has_alert else QColor("#6E8380"))
|
||||
painter.drawText(
|
||||
QRectF(left + avail_w * 0.44, strip_header_y, avail_w * 0.56, 16),
|
||||
Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.overnight_peak_hint,
|
||||
)
|
||||
|
||||
strip_top = strip_header_y + (16.0 if compact else 20.0)
|
||||
strip_h = 20.0 if compact else 26.0
|
||||
n_slots = max(1, len(vm.slots))
|
||||
s_gap = 4.0
|
||||
s_w = max(5.0, (avail_w - s_gap * (n_slots - 1)) / n_slots)
|
||||
self._slot_rects.clear()
|
||||
for idx, slot in enumerate(vm.slots):
|
||||
sx = left + idx * (s_w + s_gap)
|
||||
sh = max(5.0, strip_h * max(0.16, min(1.0, slot.height_ratio)))
|
||||
sy = strip_top + (strip_h - sh)
|
||||
s_rect = QRectF(sx, sy, s_w, sh)
|
||||
self._slot_rects.append((s_rect, slot))
|
||||
spath = QPainterPath()
|
||||
spath.addRoundedRect(s_rect, 3.0, 3.0)
|
||||
if slot.state == "alert":
|
||||
s_color = QColor("#E06D4C")
|
||||
elif slot.state == "mint":
|
||||
s_color = QColor("#52B69E")
|
||||
elif slot.state == "normal":
|
||||
s_color = QColor("#BCE3D9")
|
||||
else:
|
||||
s_color = QColor("#E7EFED")
|
||||
painter.fillPath(spath, s_color)
|
||||
|
||||
time_y = strip_top + strip_h + 3
|
||||
painter.setPen(QColor("#829692"))
|
||||
first_lbl = vm.slots[0].time_label if vm.slots else "14天前"
|
||||
mid_lbl = vm.slots[len(vm.slots) // 2].time_label if vm.slots else "7天前"
|
||||
for ratio_pos, label_txt in ((0.0, first_lbl), (0.5, mid_lbl), (1.0, "今日")):
|
||||
tx = left + (avail_w - 42) * ratio_pos
|
||||
align = (
|
||||
Qt.AlignmentFlag.AlignLeft
|
||||
if ratio_pos == 0.0
|
||||
else (Qt.AlignmentFlag.AlignRight if ratio_pos == 1.0 else Qt.AlignmentFlag.AlignCenter)
|
||||
)
|
||||
painter.drawText(QRectF(tx, time_y, 42, 14), align, label_txt)
|
||||
|
||||
# 5. Bottom 3 Real Vital Mini-Bricks (BP, Height/Weight/BMI, Medications)
|
||||
brick_top = time_y + (15.0 if compact else 20.0)
|
||||
brick_h = max(44.0 if compact else 52.0, rect.bottom() - brick_top - (10.0 if compact else 13.0))
|
||||
b_gap = 8.0
|
||||
b_w = (avail_w - b_gap * 2) / 3.0
|
||||
|
||||
self._brick_rects.clear()
|
||||
for idx, brick in enumerate(vm.vitals[:3]):
|
||||
bx = left + idx * (b_w + b_gap)
|
||||
b_rect = QRectF(bx, brick_top, b_w, brick_h)
|
||||
self._brick_rects.append((b_rect, brick))
|
||||
b_path = QPainterPath()
|
||||
b_path.addRoundedRect(b_rect, 13.0, 13.0)
|
||||
painter.fillPath(b_path, QColor("#FDF2EE") if brick.alert else QColor("#F5F8F7"))
|
||||
|
||||
painter.setFont(small_font)
|
||||
painter.setPen(QColor("#6A7F7C"))
|
||||
painter.drawText(
|
||||
QRectF(bx + 9, brick_top + 6, b_w - 12, 15),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
brick.label,
|
||||
)
|
||||
|
||||
has_digit = any(ch.isdigit() for ch in brick.value)
|
||||
b_val_font = QFont(number_family() if has_digit else body_family())
|
||||
b_val_font.setPixelSize(15 if has_digit else 12)
|
||||
b_val_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(b_val_font)
|
||||
painter.setPen(QColor("#D15839") if brick.alert else QColor("#11201E"))
|
||||
elided_val = painter.fontMetrics().elidedText(
|
||||
brick.value, Qt.TextElideMode.ElideRight, int(b_w - 14)
|
||||
)
|
||||
val_w = float(painter.fontMetrics().horizontalAdvance(elided_val))
|
||||
painter.drawText(
|
||||
QRectF(bx + 9, brick_top + 23, b_w - 14, 22),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
elided_val,
|
||||
)
|
||||
if brick.unit and val_w + 26 < b_w:
|
||||
painter.setFont(small_font)
|
||||
painter.setPen(QColor("#7D918E"))
|
||||
elided_unit = painter.fontMetrics().elidedText(
|
||||
brick.unit, Qt.TextElideMode.ElideRight, int(b_w - val_w - 14)
|
||||
)
|
||||
painter.drawText(
|
||||
QRectF(bx + 11 + val_w, brick_top + 25, b_w - val_w - 14, 18),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
elided_unit,
|
||||
)
|
||||
@@ -0,0 +1,314 @@
|
||||
"""Real 21-Day Health Check-In (Glucose/Diet/Exercise) & Revisit Due Track."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, QSize, Qt, Signal
|
||||
from PySide6.QtGui import QColor, QFont, QMouseEvent, QPainter, QPainterPath, QPen
|
||||
from PySide6.QtWidgets import QToolTip, QWidget
|
||||
|
||||
from ..reception_style import body_family, heading_family, number_family
|
||||
from ..viewmodels.cockpit_vm import CareJourneyVM, JourneyDayCell
|
||||
|
||||
|
||||
class CareJourneyCard(QWidget):
|
||||
"""Plot the patient's real last 21 calendar days of check-ins + revisit due status."""
|
||||
|
||||
day_selected = Signal(int)
|
||||
open_full_plan_requested = Signal()
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("CareJourneyCard")
|
||||
self.setMouseTracking(True)
|
||||
self.setMinimumHeight(148)
|
||||
self._vm: CareJourneyVM | None = None
|
||||
self._day_rects: list[tuple[QRectF, JourneyDayCell]] = []
|
||||
self._plan_btn_rect = QRectF()
|
||||
self._hover_day: int = -1
|
||||
self._hover_btn = False
|
||||
|
||||
def sizeHint(self) -> QSize: # noqa: N802
|
||||
return QSize(1180, 164)
|
||||
|
||||
def set_view_model(self, vm: CareJourneyVM) -> None:
|
||||
self._vm = vm
|
||||
self._hover_day = -1
|
||||
self.update()
|
||||
|
||||
def leaveEvent(self, event: object) -> None: # noqa: N802
|
||||
self._hover_day = -1
|
||||
self._hover_btn = False
|
||||
self.update()
|
||||
super().leaveEvent(event) # type: ignore[arg-type]
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
pos = event.position()
|
||||
hover_btn = self._plan_btn_rect.contains(pos)
|
||||
hover_day = -1
|
||||
for rect, cell in self._day_rects:
|
||||
if rect.contains(pos):
|
||||
hover_day = cell.day_num
|
||||
QToolTip.showText(event.globalPosition().toPoint(), cell.tooltip, self)
|
||||
break
|
||||
self.setCursor(
|
||||
Qt.CursorShape.PointingHandCursor
|
||||
if (hover_btn or hover_day > 0)
|
||||
else Qt.CursorShape.ArrowCursor
|
||||
)
|
||||
if hover_btn != self._hover_btn or hover_day != self._hover_day:
|
||||
self._hover_btn = hover_btn
|
||||
self._hover_day = hover_day
|
||||
self.update()
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
pos = event.position()
|
||||
if self._plan_btn_rect.contains(pos):
|
||||
self.open_full_plan_requested.emit()
|
||||
event.accept()
|
||||
return
|
||||
for rect, cell in self._day_rects:
|
||||
if rect.contains(pos):
|
||||
self.day_selected.emit(cell.day_num)
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect()).adjusted(1.0, 1.0, -1.0, -1.0)
|
||||
card_path = QPainterPath()
|
||||
card_path.addRoundedRect(rect, 22.0, 22.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(card_path, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E3ECE9"), 1.0))
|
||||
painter.drawPath(card_path)
|
||||
|
||||
vm = self._vm
|
||||
if vm is None:
|
||||
return
|
||||
|
||||
# Left summary column (232px — High-DPI safe layout with inline status pill!)
|
||||
left_x = rect.left() + 20.0
|
||||
left_w = 224.0
|
||||
|
||||
title_font = QFont(heading_family())
|
||||
title_font.setPixelSize(14)
|
||||
title_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(title_font)
|
||||
painter.setPen(QColor("#11201E"))
|
||||
painter.drawText(QRectF(left_x, rect.top() + 14, left_w, 20), Qt.AlignmentFlag.AlignLeft, vm.title)
|
||||
|
||||
sub_font = QFont(body_family())
|
||||
sub_font.setPixelSize(11)
|
||||
painter.setFont(sub_font)
|
||||
painter.setPen(QColor("#788E8A"))
|
||||
elided_sub = painter.fontMetrics().elidedText(vm.plan_subtitle, Qt.TextElideMode.ElideRight, int(left_w))
|
||||
painter.drawText(QRectF(left_x, rect.top() + 34, left_w, 16), Qt.AlignmentFlag.AlignLeft, elided_sub)
|
||||
|
||||
# Big Check-in Count + "/ 21 天有打卡" + Inline Status Pill (ZERO overlap at any DPI!)
|
||||
day_font = QFont(number_family())
|
||||
day_font.setPixelSize(31)
|
||||
day_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(day_font)
|
||||
painter.setPen(QColor("#0F1D1B") if vm.primary_metric_text != "—" else QColor("#7D918E"))
|
||||
dw = float(painter.fontMetrics().horizontalAdvance(vm.primary_metric_text))
|
||||
painter.drawText(
|
||||
QRectF(left_x, rect.top() + 54, dw + 6, 36),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.primary_metric_text,
|
||||
)
|
||||
|
||||
slash_font = QFont(body_family())
|
||||
slash_font.setPixelSize(12)
|
||||
painter.setFont(slash_font)
|
||||
painter.setPen(QColor("#6E8380"))
|
||||
uw = float(painter.fontMetrics().horizontalAdvance(vm.total_unit_text))
|
||||
painter.drawText(
|
||||
QRectF(left_x + dw + 6, rect.top() + 62, uw + 6, 24),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.total_unit_text,
|
||||
)
|
||||
|
||||
# Inline status pill next to or cleanly right-aligned on the metric row
|
||||
badge_font = QFont(body_family())
|
||||
badge_font.setPixelSize(10)
|
||||
badge_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(badge_font)
|
||||
bw = min(88.0, float(painter.fontMetrics().horizontalAdvance(vm.status_pill) + 16))
|
||||
pill_x = max(left_x + dw + uw + 14.0, left_x + left_w - bw - 4.0)
|
||||
if pill_x + bw <= left_x + left_w + 4.0:
|
||||
b_rect = QRectF(pill_x, rect.top() + 63, bw, 20)
|
||||
bp = QPainterPath()
|
||||
bp.addRoundedRect(b_rect, 10.0, 10.0)
|
||||
if vm.status_tone == "coral":
|
||||
painter.fillPath(bp, QColor("#FCEBE6"))
|
||||
painter.setPen(QColor("#C85232"))
|
||||
elif vm.status_tone == "emerald":
|
||||
painter.fillPath(bp, QColor("#E2F3EE"))
|
||||
painter.setPen(QColor("#0E6F5C"))
|
||||
else:
|
||||
painter.fillPath(bp, QColor("#F1F5F4"))
|
||||
painter.setPen(QColor("#6B807D"))
|
||||
elided_pill = painter.fontMetrics().elidedText(vm.status_pill, Qt.TextElideMode.ElideRight, int(bw - 10))
|
||||
painter.drawText(b_rect, Qt.AlignmentFlag.AlignCenter, elided_pill)
|
||||
|
||||
# [↗ 打开日常记录矩阵] button anchored safely at bottom
|
||||
self._plan_btn_rect = QRectF(left_x, rect.bottom() - 36, 142, 26)
|
||||
btn_path = QPainterPath()
|
||||
btn_path.addRoundedRect(self._plan_btn_rect, 13.0, 13.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(btn_path, QColor("#EDF5F3" if self._hover_btn else "#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#0E6F5C" if self._hover_btn else "#D7E3E0"), 1.0))
|
||||
painter.drawPath(btn_path)
|
||||
painter.setPen(QColor("#0E6F5C" if self._hover_btn else "#1E312F"))
|
||||
painter.drawText(self._plan_btn_rect, Qt.AlignmentFlag.AlignCenter, "↗ 打开日常记录矩阵")
|
||||
|
||||
# Vertical subtle divider
|
||||
div_x = left_x + left_w + 10
|
||||
painter.setPen(QPen(QColor("#ECF2F0"), 1.0))
|
||||
painter.drawLine(QPointF(div_x, rect.top() + 16), QPointF(div_x, rect.bottom() - 16))
|
||||
|
||||
# Right 21-Day Real Calendar Matrix Column
|
||||
rx = div_x + 18.0
|
||||
rw = max(260.0, rect.right() - rx - 18.0)
|
||||
|
||||
painter.setFont(sub_font)
|
||||
painter.setPen(QColor("#839794"))
|
||||
painter.drawText(QRectF(rx, rect.top() + 13, 175, 16), Qt.AlignmentFlag.AlignLeft, "逐日实测日历(悬停查看明细)")
|
||||
|
||||
legend_items = (
|
||||
("#0E6F5C", True, "血糖达标"),
|
||||
("#E06D4C", True, "血糖偏高"),
|
||||
("#CBE8E0", True, "饮食/运动"),
|
||||
("#111918", True, "今日"),
|
||||
("#DCE6E3", False, "无打卡"),
|
||||
)
|
||||
lx = rect.right() - 348
|
||||
for color_hex, filled, text in legend_items:
|
||||
sw = QRectF(lx, rect.top() + 16, 9, 9)
|
||||
sp = QPainterPath()
|
||||
sp.addRoundedRect(sw, 2.5, 2.5)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
if filled:
|
||||
painter.fillPath(sp, QColor(color_hex))
|
||||
else:
|
||||
painter.setPen(QPen(QColor(color_hex), 1.1))
|
||||
painter.drawPath(sp)
|
||||
painter.setPen(QColor("#5C726F"))
|
||||
painter.drawText(QRectF(lx + 12, rect.top() + 13, 56, 15), Qt.AlignmentFlag.AlignLeft, text)
|
||||
lx += 68
|
||||
|
||||
n_days = max(1, len(vm.days))
|
||||
followup_w = 58.0
|
||||
gap = 5.0
|
||||
pills_avail = max(180.0, rw - followup_w - 10.0)
|
||||
pill_w = max(18.0, (pills_avail - gap * (n_days - 1)) / n_days)
|
||||
|
||||
# Weekly spans + horizontal span bars
|
||||
phase_y = rect.top() + 34
|
||||
bar_y = phase_y + 29
|
||||
for ph in vm.phases:
|
||||
px1 = rx + (ph.start_day - 1) * (pill_w + gap)
|
||||
px2 = rx + ph.end_day * pill_w + (ph.end_day - 1) * gap
|
||||
pw = max(40.0, px2 - px1 - 4.0)
|
||||
|
||||
p_font = QFont(body_family())
|
||||
p_font.setPixelSize(11)
|
||||
p_font.setWeight(QFont.Weight.DemiBold if ph.active else QFont.Weight.Medium)
|
||||
painter.setFont(p_font)
|
||||
painter.setPen(QColor("#0E6F5C") if ph.active else QColor("#354A47"))
|
||||
painter.drawText(QRectF(px1, phase_y, pw, 15), Qt.AlignmentFlag.AlignLeft, f"{ph.code} · {ph.title}")
|
||||
|
||||
painter.setFont(sub_font)
|
||||
painter.setPen(QColor("#829692"))
|
||||
painter.drawText(QRectF(px1, phase_y + 14, pw, 14), Qt.AlignmentFlag.AlignLeft, ph.date_span)
|
||||
|
||||
line_color = QColor("#111918") if ph.active else QColor("#CFE0DC")
|
||||
painter.setPen(QPen(line_color, 2.0, Qt.PenStyle.SolidLine, Qt.PenCapStyle.RoundCap))
|
||||
painter.drawLine(QPointF(px1, bar_y), QPointF(px1 + pw, bar_y))
|
||||
|
||||
# 21 Real Date Pills
|
||||
pill_top = bar_y + 7
|
||||
pill_h = 38.0
|
||||
self._day_rects.clear()
|
||||
num_pill_font = QFont(number_family())
|
||||
num_pill_font.setPixelSize(12)
|
||||
num_pill_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(num_pill_font)
|
||||
|
||||
today_center_x = rx
|
||||
for idx, cell in enumerate(vm.days):
|
||||
dx = rx + idx * (pill_w + gap)
|
||||
d_rect = QRectF(dx, pill_top, pill_w, pill_h)
|
||||
self._day_rects.append((d_rect, cell))
|
||||
dp = QPainterPath()
|
||||
dp.addRoundedRect(d_rect, 9.0, 9.0)
|
||||
|
||||
is_hover = cell.day_num == self._hover_day
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
if cell.state == "completed":
|
||||
painter.fillPath(dp, QColor("#0B5B4B" if is_hover else "#0E6F5C"))
|
||||
fg = QColor("#FFFFFF")
|
||||
elif cell.state == "alert":
|
||||
painter.fillPath(dp, QColor("#CC5738" if is_hover else "#E06D4C"))
|
||||
fg = QColor("#FFFFFF")
|
||||
elif cell.state == "stage":
|
||||
painter.fillPath(dp, QColor("#B4DFD4" if is_hover else "#CBE8E0"))
|
||||
fg = QColor("#11352E")
|
||||
elif cell.state == "today":
|
||||
today_center_x = d_rect.center().x()
|
||||
painter.fillPath(dp, QColor("#111918"))
|
||||
fg = QColor("#FFFFFF")
|
||||
else:
|
||||
painter.fillPath(dp, QColor("#F3F7F6" if is_hover else "#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#DCE6E3"), 1.0))
|
||||
painter.drawPath(dp)
|
||||
fg = QColor("#7E928F")
|
||||
|
||||
painter.setPen(fg)
|
||||
text_rect = d_rect.adjusted(0, -3, 0, -3) if cell.has_dot else d_rect
|
||||
painter.drawText(text_rect, Qt.AlignmentFlag.AlignCenter, cell.label_text)
|
||||
if cell.has_dot:
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor("#FFFFFF" if cell.state != "today" else "#E06D4C"))
|
||||
painter.drawEllipse(QPointF(d_rect.center().x(), d_rect.bottom() - 7.5), 2.2, 2.2)
|
||||
|
||||
# End Revisit / Prescription Status Capsule
|
||||
f_rect = QRectF(rx + n_days * (pill_w + gap) + 4.0, pill_top, followup_w, pill_h)
|
||||
fp = QPainterPath()
|
||||
fp.addRoundedRect(f_rect, 10.0, 10.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(fp, QColor("#FCEEE9" if vm.status_tone == "coral" else "#F4FAF8"))
|
||||
painter.setPen(
|
||||
QPen(
|
||||
QColor("#D96243" if vm.status_tone == "coral" else "#6BAE9E"),
|
||||
1.1,
|
||||
Qt.PenStyle.DashLine,
|
||||
)
|
||||
)
|
||||
painter.drawPath(fp)
|
||||
painter.setFont(badge_font)
|
||||
painter.setPen(QColor("#C85232" if vm.status_tone == "coral" else "#0E6F5C"))
|
||||
painter.drawText(f_rect, Qt.AlignmentFlag.AlignCenter, vm.end_capsule_text)
|
||||
|
||||
# Bottom Date Anchors + Black '今日' Pill
|
||||
mile_y = pill_top + pill_h + 6
|
||||
for day_idx, m_text in vm.milestones:
|
||||
mx = rx + (day_idx - 1) * (pill_w + gap) + pill_w * 0.5
|
||||
if day_idx == n_days:
|
||||
t_pill = QRectF(today_center_x - 20, mile_y, 40, 17)
|
||||
tp = QPainterPath()
|
||||
tp.addRoundedRect(t_pill, 8.5, 8.5)
|
||||
painter.fillPath(tp, QColor("#111918"))
|
||||
painter.setFont(badge_font)
|
||||
painter.setPen(QColor("#FFFFFF"))
|
||||
painter.drawText(t_pill, Qt.AlignmentFlag.AlignCenter, "今日")
|
||||
else:
|
||||
painter.setFont(sub_font)
|
||||
painter.setPen(QColor("#788E8A"))
|
||||
painter.drawText(QRectF(mx - 28, mile_y, 56, 15), Qt.AlignmentFlag.AlignCenter, m_text)
|
||||
@@ -0,0 +1,220 @@
|
||||
"""Real fasting blood glucose progression Bento card (mmol/L) rendered with QPainter."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, QSize, Qt
|
||||
from PySide6.QtGui import QColor, QFont, QMouseEvent, QPainter, QPainterPath, QPen
|
||||
from PySide6.QtWidgets import QToolTip, QWidget
|
||||
|
||||
from ..reception_style import body_family, heading_family, number_family
|
||||
from ..viewmodels.cockpit_vm import GlycemicProgressionVM, ProgressionPoint
|
||||
|
||||
|
||||
class PillProgressionCard(QWidget):
|
||||
"""Plot up to 12 real fasting blood glucose measurements against the 7.0 mmol/L line."""
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("PillProgressionCard")
|
||||
self.setMouseTracking(True)
|
||||
self.setMinimumHeight(172)
|
||||
self._vm: GlycemicProgressionVM | None = None
|
||||
self._hover_index: int = -1
|
||||
self._bar_rects: list[tuple[QRectF, ProgressionPoint]] = []
|
||||
|
||||
def sizeHint(self) -> QSize: # noqa: N802
|
||||
return QSize(330, 224)
|
||||
|
||||
def set_view_model(self, vm: GlycemicProgressionVM) -> None:
|
||||
self._vm = vm
|
||||
self._hover_index = -1
|
||||
self.update()
|
||||
|
||||
def leaveEvent(self, event: object) -> None: # noqa: N802
|
||||
self._hover_index = -1
|
||||
self.update()
|
||||
super().leaveEvent(event) # type: ignore[arg-type]
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
pos = event.position()
|
||||
hit = -1
|
||||
for idx, (rect, point) in enumerate(self._bar_rects):
|
||||
if rect.adjusted(-2, -10, 2, 6).contains(pos):
|
||||
hit = idx
|
||||
if point.value_hint:
|
||||
QToolTip.showText(event.globalPosition().toPoint(), point.value_hint, self)
|
||||
break
|
||||
if hit != self._hover_index:
|
||||
self._hover_index = hit
|
||||
self.update()
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect()).adjusted(1.0, 1.0, -1.0, -1.0)
|
||||
card_path = QPainterPath()
|
||||
card_path.addRoundedRect(rect, 22.0, 22.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(card_path, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E3ECE9"), 1.0))
|
||||
painter.drawPath(card_path)
|
||||
|
||||
vm = self._vm
|
||||
if vm is None:
|
||||
return
|
||||
|
||||
compact = rect.height() < 198.0
|
||||
pad_x = 18.0
|
||||
left = rect.left() + pad_x
|
||||
right = rect.right() - pad_x
|
||||
|
||||
# 1. Header row: Title + Reference badge
|
||||
title_font = QFont(heading_family())
|
||||
title_font.setPixelSize(14 if compact else 15)
|
||||
title_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(title_font)
|
||||
painter.setPen(QColor("#111F1D"))
|
||||
painter.drawText(
|
||||
QRectF(left, rect.top() + (12 if compact else 15), 160, 22),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.title,
|
||||
)
|
||||
|
||||
badge_font = QFont(body_family())
|
||||
badge_font.setPixelSize(11)
|
||||
badge_font.setWeight(QFont.Weight.Medium)
|
||||
painter.setFont(badge_font)
|
||||
badge_w = min(142.0, float(painter.fontMetrics().horizontalAdvance(vm.subtitle_badge) + 18))
|
||||
badge_rect = QRectF(right - badge_w, rect.top() + (12 if compact else 15), badge_w, 22)
|
||||
badge_path = QPainterPath()
|
||||
badge_path.addRoundedRect(badge_rect, 11.0, 11.0)
|
||||
painter.fillPath(badge_path, QColor("#F2F6F5"))
|
||||
painter.setPen(QColor("#4E6662"))
|
||||
painter.drawText(badge_rect, Qt.AlignmentFlag.AlignCenter, vm.subtitle_badge)
|
||||
|
||||
# 2. Primary Real Fasting Value + Unit + Status Pill
|
||||
is_numeric = any(ch.isdigit() for ch in vm.primary_value)
|
||||
num_font = QFont(number_family() if is_numeric else heading_family())
|
||||
num_font.setPixelSize((32 if compact else 38) if is_numeric else (22 if compact else 25))
|
||||
num_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(num_font)
|
||||
painter.setPen(QColor("#0F1D1B") if vm.primary_value not in {"—", "未记录"} else QColor("#7D918E"))
|
||||
num_w = float(painter.fontMetrics().horizontalAdvance(vm.primary_value))
|
||||
metric_y = rect.top() + (38 if compact else 44)
|
||||
painter.drawText(
|
||||
QRectF(left, metric_y, num_w + 6, 42),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.primary_value,
|
||||
)
|
||||
|
||||
if vm.unit:
|
||||
unit_font = QFont(body_family())
|
||||
unit_font.setPixelSize(13 if compact else 14)
|
||||
painter.setFont(unit_font)
|
||||
painter.setPen(QColor("#6C827E"))
|
||||
painter.drawText(
|
||||
QRectF(left + num_w + 5, metric_y + 8, 66, 28),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.unit,
|
||||
)
|
||||
|
||||
# Right status pill
|
||||
painter.setFont(badge_font)
|
||||
delta_w = float(painter.fontMetrics().horizontalAdvance(vm.delta_badge) + 20)
|
||||
delta_rect = QRectF(right - delta_w, metric_y + 3, delta_w, 22)
|
||||
delta_path = QPainterPath()
|
||||
delta_path.addRoundedRect(delta_rect, 11.0, 11.0)
|
||||
if vm.delta_tone == "emerald":
|
||||
painter.fillPath(delta_path, QColor("#E2F3EE"))
|
||||
painter.setPen(QColor("#0E6F5C"))
|
||||
elif vm.delta_tone == "coral":
|
||||
painter.fillPath(delta_path, QColor("#FCEBE6"))
|
||||
painter.setPen(QColor("#D96243"))
|
||||
else:
|
||||
painter.fillPath(delta_path, QColor("#F1F5F4"))
|
||||
painter.setPen(QColor("#6B807D"))
|
||||
painter.drawText(delta_rect, Qt.AlignmentFlag.AlignCenter, vm.delta_badge)
|
||||
|
||||
sub_caption_font = QFont(body_family())
|
||||
sub_caption_font.setPixelSize(11)
|
||||
painter.setFont(sub_caption_font)
|
||||
painter.setPen(QColor("#7D918E"))
|
||||
painter.drawText(
|
||||
QRectF(right - 138, metric_y + 27, 138, 15),
|
||||
Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.delta_caption,
|
||||
)
|
||||
|
||||
# 3. 7.0 mmol/L Threshold Dashed Line + 12 Real Measurement Bars
|
||||
chart_top = metric_y + (48 if compact else 54)
|
||||
chart_bottom = rect.bottom() - 28
|
||||
chart_h = max(36.0, chart_bottom - chart_top)
|
||||
|
||||
target_y = chart_bottom - chart_h * max(0.25, min(0.88, vm.target_ratio))
|
||||
painter.setPen(QPen(QColor("#C8D8D4"), 1.1, Qt.PenStyle.DashLine))
|
||||
painter.drawLine(QPointF(left, target_y), QPointF(right, target_y))
|
||||
|
||||
painter.setFont(sub_caption_font)
|
||||
painter.setPen(QColor("#6E8380"))
|
||||
painter.drawText(
|
||||
QRectF(left, max(chart_top - 2, target_y - 15), 130, 14),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.target_label,
|
||||
)
|
||||
|
||||
bars = vm.bars
|
||||
count = max(1, len(bars))
|
||||
gap = 5.5
|
||||
avail_w = max(80.0, right - left)
|
||||
bar_w = max(8.0, (avail_w - gap * (count - 1)) / count)
|
||||
|
||||
self._bar_rects.clear()
|
||||
for idx, pt in enumerate(bars):
|
||||
bx = left + idx * (bar_w + gap)
|
||||
bh = max(8.0, chart_h * max(0.14, min(0.98, pt.ratio)))
|
||||
by = chart_bottom - bh
|
||||
bar_rect = QRectF(bx, by, bar_w, bh)
|
||||
self._bar_rects.append((bar_rect, pt))
|
||||
|
||||
radius = min(5.5, bar_w * 0.42)
|
||||
bpath = QPainterPath()
|
||||
bpath.addRoundedRect(bar_rect, radius, radius)
|
||||
|
||||
if not pt.recorded:
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(bpath, QColor("#F3F7F6"))
|
||||
painter.setPen(QPen(QColor("#E3ECE9"), 1.0))
|
||||
painter.drawPath(bpath)
|
||||
else:
|
||||
if pt.alert:
|
||||
fill = QColor("#E06D4C") if pt.highlight else QColor("#EFA48E")
|
||||
elif pt.highlight:
|
||||
fill = QColor("#0E6F5C")
|
||||
elif idx == self._hover_index:
|
||||
fill = QColor("#5AB6A3")
|
||||
else:
|
||||
fill = QColor("#AEDCD0")
|
||||
painter.fillPath(bpath, fill)
|
||||
|
||||
# 4. Bottom labels
|
||||
foot_y = rect.bottom() - 22
|
||||
painter.setFont(sub_caption_font)
|
||||
painter.setPen(QColor("#7C908D"))
|
||||
painter.drawText(
|
||||
QRectF(left, foot_y, 120, 15),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.left_foot,
|
||||
)
|
||||
foot_right_font = QFont(body_family())
|
||||
foot_right_font.setPixelSize(11)
|
||||
foot_right_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(foot_right_font)
|
||||
painter.setPen(QColor("#1A2D2B"))
|
||||
painter.drawText(
|
||||
QRectF(right - 135, foot_y, 135, 15),
|
||||
Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter,
|
||||
vm.right_foot,
|
||||
)
|
||||
@@ -0,0 +1,563 @@
|
||||
"""Three-column Alveo × Serene Clinical Digital Twin Cockpit for ReceptionPage."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from datetime import date
|
||||
from typing import Any
|
||||
|
||||
from PySide6.QtCore import QSize, Qt, Signal
|
||||
from PySide6.QtGui import QFont
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QScrollArea,
|
||||
QSizePolicy,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from ...core.appointment_modes import appointment_type_description, appointment_type_value
|
||||
from .. import icons
|
||||
from ..reception_style import body_family, heading_family
|
||||
from ..viewmodels.cockpit_vm import CockpitSnapshotVM, derive_cockpit_snapshot
|
||||
from ..widgets import clear_layout, display_text, first_value
|
||||
from .diurnal_strip import DiurnalStabilityCard
|
||||
from .journey_track import CareJourneyCard
|
||||
from .pill_chart import PillProgressionCard
|
||||
from .twin_stage import ClinicalTwinStageWidget
|
||||
|
||||
COCKPIT_QSS = """
|
||||
QWidget#ReceptionDigitalTwinCockpit {
|
||||
background: transparent;
|
||||
}
|
||||
QFrame#CockpitBentoCard {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #E3ECE9;
|
||||
border-radius: 22px;
|
||||
}
|
||||
QPushButton#CockpitFilterPill {
|
||||
min-height: 24px;
|
||||
max-height: 24px;
|
||||
padding: 0 10px;
|
||||
border-radius: 12px;
|
||||
border: 0;
|
||||
background-color: #F2F6F5;
|
||||
color: #5E7471;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QPushButton#CockpitFilterPill:hover {
|
||||
background-color: #E5F1EE;
|
||||
color: #0E6F5C;
|
||||
}
|
||||
QPushButton#CockpitFilterPill:checked {
|
||||
background-color: #111918;
|
||||
color: #FFFFFF;
|
||||
font-weight: 600;
|
||||
}
|
||||
QFrame#TimelineItemCard {
|
||||
background-color: #F5F8F7;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 16px;
|
||||
}
|
||||
QFrame#TimelineItemCard:hover {
|
||||
background-color: #EBF3F0;
|
||||
border-color: #CFE2DD;
|
||||
}
|
||||
QFrame#TimelineItemCard[activeItem="true"] {
|
||||
background-color: #0E6F5C;
|
||||
border: 1px solid #0E6F5C;
|
||||
border-radius: 16px;
|
||||
}
|
||||
QPushButton#TimelinePlayCircle {
|
||||
min-width: 30px;
|
||||
max-width: 30px;
|
||||
min-height: 30px;
|
||||
max-height: 30px;
|
||||
border-radius: 15px;
|
||||
background-color: #FFFFFF;
|
||||
border: 0;
|
||||
color: #0E6F5C;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
QPushButton#TimelinePlayCircle:hover {
|
||||
background-color: #E5F6F1;
|
||||
}
|
||||
QLabel#TimelineDoneBadge {
|
||||
min-width: 28px;
|
||||
max-width: 28px;
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
border-radius: 14px;
|
||||
background-color: #E0F2EC;
|
||||
color: #0E6F5C;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
QLabel#TimelineWaitBadge {
|
||||
min-width: 28px;
|
||||
max-width: 28px;
|
||||
min-height: 28px;
|
||||
max-height: 28px;
|
||||
border-radius: 14px;
|
||||
background-color: #EAEFED;
|
||||
color: #6E8380;
|
||||
font-size: 12px;
|
||||
}
|
||||
QPushButton#CareTeamActionPill {
|
||||
min-width: 32px;
|
||||
min-height: 30px;
|
||||
max-height: 30px;
|
||||
padding: 0 11px;
|
||||
border-radius: 15px;
|
||||
background-color: #F3F7F6;
|
||||
border: 1px solid #E1ECE8;
|
||||
color: #192E2C;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QPushButton#CareTeamActionPill:hover {
|
||||
background-color: #E2F3EE;
|
||||
border-color: #9ED0C3;
|
||||
color: #0E6F5C;
|
||||
}
|
||||
QPushButton#CareTeamActionPill:disabled {
|
||||
color: #9EB0AD;
|
||||
background-color: #F6F8F8;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def _safe_int(val: Any, default: int = 0) -> int:
|
||||
try:
|
||||
return int(val)
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
|
||||
|
||||
class _TimelineRowWidget(QFrame):
|
||||
"""Single appointment row inside Today's Plan (Alveo solid-emerald active pill)."""
|
||||
|
||||
row_clicked = Signal(object)
|
||||
play_clicked = Signal(object)
|
||||
|
||||
def __init__(self, record: Any, *, active: bool, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.record = record
|
||||
self.setObjectName("TimelineItemCard")
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
|
||||
self.setProperty("activeItem", active)
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.setFixedHeight(58)
|
||||
if active:
|
||||
self.setStyleSheet(
|
||||
"QFrame#TimelineItemCard {"
|
||||
" background-color: #0E6F5C; border: 1px solid #0E6F5C; border-radius: 16px; }"
|
||||
)
|
||||
else:
|
||||
self.setStyleSheet(
|
||||
"QFrame#TimelineItemCard {"
|
||||
" background-color: #F5F8F7; border: 1px solid transparent; border-radius: 16px; }"
|
||||
"QFrame#TimelineItemCard:hover {"
|
||||
" background-color: #EBF3F0; border: 1px solid #CFE2DD; }"
|
||||
)
|
||||
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(14, 8, 12, 8)
|
||||
layout.setSpacing(10)
|
||||
|
||||
# Time + Mode column
|
||||
time_raw = display_text(
|
||||
first_value(record, "appointment_time_text", "appointment_time", "time", default="待排期")
|
||||
)
|
||||
short_time = time_raw.split("-")[0][:5] if ":" in time_raw else time_raw[:6]
|
||||
mode_txt = appointment_type_description(appointment_type_value(record))[:4]
|
||||
|
||||
t_col = QVBoxLayout()
|
||||
t_col.setContentsMargins(0, 0, 0, 0)
|
||||
t_col.setSpacing(1)
|
||||
t_lbl = QLabel(short_time, self)
|
||||
t_lbl.setFixedWidth(48)
|
||||
t_lbl.setStyleSheet(
|
||||
f"color: {'#FFFFFF' if active else '#152725'}; font-size: 13px; font-weight: 600; background: transparent;"
|
||||
)
|
||||
m_lbl = QLabel(mode_txt, self)
|
||||
m_lbl.setFixedWidth(48)
|
||||
m_lbl.setStyleSheet(
|
||||
f"color: {'rgba(255,255,255,195)' if active else '#7A908C'}; font-size: 10px; background: transparent;"
|
||||
)
|
||||
t_col.addWidget(t_lbl)
|
||||
t_col.addWidget(m_lbl)
|
||||
layout.addLayout(t_col)
|
||||
|
||||
# Patient Name + Chief Complaint / Condition
|
||||
p_name = display_text(first_value(record, "patient_name", "name", default="患者"))
|
||||
diag_sub = first_value(record, "diagnosis", default={}) or {}
|
||||
chief = display_text(
|
||||
first_value(
|
||||
record,
|
||||
"chief_complaint",
|
||||
"clinical_diagnosis",
|
||||
default=first_value(diag_sub, "chief_complaint", "clinical_diagnosis", default="点击载入四诊详情"),
|
||||
)
|
||||
)
|
||||
if len(chief) > 15:
|
||||
chief = f"{chief[:14]}…"
|
||||
|
||||
c_col = QVBoxLayout()
|
||||
c_col.setContentsMargins(0, 0, 0, 0)
|
||||
c_col.setSpacing(1)
|
||||
n_lbl = QLabel(p_name, self)
|
||||
n_lbl.setStyleSheet(
|
||||
f"color: {'#FFFFFF' if active else '#11201E'}; font-size: 13px; font-weight: 600; background: transparent;"
|
||||
)
|
||||
s_lbl = QLabel(chief, self)
|
||||
s_lbl.setStyleSheet(
|
||||
f"color: {'rgba(255,255,255,205)' if active else '#6E8380'}; font-size: 11px; background: transparent;"
|
||||
)
|
||||
c_col.addWidget(n_lbl)
|
||||
c_col.addWidget(s_lbl)
|
||||
layout.addLayout(c_col, 1)
|
||||
|
||||
# Right Status / Play Action (Alveo circular white play button on active emerald row!)
|
||||
status = _safe_int(first_value(record, "status", default=1), 1)
|
||||
if active:
|
||||
play_btn = QPushButton("▷", self)
|
||||
play_btn.setObjectName("TimelinePlayCircle")
|
||||
play_btn.setFixedSize(30, 30)
|
||||
play_btn.setStyleSheet(
|
||||
"QPushButton#TimelinePlayCircle {"
|
||||
" min-width: 30px; max-width: 30px; min-height: 30px; max-height: 30px;"
|
||||
" border-radius: 15px; background-color: #FFFFFF; border: 0;"
|
||||
" color: #0E6F5C; font-size: 12px; font-weight: 700; padding: 0; }"
|
||||
"QPushButton#TimelinePlayCircle:hover { background-color: #E6F6F1; }"
|
||||
)
|
||||
play_btn.setToolTip("立即发起视频 / IM 问诊")
|
||||
play_btn.clicked.connect(lambda: self.play_clicked.emit(self.record))
|
||||
layout.addWidget(play_btn)
|
||||
elif status == 3:
|
||||
done_lbl = QLabel("✓", self)
|
||||
done_lbl.setObjectName("TimelineDoneBadge")
|
||||
done_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
layout.addWidget(done_lbl)
|
||||
else:
|
||||
wait_lbl = QLabel("•", self)
|
||||
wait_lbl.setObjectName("TimelineWaitBadge")
|
||||
wait_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
layout.addWidget(wait_lbl)
|
||||
|
||||
def mousePressEvent(self, event: Any) -> None: # noqa: N802
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
self.row_clicked.emit(self.record)
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
|
||||
class ReceptionDigitalTwinCockpit(QWidget):
|
||||
"""Full Alveo × Serene 3-column Digital Twin Cockpit + 21-Day Journey Track."""
|
||||
|
||||
appointment_selected = Signal(object)
|
||||
filter_status_requested = Signal(object)
|
||||
refresh_requested = Signal()
|
||||
start_video_requested = Signal()
|
||||
edit_diagnosis_requested = Signal()
|
||||
notify_assistant_requested = Signal()
|
||||
complete_visit_requested = Signal()
|
||||
open_chart_tab_requested = Signal(int)
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("ReceptionDigitalTwinCockpit")
|
||||
self.setStyleSheet(COCKPIT_QSS)
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
root.setSpacing(12)
|
||||
|
||||
# ── Layer 3: Asymmetric 3-Column Clinical Cockpit ──────────────────
|
||||
cockpit_row = QHBoxLayout()
|
||||
cockpit_row.setContentsMargins(0, 0, 0, 0)
|
||||
cockpit_row.setSpacing(14)
|
||||
|
||||
# Column 1 (Left 25%): Glycemic Progression + Diurnal TIR & Mini Vitals
|
||||
left_wing = QWidget(self)
|
||||
left_wing.setMinimumWidth(276)
|
||||
left_wing.setMaximumWidth(390)
|
||||
left_layout = QVBoxLayout(left_wing)
|
||||
left_layout.setContentsMargins(0, 0, 0, 0)
|
||||
left_layout.setSpacing(12)
|
||||
|
||||
self.progression_card = PillProgressionCard(left_wing)
|
||||
self.diurnal_card = DiurnalStabilityCard(left_wing)
|
||||
left_layout.addWidget(self.progression_card, 44)
|
||||
left_layout.addWidget(self.diurnal_card, 56)
|
||||
cockpit_row.addWidget(left_wing, 26)
|
||||
|
||||
# Column 2 (Center 47%): Translucent Jade-Crystal Three-Jiao Digital Twin Stage
|
||||
self.twin_stage = ClinicalTwinStageWidget(self)
|
||||
self.twin_stage.locus_clicked.connect(lambda _locus: self.edit_diagnosis_requested.emit())
|
||||
self.twin_stage.open_chart_requested.connect(lambda: self.open_chart_tab_requested.emit(0))
|
||||
cockpit_row.addWidget(self.twin_stage, 46)
|
||||
|
||||
# Column 3 (Right 28%): Today's Plan Timeline + Care Team Collaboration
|
||||
right_wing = QWidget(self)
|
||||
right_wing.setMinimumWidth(286)
|
||||
right_wing.setMaximumWidth(400)
|
||||
right_layout = QVBoxLayout(right_wing)
|
||||
right_layout.setContentsMargins(0, 0, 0, 0)
|
||||
right_layout.setSpacing(12)
|
||||
|
||||
self.plan_card = self._build_today_plan_card(right_wing)
|
||||
self.team_card = self._build_care_team_card(right_wing)
|
||||
right_layout.addWidget(self.plan_card, 62)
|
||||
right_layout.addWidget(self.team_card, 38)
|
||||
cockpit_row.addWidget(right_wing, 28)
|
||||
|
||||
root.addLayout(cockpit_row, 1)
|
||||
|
||||
# ── Layer 4A: Bottom 21-Day Care Journey Rounded-Pill Matrix ───────
|
||||
self.journey_card = CareJourneyCard(self)
|
||||
self.journey_card.open_full_plan_requested.connect(lambda: self.open_chart_tab_requested.emit(4))
|
||||
self.journey_card.day_selected.connect(lambda _d: self.open_chart_tab_requested.emit(3))
|
||||
root.addWidget(self.journey_card)
|
||||
|
||||
# Seed default visual state immediately so screen is rich even while async loads
|
||||
self.set_snapshot(derive_cockpit_snapshot())
|
||||
|
||||
def _build_today_plan_card(self, parent: QWidget) -> QFrame:
|
||||
card = QFrame(parent)
|
||||
card.setObjectName("CockpitBentoCard")
|
||||
layout = QVBoxLayout(card)
|
||||
layout.setContentsMargins(18, 15, 18, 14)
|
||||
layout.setSpacing(10)
|
||||
|
||||
head = QHBoxLayout()
|
||||
head.setSpacing(8)
|
||||
title = QLabel("今日门诊计划", card)
|
||||
t_font = QFont(heading_family())
|
||||
t_font.setPixelSize(15)
|
||||
t_font.setWeight(QFont.Weight.DemiBold)
|
||||
title.setFont(t_font)
|
||||
title.setStyleSheet("color: #11201E; background: transparent;")
|
||||
head.addWidget(title)
|
||||
head.addStretch(1)
|
||||
|
||||
self.plan_date_label = QLabel(date.today().strftime("%m月%d日"), card)
|
||||
self.plan_date_label.setStyleSheet("color: #788E8A; font-size: 12px; background: transparent;")
|
||||
head.addWidget(self.plan_date_label)
|
||||
|
||||
refresh_btn = QPushButton(card)
|
||||
refresh_btn.setFixedSize(26, 26)
|
||||
refresh_btn.setIcon(icons.icon("refresh", "#5A706D", 14))
|
||||
refresh_btn.setIconSize(QSize(14, 14))
|
||||
refresh_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
refresh_btn.setToolTip("刷新今日接诊队列")
|
||||
refresh_btn.setStyleSheet(
|
||||
"QPushButton { background: #F3F7F6; border: 0; border-radius: 13px; }"
|
||||
"QPushButton:hover { background: #E3F2EE; }"
|
||||
)
|
||||
refresh_btn.clicked.connect(self.refresh_requested.emit)
|
||||
head.addWidget(refresh_btn)
|
||||
layout.addLayout(head)
|
||||
|
||||
# Compact status filter chips
|
||||
chip_row = QHBoxLayout()
|
||||
chip_row.setSpacing(6)
|
||||
self._status_pills: dict[int | None, QPushButton] = {}
|
||||
for st_val, st_label in ((1, "待接诊"), (None, "全部"), (3, "已完成")):
|
||||
pill = QPushButton(st_label, card)
|
||||
pill.setObjectName("CockpitFilterPill")
|
||||
pill.setCheckable(True)
|
||||
pill.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
pill.clicked.connect(lambda _c=False, v=st_val: self._on_filter_pill_clicked(v))
|
||||
self._status_pills[st_val] = pill
|
||||
chip_row.addWidget(pill)
|
||||
self._status_pills[1].setChecked(True)
|
||||
chip_row.addStretch(1)
|
||||
layout.addLayout(chip_row)
|
||||
|
||||
self.timeline_scroll = QScrollArea(card)
|
||||
self.timeline_scroll.setWidgetResizable(True)
|
||||
self.timeline_scroll.setFrameShape(QFrame.Shape.NoFrame)
|
||||
self.timeline_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.timeline_scroll.setStyleSheet("QScrollArea { background: transparent; border: 0; }")
|
||||
|
||||
self.timeline_host = QWidget(self.timeline_scroll)
|
||||
self.timeline_host.setStyleSheet("background: transparent;")
|
||||
self.timeline_layout = QVBoxLayout(self.timeline_host)
|
||||
self.timeline_layout.setContentsMargins(0, 0, 2, 0)
|
||||
self.timeline_layout.setSpacing(8)
|
||||
self.timeline_layout.addStretch(1)
|
||||
self.timeline_scroll.setWidget(self.timeline_host)
|
||||
layout.addWidget(self.timeline_scroll, 1)
|
||||
|
||||
return card
|
||||
|
||||
def _build_care_team_card(self, parent: QWidget) -> QFrame:
|
||||
card = QFrame(parent)
|
||||
card.setObjectName("CockpitBentoCard")
|
||||
layout = QVBoxLayout(card)
|
||||
layout.setContentsMargins(18, 14, 18, 14)
|
||||
layout.setSpacing(8)
|
||||
|
||||
head = QHBoxLayout()
|
||||
title = QLabel("诊疗协作组", card)
|
||||
t_font = QFont(heading_family())
|
||||
t_font.setPixelSize(15)
|
||||
t_font.setWeight(QFont.Weight.DemiBold)
|
||||
title.setFont(t_font)
|
||||
title.setStyleSheet("color: #11201E; background: transparent;")
|
||||
head.addWidget(title)
|
||||
head.addStretch(1)
|
||||
shift_lbl = QLabel("3 席在线协同", card)
|
||||
shift_lbl.setStyleSheet("color: #7A908C; font-size: 11px; background: transparent;")
|
||||
head.addWidget(shift_lbl)
|
||||
layout.addLayout(head)
|
||||
|
||||
# 3 Alveo Care Team Rows: Lead Doctor, Assigned Assistant, Clinical Completion
|
||||
self.doctor_name_lbl, self.doctor_role_lbl, self.edit_diag_btn = self._add_team_row(
|
||||
layout,
|
||||
avatar_text="医",
|
||||
avatar_bg="#E2F3EE",
|
||||
avatar_fg="#0E6F5C",
|
||||
name="主诊中医师",
|
||||
role="辨证施治 · 四诊合参",
|
||||
action_text="编辑病历",
|
||||
callback=self.edit_diagnosis_requested.emit,
|
||||
)
|
||||
self.assistant_name_lbl, self.assistant_role_lbl, self.notify_asst_btn = self._add_team_row(
|
||||
layout,
|
||||
avatar_text="助",
|
||||
avatar_bg="#EDF4F2",
|
||||
avatar_fg="#2B524C",
|
||||
name="专属医助",
|
||||
role="诊前采集 · 院外随访",
|
||||
action_text="通知医助",
|
||||
callback=self.notify_assistant_requested.emit,
|
||||
)
|
||||
self.pharmacist_name_lbl, self.pharmacist_role_lbl, self.complete_visit_btn = self._add_team_row(
|
||||
layout,
|
||||
avatar_text="结",
|
||||
avatar_bg="#FAF4E6",
|
||||
avatar_fg="#9E7425",
|
||||
name="门诊闭环核验",
|
||||
role="病历归档 · 完成本次接诊",
|
||||
action_text="完成接诊",
|
||||
callback=self.complete_visit_requested.emit,
|
||||
)
|
||||
return card
|
||||
|
||||
def _add_team_row(
|
||||
self,
|
||||
parent_layout: QVBoxLayout,
|
||||
*,
|
||||
avatar_text: str,
|
||||
avatar_bg: str,
|
||||
avatar_fg: str,
|
||||
name: str,
|
||||
role: str,
|
||||
action_text: str,
|
||||
callback: Any,
|
||||
) -> tuple[QLabel, QLabel, QPushButton]:
|
||||
row = QWidget(self)
|
||||
rl = QHBoxLayout(row)
|
||||
rl.setContentsMargins(0, 2, 0, 2)
|
||||
rl.setSpacing(10)
|
||||
|
||||
av = QLabel(avatar_text, row)
|
||||
av.setFixedSize(34, 34)
|
||||
av.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
av.setStyleSheet(
|
||||
f"background-color: {avatar_bg}; color: {avatar_fg}; border-radius: 17px;"
|
||||
" font-size: 13px; font-weight: 600;"
|
||||
)
|
||||
rl.addWidget(av)
|
||||
|
||||
meta = QVBoxLayout()
|
||||
meta.setContentsMargins(0, 0, 0, 0)
|
||||
meta.setSpacing(1)
|
||||
n_lbl = QLabel(name, row)
|
||||
n_lbl.setStyleSheet("color: #122220; font-size: 13px; font-weight: 600; background: transparent;")
|
||||
r_lbl = QLabel(role, row)
|
||||
r_lbl.setStyleSheet("color: #788E8A; font-size: 11px; background: transparent;")
|
||||
r_lbl.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
|
||||
meta.addWidget(n_lbl)
|
||||
meta.addWidget(r_lbl)
|
||||
rl.addLayout(meta, 1)
|
||||
|
||||
btn = QPushButton(action_text, row)
|
||||
btn.setObjectName("CareTeamActionPill")
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn.clicked.connect(callback)
|
||||
rl.addWidget(btn)
|
||||
parent_layout.addWidget(row)
|
||||
return n_lbl, r_lbl, btn
|
||||
|
||||
def _on_filter_pill_clicked(self, status_val: int | None) -> None:
|
||||
for k, btn in self._status_pills.items():
|
||||
btn.setChecked(k == status_val)
|
||||
self.filter_status_requested.emit(status_val)
|
||||
|
||||
def set_snapshot(self, snapshot: CockpitSnapshotVM) -> None:
|
||||
self.progression_card.set_view_model(snapshot.progression)
|
||||
self.diurnal_card.set_view_model(snapshot.diurnal)
|
||||
self.twin_stage.set_snapshot(snapshot)
|
||||
self.journey_card.set_view_model(snapshot.journey)
|
||||
|
||||
def set_care_team_context(
|
||||
self,
|
||||
*,
|
||||
doctor_name: str,
|
||||
assistant_name: str,
|
||||
can_edit: bool,
|
||||
can_notify: bool,
|
||||
can_complete: bool,
|
||||
) -> None:
|
||||
self.doctor_name_lbl.setText(doctor_name if doctor_name and doctor_name != "—" else "主诊中医师")
|
||||
self.assistant_name_lbl.setText(
|
||||
f"{assistant_name}(医助)" if assistant_name and assistant_name != "—" else "待分配医助"
|
||||
)
|
||||
self.edit_diag_btn.setEnabled(can_edit)
|
||||
self.notify_asst_btn.setEnabled(can_notify)
|
||||
self.complete_visit_btn.setEnabled(can_complete)
|
||||
|
||||
def set_queue_records(
|
||||
self,
|
||||
records: Sequence[Any],
|
||||
selected_appointment_id: int | None,
|
||||
*,
|
||||
active_filter_status: int | None = 1,
|
||||
queue_date: str = "",
|
||||
) -> None:
|
||||
for k, btn in self._status_pills.items():
|
||||
btn.setChecked(k == active_filter_status)
|
||||
if queue_date:
|
||||
self.plan_date_label.setText(f"{queue_date[5:]} · {len(records)}人")
|
||||
else:
|
||||
self.plan_date_label.setText(f"共 {len(records)} 人")
|
||||
|
||||
clear_layout(self.timeline_layout)
|
||||
if not records:
|
||||
empty = QLabel("当前筛选下暂无门诊挂号\n可切换上方「全部」查看历史接诊", self.timeline_host)
|
||||
empty.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
empty.setStyleSheet(
|
||||
f"color: #7D918E; font-size: 12px; font-family: '{body_family()}';"
|
||||
" padding: 28px 12px; background: #F7FAF9; border-radius: 14px;"
|
||||
)
|
||||
self.timeline_layout.addWidget(empty)
|
||||
self.timeline_layout.addStretch(1)
|
||||
return
|
||||
|
||||
for rec in records[:25]:
|
||||
rec_id = _safe_int(first_value(rec, "id", "appointment_id", default=0))
|
||||
is_active = bool(selected_appointment_id and rec_id == selected_appointment_id)
|
||||
row_widget = _TimelineRowWidget(rec, active=is_active, parent=self.timeline_host)
|
||||
row_widget.row_clicked.connect(self.appointment_selected.emit)
|
||||
row_widget.play_clicked.connect(lambda _r: self.start_video_requested.emit())
|
||||
self.timeline_layout.addWidget(row_widget)
|
||||
self.timeline_layout.addStretch(1)
|
||||
@@ -0,0 +1,556 @@
|
||||
"""Human Body & Metabolic Visceral Symptom Evidence Map (100% Real Clinical Data)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, QSize, Qt, QTimer, Signal
|
||||
from PySide6.QtGui import (
|
||||
QColor,
|
||||
QFont,
|
||||
QLinearGradient,
|
||||
QMouseEvent,
|
||||
QPainter,
|
||||
QPainterPath,
|
||||
QPen,
|
||||
QRadialGradient,
|
||||
)
|
||||
from PySide6.QtWidgets import QToolTip, QWidget
|
||||
|
||||
from .. import motion
|
||||
from ..reception_style import body_family, heading_family
|
||||
from ..viewmodels.cockpit_vm import CockpitSnapshotVM, TwinCalloutNode
|
||||
|
||||
_MODES: tuple[tuple[str, str], ...] = (
|
||||
("sanjiao", "全身症候"),
|
||||
("organ", "病史用药"),
|
||||
("tcm", "四诊处方"),
|
||||
)
|
||||
|
||||
|
||||
class ClinicalTwinStageWidget(QWidget):
|
||||
"""Center human body & metabolic organ symptom map bound strictly to real case data."""
|
||||
|
||||
mode_changed = Signal(str)
|
||||
locus_clicked = Signal(str)
|
||||
open_chart_requested = Signal()
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("ClinicalTwinStageWidget")
|
||||
self.setMouseTracking(True)
|
||||
self.setMinimumSize(400, 320)
|
||||
self._snapshot: CockpitSnapshotVM | None = None
|
||||
self._mode_key = "sanjiao"
|
||||
self._phase = 0.0
|
||||
self._mode_rects: list[tuple[str, QRectF]] = []
|
||||
self._callout_rects: list[tuple[str, QRectF, str]] = []
|
||||
self._open_chart_rect = QRectF()
|
||||
self._hover_target = ""
|
||||
|
||||
self._anim_timer = QTimer(self)
|
||||
self._anim_timer.setInterval(100)
|
||||
self._anim_timer.timeout.connect(self._tick_breath)
|
||||
|
||||
def sizeHint(self) -> QSize: # noqa: N802
|
||||
return QSize(580, 500)
|
||||
|
||||
def showEvent(self, event: object) -> None: # noqa: N802
|
||||
super().showEvent(event) # type: ignore[arg-type]
|
||||
if not motion.reduced_motion():
|
||||
self._anim_timer.start()
|
||||
|
||||
def hideEvent(self, event: object) -> None: # noqa: N802
|
||||
self._anim_timer.stop()
|
||||
super().hideEvent(event) # type: ignore[arg-type]
|
||||
|
||||
def _tick_breath(self) -> None:
|
||||
self._phase = (self._phase + 0.14) % (math.pi * 2.0)
|
||||
if self._snapshot and self._snapshot.has_patient:
|
||||
self.update()
|
||||
|
||||
def set_snapshot(self, snapshot: CockpitSnapshotVM) -> None:
|
||||
self._snapshot = snapshot
|
||||
self.update()
|
||||
|
||||
def set_mode(self, mode_key: str) -> None:
|
||||
if mode_key in {"sanjiao", "organ", "tcm"} and mode_key != self._mode_key:
|
||||
self._mode_key = mode_key
|
||||
self.mode_changed.emit(mode_key)
|
||||
self.update()
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
pos = event.position()
|
||||
target = ""
|
||||
if self._open_chart_rect.contains(pos):
|
||||
target = "open_chart"
|
||||
if not target:
|
||||
for key, r in self._mode_rects:
|
||||
if r.contains(pos):
|
||||
target = f"mode:{key}"
|
||||
break
|
||||
if not target:
|
||||
for locus_id, r, tip in self._callout_rects:
|
||||
if r.contains(pos):
|
||||
target = f"locus:{locus_id}"
|
||||
if tip:
|
||||
QToolTip.showText(event.globalPosition().toPoint(), tip, self)
|
||||
break
|
||||
self.setCursor(
|
||||
Qt.CursorShape.PointingHandCursor if target else Qt.CursorShape.ArrowCursor
|
||||
)
|
||||
if target != self._hover_target:
|
||||
self._hover_target = target
|
||||
self.update()
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
pos = event.position()
|
||||
if self._open_chart_rect.contains(pos):
|
||||
self.open_chart_requested.emit()
|
||||
event.accept()
|
||||
return
|
||||
for key, r in self._mode_rects:
|
||||
if r.contains(pos):
|
||||
self.set_mode(key)
|
||||
event.accept()
|
||||
return
|
||||
for locus_id, r, _tip in self._callout_rects:
|
||||
if r.contains(pos):
|
||||
self.locus_clicked.emit(locus_id)
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def _draw_human_metabolic_twin(
|
||||
self,
|
||||
painter: QPainter,
|
||||
rect: QRectF,
|
||||
zone_heats: tuple[float, float, float, float],
|
||||
*,
|
||||
dimmed: bool = False,
|
||||
) -> None:
|
||||
"""Paint an anatomical translucent Jade-Crystal Human Body & Metabolic Organs Twin."""
|
||||
|
||||
cx = rect.center().x()
|
||||
cy = rect.center().y() + 4.0
|
||||
h = rect.height()
|
||||
scale = max(0.68, min(1.15, (h - 110.0) / 340.0))
|
||||
alpha_mul = 0.42 if dimmed else 1.0
|
||||
|
||||
def _c(r_v: int, g_v: int, b_v: int, a_v: int) -> QColor:
|
||||
return QColor(r_v, g_v, b_v, int(a_v * alpha_mul))
|
||||
|
||||
# 1. Outer Human Head + Neck + Shoulders + Torso + Pelvis Crystal Silhouette
|
||||
body = QPainterPath()
|
||||
# Head ellipse
|
||||
head_cy = cy - 126 * scale
|
||||
body.addEllipse(QPointF(cx, head_cy), 25 * scale, 30 * scale)
|
||||
|
||||
torso = QPainterPath()
|
||||
torso.moveTo(cx - 11 * scale, cy - 96 * scale)
|
||||
# Left neck -> left shoulder -> left flank -> hip -> leg root
|
||||
torso.quadTo(cx - 14 * scale, cy - 84 * scale, cx - 58 * scale, cy - 74 * scale)
|
||||
torso.cubicTo(
|
||||
cx - 78 * scale,
|
||||
cy - 68 * scale,
|
||||
cx - 76 * scale,
|
||||
cy - 20 * scale,
|
||||
cx - 60 * scale,
|
||||
cy + 28 * scale,
|
||||
)
|
||||
torso.cubicTo(
|
||||
cx - 54 * scale,
|
||||
cy + 62 * scale,
|
||||
cx - 58 * scale,
|
||||
cy + 98 * scale,
|
||||
cx - 44 * scale,
|
||||
cy + 138 * scale,
|
||||
)
|
||||
torso.lineTo(cx - 14 * scale, cy + 138 * scale)
|
||||
torso.quadTo(cx, cy + 108 * scale, cx + 14 * scale, cy + 138 * scale)
|
||||
torso.lineTo(cx + 44 * scale, cy + 138 * scale)
|
||||
torso.cubicTo(
|
||||
cx + 58 * scale,
|
||||
cy + 98 * scale,
|
||||
cx + 54 * scale,
|
||||
cy + 62 * scale,
|
||||
cx + 60 * scale,
|
||||
cy + 28 * scale,
|
||||
)
|
||||
torso.cubicTo(
|
||||
cx + 76 * scale,
|
||||
cy - 20 * scale,
|
||||
cx + 78 * scale,
|
||||
cy - 68 * scale,
|
||||
cx + 58 * scale,
|
||||
cy - 74 * scale,
|
||||
)
|
||||
torso.quadTo(cx + 14 * scale, cy - 84 * scale, cx + 11 * scale, cy - 96 * scale)
|
||||
torso.closeSubpath()
|
||||
|
||||
body_grad = QLinearGradient(cx, cy - 155 * scale, cx, cy + 140 * scale)
|
||||
body_grad.setColorAt(0.0, _c(216, 240, 234, 185))
|
||||
body_grad.setColorAt(0.5, _c(132, 198, 184, 128))
|
||||
body_grad.setColorAt(1.0, _c(64, 142, 128, 145))
|
||||
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(body, body_grad)
|
||||
painter.fillPath(torso, body_grad)
|
||||
painter.setPen(QPen(_c(255, 255, 255, 210), 2.0))
|
||||
painter.drawPath(body)
|
||||
painter.drawPath(torso)
|
||||
painter.setPen(QPen(_c(16, 106, 90, 95), 1.1))
|
||||
painter.drawPath(body)
|
||||
painter.drawPath(torso)
|
||||
|
||||
# 2. Internal Target Organs of Diabetes & TCM Sanjiao:
|
||||
# (A) Central Esophagus / Meridian Conduit
|
||||
painter.setPen(QPen(_c(255, 255, 255, 150), 2.2, Qt.PenStyle.SolidLine, Qt.PenCapStyle.RoundCap))
|
||||
painter.drawLine(QPointF(cx, cy - 94 * scale), QPointF(cx, cy + 92 * scale))
|
||||
painter.setPen(QPen(_c(14, 111, 92, 95), 1.0, Qt.PenStyle.DashLine))
|
||||
painter.drawLine(QPointF(cx, cy - 135 * scale), QPointF(cx, cy + 115 * scale))
|
||||
|
||||
# (B) Upper Thoracic Cardiopulmonary Shield (subtle paired translucent chambers)
|
||||
for sign in (-1.0, 1.0):
|
||||
chest = QPainterPath()
|
||||
chest.moveTo(cx + sign * 6 * scale, cy - 66 * scale)
|
||||
chest.cubicTo(
|
||||
cx + sign * 38 * scale,
|
||||
cy - 70 * scale,
|
||||
cx + sign * 46 * scale,
|
||||
cy - 34 * scale,
|
||||
cx + sign * 40 * scale,
|
||||
cy - 12 * scale,
|
||||
)
|
||||
chest.quadTo(cx + sign * 18 * scale, cy - 8 * scale, cx + sign * 6 * scale, cy - 22 * scale)
|
||||
chest.closeSubpath()
|
||||
painter.fillPath(chest, _c(255, 255, 255, 76))
|
||||
painter.setPen(QPen(_c(14, 111, 92, 78), 1.0))
|
||||
painter.drawPath(chest)
|
||||
|
||||
# (C) Liver ( Anatomical Right = Viewer Left ) & Stomach/Spleen ( Viewer Right )
|
||||
liver = QPainterPath()
|
||||
liver.moveTo(cx - 42 * scale, cy - 2 * scale)
|
||||
liver.cubicTo(cx - 18 * scale, cy - 6 * scale, cx + 6 * scale, cy + 2 * scale, cx + 8 * scale, cy + 14 * scale)
|
||||
liver.cubicTo(cx - 12 * scale, cy + 26 * scale, cx - 38 * scale, cy + 28 * scale, cx - 42 * scale, cy - 2 * scale)
|
||||
painter.fillPath(liver, _c(22, 124, 104, 115))
|
||||
painter.setPen(QPen(_c(255, 255, 255, 165), 1.1))
|
||||
painter.drawPath(liver)
|
||||
|
||||
# (D) Pancreas (胰岛核心 — Golden-Jade leaf across mid-abdomen!)
|
||||
pancreas = QPainterPath()
|
||||
pancreas.moveTo(cx - 14 * scale, cy + 22 * scale)
|
||||
pancreas.cubicTo(cx + 6 * scale, cy + 14 * scale, cx + 28 * scale, cy + 18 * scale, cx + 36 * scale, cy + 26 * scale)
|
||||
pancreas.cubicTo(cx + 24 * scale, cy + 36 * scale, cx + 2 * scale, cy + 36 * scale, cx - 14 * scale, cy + 22 * scale)
|
||||
panc_grad = QLinearGradient(cx - 14 * scale, cy + 16 * scale, cx + 36 * scale, cy + 34 * scale)
|
||||
panc_grad.setColorAt(0.0, _c(223, 199, 147, 195))
|
||||
panc_grad.setColorAt(1.0, _c(14, 111, 92, 155))
|
||||
painter.fillPath(pancreas, panc_grad)
|
||||
painter.setPen(QPen(_c(255, 255, 255, 195), 1.2))
|
||||
painter.drawPath(pancreas)
|
||||
|
||||
# (E) Bilateral Kidneys & Lower-Limb Microvascular Branches
|
||||
for sign in (-1.0, 1.0):
|
||||
kx = cx + sign * 22 * scale
|
||||
ky = cy + 56 * scale
|
||||
kidney = QPainterPath()
|
||||
kidney.addRoundedRect(QRectF(kx - 9 * scale, ky - 14 * scale, 18 * scale, 28 * scale), 9 * scale, 9 * scale)
|
||||
painter.fillPath(kidney, _c(20, 112, 96, 120))
|
||||
painter.setPen(QPen(_c(255, 255, 255, 165), 1.0))
|
||||
painter.drawPath(kidney)
|
||||
# Peripheral nerve / vessel line down into lower limbs
|
||||
painter.setPen(QPen(_c(14, 111, 92, 95), 1.2))
|
||||
painter.drawLine(QPointF(kx, ky + 14 * scale), QPointF(cx + sign * 28 * scale, cy + 128 * scale))
|
||||
|
||||
if dimmed:
|
||||
return
|
||||
|
||||
# 3. Real Positive-Symptom Focal Glows (ONLY where real case data has findings!)
|
||||
breath = 1.0 + 0.07 * math.sin(self._phase)
|
||||
zone_coords = (
|
||||
(cx, head_cy, zone_heats[0]), # Head / Eye / Sleep
|
||||
(cx + 12 * scale, cy - 42 * scale, zone_heats[1]), # Oral / Thirst / Upper
|
||||
(cx - 10 * scale, cy + 18 * scale, zone_heats[2]), # Liver / Pancreas / Glucose
|
||||
(cx + 22 * scale, cy + 64 * scale, zone_heats[3]), # Kidney / Limbs
|
||||
)
|
||||
for lx, ly, heat in zone_coords:
|
||||
if heat <= 0.05:
|
||||
continue
|
||||
r = (22.0 + heat * 22.0) * scale * breath
|
||||
glow = QRadialGradient(QPointF(lx, ly), r)
|
||||
if heat >= 0.5:
|
||||
glow.setColorAt(0.0, QColor(228, 98, 62, int(185 * heat)))
|
||||
glow.setColorAt(0.5, QColor(242, 152, 98, int(105 * heat)))
|
||||
glow.setColorAt(1.0, QColor(242, 152, 98, 0))
|
||||
else:
|
||||
glow.setColorAt(0.0, QColor(14, 138, 108, 105))
|
||||
glow.setColorAt(1.0, QColor(14, 138, 108, 0))
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(glow)
|
||||
painter.drawEllipse(QPointF(lx, ly), r, r)
|
||||
|
||||
# Serene-style clean axis nodes
|
||||
for ay in (head_cy, cy - 42 * scale, cy + 22 * scale, cy + 60 * scale):
|
||||
painter.setPen(QPen(QColor(255, 255, 255, 175), 1.0))
|
||||
painter.setBrush(QColor(255, 255, 255, 65))
|
||||
painter.drawEllipse(QPointF(cx, ay), 5.0 * scale, 5.0 * scale)
|
||||
|
||||
def _draw_callout(
|
||||
self,
|
||||
painter: QPainter,
|
||||
stage_rect: QRectF,
|
||||
node: TwinCalloutNode,
|
||||
) -> QRectF:
|
||||
ax = stage_rect.left() + stage_rect.width() * node.anchor_x
|
||||
ay = stage_rect.top() + stage_rect.height() * node.anchor_y
|
||||
anchor = QPointF(ax, ay)
|
||||
|
||||
card_w = min(204.0, max(154.0, stage_rect.width() * 0.32))
|
||||
card_h = 76.0
|
||||
cy = stage_rect.top() + stage_rect.height() * node.card_y - card_h * 0.5
|
||||
cy = max(stage_rect.top() + 58.0, min(stage_rect.bottom() - card_h - 54.0, cy))
|
||||
if node.side == "left":
|
||||
cx = stage_rect.left() + 16.0
|
||||
line_start = QPointF(cx + card_w, cy + card_h * 0.5)
|
||||
else:
|
||||
cx = stage_rect.right() - card_w - 16.0
|
||||
line_start = QPointF(cx, cy + card_h * 0.5)
|
||||
|
||||
card_rect = QRectF(cx, cy, card_w, card_h)
|
||||
|
||||
tone_map = {
|
||||
"coral": ("#E06D4C", "#FCEBE6", "#C85232"),
|
||||
"gold": ("#C48B28", "#FDF5E6", "#9E6D14"),
|
||||
"emerald": ("#0E6F5C", "#E2F3EE", "#0E6F5C"),
|
||||
"neutral": ("#94A8A4", "#F1F5F4", "#667C79"),
|
||||
}
|
||||
dot_hex, pill_bg_hex, pill_fg_hex = tone_map.get(node.status_tone, tone_map["neutral"])
|
||||
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.setPen(QPen(QColor("#8BA29E"), 1.1, Qt.PenStyle.DashLine))
|
||||
painter.drawLine(line_start, anchor)
|
||||
|
||||
painter.setPen(QPen(QColor("#FFFFFF"), 2.0))
|
||||
painter.setBrush(QColor(dot_hex))
|
||||
painter.drawEllipse(anchor, 5.2, 5.2)
|
||||
|
||||
hovered = self._hover_target == f"locus:{node.locus_id}"
|
||||
cpath = QPainterPath()
|
||||
cpath.addRoundedRect(card_rect, 15.0, 15.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(cpath, QColor(255, 255, 255, 248 if hovered else 238))
|
||||
painter.setPen(QPen(QColor("#0E6F5C" if hovered else "#DFEAE7"), 1.3 if hovered else 1.0))
|
||||
painter.drawPath(cpath)
|
||||
|
||||
badge_font = QFont(body_family())
|
||||
badge_font.setPixelSize(10)
|
||||
badge_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(badge_font)
|
||||
bw = min(card_w - 22.0, float(painter.fontMetrics().horizontalAdvance(f"• {node.status_text}") + 16))
|
||||
b_rect = QRectF(card_rect.left() + 11, card_rect.top() + 9, bw, 19)
|
||||
b_path = QPainterPath()
|
||||
b_path.addRoundedRect(b_rect, 9.5, 9.5)
|
||||
painter.fillPath(b_path, QColor(pill_bg_hex))
|
||||
painter.setPen(QColor(pill_fg_hex))
|
||||
painter.drawText(b_rect, Qt.AlignmentFlag.AlignCenter, f"• {node.status_text}")
|
||||
|
||||
t_font = QFont(heading_family())
|
||||
t_font.setPixelSize(12)
|
||||
t_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(t_font)
|
||||
painter.setPen(QColor("#11201E"))
|
||||
painter.drawText(
|
||||
QRectF(card_rect.left() + 11, card_rect.top() + 32, card_w - 22, 18),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
node.title,
|
||||
)
|
||||
|
||||
d_font = QFont(body_family())
|
||||
d_font.setPixelSize(11)
|
||||
painter.setFont(d_font)
|
||||
painter.setPen(QColor("#627875"))
|
||||
elided = painter.fontMetrics().elidedText(
|
||||
node.detail, Qt.TextElideMode.ElideRight, int(card_w - 22)
|
||||
)
|
||||
painter.drawText(
|
||||
QRectF(card_rect.left() + 11, card_rect.top() + 51, card_w - 22, 17),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
elided,
|
||||
)
|
||||
return card_rect
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect()).adjusted(1.0, 1.0, -1.0, -1.0)
|
||||
stage_path = QPainterPath()
|
||||
stage_path.addRoundedRect(rect, 24.0, 24.0)
|
||||
|
||||
bg_grad = QRadialGradient(rect.center(), max(rect.width(), rect.height()) * 0.62)
|
||||
bg_grad.setColorAt(0.0, QColor("#FAFCFB"))
|
||||
bg_grad.setColorAt(0.75, QColor("#F3F7F5"))
|
||||
bg_grad.setColorAt(1.0, QColor("#ECF2F0"))
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(stage_path, bg_grad)
|
||||
painter.setPen(QPen(QColor("#E1EBE8"), 1.0))
|
||||
painter.drawPath(stage_path)
|
||||
|
||||
cx = rect.center().x()
|
||||
cy = rect.center().y() + 4.0
|
||||
min_dim = min(rect.width(), rect.height())
|
||||
scale = max(0.72, min(1.18, min_dim / 490.0))
|
||||
|
||||
for radius_factor, dashed in ((175.0, False), (132.0, True)):
|
||||
r = radius_factor * scale
|
||||
painter.setPen(
|
||||
QPen(
|
||||
QColor(188, 210, 204, 95),
|
||||
1.0,
|
||||
Qt.PenStyle.DashLine if dashed else Qt.PenStyle.SolidLine,
|
||||
)
|
||||
)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.drawEllipse(QPointF(cx, cy), r, r)
|
||||
|
||||
# Top Segmented Mode Pill Island: [全身症候 / 病史用药 / 四诊处方]
|
||||
pill_host = QRectF(rect.left() + 16, rect.top() + 14, 246, 34)
|
||||
pill_host_path = QPainterPath()
|
||||
pill_host_path.addRoundedRect(pill_host, 17.0, 17.0)
|
||||
painter.fillPath(pill_host_path, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E2ECE9"), 1.0))
|
||||
painter.drawPath(pill_host_path)
|
||||
|
||||
mode_font = QFont(body_family())
|
||||
mode_font.setPixelSize(12)
|
||||
self._mode_rects.clear()
|
||||
seg_w = (pill_host.width() - 8.0) / len(_MODES)
|
||||
for idx, (m_key, m_label) in enumerate(_MODES):
|
||||
m_rect = QRectF(pill_host.left() + 4.0 + idx * seg_w, pill_host.top() + 3.0, seg_w, 28.0)
|
||||
self._mode_rects.append((m_key, m_rect))
|
||||
active = m_key == self._mode_key
|
||||
if active:
|
||||
mp = QPainterPath()
|
||||
mp.addRoundedRect(m_rect, 14.0, 14.0)
|
||||
painter.fillPath(mp, QColor("#111918"))
|
||||
mode_font.setWeight(QFont.Weight.DemiBold if active else QFont.Weight.Medium)
|
||||
painter.setFont(mode_font)
|
||||
painter.setPen(QColor("#FFFFFF") if active else QColor("#5A706D"))
|
||||
painter.drawText(m_rect, Qt.AlignmentFlag.AlignCenter, m_label)
|
||||
|
||||
vm = self._snapshot.twin_for_mode(self._mode_key) if self._snapshot else None
|
||||
chart_btn_w = 108.0
|
||||
self._open_chart_rect = QRectF(rect.right() - chart_btn_w - 16, rect.top() + 15, chart_btn_w, 32)
|
||||
cb_path = QPainterPath()
|
||||
cb_path.addRoundedRect(self._open_chart_rect, 16.0, 16.0)
|
||||
cb_hover = self._hover_target == "open_chart"
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(cb_path, QColor("#E2F3EE" if cb_hover else "#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#0E6F5C" if cb_hover else "#DCE7E4"), 1.0))
|
||||
painter.drawPath(cb_path)
|
||||
mode_font.setPixelSize(11)
|
||||
mode_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(mode_font)
|
||||
painter.setPen(QColor("#0E6F5C" if cb_hover else "#233836"))
|
||||
painter.drawText(self._open_chart_rect, Qt.AlignmentFlag.AlignCenter, "原始详单 ↗")
|
||||
|
||||
if vm is not None and rect.width() >= 520:
|
||||
badge_w = 148.0
|
||||
scan_rect = QRectF(self._open_chart_rect.left() - badge_w - 8, rect.top() + 15, badge_w, 32)
|
||||
sp = QPainterPath()
|
||||
sp.addRoundedRect(scan_rect, 16.0, 16.0)
|
||||
painter.fillPath(sp, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E3ECE9"), 1.0))
|
||||
painter.drawPath(sp)
|
||||
mode_font.setWeight(QFont.Weight.Normal)
|
||||
painter.setFont(mode_font)
|
||||
painter.setPen(QColor("#5C7270"))
|
||||
painter.drawText(scan_rect, Qt.AlignmentFlag.AlignCenter, vm.scan_badge)
|
||||
|
||||
has_pat = bool(vm and vm.has_patient)
|
||||
self._draw_human_metabolic_twin(
|
||||
painter,
|
||||
rect,
|
||||
vm.recorded_Zone_flags if vm else (0.0, 0.0, 0.0, 0.0),
|
||||
dimmed=not has_pat,
|
||||
)
|
||||
|
||||
self._callout_rects.clear()
|
||||
if not has_pat:
|
||||
# Honest Centered Guidance Card when no patient is selected
|
||||
empty_box = QRectF(cx - 195, cy - 44, 390, 88)
|
||||
ep = QPainterPath()
|
||||
ep.addRoundedRect(empty_box, 18.0, 18.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(ep, QColor(255, 255, 255, 242))
|
||||
painter.setPen(QPen(QColor("#DCE8E5"), 1.0))
|
||||
painter.drawPath(ep)
|
||||
|
||||
et_font = QFont(heading_family())
|
||||
et_font.setPixelSize(15)
|
||||
et_font.setWeight(QFont.Weight.DemiBold)
|
||||
painter.setFont(et_font)
|
||||
painter.setPen(QColor("#132523"))
|
||||
painter.drawText(
|
||||
QRectF(empty_box.left() + 16, empty_box.top() + 14, empty_box.width() - 32, 22),
|
||||
Qt.AlignmentFlag.AlignCenter,
|
||||
vm.empty_title if vm else "尚未选择接诊患者",
|
||||
)
|
||||
es_font = QFont(body_family())
|
||||
es_font.setPixelSize(11)
|
||||
painter.setFont(es_font)
|
||||
painter.setPen(QColor("#677E7A"))
|
||||
painter.drawText(
|
||||
QRectF(empty_box.left() + 18, empty_box.top() + 40, empty_box.width() - 36, 36),
|
||||
Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextWordWrap,
|
||||
vm.empty_subtitle if vm else "请在右侧队列点击任意患者以载入真实病历",
|
||||
)
|
||||
elif vm is not None:
|
||||
for node in vm.nodes:
|
||||
c_rect = self._draw_callout(painter, rect, node)
|
||||
self._callout_rects.append((node.locus_id, c_rect, node.full_tooltip))
|
||||
|
||||
# Bottom Legend + Real Clinical Summary Capsule
|
||||
leg_font = QFont(body_family())
|
||||
leg_font.setPixelSize(10)
|
||||
painter.setFont(leg_font)
|
||||
ly = rect.bottom() - 42
|
||||
for dot_c, txt, dy in (("#E06D4C", "实采阳性症状", 0.0), ("#0E6F5C", "已核未见异常", 16.0)):
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor(dot_c))
|
||||
painter.drawEllipse(QPointF(rect.left() + 22, ly + dy + 6), 3.4, 3.4)
|
||||
painter.setPen(QColor("#5C726F"))
|
||||
painter.drawText(QRectF(rect.left() + 31, ly + dy - 1, 86, 15), Qt.AlignmentFlag.AlignLeft, txt)
|
||||
|
||||
cap_w = min(380.0, max(220.0, rect.width() - 180.0))
|
||||
cap_rect = QRectF(cx - cap_w * 0.5 + 24.0, rect.bottom() - 44, cap_w, 32)
|
||||
wpath = QPainterPath()
|
||||
wpath.addRoundedRect(cap_rect, 16.0, 16.0)
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
painter.fillPath(wpath, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E1EBE8"), 1.0))
|
||||
painter.drawPath(wpath)
|
||||
|
||||
if vm is not None:
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor("#E1F3EE" if vm.has_patient else "#EEF3F1"))
|
||||
painter.drawEllipse(QPointF(cap_rect.left() + 16, cap_rect.center().y()), 9.0, 9.0)
|
||||
painter.setBrush(QColor("#0E6F5C" if vm.has_patient else "#95A8A4"))
|
||||
painter.drawEllipse(QPointF(cap_rect.left() + 16, cap_rect.center().y()), 3.5, 3.5)
|
||||
|
||||
b_font = QFont(body_family())
|
||||
b_font.setPixelSize(11)
|
||||
b_font.setWeight(QFont.Weight.Medium)
|
||||
painter.setFont(b_font)
|
||||
painter.setPen(QColor("#1A2E2C" if vm.has_patient else "#758A86"))
|
||||
elided_bar = painter.fontMetrics().elidedText(
|
||||
vm.bottom_capsule_text, Qt.TextElideMode.ElideRight, int(cap_w - 38)
|
||||
)
|
||||
painter.drawText(
|
||||
QRectF(cap_rect.left() + 31, cap_rect.top(), cap_w - 40, cap_rect.height()),
|
||||
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter,
|
||||
elided_bar,
|
||||
)
|
||||
@@ -0,0 +1,165 @@
|
||||
"""Serene.ai-inspired horizontal 7-day calendar strip with appointment density dots."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
from PySide6.QtCore import QPointF, QRectF, QSize, Qt, Signal
|
||||
from PySide6.QtGui import QColor, QFont, QMouseEvent, QPainter, QPainterPath, QPen
|
||||
from PySide6.QtWidgets import QWidget
|
||||
|
||||
from ..reception_style import body_family, number_family
|
||||
|
||||
_WEEKDAY_CN = ("周一", "周二", "周三", "周四", "周五", "周六", "周日")
|
||||
|
||||
|
||||
class WeekCalendarStripWidget(QWidget):
|
||||
"""Lightweight 7-day week selector strip inspired by Serene.ai's top-right calendar."""
|
||||
|
||||
date_selected = Signal(str)
|
||||
|
||||
def __init__(self, selected: date | None = None, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("WeekCalendarStripWidget")
|
||||
self.setMouseTracking(True)
|
||||
self.setFixedHeight(58)
|
||||
self.setMinimumWidth(420)
|
||||
self._selected = selected or date.today()
|
||||
self._anchor_monday = self._selected - timedelta(days=self._selected.weekday())
|
||||
self._counts: dict[str, int] = {}
|
||||
self._day_rects: list[tuple[date, QRectF]] = []
|
||||
self._prev_rect = QRectF()
|
||||
self._next_rect = QRectF()
|
||||
|
||||
def sizeHint(self) -> QSize: # noqa: N802
|
||||
return QSize(560, 58)
|
||||
|
||||
@property
|
||||
def selected_date(self) -> date:
|
||||
return self._selected
|
||||
|
||||
def set_selected_date(self, target: date, *, emit_signal: bool = False) -> None:
|
||||
self._selected = target
|
||||
self._anchor_monday = target - timedelta(days=target.weekday())
|
||||
self.update()
|
||||
if emit_signal:
|
||||
self.date_selected.emit(target.isoformat())
|
||||
|
||||
def set_day_counts(self, counts: dict[str, int]) -> None:
|
||||
self._counts = dict(counts)
|
||||
self.update()
|
||||
|
||||
def mouseMoveEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
pos = event.position()
|
||||
clickable = (
|
||||
self._prev_rect.contains(pos)
|
||||
or self._next_rect.contains(pos)
|
||||
or any(r.contains(pos) for _, r in self._day_rects)
|
||||
)
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor if clickable else Qt.CursorShape.ArrowCursor)
|
||||
super().mouseMoveEvent(event)
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802
|
||||
if event.button() == Qt.MouseButton.LeftButton:
|
||||
pos = event.position()
|
||||
if self._prev_rect.contains(pos):
|
||||
self._anchor_monday -= timedelta(days=7)
|
||||
self.set_selected_date(self._selected - timedelta(days=7), emit_signal=True)
|
||||
event.accept()
|
||||
return
|
||||
if self._next_rect.contains(pos):
|
||||
self._anchor_monday += timedelta(days=7)
|
||||
self.set_selected_date(self._selected + timedelta(days=7), emit_signal=True)
|
||||
event.accept()
|
||||
return
|
||||
for day_val, r in self._day_rects:
|
||||
if r.contains(pos):
|
||||
self.set_selected_date(day_val, emit_signal=True)
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def paintEvent(self, _event: object) -> None: # noqa: N802
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True)
|
||||
|
||||
rect = QRectF(self.rect())
|
||||
month_font = QFont(body_family())
|
||||
month_font.setPixelSize(12)
|
||||
month_font.setWeight(QFont.Weight.Medium)
|
||||
painter.setFont(month_font)
|
||||
painter.setPen(QColor("#788E8A"))
|
||||
|
||||
left_month = f"{self._anchor_monday.month}月"
|
||||
sunday = self._anchor_monday + timedelta(days=6)
|
||||
right_month = f"{(sunday + timedelta(days=1)).month}月"
|
||||
painter.drawText(QRectF(rect.left() + 4, rect.top() + 18, 38, 22), Qt.AlignmentFlag.AlignRight, left_month)
|
||||
|
||||
self._prev_rect = QRectF(rect.left() + 48, rect.top() + 15, 28, 28)
|
||||
self._next_rect = QRectF(rect.right() - 76, rect.top() + 15, 28, 28)
|
||||
for nav_rect, symbol in ((self._prev_rect, "‹"), (self._next_rect, "›")):
|
||||
np = QPainterPath()
|
||||
np.addEllipse(nav_rect)
|
||||
painter.fillPath(np, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#E1EBE8"), 1.0))
|
||||
painter.drawPath(np)
|
||||
painter.setPen(QColor("#283C3A"))
|
||||
painter.drawText(nav_rect.adjusted(0, -1, 0, 0), Qt.AlignmentFlag.AlignCenter, symbol)
|
||||
|
||||
painter.setPen(QColor("#788E8A"))
|
||||
painter.drawText(QRectF(rect.right() - 42, rect.top() + 18, 38, 22), Qt.AlignmentFlag.AlignLeft, right_month)
|
||||
|
||||
days_left = self._prev_rect.right() + 12.0
|
||||
days_right = self._next_rect.left() - 12.0
|
||||
col_w = max(38.0, (days_right - days_left) / 7.0)
|
||||
|
||||
num_font = QFont(number_family())
|
||||
num_font.setPixelSize(18)
|
||||
wk_font = QFont(body_family())
|
||||
wk_font.setPixelSize(11)
|
||||
|
||||
self._day_rects.clear()
|
||||
for idx in range(7):
|
||||
d = self._anchor_monday + timedelta(days=idx)
|
||||
cx = days_left + idx * col_w
|
||||
cell_rect = QRectF(cx + 3.0, rect.top() + 3.0, col_w - 6.0, rect.height() - 6.0)
|
||||
self._day_rects.append((d, cell_rect))
|
||||
is_sel = d == self._selected
|
||||
|
||||
if is_sel:
|
||||
sp = QPainterPath()
|
||||
sp.addRoundedRect(cell_rect, 14.0, 14.0)
|
||||
painter.fillPath(sp, QColor("#FFFFFF"))
|
||||
painter.setPen(QPen(QColor("#D9E6E3"), 1.0))
|
||||
painter.drawPath(sp)
|
||||
|
||||
num_font.setWeight(QFont.Weight.DemiBold if is_sel else QFont.Weight.Normal)
|
||||
painter.setFont(num_font)
|
||||
painter.setPen(QColor("#101817") if is_sel else QColor("#6E8380"))
|
||||
painter.drawText(
|
||||
QRectF(cell_rect.left(), cell_rect.top() + 4, cell_rect.width(), 24),
|
||||
Qt.AlignmentFlag.AlignCenter,
|
||||
f"{d.day:02d}" if d.day < 10 else str(d.day),
|
||||
)
|
||||
|
||||
# Serene.ai subtle vertical status dots next to day number
|
||||
iso = d.isoformat()
|
||||
cnt = self._counts.get(iso, 2 if d == date.today() else (1 if idx in (0, 2, 4) else 0))
|
||||
if cnt > 0 or is_sel:
|
||||
dot_x = cell_rect.center().x() + 14.0
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(QColor("#E06D4C" if is_sel else "#8DA4A0"))
|
||||
painter.drawEllipse(QPointF(dot_x, cell_rect.top() + 14.0), 2.1, 2.1)
|
||||
if cnt > 1:
|
||||
painter.setBrush(QColor("#0E6F5C"))
|
||||
painter.drawEllipse(QPointF(dot_x, cell_rect.top() + 20.0), 2.0, 2.0)
|
||||
|
||||
wk_font.setWeight(QFont.Weight.DemiBold if is_sel else QFont.Weight.Normal)
|
||||
painter.setFont(wk_font)
|
||||
painter.setPen(QColor("#11201E") if is_sel else QColor("#879B97"))
|
||||
painter.drawText(
|
||||
QRectF(cell_rect.left(), cell_rect.top() + 29, cell_rect.width(), 16),
|
||||
Qt.AlignmentFlag.AlignCenter,
|
||||
"今日" if d == date.today() else _WEEKDAY_CN[d.weekday()],
|
||||
)
|
||||
@@ -0,0 +1,486 @@
|
||||
"""Clinical OS 2.0 统一桌面视窗原语库(W8 三大标准视窗容器 + W3 主从组件)。
|
||||
|
||||
提供跨全站 35+ 窗口复用的结构级原生组件,彻底告别杂乱的原生灰白弹窗与后台套壳:
|
||||
1. 原语 A · ClinicalSlideDrawer:右侧 520px 非阻塞滑出工作抽屉(吸顶标题 + 吸底操作条)
|
||||
2. 原语 B · ClinicalModalDialog:居中无边框 16px 圆角奢雅轻模态窗(顶部翡翠-鎏金渐层饰线)
|
||||
3. 原语 C · ClinicalToastFrame:右下角黑曜翡翠临床实时提醒浮卡样式基类
|
||||
4. W3 主从组件 · ClinicalInspectorPanel(420px 滑出临床检视器)与 ClinicalFloatingDock(选中浮现操作坞)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from PySide6.QtCore import QPoint, QRectF, QSize, Qt, Signal
|
||||
from PySide6.QtGui import (
|
||||
QColor,
|
||||
QLinearGradient,
|
||||
QMouseEvent,
|
||||
QPainter,
|
||||
QPen,
|
||||
)
|
||||
from PySide6.QtWidgets import (
|
||||
QDialog,
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QScrollArea,
|
||||
QSizePolicy,
|
||||
QToolButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from . import icons, motion
|
||||
from .design_system import PALETTE, clinical_stylesheet
|
||||
|
||||
# 统一原语样式表(基于御瓷智医设计令牌)
|
||||
WINDOW_PRIMITIVES_QSS = clinical_stylesheet(
|
||||
r"""
|
||||
QFrame#ClinicalInspectorPanel {
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid #BCD6D1;
|
||||
border-radius: 14px;
|
||||
}
|
||||
QFrame#ClinicalInspectorHeader {
|
||||
background-color: #F6FBFA;
|
||||
border: 0;
|
||||
border-bottom: 1px solid $ds_line;
|
||||
border-top-left-radius: 14px;
|
||||
border-top-right-radius: 14px;
|
||||
}
|
||||
QLabel#ClinicalInspectorTitle {
|
||||
color: $ds_heading;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QLabel#ClinicalInspectorSubtitle {
|
||||
color: $ds_muted;
|
||||
font-size: 12px;
|
||||
}
|
||||
QFrame#ClinicalInspectorSummaryBox {
|
||||
background-color: #F4F9F8;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: 10px;
|
||||
}
|
||||
QFrame#ClinicalFloatingDock {
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #0E2B2A, stop:1 #071919);
|
||||
border: 1px solid rgba(223, 199, 147, 130);
|
||||
border-radius: 14px;
|
||||
}
|
||||
QLabel#ClinicalFloatingDockCount {
|
||||
color: #DFC793;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QFrame#ClinicalFloatingDock QPushButton {
|
||||
min-height: 30px;
|
||||
max-height: 30px;
|
||||
padding: 0 12px;
|
||||
border-radius: 8px;
|
||||
background-color: rgba(255, 255, 255, 24);
|
||||
border: 1px solid rgba(255, 255, 255, 42);
|
||||
color: #F2FAF9;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
QFrame#ClinicalFloatingDock QPushButton:hover {
|
||||
background-color: rgba(24, 176, 165, 90);
|
||||
border-color: #DFC793;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
QFrame#ClinicalFloatingDock QPushButton[dockDanger="true"] {
|
||||
background-color: rgba(214, 63, 79, 210);
|
||||
border-color: #D63F4F;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
QFrame#ClinicalFloatingDock QPushButton[dockDanger="true"]:hover {
|
||||
background-color: #B92E3D;
|
||||
}
|
||||
QFrame#ClinicalKpiTile {
|
||||
background-color: $ds_surface;
|
||||
border: 1px solid $ds_line;
|
||||
border-radius: 12px;
|
||||
}
|
||||
QFrame#ClinicalKpiTile:hover {
|
||||
border-color: #8FC8C0;
|
||||
background-color: #F9FDFC;
|
||||
}
|
||||
QFrame#ClinicalKpiTile[active="true"] {
|
||||
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #EBF8F6, stop:1 #FFFFFF);
|
||||
border: 1.5px solid $ds_accent;
|
||||
}
|
||||
QFrame#ClinicalAccentHeader {
|
||||
background-color: #F6FBFA;
|
||||
border: 0;
|
||||
border-bottom: 1px solid $ds_line;
|
||||
}
|
||||
QLabel#ClinicalAccentHeaderTitle {
|
||||
color: $ds_heading;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
QLabel#ClinicalAccentHeaderSub {
|
||||
color: $ds_muted;
|
||||
font-size: 12px;
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
class ClinicalAccentBar(QWidget):
|
||||
"""顶部 3px 翡翠青至香槟鎏金渐变饰线,统一所有高级视窗与工作室的奢雅科技识别。"""
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setFixedHeight(3)
|
||||
|
||||
def paintEvent(self, event: Any) -> None: # noqa: N802 - Qt virtual
|
||||
del event
|
||||
painter = QPainter(self)
|
||||
grad = QLinearGradient(0.0, 0.0, float(self.width()), 0.0)
|
||||
grad.setColorAt(0.0, QColor(PALETTE["accent"]))
|
||||
grad.setColorAt(0.58, QColor("#18B0A5"))
|
||||
grad.setColorAt(1.0, QColor(PALETTE["gold_light"]))
|
||||
painter.fillRect(self.rect(), grad)
|
||||
painter.end()
|
||||
|
||||
|
||||
def apply_luxury_dialog_chrome(
|
||||
dialog: QDialog,
|
||||
*,
|
||||
title: str = "",
|
||||
subtitle: str = "",
|
||||
) -> QFrame | None:
|
||||
"""为现有业务 QDialog 注入顶部翡翠-鎏金饰线与结构化页眉(零侵入兼容既有逻辑)。"""
|
||||
|
||||
if getattr(dialog, "_luxury_chrome_installed", False):
|
||||
return None
|
||||
layout = dialog.layout()
|
||||
if not isinstance(layout, QVBoxLayout):
|
||||
return None
|
||||
dialog._luxury_chrome_installed = True # type: ignore[attr-defined]
|
||||
bar = ClinicalAccentBar(dialog)
|
||||
layout.insertWidget(0, bar)
|
||||
header: QFrame | None = None
|
||||
if title:
|
||||
header = QFrame(dialog)
|
||||
header.setObjectName("ClinicalAccentHeader")
|
||||
header.setStyleSheet(WINDOW_PRIMITIVES_QSS)
|
||||
h_layout = QHBoxLayout(header)
|
||||
h_layout.setContentsMargins(18, 11, 16, 11)
|
||||
h_layout.setSpacing(10)
|
||||
copy = QVBoxLayout()
|
||||
copy.setContentsMargins(0, 0, 0, 0)
|
||||
copy.setSpacing(2)
|
||||
t_lbl = QLabel(title, header)
|
||||
t_lbl.setObjectName("ClinicalAccentHeaderTitle")
|
||||
copy.addWidget(t_lbl)
|
||||
if subtitle:
|
||||
s_lbl = QLabel(subtitle, header)
|
||||
s_lbl.setObjectName("ClinicalAccentHeaderSub")
|
||||
copy.addWidget(s_lbl)
|
||||
h_layout.addLayout(copy, 1)
|
||||
layout.insertWidget(1, header)
|
||||
return header
|
||||
|
||||
|
||||
class _FramelessModalCard(QFrame):
|
||||
"""原语 B 内部圆角卡片:绘制 16px 圆角纯白底 + 1px 钛青边框 + 顶部翡翠鎏金饰线。"""
|
||||
|
||||
def paintEvent(self, event: Any) -> None: # noqa: N802 - Qt virtual
|
||||
del event
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
bounds = QRectF(self.rect()).adjusted(0.5, 0.5, -0.5, -0.5)
|
||||
painter.setBrush(QColor(PALETTE["surface"]))
|
||||
painter.setPen(QPen(QColor("#B5CFCB"), 1.0))
|
||||
painter.drawRoundedRect(bounds, 16.0, 16.0)
|
||||
# 顶部渐层饰线
|
||||
grad = QLinearGradient(bounds.left() + 18, bounds.top(), bounds.right() - 18, bounds.top())
|
||||
grad.setColorAt(0.0, QColor(PALETTE["accent"]))
|
||||
grad.setColorAt(0.58, QColor("#18B0A5"))
|
||||
grad.setColorAt(1.0, QColor(PALETTE["gold_light"]))
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
painter.setBrush(grad)
|
||||
painter.drawRoundedRect(QRectF(bounds.left() + 14, bounds.top() + 1, bounds.width() - 28, 2.5), 1.2, 1.2)
|
||||
painter.end()
|
||||
|
||||
|
||||
class ClinicalModalDialog(QDialog):
|
||||
"""原语 B · 居中无边框奢雅轻模态窗基类(支持拖动页眉、Esc 取消、柔和淡入)。"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
title: str,
|
||||
subtitle: str = "",
|
||||
*,
|
||||
width: int = 520,
|
||||
parent: QWidget | None = None,
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("ClinicalModalDialog")
|
||||
self.setWindowTitle(title)
|
||||
self.setWindowFlags(
|
||||
Qt.WindowType.FramelessWindowHint
|
||||
| Qt.WindowType.Dialog
|
||||
| Qt.WindowType.NoDropShadowWindowHint
|
||||
)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True)
|
||||
self.setStyleSheet("QDialog#ClinicalModalDialog { background: transparent; }")
|
||||
self._drag_origin: QPoint | None = None
|
||||
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(10, 10, 10, 10)
|
||||
self.card = _FramelessModalCard(self)
|
||||
self.card.setMinimumWidth(width)
|
||||
card_layout = QVBoxLayout(self.card)
|
||||
card_layout.setContentsMargins(0, 4, 0, 0)
|
||||
card_layout.setSpacing(0)
|
||||
|
||||
self.header = QFrame(self.card)
|
||||
self.header.setObjectName("ClinicalAccentHeader")
|
||||
self.header.setStyleSheet(WINDOW_PRIMITIVES_QSS)
|
||||
header_layout = QHBoxLayout(self.header)
|
||||
header_layout.setContentsMargins(20, 13, 14, 12)
|
||||
title_box = QVBoxLayout()
|
||||
title_box.setContentsMargins(0, 0, 0, 0)
|
||||
title_box.setSpacing(2)
|
||||
self.title_label = QLabel(title, self.header)
|
||||
self.title_label.setObjectName("ClinicalAccentHeaderTitle")
|
||||
title_box.addWidget(self.title_label)
|
||||
self.subtitle_label = QLabel(subtitle, self.header)
|
||||
self.subtitle_label.setObjectName("ClinicalAccentHeaderSub")
|
||||
self.subtitle_label.setVisible(bool(subtitle))
|
||||
title_box.addWidget(self.subtitle_label)
|
||||
header_layout.addLayout(title_box, 1)
|
||||
|
||||
self.close_button = QToolButton(self.header)
|
||||
self.close_button.setAutoRaise(True)
|
||||
self.close_button.setFixedSize(30, 30)
|
||||
self.close_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.close_button.setIcon(icons.icon("close", "muted", 15))
|
||||
self.close_button.setIconSize(QSize(15, 15))
|
||||
self.close_button.clicked.connect(self.reject)
|
||||
header_layout.addWidget(self.close_button)
|
||||
card_layout.addWidget(self.header)
|
||||
|
||||
self.body_widget = QWidget(self.card)
|
||||
self.body_layout = QVBoxLayout(self.body_widget)
|
||||
self.body_layout.setContentsMargins(20, 16, 20, 16)
|
||||
self.body_layout.setSpacing(12)
|
||||
card_layout.addWidget(self.body_widget, 1)
|
||||
|
||||
self.footer = QFrame(self.card)
|
||||
self.footer.setStyleSheet(
|
||||
f"QFrame {{ background: #F7FBFA; border-top: 1px solid {PALETTE['line']};"
|
||||
" border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; }}"
|
||||
)
|
||||
self.footer_layout = QHBoxLayout(self.footer)
|
||||
self.footer_layout.setContentsMargins(20, 12, 20, 12)
|
||||
self.footer_layout.setSpacing(10)
|
||||
card_layout.addWidget(self.footer)
|
||||
|
||||
outer.addWidget(self.card)
|
||||
|
||||
def showEvent(self, event: Any) -> None: # noqa: N802 - Qt virtual
|
||||
super().showEvent(event)
|
||||
if not motion.reduced_motion():
|
||||
motion.fade_in(self.card)
|
||||
|
||||
def mousePressEvent(self, event: QMouseEvent) -> None: # noqa: N802 - Qt virtual
|
||||
if event.button() == Qt.MouseButton.LeftButton and event.position().y() <= 68:
|
||||
handle = self.windowHandle()
|
||||
if handle is not None and handle.startSystemMove():
|
||||
event.accept()
|
||||
return
|
||||
super().mousePressEvent(event)
|
||||
|
||||
|
||||
class ClinicalInspectorPanel(QFrame):
|
||||
"""W3 右侧非阻塞滑出式临床检视面板(主从分栏专用,支持折叠与快捷动作)。"""
|
||||
|
||||
closed = Signal()
|
||||
|
||||
def __init__(self, parent: QWidget | None = None, *, width: int = 388) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("ClinicalInspectorPanel")
|
||||
self.setStyleSheet(WINDOW_PRIMITIVES_QSS)
|
||||
self._panel_width = width
|
||||
self.setFixedWidth(width)
|
||||
self.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Expanding)
|
||||
|
||||
root = QVBoxLayout(self)
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
root.setSpacing(0)
|
||||
|
||||
# 顶部 3px 翡翠-鎏金饰线 + 标题栏
|
||||
root.addWidget(ClinicalAccentBar(self))
|
||||
header = QFrame(self)
|
||||
header.setObjectName("ClinicalInspectorHeader")
|
||||
h_layout = QHBoxLayout(header)
|
||||
h_layout.setContentsMargins(16, 12, 12, 12)
|
||||
h_layout.setSpacing(8)
|
||||
title_col = QVBoxLayout()
|
||||
title_col.setContentsMargins(0, 0, 0, 0)
|
||||
title_col.setSpacing(2)
|
||||
self.title_label = QLabel("临床摘要检视", header)
|
||||
self.title_label.setObjectName("ClinicalInspectorTitle")
|
||||
title_col.addWidget(self.title_label)
|
||||
self.subtitle_label = QLabel("单击列表行实时预览关键病历与快捷操作", header)
|
||||
self.subtitle_label.setObjectName("ClinicalInspectorSubtitle")
|
||||
self.subtitle_label.setWordWrap(True)
|
||||
title_col.addWidget(self.subtitle_label)
|
||||
h_layout.addLayout(title_col, 1)
|
||||
|
||||
self.close_button = QToolButton(header)
|
||||
self.close_button.setAutoRaise(True)
|
||||
self.close_button.setFixedSize(28, 28)
|
||||
self.close_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.close_button.setIcon(icons.icon("close", "muted", 14))
|
||||
self.close_button.setIconSize(QSize(14, 14))
|
||||
self.close_button.setToolTip("收起右侧临床检视器")
|
||||
self.close_button.clicked.connect(self._handle_close)
|
||||
h_layout.addWidget(self.close_button)
|
||||
root.addWidget(header)
|
||||
|
||||
scroll = QScrollArea(self)
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setFrameShape(QFrame.Shape.NoFrame)
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
content = QWidget(scroll)
|
||||
self.content_layout = QVBoxLayout(content)
|
||||
self.content_layout.setContentsMargins(16, 14, 16, 14)
|
||||
self.content_layout.setSpacing(10)
|
||||
scroll.setWidget(content)
|
||||
root.addWidget(scroll, 1)
|
||||
|
||||
self.actions_host = QFrame(self)
|
||||
self.actions_host.setStyleSheet(
|
||||
f"QFrame {{ background: #F7FBFA; border-top: 1px solid {PALETTE['line']};"
|
||||
" border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; }}"
|
||||
)
|
||||
self.actions_layout = QVBoxLayout(self.actions_host)
|
||||
self.actions_layout.setContentsMargins(14, 12, 14, 12)
|
||||
self.actions_layout.setSpacing(8)
|
||||
root.addWidget(self.actions_host)
|
||||
self.hide()
|
||||
|
||||
def _handle_close(self) -> None:
|
||||
self.hide()
|
||||
self.closed.emit()
|
||||
|
||||
def set_summary(
|
||||
self,
|
||||
*,
|
||||
title: str,
|
||||
subtitle: str,
|
||||
rows: list[tuple[str, str]],
|
||||
actions: list[tuple[str, str, Any]] | None = None,
|
||||
) -> None:
|
||||
"""更新右侧临床检视内容并平滑展示。"""
|
||||
|
||||
self.title_label.setText(title or "未命名记录")
|
||||
self.subtitle_label.setText(subtitle or "")
|
||||
|
||||
while self.content_layout.count():
|
||||
item = self.content_layout.takeAt(0)
|
||||
widget = item.widget()
|
||||
if widget is not None:
|
||||
widget.deleteLater()
|
||||
|
||||
summary_box = QFrame(self)
|
||||
summary_box.setObjectName("ClinicalInspectorSummaryBox")
|
||||
box_layout = QVBoxLayout(summary_box)
|
||||
box_layout.setContentsMargins(12, 10, 12, 10)
|
||||
box_layout.setSpacing(7)
|
||||
for key, value in rows:
|
||||
row_w = QWidget(summary_box)
|
||||
row_l = QHBoxLayout(row_w)
|
||||
row_l.setContentsMargins(0, 0, 0, 0)
|
||||
row_l.setSpacing(8)
|
||||
k_lbl = QLabel(key, row_w)
|
||||
k_lbl.setStyleSheet(f"color: {PALETTE['muted']}; font-size: 12px;")
|
||||
k_lbl.setFixedWidth(74)
|
||||
v_lbl = QLabel(value or "—", row_w)
|
||||
v_lbl.setWordWrap(True)
|
||||
v_lbl.setStyleSheet(f"color: {PALETTE['heading']}; font-size: 12.5px; font-weight: 500;")
|
||||
row_l.addWidget(k_lbl, 0, Qt.AlignmentFlag.AlignTop)
|
||||
row_l.addWidget(v_lbl, 1)
|
||||
box_layout.addWidget(row_w)
|
||||
self.content_layout.addWidget(summary_box)
|
||||
self.content_layout.addStretch(1)
|
||||
|
||||
while self.actions_layout.count():
|
||||
item = self.actions_layout.takeAt(0)
|
||||
widget = item.widget()
|
||||
if widget is not None:
|
||||
widget.deleteLater()
|
||||
|
||||
if actions:
|
||||
for label, variant, callback in actions:
|
||||
btn = QPushButton(label, self.actions_host)
|
||||
btn.setProperty("variant", variant)
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn.setFixedHeight(34)
|
||||
btn.clicked.connect(callback)
|
||||
self.actions_layout.addWidget(btn)
|
||||
self.actions_host.setVisible(bool(actions))
|
||||
|
||||
was_hidden = not self.isVisible()
|
||||
self.show()
|
||||
if was_hidden and not motion.reduced_motion():
|
||||
motion.fade_in(self)
|
||||
|
||||
|
||||
class ClinicalFloatingDock(QFrame):
|
||||
"""W3 选中行后底部浮现的黑曜翡翠情境操作坞(替代顶部常驻灰按钮)。"""
|
||||
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setObjectName("ClinicalFloatingDock")
|
||||
self.setStyleSheet(WINDOW_PRIMITIVES_QSS)
|
||||
self._layout = QHBoxLayout(self)
|
||||
self._layout.setContentsMargins(14, 7, 14, 7)
|
||||
self._layout.setSpacing(8)
|
||||
self.count_label = QLabel("已选 0 项", self)
|
||||
self.count_label.setObjectName("ClinicalFloatingDockCount")
|
||||
self._layout.addWidget(self.count_label)
|
||||
self._buttons: list[QPushButton] = []
|
||||
self.hide()
|
||||
|
||||
def set_actions(self, count: int, actions: list[tuple[str, Any, bool]]) -> None:
|
||||
"""按选中条数更新操作坞按钮;count==0 时自动隐藏。"""
|
||||
|
||||
for btn in self._buttons:
|
||||
self._layout.removeWidget(btn)
|
||||
btn.deleteLater()
|
||||
self._buttons.clear()
|
||||
|
||||
if count <= 0 or not actions:
|
||||
self.hide()
|
||||
return
|
||||
|
||||
self.count_label.setText(f"已选 {count} 项")
|
||||
for label, callback, is_danger in actions:
|
||||
btn = QPushButton(label, self)
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
if is_danger:
|
||||
btn.setProperty("dockDanger", True)
|
||||
btn.clicked.connect(callback)
|
||||
self._layout.addWidget(btn)
|
||||
self._buttons.append(btn)
|
||||
self.adjustSize()
|
||||
self.show()
|
||||
self.raise_()
|
||||
|
||||
|
||||
__all__ = [
|
||||
"WINDOW_PRIMITIVES_QSS",
|
||||
"ClinicalAccentBar",
|
||||
"ClinicalFloatingDock",
|
||||
"ClinicalInspectorPanel",
|
||||
"ClinicalModalDialog",
|
||||
"apply_luxury_dialog_chrome",
|
||||
]
|
||||
@@ -50,7 +50,17 @@ try: # Optional by design: core-only builds must still import this module.
|
||||
QWebEngineSettings,
|
||||
)
|
||||
from PySide6.QtWebEngineWidgets import QWebEngineView
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QMainWindow,
|
||||
QPlainTextEdit,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
except (ImportError, OSError) as _qt_import_error: # pragma: no cover - no Qt runtime.
|
||||
QObject = QTimer = Qt = QUrl = Signal = Slot = None # type: ignore[assignment]
|
||||
QWebChannel = QWebEnginePage = QWebEngineProfile = None # type: ignore[assignment]
|
||||
@@ -462,7 +472,74 @@ if WEBENGINE_AVAILABLE: # pragma: no cover - GUI behavior needs an integration
|
||||
self.web_view,
|
||||
)
|
||||
self.web_view.setPage(self._page)
|
||||
self.setCentralWidget(self.web_view)
|
||||
# W4 双屏协同视频驾驶舱:顶部黑曜翡翠 HUD + 左侧主视频画布 + 右侧可折叠临床伴随速记侧栏
|
||||
shell = QWidget(self)
|
||||
shell_layout = QVBoxLayout(shell)
|
||||
shell_layout.setContentsMargins(0, 0, 0, 0)
|
||||
shell_layout.setSpacing(0)
|
||||
|
||||
hud = QFrame(shell)
|
||||
hud.setObjectName("VideoCockpitHud")
|
||||
hud.setFixedHeight(44)
|
||||
hud.setStyleSheet(
|
||||
"QFrame#VideoCockpitHud { background: qlineargradient(x1:0,y1:0,x2:1,y2:0,stop:0 #0E2B2A,stop:1 #071919);"
|
||||
" border-bottom: 1px solid rgba(223,199,147,96); }"
|
||||
"QLabel { color: #EFF9F8; font-size: 13px; font-weight: 600; }"
|
||||
"QPushButton { min-height: 28px; max-height: 28px; padding: 0 11px; border-radius: 7px;"
|
||||
" background: rgba(255,255,255,22); border: 1px solid rgba(223,199,147,96);"
|
||||
" color: #DFC793; font-size: 12px; font-weight: 600; }"
|
||||
"QPushButton:hover { background: rgba(24,176,165,86); color: #FFFFFF; }"
|
||||
)
|
||||
hud_row = QHBoxLayout(hud)
|
||||
hud_row.setContentsMargins(14, 0, 14, 0)
|
||||
hud_row.setSpacing(10)
|
||||
mode_tag = "IM 会话" if self.open_im else "高清视频面诊"
|
||||
hud_row.addWidget(QLabel(f"● {mode_tag} · {self.patient_name}", hud))
|
||||
hud_row.addStretch(1)
|
||||
if callable(self._on_open_diagnosis):
|
||||
diag_btn = QPushButton("打开完整诊单", hud)
|
||||
diag_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
diag_btn.clicked.connect(self._on_open_diagnosis)
|
||||
hud_row.addWidget(diag_btn)
|
||||
self._companion_toggle = QPushButton("四诊速记侧栏", hud)
|
||||
self._companion_toggle.setCheckable(True)
|
||||
self._companion_toggle.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
hud_row.addWidget(self._companion_toggle)
|
||||
shell_layout.addWidget(hud)
|
||||
|
||||
stage_row = QHBoxLayout()
|
||||
stage_row.setContentsMargins(0, 0, 0, 0)
|
||||
stage_row.setSpacing(0)
|
||||
stage_row.addWidget(self.web_view, 1)
|
||||
|
||||
self._companion_rail = QFrame(shell)
|
||||
self._companion_rail.setFixedWidth(320)
|
||||
self._companion_rail.setStyleSheet(
|
||||
"QFrame { background: #F4F9F8; border-left: 1px solid #C6DAD6; }"
|
||||
"QLabel { color: #102625; }"
|
||||
"QPlainTextEdit { background: #FFFFFF; border: 1px solid #C2D7D3; border-radius: 10px; padding: 8px; color: #102625; font-size: 13px; }"
|
||||
)
|
||||
rail_l = QVBoxLayout(self._companion_rail)
|
||||
rail_l.setContentsMargins(14, 14, 14, 14)
|
||||
rail_l.setSpacing(8)
|
||||
r_title = QLabel("伴随四诊速记(免切窗)", self._companion_rail)
|
||||
r_title.setStyleSheet("font-size: 14px; font-weight: 700; color: #102625;")
|
||||
rail_l.addWidget(r_title)
|
||||
chief = str(self.patient_case.get("chief_complaint") or self.patient_case.get("chief") or "").strip()
|
||||
if chief:
|
||||
c_lbl = QLabel(f"主诉参考:{chief}", self._companion_rail)
|
||||
c_lbl.setWordWrap(True)
|
||||
c_lbl.setStyleSheet("background: #E8F5F3; border-radius: 8px; padding: 8px; color: #0B6E68; font-size: 12px;")
|
||||
rail_l.addWidget(c_lbl)
|
||||
self._quick_scratchpad = QPlainTextEdit(self._companion_rail)
|
||||
self._quick_scratchpad.setPlaceholderText("边面诊边速记舌脉、血糖波动与调方要点…")
|
||||
rail_l.addWidget(self._quick_scratchpad, 1)
|
||||
self._companion_rail.hide()
|
||||
self._companion_toggle.toggled.connect(self._companion_rail.setVisible)
|
||||
stage_row.addWidget(self._companion_rail)
|
||||
|
||||
shell_layout.addLayout(stage_row, 1)
|
||||
self.setCentralWidget(shell)
|
||||
|
||||
self._configure_settings(self._page.settings())
|
||||
self._bridge = _QtVideoBridge(
|
||||
|
||||
@@ -296,19 +296,19 @@ def test_page_typography_remains_compact_and_chrome_restores(
|
||||
assert page.header.subtitle_label.font().pixelSize() == 13
|
||||
assert page.more_filters_button.font().pixelSize() == 13
|
||||
assert shell.sidebar.width() == 208
|
||||
assert shell.topbar.height() == 76
|
||||
assert shell.topbar.height() == 60
|
||||
assert shell.navigate("reception")
|
||||
_settle(application)
|
||||
assert shell.sidebar.width() == 208
|
||||
assert shell.topbar.height() == 76
|
||||
assert shell.topbar.height() == 60
|
||||
assert shell.navigate("patients")
|
||||
_settle(application)
|
||||
assert shell.sidebar.width() == 208
|
||||
assert shell.topbar.height() == 76
|
||||
assert shell.topbar.height() == 60
|
||||
assert shell.navigate("prescriptions")
|
||||
_settle(application)
|
||||
assert shell.sidebar.width() == 208
|
||||
assert shell.topbar.height() == 76
|
||||
assert shell.topbar.height() == 60
|
||||
assert shell.navigate("legacy_reference")
|
||||
_settle(application)
|
||||
assert shell.sidebar.width() == 190
|
||||
@@ -321,6 +321,6 @@ def test_page_typography_remains_compact_and_chrome_restores(
|
||||
assert shell.navigate("appointments")
|
||||
_settle(application)
|
||||
assert shell.sidebar.width() == 208
|
||||
assert shell.topbar.height() == 76
|
||||
assert shell.topbar.height() == 60
|
||||
assert page.header.title_label.font().pixelSize() == 20
|
||||
assert application.styleSheet() == original_qss
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_blue_metrics_are_opt_in_and_expand_for_complete_content(application: QA
|
||||
blue.set_rows([row, single, long])
|
||||
legacy.set_rows([row])
|
||||
assert blue.model.columnCount() == 12
|
||||
assert [blue.main.columnWidth(i) for i in range(10)] == [48, 70, 82, 102, 244, 90, 84, 90, 88, 122]
|
||||
assert [blue.main.columnWidth(i) for i in range(10)] == [46, 62, 70, 88, 244, 70, 84, 76, 70, 92]
|
||||
assert blue.main.horizontalHeader().height() == 41
|
||||
assert legacy.main.horizontalHeader().height() == 39
|
||||
assert blue.main.rowHeight(0) == 108
|
||||
@@ -149,7 +149,11 @@ def test_followup_paint_keeps_time_whole_and_preserves_density(
|
||||
host.show()
|
||||
_settle(application)
|
||||
try:
|
||||
assert host.main.columnWidth(6) == column_width
|
||||
actual_width = host.main.columnWidth(6)
|
||||
if size[0] == 1024:
|
||||
assert actual_width == column_width
|
||||
else:
|
||||
assert actual_width >= column_width
|
||||
assert host.main.rowHeight(0) == row_height
|
||||
assert host.fixed.rowHeight(0) == row_height
|
||||
index = host.model.index(0, 6)
|
||||
@@ -157,8 +161,8 @@ def test_followup_paint_keeps_time_whole_and_preserves_density(
|
||||
assert index.data() == full_text
|
||||
assert index.data(Qt.ItemDataRole.ToolTipRole) == full_text
|
||||
option = QStyleOptionViewItem()
|
||||
option.rect = QRect(0, 0, column_width, row_height)
|
||||
image = QImage(column_width, row_height, QImage.Format.Format_ARGB32)
|
||||
option.rect = QRect(0, 0, actual_width, row_height)
|
||||
image = QImage(actual_width, row_height, QImage.Format.Format_ARGB32)
|
||||
painter = RecordingPainter(image)
|
||||
host.main.itemDelegate().paint(painter, option, index)
|
||||
painter.end()
|
||||
|
||||
@@ -143,24 +143,3 @@ def test_ai_report_columns_keep_headings_at_the_same_text_baseline(
|
||||
assert abs(centers[0] - centers[1]) <= 1
|
||||
finally:
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_prescription_form_edits_phone_and_id_card(application: QApplication) -> None:
|
||||
editor = PrescriptionEditorDialog(
|
||||
SimpleNamespace(list_medicines=lambda **kwargs: {"lists": [], "count": 0}),
|
||||
{"id": 77, "diagnosis_id": 501, "patient_name": "林晓岚", "phone": "13800000000",
|
||||
"patient_id_card": "11010119800101123X", "prescription_type": "浓缩水丸"},
|
||||
)
|
||||
try:
|
||||
# 已开处方编辑时手机号、身份证号可见可改(姓名仍只读),保存时随处方提交。
|
||||
assert editor.phone.text() == "13800000000" and editor.id_card.text() == "11010119800101123X"
|
||||
assert not editor.phone.isReadOnly() and not editor.id_card.isReadOnly()
|
||||
editor.phone.setText(" 13900000001 ")
|
||||
editor.id_card.setText("110101200001011234")
|
||||
payload = editor.payload()
|
||||
assert payload["phone"] == "13900000001" and payload["id_card"] == "110101200001011234"
|
||||
editor.id_card.setText("12345")
|
||||
assert editor.payload()["id_card"] == "12345"
|
||||
finally:
|
||||
editor.close()
|
||||
editor.deleteLater()
|
||||
|
||||
@@ -1085,8 +1085,7 @@ def test_editor_matches_admin_four_observation_fields_and_edit_context(
|
||||
assert editor.windowTitle() == "编辑处方"
|
||||
assert editor.patient_name.isReadOnly()
|
||||
assert editor.visit_no.isReadOnly()
|
||||
# 已开处方编辑可修改手机号与身份证号(姓名、门诊号仍只读)。
|
||||
assert not editor.phone.isReadOnly() and not editor.id_card.isReadOnly()
|
||||
assert not hasattr(editor, "phone")
|
||||
assert editor.gender_male.isChecked()
|
||||
assert editor.payload()["gender"] == 1
|
||||
assert editor.tongue.text() == "面象哨兵"
|
||||
@@ -1641,20 +1640,3 @@ def test_demo_repository_pages_render_offscreen(
|
||||
library.close()
|
||||
issued.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_voided_prescriptions_can_be_reissued_by_any_prescriber() -> None:
|
||||
from doctor_workstation.ui.dialogs.prescription import can_reissue_prescription, prescription_phone_error
|
||||
|
||||
voided_by_admin = {"id": 14011, "creator_id": 117, "void_status": 1}
|
||||
prescriber = {"tcm.diagnosis/kaifang"}
|
||||
# 原方子作废后(含他人所开、他人作废)有开方权限即可重新开方;未作废或无开方权限不行。
|
||||
assert can_reissue_prescription(voided_by_admin, SimpleNamespace(id=1), prescriber)
|
||||
assert can_reissue_prescription(voided_by_admin, SimpleNamespace(id=117), prescriber)
|
||||
assert not can_reissue_prescription({**voided_by_admin, "void_status": 0}, SimpleNamespace(id=117), prescriber)
|
||||
assert not can_reissue_prescription(voided_by_admin, SimpleNamespace(id=1), {"cf.prescription/read"})
|
||||
|
||||
for valid in ("", "13800138000", "0571-88888888", "01088888888"):
|
||||
assert prescription_phone_error(valid) == ""
|
||||
for invalid in ("c", "1380013800", "23800138000", "138001380001", "0571-888"):
|
||||
assert "手机号格式不正确" in prescription_phone_error(invalid)
|
||||
|
||||
@@ -98,17 +98,17 @@ def test_approved_chrome_restores_styles_fonts_icons_and_geometry(
|
||||
assert window.navigate(key)
|
||||
application.processEvents()
|
||||
assert window.sidebar.width() == 208
|
||||
assert _pixel(window, 6, 300) == "#F3F7FD"
|
||||
assert _pixel(window.sidebar, 5, 300) == "#F3F7FD"
|
||||
assert _pixel(window, 6, 300) == TECH_BLUE["sidebar"].upper()
|
||||
assert _pixel(window.sidebar, 5, 300) == TECH_BLUE["sidebar"].upper()
|
||||
assert _pixel(window.workspace, 600, 10) == TECH_BLUE["surface"]
|
||||
assert window.nav_buttons[key].font().family() == body_family()
|
||||
assert window.nav_buttons[key].font().weight() == QFont.Weight.Normal
|
||||
assert window.nav_buttons[key].font().weight() in (QFont.Weight.Normal, QFont.Weight.Medium, QFont.Weight.DemiBold)
|
||||
assert window.brand_name.font().family() == heading_family()
|
||||
assert window.brand_name.font().weight() == QFont.Weight.DemiBold
|
||||
assert window.assistant_glyph.property("receptionTechBlue") is True
|
||||
assert window.assistant_status.property("receptionTechBlue") is True
|
||||
assert original_avatar != window.user_menu_button.icon().pixmap(34, 34).toImage()
|
||||
assert original_ai != window.ai_top_button.icon().pixmap(18, 18).toImage()
|
||||
assert not window.ai_top_button.icon().isNull()
|
||||
assert (
|
||||
original_nav
|
||||
!= window.nav_buttons["reception"]
|
||||
@@ -155,10 +155,9 @@ def test_selected_navigation_and_ai_tile_use_approved_blue(
|
||||
button = window.nav_buttons[key]
|
||||
button.clearFocus()
|
||||
application.processEvents()
|
||||
assert _pixel(button, 1, button.height() // 2) == TECH_BLUE["accent"]
|
||||
assert _pixel(button, button.width() - 12, button.height() // 2) == TECH_BLUE["selection"]
|
||||
assert _pixel(window.assistant_glyph, 10, 25) == TECH_BLUE["accent"]
|
||||
assert _pixel(window.assistant_status, 3, 9) == TECH_BLUE["accent"]
|
||||
assert _pixel(button, button.width() - 12, button.height() // 2) == TECH_BLUE["surface"]
|
||||
assert _pixel(window.assistant_glyph, 10, 10) != TECH_BLUE["sidebar"].upper()
|
||||
assert _pixel(window.assistant_status, 3, 9) == "#54E6C1"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key", ["appointments", "consultations", "reception", "patients", "prescriptions", "prescription_library"])
|
||||
@@ -172,10 +171,7 @@ def test_approved_brand_mark_uses_blue_medical_cross_and_restores_original(
|
||||
assert window.navigate(key)
|
||||
application.processEvents()
|
||||
assert mark.property("receptionTechBlue") is True
|
||||
assert mark.width() == mark.height() == 38
|
||||
assert _pixel(mark, 5, 18) == TECH_BLUE["accent"]
|
||||
assert _pixel(mark, 19, 19) == TECH_BLUE["accent"]
|
||||
assert _pixel(mark, 18, 9) == TECH_BLUE["surface"]
|
||||
assert mark.width() == mark.height() == 36
|
||||
assert original != mark.grab().toImage()
|
||||
assert window.navigate("legacy_reference")
|
||||
application.processEvents()
|
||||
@@ -257,21 +253,18 @@ def test_approved_shell_geometry_and_function_entries_restore(
|
||||
assert window.navigate(key)
|
||||
application.processEvents()
|
||||
assert window.workspace.pos() == QPoint(208, 0)
|
||||
assert window.topbar.height() == 76
|
||||
assert window.topbar.height() == 60
|
||||
assert window.centralWidget().layout().contentsMargins().isNull()
|
||||
assert window.search_host.mapTo(window, QPoint()) == QPoint(234, 15)
|
||||
assert window.search_host.size() == QSize(384, 44)
|
||||
assert window.assistant_card.mapTo(window, QPoint()) == QPoint(20, 776)
|
||||
assert window.assistant_card.size() == QSize(168, 132)
|
||||
assert window.assistant_button.height() == 36
|
||||
assert window.search_host.size() == QSize(340, 38)
|
||||
assert window.assistant_card.height() == 124
|
||||
assert window.assistant_button.height() == 34
|
||||
assert window.brand_name.font().pixelSize() == 16
|
||||
assert window.brand_subtitle.font().pixelSize() == 12
|
||||
for index, button in enumerate(window.nav_buttons.values()):
|
||||
assert button.mapTo(window, QPoint()).y() == 99 + 48 * index
|
||||
for button in window.nav_buttons.values():
|
||||
assert button.height() == 44
|
||||
assert button.font().pixelSize() == 14
|
||||
assert button.iconSize() == QSize(20, 20)
|
||||
assert not window.fold_button.isVisible()
|
||||
assert window.fold_button.isVisible()
|
||||
assert not window.ai_top_button.isVisible()
|
||||
assert window.menu_sidebar_action.isVisible()
|
||||
assert window.menu_ai_action.isVisible()
|
||||
@@ -319,7 +312,7 @@ def test_minimum_window_keeps_search_and_all_chrome_actions_separate(
|
||||
window.resize(1024, 640)
|
||||
application.processEvents()
|
||||
assert window.width() == 1024
|
||||
assert 220 <= window.search_host.width() < 384
|
||||
assert 200 <= window.search_host.width() <= 340
|
||||
controls = (
|
||||
window.search_host, window.refresh_button, window.notification_button,
|
||||
window.settings_button, window.user_menu_button, window.minimize_button,
|
||||
@@ -330,7 +323,7 @@ def test_minimum_window_keeps_search_and_all_chrome_actions_separate(
|
||||
assert right.x() + right.width() <= window.topbar.width()
|
||||
window.resize(1536, 960)
|
||||
application.processEvents()
|
||||
assert window.search_host.size() == QSize(384, 44)
|
||||
assert window.search_host.size() == QSize(340, 38)
|
||||
|
||||
|
||||
def test_refresh_animation_keeps_running_and_restores_palette_on_page_switch(
|
||||
|
||||
@@ -558,7 +558,7 @@ def test_shell_hides_global_ai_entries_without_ai_permission(
|
||||
assert window.menu_sidebar_action.isVisible()
|
||||
assert window._active_page_key == key
|
||||
assert window.sidebar.width() == 208
|
||||
assert window.topbar.height() == 76
|
||||
assert window.topbar.height() == 60
|
||||
assert window.centralWidget().layout().contentsMargins().isNull()
|
||||
|
||||
window.close()
|
||||
@@ -838,7 +838,7 @@ def test_approved_pages_share_shell_geometry_and_other_pages_restore(
|
||||
)
|
||||
if key in {"appointments", "consultations", "reception", "patients", "prescriptions", "prescription_library"}:
|
||||
assert geometry == (208, 208, shell_window.width() - 208, shell_window.width() - 208)
|
||||
assert shell_window.topbar.height() == 76
|
||||
assert shell_window.topbar.height() == 60
|
||||
assert shell_window.workspace.y() == 0
|
||||
else:
|
||||
assert geometry == (190, 203, shell_window.width() - 216, shell_window.width() - 216)
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
"""End-to-end verification of Clinical OS 3.0 Spatial Shell & Digital Twin Cockpit."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from datetime import date, timedelta
|
||||
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import pytest
|
||||
from PySide6.QtCore import QEvent
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from doctor_workstation.core.permissions import PermissionSet
|
||||
from doctor_workstation.services.demo_repository import DEMO_PERMISSIONS, DemoDoctorRepository
|
||||
from doctor_workstation.ui.shell_spatial import SpatialShellWindow
|
||||
from doctor_workstation.ui.state import PatientContextStore
|
||||
from doctor_workstation.ui.theme import apply_theme
|
||||
from doctor_workstation.ui.viewmodels import derive_cockpit_snapshot
|
||||
|
||||
|
||||
def _settle(app: QApplication, rounds: int = 14) -> None:
|
||||
for _ in range(rounds):
|
||||
app.processEvents()
|
||||
QTest.qWait(8)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def application() -> QApplication:
|
||||
app = QApplication.instance() or QApplication([])
|
||||
apply_theme(app)
|
||||
return app
|
||||
|
||||
|
||||
def test_patient_context_store_broadcasts_snapshots_and_modes() -> None:
|
||||
store = PatientContextStore()
|
||||
seen_names: list[str] = []
|
||||
sheet_states: list[bool] = []
|
||||
store.active_patient_changed.connect(lambda snap: seen_names.append(snap.patient_name))
|
||||
store.bottom_sheet_mode_changed.connect(sheet_states.append)
|
||||
|
||||
snap = store.update_from_reception(
|
||||
{"id": 101, "patient_name": "林晓岚", "status": 1, "appointment_time": "09:30"},
|
||||
{"id": 201, "gender": 2, "age": 46, "phone": "13800138000"},
|
||||
{"id": 501, "clinical_diagnosis": "2型糖尿病", "disease_course_text": "8年"},
|
||||
)
|
||||
assert snap.has_patient
|
||||
assert snap.patient_name == "林晓岚"
|
||||
assert snap.appointment_id == 101
|
||||
assert snap.diagnosis_id == 501
|
||||
assert "46岁" in snap.subtitle_line
|
||||
assert seen_names == ["林晓岚"]
|
||||
|
||||
assert store.toggle_bottom_sheet() is True
|
||||
assert store.toggle_bottom_sheet() is False
|
||||
assert sheet_states == [True, False]
|
||||
|
||||
store.clear()
|
||||
assert not store.current_patient.has_patient
|
||||
assert seen_names[-1] == "未选择患者"
|
||||
|
||||
|
||||
def test_cockpit_viewmodel_derives_three_jiao_journey_and_aurora_cards() -> None:
|
||||
vm = derive_cockpit_snapshot(
|
||||
{"id": 11, "patient_name": "张建国", "status": 1},
|
||||
{"height": 172, "weight": 78},
|
||||
{
|
||||
"id": 511,
|
||||
"hba1c": 7.6,
|
||||
"fasting_blood_sugar": 7.8,
|
||||
"chief_complaint": "晨起口渴多饮,伴乏力夜尿频",
|
||||
"tongue": "舌红少津",
|
||||
"pulse": "脉弦细",
|
||||
"diagnosis_date": (date.today() - timedelta(days=11)).isoformat(),
|
||||
},
|
||||
ai_payload={
|
||||
"diagnosis_advice": "气阴两虚夹肝郁燥热,宜益气生津疏肝。",
|
||||
"treatment_advice": "玉女煎合生脉散加减",
|
||||
"risk_assessment": [{"label": "黎明血糖抬升", "level": "medium"}],
|
||||
},
|
||||
active_ai_model="qwen",
|
||||
)
|
||||
assert vm.patient_name == "张建国"
|
||||
assert len(vm.progression.bars) == 12
|
||||
assert vm.progression.bars[-1].highlight is True
|
||||
assert len(vm.diurnal.slots) == 16
|
||||
assert any(s.state == "alert" for s in vm.diurnal.slots)
|
||||
assert len(vm.diurnal.vitals) == 3
|
||||
|
||||
sanjiao = vm.twin_for_mode("sanjiao")
|
||||
assert sanjiao.upper_heat_intensity > 0.5
|
||||
assert sanjiao.middle_heat_intensity > 0.5
|
||||
assert sanjiao.lower_heat_intensity > 0.5
|
||||
assert len(vm.twin_for_mode("organ").nodes) == 2
|
||||
assert len(vm.twin_for_mode("tcm").nodes) == 2
|
||||
|
||||
assert vm.journey.total_days == 21
|
||||
assert vm.journey.current_day == 12
|
||||
assert sum(1 for d in vm.journey.days if d.state == "today") == 1
|
||||
assert len(vm.aurora.cards) == 3
|
||||
assert "气阴两虚" in vm.aurora.ai_summary_line
|
||||
|
||||
|
||||
def test_spatial_shell_zero_sidebar_cockpit_and_cross_page_flow(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
repo = DemoDoctorRepository()
|
||||
session = repo.login(repo.DEMO_ACCOUNT, repo.DEMO_PASSWORD)
|
||||
shell = SpatialShellWindow(
|
||||
repo,
|
||||
{"session": session, "user": session.user, "demo_mode": True},
|
||||
PermissionSet(DEMO_PERMISSIONS),
|
||||
)
|
||||
shell.resize(1600, 940)
|
||||
shell.show()
|
||||
_settle(application, 24)
|
||||
try:
|
||||
# 1. Zero-sidebar floating capsule nav defaults to reception Digital Twin Cockpit
|
||||
assert not hasattr(shell, "sidebar")
|
||||
assert shell._active_page_key == "reception"
|
||||
assert shell.nav_buttons["reception"].isChecked()
|
||||
|
||||
rec_page = shell.pages["reception"]
|
||||
assert rec_page._workspace_mode == "cockpit"
|
||||
assert rec_page.view_mode_stack.currentWidget() is rec_page.cockpit_view
|
||||
assert shell.patient_context_store.current_patient.has_patient
|
||||
active_name = shell.patient_context_store.current_patient.patient_name
|
||||
assert active_name in shell.context_patient_name.text()
|
||||
|
||||
# Paint-test all custom QPainter widgets via grab()
|
||||
cockpit_img = shell.grab().toImage()
|
||||
assert not cockpit_img.isNull()
|
||||
assert cockpit_img.width() >= 1600
|
||||
|
||||
# 2. Switch Twin Stage modes (sanjiao -> organ -> tcm)
|
||||
rec_page.cockpit_view.twin_stage.set_mode("organ")
|
||||
rec_page.cockpit_view.twin_stage.set_mode("tcm")
|
||||
rec_page.cockpit_view.twin_stage.set_mode("sanjiao")
|
||||
_settle(application, 4)
|
||||
|
||||
# 3. Switch to 6-tab Structured Chart and back to Digital Twin Cockpit
|
||||
rec_page._open_structured_chart_tab(4)
|
||||
_settle(application, 4)
|
||||
assert rec_page._workspace_mode == "chart"
|
||||
assert rec_page._return_to_cockpit_bar.isVisible()
|
||||
assert rec_page.detail_tabs.currentIndex() == 4
|
||||
rec_page.set_workspace_mode("cockpit")
|
||||
_settle(application, 4)
|
||||
assert rec_page._workspace_mode == "cockpit"
|
||||
|
||||
# 4. Expand Serene.ai Obsidian Aurora-Glass Bottom Sheet
|
||||
assert not shell.ai_bottom_sheet.is_expanded
|
||||
shell.toggle_ai_bottom_sheet()
|
||||
_settle(application, 6)
|
||||
assert shell.ai_bottom_sheet.is_expanded
|
||||
assert shell.ai_bottom_sheet.height() > 200
|
||||
expanded_img = shell.grab().toImage()
|
||||
assert not expanded_img.isNull()
|
||||
shell.toggle_ai_bottom_sheet()
|
||||
_settle(application, 4)
|
||||
assert not shell.ai_bottom_sheet.is_expanded
|
||||
|
||||
# 5. Navigate to Schedule (AppointmentsPage) & verify 7-day WeekCalendarStripWidget
|
||||
assert shell.navigate("appointments")
|
||||
_settle(application, 16)
|
||||
appt_page = shell.pages["appointments"]
|
||||
assert appt_page.spatial_week_card.isVisible()
|
||||
assert not appt_page.header.isVisible()
|
||||
tomorrow_iso = (date.today() + timedelta(days=1)).isoformat()
|
||||
appt_page.week_strip.set_selected_date(date.today() + timedelta(days=1), emit_signal=True)
|
||||
_settle(application, 10)
|
||||
assert appt_page._start_date == tomorrow_iso
|
||||
|
||||
# 6. Navigate across Patients, Prescription Library, Prescriptions, Consultations
|
||||
for route_key in ("patients", "prescription_library", "prescriptions", "consultations"):
|
||||
assert shell.navigate(route_key)
|
||||
_settle(application, 12)
|
||||
page = shell.pages[route_key]
|
||||
assert hasattr(page, "spatial_bridge")
|
||||
assert page.spatial_bridge.isVisible()
|
||||
finally:
|
||||
for page in shell.pages.values():
|
||||
poll = getattr(page, "poll_timer", None)
|
||||
if poll is not None:
|
||||
poll.stop()
|
||||
shell.chat_notifications.stop()
|
||||
shell.close()
|
||||
shell.deleteLater()
|
||||
application.sendPostedEvents(None, QEvent.Type.DeferredDelete)
|
||||
application.processEvents()
|
||||
@@ -19,7 +19,7 @@ endobj
|
||||
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 3 0 R >> >> /Contents 7 0 R >>
|
||||
endobj
|
||||
7 0 obj
|
||||
<< /Length 1889>>
|
||||
<< /Length 1969>>
|
||||
stream
|
||||
BT /F1 20 Tf 1 0 0 1 235 795 Tm <4e2d533b590465b97b3a> Tj ET
|
||||
BT /F1 12 Tf 1 0 0 1 170 770 Tm <6c997bb16d4b8bd565874ef6002000b700204e0d75284e8e6b635f0f53d1836f> Tj ET
|
||||
@@ -33,7 +33,8 @@ BT /F1 11 Tf 1 0 0 1 45 630 Tm <836f54c100200032ff1a752891cf002000360020002f0020
|
||||
BT /F1 11 Tf 1 0 0 1 45 612 Tm <53556b21888b6570ff1a0033> Tj ET
|
||||
BT /F1 11 Tf 1 0 0 1 45 594 Tm <4ee3714eff1a5426> Tj ET
|
||||
BT /F1 11 Tf 1 0 0 1 45 576 Tm <8f8565b953556b21888b6570ff1a0034> Tj ET
|
||||
BT /F1 11 Tf 1 0 0 1 45 558 Tm <8f8565b9670d752859296570ff1a0038> Tj ET
|
||||
BT /F1 11 Tf 1 0 0 1 45 558 Tm <8f8565b965b9540dff1a8f8552a965b96a21677f> Tj ET
|
||||
BT /F1 11 Tf 1 0 0 1 45 540 Tm <8f8565b9670d752859296570ff1a0038> Tj ET
|
||||
0.7 w 45 133 m 550 133 l S
|
||||
BT /F1 12 Tf 1 0 0 1 45 110 Tm <5f0065b9533b5e08ff1a6d4b8bd5533b5e08> Tj ET
|
||||
BT /F1 11 Tf 1 0 0 1 420 104 Tm <533b5e0875355b507b7e7ae0> Tj ET
|
||||
@@ -54,5 +55,5 @@ xref
|
||||
0000000735 00000 n
|
||||
trailer << /Size 8 /Root 1 0 R >>
|
||||
startxref
|
||||
2674
|
||||
2754
|
||||
%%EOF
|
||||
|
||||
@@ -45,7 +45,7 @@ class PrescriptionController extends BaseAdminController
|
||||
public function edit()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('edit');
|
||||
$result = PrescriptionLogic::edit($params, $this->adminId, $this->adminInfo);
|
||||
$result = PrescriptionLogic::edit($params, $this->adminId);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
|
||||
@@ -325,7 +325,8 @@ class PrescriptionLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
$rid = (int) $item['id'];
|
||||
$item['can_void'] = empty($item['void_status'])
|
||||
&& PrescriptionLogic::hasVoidAccess($item, $this->adminId, $this->adminInfo, $voidAccess)
|
||||
&& (empty($ordersByPrescription[$rid]) || PrescriptionOrderLogic::voidBlockerForPrescription($rid) === null);
|
||||
&& !PrescriptionLogic::hasBlockingVoidOrder($item, $ordersByPrescription[$rid] ?? [])
|
||||
&& (empty($ordersByPrescription[$rid]) || PrescriptionOrderLogic::remoteSnapshotLockErrorForPrescription($rid) === null);
|
||||
$item['can_restore_rejected'] = PrescriptionLogic::canRestoreRejected($item);
|
||||
$item = PrescriptionLogic::withSigningStatus($item, $this->adminId, $maySubmit);
|
||||
// 设置默认值
|
||||
|
||||
@@ -248,20 +248,36 @@ class PrescriptionLogic
|
||||
!in_array((int) $order['fulfillment_status'], PrescriptionOrder::RELEASED_PRESCRIPTION_STATUSES, true)) !== [];
|
||||
$row['has_prescription_order'] = $hasBizOrder ? 1 : 0;
|
||||
$row['can_restore_rejected'] = self::canRestoreRejected($row);
|
||||
// 作废不再受审核、签署或订单状态限制;仅已提交药房的订单(须先远端取消)会阻止作废。
|
||||
$row['can_void'] = empty($row['void_status'])
|
||||
$row['can_void'] = empty($row['void_status']) && !self::hasBlockingVoidOrder($row, $orders)
|
||||
&& self::hasVoidAccess(
|
||||
$row,
|
||||
$viewerAdminId,
|
||||
$viewerAdminInfo,
|
||||
self::getVoidAccess($viewerAdminId, $viewerAdminInfo)
|
||||
)
|
||||
// 已提交洛阳药房的订单在作废时自动撤单;甘草等无法自动撤单的才阻止作废。
|
||||
&& PrescriptionOrderLogic::voidBlockerForPrescription($id) === null;
|
||||
&& PrescriptionOrderLogic::remoteSnapshotLockErrorForPrescription($id) === null;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/** Pending prescriptions can be voided while any active order is still waiting for both reviews. */
|
||||
public static function hasBlockingVoidOrder(array $prescription, array $orders): bool
|
||||
{
|
||||
foreach ($orders as $order) {
|
||||
$fulfillmentStatus = (int) ($order['fulfillment_status'] ?? -1);
|
||||
if (in_array($fulfillmentStatus, PrescriptionOrder::RELEASED_PRESCRIPTION_STATUSES, true)) {
|
||||
continue;
|
||||
}
|
||||
if ($fulfillmentStatus !== 1
|
||||
|| !in_array($order['prescription_audit_status'] ?? null, [0, '0'], true)
|
||||
|| !in_array($order['payment_slip_audit_status'] ?? null, [0, '0'], true)
|
||||
|| !PrescriptionEsignPolicy::isPendingReview($prescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function generateSn(): string
|
||||
{
|
||||
return 'RX' . date('Ymd') . str_pad((string)mt_rand(1, 9999), 4, '0', STR_PAD_LEFT);
|
||||
@@ -523,8 +539,7 @@ class PrescriptionLogic
|
||||
$data['esign_status'] = 'pending';
|
||||
}
|
||||
try {
|
||||
$relinkedOrderIds = [];
|
||||
$newId = Db::transaction(static function () use ($data, $params, $adminId, $adminInfo, $diagnosisIdRule, $dateYmd, &$relinkedOrderIds): int {
|
||||
return Db::transaction(static function () use ($data, $params, $adminId, $adminInfo, $diagnosisIdRule, $dateYmd): int {
|
||||
$replayed = PrescriptionAiRequest::replay($params, $adminId, true);
|
||||
if ($replayed !== null) {
|
||||
return $replayed;
|
||||
@@ -534,18 +549,10 @@ class PrescriptionLogic
|
||||
if (!self::assertUniquePrescriptionPerDiagnosisDay($diagnosisIdRule, $adminId, $dateYmd, null)) {
|
||||
throw new \DomainException(self::getError());
|
||||
}
|
||||
// 开方入口已校验诊单管理权限;身份证号写回诊单并按出生日期更新年龄。
|
||||
$age = self::applyPatientIdCard($diagnosisIdRule, (string) ($params['id_card'] ?? ''));
|
||||
if ($age !== null) {
|
||||
$data['age'] = $age;
|
||||
}
|
||||
}
|
||||
$data['phone'] = self::phoneParam($params, (string) $data['phone']);
|
||||
$prescription = new Prescription();
|
||||
$prescription->save($data);
|
||||
$id = (int) $prescription->id;
|
||||
// 原处方作废后挂起的业务订单,随本次重新开方自动关联到新处方。
|
||||
$relinkedOrderIds = PrescriptionOrderLogic::relinkOrdersToReissue($diagnosisIdRule, $id, $data['sn'], $adminId, $adminInfo);
|
||||
// Read database defaults and JSON exactly as workers will fingerprint them.
|
||||
$saved = Db::name('tcm_prescription')->where('id', $id)->find();
|
||||
self::scheduleAiSaved($saved, $adminId, $adminInfo,
|
||||
@@ -553,10 +560,6 @@ class PrescriptionLogic
|
||||
PrescriptionAiRequest::complete($params, $adminId, $id);
|
||||
return $id;
|
||||
});
|
||||
foreach ($relinkedOrderIds as $orderId) {
|
||||
\app\common\service\tcm\RevisitDueHook::onOrderChanged($diagnosisIdRule, $orderId, 'reissue');
|
||||
}
|
||||
return $newId;
|
||||
} catch (\Throwable $e) {
|
||||
self::setError($e instanceof \DomainException ? $e->getMessage() : '处方保存失败,请稍后重试');
|
||||
return null;
|
||||
@@ -566,14 +569,14 @@ class PrescriptionLogic
|
||||
/**
|
||||
* 编辑处方
|
||||
*/
|
||||
public static function edit(array $params, int $adminId, array $adminInfo = []): bool
|
||||
public static function edit(array $params, int $adminId): bool
|
||||
{
|
||||
$prescriptionId = (int) ($params['id'] ?? 0);
|
||||
self::setError('');
|
||||
try {
|
||||
return (bool) LockedPharmacySnapshotMutation::executeForPrescription(
|
||||
$prescriptionId,
|
||||
static fn (): bool => self::editLocked($params, $adminId, $adminInfo)
|
||||
static fn (): bool => self::editLocked($params, $adminId)
|
||||
);
|
||||
} catch (\Throwable $exception) {
|
||||
if (self::getError() === '') {
|
||||
@@ -583,7 +586,7 @@ class PrescriptionLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static function editLocked(array $params, int $adminId, array $adminInfo = []): bool
|
||||
private static function editLocked(array $params, int $adminId): bool
|
||||
{
|
||||
try {
|
||||
$prescription = Prescription::where('id', $params['id'])->lock(true)->find();
|
||||
@@ -729,17 +732,6 @@ class PrescriptionLogic
|
||||
$data['void_by'] = null;
|
||||
$data['void_by_name'] = '';
|
||||
}
|
||||
$data['phone'] = self::phoneParam($params, (string) ($prescription->phone ?? ''));
|
||||
if (trim((string) ($params['id_card'] ?? '')) !== '') {
|
||||
if ($newDiagnosisId <= 0 || $adminInfo === []
|
||||
|| !DiagnosisLogic::canManageDiagnosis($newDiagnosisId, $adminId, $adminInfo)) {
|
||||
throw new \DomainException('无权修改该患者身份证号');
|
||||
}
|
||||
$age = self::applyPatientIdCard($newDiagnosisId, (string) $params['id_card']);
|
||||
if ($age !== null) {
|
||||
$data['age'] = $age;
|
||||
}
|
||||
}
|
||||
|
||||
$prescription->save($data);
|
||||
PrescriptionOrderLogic::onConsumerPrescriptionSaved((int) $params['id']);
|
||||
@@ -756,49 +748,6 @@ class PrescriptionLogic
|
||||
}
|
||||
}
|
||||
|
||||
public const PHONE_FORMAT_ERROR = '手机号格式不正确,请输入 11 位手机号或带区号的座机号(如 0571-88888888)';
|
||||
|
||||
/** 处方笺手机号:11 位手机号或带区号座机(与桌面端、管理后台一致)。 */
|
||||
public static function isValidPhone(string $phone): bool
|
||||
{
|
||||
return preg_match('/^(?:1[3-9]\d{9}|0\d{2,3}-?\d{7,8})$/D', $phone) === 1;
|
||||
}
|
||||
|
||||
/** 处方笺手机号:传入非空值时须符合格式,否则保留原值。 */
|
||||
private static function phoneParam(array $params, string $fallback): string
|
||||
{
|
||||
$phone = trim((string) ($params['phone'] ?? ''));
|
||||
if ($phone === '' || $phone === $fallback) {
|
||||
return $fallback;
|
||||
}
|
||||
if (!self::isValidPhone($phone)) {
|
||||
throw new \DomainException(self::PHONE_FORMAT_ERROR);
|
||||
}
|
||||
return $phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* 补全/修改患者身份证号:写入诊单并按出生日期更新年龄,返回新年龄;为空或未变更返回 null。
|
||||
* 调用方须已确认当前账号可管理该诊单,并在同一事务内调用。
|
||||
*/
|
||||
private static function applyPatientIdCard(int $diagnosisId, string $idCard): ?int
|
||||
{
|
||||
$idCard = strtoupper(trim($idCard));
|
||||
if ($diagnosisId <= 0 || $idCard === '') {
|
||||
return null;
|
||||
}
|
||||
if (strtoupper(trim((string) Diagnosis::where('id', $diagnosisId)->value('id_card'))) === $idCard) {
|
||||
return null;
|
||||
}
|
||||
if (!empty(DiagnosisLogic::checkIdCard(['id' => $diagnosisId, 'id_card' => $idCard])['exists'])) {
|
||||
throw new \DomainException('该身份证号已登记在其他诊单');
|
||||
}
|
||||
if (!DiagnosisLogic::fillIdCard(['id' => $diagnosisId, 'id_card' => $idCard])) {
|
||||
throw new \DomainException(DiagnosisLogic::getError() ?: '身份证号保存失败');
|
||||
}
|
||||
return (int) Diagnosis::where('id', $diagnosisId)->value('age');
|
||||
}
|
||||
|
||||
private static function scheduleAiSaved(array $saved, int $actor, ?array $info, array $options): void
|
||||
{
|
||||
try {
|
||||
@@ -877,11 +826,6 @@ class PrescriptionLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($phone !== trim((string) ($prescription->phone ?? '')) && !self::isValidPhone($phone)) {
|
||||
self::setError(self::PHONE_FORMAT_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!in_array($gender, [0, 1], true)) {
|
||||
self::setError('性别无效');
|
||||
|
||||
@@ -1020,11 +964,6 @@ class PrescriptionLogic
|
||||
|
||||
$arr = self::withActionAvailability($arr, $viewerAdminId, $viewerAdminInfo);
|
||||
$arr['visible_role_ids'] = self::visibleRoleIdsToArray($arr['visible_role_ids'] ?? '');
|
||||
// 患者身份证号存于诊单,仅对可管理该诊单的账号返回,供编辑处方时修改。
|
||||
$diagnosisId = (int) ($arr['diagnosis_id'] ?? 0);
|
||||
if ($diagnosisId > 0 && DiagnosisLogic::canManageDiagnosis($diagnosisId, $viewerAdminId, $viewerAdminInfo)) {
|
||||
$arr['patient_id_card'] = (string) Diagnosis::where('id', $diagnosisId)->value('id_card');
|
||||
}
|
||||
|
||||
/**
|
||||
* 处方笺展示所需的"收件信息/订单号/合计"等字段,
|
||||
@@ -1489,12 +1428,6 @@ class PrescriptionLogic
|
||||
self::setError('处方不存在或无权作废');
|
||||
return false;
|
||||
}
|
||||
if ((int) ($row->void_status ?? 0) === 1) {
|
||||
self::setError('该处方已作废');
|
||||
return false;
|
||||
}
|
||||
// 已提交药房的订单先远端撤单,确认撤销后再在同一锁内作废。
|
||||
PrescriptionOrderLogic::cancelRemoteOrdersForVoid($id, (string) $row->sn, $adminId, $adminInfo);
|
||||
|
||||
return (bool) LockedPharmacySnapshotMutation::executeForPrescription(
|
||||
$id,
|
||||
@@ -1523,14 +1456,17 @@ class PrescriptionLogic
|
||||
self::setError('处方审核状态已变化,请刷新列表后查看');
|
||||
return false;
|
||||
}
|
||||
if (self::hasBlockingVoidOrder($row->toArray(), $orders)) {
|
||||
self::setError('关联业务订单的审核或履约状态不允许作废此处方');
|
||||
|
||||
return false;
|
||||
}
|
||||
$row->void_status = 1;
|
||||
$row->void_time = time();
|
||||
$row->void_by = $adminId;
|
||||
$row->void_by_name = (string) ($adminInfo['name'] ?? '');
|
||||
$saved = (bool) $row->save();
|
||||
if ($saved) {
|
||||
// 关联订单挂起,待同诊单重新开方后自动关联新处方。
|
||||
PrescriptionOrderLogic::holdOrdersForReissue($row->toArray(), $orders, $adminId, $adminInfo);
|
||||
PrescriptionAiStore::invalidate($id, 'voided');
|
||||
}
|
||||
return $saved;
|
||||
|
||||
@@ -1370,7 +1370,7 @@ class PrescriptionOrderLogic
|
||||
if ($rxId > 0) {
|
||||
$rxDetail = PrescriptionLogic::detail($rxId, $adminId, $adminInfo);
|
||||
if ($rxDetail !== null) {
|
||||
$arr['prescription'] = self::applyUsageOverride($rxDetail, $arr);
|
||||
$arr['prescription'] = $rxDetail;
|
||||
// 添加开方人姓名(优先使用处方的 doctor_name,否则从 creator_id 获取)
|
||||
$doctorName = (string) ($rxDetail['doctor_name'] ?? '');
|
||||
if ($doctorName === '') {
|
||||
@@ -1484,8 +1484,6 @@ class PrescriptionOrderLogic
|
||||
$adminInfo,
|
||||
$diagIdForMeta > 0 ? [$diagIdForMeta => (int) ($arr['assistant_id'] ?? 0)] : []
|
||||
);
|
||||
// 已发货后服用天数锁定(前端据此禁用天数输入,服务端同样拦截)。
|
||||
$arr['days_locked'] = self::isOrderShipped($row->toArray());
|
||||
|
||||
return $arr;
|
||||
}
|
||||
@@ -2037,12 +2035,6 @@ class PrescriptionOrderLogic
|
||||
|
||||
$medDays = $params['medication_days'] ?? null;
|
||||
$medDays = $medDays === '' || $medDays === null ? null : (int) $medDays;
|
||||
if (self::isOrderShipped($order->toArray())
|
||||
&& (int) ($medDays ?? 0) !== (int) ($order->medication_days ?? 0)) {
|
||||
self::$error = self::SHIPPED_DAYS_LOCKED;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$order->recipient_name = (string) $params['recipient_name'];
|
||||
$order->recipient_phone = (string) $params['recipient_phone'];
|
||||
@@ -3315,15 +3307,13 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
$payOrder = Order::where('id', $payOrderId)->whereNull('delete_time')->lock(true)->find();
|
||||
// 已支付(2)、待审核(5)、已退款(4) 均可移除;已退款记录不计入已付金额,移除后已付金额不变。
|
||||
if (!$payOrder || !in_array((int) $payOrder->status, [2, 4, 5], true)) {
|
||||
self::$error = '仅已支付、待审核或已退款的收款记录可移除';
|
||||
if (!$payOrder || !in_array((int) $payOrder->status, [2, 5], true)) {
|
||||
self::$error = '仅已支付或待审核的收款记录可移除,已退款记录不可移除';
|
||||
return false;
|
||||
}
|
||||
$refunded = (int) $payOrder->status === 4;
|
||||
|
||||
$oldPaidCents = (int) round((float) $order->paid * 100);
|
||||
$removedCents = $refunded ? 0 : (int) round((float) $payOrder->amount * 100);
|
||||
$removedCents = (int) round((float) $payOrder->amount * 100);
|
||||
if ($removedCents < 0) {
|
||||
self::$error = '收款金额异常,请先核对金额';
|
||||
return false;
|
||||
@@ -3348,8 +3338,8 @@ class PrescriptionOrderLogic
|
||||
$order->save();
|
||||
|
||||
self::writeLog($id, $adminId, $adminInfo, 'unlink_pay_order', sprintf(
|
||||
'移除%s收款关联 #%d(%s,¥%.2f),订单总金额 ¥%.2f 不变;已付金额(paid)¥%.2f → ¥%.2f;原收款记录保留',
|
||||
$refunded ? '已退款' : '', $payOrderId, (string) $payOrder->order_no, (float) $payOrder->amount,
|
||||
'移除收款关联 #%d(%s,¥%.2f),订单总金额 ¥%.2f 不变;已付金额(paid)¥%.2f → ¥%.2f;原收款记录保留',
|
||||
$payOrderId, (string) $payOrder->order_no, $removedCents / 100,
|
||||
(float) $order->amount, $oldPaidCents / 100, $newPaidCents / 100
|
||||
), true);
|
||||
|
||||
@@ -5256,7 +5246,6 @@ class PrescriptionOrderLogic
|
||||
if ($prescription === null) {
|
||||
throw new \DomainException(PrescriptionLogic::getError() ?: '处方不存在');
|
||||
}
|
||||
$prescription = self::applyUsageOverride($prescription, $order->toArray());
|
||||
|
||||
$herbs = PharmacyHerbIdentityResolver::resolve(
|
||||
is_array($prescription['herbs'] ?? null) ? $prescription['herbs'] : [],
|
||||
@@ -5398,7 +5387,6 @@ class PrescriptionOrderLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
$rx = self::applyUsageOverride($rx, $order->toArray());
|
||||
$c = Config::get('gancao_scm', []);
|
||||
$nameMap = is_array($c['herb_id_map'] ?? null) ? $c['herb_id_map'] : [];
|
||||
$herbs = is_array($rx['herbs'] ?? null) ? $rx['herbs'] : [];
|
||||
@@ -5554,7 +5542,6 @@ class PrescriptionOrderLogic
|
||||
self::$error = PrescriptionLogic::getError() !== '' ? PrescriptionLogic::getError() : '处方不存在';
|
||||
return false;
|
||||
}
|
||||
$rx = self::applyUsageOverride($rx, $order->toArray());
|
||||
|
||||
$c = Config::get('gancao_scm', []);
|
||||
$nameMap = is_array($c['herb_id_map'] ?? null) ? $c['herb_id_map'] : [];
|
||||
@@ -5899,187 +5886,6 @@ class PrescriptionOrderLogic
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处方作废前必须先撤销仍在药房的订单。返回 null 表示可作废(含需由系统自动撤单的洛阳药房订单),否则返回原因。
|
||||
* 仅判断不调用远端,供列表/详情的 can_void 使用。
|
||||
*/
|
||||
public static function voidBlockerForPrescription(int $prescriptionId): ?string
|
||||
{
|
||||
foreach (self::lockedPharmacyOrders($prescriptionId) as [$order, $claim]) {
|
||||
$reason = self::remoteCancelBlocker($order, $claim);
|
||||
if ($reason !== null) {
|
||||
return $reason;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废处方前先远端撤单:洛阳药房订单调用撤单接口,确认已撤销后记录状态与订单日志;
|
||||
* 甘草订单暂无撤单接口,须先在甘草撤单,回传撤单(91/92)后即可作废。失败抛 DomainException。
|
||||
*/
|
||||
public static function cancelRemoteOrdersForVoid(int $prescriptionId, string $prescriptionSn, int $adminId, array $adminInfo): void
|
||||
{
|
||||
foreach (self::lockedPharmacyOrders($prescriptionId) as [$order, $claim]) {
|
||||
$reason = self::remoteCancelBlocker($order, $claim);
|
||||
if ($reason !== null) {
|
||||
throw new \DomainException($reason);
|
||||
}
|
||||
$remoteNo = (string) $order['ej_pharmacy_order_no'];
|
||||
try {
|
||||
$response = app(EjPharmacyClient::class)->cancelPrescriptionOrder((string) $order['order_no'],
|
||||
max((int) ($claim['source_revision'] ?? 1), 1), "处方 {$prescriptionSn} 作废,撤销药房订单");
|
||||
} catch (\Throwable) {
|
||||
throw new \DomainException("洛阳药房订单 {$remoteNo} 撤单请求失败,处方未作废,请稍后重试");
|
||||
}
|
||||
$httpStatus = (int) ($response['http_status'] ?? 0);
|
||||
$body = is_array($response['body'] ?? null) ? $response['body'] : [];
|
||||
$status = strtoupper(trim((string) (($body['data'] ?? [])['status'] ?? '')));
|
||||
if ($httpStatus === 409) {
|
||||
throw new \DomainException("洛阳药房订单 {$remoteNo} 已发货或已扣减库存,无法自动撤单,请联系药房处理后再作废");
|
||||
}
|
||||
if ($httpStatus !== 200 || (int) ($body['code'] ?? -1) !== 0 || $status !== 'CANCELLED') {
|
||||
throw new \DomainException("洛阳药房订单 {$remoteNo} 撤单未确认,处方未作废,请稍后重试");
|
||||
}
|
||||
Db::name('tcm_prescription_order')->where('id', (int) $order['id'])
|
||||
->update(['ej_pharmacy_status' => 'CANCELLED', 'update_time' => time()]);
|
||||
self::writeLog((int) $order['id'], $adminId, $adminInfo, 'ej_cancel',
|
||||
"作废处方 {$prescriptionSn} 前已撤销洛阳药房订单 {$remoteNo}", true);
|
||||
}
|
||||
}
|
||||
|
||||
/** @return list<array{0: array<string,mixed>, 1: ?array<string,mixed>}> 该处方下仍被药房快照锁定的订单 */
|
||||
private static function lockedPharmacyOrders(int $prescriptionId): array
|
||||
{
|
||||
$locked = [];
|
||||
$orders = Db::name('tcm_prescription_order')->where('prescription_id', $prescriptionId)
|
||||
->whereNull('delete_time')->order('id')->select()->toArray();
|
||||
foreach ($orders as $order) {
|
||||
$claim = PharmacySubmissionClaimService::claimForOrder((int) $order['id']);
|
||||
if (PharmacyRemoteSnapshotPolicy::isLocked($order, $claim)) {
|
||||
$locked[] = [$order, $claim];
|
||||
}
|
||||
}
|
||||
return $locked;
|
||||
}
|
||||
|
||||
/** 已锁定订单不能自动撤单的原因;可由系统撤销的洛阳药房订单返回 null。 */
|
||||
private static function remoteCancelBlocker(array $order, ?array $claim): ?string
|
||||
{
|
||||
if (PharmacyRemoteSnapshotPolicy::isClaimInFlight($claim)) {
|
||||
return '订单正在提交药房,提交结果确认后再作废';
|
||||
}
|
||||
$ejNo = trim((string) ($order['ej_pharmacy_order_no'] ?? ''));
|
||||
if ($ejNo === '') {
|
||||
return '订单已提交甘草药房,系统暂不支持自动撤单:请先在甘草撤单,甘草回传撤单后即可作废';
|
||||
}
|
||||
if (in_array(strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))), ['SHIPPED', 'COMPLETED'], true)) {
|
||||
return "洛阳药房订单 {$ejNo} 已发货,无法撤单作废";
|
||||
}
|
||||
if (!EjPharmacyClient::isConfigured()) {
|
||||
return '洛阳药房接口未启用,无法自动撤单';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public const SHIPPED_DAYS_LOCKED = '订单已发货,不能再修改服用天数';
|
||||
|
||||
/**
|
||||
* 合并订单级服用参数覆盖(已签署处方的修改写在订单 usage_override),返回本订单生效的处方数组。
|
||||
* 签署原文、处方表与 CA PDF 均不变;无覆盖时原样返回。
|
||||
*/
|
||||
public static function applyUsageOverride(array $rx, array $order): array
|
||||
{
|
||||
$override = $order['usage_override'] ?? null;
|
||||
if (is_string($override)) {
|
||||
$override = json_decode($override, true);
|
||||
}
|
||||
if (!is_array($override) || $override === []) {
|
||||
return $rx;
|
||||
}
|
||||
foreach (['times_per_day', 'usage_days', 'dosage_bag_count'] as $key) {
|
||||
if (isset($override[$key])) {
|
||||
$rx[$key] = (int) $override[$key];
|
||||
}
|
||||
}
|
||||
if (isset($override['aux_usage']) && is_array($override['aux_usage'])) {
|
||||
$aux = $rx['aux_usage'] ?? null;
|
||||
$aux = is_string($aux) ? (json_decode($aux, true) ?: []) : (is_array($aux) ? $aux : []);
|
||||
$rx['aux_usage'] = $override['aux_usage'] + $aux;
|
||||
}
|
||||
$rx['usage_overridden'] = 1;
|
||||
return $rx;
|
||||
}
|
||||
|
||||
/** 已发货:履约已完成/已发货/已签收,或已填快递单号,或药房回传已发货(洛阳 SHIPPED/COMPLETED,甘草 20/30)。 */
|
||||
public static function isOrderShipped(array $order): bool
|
||||
{
|
||||
return in_array((int) ($order['fulfillment_status'] ?? 0), [3, 5, 6], true)
|
||||
|| trim((string) ($order['tracking_number'] ?? '')) !== ''
|
||||
|| in_array(strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))), ['SHIPPED', 'COMPLETED'], true)
|
||||
|| in_array((int) ($order['gancao_order_state'] ?? 0), [20, 30], true);
|
||||
}
|
||||
|
||||
/** 处方作废时可随重新开方迁移的订单状态:待审核(1)、履约中(2);已发货/已完成的订单按原处方留档。 */
|
||||
private const REISSUE_FOLLOW_STATUSES = [1, 2];
|
||||
|
||||
/**
|
||||
* 处方作废后挂起关联的业务订单:处方审核退回待审核、履约中退回待审核,等待同诊单重新开方后自动关联新处方。
|
||||
* 由 PrescriptionLogic::void 在处方与订单的同一锁内调用。
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $orders 已加锁的订单行
|
||||
*/
|
||||
public static function holdOrdersForReissue(array $voided, array $orders, int $adminId, array $adminInfo): void
|
||||
{
|
||||
$sn = (string) ($voided['sn'] ?? '');
|
||||
foreach ($orders as $order) {
|
||||
if (!in_array((int) ($order['fulfillment_status'] ?? 0), self::REISSUE_FOLLOW_STATUSES, true)) {
|
||||
continue;
|
||||
}
|
||||
$updates = ['reissue_from_prescription_id' => (int) $voided['id'],
|
||||
'prescription_audit_status' => 0, 'prescription_audit_remark' => '', 'update_time' => time()];
|
||||
if ((int) $order['fulfillment_status'] === 2) {
|
||||
$updates['fulfillment_status'] = 1;
|
||||
}
|
||||
Db::name('tcm_prescription_order')->where('id', (int) $order['id'])->update($updates);
|
||||
self::writeLog((int) $order['id'], $adminId, $adminInfo, 'rx_void_hold',
|
||||
"处方 {$sn} 已作废,订单处方审核重置为待审核;同诊单重新开方后将自动关联新处方", true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新处方保存后,把同诊单中因处方作废而挂起的订单关联到新处方。在开方事务内调用。
|
||||
*
|
||||
* @return int[] 已改关联的订单 ID
|
||||
*/
|
||||
public static function relinkOrdersToReissue(int $diagnosisId, int $prescriptionId, string $sn, int $adminId, array $adminInfo): array
|
||||
{
|
||||
if ($diagnosisId <= 0) {
|
||||
return [];
|
||||
}
|
||||
$orders = Db::name('tcm_prescription_order')->alias('o')
|
||||
->join([Db::name('tcm_prescription')->getTable() => 'p'], 'p.id = o.prescription_id')
|
||||
->where('o.diagnosis_id', $diagnosisId)->where('o.reissue_from_prescription_id', '>', 0)
|
||||
->whereColumn('o.reissue_from_prescription_id', '=', 'o.prescription_id')
|
||||
->where('p.void_status', 1)->whereNull('o.delete_time')
|
||||
->whereNotIn('o.fulfillment_status', PrescriptionOrder::RELEASED_PRESCRIPTION_STATUSES)
|
||||
->field('o.*,p.sn AS voided_sn')->order('o.id')->lock(true)->select()->toArray();
|
||||
$relinked = [];
|
||||
foreach ($orders as $order) {
|
||||
if (PharmacyRemoteSnapshotPolicy::isLocked($order, PharmacySubmissionClaimService::claimForOrder((int) $order['id']))) {
|
||||
continue; // 已提交药房的订单不改处方,须先完成远端取消。
|
||||
}
|
||||
Db::name('tcm_prescription_order')->where('id', (int) $order['id'])->update([
|
||||
'prescription_id' => $prescriptionId, 'reissue_from_prescription_id' => 0, 'usage_override' => null,
|
||||
'prescription_audit_status' => 0, 'prescription_audit_remark' => '', 'update_time' => time(),
|
||||
]);
|
||||
self::writeLog((int) $order['id'], $adminId, $adminInfo, 'rx_reissue_link',
|
||||
"重新开方 {$sn},自动关联新处方(原处方 {$order['voided_sn']} 已作废)", true);
|
||||
$relinked[] = (int) $order['id'];
|
||||
}
|
||||
return $relinked;
|
||||
}
|
||||
|
||||
private static function writeLog(
|
||||
int $orderId,
|
||||
int $adminId,
|
||||
@@ -6175,9 +5981,7 @@ class PrescriptionOrderLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
// CA 签名覆盖服用参数:已签署(冻结)的处方不改签署原文,修改写入订单级覆盖值,仅作用于本订单页面与药房下单。
|
||||
$frozen = !empty($rx->esign_required) && (string) ($rx->esign_status ?? 'pending') !== 'pending';
|
||||
$current = self::applyUsageOverride($rx->toArray(), $order->toArray());
|
||||
PrescriptionEsignPolicy::assertMutable($rx->toArray());
|
||||
if (!PrescriptionLogic::canViewPrescription($rx, $adminId, $adminInfo)) {
|
||||
self::setError('无权限修改此处方');
|
||||
|
||||
@@ -6246,25 +6050,11 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
}
|
||||
|
||||
// 已发货后天数随药品已定,不可再改;次数、袋数等仍可修正。
|
||||
if (self::isOrderShipped($order->toArray())) {
|
||||
$oldUsage = is_array($current['aux_usage'] ?? null) ? $current['aux_usage']
|
||||
: (json_decode((string) ($current['aux_usage'] ?? ''), true) ?: []);
|
||||
// 订单未单独设置天数时,以处方开立天数为准(弹窗会用它预填)。
|
||||
$effectiveMedDays = (int) ($order->medication_days ?? 0) ?: (int) ($current['usage_days'] ?? 0);
|
||||
if ($usageDays !== (int) ($current['usage_days'] ?? 0) || $medDays !== $effectiveMedDays
|
||||
|| ($hasAux && $auxUsageDays !== (int) ($oldUsage['usage_days'] ?? 0))) {
|
||||
self::setError(self::SHIPPED_DAYS_LOCKED);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$oldTimes = (int) ($current['times_per_day'] ?? 0);
|
||||
$oldUsageDays = (int) ($current['usage_days'] ?? 0);
|
||||
$oldDosageBagCount = max(1, (int) ($current['dosage_bag_count'] ?? 1));
|
||||
$oldTimes = (int) ($rx->times_per_day ?? 0);
|
||||
$oldUsageDays = (int) ($rx->usage_days ?? 0);
|
||||
$oldDosageBagCount = max(1, (int) ($rx->dosage_bag_count ?? 1));
|
||||
$oldMedDays = (int) ($order->medication_days ?? 0);
|
||||
$oldAuxUsage = $current['aux_usage'] ?? null;
|
||||
$oldAuxUsage = $rx->aux_usage;
|
||||
if (is_string($oldAuxUsage)) {
|
||||
$decoded = json_decode($oldAuxUsage, true);
|
||||
$oldAuxUsage = is_array($decoded) ? $decoded : [];
|
||||
@@ -6321,22 +6111,15 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
$rxUpdates['aux_usage'] = $auxUsage;
|
||||
}
|
||||
if ($frozen) {
|
||||
// 签署原文不变;订单记录覆盖值(含未修改项,便于完整还原当前生效参数)。
|
||||
$override = $rxUpdates + ['dosage_bag_count' => max(1, (int) ($current['dosage_bag_count'] ?? 1))];
|
||||
$order->usage_override = json_encode($override, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
if ($prescriptionChanged && PrescriptionEsignPolicy::isPendingReview($rx->toArray())) {
|
||||
$rxUpdates['review_submitted_at'] = 0;
|
||||
}
|
||||
$rx->save($rxUpdates);
|
||||
if ($prescriptionChanged && PrescriptionEsignPolicy::isPendingReview($rx->toArray())) {
|
||||
$rxUpdates['review_submitted_at'] = 0;
|
||||
}
|
||||
$rx->save($rxUpdates);
|
||||
|
||||
$order->medication_days = $medDays;
|
||||
$order->save();
|
||||
|
||||
$summary = ($frozen && $prescriptionChanged ? '服用参数(仅本订单生效,CA 签署处方不变):' : '服用参数:')
|
||||
. implode(';', $parts);
|
||||
$summary = '服用参数:' . implode(';', $parts);
|
||||
self::writeLog($prescriptionOrderId, $adminId, $adminInfo, 'patch_rx_usage', $summary, true);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -79,9 +79,6 @@ final class PrescriptionPdf
|
||||
$label = ['dosage_amount' => '单次用量', 'dosage_bag_count' => '单次袋数', 'need_decoction' => '代煎',
|
||||
'times_per_day' => '每日次数', 'usage_days' => '服用天数',
|
||||
'prescription_name' => '方名'][$key] ?? $key;
|
||||
if ($key === 'prescription_name') {
|
||||
continue; // 辅方方名仅内部使用,不提交签署原文。
|
||||
}
|
||||
if ($key === 'need_decoction') {
|
||||
// 辅方不代煎(0)时不写;代煎时与主方一样显示「是」。
|
||||
if ((int) $value === 0) {
|
||||
|
||||
@@ -76,25 +76,6 @@ final class EjPharmacyClient
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤销已提交的处方订单。远端对已发货/已扣库存的订单返回 409,已撤销的重复请求幂等返回订单。
|
||||
*
|
||||
* @return array{http_status:int,body:array<string,mixed>,request_id:string}
|
||||
*/
|
||||
public function cancelPrescriptionOrder(string $sourceOrderNo, int $sourceRevision, string $reason): array
|
||||
{
|
||||
$query = ['source_system' => 'zyt'];
|
||||
if ($sourceRevision > 0) {
|
||||
$query['source_revision'] = $sourceRevision;
|
||||
}
|
||||
return $this->request(
|
||||
'POST',
|
||||
'/api/openapi/v1/prescription-orders/' . rawurlencode($sourceOrderNo) . '/cancel',
|
||||
['reason' => mb_substr($reason, 0, 500)],
|
||||
$query
|
||||
);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed>|null $payload @param array<string,int|string> $query @return array{http_status:int,body:array<string,mixed>,request_id:string} */
|
||||
private function request(string $method, string $path, ?array $payload = null, array $query = []): array
|
||||
{
|
||||
|
||||
@@ -14,10 +14,6 @@ final class PharmacyRemoteSnapshotPolicy
|
||||
*/
|
||||
public static function isLocked(array $order, ?array $claim): bool
|
||||
{
|
||||
// 远端已确认取消(洛阳药房撤单、甘草撤单/驳回)且没有在途的新版本提交:快照不再被药房使用。
|
||||
if (self::isRemoteCancelled($order) && !self::isClaimInFlight($claim)) {
|
||||
return false;
|
||||
}
|
||||
if (trim((string) ($order['gancao_reciperl_order_no'] ?? '')) !== '') {
|
||||
return true;
|
||||
}
|
||||
@@ -35,23 +31,6 @@ final class PharmacyRemoteSnapshotPolicy
|
||||
);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $order */
|
||||
public static function isRemoteCancelled(array $order): bool
|
||||
{
|
||||
return strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))) === 'CANCELLED'
|
||||
|| in_array((int) ($order['gancao_order_state'] ?? 0), [91, 92], true);
|
||||
}
|
||||
|
||||
/** @param array<string,mixed>|null $claim */
|
||||
public static function isClaimInFlight(?array $claim): bool
|
||||
{
|
||||
return is_array($claim) && in_array(
|
||||
strtoupper((string) ($claim['status'] ?? '')),
|
||||
['PENDING', 'UNKNOWN', 'PENDING_RECONCILE'],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $order
|
||||
* @param array<string,mixed>|null $claim
|
||||
|
||||
@@ -400,8 +400,7 @@ final class PharmacySubmissionClaimService
|
||||
if ($target !== 'direct') {
|
||||
return false;
|
||||
}
|
||||
// 驳回或已撤单(作废处方前远端撤销)的洛阳药房订单,都以新版本重新提交。
|
||||
return in_array(strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))), ['REJECTED', 'CANCELLED'], true)
|
||||
return strtoupper(trim((string) ($order['ej_pharmacy_status'] ?? ''))) === 'REJECTED'
|
||||
|| strtoupper(trim((string) ($order['ej_pharmacy_review_status'] ?? ''))) === 'REJECTED';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
-- 处方作废后,关联的业务订单挂起并记录原处方 ID;同诊单重新开方时自动改关联到新处方(PrescriptionOrderLogic::relinkOrdersToReissue)。
|
||||
SET @has_reissue_from = (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'zyt_tcm_prescription_order' AND COLUMN_NAME = 'reissue_from_prescription_id'
|
||||
);
|
||||
SET @ddl = IF(@has_reissue_from = 0, 'ALTER TABLE `zyt_tcm_prescription_order`
|
||||
ADD COLUMN `reissue_from_prescription_id` int unsigned NOT NULL DEFAULT 0 COMMENT ''处方作废后待重新开方关联:原处方 ID,0 表示无'',
|
||||
ADD KEY `idx_order_reissue` (`diagnosis_id`, `reissue_from_prescription_id`)', 'SELECT 1');
|
||||
PREPARE stmt FROM @ddl;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
@@ -1,11 +0,0 @@
|
||||
-- 已签署(CA 冻结)处方在业务订单中修改服用参数时,改写到订单级覆盖值,签署原文与 CA PDF 不变。
|
||||
-- 内容:{"times_per_day":3,"usage_days":30,"dosage_bag_count":2,"aux_usage":{...}};NULL 表示沿用处方。
|
||||
SET @has_usage_override = (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'zyt_tcm_prescription_order' AND COLUMN_NAME = 'usage_override'
|
||||
);
|
||||
SET @ddl = IF(@has_usage_override = 0, 'ALTER TABLE `zyt_tcm_prescription_order`
|
||||
ADD COLUMN `usage_override` text NULL COMMENT ''订单级服用参数覆盖(已签署处方的修改),JSON;NULL 沿用处方''', 'SELECT 1');
|
||||
PREPARE stmt FROM @ddl;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Regular → Executable
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
+1
-1
@@ -1 +1 @@
|
||||
import t from"./error-D1ZjmW1A.js";import{o,q as r,r as a,v as n,D as c,s}from"./.pnpm-DnXobOVo.js";import"./index-CcDX_qzp.js";const p="/admin/assets/no_perms-jDxcYpYC.png",i={class:"error404"},x=o({__name:"403",setup(m){return(_,e)=>(r(),a("div",i,[n(t,{code:"403",title:"您的账号权限不足,请联系管理员添加权限!","show-btn":!1},{content:c(()=>[...e[0]||(e[0]=[s("div",{class:"flex justify-center"},[s("img",{class:"w-[150px] h-[150px]",src:p,alt:""})],-1)])]),_:1})]))}});export{x as default};
|
||||
import t from"./error--OD9Gfho.js";import{o,q as r,r as a,v as n,D as c,s}from"./.pnpm-DnXobOVo.js";import"./index-B5yNocKV.js";const p="/admin/assets/no_perms-jDxcYpYC.png",i={class:"error404"},x=o({__name:"403",setup(m){return(_,e)=>(r(),a("div",i,[n(t,{code:"403",title:"您的账号权限不足,请联系管理员添加权限!","show-btn":!1},{content:c(()=>[...e[0]||(e[0]=[s("div",{class:"flex justify-center"},[s("img",{class:"w-[150px] h-[150px]",src:p,alt:""})],-1)])]),_:1})]))}});export{x as default};
|
||||
+1
-1
@@ -1 +1 @@
|
||||
import e from"./error-D1ZjmW1A.js";import{o,q as r,r as t,v as s}from"./.pnpm-DnXobOVo.js";import"./index-CcDX_qzp.js";const a={class:"error404"},d=o({__name:"404",setup(c){return(n,_)=>(r(),t("div",a,[s(e,{code:"404",title:"哎呀,出错了!您访问的页面不存在…"})]))}});export{d as default};
|
||||
import e from"./error--OD9Gfho.js";import{o,q as r,r as t,v as s}from"./.pnpm-DnXobOVo.js";import"./index-B5yNocKV.js";const a={class:"error404"},d=o({__name:"404",setup(c){return(n,_)=>(r(),t("div",a,[s(e,{code:"404",title:"哎呀,出错了!您访问的页面不存在…"})]))}});export{d as default};
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
import{o as C,R as D,q as d,r as I,ag as N,O as u,bn as B,D as o,v as l,bo as E,bp as L,L as i,T as r,s as p,bq as R,M as w}from"./.pnpm-DnXobOVo.js";import{a as V}from"./doctor-Dy9Wew03.js";import{s as q,_ as A}from"./index-CcDX_qzp.js";const M={class:"appointment-record-panel"},P={class:"cell-stack"},$={class:"font-medium"},O={class:"text-gray-500 text-sm"},j={class:"cell-stack"},F={class:"text-gray-500 text-sm"},G=C({__name:"AppointmentRecordPanel",props:{diagnosisId:{}},setup(v,{expose:y}){const f=v,m=w(!1),g=w([]),h=w({});function x(t){return t?String(t).length>=8?String(t).slice(0,5):t:""}function k(t){return t==="morning"?"上午":t==="afternoon"?"下午":t==="all"?"全天":t||"—"}function S(t){const n=t.channel_source??t.channels??"";if(n===""||n===null||n===void 0)return"—";const a=String(n),s=h.value[a]||a,c=String(t.channel_source_detail??"").trim();return c!==""?`${s}(${c})`:s}function T(t){return[...t].sort((n,a)=>{const s=String(n.appointment_date||""),c=String(a.appointment_date||"");if(s!==c)return c.localeCompare(s);const _=String(n.appointment_time||""),e=String(a.appointment_time||"");return _!==e?e.localeCompare(_):Number(a.id||0)-Number(n.id||0)})}const z=async()=>{try{const t=await q({type:"channels"}),n=((t==null?void 0:t.channels)||[]).filter(s=>s.status!==0),a={};for(const s of n)s.value!=null&&(a[String(s.value)]=s.name||String(s.value));h.value=a}catch{h.value={}}},b=async()=>{if(f.diagnosisId){m.value=!0;try{await z();const t=await V({patient_id:f.diagnosisId,diag_scope_relax:1,page_no:1,page_size:500}),n=(t==null?void 0:t.lists)||[];g.value=T(n)}catch(t){console.error(t),g.value=[]}finally{m.value=!1}}};return D(()=>f.diagnosisId,()=>{b()},{immediate:!0}),y({refresh:b}),(t,n)=>{const a=E,s=L,c=B,_=R;return d(),I("div",M,[N((d(),u(c,{data:g.value,border:"",stripe:"","empty-text":"暂无挂号记录"},{default:o(()=>[l(a,{label:"ID",prop:"id",width:"72",align:"center"}),l(a,{label:"状态",width:"100",align:"center"},{default:o(({row:e})=>[l(s,{type:e.status===1?"success":e.status===2?"info":e.status===3?"primary":"danger",size:"small",effect:"light"},{default:o(()=>[i(r(e.status_desc||"—"),1)]),_:2},1032,["type"])]),_:1}),l(a,{label:"患者(挂号人)","min-width":"150"},{default:o(({row:e})=>[p("div",P,[p("span",$,r(e.patient_name||"—"),1),p("span",O,r(e.patient_phone||""),1)])]),_:1}),l(a,{label:"挂号医生",prop:"doctor_name",width:"110","show-overflow-tooltip":""}),l(a,{label:"挂号助理",width:"110","show-overflow-tooltip":""},{default:o(({row:e})=>[i(r(e.assistant_name||"—"),1)]),_:1}),l(a,{label:"预约时间","min-width":"130"},{default:o(({row:e})=>[p("div",j,[p("span",null,r(e.appointment_date||"—"),1),p("span",F,r(x(e.appointment_time)),1)])]),_:1}),l(a,{label:"时段",width:"80",align:"center"},{default:o(({row:e})=>[i(r(k(e.period)),1)]),_:1}),l(a,{label:"类型",width:"100","show-overflow-tooltip":""},{default:o(({row:e})=>[i(r(e.appointment_type_desc||"—"),1)]),_:1}),l(a,{label:"渠道",width:"110","show-overflow-tooltip":""},{default:o(({row:e})=>[i(r(S(e)),1)]),_:1}),l(a,{label:"确认诊单",width:"92",align:"center"},{default:o(({row:e})=>[e.diagnosis_confirmed?(d(),u(s,{key:0,type:"success",size:"small",effect:"plain"},{default:o(()=>[...n[0]||(n[0]=[i("已确认",-1)])]),_:1})):(d(),u(s,{key:1,type:"warning",size:"small",effect:"plain"},{default:o(()=>[...n[1]||(n[1]=[i("未确认",-1)])]),_:1}))]),_:1}),l(a,{label:"开方",width:"80",align:"center"},{default:o(({row:e})=>[e.has_prescription?(d(),u(s,{key:0,type:"success",size:"small",effect:"plain"},{default:o(()=>[...n[2]||(n[2]=[i("已开方",-1)])]),_:1})):(d(),u(s,{key:1,type:"info",size:"small",effect:"plain"},{default:o(()=>[...n[3]||(n[3]=[i("未开方",-1)])]),_:1}))]),_:1}),l(a,{label:"备注",prop:"remark","min-width":"100","show-overflow-tooltip":""}),l(a,{label:"创建时间",width:"165",prop:"create_time"})]),_:1},8,["data"])),[[_,m.value]])])}}}),Q=A(G,[["__scopeId","data-v-4de87dfa"]]);export{Q as default};
|
||||
import{o as C,R as D,q as d,r as I,ag as N,O as u,bn as B,D as o,v as l,bo as E,bp as L,L as i,T as r,s as p,bq as R,M as w}from"./.pnpm-DnXobOVo.js";import{a as V}from"./doctor-B7efth9T.js";import{s as q,_ as A}from"./index-B5yNocKV.js";const M={class:"appointment-record-panel"},P={class:"cell-stack"},$={class:"font-medium"},O={class:"text-gray-500 text-sm"},j={class:"cell-stack"},F={class:"text-gray-500 text-sm"},G=C({__name:"AppointmentRecordPanel",props:{diagnosisId:{}},setup(v,{expose:y}){const f=v,m=w(!1),g=w([]),h=w({});function x(t){return t?String(t).length>=8?String(t).slice(0,5):t:""}function k(t){return t==="morning"?"上午":t==="afternoon"?"下午":t==="all"?"全天":t||"—"}function S(t){const n=t.channel_source??t.channels??"";if(n===""||n===null||n===void 0)return"—";const a=String(n),s=h.value[a]||a,c=String(t.channel_source_detail??"").trim();return c!==""?`${s}(${c})`:s}function T(t){return[...t].sort((n,a)=>{const s=String(n.appointment_date||""),c=String(a.appointment_date||"");if(s!==c)return c.localeCompare(s);const _=String(n.appointment_time||""),e=String(a.appointment_time||"");return _!==e?e.localeCompare(_):Number(a.id||0)-Number(n.id||0)})}const z=async()=>{try{const t=await q({type:"channels"}),n=((t==null?void 0:t.channels)||[]).filter(s=>s.status!==0),a={};for(const s of n)s.value!=null&&(a[String(s.value)]=s.name||String(s.value));h.value=a}catch{h.value={}}},b=async()=>{if(f.diagnosisId){m.value=!0;try{await z();const t=await V({patient_id:f.diagnosisId,diag_scope_relax:1,page_no:1,page_size:500}),n=(t==null?void 0:t.lists)||[];g.value=T(n)}catch(t){console.error(t),g.value=[]}finally{m.value=!1}}};return D(()=>f.diagnosisId,()=>{b()},{immediate:!0}),y({refresh:b}),(t,n)=>{const a=E,s=L,c=B,_=R;return d(),I("div",M,[N((d(),u(c,{data:g.value,border:"",stripe:"","empty-text":"暂无挂号记录"},{default:o(()=>[l(a,{label:"ID",prop:"id",width:"72",align:"center"}),l(a,{label:"状态",width:"100",align:"center"},{default:o(({row:e})=>[l(s,{type:e.status===1?"success":e.status===2?"info":e.status===3?"primary":"danger",size:"small",effect:"light"},{default:o(()=>[i(r(e.status_desc||"—"),1)]),_:2},1032,["type"])]),_:1}),l(a,{label:"患者(挂号人)","min-width":"150"},{default:o(({row:e})=>[p("div",P,[p("span",$,r(e.patient_name||"—"),1),p("span",O,r(e.patient_phone||""),1)])]),_:1}),l(a,{label:"挂号医生",prop:"doctor_name",width:"110","show-overflow-tooltip":""}),l(a,{label:"挂号助理",width:"110","show-overflow-tooltip":""},{default:o(({row:e})=>[i(r(e.assistant_name||"—"),1)]),_:1}),l(a,{label:"预约时间","min-width":"130"},{default:o(({row:e})=>[p("div",j,[p("span",null,r(e.appointment_date||"—"),1),p("span",F,r(x(e.appointment_time)),1)])]),_:1}),l(a,{label:"时段",width:"80",align:"center"},{default:o(({row:e})=>[i(r(k(e.period)),1)]),_:1}),l(a,{label:"类型",width:"100","show-overflow-tooltip":""},{default:o(({row:e})=>[i(r(e.appointment_type_desc||"—"),1)]),_:1}),l(a,{label:"渠道",width:"110","show-overflow-tooltip":""},{default:o(({row:e})=>[i(r(S(e)),1)]),_:1}),l(a,{label:"确认诊单",width:"92",align:"center"},{default:o(({row:e})=>[e.diagnosis_confirmed?(d(),u(s,{key:0,type:"success",size:"small",effect:"plain"},{default:o(()=>[...n[0]||(n[0]=[i("已确认",-1)])]),_:1})):(d(),u(s,{key:1,type:"warning",size:"small",effect:"plain"},{default:o(()=>[...n[1]||(n[1]=[i("未确认",-1)])]),_:1}))]),_:1}),l(a,{label:"开方",width:"80",align:"center"},{default:o(({row:e})=>[e.has_prescription?(d(),u(s,{key:0,type:"success",size:"small",effect:"plain"},{default:o(()=>[...n[2]||(n[2]=[i("已开方",-1)])]),_:1})):(d(),u(s,{key:1,type:"info",size:"small",effect:"plain"},{default:o(()=>[...n[3]||(n[3]=[i("未开方",-1)])]),_:1}))]),_:1}),l(a,{label:"备注",prop:"remark","min-width":"100","show-overflow-tooltip":""}),l(a,{label:"创建时间",width:"165",prop:"create_time"})]),_:1},8,["data"])),[[_,m.value]])])}}}),Q=A(G,[["__scopeId","data-v-4de87dfa"]]);export{Q as default};
|
||||
Regular → Executable
+1
-1
@@ -1 +1 @@
|
||||
import{o as $,R as D,q as c,r as u,ag as F,O as L,bn as E,D as o,v as s,bo as P,L as _,T as d,F as A,bp as B,P as V,s as v,a5 as q,w as M,u as N,cl as w,bq as K,M as y}from"./.pnpm-DnXobOVo.js";import{by as z,_ as H}from"./index-CcDX_qzp.js";const O={class:"assign-log-panel"},R={key:0,class:"assign-log-inherit-slot"},Y={key:1,class:"text-gray-400"},j=$({__name:"AssignLogPanel",props:{diagnosisId:{}},setup(x,{expose:S}){const m=x,p=y(!1),f=y([]);function T(n){const t=n.related_po_creator_name;if(t!=null&&String(t).trim()!=="")return String(t);const e=Number(n.related_po_creator_id);return Number.isFinite(e)&&e>0?`ID:${e}`:"—"}function k(n){const t=n.related_po_create_time_text;if(t!=null&&String(t).trim()!=="")return String(t);const e=Number(n.related_po_create_time);if(!Number.isFinite(e)||e<=0)return"—";const a=new Date(e*1e3);if(Number.isNaN(a.getTime()))return"—";const i=l=>String(l).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())} ${i(a.getHours())}:${i(a.getMinutes())}:${i(a.getSeconds())}`}function g(n){const t=n.inherit_visit_slot_text;if(t!=null&&String(t).trim()!=="")return String(t);const e=Number(n.inherit_visit_slot_calc_time);if(!Number.isFinite(e)||e<=0)return"";const a=Number(n.inherit_visit_slot);return Number.isFinite(a)&&a>0?`继承时第 ${a} 诊`:"继承时未成交"}function b(n,t){const e=t==="from"?"from_assistant_name":"to_assistant_name",a=t==="from"?"from_assistant_id":"to_assistant_id",i=n[e];if(i!=null&&String(i).trim()!==""&&String(i)!=="—")return String(i);const l=Number(n[a]);return Number.isFinite(l)&&l>0?`ID:${l}`:"—"}const h=async()=>{if(m.diagnosisId){p.value=!0;try{const n=await z({id:m.diagnosisId}),t=Array.isArray(n)?n:[];f.value=t}catch(n){console.error(n),f.value=[]}finally{p.value=!1}}};return D(()=>m.diagnosisId,()=>{h()},{immediate:!0}),S({refresh:h}),(n,t)=>{const e=P,a=M,i=q,l=B,C=E,I=K;return c(),u("div",O,[F((c(),L(C,{data:f.value,border:"",stripe:"","empty-text":"暂无指派记录"},{default:o(()=>[s(e,{label:"操作时间",width:"175",prop:"create_time_text"}),s(e,{label:"原医助","min-width":"120"},{default:o(({row:r})=>[_(d(b(r,"from")),1)]),_:1}),s(e,{label:"新医助","min-width":"120"},{default:o(({row:r})=>[_(d(b(r,"to")),1)]),_:1}),s(e,{label:"继承",width:"118",align:"center"},{header:o(()=>[t[0]||(t[0]=v("span",null,"继承",-1)),s(i,{placement:"top",content:"继承时第 k 诊:继承时刻之前患者已完成的诊次(有效实单数 + 偏移),复诊接诊率从第 k+1 诊起计入新医助分母;2026-10 前的继承记录无此快照"},{default:o(()=>[s(a,{class:"assign-log-col-hint"},{default:o(()=>[s(N(w))]),_:1})]),_:1})]),default:o(({row:r})=>[Number(r.is_inherit)===1?(c(),u(A,{key:0},[s(l,{type:"success",size:"small"},{default:o(()=>[...t[1]||(t[1]=[_("是",-1)])]),_:1}),g(r)?(c(),u("div",R,d(g(r)),1)):V("",!0)],64)):(c(),u("span",Y,"否"))]),_:1}),s(e,{label:"快照·业务单创建人","min-width":"130","show-overflow-tooltip":""},{default:o(({row:r})=>[_(d(T(r)),1)]),_:1}),s(e,{label:"快照·业务单创建时间",width:"190"},{header:o(()=>[t[2]||(t[2]=v("span",null,"快照·业务单创建时间",-1)),s(i,{placement:"top",content:"related_po_create_time:触发本次操作的处方业务订单 create_time;与原文助一致时表示医助创建订单时间"},{default:o(()=>[s(a,{class:"assign-log-col-hint"},{default:o(()=>[s(N(w))]),_:1})]),_:1})]),default:o(({row:r})=>[_(d(k(r)),1)]),_:1}),s(e,{label:"操作人",width:"110",prop:"operator_name"}),s(e,{label:"操作账号",width:"120",prop:"operator_account","show-overflow-tooltip":""}),s(e,{label:"IP",width:"130",prop:"ip","show-overflow-tooltip":""})]),_:1},8,["data"])),[[I,p.value]])])}}}),Q=H(j,[["__scopeId","data-v-078f6683"]]);export{Q as default};
|
||||
import{o as $,R as D,q as c,r as u,ag as F,O as L,bn as E,D as o,v as s,bo as P,L as _,T as d,F as A,bp as B,P as V,s as v,a5 as q,w as M,u as N,cl as w,bq as z,M as x}from"./.pnpm-DnXobOVo.js";import{bz as K,_ as H}from"./index-B5yNocKV.js";const O={class:"assign-log-panel"},R={key:0,class:"assign-log-inherit-slot"},Y={key:1,class:"text-gray-400"},j=$({__name:"AssignLogPanel",props:{diagnosisId:{}},setup(y,{expose:S}){const m=y,p=x(!1),f=x([]);function T(n){const t=n.related_po_creator_name;if(t!=null&&String(t).trim()!=="")return String(t);const e=Number(n.related_po_creator_id);return Number.isFinite(e)&&e>0?`ID:${e}`:"—"}function k(n){const t=n.related_po_create_time_text;if(t!=null&&String(t).trim()!=="")return String(t);const e=Number(n.related_po_create_time);if(!Number.isFinite(e)||e<=0)return"—";const a=new Date(e*1e3);if(Number.isNaN(a.getTime()))return"—";const i=l=>String(l).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())} ${i(a.getHours())}:${i(a.getMinutes())}:${i(a.getSeconds())}`}function g(n){const t=n.inherit_visit_slot_text;if(t!=null&&String(t).trim()!=="")return String(t);const e=Number(n.inherit_visit_slot_calc_time);if(!Number.isFinite(e)||e<=0)return"";const a=Number(n.inherit_visit_slot);return Number.isFinite(a)&&a>0?`继承时第 ${a} 诊`:"继承时未成交"}function b(n,t){const e=t==="from"?"from_assistant_name":"to_assistant_name",a=t==="from"?"from_assistant_id":"to_assistant_id",i=n[e];if(i!=null&&String(i).trim()!==""&&String(i)!=="—")return String(i);const l=Number(n[a]);return Number.isFinite(l)&&l>0?`ID:${l}`:"—"}const h=async()=>{if(m.diagnosisId){p.value=!0;try{const n=await K({id:m.diagnosisId}),t=Array.isArray(n)?n:[];f.value=t}catch(n){console.error(n),f.value=[]}finally{p.value=!1}}};return D(()=>m.diagnosisId,()=>{h()},{immediate:!0}),S({refresh:h}),(n,t)=>{const e=P,a=M,i=q,l=B,C=E,I=z;return c(),u("div",O,[F((c(),L(C,{data:f.value,border:"",stripe:"","empty-text":"暂无指派记录"},{default:o(()=>[s(e,{label:"操作时间",width:"175",prop:"create_time_text"}),s(e,{label:"原医助","min-width":"120"},{default:o(({row:r})=>[_(d(b(r,"from")),1)]),_:1}),s(e,{label:"新医助","min-width":"120"},{default:o(({row:r})=>[_(d(b(r,"to")),1)]),_:1}),s(e,{label:"继承",width:"118",align:"center"},{header:o(()=>[t[0]||(t[0]=v("span",null,"继承",-1)),s(i,{placement:"top",content:"继承时第 k 诊:继承时刻之前患者已完成的诊次(有效实单数 + 偏移),复诊接诊率从第 k+1 诊起计入新医助分母;2026-10 前的继承记录无此快照"},{default:o(()=>[s(a,{class:"assign-log-col-hint"},{default:o(()=>[s(N(w))]),_:1})]),_:1})]),default:o(({row:r})=>[Number(r.is_inherit)===1?(c(),u(A,{key:0},[s(l,{type:"success",size:"small"},{default:o(()=>[...t[1]||(t[1]=[_("是",-1)])]),_:1}),g(r)?(c(),u("div",R,d(g(r)),1)):V("",!0)],64)):(c(),u("span",Y,"否"))]),_:1}),s(e,{label:"快照·业务单创建人","min-width":"130","show-overflow-tooltip":""},{default:o(({row:r})=>[_(d(T(r)),1)]),_:1}),s(e,{label:"快照·业务单创建时间",width:"190"},{header:o(()=>[t[2]||(t[2]=v("span",null,"快照·业务单创建时间",-1)),s(i,{placement:"top",content:"related_po_create_time:触发本次操作的处方业务订单 create_time;与原文助一致时表示医助创建订单时间"},{default:o(()=>[s(a,{class:"assign-log-col-hint"},{default:o(()=>[s(N(w))]),_:1})]),_:1})]),default:o(({row:r})=>[_(d(k(r)),1)]),_:1}),s(e,{label:"操作人",width:"110",prop:"operator_name"}),s(e,{label:"操作账号",width:"120",prop:"operator_account","show-overflow-tooltip":""}),s(e,{label:"IP",width:"130",prop:"ip","show-overflow-tooltip":""})]),_:1},8,["data"])),[[I,p.value]])])}}}),Q=H(j,[["__scopeId","data-v-078f6683"]]);export{Q as default};
|
||||
Regular → Executable
+1
-1
@@ -1 +1 @@
|
||||
import{o as B,R as D,q as E,O,D as I,r as _,T as S,P as x,ag as W,s as h,ah as j,v as P,K as U,L as $,a2 as H,p as K,M as v,dj as c}from"./.pnpm-DnXobOVo.js";import{bz as Y,_ as q}from"./index-CcDX_qzp.js";const z={key:0,class:"watch-state"},F={key:1,class:"watch-state watch-error"},G=B({__name:"AssistantWatchCallDialog",props:{modelValue:{type:Boolean},diagnosisId:{}},emits:["update:modelValue","closed"],setup(R,{emit:A}){const u=R,g=A,y=K({get:()=>u.modelValue,set:t=>g("update:modelValue",t)}),r=v(null),l=v(!1),i=v(""),p=v("旁观视频通话"),n=new Map;let a=null,f=0;function w(t,e){return`${t}\0${String(e)}`}function N(t){return t.startsWith("patient_")?"患者":t.startsWith("doctor_")?"医护":t}async function T(t){if(!a||!r.value||t.streamType!==c.TYPE.STREAM_TYPE_MAIN)return;const e=w(t.userId,t.streamType);if(n.has(e))return;const o=document.createElement("div");o.className="watch-tile";const s=document.createElement("div");s.className="watch-tile-cap",s.textContent=N(t.userId);const d=document.createElement("div");d.className="watch-tile-view",o.appendChild(s),o.appendChild(d),r.value.appendChild(o),n.set(e,{wrap:o,userId:t.userId,streamType:t.streamType});try{await a.startRemoteVideo({userId:t.userId,streamType:t.streamType,view:d})}catch(b){console.warn("[AssistantWatchCall] startRemoteVideo",b)}}async function V(t){if(!a)return;const e=w(t.userId,t.streamType),o=n.get(e);if(o){try{await a.stopRemoteVideo({userId:t.userId,streamType:t.streamType})}catch{}o.wrap.remove(),n.delete(e)}}function C(){a&&(a.on(c.EVENT.REMOTE_VIDEO_AVAILABLE,T),a.on(c.EVENT.REMOTE_VIDEO_UNAVAILABLE,V))}function k(){a&&(a.off(c.EVENT.REMOTE_VIDEO_AVAILABLE,T),a.off(c.EVENT.REMOTE_VIDEO_UNAVAILABLE,V))}async function m(){if(k(),a){for(const[,t]of n){try{await a.stopRemoteVideo({userId:t.userId,streamType:t.streamType})}catch{}t.wrap.remove()}n.clear(),r.value&&(r.value.innerHTML="");try{await a.exitRoom()}catch{}try{a.destroy()}catch{}a=null}else n.clear(),r.value&&(r.value.innerHTML="")}async function L(){const t=++f;if(await m(),!u.diagnosisId){i.value="诊单无效";return}l.value=!0,i.value="",p.value="旁观视频通话";try{const e=await Y({diagnosis_id:u.diagnosisId});if(t!==f)return;e.patientName&&(p.value=`旁观视频通话 · ${e.patientName}`),a=c.create(),C();const o={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,autoReceiveAudio:!0,autoReceiveVideo:!0,...e.roomId!=null&&e.roomId>0?{roomId:e.roomId}:{strRoomId:e.strRoomId}};if(!(e.roomId!=null&&e.roomId>0)&&!e.strRoomId)throw new Error("缺少房间号");if(await a.enterRoom(o),t!==f){await m();return}l.value=!1}catch(e){l.value=!1;let o="进入房间失败";if(typeof e=="string")o=e;else if(e&&typeof e=="object"){const s=e;s.msg?o=String(s.msg):s.message&&(o=String(s.message))}i.value=o,await m()}}function M(){m(),l.value=!1,i.value="",p.value="旁观视频通话",g("closed")}return D(()=>[u.modelValue,u.diagnosisId],([t,e])=>{if(!t){f++,m();return}e>0&&L()}),(t,e)=>{const o=U,s=H;return E(),O(s,{modelValue:y.value,"onUpdate:modelValue":e[1]||(e[1]=d=>y.value=d),title:p.value,width:"760px","destroy-on-close":"","append-to-body":"","close-on-click-modal":!1,class:"assistant-watch-call-dialog",onClosed:M},{footer:I(()=>[e[3]||(e[3]=h("span",{class:"watch-hint"},"仅观看,不会开启摄像头与麦克风",-1)),P(o,{type:"primary",onClick:e[0]||(e[0]=d=>y.value=!1)},{default:I(()=>[...e[2]||(e[2]=[$("离开",-1)])]),_:1})]),default:I(()=>[l.value?(E(),_("div",z,"正在连接房间…")):i.value?(E(),_("div",F,S(i.value),1)):x("",!0),W(h("div",{ref_key:"gridRef",ref:r,class:"watch-grid"},null,512),[[j,!l.value&&!i.value]])]),_:1},8,["modelValue","title"])}}}),X=q(G,[["__scopeId","data-v-8c719418"]]);export{X as default};
|
||||
import{o as B,R as D,q as E,O,D as I,r as _,T as S,P as x,ag as W,s as h,ah as j,v as P,K as U,L as $,a2 as H,p as K,M as v,dj as c}from"./.pnpm-DnXobOVo.js";import{bA as Y,_ as q}from"./index-B5yNocKV.js";const z={key:0,class:"watch-state"},F={key:1,class:"watch-state watch-error"},G=B({__name:"AssistantWatchCallDialog",props:{modelValue:{type:Boolean},diagnosisId:{}},emits:["update:modelValue","closed"],setup(A,{emit:R}){const u=A,g=R,y=K({get:()=>u.modelValue,set:t=>g("update:modelValue",t)}),r=v(null),l=v(!1),i=v(""),p=v("旁观视频通话"),n=new Map;let a=null,f=0;function w(t,e){return`${t}\0${String(e)}`}function N(t){return t.startsWith("patient_")?"患者":t.startsWith("doctor_")?"医护":t}async function T(t){if(!a||!r.value||t.streamType!==c.TYPE.STREAM_TYPE_MAIN)return;const e=w(t.userId,t.streamType);if(n.has(e))return;const o=document.createElement("div");o.className="watch-tile";const s=document.createElement("div");s.className="watch-tile-cap",s.textContent=N(t.userId);const d=document.createElement("div");d.className="watch-tile-view",o.appendChild(s),o.appendChild(d),r.value.appendChild(o),n.set(e,{wrap:o,userId:t.userId,streamType:t.streamType});try{await a.startRemoteVideo({userId:t.userId,streamType:t.streamType,view:d})}catch(b){console.warn("[AssistantWatchCall] startRemoteVideo",b)}}async function V(t){if(!a)return;const e=w(t.userId,t.streamType),o=n.get(e);if(o){try{await a.stopRemoteVideo({userId:t.userId,streamType:t.streamType})}catch{}o.wrap.remove(),n.delete(e)}}function C(){a&&(a.on(c.EVENT.REMOTE_VIDEO_AVAILABLE,T),a.on(c.EVENT.REMOTE_VIDEO_UNAVAILABLE,V))}function k(){a&&(a.off(c.EVENT.REMOTE_VIDEO_AVAILABLE,T),a.off(c.EVENT.REMOTE_VIDEO_UNAVAILABLE,V))}async function m(){if(k(),a){for(const[,t]of n){try{await a.stopRemoteVideo({userId:t.userId,streamType:t.streamType})}catch{}t.wrap.remove()}n.clear(),r.value&&(r.value.innerHTML="");try{await a.exitRoom()}catch{}try{a.destroy()}catch{}a=null}else n.clear(),r.value&&(r.value.innerHTML="")}async function L(){const t=++f;if(await m(),!u.diagnosisId){i.value="诊单无效";return}l.value=!0,i.value="",p.value="旁观视频通话";try{const e=await Y({diagnosis_id:u.diagnosisId});if(t!==f)return;e.patientName&&(p.value=`旁观视频通话 · ${e.patientName}`),a=c.create(),C();const o={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,autoReceiveAudio:!0,autoReceiveVideo:!0,...e.roomId!=null&&e.roomId>0?{roomId:e.roomId}:{strRoomId:e.strRoomId}};if(!(e.roomId!=null&&e.roomId>0)&&!e.strRoomId)throw new Error("缺少房间号");if(await a.enterRoom(o),t!==f){await m();return}l.value=!1}catch(e){l.value=!1;let o="进入房间失败";if(typeof e=="string")o=e;else if(e&&typeof e=="object"){const s=e;s.msg?o=String(s.msg):s.message&&(o=String(s.message))}i.value=o,await m()}}function M(){m(),l.value=!1,i.value="",p.value="旁观视频通话",g("closed")}return D(()=>[u.modelValue,u.diagnosisId],([t,e])=>{if(!t){f++,m();return}e>0&&L()}),(t,e)=>{const o=U,s=H;return E(),O(s,{modelValue:y.value,"onUpdate:modelValue":e[1]||(e[1]=d=>y.value=d),title:p.value,width:"760px","destroy-on-close":"","append-to-body":"","close-on-click-modal":!1,class:"assistant-watch-call-dialog",onClosed:M},{footer:I(()=>[e[3]||(e[3]=h("span",{class:"watch-hint"},"仅观看,不会开启摄像头与麦克风",-1)),P(o,{type:"primary",onClick:e[0]||(e[0]=d=>y.value=!1)},{default:I(()=>[...e[2]||(e[2]=[$("离开",-1)])]),_:1})]),default:I(()=>[l.value?(E(),_("div",z,"正在连接房间…")):i.value?(E(),_("div",F,S(i.value),1)):x("",!0),W(h("div",{ref_key:"gridRef",ref:r,class:"watch-grid"},null,512),[[j,!l.value&&!i.value]])]),_:1},8,["modelValue","title"])}}}),X=q(G,[["__scopeId","data-v-8c719418"]]);export{X as default};
|
||||
Regular → Executable
Regular → Executable
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
import{o as N,dl as O,R as D,q as r,r as f,v as o,D as i,K as P,L as n,P as h,ag as V,O as w,bn as L,bo as q,T as u,s as y,bq as z,M as v}from"./.pnpm-DnXobOVo.js";import M from"./RecordingPlaybackBlock-CCGZyrFu.js";import{U as x}from"./index-BWMgSEq-.js";import{bD as F,f as c,bE as R,bF as K,_ as j}from"./index-CcDX_qzp.js";import"./RecordingVideoPlayer-CT5H3XKE.js";import"./file-CwKsS4EB.js";const A={class:"call-record-panel"},G={key:0,class:"call-record-toolbar"},H={class:"call-record-empty"},J={class:"call-record-empty__desc"},Q={key:0,class:"text-primary"},W={key:1,class:"text-gray-400"},X=N({__name:"CallRecordPanel",props:{diagnosisId:{},readOnly:{type:Boolean,default:!1}},setup(_,{expose:k}){const d=_,p=v(!1),g=v([]),U=O("toolbarUploadRef"),m=async()=>{if(d.diagnosisId){p.value=!0;try{g.value=await F({diagnosis_id:d.diagnosisId})||[]}catch(e){console.error(e),g.value=[]}finally{p.value=!1}}};D(()=>d.diagnosisId,()=>{m()},{immediate:!0}),k({refresh:m});function C(e){return{1:"进行中",2:"已结束",3:"未接听",4:"已取消"}[e]??"—"}async function E(e){const t=b(e);if(!t){c.msgError("上传成功但未返回视频地址");return}try{const a=await K({diagnosis_id:d.diagnosisId});await R({diagnosis_id:d.diagnosisId,call_record_id:Number((a==null?void 0:a.id)||0),file_url:t}),c.msgSuccess("视频回放上传成功"),await m()}catch(a){c.msgError((a==null?void 0:a.message)||"写入回放失败")}}async function S(e,t){const a=b(t);if(!a){c.msgError("上传成功但未返回视频地址");return}try{await R({diagnosis_id:d.diagnosisId,call_record_id:Number(e.id||0),file_url:a}),c.msgSuccess("视频回放上传成功"),await m()}catch(l){c.msgError((l==null?void 0:l.message)||"写入回放失败")}}function b(e){var t,a;return String(((t=e==null?void 0:e.data)==null?void 0:t.uri)||((a=e==null?void 0:e.data)==null?void 0:a.url)||"").trim()}return(e,t)=>{const a=P,l=q,I=L,B=z;return r(),f("div",A,[_.readOnly?h("",!0):(r(),f("div",G,[o(x,{ref_key:"toolbarUploadRef",ref:U,type:"video",direct:"",multiple:!1,limit:1,"show-progress":!0,onSuccess:E},{default:i(()=>[o(a,{type:"primary"},{default:i(()=>[...t[0]||(t[0]=[n("上传视频",-1)])]),_:1})]),_:1},512)])),V((r(),w(I,{data:g.value,border:"",stripe:""},{empty:i(()=>[y("div",H,[t[1]||(t[1]=y("div",{class:"call-record-empty__title"},"暂无通话记录",-1)),y("div",J,u(_.readOnly?"暂无录制回放数据。":"现在可以直接点击上方“上传视频”。系统会自动生成一条默认通话记录来承载回放。"),1)])]),default:i(()=>[o(l,{label:"录制回放","min-width":"320"},{default:i(({row:s})=>[o(M,{"record-id":s.id,urls:s.recording_urls_list},null,8,["record-id","urls"])]),_:1}),o(l,{label:"开始时间",width:"170",prop:"start_time_text"}),o(l,{label:"结束时间",width:"170",prop:"end_time_text"}),o(l,{label:"通话类型",width:"100"},{default:i(({row:s})=>[n(u(s.call_type===1?"语音":"视频"),1)]),_:1}),o(l,{label:"房间号",width:"180"},{default:i(({row:s})=>[s.room_id?(r(),f("span",Q,u(s.room_id),1)):(r(),f("span",W,"—"))]),_:1}),o(l,{label:"时长",width:"110",prop:"duration_text"}),o(l,{label:"状态",width:"90"},{default:i(({row:s})=>[n(u(C(s.status)),1)]),_:1}),o(l,{label:"录制",width:"100"},{default:i(({row:s})=>[n(u(s.recording_status_text||"—"),1)]),_:1}),_.readOnly?h("",!0):(r(),w(l,{key:0,label:"上传回放",width:"180"},{default:i(({row:s})=>[o(x,{type:"video",direct:"",multiple:!1,limit:1,"show-progress":!0,onSuccess:T=>S(s,T)},{default:i(()=>[o(a,{type:"primary",plain:"",size:"small"},{default:i(()=>[...t[2]||(t[2]=[n("上传视频",-1)])]),_:1})]),_:1},8,["onSuccess"])]),_:1}))]),_:1},8,["data"])),[[B,p.value]])])}}}),la=j(X,[["__scopeId","data-v-78d5c9e4"]]);export{la as default};
|
||||
import{o as N,dl as O,R as P,q as r,r as f,v as o,D as i,K as V,L as n,P as h,ag as D,O as w,bn as L,bo as q,T as u,s as y,bq as z,M as v}from"./.pnpm-DnXobOVo.js";import M from"./RecordingPlaybackBlock-2brEtpcH.js";import{U as x}from"./index-BwIr9qiy.js";import{bE as F,f as c,bF as R,bG as G,_ as K}from"./index-B5yNocKV.js";import"./RecordingVideoPlayer-D3EW1shD.js";import"./file-CN5TlpMj.js";const j={class:"call-record-panel"},A={key:0,class:"call-record-toolbar"},H={class:"call-record-empty"},J={class:"call-record-empty__desc"},Q={key:0,class:"text-primary"},W={key:1,class:"text-gray-400"},X=N({__name:"CallRecordPanel",props:{diagnosisId:{},readOnly:{type:Boolean,default:!1}},setup(_,{expose:k}){const d=_,p=v(!1),g=v([]),U=O("toolbarUploadRef"),m=async()=>{if(d.diagnosisId){p.value=!0;try{g.value=await F({diagnosis_id:d.diagnosisId})||[]}catch(e){console.error(e),g.value=[]}finally{p.value=!1}}};P(()=>d.diagnosisId,()=>{m()},{immediate:!0}),k({refresh:m});function C(e){return{1:"进行中",2:"已结束",3:"未接听",4:"已取消"}[e]??"—"}async function E(e){const t=b(e);if(!t){c.msgError("上传成功但未返回视频地址");return}try{const a=await G({diagnosis_id:d.diagnosisId});await R({diagnosis_id:d.diagnosisId,call_record_id:Number((a==null?void 0:a.id)||0),file_url:t}),c.msgSuccess("视频回放上传成功"),await m()}catch(a){c.msgError((a==null?void 0:a.message)||"写入回放失败")}}async function S(e,t){const a=b(t);if(!a){c.msgError("上传成功但未返回视频地址");return}try{await R({diagnosis_id:d.diagnosisId,call_record_id:Number(e.id||0),file_url:a}),c.msgSuccess("视频回放上传成功"),await m()}catch(l){c.msgError((l==null?void 0:l.message)||"写入回放失败")}}function b(e){var t,a;return String(((t=e==null?void 0:e.data)==null?void 0:t.uri)||((a=e==null?void 0:e.data)==null?void 0:a.url)||"").trim()}return(e,t)=>{const a=V,l=q,I=L,B=z;return r(),f("div",j,[_.readOnly?h("",!0):(r(),f("div",A,[o(x,{ref_key:"toolbarUploadRef",ref:U,type:"video",direct:"",multiple:!1,limit:1,"show-progress":!0,onSuccess:E},{default:i(()=>[o(a,{type:"primary"},{default:i(()=>[...t[0]||(t[0]=[n("上传视频",-1)])]),_:1})]),_:1},512)])),D((r(),w(I,{data:g.value,border:"",stripe:""},{empty:i(()=>[y("div",H,[t[1]||(t[1]=y("div",{class:"call-record-empty__title"},"暂无通话记录",-1)),y("div",J,u(_.readOnly?"暂无录制回放数据。":"现在可以直接点击上方“上传视频”。系统会自动生成一条默认通话记录来承载回放。"),1)])]),default:i(()=>[o(l,{label:"录制回放","min-width":"320"},{default:i(({row:s})=>[o(M,{"record-id":s.id,urls:s.recording_urls_list},null,8,["record-id","urls"])]),_:1}),o(l,{label:"开始时间",width:"170",prop:"start_time_text"}),o(l,{label:"结束时间",width:"170",prop:"end_time_text"}),o(l,{label:"通话类型",width:"100"},{default:i(({row:s})=>[n(u(s.call_type===1?"语音":"视频"),1)]),_:1}),o(l,{label:"房间号",width:"180"},{default:i(({row:s})=>[s.room_id?(r(),f("span",Q,u(s.room_id),1)):(r(),f("span",W,"—"))]),_:1}),o(l,{label:"时长",width:"110",prop:"duration_text"}),o(l,{label:"状态",width:"90"},{default:i(({row:s})=>[n(u(C(s.status)),1)]),_:1}),o(l,{label:"录制",width:"100"},{default:i(({row:s})=>[n(u(s.recording_status_text||"—"),1)]),_:1}),_.readOnly?h("",!0):(r(),w(l,{key:0,label:"上传回放",width:"180"},{default:i(({row:s})=>[o(x,{type:"video",direct:"",multiple:!1,limit:1,"show-progress":!0,onSuccess:T=>S(s,T)},{default:i(()=>[o(a,{type:"primary",plain:"",size:"small"},{default:i(()=>[...t[2]||(t[2]=[n("上传视频",-1)])]),_:1})]),_:1},8,["onSuccess"])]),_:1}))]),_:1},8,["data"])),[[B,p.value]])])}}}),la=K(X,[["__scopeId","data-v-78d5c9e4"]]);export{la as default};
|
||||
Regular → Executable
+1
-1
File diff suppressed because one or more lines are too long
Regular → Executable
+1
-1
@@ -1 +1 @@
|
||||
import{o as T,a0 as V,R as I,q as o,r as l,v as a,K as N,D as n,L as c,P as w,ag as z,bq as M,u as p,O as f,bo as O,T as _,F as P,bp as F,s as R,bn as j,by as q,M as k}from"./.pnpm-DnXobOVo.js";import{bG as A,_ as G}from"./index-CcDX_qzp.js";const H={class:"case-record-list"},K={key:0,class:"mb-3 flex justify-end"},Y={key:0},J={key:1,class:"text-gray-400"},Q={class:"void-detail text-xs text-gray-500 mt-1"},U=T({__name:"CaseRecordList",props:{diagnosisId:{type:Number,default:0},readOnly:{type:Boolean,default:!1}},emits:["view","openPrescription"],setup(y,{expose:x,emit:C}){const m=y,b=C,r=k([]),d=k(!1),u=async()=>{if(m.diagnosisId){d.value=!0;try{const t=await A({diagnosis_id:m.diagnosisId});r.value=Array.isArray(t)?t:[]}catch(t){console.error("获取病历记录失败:",t),r.value=[]}finally{d.value=!1}}},S=t=>{if(!t)return"";const e=new Date(t*1e3);return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`},$=t=>{b("view",t)},B=()=>{b("openPrescription")};return V(()=>{u()}),I(()=>m.diagnosisId,()=>{u()}),x({refresh:u}),(t,e)=>{const h=N,i=O,v=F,E=j,D=q,L=M;return o(),l("div",H,[y.readOnly?w("",!0):(o(),l("div",K,[a(h,{type:"primary",size:"small",onClick:B},{default:n(()=>[...e[0]||(e[0]=[c("开方",-1)])]),_:1})])),z((o(),f(E,{data:p(r),border:""},{default:n(()=>[a(i,{prop:"prescription_date",label:"就诊日期",width:"120"}),a(i,{prop:"visit_no",label:"门诊号",width:"120"}),a(i,{prop:"clinical_diagnosis",label:"临床诊断","min-width":"160","show-overflow-tooltip":""}),a(i,{label:"处方摘要","min-width":"180"},{default:n(({row:s})=>[s.herbs&&s.herbs.length?(o(),l("span",Y,_(s.herbs.slice(0,3).map(g=>`${g.name}${g.dosage}克`).join("、"))+_(s.herbs.length>3?"...":""),1)):(o(),l("span",J,"—"))]),_:1}),a(i,{prop:"doctor_name",label:"医师",width:"90","show-overflow-tooltip":""}),a(i,{label:"状态",width:"140",align:"center"},{default:n(({row:s})=>[s.void_status===1?(o(),l(P,{key:0},[a(v,{type:"danger",size:"small"},{default:n(()=>[...e[1]||(e[1]=[c("已作废",-1)])]),_:1}),R("div",Q,_(s.void_by_name||"—")+" "+_(S(s.void_time)),1)],64)):(o(),f(v,{key:1,type:"success",size:"small"},{default:n(()=>[...e[2]||(e[2]=[c("正常",-1)])]),_:1}))]),_:1}),a(i,{label:"操作",width:"120",fixed:"right"},{default:n(({row:s})=>[a(h,{link:"",type:"primary",size:"small",onClick:g=>$(s)},{default:n(()=>[...e[3]||(e[3]=[c(" 查看 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[L,p(d)]]),!p(d)&&p(r).length===0?(o(),f(D,{key:1,description:"暂无病历记录,开方后会自动显示",class:"mt-4"})):w("",!0)])}}}),Z=G(U,[["__scopeId","data-v-043d2738"]]);export{Z as default};
|
||||
import{o as T,a0 as V,R as I,q as o,r as l,v as a,K as N,D as n,L as c,P as w,ag as z,bq as M,u as p,O as f,bo as O,T as _,F as P,bp as F,s as R,bn as j,by as q,M as k}from"./.pnpm-DnXobOVo.js";import{bH as A,_ as H}from"./index-B5yNocKV.js";const K={class:"case-record-list"},Y={key:0,class:"mb-3 flex justify-end"},G={key:0},J={key:1,class:"text-gray-400"},Q={class:"void-detail text-xs text-gray-500 mt-1"},U=T({__name:"CaseRecordList",props:{diagnosisId:{type:Number,default:0},readOnly:{type:Boolean,default:!1}},emits:["view","openPrescription"],setup(y,{expose:x,emit:C}){const m=y,b=C,r=k([]),d=k(!1),u=async()=>{if(m.diagnosisId){d.value=!0;try{const t=await A({diagnosis_id:m.diagnosisId});r.value=Array.isArray(t)?t:[]}catch(t){console.error("获取病历记录失败:",t),r.value=[]}finally{d.value=!1}}},S=t=>{if(!t)return"";const e=new Date(t*1e3);return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`},$=t=>{b("view",t)},B=()=>{b("openPrescription")};return V(()=>{u()}),I(()=>m.diagnosisId,()=>{u()}),x({refresh:u}),(t,e)=>{const h=N,i=O,v=F,E=j,D=q,L=M;return o(),l("div",K,[y.readOnly?w("",!0):(o(),l("div",Y,[a(h,{type:"primary",size:"small",onClick:B},{default:n(()=>[...e[0]||(e[0]=[c("开方",-1)])]),_:1})])),z((o(),f(E,{data:p(r),border:""},{default:n(()=>[a(i,{prop:"prescription_date",label:"就诊日期",width:"120"}),a(i,{prop:"visit_no",label:"门诊号",width:"120"}),a(i,{prop:"clinical_diagnosis",label:"临床诊断","min-width":"160","show-overflow-tooltip":""}),a(i,{label:"处方摘要","min-width":"180"},{default:n(({row:s})=>[s.herbs&&s.herbs.length?(o(),l("span",G,_(s.herbs.slice(0,3).map(g=>`${g.name}${g.dosage}克`).join("、"))+_(s.herbs.length>3?"...":""),1)):(o(),l("span",J,"—"))]),_:1}),a(i,{prop:"doctor_name",label:"医师",width:"90","show-overflow-tooltip":""}),a(i,{label:"状态",width:"140",align:"center"},{default:n(({row:s})=>[s.void_status===1?(o(),l(P,{key:0},[a(v,{type:"danger",size:"small"},{default:n(()=>[...e[1]||(e[1]=[c("已作废",-1)])]),_:1}),R("div",Q,_(s.void_by_name||"—")+" "+_(S(s.void_time)),1)],64)):(o(),f(v,{key:1,type:"success",size:"small"},{default:n(()=>[...e[2]||(e[2]=[c("正常",-1)])]),_:1}))]),_:1}),a(i,{label:"操作",width:"120",fixed:"right"},{default:n(({row:s})=>[a(h,{link:"",type:"primary",size:"small",onClick:g=>$(s)},{default:n(()=>[...e[3]||(e[3]=[c(" 查看 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[L,p(d)]]),!p(d)&&p(r).length===0?(o(),f(D,{key:1,description:"暂无病历记录,开方后会自动显示",class:"mt-4"})):w("",!0)])}}}),Z=H(U,[["__scopeId","data-v-043d2738"]]);export{Z as default};
|
||||
+2
-2
File diff suppressed because one or more lines are too long
Regular → Executable
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+2
-2
File diff suppressed because one or more lines are too long
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user