From ed4e8cd7dfc807cd4fece8fe0ff70fe112921e94 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 21 Apr 2023 17:00:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=85=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...oPharmacistCaVerifyDelayDirectConsumer.php | 67 ++++++++++++++----- app/Model/OrderInquiryCase.php | 1 + app/Services/MessagePush.php | 4 +- app/Services/OrderPrescriptionService.php | 2 +- app/Services/UserDoctorService.php | 2 +- 5 files changed, 56 insertions(+), 20 deletions(-) diff --git a/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php b/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php index 506b712..dc975f5 100644 --- a/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php +++ b/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php @@ -120,33 +120,36 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage $params['order_prescription_id'] = $order_prescription['order_prescription_id']; $order_prescription_product = OrderPrescriptionProduct::getList($params); if (!empty($order_prescription_product)){ - $product_name = array_column($order_prescription_product->toArray(),'product_name'); - if (count($product_name) > 1){ - $product_name = implode('、',$product_name); + $product_name_array = array_column($order_prescription_product->toArray(),'product_name'); + if (count($product_name_array) > 1){ + $product_name = implode('、',$product_name_array); }else{ - $product_name = $product_name[0]; + $product_name = $product_name_array[0]; } } - // 订单-处方 - $OrderPrescriptionService = new OrderPrescriptionService(); - // 下载医生签章文件 Db::beginTransaction(); try { + Log::getInstance("queue-AutoPharmacistCaVerify")->info("检测执行次数"); + // 检测执行次数 $res = $this->checkHandleNumber($data['prescription_file_id']); if (!$res) { - // 超出最大执行次数或检测错误 - // 自动驳回 - $OrderPrescriptionService->rejectPrescription( - $data['order_prescription_id'], - $user_doctor['user_id'], - $user_patient['user_id'], - $order_prescription['order_inquiry_id'], - "请联系平台客服,请勿重开处方" - ); + Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:超出最大执行次数或检测错误"); + // 修改处方表为未通过 + $this->modifyOrderPrescription($data['prescription_file_id'],2,"请联系平台客服,请勿重开处方"); + + // 医生-开具的处方审核未通过 + $MessagePush = new MessagePush($user_doctor['user_id'], $order_prescription['order_inquiry_id']); + $MessagePush->prescriptionVerifyFail($data['order_prescription_id']); + + // 患者-处方审核未通过 + $MessagePush = new MessagePush($user_patient['user_id'], $order_prescription['order_inquiry_id']); + $MessagePush->patientPrescriptionVerifyFail(); + + Db::commit(); return Result::ACK; } @@ -169,6 +172,8 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage return Result::REQUEUE; } + Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医生的签章pdf并上传至oss"); + // 下载医生的签章pdf并上传至oss $prescription_pdf_oss_path = $this->downCaPdfToOss($order_prescription, $user_doctor['user_id'],2,$order_prescription_file['doctor_ca_file_id']); if (!$prescription_pdf_oss_path) { @@ -197,6 +202,9 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage // 修改处方文件表,添加prescription_pdf_oss_path字段 $this->modifyOrderPrescriptionFile($data['prescription_file_id'],$prescription_pdf_oss_path,$prescription_open_result['file_id']); + // 修改处方表为通过 + $this->modifyOrderPrescription($data['prescription_file_id'],1); + Db::commit(); Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功"); } catch (\Exception $e) { @@ -413,4 +421,31 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage } } + /** + * 修改处方表 + * @param string $order_prescription_id 处方id + * @param int $status 审核状态 1:成功 2:驳回 + * @param string $pharmacist_fail_reason 驳回理由 + * @return void + */ + protected function modifyOrderPrescription(string $order_prescription_id,int $status,string $pharmacist_fail_reason = ""): void + { + // 修改处方审核状态 + $data = array(); + if ($status == 1){ + // 审核成功 + $data['prescription_status'] = 2; + $data['pharmacist_audit_status'] = 1; + $data['platform_audit_status'] = 1; + }else{ + $data['pharmacist_audit_status'] = 2; + $data['pharmacist_fail_reason'] = $pharmacist_fail_reason; + } + $data['pharmacist_verify_time'] = date('Y-m-d H:i:s',time()); + + $params = array(); + $params['order_prescription_id'] = $order_prescription_id; + + OrderPrescription::edit($params,$data); + } } diff --git a/app/Model/OrderInquiryCase.php b/app/Model/OrderInquiryCase.php index 16acf37..2b9631d 100644 --- a/app/Model/OrderInquiryCase.php +++ b/app/Model/OrderInquiryCase.php @@ -106,6 +106,7 @@ class OrderInquiryCase extends Model $query->where($order_inquiry_params); }) ->where($params) + ->orderBy('finish_time','desc') ->first($fields); } diff --git a/app/Services/MessagePush.php b/app/Services/MessagePush.php index 4cda40e..cc546e4 100644 --- a/app/Services/MessagePush.php +++ b/app/Services/MessagePush.php @@ -1260,7 +1260,7 @@ class MessagePush extends BaseService // 短信 $sms_data = array(); $sms_data['template_code'] = "SMS_272120097"; - $sms_data['scene_desc'] = "医生开具的处方审核通过"; + $sms_data['scene_desc'] = "您为${$this->order_inquiry['patient_name']}患者开具的电子处方药师已审核通过,尽快和患者完成交流并提醒患者购药。请前往微信小程序“问诊消息”进行操作。"; $sms_data['phone'] = $this->user['mobile']; $sms_data['user_id'] = $this->user['user_id']; @@ -1319,7 +1319,7 @@ class MessagePush extends BaseService // 短信 $sms_data = array(); $sms_data['template_code'] = "SMS_271905264"; - $sms_data['scene_desc'] = "医生开具的处方审核未通过"; + $sms_data['scene_desc'] = "您为${$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。模版code:SMS_271905264"; $sms_data['phone'] = $this->user['mobile']; $sms_data['user_id'] = $this->user['user_id']; diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index 2b7e0af..05a9a53 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -480,7 +480,7 @@ class OrderPrescriptionService extends BaseService } /** - * 药师驳回处方 + * 驳回处方-修改处方表 * @param string $order_prescription_id 处方id * @param string $doctor_user_id 医生user_id * @param string $patient_user_id 患者user_id diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index a8f290a..a0b0bbb 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -1418,7 +1418,7 @@ class UserDoctorService extends BaseService if ($system_config['is_auto_phar_verify_prescription'] == 1){ // 添加药师自动签章审核队列 $data = array(); - $data['prescription_file_id'] = $prescription_open_result['file_id']; + $data['prescription_file_id'] = (string)$order_prescription_file->prescription_file_id; $data['order_prescription_id'] = (string)$order_prescription->order_prescription_id; $message = new AutoPharmacistCaVerifyDelayDirectProducer($data);