「已开处方」新增作废、医生电子签署身份两个按钮权限,按角色勾选
- 作废(tcm.prescription/void):未勾选的角色看不到按钮、接口也拒绝;开方/删除/审核权限不再隐含作废。 勾选后仍只能作废本人开具的处方,具备审核角色的可作废数据范围内他人的处方;审核驳回作废不受影响 - 医生电子签署身份(tcm.prescription/esignDoctor):医生角色未勾选时,顶部下拉入口与签署面板「签署身份与证书」隐藏, 服务端认证、快捷签授权一并拒绝(即不能签署处方);药师审核签署身份不受影响。桌面端入口同步按此权限判断 - 迁移 2026_11_27_prescription_void_esign_doctor_menu.sql:挂在「已开处方」下,默认不授予任何角色 - 重新构建管理后台 - 记录诊单 IM 聊天补拉改为独立系统 cron 的部署说明(原串行调度会被其阻塞数小时) Co-Authored-By: Claude Opus 5 (1M context) <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5 (1M context)
parent
3451f43c22
commit
dfe5768cd2
@@ -143,6 +143,10 @@ namespace {
|
||||
doctor_name TEXT,create_time INTEGER,UNIQUE(doctor_id,environment,app_id))');
|
||||
Db::name('admin')->insertAll([['id' => 1, 'name' => Provider::NAME], ['id' => 2, 'name' => '另一位医师'], ['id' => 3, 'name' => '客服']]);
|
||||
Db::name('admin_role')->insertAll([['admin_id' => 1, 'role_id' => 1], ['admin_id' => 2, 'role_id' => 1], ['admin_id' => 3, 'role_id' => 2]]);
|
||||
Db::execute('CREATE TABLE zyt_system_menu (id INTEGER PRIMARY KEY, perms TEXT, is_disable INTEGER DEFAULT 0)');
|
||||
Db::execute('CREATE TABLE zyt_system_role_menu (role_id INTEGER, menu_id INTEGER)');
|
||||
Db::name('system_menu')->insert(['id' => 1, 'perms' => Enrollment::DOCTOR_IDENTITY_PERMISSION]);
|
||||
Db::name('system_role_menu')->insert(['role_id' => 1, 'menu_id' => 1]);
|
||||
|
||||
$checks = 0;
|
||||
$assert = static function (bool $condition, string $message) use (&$checks): void {
|
||||
@@ -167,6 +171,15 @@ namespace {
|
||||
$unbound = Enrollment::status(1);
|
||||
$assert($unbound['status'] === 'unbound' && !isset($unbound['certificate_state']), 'doctor starts unbound');
|
||||
$throws(static fn () => Enrollment::status(3), DomainException::class, 'non-physician denied');
|
||||
Db::name('system_role_menu')->where('menu_id', 1)->delete();
|
||||
foreach ([static fn () => Enrollment::status(1), static fn () => Enrollment::start(1, $phone)] as $withoutGrant) {
|
||||
$throws($withoutGrant, DomainException::class, 'a doctor role without the signing identity button grant cannot enroll or sign');
|
||||
}
|
||||
Db::name('system_menu')->where('id', 1)->update(['is_disable' => 1]);
|
||||
Db::name('system_role_menu')->insert(['role_id' => 1, 'menu_id' => 1]);
|
||||
$throws(static fn () => Enrollment::status(1), DomainException::class, 'a disabled signing identity button grants nothing');
|
||||
Db::name('system_menu')->where('id', 1)->update(['is_disable' => 0]);
|
||||
$assert(Provider::$starts === 0 && Db::name('doctor_esign_identity')->count() === 0, 'a refused doctor never reaches the provider');
|
||||
$throws(static fn () => Enrollment::willingnessRecipient(1, Provider::NAME, ''), DoctorEsignIdentityRequired::class, 'setup-required reason distinguishes an unbound doctor');
|
||||
|
||||
Provider::$duringStart = static function () use ($assert, $phone): void {
|
||||
|
||||
@@ -989,6 +989,9 @@ namespace {
|
||||
Db::execute("INSERT INTO zyt_system_menu (id, perms) VALUES (1, 'tcm.diagnosis/kaifang'), (2, 'cf.prescription/lists'), (3, 'cf.prescription/audit')");
|
||||
Db::execute('INSERT INTO zyt_admin_role VALUES (1, 1), (2, 1), (3, 2), (4, 3)');
|
||||
Db::execute('INSERT INTO zyt_system_role_menu VALUES (1, 1), (2, 2), (3, 3)');
|
||||
// 医生角色勾选「医生电子签署身份」,后续短信/快捷签流程才能使用签署身份。
|
||||
Db::name('system_menu')->insert(['id' => 6, 'perms' => \app\common\service\esign\DoctorEsignIdentityService::DOCTOR_IDENTITY_PERMISSION]);
|
||||
Db::name('system_role_menu')->insert(['role_id' => 1, 'menu_id' => 6]);
|
||||
Db::execute("INSERT INTO zyt_system_role VALUES (1, 'Doctor', 4, NULL), (2, 'Read only', 4, NULL), (3, 'Audit', 1, NULL)");
|
||||
Db::execute('CREATE TABLE zyt_tcm_diagnosis (id INTEGER PRIMARY KEY, status INTEGER, patient_id INTEGER,
|
||||
assistant_id INTEGER, patient_name TEXT, gender INTEGER, age INTEGER, phone TEXT, delete_time INTEGER)');
|
||||
@@ -1006,12 +1009,20 @@ namespace {
|
||||
$auditor = ['root' => 0, 'admin_id' => 4, 'role_id' => [3]];
|
||||
$permissionAlias = new \ReflectionMethod(AuthMiddleware::class, 'matchPermissionAlias');
|
||||
foreach (PrescriptionLogic::PRESCRIBE_PERMISSIONS as $grant) {
|
||||
$assert($permissionAlias->invoke(new AuthMiddleware(), 'tcm.prescription/void', [$grant]), 'prescribing grants permit the void route');
|
||||
$assert(!$permissionAlias->invoke(new AuthMiddleware(), 'tcm.prescription/void', [$grant]), 'prescribing grants no longer imply the void button');
|
||||
$assert($permissionAlias->invoke(new AuthMiddleware(), 'tcm.prescription/submitforreview', [$grant]), 'prescribing grants permit the upload route');
|
||||
}
|
||||
$assert(!$permissionAlias->invoke(new AuthMiddleware(), 'tcm.prescription/void', ['cf.prescription/lists']), 'read permission grants no void route');
|
||||
foreach (['cf.prescription/lists', 'cf.prescription/del', 'cf.prescription/audit', 'tcm.prescription/audit'] as $grant) {
|
||||
$assert(!$permissionAlias->invoke(new AuthMiddleware(), 'tcm.prescription/void', [$grant]), 'only the void button grant permits the void route: ' . $grant);
|
||||
}
|
||||
$assert(!$permissionAlias->invoke(new AuthMiddleware(), 'tcm.prescription/submitforreview', ['cf.prescription/lists']), 'read permission grants no upload route');
|
||||
$throws(fn () => PrescriptionLogic::submitForReview(41, 3, $readOnly), 'read-only accounts cannot upload prescriptions');
|
||||
$assert(!PrescriptionLogic::detail(2, 1, $doctor)['can_void'] && !PrescriptionLogic::detail(2, 4, $auditor)['can_void']
|
||||
&& !PrescriptionLogic::void(2, 1, $doctor) && !PrescriptionLogic::void(2, 4, $auditor)
|
||||
&& (int) Db::name('tcm_prescription')->where('id', 2)->value('void_status') === 0,
|
||||
'without the void button grant neither the creator nor an auditor can void');
|
||||
Db::name('system_menu')->insert(['id' => 5, 'perms' => PrescriptionLogic::VOID_PERMISSION]);
|
||||
Db::name('system_role_menu')->insertAll([['role_id' => 1, 'menu_id' => 5], ['role_id' => 3, 'menu_id' => 5]]);
|
||||
$assert(PrescriptionLogic::detail(2, 1, $doctor)['can_void'], 'creator can void signed prescription through detail');
|
||||
$appointmentPrescription = PrescriptionLogic::getByAppointment(40, 1, $doctor);
|
||||
$assert((int) $appointmentPrescription['id'] === 2 && $appointmentPrescription['can_void'] === true
|
||||
@@ -1025,7 +1036,7 @@ namespace {
|
||||
Db::name('system_menu')->insert(['id' => 4, 'perms' => 'cf.prescription/del']);
|
||||
Db::name('system_role_menu')->insert(['role_id' => 1, 'menu_id' => 4]);
|
||||
Db::name('system_role')->where('id', 1)->update(['data_scope' => 1]);
|
||||
$assert(!PrescriptionLogic::void(2, 2, $otherDoctor), 'a doctor with a delete grant still cannot void another doctor\'s prescription');
|
||||
$assert(!PrescriptionLogic::void(2, 2, $otherDoctor), 'a doctor with delete and void grants still cannot void another doctor\'s prescription');
|
||||
Db::name('system_role_menu')->where('menu_id', 4)->delete();
|
||||
Db::name('system_role')->where('id', 1)->update(['data_scope' => 4]);
|
||||
$assert(!PrescriptionLogic::void(2, 3, $readOnly), 'read-only account cannot void a prescription');
|
||||
|
||||
Reference in New Issue
Block a user