From 25cdfbc20a5fd3d2f4df271306b58ad2011e6e80 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 31 Mar 2023 17:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=B6=E5=BA=AD=E6=88=90=E5=91=98=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=83=85=E5=86=B5=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E6=9C=8D=E8=8D=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/TestController.php | 5 +- app/Services/OrderPrescriptionService.php | 221 ++++++++++++---------- app/Services/PatientFamilyService.php | 14 +- 3 files changed, 139 insertions(+), 101 deletions(-) diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index fffab3a..94310ce 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -44,7 +44,7 @@ class TestController extends AbstractController // 获取云证书-首次 public function test_1(){ $ca = new Ca(); - +// // 测试医生 // $data = array(); // $data['user_id'] = "491925054435950592"; // $data['card_num'] = "410323199603261241"; @@ -61,9 +61,10 @@ class TestController extends AbstractController // return fail(); // } + // 测试药师 $data = array(); $data['user_id'] = "534534546"; - $data['card_num'] = "410323199603261236"; + $data['card_num'] = "410323199603261240"; $result = $ca->getCloudCert($data); $data = array(); diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index 73614de..f9d11ad 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -163,6 +163,11 @@ class OrderPrescriptionService extends BaseService throw new BusinessException("医生开方日期错误"); } + // 药师端检测处方图片 + if ($user['user_type'] == 3 && empty($order_prescription['prescription_img'])){ + throw new BusinessException("医生开方日期错误"); + } + // 获取处方关联疾病数据 $params = array(); $params['order_prescription_id'] = $order_prescription_id; @@ -236,131 +241,157 @@ class OrderPrescriptionService extends BaseService $data['product'][] = $product; } dump("签名获取成功"); - $cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data); + + if ($user['user_type'] == 3){ + $cert_sign_result = $ca->getCertSign($user['user_id'], $user['user_id'], $data); + }else{ + $cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data); + } + // 验证云证书签名-验证无需处理,只要不返回错误即可 $ca->verifyPkcs7($cert_sign_result['signP7'],$data); dump("签名验证成功"); - // 下载基础处方pdf图片 + $oss = new Oss(); - $filename = "basic/file/prescription.jpg"; - $prescription_image = $oss->getObjectToRAM($filename); + // 医生 + if ($user['user_type'] == 2){ + // 下载基础处方pdf图片 + $filename = "basic/file/prescription.jpg"; + $prescription_image = $oss->getObjectToRAM($filename); - dump("下载基础处方pdf图片成功"); + dump("下载基础处方pdf图片成功"); - $manager = new ImageManager(); + $manager = new ImageManager(); - $image = $manager->make($prescription_image); + $image = $manager->make($prescription_image); // $fontPath = './extend/Ca/ZiYuYongSongTi-2.ttf'; - $fontPath = './extend/Ca/msyh.ttf'; + $fontPath = './extend/Ca/msyh.ttf'; - // 处方号 - $image->text($order_prescription['prescription_code'], 1480, 540, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 日期 - $image->text(date('Y-m-d',strtotime($order_prescription['doctor_created_time'])), 354, 675, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 科室 - $image->text($hospital_department_custom['department_name'] ?: "", 1385, 675, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 姓名 - $image->text($order_prescription['patient_name'], 354, 795, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 性别 - $image->text(sexToStringSex($order_prescription['patient_sex']), 1385, 790, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 年龄 - $image->text($order_prescription['patient_age'], 354, 900, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 过敏史 - $image->text($order_inquiry_case['allergy_history'] ?: "无", 405, 1030, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 初步诊断 - $image->text($icd_name, 445, 1145, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 医生建议 - $image->text($order_prescription['doctor_advice'] ?: "无", 445, 1252, function ($font) use($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 商品数据 - foreach ($order_prescription_product as $key => $item){ - $x_axis = 229; - $y_axis = 1600 + $key * 250; - $x_axis_num = 1900;// 数量使用 - - // 商品名称 - $image->text($item['product_name'], $x_axis, $y_axis, function ($font) use($fontPath) { + // 处方号 + $image->text($order_prescription['prescription_code'], 1480, 540, function ($font) use($fontPath) { $font->file($fontPath); - $font->size(50); + $font->size(60); $font->align('left'); }); - $image->text("X" . $item['prescription_product_num'] . $item['packaging_unit'], $x_axis_num, $y_axis, function ($font) use($fontPath) { + // 日期 + $image->text(date('Y-m-d',strtotime($order_prescription['doctor_created_time'])), 354, 675, function ($font) use($fontPath) { $font->file($fontPath); - $font->size(50); + $font->size(60); $font->align('left'); }); - // 用量 - $image->text("用量:" . $item['single_unit'] . " " . $item['frequency_use'], $x_axis, $y_axis+70, function ($font) use($fontPath) { + // 科室 + $image->text($hospital_department_custom['department_name'] ?: "", 1385, 675, function ($font) use($fontPath) { $font->file($fontPath); - $font->size(50); + $font->size(60); $font->align('left'); }); - // 用法 - $image->text("用法:" . $item['single_use'], $x_axis, $y_axis+140, function ($font) use($fontPath) { + // 姓名 + $image->text($order_prescription['patient_name'], 354, 795, function ($font) use($fontPath) { $font->file($fontPath); - $font->size(50); + $font->size(60); $font->align('left'); }); + + // 性别 + $image->text(sexToStringSex($order_prescription['patient_sex']), 1385, 790, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(60); + $font->align('left'); + }); + + // 年龄 + $image->text($order_prescription['patient_age'], 354, 900, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(60); + $font->align('left'); + }); + + // 过敏史 + $image->text($order_inquiry_case['allergy_history'] ?: "无", 405, 1030, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(60); + $font->align('left'); + }); + + // 初步诊断 + $image->text($icd_name, 445, 1145, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(60); + $font->align('left'); + }); + + // 医生建议 + $image->text($order_prescription['doctor_advice'] ?: "无", 445, 1252, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(60); + $font->align('left'); + }); + + // 商品数据 + foreach ($order_prescription_product as $key => $item){ + $x_axis = 229; + $y_axis = 1600 + $key * 250; + $x_axis_num = 1900;// 数量使用 + + // 商品名称 + $image->text($item['product_name'], $x_axis, $y_axis, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(50); + $font->align('left'); + }); + + $image->text("X" . $item['prescription_product_num'] . $item['packaging_unit'], $x_axis_num, $y_axis, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(50); + $font->align('left'); + }); + + // 用量 + $image->text("用量:" . $item['single_unit'] . " " . $item['frequency_use'], $x_axis, $y_axis+70, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(50); + $font->align('left'); + }); + + // 用法 + $image->text("用法:" . $item['single_use'], $x_axis, $y_axis+140, function ($font) use($fontPath) { + $font->file($fontPath); + $font->size(50); + $font->align('left'); + }); + } + + // 生成图片 + $img_result = (string) $image->encode('png', 75); + dump("处方图片生成成功"); + + // 上传处方图片至oss + $filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'jpg'; + $prescription_img_url = $oss->putObject($filename, $img_result); + dump("处方图片上传oss成功"); } - // 生成图片 - $img_result = (string) $image->encode('png', 75); - dump("处方图片生成成功"); + // 药师 + if ($user['user_type'] == 3){ + // 下载开具的处方图片 + $filename = "basic/file/prescription.jpg"; + $prescription_image = $oss->getObjectToRAM($filename); + + dump("下载基础处方pdf图片成功"); + + + } + + + + - // 上传处方图片至oss - $filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'jpg'; - $prescription_img_url = $oss->putObject($filename, $img_result); - dump("处方图片上传oss成功"); // 图片生成pdf $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); diff --git a/app/Services/PatientFamilyService.php b/app/Services/PatientFamilyService.php index 4dd9b8a..79ce2af 100644 --- a/app/Services/PatientFamilyService.php +++ b/app/Services/PatientFamilyService.php @@ -779,9 +779,12 @@ class PatientFamilyService extends BaseService } } - if (isset($request_params['drugs_name'])){ - if ($request_params['drugs_name'] != $patient_family_health['drugs_name']){ - $data['drugs_name'] = $request_params['drugs_name']; + if (isset($request_params['is_take_medicine'])){ + if ($request_params['is_take_medicine'] != $patient_family_health['is_take_medicine']){ + $data['is_take_medicine'] = $request_params['is_take_medicine']; + if ($request_params['drugs_name'] != $patient_family_health['drugs_name']){ + $data['drugs_name'] = $request_params['drugs_name']; + } } } @@ -845,7 +848,10 @@ class PatientFamilyService extends BaseService $data['diagnosis_date'] = $request_params['diagnosis_date']; $data['diagnosis_hospital'] = $request_params['diagnosis_hospital']; - $data['drugs_name'] = $request_params['drugs_name']; + if (isset($request_params['is_take_medicine'])){ + $data['is_take_medicine'] = $request_params['is_take_medicine']; + $data['drugs_name'] = $request_params['drugs_name']; + } $patient_family_health = PatientFamilyHealth::addPatientFamilyHealth($data); if (empty($patient_family_health)){ return fail();