修改开具处方问题

This commit is contained in:
wucongxing 2023-09-08 17:49:22 +08:00
parent 47d36afcb6
commit 4afcbaacf0
4 changed files with 171 additions and 186 deletions

View File

@ -134,7 +134,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
// 检测执行次数 // 检测执行次数
$res = $this->checkHandleNumber($data['prescription_file_id']); $res = $this->checkHandleNumber($data['prescription_file_id']);
}catch (\Exception $e){ }catch (\Throwable $e){
// 检测次数失败 // 检测次数失败
Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage()); Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage());
return Result::ACK; return Result::ACK;
@ -158,14 +158,13 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
Db::commit(); Db::commit();
return Result::ACK; return Result::ACK;
}catch (\Exception $e){ }catch (\Throwable $e){
Db::rollBack(); Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage()); Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage());
return Result::ACK; return Result::ACK;
} }
} }
// 下载医生签章文件 // 下载医生签章文件
Db::beginTransaction(); Db::beginTransaction();
try { try {
@ -199,30 +198,51 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
return Result::REQUEUE; return Result::REQUEUE;
} }
Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医生的签章pdf并上传至oss");
// 下载医生的签章pdf并上传至oss // 下载医生的签章pdf并上传至oss
$prescription_pdf_oss_path = $this->downCaPdfToOss($order_prescription, $user_doctor['user_id'],2,$order_prescription_file['doctor_ca_file_id']); Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医生的签章pdf并上传至oss");
if (!$prescription_pdf_oss_path) { $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(); Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path); Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path);
return Result::REQUEUE; return Result::REQUEUE;
} }
// 药师/医院签章 // 药师签章
Log::getInstance("queue-AutoPharmacistCaVerify")->info("药师/医院签章"); Log::getInstance("queue-AutoPharmacistCaVerify")->info("药师签章");
$OrderPrescriptionService = new OrderPrescriptionService(); $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'])){ if (empty($prescription_open_result['file_id'])){
Db::rollBack(); Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:处方开具失败"); Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:药师签章失败");
return Result::REQUEUE; 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"); 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']); $CaService = new CaService($order_prescription,1);
if (!$prescription_pdf_oss_path) { $prescription_pdf_oss_path = $CaService->downCaPdfToOss($prescription_open_result['file_id']);
if ($prescription_pdf_oss_path == "") {
Db::rollBack(); Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path); Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path);
return Result::REQUEUE; return Result::REQUEUE;
@ -244,7 +264,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
Db::commit(); Db::commit();
Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功"); Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功");
} catch (\Exception $e) { } catch (\Throwable $e) {
Db::rollBack(); Db::rollBack();
Log::getInstance("queue-AutoPharmacistCaVerify")->error("异常错误:" . $e->getMessage()); Log::getInstance("queue-AutoPharmacistCaVerify")->error("异常错误:" . $e->getMessage());
@ -279,7 +299,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
Log::getInstance("queue-AutoPharmacistCaVerify")->error("添加处方过期队列失败!"); Log::getInstance("queue-AutoPharmacistCaVerify")->error("添加处方过期队列失败!");
return Result::ACK; return Result::ACK;
} }
}catch(\Exception $e){ }catch(\Throwable $e){
Log::getInstance("queue-AutoPharmacistCaVerify")->error("发送消息异常错误:" . $e->getMessage()); Log::getInstance("queue-AutoPharmacistCaVerify")->error("发送消息异常错误:" . $e->getMessage());
return Result::ACK; return Result::ACK;
} }
@ -405,34 +425,6 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
return true; 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 * @param string $prescription_file_id 主键id

View File

@ -38,81 +38,77 @@ class CaService extends BaseService
// 是否已添加签章配置(第一次需申请) // 是否已添加签章配置(第一次需申请)
protected string $is_sign_config; protected string $is_sign_config;
// 用户签名图片地址 // 签名图片地址
public string $sign_image_path; public string $sign_image_path;
// 医院签名图片地址 // 唯一标识
protected string $hospital_sign_image_path; protected string $entity_id;
// 用户唯一标识
protected string $user_entity_id;
// 医院唯一标识
protected string $hospital_entity_id;
// 证书序列号 // 证书序列号
protected string $cert_serial_number; protected string $cert_serial_number;
// 身份证号 // 身份证号/信用代码
protected string $card_num; protected string $card_num;
// 信用代码
protected string $org_num;
// 处方pdf本地地址 // 处方pdf本地地址
protected string $prescription_pdf_local_path; protected string $prescription_pdf_local_path;
// 处方pdf oss地址 // 处方pdf oss地址
protected string $prescription_pdf_oss_path; protected string $prescription_pdf_oss_path;
/** /**
* 初始化类,此处会获取基础数据 * 初始化类,此处会获取基础数据
* @param array|object $order_prescription 处方表数据 * @param array|object $order_prescription 处方表数据
* @param array|object $user 用户表数据 * @param string|int $user_id 用户id
* @param int $type 类型 1:医院 2:医生 3:药师
*/ */
public function __construct(array|object $order_prescription,array|object $user){ public function __construct(array|object $order_prescription,int $type,string|int $user_id = ""){
// 获取用户、医院签名图片地址、用户标识信息 // 获取用户、医院签名图片地址、用户标识信息
$params = array(); if ($type == 1){
$params['user_id'] = $user['user_id']; // 医院
if ($user['user_type'] == 2) { $this->sign_image_path = "basic/file/hospital_signature.png";
$this->entity_id = "5345345461";
$this->card_num = "91510106MABTJY4K9R";
}elseif($type == 2){
// 用户
$params = array();
$params['user_id'] = $user_id;
$user_doctor_info = UserDoctorInfo::getOne($params); $user_doctor_info = UserDoctorInfo::getOne($params);
if (empty($user_doctor_info)) { if (empty($user_doctor_info)) {
throw new BusinessException("用户数据错误"); throw new BusinessException("用户数据错误");
} }
$user_sign_image_path = $user_doctor_info['sign_image']; $this->sign_image_path = substr($user_doctor_info['sign_image'], 1, strlen($user_doctor_info['sign_image']) - 1);
$app_env = config('app_env','dev'); $app_env = config('app_env','dev');
if ($app_env == 'prod'){ if ($app_env == 'prod'){
$this->user_entity_id = $user_doctor_info['user_id']; $this->entity_id = $user_doctor_info['user_id'];
}else{ }else{
$this->user_entity_id = "491925054435950592"; $this->entity_id = "491925054435950592";
} }
$this->card_num = $user_doctor_info['card_num']; $this->card_num = $user_doctor_info['card_num'];
} else { } elseif ($type == 3){
$params = array();
$params['user_id'] = $user_id;
$user_pharmacist_info = UserPharmacistInfo::getOne($params); $user_pharmacist_info = UserPharmacistInfo::getOne($params);
if (empty($user_pharmacist_info)) { if (empty($user_pharmacist_info)) {
throw new BusinessException("用户数据错误"); throw new BusinessException("用户数据错误");
} }
$user_sign_image_path = $user_pharmacist_info['sign_image']; // 去除用户签名图片第一个/ oss不识别
$this->user_entity_id = $user['user_id']; $this->sign_image_path = substr($user_pharmacist_info['sign_image'], 1, strlen($user_pharmacist_info['sign_image']) - 1);
$this->card_num = $user_pharmacist_info['card_num'];
$this->hospital_sign_image_path = "basic/file/hospital_signature.png"; $this->entity_id = $user_id;
$this->hospital_entity_id = "5345345461"; $this->card_num = $user_pharmacist_info['card_num'];
$this->org_num = "91510106MABTJY4K9R"; } else{
throw new BusinessException("用户类型错误");
} }
if (empty($user_sign_image_path) || empty($this->user_entity_id)) { if (empty($this->sign_image_path) || empty($this->entity_id)) {
throw new BusinessException("无签名图片/用户唯一标识"); throw new BusinessException("无签名图片/用户唯一标识");
} }
// 去除用户签名图片第一个/ oss不识别
$this->sign_image_path = substr($user_sign_image_path, 1, strlen($user_sign_image_path) - 1);
$order_prescription_id = $order_prescription['order_prescription_id']; $order_prescription_id = $order_prescription['order_prescription_id'];
// 创建协程客户端 // 创建协程客户端
@ -225,9 +221,8 @@ class CaService extends BaseService
/** /**
* 获取云证书签名+验证云证书签名 * 获取云证书签名+验证云证书签名
* @param array|object $order_prescription * @param array|object $order_prescription
* @param int $type 类型 1:用户 2:医院
*/ */
public function getVerifyCertSign(array|object $order_prescription,int $type) public function getVerifyCertSign(array|object $order_prescription)
{ {
$CaOnline = new CaOnline(); $CaOnline = new CaOnline();
@ -254,13 +249,7 @@ class CaService extends BaseService
$data['product'][] = $product; $data['product'][] = $product;
} }
if ($type == 1){ $cert_sign_result = $CaOnline->getCertSign($this->entity_id, $this->entity_id, $data);
// 用户
$cert_sign_result = $CaOnline->getCertSign($this->user_entity_id, $this->user_entity_id, $data);
}else{
// 医院
$cert_sign_result = $CaOnline->getCertSign($this->hospital_entity_id, $this->hospital_entity_id, $data);
}
// 验证云证书签名 验证无需处理,只要不返回错误即可 // 验证云证书签名 验证无需处理,只要不返回错误即可
$CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data); $CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data);
@ -411,38 +400,23 @@ class CaService extends BaseService
/** /**
* 下载Oss中处方pdf * 下载Oss中处方pdf
* 存在:当次发版内医生开具后,药师再去开具
* 不存在:医生开具后,进行发版过,此时需重新下载
* @return void * @return void
*/ */
public function downOssPdfToLocal(): void public function downOssPdfToLocal(): void
{ {
$res = file_exists($this->prescription_pdf_local_path); $oss = new Oss();
if (!$res){ $oss->getObjectToLocal($this->prescription_pdf_oss_path, $this->prescription_pdf_local_path);
// 去除第一个/ oss不识别
// $prescription_pdf_path = substr($doctor_pdf_oss_path, 1, strlen($doctor_pdf_oss_path) - 1);
$oss = new Oss();
$oss->getObjectToLocal($this->prescription_pdf_oss_path, $this->prescription_pdf_local_path);
}
} }
/** /**
* 下载CA中pdf至本地文件 * 下载CA中pdf至本地文件
* @param string $file_id * @param string $file_id
* @param int $type 类型 1:用户 2:医院
* @return void * @return void
*/ */
public function downCaPdfToLocal(string $file_id,int $type): void public function downCaPdfToLocal(string $file_id): void
{ {
$CaOnline = new CaOnline(); $CaOnline = new CaOnline();
if ($type == 1){ $prescription_pdf_result = $CaOnline->getSignedFile($this->entity_id, $file_id);
// 用户
$prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id);
}else{
// 医院
$prescription_pdf_result = $CaOnline->getSignedFile($this->hospital_entity_id, $file_id);
}
$file = fopen($this->prescription_pdf_local_path, "w"); $file = fopen($this->prescription_pdf_local_path, "w");
fwrite($file, $prescription_pdf_result); fwrite($file, $prescription_pdf_result);
@ -452,20 +426,13 @@ class CaService extends BaseService
/** /**
* 下载CA中的pdf并上传至oss * 下载CA中的pdf并上传至oss
* @param string $file_id * @param string $file_id
* @param int $type 类型 1:用户 2:医院
* @return string oss地址 * @return string oss地址
*/ */
public function downCaPdfToOss(string $file_id,int $type): string public function downCaPdfToOss(string $file_id): string
{ {
$CaOnline = new CaOnline(); $CaOnline = new CaOnline();
if ($type == 1){ $prescription_pdf_result = $CaOnline->getSignedFile($this->entity_id, $file_id);
// 用户
$prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id);
}else{
// 医院
$prescription_pdf_result = $CaOnline->getSignedFile($this->hospital_entity_id, $file_id);
}
// 上传oss // 上传oss
$oss = new Oss(); $oss = new Oss();
@ -479,27 +446,15 @@ class CaService extends BaseService
*/ */
public function addSignPdf(string $type): string public function addSignPdf(string $type): string
{ {
// 下载签名图片 $oss = new Oss();
if ($type == 1){ if ($type == 1){
$local_path = "./extend/Ca/hospital_signature.png"; $style = "image/resize,w_300,h_300";
$res = file_exists($local_path); }else{
if ($res){ $style = "image/resize,m_lfit,w_100,h_350";
// 读取本地文件
$sign_image = fopen($local_path,'r');
}
} }
if (!isset($sign_image)){ $sign_image = $oss->getCusTomObjectToRAM($this->sign_image_path, $style);
$oss = new Oss();
if ($type == 1){
$style = "image/resize,w_300,h_300";
$sign_image = $oss->getCusTomObjectToRAM($this->hospital_sign_image_path, $style);
}else{
$style = "image/resize,m_lfit,w_100,h_350";
$sign_image = $oss->getCusTomObjectToRAM($this->sign_image_path, $style);
}
}
$sign_image = base64_encode($sign_image); $sign_image = base64_encode($sign_image);
if (!$sign_image) { if (!$sign_image) {
@ -512,24 +467,18 @@ class CaService extends BaseService
$lly = "210"; // 左边底部Y坐标 控制上下(越小越下) $lly = "210"; // 左边底部Y坐标 控制上下(越小越下)
$urx = "520"; // 右边上部x坐标 $urx = "520"; // 右边上部x坐标
$ury = "360"; // 右边上部y坐标 $ury = "360"; // 右边上部y坐标
$entity_id = $this->hospital_entity_id;
} elseif ($type == 2){ } elseif ($type == 2){
// 医生端 // 医生端
$llx = "120"; // 左边底部X坐标 $llx = "120"; // 左边底部X坐标
$lly = "190"; // 左边底部Y坐标 $lly = "190"; // 左边底部Y坐标
$urx = "190"; // 右边上部x坐标 $urx = "190"; // 右边上部x坐标
$ury = "140"; // 右边上部y坐标 $ury = "140"; // 右边上部y坐标
$entity_id = $this->user_entity_id;
}else{ }else{
// 药师端 // 药师端
$llx = "350"; // 左边底部X坐标 $llx = "350"; // 左边底部X坐标
$lly = "190"; // 左边底部Y坐标 $lly = "190"; // 左边底部Y坐标
$urx = "440"; // 右边上部x坐标 $urx = "440"; // 右边上部x坐标
$ury = "140"; // 右边上部y坐标 $ury = "140"; // 右边上部y坐标
$entity_id = $this->user_entity_id;
} }
$sign_param = [ $sign_param = [
@ -559,11 +508,7 @@ class CaService extends BaseService
$data['sign_param'] = json_encode($sign_param); $data['sign_param'] = json_encode($sign_param);
$data['seal_img'] = $sign_image; $data['seal_img'] = $sign_image;
if ($type == 1){ $CaOnline->addUserSignConfig($this->entity_id,$this->card_num,$data);
$CaOnline->addUserSignConfig($entity_id,$this->org_num,$data);
}else{
$CaOnline->addUserSignConfig($entity_id,$this->card_num,$data);
}
$params = array(); $params = array();
$params['cert_id'] = $user_ca_cert['cert_id']; $params['cert_id'] = $user_ca_cert['cert_id'];
@ -580,17 +525,16 @@ class CaService extends BaseService
throw new BusinessException("处方pdf打开失败"); throw new BusinessException("处方pdf打开失败");
} }
// 处方pdf进行签章 // 处方pdf进行签章
$data = array(); $data = array();
$data['sign_param'] = json_encode($sign_param); $data['sign_param'] = json_encode($sign_param);
$data['pdf_file'] = $pdf_file; $data['pdf_file'] = $pdf_file;
$sign_pdf_result = $CaOnline->addSignPdf($entity_id, $data); $sign_pdf_result = $CaOnline->addSignPdf($this->entity_id, $data);
if (empty($sign_pdf_result[0]['fileId'])) { if (empty($sign_pdf_result[0]['fileId'])) {
throw new BusinessException("处方签章失败"); throw new BusinessException("处方签章失败");
} }
return $sign_pdf_result[0]['fileId']; return $sign_pdf_result[0]['fileId'];
} }
} }

View File

@ -132,21 +132,90 @@ class OrderPrescriptionService extends BaseService
* @param string $user_id 用户id * @param string $user_id 用户id
* @return array * @return array
*/ */
public function openPrescription(string $order_prescription_id, string $user_id): array // public function openPrescription1(string $order_prescription_id, string $user_id): array
// {
// try {
// // 获取用户数据
// $params = array();
// $params['user_id'] = $user_id;
// $user = User::getOne($params);
// if (empty($user)) {
// throw new BusinessException("用户数据错误");
// }
//
// if ($user['user_type'] != 2 && $user['user_type'] != 3) {
// throw new BusinessException("用户类型错误");
// }
//
// // 获取处方数据
// $params = array();
// $params['order_prescription_id'] = $order_prescription_id;
// $order_prescription = OrderPrescription::getOne($params);
// if (empty($order_prescription)) {
// throw new BusinessException("处方数据错误");
// }
//
// if (empty($order_prescription['doctor_created_time'])) {
// throw new BusinessException("医生开方日期错误");
// }
//
// $CaService = new CaService($order_prescription,$user);
//
// // 获取云证书签名+验证云证书签名
// $CaService->getVerifyCertSign($order_prescription,1);
//
// // 医生
// if ($user['user_type'] == 2) {
// // 生成处方图片+处方图片生成pdf
// $prescription_img_oss_path = $CaService->createPrescriptionImgPdf($order_prescription);
// }
//
// // 药师-医院签章
// if ($user['user_type'] == 3) {
// // 获取医院云证书签名+验证云证书签名
// $CaService->getVerifyCertSign($order_prescription,2);
//
// // 下载医生开具的处方pdf至本地
// $CaService->downOssPdfToLocal();
// }
//
// // 进行处方pdf签章
// $file_id = $CaService->addSignPdf($user['user_type']);
//
// // 药师-医院签章
// if ($user['user_type'] == 3) {
// // 药师端时,需要进行系统签章
// // 把药师签章的pdf存储至本地文件
// // 下载药师签章pdf图片
// dump($file_id);
// $CaService->downCaPdfToLocal($file_id,1);
//
// // 进行处方pdf签章
// $file_id = $CaService->addSignPdf($user['user_type']);
// }
//
// $result = array();
// $result['prescription_img_oss_path'] = $prescription_img_oss_path ?? "";
// $result['file_id'] = $file_id;
// return $result;
//
// } catch (\Throwable $e) {
// throw new BusinessException($e->getMessage());
// }
// }
/**
* 开具处方
* 医生-正常开具
* 药师-先开具药师处方,再开具医院签章
* @param string $order_prescription_id 处方id
* @param string $user_id 用户id
* @param int $type 类型 1:医院 2:医生 3:药师
* @return array
*/
public function openPrescription(string $order_prescription_id,int $type,string $user_id = ""): array
{ {
try { try {
// 获取用户数据
$params = array();
$params['user_id'] = $user_id;
$user = User::getOne($params);
if (empty($user)) {
throw new BusinessException("用户数据错误");
}
if ($user['user_type'] != 2 && $user['user_type'] != 3) {
throw new BusinessException("用户类型错误");
}
// 获取处方数据 // 获取处方数据
$params = array(); $params = array();
$params['order_prescription_id'] = $order_prescription_id; $params['order_prescription_id'] = $order_prescription_id;
@ -159,40 +228,20 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException("医生开方日期错误"); throw new BusinessException("医生开方日期错误");
} }
$CaService = new CaService($order_prescription,$user); $CaService = new CaService($order_prescription,$type,$user_id);
// 获取云证书签名+验证云证书签名 // 获取云证书签名+验证云证书签名
$CaService->getVerifyCertSign($order_prescription,1); $CaService->getVerifyCertSign($order_prescription);
if ($type == 2) {
// 医生
if ($user['user_type'] == 2) {
// 生成处方图片+处方图片生成pdf // 生成处方图片+处方图片生成pdf
$prescription_img_oss_path = $CaService->createPrescriptionImgPdf($order_prescription); $prescription_img_oss_path = $CaService->createPrescriptionImgPdf($order_prescription);
} }else{
// 下载已经开具的处方pdf至本地
// 药师-医院签章
if ($user['user_type'] == 3) {
// 获取医院云证书签名+验证云证书签名
$CaService->getVerifyCertSign($order_prescription,2);
// 下载医生开具的处方pdf至本地文件存在时不进行下载
$CaService->downOssPdfToLocal(); $CaService->downOssPdfToLocal();
} }
// 进行处方pdf签章 // 进行处方pdf签章
$file_id = $CaService->addSignPdf($user['user_type']); $file_id = $CaService->addSignPdf($type);
// 药师-医院签章
if ($user['user_type'] == 3) {
// 药师端时,需要进行系统签章
// 把药师签章的pdf存储至本地文件
// 下载药师签章pdf图片
$CaService->downCaPdfToLocal($file_id,1);
// 进行处方pdf签章
$file_id = $CaService->addSignPdf($user['user_type']);
}
$result = array(); $result = array();
$result['prescription_img_oss_path'] = $prescription_img_oss_path ?? ""; $result['prescription_img_oss_path'] = $prescription_img_oss_path ?? "";
$result['file_id'] = $file_id; $result['file_id'] = $file_id;

View File

@ -1471,7 +1471,7 @@ class UserDoctorService extends BaseService
// 开具处方 // 开具处方
$OrderPrescriptionService = new OrderPrescriptionService(); $OrderPrescriptionService = new OrderPrescriptionService();
$prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']); $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,2,$user_info['user_id']);
if (empty($prescription_open_result['prescription_img_oss_path']) || empty($prescription_open_result['file_id'])){ if (empty($prescription_open_result['prescription_img_oss_path']) || empty($prescription_open_result['file_id'])){
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败");