修改ca签章
This commit is contained in:
+62
-15
@@ -7,6 +7,7 @@ use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\UserCaCert;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserPharmacistInfo;
|
||||
@@ -34,6 +35,9 @@ class CaService extends BaseService
|
||||
// 过敏史
|
||||
protected string $allergy_history;
|
||||
|
||||
// 是否已添加签章配置(第一次需申请)
|
||||
protected string $is_sign_config;
|
||||
|
||||
// 用户签名图片地址
|
||||
public string $sign_image_path;
|
||||
|
||||
@@ -46,6 +50,15 @@ class CaService extends BaseService
|
||||
// 医院唯一标识
|
||||
protected string $hospital_entity_id;
|
||||
|
||||
// 证书序列号
|
||||
protected string $cert_serial_number;
|
||||
|
||||
// 身份证号
|
||||
protected string $card_num;
|
||||
|
||||
// 信用代码
|
||||
protected string $org_num;
|
||||
|
||||
/**
|
||||
* 初始化类,此处会获取基础数据
|
||||
* @param array|object $order_prescription 处方表数据
|
||||
@@ -63,6 +76,7 @@ class CaService extends BaseService
|
||||
|
||||
$user_sign_image_path = $user_doctor_info['sign_image'];
|
||||
$this->user_entity_id = "491925054435950592";
|
||||
$this->card_num = $user_doctor_info['card_num'];
|
||||
} else {
|
||||
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
|
||||
if (empty($user_pharmacist_info)) {
|
||||
@@ -71,9 +85,11 @@ class CaService extends BaseService
|
||||
|
||||
$user_sign_image_path = $user_pharmacist_info['sign_image'];
|
||||
$this->user_entity_id = $user['user_id'];
|
||||
$this->card_num = $user_pharmacist_info['card_num'];
|
||||
|
||||
$this->hospital_sign_image_path = "basic/file/hospital_signature.png";
|
||||
$this->hospital_entity_id = "5345345461";
|
||||
$this->org_num = "91510106MABTJY4K9R";
|
||||
}
|
||||
|
||||
if (empty($user_sign_image_path) || empty($this->user_entity_id)) {
|
||||
@@ -94,7 +110,7 @@ class CaService extends BaseService
|
||||
$wg->add(4);
|
||||
|
||||
// 获取处方关联疾病名称
|
||||
co(function () use ($wg,$channel,&$icd_name,$order_prescription_id) {
|
||||
co(function () use ($wg,$channel,$order_prescription_id) {
|
||||
defer(function() use ($wg) {
|
||||
$wg->done();
|
||||
});
|
||||
@@ -107,6 +123,7 @@ class CaService extends BaseService
|
||||
return;
|
||||
}
|
||||
|
||||
$this->icd_name = "";
|
||||
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
|
||||
if (!empty($icd_name)) {
|
||||
if (count($icd_name) > 1) {
|
||||
@@ -134,9 +151,9 @@ class CaService extends BaseService
|
||||
$this->order_prescription_product = $order_prescription_product->toArray();
|
||||
});
|
||||
|
||||
// 获取医生自定义科室数据
|
||||
// 获取医生自定义科室名称
|
||||
$doctor_id = $order_prescription['doctor_id'];
|
||||
co(function () use ($wg,$channel,&$hospital_department_custom,$doctor_id) {
|
||||
co(function () use ($wg,$channel,$doctor_id) {
|
||||
defer(function() use ($wg) {
|
||||
$wg->done();
|
||||
});
|
||||
@@ -162,9 +179,9 @@ class CaService extends BaseService
|
||||
$this->department_name = $hospital_department_custom['department_name'] ?: "";
|
||||
});
|
||||
|
||||
// 获取处方关联病例数据
|
||||
// 获取过敏史
|
||||
$order_inquiry_id = $order_prescription['order_inquiry_id'];
|
||||
co(function () use ($wg,$channel,&$order_inquiry_case,$order_inquiry_id) {
|
||||
co(function () use ($wg,$channel,$order_inquiry_id) {
|
||||
defer(function() use ($wg) {
|
||||
$wg->done();
|
||||
});
|
||||
@@ -173,6 +190,7 @@ class CaService extends BaseService
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||
if (empty($order_inquiry_case)) {
|
||||
dump(111);
|
||||
$channel->push('处方病例数据错误');
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +203,7 @@ class CaService extends BaseService
|
||||
|
||||
// 判断通道是否存在异常数据
|
||||
$res = $channel->isEmpty();
|
||||
if ($res){
|
||||
if (!$res){
|
||||
// 读取通道数据
|
||||
$data = $channel->pop();
|
||||
|
||||
@@ -197,8 +215,6 @@ class CaService extends BaseService
|
||||
// 关闭channel通道
|
||||
$channel->close();
|
||||
}
|
||||
|
||||
$this->icd_name = $icd_name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,6 +259,8 @@ class CaService extends BaseService
|
||||
|
||||
// 验证云证书签名 验证无需处理,只要不返回错误即可
|
||||
$CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data);
|
||||
|
||||
$this->cert_serial_number = $cert_sign_result['certSerialnumber'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,16 +409,17 @@ class CaService extends BaseService
|
||||
* 下载医生开具的处方pdf
|
||||
* 存在:当次发版内医生开具后,药师再去开具
|
||||
* 不存在:医生开具后,进行发版过,此时需重新下载
|
||||
* @param array|object $order_prescription
|
||||
* @param string $order_prescription_id
|
||||
* @param string $doctor_pdf_oss_path
|
||||
* @return void
|
||||
*/
|
||||
public function downDoctorPrescriptionPdf(array|object $order_prescription): void
|
||||
public function downDoctorPrescriptionPdf(string $order_prescription_id,string $doctor_pdf_oss_path): void
|
||||
{
|
||||
$local_path = "./runtime/file/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf';
|
||||
$local_path = "./runtime/file/prescription/" . $order_prescription_id . '.' . 'pdf';
|
||||
$res = file_exists($local_path);
|
||||
if (!$res){
|
||||
// 去除第一个/ oss不识别
|
||||
$prescription_pdf_path = substr($order_prescription['prescription_pdf'], 1, strlen($order_prescription['prescription_pdf']) - 1);
|
||||
$prescription_pdf_path = substr($doctor_pdf_oss_path, 1, strlen($doctor_pdf_oss_path) - 1);
|
||||
|
||||
$oss = new Oss();
|
||||
$oss->getObjectToLocal($prescription_pdf_path, $local_path);
|
||||
@@ -479,14 +498,42 @@ class CaService extends BaseService
|
||||
],
|
||||
];
|
||||
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
// 检测是否已添加签章配置
|
||||
$params = array();
|
||||
$params['cert_serial_number'] = $this->cert_serial_number;
|
||||
$user_ca_cert = UserCaCert::getOne($params);
|
||||
if (empty($user_ca_cert)){
|
||||
throw new BusinessException("未申请证书");
|
||||
}
|
||||
|
||||
if ($user_ca_cert['is_sign_config'] == 0){
|
||||
// 添加签章配置
|
||||
$data = array();
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
$data['seal_img'] = $sign_image;
|
||||
|
||||
if ($type == 1){
|
||||
$CaOnline->addUserSignConfig($entity_id,$this->org_num,$data);
|
||||
}else{
|
||||
$CaOnline->addUserSignConfig($entity_id,$this->card_num,$data);
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['cert_id'] = $user_ca_cert['cert_id'];
|
||||
|
||||
$data = array();
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
UserCaCert::edit($params,$data);
|
||||
}
|
||||
|
||||
// 打开处方pdf文件
|
||||
$pdf_file = fopen("./runtime/" . $order_prescription['order_prescription_id'] . ".pdf", 'r');
|
||||
$pdf_file = fopen("./runtime/file/prescription/" . $order_prescription['order_prescription_id'] . ".pdf", 'r');
|
||||
if (!$pdf_file) {
|
||||
throw new BusinessException("处方图片打开失败");
|
||||
}
|
||||
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
// 处方pdf进行签章
|
||||
$data = array();
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
|
||||
Reference in New Issue
Block a user