修改消息推送

This commit is contained in:
2023-04-04 18:39:10 +08:00
parent ad119be0e8
commit 9c44f13498
11 changed files with 351 additions and 277 deletions
+148 -99
View File
@@ -18,8 +18,10 @@ use App\Model\UserDoctor;
use App\Model\UserDoctorInfo;
use App\Model\UserPharmacist;
use App\Model\UserPharmacistInfo;
use App\Utils\Log;
use Extend\Alibaba\Oss;
use Extend\Ca\Ca;
use Extend\Prescription\Prescription;
use Hyperf\Contract\LengthAwarePaginatorInterface;
use Hyperf\Utils\WaitGroup;
use Intervention\Image\ImageManager;
@@ -226,7 +228,7 @@ class OrderPrescriptionService extends BaseService
// 处理疾病数据
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
if (!empty($icd_name)) {
if (count($icd_name > 1)) {
if (count($icd_name) > 1) {
$icd_name = implode(';', $icd_name);
} else {
$icd_name = $icd_name[0];
@@ -562,13 +564,12 @@ class OrderPrescriptionService extends BaseService
public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product)
{
$wg = new WaitGroup();
$wg->add(2);
$wg->add(8);
$user = []; // 就诊患者用户数据
$patient_family = []; // 家庭成员-基本信息
$order_prescription_icd = []; // 处方关联疾病数据
$user_doctor = []; // 医生数据
$hospital_department_custom = []; // 医生科室
$user_doctor_info = []; // 医生详情数据
$user_pharmacist = []; // 药师数据
$user_pharmacist_info = []; // 药师详数据
@@ -576,18 +577,17 @@ class OrderPrescriptionService extends BaseService
// 获取就诊患者用户数据
$user_id = $order_inquiry['user_id'];
co(function () use ($wg,&$user,$user_id) {
co(function () use ($wg, &$user, $user_id) {
$params = array();
$params['user_id'] = $user_id;
$user = User::getOne($params);
$user = User::getOne($params)->toArray();
// 计数器减一
$wg->done();
});
// 获取家庭成员-基本信息
$family_id = $order_inquiry['family_id'];
co(function () use ($wg,&$patient_family,$family_id) {
co(function () use ($wg, &$patient_family, $family_id) {
$params = array();
$params['family_id'] = $family_id;
$patient_family = PatientFamily::getOne($params);
@@ -598,7 +598,7 @@ class OrderPrescriptionService extends BaseService
// 获取处方关联疾病数据
$order_prescription_id = $order_prescription['order_prescription_id'];
co(function () use ($wg,&$order_prescription_icd,$order_prescription_id) {
co(function () use ($wg, &$order_prescription_icd, $order_prescription_id) {
$params = array();
$params['order_prescription_id'] = $order_prescription_id;
$order_prescription_icd = OrderPrescriptionIcd::getList($params);
@@ -607,6 +607,63 @@ class OrderPrescriptionService extends BaseService
$wg->done();
});
// 获取医生数据
$doctor_id = $order_prescription['doctor_id'];
co(function () use ($wg, &$user_doctor, $doctor_id) {
$params = array();
$params['doctor_id'] = $doctor_id;
$user_doctor = UserDoctor::getOne($params);
// 计数器减一
$wg->done();
});
// 获取医生详情数据
$doctor_id = $order_prescription['doctor_id'];
co(function () use ($wg, &$user_doctor_info, $doctor_id) {
$params = array();
$params['doctor_id'] = $doctor_id;
$user_doctor_info = UserDoctorInfo::getOne($params);
// 计数器减一
$wg->done();
});
// 获取药师数据
$pharmacist_id = $order_prescription['pharmacist_id'];
co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
$params = array();
$params['pharmacist_id'] = $pharmacist_id;
$user_pharmacist = UserPharmacist::getOne($params);
// 计数器减一
$wg->done();
});
// 获取药师详情数据
$pharmacist_id = $order_prescription['pharmacist_id'];
co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
$params = array();
$params['pharmacist_id'] = $pharmacist_id;
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
// 计数器减一
$wg->done();
});
// 获取病例数据
$order_inquiry_id = $order_inquiry['order_inquiry_id'];
co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) {
$params = array();
$params['order_inquiry_id'] = $order_inquiry_id;
$params['status'] = 1;
$order_inquiry_case = OrderInquiryCase::getOne($params);
// 计数器减一
$wg->done();
});
$wg->wait();
if (empty($user)) {
throw new BusinessException("用户数据错误");
@@ -617,6 +674,21 @@ class OrderPrescriptionService extends BaseService
if (empty($order_prescription_icd)) {
throw new BusinessException("处方疾病数据错误");
}
if (empty($user_doctor)) {
throw new BusinessException("医生数据错误");
}
if (empty($user_doctor_info)) {
throw new BusinessException("医生详情数据错误");
}
if (empty($user_pharmacist)) {
throw new BusinessException("药师数据错误");
}
if (empty($user_pharmacist_info)) {
throw new BusinessException("药师详情数据错误");
}
if (empty($order_inquiry_case)) {
throw new BusinessException("病例数据错误");
}
// 处理疾病数据
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
@@ -630,14 +702,6 @@ class OrderPrescriptionService extends BaseService
$icd_name = "";
}
// 获取医生数据
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
$user_doctor = UserDoctor::getOne($params);
if (empty($user_doctor)) {
throw new BusinessException("医生数据错误");
}
// 获取医生科室
$params = array();
$params['department_custom_id'] = $user_doctor['department_custom_id'];
@@ -646,46 +710,14 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException("医生科室数据错误");
}
// 获取医生详情数据
$params = array();
$params['doctor_id'] = $order_prescription['doctor_id'];
$user_doctor_info = UserDoctorInfo::getOne($params);
if (empty($user_doctor_info)) {
throw new BusinessException("医生详情数据错误");
}
// 获取药师数据
$params = array();
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
$user_pharmacist = UserPharmacist::getOne($params);
if (empty($user_pharmacist)) {
throw new BusinessException("药师数据错误");
}
// 获取药师详情数据
$params = array();
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
if (empty($user_pharmacist_info)) {
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("病例数据错误");
}
$arg = array();
$arg['terminalCode'] = "JG-10009";
$arg['orderNo'] = $order_product['order_product_no']; // 支付流水号
$arg['transactNo'] = $order_product['escrow_trade_no']; // 支付流水号
$arg['terminalCode'] = "ZD-10003";
$arg['orderNo'] = $order_product['order_product_no']; // 订单编号
$arg['transactNo'] = $order_product['escrow_trade_no']; // 流水单号
$arg['payDate'] = $order_product['pay_time']; // 支付时间
$arg['money'] = $order_product['payment_amount_total']; // 订单金额
$arg['takeTypeCode'] = 2; // 取货方式 1 自提 2 快递,目 前只支持快递,传 固定值 2
$arg['freight'] = $order_product['logistics_fee']; // 运费(单位:元)
$arg['takeTypeCode'] = 2; // 取货方式 1 自提 2 快递,目前只支持快递,传固定值 2
$arg['buyerName'] = $order_product['consignee_name'];// 收货人姓名
$arg['buyerPhone'] = $order_product['consignee_tel'];// 收货人联系方式
$arg['buyerAddress'] = $order_product['address'];// 收货人地址
@@ -695,32 +727,32 @@ class OrderPrescriptionService extends BaseService
$arg['cityName'] = $order_product['city']; // 收货地址(市) 名称
$arg['districtCode'] = $order_product['county_id']; // 收货地址(区 县)编码
$arg['districtName'] = $order_product['county']; // 收货地址(区 县)名称
$arg['freight'] = $order_product['logistics_fee']; // 运费(单位:元)
$arg['prescriptionNo'] = $order_prescription['prescription_code']; // 处方编号
$arg['prescriptionSubType'] = 1; // 处方类型 0:无类型 1:普 通处方 2:儿科处 方
$arg['patientName'] = $order_prescription['patient_name']; // 就诊人姓名
$arg['patientPhone'] = $user['mobile']; // 就诊人联系方式
$arg['idCard'] = $patient_family['id_number']; // 身份证号
$arg['advice'] = $order_prescription['doctor_advice'] ?: ""; // 医嘱
$arg['diagnosisName'] = $icd_name ?: ""; // 诊断
$arg['thirdDoctorName'] = $user_doctor['user_name']; // 开方医生姓名
$arg['thirdDeptName'] = $hospital_department_custom['department_name'] ?: ""; // 开方科室名称
$arg['thirdDoctorNameImg'] = addAliyunOssWebsite($user_doctor_info['sign_image']); // 开方医生签名链接
$arg['prescriptionTime'] = $order_prescription['doctor_created_time']; // 开方时间
$arg['thirdFirstPharmacist'] = $user_pharmacist['user_name']; // 初审药师姓名
$arg['thirdFirstPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 初审药师签名链接
$arg['thirdFirstTime'] = $order_prescription['pharmacist_verify_time']; // 初审时间
$arg['thirdLastPharmacist'] = $user_pharmacist['user_name']; // 终审药师姓名
$arg['thirdLastPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 终审药师签名 链接
$arg['ThirdLastTime'] = $order_prescription['pharmacist_verify_time']; // 终审时间
$arg['thirdSignImg'] = addAliyunOssWebsite("/basic/file/hospital_signature.png"); // 处方签章链接
$arg['referenceCharge'] = $order_product['amount_total']; // 处方费用(不包含运费)
$arg['chiefComplaint'] = $order_inquiry_case['disease_desc'] ?: ""; // 主诉
$arg['historyPresent'] = $order_inquiry_case['disease_class_name'] ?: ""; // 现病史
$arg['pastHistory'] = $order_inquiry_case['family_history'] ?: "无"; // 既往史
$arg['physicalExamination'] = "无"; // 体格检查
$arg['supplementaryExamination'] = "无"; // 辅助检查
$arg['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: "无"; // 过敏史
$arg['presList'][0]['prescriptionNo'] = $order_prescription['prescription_code']; // 处方编号
$arg['presList'][0]['prescriptionSubType'] = 1; // 处方类型 0:无类型 1:普 通处方 2:儿科处 方
$arg['presList'][0]['patientName'] = $order_prescription['patient_name']; // 就诊人姓名
$arg['presList'][0]['patientPhone'] = $user['mobile']; // 就诊人联系方式
$arg['presList'][0]['idCard'] = $patient_family['id_number']; // 身份证号
$arg['presList'][0]['advice'] = $order_prescription['doctor_advice'] ?: ""; // 医嘱
$arg['presList'][0]['diagnosisName'] = $icd_name ?: ""; // 诊断
$arg['presList'][0]['thirdDoctorName'] = $user_doctor['user_name']; // 开方医生姓名
$arg['presList'][0]['thirdDeptName'] = $hospital_department_custom['department_name'] ?: ""; // 开方科室名称
$arg['presList'][0]['thirdDoctorNameImg'] = addAliyunOssWebsite($user_doctor_info['sign_image']); // 开方医生签名链接
$arg['presList'][0]['prescriptionTime'] = $order_prescription['doctor_created_time']; // 开方时间
$arg['presList'][0]['thirdFirstPharmacist'] = $user_pharmacist['user_name']; // 初审药师姓名
$arg['presList'][0]['thirdFirstPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 初审药师签名链接
$arg['presList'][0]['thirdFirstTime'] = $order_prescription['pharmacist_verify_time']; // 初审时间
$arg['presList'][0]['thirdLastPharmacist'] = $user_pharmacist['user_name']; // 终审药师姓名
$arg['presList'][0]['thirdLastPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 终审药师签名 链接
$arg['presList'][0]['ThirdLastTime'] = $order_prescription['pharmacist_verify_time']; // 终审时间
$arg['presList'][0]['thirdSignImg'] = addAliyunOssWebsite("/basic/file/hospital_signature.png"); // 处方签章链接
$arg['presList'][0]['referenceCharge'] = $order_product['amount_total']; // 处方费用(不包含运费)
$arg['presList'][0]['chiefComplaint'] = $order_inquiry_case['disease_desc'] ?: ""; // 主诉
$arg['presList'][0]['historyPresent'] = $order_inquiry_case['disease_class_name'] ?: ""; // 现病史
$arg['presList'][0]['pastHistory'] = $order_inquiry_case['family_history'] ?: "无"; // 既往史
$arg['presList'][0]['physicalExamination'] = "无"; // 体格检查
$arg['presList'][0]['supplementaryExamination'] = "无"; // 辅助检查
$arg['presList'][0]['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: "无"; // 过敏史
// 药品数据
foreach ($order_prescription_product as $key => $item) {
@@ -732,29 +764,46 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException("药品数据错误");
}
$arg['drugList'][$key]['drugCode'] = $product['product_pharmacy_code']; // 药品编码
$arg['drugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
$arg['drugList'][$key]['drugName'] = $product['product_name']; // 药品名称
$arg['drugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
$arg['drugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['drugList'][$key]['packingCount'] = $item['prescription_product_num']; // 药品数量
$arg['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量
$arg['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
$arg['drugList'][$key]['singleDosage'] = $product['single_unit']; // 单次用量
$arg['drugList'][$key]['singleDosageUnit'] = ""; // 单次用量单位
$arg['drugList'][$key]['useName'] = $product['single_use']; // 用法名称
$arg['drugList'][$key]['frequencyName'] = $product['frequency_use']; // 频次名称
$arg['drugList'][$key]['useDays'] = $product['available_days']; // 使用天数
$arg['presList'][0]['drugList'][$key]['drugCode'] = $product['product_platform_code']; // 药品编码
$arg['presList'][0]['drugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
$arg['presList'][0]['drugList'][$key]['drugName'] = $product['product_name']; // 药品名称
$arg['presList'][0]['drugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
$arg['presList'][0]['drugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['presList'][0]['drugList'][$key]['packingCount'] = $item['prescription_product_num']; // 药品数量
$arg['presList'][0]['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量
$arg['presList'][0]['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
$arg['presList'][0]['drugList'][$key]['singleDosage'] = 1; // 单次用量
$arg['presList'][0]['drugList'][$key]['singleDosageUnit'] = "片"; // 单次用量单位
$arg['presList'][0]['drugList'][$key]['useName'] = $product['single_use']; // 用法名称
$arg['presList'][0]['drugList'][$key]['frequencyName'] = $product['frequency_use']; // 频次名称
$arg['presList'][0]['drugList'][$key]['useDays'] = $product['available_days']; // 使用天数
$arg['orderDrugList'][$key]['drugCode'] = $product['product_pharmacy_code']; // 药品编码
$arg['orderDrugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
$arg['orderDrugList'][$key]['drugName'] = $product['product_name']; // 药品名称
$arg['orderDrugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
$arg['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['orderDrugList'][$key]['drugCount'] = $item['prescription_product_num']; // 药品数量
$arg['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
$arg['presList'][0]['orderDrugList'][$key]['drugCode'] = $product['product_platform_code']; // 药品编码
$arg['presList'][0]['orderDrugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
$arg['presList'][0]['orderDrugList'][$key]['drugName'] = $product['product_name']; // 药品名称
$arg['presList'][0]['orderDrugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
$arg['presList'][0]['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['presList'][0]['orderDrugList'][$key]['drugCount'] = $item['prescription_product_num']; // 药品数量
$arg['presList'][0]['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
}
Log::getInstance()->info(json_encode($arg,JSON_UNESCAPED_UNICODE));
dump($arg);
$Prescription = new Prescription();
$result = $Prescription->reportPrescription($arg);
dump($result);
if ($result['resultCode'] != "1000"){
if ($result['resultCode'] == "1008"){
// 没有相关药品或库存不足
}
if(!empty($result['resultDesc'])){
throw new BusinessException($result['resultDesc']);
}
throw new BusinessException("上报处方平台失败");
}
return $arg;
}