新增处方打印
This commit is contained in:
parent
bb76ae5cc9
commit
89c9eadb1b
@ -10,6 +10,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $doctor_info_id 主键
|
* @property int $doctor_info_id 主键
|
||||||
|
* @property int $user_id 用户id
|
||||||
* @property int $doctor_id 医生id
|
* @property int $doctor_id 医生id
|
||||||
* @property int $card_type 类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
* @property int $card_type 类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
||||||
* @property string $card_name 证件姓名
|
* @property string $card_name 证件姓名
|
||||||
@ -21,6 +22,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property string $qualification_cert_num 医师资格证号(逗号分隔)
|
* @property string $qualification_cert_num 医师资格证号(逗号分隔)
|
||||||
* @property string $work_cert 医师工作证(逗号分隔)
|
* @property string $work_cert 医师工作证(逗号分隔)
|
||||||
* @property string $multi_point_images 多点执业备案信息(逗号分隔)
|
* @property string $multi_point_images 多点执业备案信息(逗号分隔)
|
||||||
|
* @property string $id_card_front 身份证正面图片
|
||||||
|
* @property string $id_card_back 身份证背面图片
|
||||||
* @property string $sign_image 签名图片
|
* @property string $sign_image 签名图片
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
@ -37,7 +40,7 @@ class UserDoctorInfo extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['doctor_info_id', 'doctor_id', 'card_type', 'card_name', 'card_name_mask', 'card_num', 'card_num_mask', 'license_cert', 'qualification_cert', 'qualification_cert_num', 'work_cert', 'multi_point_images', 'sign_image', 'created_at', 'updated_at'];
|
protected array $fillable = ['doctor_info_id', 'user_id', 'doctor_id', 'card_type', 'card_name', 'card_name_mask', 'card_num', 'card_num_mask', 'license_cert', 'qualification_cert', 'qualification_cert_num', 'work_cert', 'multi_point_images', 'id_card_front', 'id_card_back', 'sign_image', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "doctor_info_id";
|
protected string $primaryKey = "doctor_info_id";
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $info_id 主键id
|
* @property int $info_id 主键id
|
||||||
|
* @property int $user_id 用户id
|
||||||
* @property int $pharmacist_id 药师id
|
* @property int $pharmacist_id 药师id
|
||||||
* @property int $card_type 类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
* @property int $card_type 类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
||||||
* @property string $card_name 证件姓名
|
* @property string $card_name 证件姓名
|
||||||
@ -40,7 +41,7 @@ class UserPharmacistInfo extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['info_id', 'pharmacist_id', 'card_type', 'card_name', 'card_name_mask', 'card_num', 'card_num_mask', 'license_cert', 'qualification_cert', 'qualification_cert_num', 'work_cert', 'multi_point_images', 'id_card_front', 'id_card_back', 'sign_image', 'created_at', 'updated_at'];
|
protected array $fillable = ['info_id', 'user_id', 'pharmacist_id', 'card_type', 'card_name', 'card_name_mask', 'card_num', 'card_num_mask', 'license_cert', 'qualification_cert', 'qualification_cert_num', 'work_cert', 'multi_point_images', 'id_card_front', 'id_card_back', 'sign_image', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "info_id";
|
protected string $primaryKey = "info_id";
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,7 @@ class DoctorAuthService extends BaseService
|
|||||||
if (empty($user_doctor_info)) {
|
if (empty($user_doctor_info)) {
|
||||||
// 新增医生详情
|
// 新增医生详情
|
||||||
$data = array();
|
$data = array();
|
||||||
|
$data['user_id'] = $user_info['user_id'];
|
||||||
$data['doctor_id'] = $user_info['client_user_id'];
|
$data['doctor_id'] = $user_info['client_user_id'];
|
||||||
$data['card_type'] = 1;
|
$data['card_type'] = 1;
|
||||||
$data['card_name'] = $card_name;
|
$data['card_name'] = $card_name;
|
||||||
|
|||||||
@ -13,6 +13,8 @@ use App\Model\OrderPrescriptionProduct;
|
|||||||
use App\Model\OrderProductItem;
|
use App\Model\OrderProductItem;
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
|
use App\Model\UserDoctorInfo;
|
||||||
|
use App\Model\UserPharmacistInfo;
|
||||||
use Extend\Alibaba\Oss;
|
use Extend\Alibaba\Oss;
|
||||||
use Extend\Ca\Ca;
|
use Extend\Ca\Ca;
|
||||||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||||||
@ -106,10 +108,49 @@ class OrderPrescriptionService extends BaseService
|
|||||||
return OrderPrescription::getCount($params);
|
return OrderPrescription::getCount($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 医生开具处方
|
/**
|
||||||
public function doctorOpenPrescription(string $order_prescription_id,string $user_type)
|
* 开具处方
|
||||||
|
* @param string $order_prescription_id
|
||||||
|
* @param string $user_id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function openPrescription(string $order_prescription_id,string $user_id): string
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
// 获取用户数据
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_id;
|
||||||
|
$user = User::getOne($params);
|
||||||
|
if (empty($user)){
|
||||||
|
throw new BusinessException("用户数据错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户info数据
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user['user_id'];
|
||||||
|
|
||||||
|
$sign_image_path = "";
|
||||||
|
if ($user['user_type'] == 2){
|
||||||
|
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||||
|
if (!empty($user_doctor_info)){
|
||||||
|
$sign_image_path = $user_doctor_info['sign_image'];
|
||||||
|
}
|
||||||
|
}elseif ($user['user_type'] == 3){
|
||||||
|
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
|
||||||
|
if (!empty($user_pharmacist_info)){
|
||||||
|
$sign_image_path = $user_pharmacist_info['sign_image'];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
throw new BusinessException("用户类型错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($sign_image_path)){
|
||||||
|
throw new BusinessException("无签名图片");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去除第一个/ oss不识别
|
||||||
|
$sign_image_path = substr($sign_image_path, 1, strlen($sign_image_path) - 1);
|
||||||
|
|
||||||
// 获取处方数据
|
// 获取处方数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_prescription_id'] = $order_prescription_id;
|
$params['order_prescription_id'] = $order_prescription_id;
|
||||||
@ -170,44 +211,44 @@ class OrderPrescriptionService extends BaseService
|
|||||||
$icd_name = "";
|
$icd_name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// $ca = new Ca();
|
$ca = new Ca();
|
||||||
//
|
|
||||||
// // 获取云证书签名
|
// 获取云证书签名
|
||||||
// $data = array();
|
$data = array();
|
||||||
// $data['created_at'] = $order_prescription['doctor_created_time'];
|
$data['created_at'] = $order_prescription['doctor_created_time'];
|
||||||
// $data['department_custom_name'] = $hospital_department_custom['department_name'] ?: "";
|
$data['department_custom_name'] = $hospital_department_custom['department_name'] ?: "";
|
||||||
// $data['user_name'] = $order_prescription['patient_name'];
|
$data['user_name'] = $order_prescription['patient_name'];
|
||||||
// $data['sex'] = sexToStringSex($order_prescription['patient_sex']);
|
$data['sex'] = sexToStringSex($order_prescription['patient_sex']);
|
||||||
// $data['age'] = $order_prescription['patient_age'];
|
$data['age'] = $order_prescription['patient_age'];
|
||||||
// $data['allergy_history'] = $order_inquiry_case['allergy_history'] ?: "无";
|
$data['allergy_history'] = $order_inquiry_case['allergy_history'] ?: "无";
|
||||||
// $data['icd_name'] = $icd_name;
|
$data['icd_name'] = $icd_name;
|
||||||
// $data['doctor_advice'] = $order_prescription['doctor_advice'] ?: "无";
|
$data['doctor_advice'] = $order_prescription['doctor_advice'] ?: "无";
|
||||||
//
|
|
||||||
// // 商品数据
|
// 商品数据
|
||||||
// $data['product'] = array();
|
$data['product'] = array();
|
||||||
// foreach ($order_prescription_product as $item){
|
foreach ($order_prescription_product as $item){
|
||||||
// $product = array();
|
$product = array();
|
||||||
// $product['product_name'] = $item['product_name'] . "(" . $item['product_spec'] . ")"; // 商品名称+商品规格
|
$product['product_name'] = $item['product_name'] . "(" . $item['product_spec'] . ")"; // 商品名称+商品规格
|
||||||
// $product['single_unit'] = $item['single_unit'] ?: ""; // 单次剂量(例:1次1包)
|
$product['single_unit'] = $item['single_unit'] ?: ""; // 单次剂量(例:1次1包)
|
||||||
// $product['frequency_use'] = $item['frequency_use'] ?: ""; // 使用频率(例:1天3次)
|
$product['frequency_use'] = $item['frequency_use'] ?: ""; // 使用频率(例:1天3次)
|
||||||
// $product['single_use'] = $item['single_use'] ?: ""; // 单次用法(例:口服)
|
$product['single_use'] = $item['single_use'] ?: ""; // 单次用法(例:口服)
|
||||||
// $product['prescription_product_num'] = $item['prescription_product_num'] . $item['packaging_unit']; // 商品数量 + 基本包装单位(例:盒/瓶)
|
$product['prescription_product_num'] = $item['prescription_product_num'] . $item['packaging_unit']; // 商品数量 + 基本包装单位(例:盒/瓶)
|
||||||
// $data['product'][] = $product;
|
$data['product'][] = $product;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// $cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data);
|
$cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data);
|
||||||
//
|
|
||||||
// // 验证云证书签名-验证无需处理,只要不返回错误即可
|
// 验证云证书签名-验证无需处理,只要不返回错误即可
|
||||||
// $ca->verifyPkcs7($cert_sign_result['signP7'],$data);
|
$ca->verifyPkcs7($cert_sign_result['signP7'],$data);
|
||||||
|
|
||||||
// 生成处方pdf图片
|
// 生成处方pdf图片
|
||||||
$oss = new Oss();
|
$oss = new Oss();
|
||||||
|
|
||||||
$filename = "basic/file/prescription.jpg";
|
$filename = "basic/file/prescription.jpg";
|
||||||
$sign_image = $oss->getObjectToRAM($filename);
|
$prescription_image = $oss->getObjectToRAM($filename);
|
||||||
$manager = new ImageManager();
|
$manager = new ImageManager();
|
||||||
|
|
||||||
$image = $manager->make($sign_image);
|
$image = $manager->make($prescription_image);
|
||||||
|
|
||||||
$fontPath = './runtime/ZiYuYongSongTi-2.ttf';
|
$fontPath = './runtime/ZiYuYongSongTi-2.ttf';
|
||||||
|
|
||||||
@ -315,23 +356,71 @@ class OrderPrescriptionService extends BaseService
|
|||||||
$pdf->AddPage();
|
$pdf->AddPage();
|
||||||
$pdf->Image('@' . $img_result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
|
$pdf->Image('@' . $img_result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
|
||||||
|
|
||||||
// 生成本地文件
|
$filename = $order_prescription['order_prescription_id'] . '.' . 'pdf';
|
||||||
$pdf->Output(dirname(__DIR__, 2) . "/prescription_img.pdf","F");
|
|
||||||
|
|
||||||
// 生成文件流
|
// 图片生成的处方pdf存储为本地文件
|
||||||
$pdf_result = $pdf->Output("","S");
|
$pdf->Output(dirname(__DIR__, 2) . "/" . $filename ,"F");
|
||||||
|
|
||||||
|
// 下载签名图片
|
||||||
|
$style = "image/resize,m_lfit,w_100,h_350";
|
||||||
|
$sign_image = $oss->getCusTomObjectToRAM($sign_image_path,$style);
|
||||||
|
$sign_image = base64_encode($sign_image);
|
||||||
|
if (!$sign_image){
|
||||||
|
throw new BusinessException("签名图片下载失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user['user_type'] == 2){
|
||||||
|
$sign_param = [
|
||||||
|
[ // 医生端
|
||||||
|
"llx"=>"120", // 左边底部X坐标
|
||||||
|
"lly"=>"190", // 左边底部Y坐标
|
||||||
|
"urx"=>"190", // 右边上部x坐标
|
||||||
|
"ury"=>"140", // 右边上部y坐标
|
||||||
|
"pageList"=>[1],
|
||||||
|
"sealImg"=>$sign_image
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
$sign_param = [
|
||||||
|
[ // 药师端
|
||||||
|
"llx"=>"350", // 左边底部X坐标
|
||||||
|
"lly"=>"190", // 左边底部Y坐标
|
||||||
|
"urx"=>"440", // 右边上部x坐标
|
||||||
|
"ury"=>"140", // 右边上部y坐标
|
||||||
|
"pageList"=>[1],
|
||||||
|
"sealImg"=>$sign_image
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开处方pdf文件
|
||||||
|
$pdf_file = fopen("./runtime/" . $filename,'r');
|
||||||
|
|
||||||
|
// 处方pdf进行签章
|
||||||
|
$data = array();
|
||||||
|
$data['sign_param'] = json_encode($sign_param);
|
||||||
|
$data['pdf_file'] = $pdf_file;
|
||||||
|
$sign_pdf_result = $ca->addSignPdf("491925054435950592",$data);
|
||||||
|
|
||||||
|
if (empty($sign_pdf_result[0]['fileId'])){
|
||||||
|
throw new BusinessException("处方签章失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载处方签章文件
|
||||||
|
$file_id = $sign_pdf_result[0]['fileId'];
|
||||||
|
$prescription_pdf_result = $ca->getSignedFile("491925054435950592",$file_id);
|
||||||
|
if (empty($result)){
|
||||||
|
throw new BusinessException("下载处方签章文件失败");
|
||||||
|
}
|
||||||
|
|
||||||
// 上传oss
|
// 上传oss
|
||||||
$filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf';
|
$filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf';
|
||||||
|
$prescription_pdf_url = $oss->putObject($filename, $prescription_pdf_result);
|
||||||
|
|
||||||
$prescription_pdf_url = $oss->putObject($filename, $pdf_result);
|
return $prescription_pdf_url;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
dump($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,13 +444,12 @@ class PatientOrderService extends BaseService
|
|||||||
];
|
];
|
||||||
|
|
||||||
$order_product = OrderProduct::getPatientOrderProductPage($params, $fields, $page, $per_page);
|
$order_product = OrderProduct::getPatientOrderProductPage($params, $fields, $page, $per_page);
|
||||||
if (empty($order_product['data'])) {
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($order_product['data'] as $item) {
|
if (!empty($order_product['data'])){
|
||||||
foreach ($item['orderProductItem'] as &$product_item) {
|
foreach ($order_product['data'] as $item) {
|
||||||
$product_item['product_cover_img'] = addAliyunOssWebsite($product_item['product_cover_img']);
|
foreach ($item['orderProductItem'] as &$product_item) {
|
||||||
|
$product_item['product_cover_img'] = addAliyunOssWebsite($product_item['product_cover_img']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1147,7 +1147,7 @@ class UserDoctorService extends BaseService
|
|||||||
$prescription_icd = $this->request->input('prescription_icd');
|
$prescription_icd = $this->request->input('prescription_icd');
|
||||||
$doctor_advice = $this->request->input('doctor_advice');
|
$doctor_advice = $this->request->input('doctor_advice');
|
||||||
$prescription_product = $this->request->input('prescription_product');
|
$prescription_product = $this->request->input('prescription_product');
|
||||||
|
return success();
|
||||||
// 获取医生信息
|
// 获取医生信息
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
@ -1281,6 +1281,10 @@ class UserDoctorService extends BaseService
|
|||||||
unset($product);
|
unset($product);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$OrderPrescriptionService = new OrderPrescriptionService();
|
||||||
|
|
||||||
|
$prescription_img = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$order_inquiry['order_inquiry_id']);
|
||||||
|
|
||||||
// 加入分配药师队列
|
// 加入分配药师队列
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
$data['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||||
|
|||||||
@ -559,4 +559,6 @@ class UserService extends BaseService
|
|||||||
|
|
||||||
return $open_id;
|
return $open_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user