4.2 KiB
Desktop business-order prescription audit signatures
Completed 2026-11-13. Scope: app/ desktop Python workstation; no changes to server/ or admin/.
Implemented
app/src/doctor_workstation/ui/pages/patients.py: business-order prescription audit now opens_PrescriptionAuditDialog, with approve/reject, remarks, and the existing handwrittenSignaturePad. Both results require new ink, rejection still requires an opinion. Signature data is never loaded from a previous order or user profile. Clear and cancellation remove the signature; each newly opened dialog starts blank. Invalid input cannot submit. Pending submissions disable controls and block duplicate submit, Escape, and closing. Network/server errors retain ink and remarks for retry; only success closes the dialog and refreshes workspaces. The body scrolls at narrow/short sizes, with the clear control above the pad and the action buttons outside the scroll area. Payment audit retains its original flow.app/src/doctor_workstation/services/repository.py: protocol and remote method require keywordsignature; the request tofirstvisit.myPatient/orderAuditPrescriptioncontainsid,action, trimmedremark, and the PNG data URL. Blank/non-PNG data URLs are rejected locally. Pixel/image validity remains authoritative on the server.app/src/doctor_workstation/services/mock_repository.py: demo audit records the current signer ID/name/time and signature, clears active fields on revocation, and supplies current order audit fields on prescription detail. Demo detail chooses the latest non-deleted, non-cancelled/non-refunded order, matching the coordinated backend contract.app/src/doctor_workstation/ui/dialogs/prescription.py: shared slip renderer adds药师:姓名directly below the doctor, in both pharmacy and patient copies, only whenprescription_audit_status == 1, signature is present, andprescription_audit_signed_nameis nonblank. Names are HTML-escaped. Consumer audit identity is not used as a fallback. The renderer is already shared by preview, raster image, printing, and PDF export, so all carry the same name. Existing doctor signature capture and consumer prescription audit behavior are unchanged.
Verification
Using local app/.venv/Scripts/python.exe, PySide6 6.11.1 and pytest 8.4.2:
python -m pytest tests/test_patient_order_audit_signature.py tests/test_patients_ui.py tests/test_repository_parity.py tests/test_prescription_ui.py tests/test_mock_repository.py -o addopts='' -q --basetemp=.pytest-tmp-rx-audit-signature-final
121 passed in 20.52s
The new behavior tests cover approve/reject payloads, missing/blank signature, rejection reason, actual mouse-drawn PNG output, no prefill from historical signatures, clearing, fresh reopening, failure retention and retry, duplicate-submit prevention, blocking dismissal in flight, narrow geometry at 360 px, unchanged payment audit, demo signer/revocation metadata, valid-only pharmacist attribution, HTML escaping, both prescription variants, print mode, image and PDF output. Existing patient UI integration was updated to exercise the new dialog with actual pointer events.
Ruff checks passed for all six changed Python files. git -c core.whitespace=cr-at-eol diff --check -- app passed. Existing repository files contain mixed CRLF/LF; their line-ending style was preserved rather than rewriting whole files.
Visual inspection performed on a themed 360 × 520 audit dialog and on the exported patient slip PNG and rendered one-page PDF. Clear/submit controls remain accessible, and the pharmacist name is visibly below the doctor in both exported formats.
artifacts/rx-audit-signature-desktop-dialog.pngartifacts/rx-audit-signature-desktop-slip.pngartifacts/rx-audit-signature-desktop-slip.pdfartifacts/rx-audit-signature-desktop-pdf-preview.png
Limits
No authenticated production request or live database mutation was performed. Remote tests assert the exact request contract with recording clients; Qt UI and export tests use local data. The server must provide the agreed prescription audit fields and perform authoritative signature image validation and permission/state checks. The desktop does not infer a pharmacist from historical unsigned audits or the separate consumer audit.