修改开具处方问题

This commit is contained in:
2023-09-08 17:49:22 +08:00
parent 47d36afcb6
commit 4afcbaacf0
4 changed files with 171 additions and 186 deletions
@@ -134,7 +134,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
// 检测执行次数
$res = $this->checkHandleNumber($data['prescription_file_id']);
}catch (\Exception $e){
}catch (\Throwable $e){
// 检测次数失败
Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage());
return Result::ACK;
@@ -158,14 +158,13 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
Db::commit();
return Result::ACK;
}catch (\Exception $e){
}catch (\Throwable $e){
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage());
return Result::ACK;
}
}
// 下载医生签章文件
Db::beginTransaction();
try {
@@ -199,30 +198,51 @@ 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) {
Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医生的签章pdf并上传至oss");
$CaService = new CaService($order_prescription,2,$user_doctor['user_id']);
$prescription_pdf_oss_path = $CaService->downCaPdfToOss($order_prescription_file['doctor_ca_file_id']);
if ($prescription_pdf_oss_path == "") {
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path);
return Result::REQUEUE;
}
// 药师/医院签章
Log::getInstance("queue-AutoPharmacistCaVerify")->info("药师/医院签章");
// 药师签章
Log::getInstance("queue-AutoPharmacistCaVerify")->info("药师签章");
$OrderPrescriptionService = new OrderPrescriptionService();
$prescription_open_result = $OrderPrescriptionService->openPrescription($data['order_prescription_id'],$user_pharmacist['user_id']);
$prescription_open_result = $OrderPrescriptionService->openPrescription($data['order_prescription_id'],3,$user_pharmacist['user_id']);
if (empty($prescription_open_result['file_id'])){
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:处方开具失败");
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:药师签章失败");
return Result::REQUEUE;
}
// 下载医院的签章pdf并上传至oss
// 下载药师签章pdf并上传至oss
Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载药师的签章pdf并上传至oss");
$CaService = new CaService($order_prescription,3,$user_pharmacist['user_id']);
$prescription_pdf_oss_path = $CaService->downCaPdfToOss($prescription_open_result['file_id']);
if ($prescription_pdf_oss_path == "") {
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path);
return Result::REQUEUE;
}
// 医院签章
Log::getInstance("queue-AutoPharmacistCaVerify")->info("医院签章");
$OrderPrescriptionService = new OrderPrescriptionService();
$prescription_open_result = $OrderPrescriptionService->openPrescription($data['order_prescription_id'],1);
if (empty($prescription_open_result['file_id'])){
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:医院签章失败");
return Result::REQUEUE;
}
// 下载医院签章pdf并上传至oss
Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医院的签章pdf并上传至oss");
$prescription_pdf_oss_path = $this->downCaPdfToOss($order_prescription, $user_pharmacist['user_id'],3,$prescription_open_result['file_id']);
if (!$prescription_pdf_oss_path) {
$CaService = new CaService($order_prescription,1);
$prescription_pdf_oss_path = $CaService->downCaPdfToOss($prescription_open_result['file_id']);
if ($prescription_pdf_oss_path == "") {
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path);
return Result::REQUEUE;
@@ -244,7 +264,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
Db::commit();
Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功");
} catch (\Exception $e) {
} catch (\Throwable $e) {
Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("异常错误:" . $e->getMessage());
@@ -279,7 +299,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
Log::getInstance("queue-AutoPharmacistCaVerify")->error("添加处方过期队列失败!");
return Result::ACK;
}
}catch(\Exception $e){
}catch(\Throwable $e){
Log::getInstance("queue-AutoPharmacistCaVerify")->error("发送消息异常错误:" . $e->getMessage());
return Result::ACK;
}
@@ -405,34 +425,6 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
return true;
}
/**
* 下载签章pdf并上传至oss
* @param array|object $order_prescription
* @param string $user_id 用户id
* @param string|int $user_type 用户类型 1:患者 2:医生 3:药师
* @param string $file_id
* @return string|bool oss地址|false(存在异常时)
*/
protected function downCaPdfToOss(array|object $order_prescription, string $user_id, string|int $user_type, string $file_id): string|bool
{
try {
$user = array();
$user['user_id'] = $user_id;
$user['user_type'] = $user_type;
$CaService = new CaService($order_prescription, $user);
// 下载签章pdf并上传至oss
if ($user_type == 2){
return $CaService->downCaPdfToOss($file_id,1);
}else{
return $CaService->downCaPdfToOss($file_id,2);
}
} catch (\Exception $e) {
return false;
}
}
/**
* 修改处方文件表
* @param string $prescription_file_id 主键id