first commit

This commit is contained in:
Your Name
2026-09-08 11:40:15 +08:00
commit a5353f7eb5
9568 changed files with 1646214 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# 此文件是源码开发/企业部署模板,不会被复制进发布 ZIP/.app。
# 生产配置应由受控启动器、设备管理或进程环境注入;禁止把密码、token、
# UserSig、TRTC SecretKey 或其他长期凭据写进本文件或发布包。
# 后端根地址。程序会自动追加 /adminapi;也可直接填写以 /adminapi 结尾的地址。
DOCTOR_API_BASE_URL=https://api.example.com
# 首次验收可设为 true,使用内置演示数据;生产必须设为 false。
DOCTOR_DEMO_MODE=true
# 当前只支持 embedded。browser 在后端提供一次性 handoff 前会被明确拒绝,且不会自动打开系统浏览器。
DOCTOR_VIDEO_MODE=embedded
# 可选:本地 dist 缺失时由 QtWebEngine 内嵌加载的可信 HTTPS 页面;不是 browser handoff URL,禁止携带 UserSig。
DOCTOR_VIDEO_WEB_URL=
# 生产环境必须保持 true。仅内网自签证书调试时临时关闭。
DOCTOR_VERIFY_SSL=true
DOCTOR_REQUEST_TIMEOUT=30
# 日志级别:DEBUG / INFO / WARNING / ERROR。日志会自动脱敏 token 与 UserSig。
DOCTOR_LOG_LEVEL=INFO
# 可选:仅供企业部署/自动化验收隔离用户数据目录。
# DOCTOR_CONFIG_DIR=
# DOCTOR_LOG_DIR=
+23
View File
@@ -0,0 +1,23 @@
.env
.venv/
.venv-build/
.uv-cache/
.uv-python/
__pycache__/
*.py[cod]
.pytest_cache/
.pytest-tmp-*/
artifacts/pytest_*/
.ruff_cache/
.coverage
htmlcov/
build/
dist/
!video_companion/dist/
!video_companion/dist/**
*.spec.bak
node_modules/
video_companion/node_modules/
*.log
.DS_Store
Thumbs.db
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "PROJECT_ROOT=%~dp0"
set "POWERSHELL_EXE=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
"%POWERSHELL_EXE%" -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%PROJECT_ROOT%scripts\package_windows.ps1" %*
set "RESULT=%ERRORLEVEL%"
if "%RESULT%"=="0" (
echo.
echo Package ready in: %PROJECT_ROOT%dist
if /I not "%~1"=="-ValidateOnly" (
start "" "%SystemRoot%\explorer.exe" "%PROJECT_ROOT%dist"
)
) else (
echo.
echo DoctorWorkstation packaging failed. Exit code: %RESULT%
echo Press any key to close this window.
pause >nul
)
endlocal & exit /b %RESULT%
+82
View File
@@ -0,0 +1,82 @@
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "PROJECT_ROOT=%~dp0"
set "PYTHON_EXE=%PROJECT_ROOT%.venv\Scripts\python.exe"
cd /d "%PROJECT_ROOT%" || goto :cd_failed
if not exist "%PYTHON_EXE%" goto :venv_missing
rem Always run the current source tree instead of an older packaged EXE.
set "PYTHONPATH=%PROJECT_ROOT%src"
set "PYTHONUNBUFFERED=1"
set "PYTHONDONTWRITEBYTECODE=1"
rem Keep a dedicated debug profile, but reuse it so account/server preferences persist.
set "DEBUG_PROFILE=%LOCALAPPDATA%\ZhenYangTang\DoctorWorkstation\Debug"
if not defined LOCALAPPDATA set "DEBUG_PROFILE=%PROJECT_ROOT%.debug-profile"
set "DOCTOR_CONFIG_DIR=%DEBUG_PROFILE%\config"
set "DOCTOR_LOG_DIR=%DEBUG_PROFILE%\logs"
set "DOCTOR_DEMO_MODE=true"
set "DOCTOR_LOG_LEVEL=DEBUG"
set "DOCTOR_VIDEO_MODE=embedded"
if not exist "%DOCTOR_CONFIG_DIR%" mkdir "%DOCTOR_CONFIG_DIR%" >nul 2>&1
if not exist "%DOCTOR_LOG_DIR%" mkdir "%DOCTOR_LOG_DIR%" >nul 2>&1
echo ============================================================
echo Doctor Workstation - Source Debug Mode
echo ============================================================
echo Project : %PROJECT_ROOT%
echo Logs : %DOCTOR_LOG_DIR%
echo Account : doctor
echo Password: doctor123
echo ============================================================
echo.
if /I "%~1"=="--check" goto :check
"%PYTHON_EXE%" -X faulthandler -m doctor_workstation
set "RESULT=%ERRORLEVEL%"
if "%RESULT%"=="0" goto :success
echo.
echo [ERROR] Doctor Workstation exited with code %RESULT%.
echo [INFO] Debug logs: %DOCTOR_LOG_DIR%
echo Press any key to close this window.
pause >nul
endlocal & exit /b %RESULT%
:check
"%PYTHON_EXE%" -c "import doctor_workstation; from doctor_workstation.ui.theme import COLORS; print('DEBUG_LAUNCHER_OK', COLORS['canvas'])"
set "RESULT=%ERRORLEVEL%"
if not "%RESULT%"=="0" goto :check_failed
echo.
echo [OK] Source imports and debug environment are ready.
endlocal & exit /b 0
:check_failed
echo.
echo [ERROR] Source import check failed with code %RESULT%.
pause >nul
endlocal & exit /b %RESULT%
:success
endlocal & exit /b 0
:venv_missing
echo.
echo [ERROR] Python virtual environment was not found:
echo %PYTHON_EXE%
echo.
echo Create or restore app\.venv and install the project dependencies first.
echo Press any key to close this window.
pause >nul
endlocal & exit /b 2
:cd_failed
echo [ERROR] Could not enter the project directory: %PROJECT_ROOT%
pause >nul
endlocal & exit /b 3
+137
View File
@@ -0,0 +1,137 @@
# 甄养堂医生工作站
一个以 Python + PySide6 编写的跨平台医生桌面端,面向 Windows 10/11 与 macOS 13+。项目按现有 `admin` 源码的真实接口契约实现,覆盖登录、接诊台、我的处方库、已开处方、患者列表、问诊列表和腾讯云视频面诊。
> 当前版本提供完整的演示数据模式,便于在没有后端账号或腾讯云配置时验收界面与流程。切换到生产模式后,数据与权限均由现有后端返回。
## 一键运行与一键打包
Windows 直接在项目根目录双击:
- `一键运行_医生工作站.bat`:优先启动现有成品;没有成品时自动使用 `uv` 准备源码环境并运行。
- `一键打包_医生工作站.bat`:自动同步锁定的 Python/Node 依赖,检查冻结 QtWebEngine/QtMultimedia 文件,执行应用与媒体离屏冒烟验证,最后生成 `dist/DoctorWorkstation-Windows-x64-<版本>.zip` 和 SHA-256 文件。
英文稳定别名分别是 `Run_DoctorWorkstation.bat``Build_DoctorWorkstation.bat`。分发 ZIP 解压后,可直接双击其中的 `Start_DoctorWorkstation.bat`
macOS 在 Finder 中双击:
- `一键运行.command`:优先打开现有 `DoctorWorkstation.app`,否则自动准备源码环境并运行。
- `一键打包.command`:构建、QtWebEngine/QtMultimedia 文件门禁、签名检查和两项冻结冒烟验证后,生成 `.app`、可分发 ZIP 及 SHA-256 文件。
Windows 打包机需预先安装 `uv` 与 Node.js 20+;脚本会自动处理项目虚拟环境和锁定依赖。首次打包需要联网下载依赖,之后会复用本机缓存。macOS 发布源码中的根 `.command` 与操作型 `scripts/*.sh` 必须以 Git mode `100755` 跟踪;源码压缩包在传输中丢失权限时,可在项目目录执行一次 `chmod +x *.command scripts/*.sh`。若 Gatekeeper 拦截未签名内部测试版,请使用右键“打开”。
## 已实现范围
- 账号密码登录、token 会话、通过系统凭据管理器安全记住密码和退出登录。
- 登录后读取 `/adminapi/auth.admin/mySelf`,按 `permissions` 动态控制页面和操作按钮;`*` 超级权限兼容现有后台。
- 接诊台:今日待接诊/已过号、患者详情、医生备注、通知医助、完成接诊、发起视频面诊。
- 挂号列表:对齐管理端 `tcm/appointment/list`,支持状态 Tab、日期/确认/部门筛选、通话、完成、开方与取消挂号。
- 我的处方库:主方/辅方与公开范围筛选,药材动态编辑,模板所有权和增删改权限。
- 已开处方:处方号/患者/审核状态筛选、状态展示和只读详情。
- 患者列表:复用 `/firstvisit.myPatient/lists` 的服务端数据范围,不在客户端伪造医生或部门过滤。
- 问诊列表:对齐管理端 `tcm/diagnosis`,支持诊单筛选、预约、开方、指派、日常记录与只读详情。
- 腾讯视频:沿用现有项目的 `@trtc/calls-uikit-vue` 主链;UserSig 只从后端短时获取,客户端不包含 SDKSecretKey。当前仅支持隔离的 QtWebEngine 内嵌模式。
- PyInstaller Windows/macOS 构建脚本、macOS 摄像头/麦克风权限配置与自动化测试。
## 手动运行
先安装 [uv](https://docs.astral.sh/uv/),然后在项目根目录执行:
```powershell
uv sync --extra dev --extra build
Copy-Item .env.example .env
uv run doctor-workstation
```
macOS/Linux
```bash
uv sync --extra dev --extra build
cp .env.example .env
uv run doctor-workstation
```
`.env.example` 默认启用演示模式。演示账号:`doctor`,密码:`doctor123`
`.env.example` 仅作为源码开发/企业部署模板,不会复制进发布 ZIP 或 `.app`。生产环境请通过受控启动器、设备管理或进程环境注入配置;不要把密码、token、UserSig、TRTC SecretKey 等凭据放进 `.env` 或发布包。
## 连接现有后端
`.env` 调整为:
```dotenv
DOCTOR_API_BASE_URL=https://your-api.example.com
DOCTOR_DEMO_MODE=false
DOCTOR_VERIFY_SSL=true
```
如果可信内网调试服务器使用自签名证书,可在登录页展开“服务器设置”,临时勾选
“信任自签名证书(仅内网调试)”;点击登录时会自动应用当前设置。该选项会关闭
服务器身份校验,不得用于公网或生产环境。
程序会自动在地址末尾追加 `/adminapi`。它与现有管理端保持相同约定:
- 登录:`POST /login/account`,请求包含 `account``password``terminal=1`
- 鉴权请求头:`token: <登录 token>``version: 1.9.4`
- 响应 envelope`code=1` 成功、`0` 业务失败、`-1` 登录失效、`10` 需绑定企业微信。
- 权限与数据范围:完全以后端 `/auth.admin/mySelf` 返回为准。
环境配置不会保存明文密码、TRTC SecretKey 或腾讯云长期凭据。登录密码优先存入系统凭据管理器;Windows 凭据后端不可用时仅保存当前 Windows 用户可解密的 DPAPI 密文。登录 token 优先存入系统凭据库,无法使用时仅回退到用户配置目录中的受限文件。
## 视频伴随页
腾讯云没有官方 Python/PySide6 客户端 SDK。本项目因此采用 Python 业务主程序 + 腾讯官方 Web TUICallKit 伴随页:
```powershell
Set-Location video_companion
npm ci
npm run build
```
构建输出位于 `video_companion/dist`,由桌面端内嵌加载。生产 UserSig 必须由现有 `/tcm.diagnosis/getCallSignature` 接口签发;不要把 SDKSecretKey 写入 `.env` 或 JavaScript。
当前仅支持 `embedded`。在业务后端提供服务端签发、一次性消费的 browser handoff 之前,`browser` 模式会被明确拒绝,QtWebEngine 不可用时也不会自动打开系统浏览器。这样可以避免后端已记录 `startCall`、浏览器页面却没有通话票据的“幽灵通话”。
```dotenv
DOCTOR_VIDEO_MODE=embedded
DOCTOR_VIDEO_WEB_URL=https://rtc.example.com/doctor-call
```
`DOCTOR_VIDEO_WEB_URL` 仅用于本地 `dist` 缺失时,在 QtWebEngine 中内嵌加载受信任的 HTTPS 主文档;它不是 browser handoff URL,也不得在 URL 中携带 UserSig 或其他 RTC 凭据。
## 测试与打包
```powershell
uv run pytest
uv run ruff check src tests
.\scripts\build_windows.ps1
```
`build_windows.ps1` 只生成并验证 onedir;正式一键发布请运行 `Build_DoctorWorkstation.bat`,它在所有冻结文件/媒体门禁通过后再生成版本 ZIP 与 SHA-256。
macOS 必须在 macOS 机器上构建、签名和公证:
```bash
./scripts/build_macos.sh
```
`build_macos.sh` 只生成并验证 `.app`;正式一键发布请双击 `一键打包.command`(或 `package_macos.command`),通过相同门禁后再归档并生成 SHA-256。
Windows 与 macOS 的 Qt/媒体权限和签名产物不能交叉编译。首次生产发布前,应按 [research/tencent_rtc.md](research/tencent_rtc.md) 的准入清单完成摄像头、麦克风、设备插拔、休眠恢复和弱网实测。
## 工程结构
```text
src/doctor_workstation/
core/ 业务模型、权限、会话与异常
services/ HTTP 客户端、远程仓库、演示仓库与安全 token 存储
ui/ PySide6 登录、主框架、页面和对话框
video/ 视频请求规范化、异步生命周期与隔离的内嵌窗口
video_companion/ 腾讯 TUICallKit 页面
packaging/ PyInstaller 与 macOS 权限配置
scripts/ Windows/macOS 构建脚本
tests/ 不依赖真实后端和腾讯云的自动化测试
research/ admin 源码审计、架构和腾讯 RTC 官方资料研究
```
详细的接口/字段与权限审计见 [research/admin_audit.md](research/admin_audit.md)。
+16
View File
@@ -0,0 +1,16 @@
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "PROJECT_ROOT=%~dp0"
set "POWERSHELL_EXE=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
"%POWERSHELL_EXE%" -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%PROJECT_ROOT%scripts\run_windows.ps1" %*
set "RESULT=%ERRORLEVEL%"
if not "%RESULT%"=="0" (
echo.
echo DoctorWorkstation failed to start. Exit code: %RESULT%
echo Press any key to close this window.
pause >nul
)
endlocal & exit /b %RESULT%
+14
View File
@@ -0,0 +1,14 @@
# 安全与隐私约束
医生工作台会处理患者身份、病历、处方和音视频等敏感信息。生产部署必须遵守以下基线:
- 客户端不包含腾讯云 `SDKSecretKey`、COS Secret 或后端数据库凭据。TRTC `UserSig` 由服务端按当前医生和单次通话短时签发。
- 不在 URL 查询参数、命令行或日志中传递 token、UserSig、患者身份证号和完整病历。项目日志过滤器会遮蔽常见凭据,但调用代码仍应避免记录完整请求/响应。
- 密码从不落盘;“记住账号”只保存账号。登录 token 优先写入 Windows Credential Manager / macOS Keychain。
- 生产 API 与浏览器视频页必须使用 HTTPS 并验证证书。`DOCTOR_VERIFY_SSL=false` 只允许在受控开发环境临时使用。
- 页面可见性与按钮权限来自 `/auth.admin/mySelf`,但客户端权限仅用于界面体验;服务端仍必须对每个接口执行身份、租户、数据范围和动作权限校验。
- 本地不缓存患者列表、病历、处方和通话票据。演示数据是完全虚构的静态数据。
- 通话录制、截图和报告上传属于单独的合规能力;启用前必须确认患者告知/同意、留存周期、访问审计和删除流程。
- 软件发布必须签名。Windows 建议 AuthenticodemacOS 需要 Developer ID、Hardened Runtime、摄像头/麦克风用途说明与公证。
发现凭据泄露、越权、患者数据写入日志或视频房间被未授权加入时,应立即停用相关凭据、保留审计证据并按组织的安全响应流程处置。
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Some files were not shown because too many files have changed in this diff Show More