igengx
This commit is contained in:
@@ -8,6 +8,7 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionValidate;
|
||||
use app\common\service\esign\DoctorEsignIdentityService;
|
||||
use app\common\service\esign\PrescriptionCaSigningSettings;
|
||||
use app\common\service\esign\PrescriptionEsignService;
|
||||
use app\common\service\esign\PrescriptionReviewEsignService;
|
||||
|
||||
@@ -102,6 +103,27 @@ class PrescriptionController extends BaseAdminController
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 上传处方送审
|
||||
*/
|
||||
public function submitForReview()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->fail('请使用 POST 上传处方');
|
||||
}
|
||||
$rawId = $this->request->post('id');
|
||||
$id = (is_int($rawId) || is_string($rawId))
|
||||
? filter_var($rawId, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]) : false;
|
||||
if ($id === false) {
|
||||
return $this->fail('处方ID无效');
|
||||
}
|
||||
try {
|
||||
return $this->data(PrescriptionLogic::submitForReview($id, (int) $this->adminId, $this->adminInfo));
|
||||
} catch (\Throwable $error) {
|
||||
return $this->fail($error instanceof \DomainException ? $error->getMessage() : '处方上传失败,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核处方(通过 / 驳回,驳回即作废)
|
||||
*/
|
||||
@@ -121,13 +143,8 @@ class PrescriptionController extends BaseAdminController
|
||||
|
||||
$msg = $params['action'] === 'reject' ? '已驳回并作废处方' : '审核通过';
|
||||
$wecom = PrescriptionLogic::consumeLastAuditWecomNotify();
|
||||
$data = [];
|
||||
if (is_array($wecom)) {
|
||||
$data['wecom_notify_ok'] = !empty($wecom['ok']);
|
||||
if (empty($wecom['ok']) && !empty($wecom['message'])) {
|
||||
$data['wecom_notify_hint'] = (string) $wecom['message'];
|
||||
}
|
||||
}
|
||||
// The audit is already committed. The notification diagnostic belongs in server logs.
|
||||
$data = $wecom === null ? [] : ['wecom_notify_ok' => !empty($wecom['ok'])];
|
||||
|
||||
return $this->success($msg, $data);
|
||||
}
|
||||
@@ -180,7 +197,11 @@ class PrescriptionController extends BaseAdminController
|
||||
if ($id <= 0) {
|
||||
return $this->fail('处方ID不能为空');
|
||||
}
|
||||
$ok = PrescriptionLogic::void($id, $this->adminId, $this->adminInfo);
|
||||
$pendingOnly = $this->request->post('pending_only', false, null);
|
||||
if (!is_bool($pendingOnly)) {
|
||||
return $this->fail('作废参数无效');
|
||||
}
|
||||
$ok = PrescriptionLogic::void($id, $this->adminId, $this->adminInfo, $pendingOnly);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
@@ -191,6 +212,29 @@ class PrescriptionController extends BaseAdminController
|
||||
{
|
||||
return $this->data(PrescriptionEsignService::capability());
|
||||
}
|
||||
|
||||
/** @notes 修改处方 CA 签名设置 */
|
||||
public function esignSetConfig()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
return $this->fail('请使用 POST 修改 CA 签名设置');
|
||||
}
|
||||
if ((int) ($this->adminInfo['root'] ?? 0) !== 1) {
|
||||
return $this->fail('仅超级管理员可以修改 CA 签名设置');
|
||||
}
|
||||
$enabled = $this->request->post('enabled', null, null);
|
||||
if (!is_bool($enabled)) {
|
||||
return $this->fail('CA 签名开关必须为布尔值');
|
||||
}
|
||||
try {
|
||||
PrescriptionCaSigningSettings::setEnabled($enabled, $this->adminId);
|
||||
return $this->data(PrescriptionEsignService::capability());
|
||||
} catch (\DomainException $error) {
|
||||
return $this->fail($error->getMessage());
|
||||
} catch (\Throwable) {
|
||||
return $this->fail('CA 签名设置暂时无法保存,请稍后重试');
|
||||
}
|
||||
}
|
||||
|
||||
public function esignStatus()
|
||||
{
|
||||
@@ -238,11 +282,11 @@ class PrescriptionController extends BaseAdminController
|
||||
if ($confirm ? !$this->request->isPost() : !$this->request->isGet()) {
|
||||
return $this->fail($confirm ? '请使用 POST 请求' : '请使用 GET 请求');
|
||||
}
|
||||
$params = $confirm ? $this->request->post() : $this->request->get();
|
||||
$params = $confirm ? $this->request->post(false) : $this->request->get();
|
||||
$id = (int) ($params['id'] ?? 0);
|
||||
$orderId = (int) ($params['order_id'] ?? 0);
|
||||
$actor = (int) $this->adminId;
|
||||
$verifyOnly = $params['verify_only'] ?? false;
|
||||
$verifyOnly = array_key_exists('verify_only', $params) ? $params['verify_only'] : false;
|
||||
if ($id <= 0 || $orderId < 0 || !is_bool($verifyOnly)) {
|
||||
return $this->fail('审核签署参数无效');
|
||||
}
|
||||
@@ -300,9 +344,16 @@ class PrescriptionController extends BaseAdminController
|
||||
}
|
||||
if ($operation === 'complete') {
|
||||
ignore_user_abort(true);
|
||||
$data = DoctorEsignIdentityService::complete((int) $this->adminId, $input);
|
||||
} else {
|
||||
$body = $this->request->post(false);
|
||||
$signerName = $body['signer_name'] ?? null;
|
||||
if (array_key_exists('signer_name', $body) && (!is_string($signerName) || strlen($signerName) > 200)) {
|
||||
return $this->fail('证件姓名格式无效');
|
||||
}
|
||||
$data = DoctorEsignIdentityService::start((int) $this->adminId, $input, $signerName);
|
||||
}
|
||||
return $this->data(DoctorEsignIdentityService::{$operation}((int) $this->adminId, $input))
|
||||
->header(['Cache-Control' => 'private, no-store']);
|
||||
return $this->data($data)->header(['Cache-Control' => 'private, no-store']);
|
||||
} catch (\Throwable $error) {
|
||||
return $this->fail($error instanceof \DomainException ? $error->getMessage() : '医师认证暂不可用,请稍后重试');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user