i更新
This commit is contained in:
@@ -7,6 +7,7 @@ namespace app\adminapi\controller\tcm;
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionValidate;
|
||||
use app\common\service\esign\PrescriptionEsignService;
|
||||
|
||||
/**
|
||||
* 中医处方单控制器
|
||||
@@ -32,7 +33,7 @@ class PrescriptionController extends BaseAdminController
|
||||
if ($id === null) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功', ['id' => $id]);
|
||||
return $this->success('保存成功', ['id' => $id, 'esign' => PrescriptionEsignService::status($id, (int) $this->adminId, $this->adminInfo)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +46,7 @@ class PrescriptionController extends BaseAdminController
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('编辑成功');
|
||||
return $this->success('编辑成功', ['id' => (int) $params['id'], 'esign' => PrescriptionEsignService::status((int) $params['id'], (int) $this->adminId, $this->adminInfo)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,4 +182,50 @@ class PrescriptionController extends BaseAdminController
|
||||
}
|
||||
return $this->success('作废成功');
|
||||
}
|
||||
|
||||
public function esignConfig()
|
||||
{
|
||||
return $this->data(PrescriptionEsignService::capability());
|
||||
}
|
||||
|
||||
public function esignStatus()
|
||||
{
|
||||
return $this->esignOperation('status', false);
|
||||
}
|
||||
|
||||
public function esignStart()
|
||||
{
|
||||
return $this->esignOperation('start', true);
|
||||
}
|
||||
|
||||
public function esignComplete()
|
||||
{
|
||||
return $this->esignOperation('complete', true);
|
||||
}
|
||||
|
||||
public function esignDownload()
|
||||
{
|
||||
return $this->esignOperation('download', false);
|
||||
}
|
||||
|
||||
private function esignOperation(string $operation, bool $post)
|
||||
{
|
||||
if ($post && !$this->request->isPost()) {
|
||||
return $this->fail('请使用 POST 请求');
|
||||
}
|
||||
$id = (int) ($post ? $this->request->post('id', 0) : $this->request->get('id', 0));
|
||||
if ($id <= 0) {
|
||||
return $this->fail('处方ID无效');
|
||||
}
|
||||
if ($operation === 'complete') {
|
||||
// A browser disconnect must not interrupt archival after signing.
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(300);
|
||||
}
|
||||
try {
|
||||
return $this->data(PrescriptionEsignService::{$operation}($id, (int) $this->adminId, $this->adminInfo));
|
||||
} catch (\Throwable $e) {
|
||||
return $this->fail($e instanceof \DomainException ? $e->getMessage() : '电子签署暂不可用,请联系管理员');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,24 @@ class AuthMiddleware
|
||||
// 当前访问路径
|
||||
$accessUri = strtolower($request->controller() . '/' . $request->action());
|
||||
|
||||
// Explicit gate: these new endpoints must not use unregistered-route bypass.
|
||||
if (str_starts_with($accessUri, 'tcm.prescription/esign')) {
|
||||
$action = substr($accessUri, strlen('tcm.prescription/'));
|
||||
if ($action === 'esignconfig') {
|
||||
return $next($request); // Only exposes enabled + environment, to logged-in users.
|
||||
}
|
||||
$uris = $this->formatUrl($adminAuthCache->getAdminUri() ?? []);
|
||||
$writes = ['tcm.prescription/add', 'tcm.prescription/edit', 'cf.prescription/add', 'cf.prescription/edit',
|
||||
'tcm.diagnosis/chufang', 'tcm.diagnosis/kaifang'];
|
||||
$reads = array_merge($writes, ['tcm.prescription/detail', 'tcm.prescription/lists', 'cf.prescription/lists',
|
||||
'cf.prescription/detail', 'cf.prescription/audit', 'tcm.prescription/audit',
|
||||
'tcm.prescriptionorder/lists', 'tcm.prescriptionorder/detail', 'tcm.prescriptionorder/auditprescription']);
|
||||
$grants = in_array($action, ['esignstart', 'esigncomplete'], true) ? $writes : $reads;
|
||||
return in_array($action, ['esignstart', 'esigncomplete', 'esignstatus', 'esigndownload'], true)
|
||||
&& array_intersect($grants, $uris) !== []
|
||||
? $next($request) : JsonService::fail('权限不足,无法访问电子签署');
|
||||
}
|
||||
|
||||
// 患者列表的部门筛选复用列表权限;只允许 GET 查询显式启用数据范围的部门树。
|
||||
// 必须与 DeptController::all 读取同一个 GET 参数,避免请求体参数意外放行全量部门。
|
||||
if ($accessUri === 'dept.dept/all'
|
||||
|
||||
@@ -296,6 +296,7 @@ class PrescriptionLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
|
||||
// 处理字段格式
|
||||
foreach ($lists as &$item) {
|
||||
$item['esign'] = \app\common\service\esign\PrescriptionEsignService::describe($item, (int) $this->adminId);
|
||||
// 设置默认值
|
||||
$item['usage_time'] = $item['usage_time'] ?? '饭前';
|
||||
$item['usage_way'] = $item['usage_way'] ?? '温水送服';
|
||||
|
||||
@@ -19,6 +19,8 @@ use think\facade\Log;
|
||||
use think\facade\Db;
|
||||
use app\common\service\prescriptionai\PrescriptionAiStore;
|
||||
use app\common\service\prescriptionai\PrescriptionAiRequest;
|
||||
use app\common\service\esign\PrescriptionEsignService;
|
||||
use app\common\service\esign\PrescriptionEsignPolicy;
|
||||
|
||||
class PrescriptionLogic
|
||||
{
|
||||
@@ -394,6 +396,10 @@ class PrescriptionLogic
|
||||
'assistant_id' => $assistantIdForRx,
|
||||
];
|
||||
|
||||
if (PrescriptionEsignService::enabled()) {
|
||||
$data['esign_required'] = 1;
|
||||
$data['esign_status'] = 'pending';
|
||||
}
|
||||
try {
|
||||
return Db::transaction(static function () use ($data, $params, $adminId, $adminInfo, $diagnosisIdRule, $dateYmd): int {
|
||||
$replayed = PrescriptionAiRequest::replay($params, $adminId, true);
|
||||
@@ -457,6 +463,7 @@ class PrescriptionLogic
|
||||
}
|
||||
|
||||
// 已通过且未作废:不可编辑
|
||||
PrescriptionEsignPolicy::assertMutable($prescription->toArray());
|
||||
if ((int) ($prescription->audit_status ?? 1) === 1 && (int) ($prescription->void_status ?? 0) === 0) {
|
||||
self::setError('该处方已通过审核,不可编辑');
|
||||
return false;
|
||||
@@ -555,7 +562,7 @@ class PrescriptionLogic
|
||||
'usage_way' => $params['usage_way'] ?? $prescription->usage_way,
|
||||
'dietary_taboo' => is_array($params['dietary_taboo'] ?? null) ? implode(',', $params['dietary_taboo']) : ($params['dietary_taboo'] ?? $prescription->dietary_taboo),
|
||||
'usage_notes' => $params['usage_notes'] ?? $prescription->usage_notes,
|
||||
'doctor_name' => $params['doctor_name'] ?? $prescription->doctor_name,
|
||||
'doctor_name' => (string) $prescription->doctor_name,
|
||||
'doctor_signature' => $params['doctor_signature'] ?? $prescription->doctor_signature,
|
||||
'is_shared' => (int)($params['is_shared'] ?? $prescription->is_shared),
|
||||
'visible_role_ids' => array_key_exists('visible_role_ids', $params)
|
||||
@@ -571,6 +578,10 @@ class PrescriptionLogic
|
||||
'audit_remark' => '',
|
||||
];
|
||||
|
||||
if (PrescriptionEsignService::enabled()) {
|
||||
$data['esign_required'] = 1;
|
||||
$data['esign_status'] = 'pending';
|
||||
}
|
||||
if ($wasVoid) {
|
||||
$data['void_status'] = 0;
|
||||
$data['void_time'] = null;
|
||||
@@ -631,7 +642,7 @@ class PrescriptionLogic
|
||||
private static function patchPatientContactLocked(int $rxId, string $patientName, string $phone, int $gender, int $adminId, array $adminInfo): bool
|
||||
{
|
||||
self::$error = '';
|
||||
$prescription = Prescription::find($rxId);
|
||||
$prescription = Prescription::where('id', $rxId)->lock(true)->find();
|
||||
if (!$prescription) {
|
||||
self::setError('处方不存在');
|
||||
|
||||
@@ -648,6 +659,7 @@ class PrescriptionLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
PrescriptionEsignPolicy::assertMutable($prescription->toArray());
|
||||
$patientName = trim($patientName);
|
||||
$phone = trim($phone);
|
||||
if ($patientName === '') {
|
||||
@@ -767,6 +779,7 @@ class PrescriptionLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
PrescriptionEsignPolicy::assertMutable($prescription->toArray());
|
||||
$prescription->delete();
|
||||
PrescriptionAiStore::invalidate($id, 'deleted');
|
||||
return true;
|
||||
@@ -792,6 +805,7 @@ class PrescriptionLogic
|
||||
return null;
|
||||
}
|
||||
$arr = $row->toArray();
|
||||
$arr['esign'] = PrescriptionEsignService::describe($arr, $viewerAdminId);
|
||||
$arr['gender_desc'] = $arr['gender'] == 1 ? '男' : '女';
|
||||
$arr['visible_role_ids'] = self::visibleRoleIdsToArray($arr['visible_role_ids'] ?? '');
|
||||
|
||||
@@ -848,31 +862,24 @@ class PrescriptionLogic
|
||||
if ($prescriptionId <= 0) {
|
||||
return;
|
||||
}
|
||||
$row = Prescription::find($prescriptionId);
|
||||
if (!$row) {
|
||||
return;
|
||||
}
|
||||
if ((int) ($row->void_status ?? 0) === 1) {
|
||||
return;
|
||||
}
|
||||
if ((int) ($row->audit_status ?? 1) !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$lastAuditWecomNotify = null;
|
||||
$name = (string) ($adminInfo['name'] ?? '');
|
||||
$now = time();
|
||||
$finalRemark = trim($remark) !== '' ? trim($remark) : '业务订单处方审核通过';
|
||||
$finalRemark = mb_substr($finalRemark, 0, 500);
|
||||
|
||||
$row->audit_status = 1;
|
||||
$row->audit_time = $now;
|
||||
$row->audit_by = $adminId;
|
||||
$row->audit_by_name = $name;
|
||||
$row->audit_remark = $finalRemark;
|
||||
|
||||
try {
|
||||
if ($row->save()) {
|
||||
$row = Db::transaction(static function () use ($prescriptionId, $adminId, $adminInfo, $finalRemark): ?Prescription {
|
||||
$row = Prescription::where('id', $prescriptionId)->lock(true)->find();
|
||||
if (!$row || (int) ($row->void_status ?? 0) === 1 || (int) ($row->audit_status ?? 1) !== 0) {
|
||||
return null;
|
||||
}
|
||||
PrescriptionEsignService::assertSignedById($prescriptionId);
|
||||
$row->audit_status = 1;
|
||||
$row->audit_time = time();
|
||||
$row->audit_by = $adminId;
|
||||
$row->audit_by_name = (string) ($adminInfo['name'] ?? '');
|
||||
$row->audit_remark = $finalRemark;
|
||||
return $row->save() ? $row : null;
|
||||
});
|
||||
if ($row) {
|
||||
self::$lastAuditWecomNotify = self::notifyCreatorAuditResult($row, 'approve', $finalRemark, $adminInfo);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
@@ -905,7 +912,29 @@ class PrescriptionLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = Prescription::find($id);
|
||||
try {
|
||||
// Keep the signature check and audit write under the same row lock.
|
||||
// Reject also shares pharmacy claim locks with void/edit operations.
|
||||
$mutate = static fn () => self::auditLocked($id, $action, $remark, $adminId, $adminInfo);
|
||||
$row = $action === 'reject'
|
||||
? LockedPharmacySnapshotMutation::executeForPrescription($id, $mutate)
|
||||
: Db::transaction($mutate);
|
||||
} catch (\Throwable $exception) {
|
||||
if (self::getError() === '') {
|
||||
self::setError($exception->getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!$row) {
|
||||
return false;
|
||||
}
|
||||
self::$lastAuditWecomNotify = self::notifyCreatorAuditResult($row, $action, $remark, $adminInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function auditLocked(int $id, string $action, string $remark, int $adminId, array $adminInfo): Prescription|false
|
||||
{
|
||||
$row = Prescription::where('id', $id)->lock(true)->find();
|
||||
if (!$row) {
|
||||
self::setError('处方不存在');
|
||||
|
||||
@@ -918,7 +947,7 @@ class PrescriptionLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((int) ($row->audit_status ?? 1) !== 0) {
|
||||
if ((int) ($row->audit_status ?? 1) !== 0 || !empty($row->void_status)) {
|
||||
self::setError('当前状态不可审核');
|
||||
|
||||
return false;
|
||||
@@ -928,18 +957,19 @@ class PrescriptionLogic
|
||||
$now = time();
|
||||
|
||||
if ($action === 'approve') {
|
||||
try {
|
||||
PrescriptionEsignService::assertSignedById($id);
|
||||
} catch (\DomainException $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
$row->audit_status = 1;
|
||||
$row->audit_time = $now;
|
||||
$row->audit_by = $adminId;
|
||||
$row->audit_by_name = $name;
|
||||
$row->audit_remark = $remark;
|
||||
|
||||
$ok = (bool) $row->save();
|
||||
if ($ok) {
|
||||
self::$lastAuditWecomNotify = self::notifyCreatorAuditResult($row, 'approve', $remark, $adminInfo);
|
||||
}
|
||||
|
||||
return $ok;
|
||||
return $row->save() ? $row : false;
|
||||
}
|
||||
|
||||
if ($action === 'reject') {
|
||||
@@ -958,19 +988,11 @@ class PrescriptionLogic
|
||||
$row->void_by = $adminId;
|
||||
$row->void_by_name = $name;
|
||||
|
||||
$ok = Db::transaction(static function () use ($row, $id): bool {
|
||||
Prescription::where('id', $id)->lock(true)->find();
|
||||
$saved = (bool) $row->save();
|
||||
if ($saved) {
|
||||
PrescriptionAiStore::invalidate($id, 'voided');
|
||||
}
|
||||
return $saved;
|
||||
});
|
||||
$ok = (bool) $row->save();
|
||||
if ($ok) {
|
||||
self::$lastAuditWecomNotify = self::notifyCreatorAuditResult($row, 'reject', $remark, $adminInfo);
|
||||
PrescriptionAiStore::invalidate($id, 'voided');
|
||||
}
|
||||
|
||||
return $ok;
|
||||
return $ok ? $row : false;
|
||||
}
|
||||
|
||||
self::setError('无效的审核操作');
|
||||
@@ -1067,10 +1089,14 @@ class PrescriptionLogic
|
||||
*/
|
||||
private static function filterViewablePrescriptions(array $rows, int $viewerAdminId, array $viewerAdminInfo): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
$visible = array_values(array_filter(
|
||||
$rows,
|
||||
static fn (array $row): bool => self::canViewPrescription($row, $viewerAdminId, $viewerAdminInfo)
|
||||
));
|
||||
return array_map(static function (array $row) use ($viewerAdminId): array {
|
||||
$row['esign'] = PrescriptionEsignService::describe($row, $viewerAdminId);
|
||||
return $row;
|
||||
}, $visible);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1107,7 +1133,9 @@ class PrescriptionLogic
|
||||
return null;
|
||||
}
|
||||
|
||||
return $row->toArray();
|
||||
$result = $row->toArray();
|
||||
$result['esign'] = PrescriptionEsignService::describe($result, $viewerAdminId);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1234,6 +1262,10 @@ class PrescriptionLogic
|
||||
'assistant_id' => $assistantIdForRx,
|
||||
];
|
||||
|
||||
if (PrescriptionEsignService::enabled()) {
|
||||
$data['esign_required'] = 1;
|
||||
$data['esign_status'] = 'pending';
|
||||
}
|
||||
$prescription = new Prescription();
|
||||
$prescription->save($data);
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ use app\common\service\pharmacy\PharmacySubmissionClaimWorkflow;
|
||||
use app\common\service\pharmacy\PharmacySupplyMode;
|
||||
use app\common\service\tcm\RevisitDueHook;
|
||||
use think\db\Query;
|
||||
use app\common\service\esign\PrescriptionEsignService;
|
||||
use app\common\service\esign\PrescriptionEsignPolicy;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
@@ -58,6 +60,17 @@ class PrescriptionOrderLogic
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
private static function assertEsignApproved(PrescriptionOrder $order, bool $forDispensing = false): bool
|
||||
{
|
||||
try {
|
||||
PrescriptionEsignService::assertSignedById((int) $order->prescription_id, $forDispensing);
|
||||
return true;
|
||||
} catch (\DomainException $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function assertTrackingAuditApproved(PrescriptionOrder $order): bool
|
||||
{
|
||||
if ((int) $order->prescription_audit_status !== 1 || (int) $order->payment_slip_audit_status !== 1) {
|
||||
@@ -66,7 +79,7 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return self::assertEsignApproved($order, true);
|
||||
}
|
||||
|
||||
private static function assertRemoteSnapshotMutable(PrescriptionOrder $order): bool
|
||||
@@ -1429,12 +1442,13 @@ class PrescriptionOrderLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
$rx = Prescription::where('id', $rxId)->whereNull('delete_time')->find();
|
||||
$rx = Prescription::where('id', $rxId)->whereNull('delete_time')->lock(true)->find();
|
||||
if (!$rx) {
|
||||
self::setError('处方不存在');
|
||||
|
||||
return false;
|
||||
}
|
||||
PrescriptionEsignPolicy::assertMutable($rx->toArray());
|
||||
if (!PrescriptionLogic::canViewPrescription($rx, $adminId, $adminInfo)) {
|
||||
self::setError('无权限修改此处方');
|
||||
|
||||
@@ -2352,7 +2366,32 @@ class PrescriptionOrderLogic
|
||||
public static function auditPrescription(int $id, string $action, string $remark, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
$order = PrescriptionOrder::where('id', $id)->whereNull('delete_time')->find();
|
||||
try {
|
||||
$out = Db::transaction(static function () use ($id, $action, $remark, $adminId, $adminInfo) {
|
||||
$result = self::auditPrescriptionLocked($id, $action, $remark, $adminId, $adminInfo);
|
||||
if ($result === false) {
|
||||
throw new \DomainException(self::$error ?: '审核未完成');
|
||||
}
|
||||
return $result;
|
||||
});
|
||||
} catch (\Throwable $exception) {
|
||||
self::$error = $exception->getMessage();
|
||||
return false;
|
||||
}
|
||||
if ($out !== false && $action === 'approve') {
|
||||
// Notify only after the audit transaction releases its locks.
|
||||
PrescriptionLogic::syncApproveConsumerPrescriptionIfPending(
|
||||
(int) $out['prescription_id'], $adminId, $adminInfo,
|
||||
trim($remark) !== '' ? trim($remark) : '业务订单处方审核通过'
|
||||
);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
private static function auditPrescriptionLocked(int $id, string $action, string $remark, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
$order = PrescriptionOrder::where('id', $id)->whereNull('delete_time')->lock(true)->find();
|
||||
if (!$order) {
|
||||
self::$error = '订单不存在';
|
||||
|
||||
@@ -2375,9 +2414,17 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($action, ['approve', 'reject'], true)) {
|
||||
self::$error = '无效的审核操作';
|
||||
return false;
|
||||
}
|
||||
if ($action === 'reject' && trim($remark) === '') {
|
||||
self::$error = '驳回时请填写审核意见';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($action === 'approve' && !self::assertEsignApproved($order)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2403,16 +2450,6 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($action === 'approve') {
|
||||
$syncRemark = trim($remark) !== '' ? trim($remark) : '业务订单处方审核通过';
|
||||
PrescriptionLogic::syncApproveConsumerPrescriptionIfPending(
|
||||
(int) $order->prescription_id,
|
||||
$adminId,
|
||||
$adminInfo,
|
||||
$syncRemark
|
||||
);
|
||||
}
|
||||
|
||||
$actionName = $action === 'approve' ? 'audit_rx_approve' : 'audit_rx_reject';
|
||||
$summary = $action === 'approve' ? '处方审核通过' . ($remark ? ',意见:' . $remark : '') : '处方审核驳回,意见:' . $remark;
|
||||
self::writeLog((int) $order->id, $adminId, $adminInfo, $actionName, $summary);
|
||||
@@ -2776,6 +2813,23 @@ class PrescriptionOrderLogic
|
||||
public static function addLog(array $params, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
try {
|
||||
return Db::transaction(static function () use ($params, $adminId, $adminInfo) {
|
||||
$result = self::addLogLocked($params, $adminId, $adminInfo);
|
||||
if ($result === false) {
|
||||
throw new \DomainException(self::$error ?: '日志变更未完成');
|
||||
}
|
||||
return $result;
|
||||
});
|
||||
} catch (\Throwable $exception) {
|
||||
self::$error = $exception->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function addLogLocked(array $params, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
$id = (int) ($params['id'] ?? 0);
|
||||
$summary = mb_substr(trim((string) ($params['summary'] ?? '')), 0, 500);
|
||||
if ($summary === '') {
|
||||
@@ -2784,7 +2838,7 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
$order = PrescriptionOrder::where('id', $id)->whereNull('delete_time')->find();
|
||||
$order = PrescriptionOrder::where('id', $id)->whereNull('delete_time')->lock(true)->find();
|
||||
if (!$order) {
|
||||
self::$error = '订单不存在';
|
||||
|
||||
@@ -2814,6 +2868,9 @@ class PrescriptionOrderLogic
|
||||
if (!in_array($newRx, [0, 1, 2], true)) {
|
||||
self::$error = '处方审核状态无效';
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($newRx === 1 && !self::assertEsignApproved($order)) {
|
||||
return false;
|
||||
}
|
||||
$oldRx = (int) $order->prescription_audit_status;
|
||||
@@ -4947,6 +5004,9 @@ class PrescriptionOrderLogic
|
||||
self::$error = '无权限操作';
|
||||
return false;
|
||||
}
|
||||
if (!self::assertEsignApproved($order, true)) {
|
||||
return false;
|
||||
}
|
||||
$target = self::normalizeShipMode((string) ($order->ship_mode ?? 'gancao')) === 'direct'
|
||||
? 'direct'
|
||||
: 'gancao';
|
||||
@@ -5083,6 +5143,9 @@ class PrescriptionOrderLogic
|
||||
/** @return array<string,mixed>|false */
|
||||
private static function uploadEjRemote(PrescriptionOrder $order, int $adminId, array $adminInfo, array $claim)
|
||||
{
|
||||
if (!self::assertEsignApproved($order, true)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$prescription = PrescriptionLogic::detail((int) $order->prescription_id, $adminId, $adminInfo);
|
||||
if ($prescription === null) {
|
||||
@@ -5203,6 +5266,9 @@ class PrescriptionOrderLogic
|
||||
if (!self::canAccessOrder($order, $adminId, $adminInfo)) {
|
||||
self::$error = '无权限操作';
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!self::assertEsignApproved($order, true)) {
|
||||
return false;
|
||||
}
|
||||
$item = $order->toArray();
|
||||
@@ -5817,6 +5883,7 @@ class PrescriptionOrderLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
PrescriptionEsignPolicy::assertMutable($rx->toArray());
|
||||
if (!PrescriptionLogic::canViewPrescription($rx, $adminId, $adminInfo)) {
|
||||
self::setError('无权限修改此处方');
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ class PrescriptionValidate extends BaseValidate
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
if (\app\common\service\esign\PrescriptionEsignService::enabled()) {
|
||||
$this->remove('doctor_signature', 'require');
|
||||
}
|
||||
return $this->only([
|
||||
'prescription_type', 'dosage_amount', 'dosage_unit', 'dosage_bag_count', 'need_decoction', 'bags_per_dose',
|
||||
'prescription_name', 'patient_id', 'patient_name', 'phone', 'gender', 'age',
|
||||
@@ -54,6 +57,9 @@ class PrescriptionValidate extends BaseValidate
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
if (\app\common\service\esign\PrescriptionEsignService::enabled()) {
|
||||
$this->remove('doctor_signature', 'require');
|
||||
}
|
||||
return $this->only([
|
||||
'id', 'prescription_type', 'dosage_amount', 'dosage_unit', 'dosage_bag_count', 'need_decoction', 'bags_per_dose',
|
||||
'prescription_name', 'patient_id', 'patient_name', 'phone', 'gender', 'age',
|
||||
|
||||
Reference in New Issue
Block a user