845 lines
29 KiB
PHP
845 lines
29 KiB
PHP
<?php
|
||
|
||
namespace App\Controller;
|
||
|
||
use App\Amqp\Producer\AssignDoctorProducer;
|
||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||
use App\Constants\HttpEnumCode;
|
||
use App\Exception\BusinessException;
|
||
use App\Model\DoctorInquiryTime;
|
||
use App\Model\HospitalDepartmentCustom;
|
||
use App\Model\OrderInquiryCase;
|
||
use App\Model\OrderPrescriptionProduct;
|
||
use App\Model\OrderProduct;
|
||
use App\Model\OrderProductItem;
|
||
use App\Model\PatientFamily;
|
||
use App\Model\User;
|
||
use App\Model\UserCaCert;
|
||
use App\Model\OrderInquiry;
|
||
use App\Model\OrderPrescription;
|
||
use App\Model\OrderPrescriptionIcd;
|
||
use App\Model\UserDoctor;
|
||
use App\Model\UserDoctorInfo;
|
||
use App\Services\ImService;
|
||
use App\Services\InquiryService;
|
||
use App\Services\MessagePush;
|
||
use App\Services\OrderPrescriptionService;
|
||
use App\Services\OrderProductService;
|
||
use App\Services\PatientOrderService;
|
||
use App\Services\UserDoctorService;
|
||
use App\Utils\Log;
|
||
use Extend\Alibaba\Oss;
|
||
use Extend\Ca\Ca;
|
||
use Extend\Ca\CaOnline;
|
||
use Extend\Kuaidi100\Kuaidi;
|
||
use Extend\Prescription\Prescription;
|
||
use Extend\RegulatoryPlatform\regulatoryPlatform;
|
||
use Extend\TencentIm\RecentContact;
|
||
use Hyperf\Amqp\Producer;
|
||
use Hyperf\DbConnection\Db;
|
||
use Hyperf\Redis\Redis;
|
||
use Hyperf\Utils\ApplicationContext;
|
||
use Hyperf\Utils\Coroutine\Concurrent;
|
||
use Imagick;
|
||
use Intervention\Image\ImageManager;
|
||
use Spatie\PdfToImage\Pdf;
|
||
use Swoole\Coroutine;
|
||
use Swoole\Coroutine\Channel;
|
||
use Swoole\Coroutine\WaitGroup;
|
||
use TCPDF;
|
||
|
||
class TestController extends AbstractController
|
||
{
|
||
public function test(){
|
||
// $this->test_8();
|
||
// $this->test_3();
|
||
// $this->test_4();
|
||
// $this->test_6();
|
||
// $this->test_9();
|
||
// $this->test_10();
|
||
// $this->test_11();
|
||
// $this->test_5();
|
||
// $this->test_1();
|
||
// $this->test_11();
|
||
// $this->test_12();
|
||
// $this->test_13();
|
||
// $this->test_14();
|
||
$this->test_15();
|
||
}
|
||
|
||
// 获取云证书-首次
|
||
public function test_1(){
|
||
$ca = new Ca();
|
||
// // 测试医生
|
||
// $data = array();
|
||
// $data['user_id'] = "491925054435950592";
|
||
// $data['card_num'] = "410323199603261241";
|
||
// $result = $ca->getCloudCert($data);
|
||
//
|
||
// $data = array();
|
||
// $data['user_id'] = "491925054435950592";
|
||
// $data['cert_base64'] = $result['certBase64'];
|
||
// $data['cert_chain_p7'] = $result['certP7'];
|
||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||
// $data['ca_pin'] = "491925054435950592";
|
||
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||
// if (empty($doctor_pharmacist_cert)){
|
||
// return fail();
|
||
// }
|
||
|
||
// 测试药师
|
||
// $data = array();
|
||
// $data['user_id'] = "534534546";
|
||
// $data['card_num'] = "410323199603261240";
|
||
// $result = $ca->getCloudCert($data);
|
||
//
|
||
// $data = array();
|
||
// $data['user_id'] = "534534546";
|
||
// $data['cert_base64'] = $result['certBase64'];
|
||
// $data['cert_chain_p7'] = $result['certP7'];
|
||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||
// $data['ca_pin'] = "534534546";
|
||
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||
// if (empty($doctor_pharmacist_cert)){
|
||
// return fail();
|
||
// }
|
||
|
||
// 测试企业
|
||
// $data = array();
|
||
// $data['user_id'] = "5345345461";
|
||
// $data['card_num'] = "91510106MABTJY4K9R";
|
||
// $result = $ca->getCloudCert($data,"Organizational");
|
||
//
|
||
// $data = array();
|
||
// $data['is_system'] = 1;
|
||
// $data['cert_base64'] = $result['certBase64'];
|
||
// $data['cert_chain_p7'] = $result['certP7'];
|
||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||
// $data['ca_pin'] = "5345345461";
|
||
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||
// if (empty($doctor_pharmacist_cert)){
|
||
// return fail();
|
||
// }
|
||
}
|
||
|
||
// 获取用户云证书数据-验证PKCS7签名
|
||
public function test_2(){
|
||
$ca = new Ca();
|
||
|
||
$params = array();
|
||
$params['user_id'] = "491925054435950592";
|
||
$params['type'] = 1;
|
||
$doctor_pharmacist_cert = UserCaCert::getOne($params);
|
||
if (empty($doctor_pharmacist_cert)){
|
||
return fail(HttpEnumCode::HTTP_ERROR,"用户数据错误");
|
||
}
|
||
|
||
// 获取云证书签名
|
||
$data = array();
|
||
$data['created_at'] = "2023-03-01 12:44:10";
|
||
$data['department_custom_name'] = "外科";
|
||
$data['user_name'] = "测试用户1";
|
||
$data['sex'] = "男";
|
||
$data['age'] = 19;
|
||
$data['allergy_history'] = "无";
|
||
$data['icd_name'] = "感冒";
|
||
$data['doctor_advice'] = "多吃药";
|
||
$data['product'] = [
|
||
[
|
||
"product_name" => "感冒药1(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药2(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药3(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药4(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药5(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
];
|
||
|
||
$result = $ca->getCertSign("491925054435950592","491925054435950592",$data);
|
||
|
||
// 验证PKCS7签名-验证无需处理,只要不返回错误即可
|
||
$ca->verifyPkcs7($result['signP7'],$data);
|
||
}
|
||
|
||
// 添加签章配置(首次)
|
||
public function test_3(){
|
||
$CaOnline = new CaOnline();
|
||
|
||
// // 下载阿里云图片
|
||
// $oss = new Oss();
|
||
//
|
||
// $filename = "applet/doctor/cert/f2abdb81-fac0-4264-bc11-aa2b6cf2761c.png";
|
||
//
|
||
// $style = "image/resize,m_lfit,w_100,h_350";
|
||
//
|
||
// $sign_image = $oss->getCusTomObjectToRAM($filename,$style);
|
||
// $sign_image = base64_encode($sign_image);
|
||
// if (!$sign_image){
|
||
// return fail(HttpEnumCode::SERVER_ERROR);
|
||
// }
|
||
//
|
||
// $sign_param = [
|
||
// [
|
||
// "llx"=> "500", // 左边底部X坐标
|
||
// "lly"=>"3015", // 左边底部Y坐标
|
||
// "urx"=>"850", // 右边上部x坐标
|
||
// "ury"=>"3115", // 右边上部y坐标
|
||
// "pageList"=>[1],
|
||
// "sealImg"=>$sign_image
|
||
// ]
|
||
// ];
|
||
// $data = array();
|
||
// $data['sign_param'] = json_encode($sign_param);
|
||
// $data['seal_img'] = $sign_image;
|
||
//
|
||
// $result = $ca->addUserSignConfig("491925054435950592","410323199603261241",$data);
|
||
|
||
// 下载阿里云图片
|
||
$oss = new Oss();
|
||
|
||
$filename = "applet/doctor/cert/f2abdb81-fac0-4264-bc11-aa2b6cf2761c.png";
|
||
|
||
$style = "image/resize,m_lfit,w_100,h_350";
|
||
|
||
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
|
||
$sign_image = base64_encode($sign_image);
|
||
if (!$sign_image){
|
||
return fail(HttpEnumCode::SERVER_ERROR);
|
||
}
|
||
|
||
$sign_param = [
|
||
[ // 医生端
|
||
"llx" => "120", // 左边底部X坐标
|
||
"lly" => "190", // 左边底部Y坐标
|
||
"urx" => "190", // 右边上部x坐标
|
||
"ury" => "140", // 右边上部y坐标
|
||
"pageList" => [1],
|
||
"sealImg" => $sign_image
|
||
],
|
||
];
|
||
$data = array();
|
||
$data['sign_param'] = json_encode($sign_param);
|
||
$data['seal_img'] = $sign_image;
|
||
|
||
$result = $CaOnline->addUserSignConfig("491925054435950592","130582199202032038",$data);
|
||
}
|
||
|
||
// 获取用户签章图片
|
||
public function test_4(){
|
||
$ca = new Ca();
|
||
$result = $ca->getFetchUserSeal("491925054435950592");
|
||
$data = urldecode($result[0]['sealImg']);
|
||
dump($data);
|
||
}
|
||
|
||
// 生成处方pdf图片
|
||
public function test_5(){
|
||
// 下载阿里云图片
|
||
// $oss = new Oss();
|
||
//
|
||
// $filename = "basic/file/prescription.jpg";
|
||
// $sign_image = $oss->getObjectToRAM($filename);
|
||
|
||
$sign_image = fopen("./extend/Ca/prescription.jpg", 'r+');
|
||
|
||
$manager = new ImageManager();
|
||
|
||
$image = $manager->make($sign_image);
|
||
|
||
$fontPath = './extend/Ca/msyh.ttf';
|
||
|
||
// 处方号
|
||
$image->text('1234567890', 1480, 540, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 日期
|
||
$image->text('2023-03-21', 354, 675, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 科室
|
||
$image->text('测试科室1', 1385, 675, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 姓名
|
||
$image->text('测试姓名', 354, 795, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 性别
|
||
$image->text('男', 1385, 790, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 年龄
|
||
$image->text('19', 354, 900, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 过敏史
|
||
$image->text('对阿莫西林过敏对阿莫西林过敏', 405, 1030, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 初步诊断
|
||
$image->text('对阿莫西林过敏对阿莫西林过敏', 445, 1145, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
// 医生建议
|
||
$image->text('没有建议', 445, 1252, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(60);
|
||
$font->align('left');
|
||
});
|
||
|
||
$data = array();
|
||
$data['product'] = [
|
||
[
|
||
"product_name" => "感冒药1(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药2(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药3(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药4(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
[
|
||
"product_name" => "感冒药5(50ml*10)",
|
||
"single_unit" => "一次一包",
|
||
"frequency_use" => "1天3次",
|
||
"single_use" => "口服",
|
||
"prescription_product_num" => "X1盒",
|
||
],
|
||
];
|
||
|
||
// 用药
|
||
foreach ($data['product'] as $key => $item){
|
||
if ($key <= 2){
|
||
$x_axis = 229;
|
||
$y_axis = 1600 + $key * 350;
|
||
}else{
|
||
$x_axis = 1240;
|
||
$y_axis = 1600 + ($key - 3) * 350;
|
||
}
|
||
|
||
|
||
$image->text($item['product_name'], $x_axis, $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+90, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(50);
|
||
$font->align('left');
|
||
});
|
||
|
||
$image->text("用法:" . $item['single_use'], $x_axis, $y_axis+180, function ($font) use($fontPath) {
|
||
$font->file($fontPath);
|
||
$font->size(50);
|
||
$font->align('left');
|
||
});
|
||
}
|
||
|
||
// 将处理后的图片重新保存到其他路径
|
||
// $image->save('./runtime/2.jpg');
|
||
|
||
$result = (string) $image->encode('png', 75);
|
||
|
||
// 图片生成pdf
|
||
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
|
||
|
||
$pdf->AddPage();
|
||
$pdf->Image('@' . $result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
|
||
|
||
$path = dirname(__DIR__, 2) . "/file/prescription/";
|
||
$a = mkdirs($path);
|
||
if (!$a){
|
||
// 目录创建失败
|
||
}
|
||
$pdf->Output(dirname(__DIR__, 2) . "/file/prescription/" . "prescription_img.pdf","F");
|
||
|
||
}
|
||
|
||
// pdf进行签章
|
||
public function test_6(){
|
||
$pdf_file = fopen("./runtime/prescription.pdf",'r');
|
||
|
||
$oss = new Oss();
|
||
|
||
$filename = "applet/doctor/cert/f2abdb81-fac0-4264-bc11-aa2b6cf2761c.png";
|
||
|
||
$style = "image/resize,m_lfit,w_100,h_350";
|
||
|
||
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
|
||
$sign_image = base64_encode($sign_image);
|
||
if (!$sign_image){
|
||
return fail(HttpEnumCode::SERVER_ERROR);
|
||
}
|
||
|
||
$sign_param = [
|
||
[ // 医生端
|
||
"llx"=>"120", // 左边底部X坐标
|
||
"lly"=>"190", // 左边底部Y坐标
|
||
"urx"=>"190", // 右边上部x坐标
|
||
"ury"=>"140", // 右边上部y坐标
|
||
"pageList"=>[1],
|
||
"sealImg"=>$sign_image
|
||
],
|
||
// [ // 药师端
|
||
// "llx"=>"350", // 左边底部X坐标
|
||
// "lly"=>"190", // 左边底部Y坐标
|
||
// "urx"=>"440", // 右边上部x坐标
|
||
// "ury"=>"140", // 右边上部y坐标
|
||
// "pageList"=>[1],
|
||
// "sealImg"=>$sign_image
|
||
// ]
|
||
];
|
||
$data = array();
|
||
$data['sign_param'] = json_encode($sign_param);
|
||
$data['pdf_file'] = $pdf_file;
|
||
|
||
$ca = new Ca();
|
||
$result = $ca->addSignPdf("491925054435950592",$data);
|
||
|
||
$file_id = $result[0]['fileId'];
|
||
|
||
$result = $ca->getSignedFile("491925054435950592",$file_id);
|
||
if (empty($result)){
|
||
return fail();
|
||
}
|
||
|
||
// $file = fopen("./runtime/test.pdf", "w") or die("Unable to open file!");
|
||
// fwrite($file, $result);
|
||
// fclose($file);
|
||
|
||
// 上传阿里云oss
|
||
|
||
$oss = new Oss();
|
||
|
||
$filename = "applet/doctor/prescription/test.pdf";
|
||
|
||
$result = $oss->putObject($filename, $result);
|
||
dump($result);
|
||
}
|
||
|
||
// 延迟队列测试
|
||
public function test_7(){
|
||
$out_trade_no = $this->request->input('out_trade_no');
|
||
if ($out_trade_no == 1){
|
||
// 增加至取消订单延迟队列
|
||
$data = array();
|
||
$data['order_no'] = 111;
|
||
$data['order_type'] = 1;
|
||
|
||
$message = new CancelUnpayOrdersDelayDirectProducer($data);
|
||
$message->setDelayMs(1000 * 5 * 1);
|
||
$producer = $this->container->get(Producer::class);
|
||
$res = $producer->produce($message);
|
||
if (!$res) {
|
||
Db::rollBack();
|
||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||
}
|
||
}else{
|
||
// 增加至取消订单延迟队列
|
||
$data = array();
|
||
$data['order_no'] = 2222;
|
||
$data['order_type'] = 1;
|
||
|
||
$message = new CancelUnpayOrdersDelayDirectProducer($data);
|
||
$message->setDelayMs(1000 * 15 * 1);
|
||
$producer = $this->container->get(Producer::class);
|
||
$res = $producer->produce($message);
|
||
if (!$res) {
|
||
Db::rollBack();
|
||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||
}
|
||
}
|
||
}
|
||
|
||
// 删除签章配置
|
||
public function test_8(){
|
||
$ca = new Ca();
|
||
$result = $ca->deleteUserSignConfig("491925054435950592");
|
||
}
|
||
|
||
// 下载签章的pdf文件
|
||
public function test_9(){
|
||
$ca = new Ca();
|
||
$result = $ca->getSignedFile("5345345461","1642769369872105473");
|
||
if (empty($result)){
|
||
return fail();
|
||
}
|
||
|
||
// 上传阿里云oss
|
||
|
||
$oss = new Oss();
|
||
|
||
$filename = "applet/doctor/prescription/111.pdf";
|
||
|
||
$result = $oss->putObject($filename, $result);
|
||
dump($result);
|
||
}
|
||
|
||
// 处方上报处方平台
|
||
public function test_11(){
|
||
|
||
$order_prescription_id = "501751534291394561";
|
||
|
||
// 获取处方数据
|
||
$params = array();
|
||
$params['order_prescription_id'] = $order_prescription_id;
|
||
$order_prescription = OrderPrescription::getOne($params);
|
||
if (empty($order_prescription)) {
|
||
throw new BusinessException("处方数据错误");
|
||
}
|
||
|
||
// 获取处方关联商品数据
|
||
$params = array();
|
||
$params['order_prescription_id'] = $order_prescription_id;
|
||
$order_prescription_product = OrderPrescriptionProduct::getList($params);
|
||
if (empty($order_prescription_product)) {
|
||
throw new BusinessException("处方药品数据错误");
|
||
}
|
||
|
||
// 获取问诊订单数据
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||
$order_inquiry = OrderInquiry::getOne($params);
|
||
if (empty($order_inquiry)) {
|
||
throw new BusinessException("处方药品数据错误");
|
||
}
|
||
|
||
// 获取商品订单数据
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||
$order_product = OrderProduct::getOne($params);
|
||
if (empty($order_product)) {
|
||
throw new BusinessException("处方药品数据错误");
|
||
}
|
||
|
||
// 获取商品订单数据
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||
$order_product_item = OrderProductItem::getList($params);
|
||
if (empty($order_product_item)) {
|
||
throw new BusinessException("处方药品数据错误");
|
||
}
|
||
|
||
$OrderPrescriptionService = new OrderPrescriptionService();
|
||
$result = $OrderPrescriptionService->reportPrescription(
|
||
$order_inquiry->toArray(),
|
||
$order_prescription->toArray(),
|
||
$order_prescription_product->toArray(),
|
||
$order_product->toArray()
|
||
);
|
||
|
||
dump($result);
|
||
}
|
||
|
||
// 上报监管平台
|
||
public function test_12(){
|
||
$regulatoryPlatform = new regulatoryPlatform();
|
||
|
||
$order_inquiry_id = "502434942043090944";
|
||
|
||
// 获取问诊订单数据
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||
$order_inquiry = OrderInquiry::getOne($params);
|
||
if (empty($order_inquiry)) {
|
||
throw new BusinessException("处方药品数据错误");
|
||
}
|
||
$order_inquiry = $order_inquiry->toArray();
|
||
|
||
// 获取医生数据
|
||
$params = array();
|
||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||
$user_doctor = UserDoctor::getOne($params);
|
||
if (empty($user_doctor)) {
|
||
throw new BusinessException("医生数据错误");
|
||
}
|
||
|
||
$params = array();
|
||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||
if (empty($user_doctor_info)) {
|
||
throw new BusinessException("医生数据错误");
|
||
}
|
||
|
||
// 获取医生自定义科室数据
|
||
$params = array();
|
||
$params['department_custom_id'] = $user_doctor['department_custom_id'];
|
||
$hospital_department_custom = HospitalDepartmentCustom::getOne($params);
|
||
if (empty($hospital_department_custom)) {
|
||
throw new BusinessException("医生自定义数据错误");
|
||
}
|
||
|
||
// 获取问诊患者数据
|
||
$params = array();
|
||
$params['family_id'] = $order_inquiry['family_id'];
|
||
$patient_family = PatientFamily::getOne($params);
|
||
if (empty($patient_family)){
|
||
throw new BusinessException("医生自定义数据错误");
|
||
}
|
||
|
||
// 获取患者问诊病例
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||
$params['status'] = 1;
|
||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||
if (empty($order_inquiry_case)){
|
||
throw new BusinessException("医生自定义数据错误");
|
||
}
|
||
|
||
// 获取问诊处方数据
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||
$params['pharmacist_audit_status'] = 1;
|
||
$params['platform_audit_status'] = 1;
|
||
$order_prescription = OrderPrescription::getOne($params);
|
||
|
||
// 网络咨询(网络门诊)服务
|
||
$arg = array();
|
||
$arg['thirdUniqueid'] = $order_inquiry['order_inquiry_id']; // 唯一标识
|
||
$arg['orgName'] = "成都金牛欣欣相照互联网医院"; // 机构名称
|
||
$arg['orgCode'] = "MA6CGUDA251010619D2112"; // 机构编码
|
||
$arg['channelName'] = "成都金牛欣欣相照互联网医院";//平台名称
|
||
$arg['section'] = $hospital_department_custom['department_name'];//科室名称
|
||
$arg['sectionCode'] = $hospital_department_custom['department_code'];//科室编码
|
||
$arg['docName'] = $user_doctor['user_name'];// 姓名(医师、护师、技师)
|
||
$arg['certificateNum'] = $user_doctor_info['qualification_cert_num']; // 执业资格证号
|
||
$arg['patientName'] = $order_inquiry['patient_name']; // 患者姓名
|
||
$arg['patientAge'] = $order_inquiry['patient_age']; // 患者年龄
|
||
$arg['patientSex'] = $order_inquiry['patient_sex'] == 0 ?: 1; // 患者性别
|
||
$arg['patientIdcardType'] = 1; // 证件类型
|
||
$arg['patientIdcardNum'] = $patient_family['id_number']; // 患者证件号码
|
||
$arg['serviceType'] = 1; // 服务类型 1网络咨询 2网络门诊
|
||
$arg['consultNo'] = $order_inquiry['inquiry_no']; // 网络咨询或网络门诊编号 订单编号
|
||
$arg['consultType'] = 1; // 咨询类别 1、图文咨询 2语音咨询3、视频咨询
|
||
$arg['consultApplyTime'] = $order_inquiry['created_at']; // 咨询申请时间
|
||
$arg['consultStartTime'] = $order_inquiry['reception_time']; // 咨询开始时间
|
||
$arg['consultEndTime'] = $order_inquiry['complete_time']; // 咨询结束时间
|
||
$arg['feeType'] = 1; // 费别 1自费 2医保
|
||
$arg['price'] = $order_inquiry['payment_amount_total']; // 咨询价格 元
|
||
$arg['isReply'] = 1; //咨询是否回复 0未回复 1已回复
|
||
$arg['patientEvaluate'] = 1; //患者满意度 1-5 1代表非常满意 5代表非常不满意
|
||
$arg['complainInfo'] = "无"; //投诉举报信息
|
||
$arg['disposeResult'] = "无"; //处理结果信息
|
||
$arg['isRiskWarn'] = 1; //是否进行诊前风险提示 0否 1是
|
||
$arg['isPatientSign'] = 1; //是否确认患者为签约对象 0否 1是
|
||
$arg['uploadTime'] = date('Y-m-d H:i:s',time()); //上传时间
|
||
$arg['medicalHistory'] = $order_inquiry_case['disease_desc']; //患者病史描述
|
||
$arg['docAdvice'] = $order_prescription['doctor_advice'] ?? "无"; // 医生建议描述 医嘱
|
||
$arg['isMark'] = 1;//是否留痕 1:代表留痕;0代表未留痕
|
||
|
||
$result = $regulatoryPlatform->uploadConsult($arg);
|
||
|
||
//上报 网络复诊服务
|
||
// $arg = array();
|
||
// $arg['thirdUniqueid'] =
|
||
//
|
||
// $result = $regulatoryPlatform->uploadFurtherConsult($arg);
|
||
dump($result);
|
||
}
|
||
|
||
// 退款
|
||
public function refund(){
|
||
$out_trade_no = $this->request->input('out_trade_no');
|
||
$params = array();
|
||
$params['order_inquiry_id'] = $out_trade_no;
|
||
$order_inquiry = OrderInquiry::getOne($params);
|
||
if (empty($order_inquiry)){
|
||
return fail();
|
||
}
|
||
|
||
// 需退款
|
||
$inquiryService = new InquiryService();
|
||
$inquiryService->inquiryRefund($out_trade_no, "取消问诊");
|
||
return success();
|
||
}
|
||
|
||
// 获取云证书-线上
|
||
public function test_14(){
|
||
$CaOnline = new CaOnline();
|
||
|
||
// // 测试医生
|
||
// $data = array();
|
||
// $data['user_id'] = "491925054435950592";
|
||
// $data['mobile'] = "13028643897";
|
||
// $data['card_name'] = "郝明明";
|
||
// $data['card_num'] = "130582199202032038";
|
||
// $data['orgDept'] = "科室名称";
|
||
// $data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||
// $data['org_number'] = "91510106MABTJY4K9R";
|
||
// $result = $CaOnline->getCloudCert($data);
|
||
//
|
||
// $data = array();
|
||
// $data['user_id'] = "491925054435950592";
|
||
// $data['type'] = 2;
|
||
// $data['cert_base64'] = $result['certBase64'];
|
||
// $data['cert_chain_p7'] = $result['certP7'];
|
||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||
// $data['ca_pin'] = "491925054435950592";
|
||
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||
// if (empty($doctor_pharmacist_cert)){
|
||
// return fail();
|
||
// }
|
||
// dump(111);
|
||
|
||
// // 测试药师
|
||
// $data = array();
|
||
// $data['user_id'] = "534534546";
|
||
// $data['mobile'] = "18812345678";
|
||
// $data['card_name'] = "仝成亮";
|
||
// $data['card_num'] = "411322199212122054";
|
||
// $data['orgDept'] = "科室名称";
|
||
// $data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||
// $data['org_number'] = "91510106MABTJY4K9R";
|
||
// $result = $CaOnline->getCloudCert($data);
|
||
//
|
||
// $data = array();
|
||
// $data['user_id'] = "534534546";
|
||
// $data['type'] = 2;
|
||
// $data['cert_base64'] = $result['certBase64'];
|
||
// $data['cert_chain_p7'] = $result['certP7'];
|
||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||
// $data['ca_pin'] = "534534546";
|
||
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||
// if (empty($doctor_pharmacist_cert)){
|
||
// return fail();
|
||
// }
|
||
|
||
// // 测试医院
|
||
// $data = array();
|
||
// $data['user_id'] = "5345345461";
|
||
// $data['mobile'] = "18221234167";
|
||
// $data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||
// $data['org_number'] = "91510106MABTJY4K9R";
|
||
//
|
||
// $result = $CaOnline->getCloudCert($data,'Organizational');
|
||
//
|
||
// $data = array();
|
||
// $data['is_system'] = 1;
|
||
// $data['type'] = 2;
|
||
// $data['cert_base64'] = $result['certBase64'];
|
||
// $data['cert_chain_p7'] = $result['certP7'];
|
||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||
// $data['ca_pin'] = "5345345461";
|
||
// $doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||
// if (empty($doctor_pharmacist_cert)){
|
||
// return fail();
|
||
// }
|
||
}
|
||
|
||
public function test_15(){
|
||
$wg = new \Hyperf\Utils\WaitGroup();
|
||
$channel = new Channel();
|
||
$wg->add(2);
|
||
|
||
co(function () use ($wg,$channel) {
|
||
defer(function() use ($wg) {
|
||
dump("执行了defer");
|
||
$wg->done();
|
||
});
|
||
|
||
dump("执行了协程1");
|
||
});
|
||
|
||
co(function () use ($wg,$channel) {
|
||
defer(function() use ($wg) {
|
||
dump("执行了defer");
|
||
$wg->done();
|
||
});
|
||
|
||
dump("执行了协程2");
|
||
});
|
||
|
||
|
||
|
||
|
||
|
||
$wg->wait();
|
||
|
||
$res = $channel->isEmpty();
|
||
if ($res){
|
||
dump("存在异常");
|
||
}
|
||
|
||
$res = $channel->close();
|
||
dump($res);
|
||
|
||
$a = $wg->count();
|
||
dump($a);
|
||
|
||
dump("执行完毕");
|
||
}
|
||
} |