新增im清除会话接口,新增定时商品订单上报处方平台
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\Product;
|
||||
use App\Model\UserCaCert;
|
||||
@@ -569,9 +571,45 @@ class OrderPrescriptionService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 上报处方平台
|
||||
public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product): array
|
||||
/**
|
||||
* 上报处方平台
|
||||
* @param string $order_product_id 商品订单id
|
||||
* @return bool
|
||||
*/
|
||||
public function reportPrescription(string $order_product_id): bool
|
||||
{
|
||||
// 获取商品订单数据
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)) {
|
||||
throw new BusinessException("上报处方平台失败:商品订单数据错误");
|
||||
}
|
||||
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_product['order_prescription_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
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_item = OrderProductItem::getList($params);
|
||||
if (empty($order_product_item)) {
|
||||
throw new BusinessException("上报处方平台失败:商品订单列表数据错误");
|
||||
}
|
||||
|
||||
$wg = new WaitGroup();
|
||||
$wg->add(8);
|
||||
|
||||
@@ -584,8 +622,13 @@ class OrderPrescriptionService extends BaseService
|
||||
$user_pharmacist_info = []; // 药师详数据
|
||||
$order_inquiry_case = []; // 病例数据
|
||||
|
||||
// 获取就诊患者用户数据
|
||||
$user_id = $order_inquiry['user_id'];
|
||||
$doctor_id = $order_prescription['doctor_id'];
|
||||
$family_id = $order_inquiry['family_id'];
|
||||
$pharmacist_id = $order_prescription['pharmacist_id'];
|
||||
$order_inquiry_id = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
// 获取就诊患者用户数据
|
||||
co(function () use ($wg, &$user, $user_id) {
|
||||
$params = array();
|
||||
$params['user_id'] = $user_id;
|
||||
@@ -595,7 +638,6 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取家庭成员-基本信息
|
||||
$family_id = $order_inquiry['family_id'];
|
||||
co(function () use ($wg, &$patient_family, $family_id) {
|
||||
$params = array();
|
||||
$params['family_id'] = $family_id;
|
||||
@@ -617,7 +659,6 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取医生数据
|
||||
$doctor_id = $order_prescription['doctor_id'];
|
||||
co(function () use ($wg, &$user_doctor, $doctor_id) {
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
@@ -628,7 +669,6 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取医生详情数据
|
||||
$doctor_id = $order_prescription['doctor_id'];
|
||||
co(function () use ($wg, &$user_doctor_info, $doctor_id) {
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
@@ -639,7 +679,6 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取药师数据
|
||||
$pharmacist_id = $order_prescription['pharmacist_id'];
|
||||
co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $pharmacist_id;
|
||||
@@ -650,7 +689,6 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取药师详情数据
|
||||
$pharmacist_id = $order_prescription['pharmacist_id'];
|
||||
co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $pharmacist_id;
|
||||
@@ -661,7 +699,6 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取病例数据
|
||||
$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;
|
||||
@@ -764,11 +801,11 @@ class OrderPrescriptionService extends BaseService
|
||||
$arg['presList'][0]['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: "无"; // 过敏史
|
||||
|
||||
// 药品数据
|
||||
foreach ($order_prescription_product as $key => $item) {
|
||||
foreach ($order_product_item as $key => $item) {
|
||||
// 获取商品数据
|
||||
$pamras = array();
|
||||
$pamras['product_id'] = $item['product_id'];
|
||||
$product = Product::getOne($pamras);
|
||||
$params = array();
|
||||
$params['product_id'] = $item['product_id'];
|
||||
$product = Product::getOne($params);
|
||||
if (empty($product)) {
|
||||
throw new BusinessException("药品数据错误");
|
||||
}
|
||||
@@ -778,7 +815,7 @@ class OrderPrescriptionService extends BaseService
|
||||
$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]['packingCount'] = $item['amount']; // 药品数量
|
||||
$arg['presList'][0]['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量
|
||||
$arg['presList'][0]['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
|
||||
$arg['presList'][0]['drugList'][$key]['singleDosage'] = 1; // 单次用量
|
||||
@@ -792,29 +829,23 @@ class OrderPrescriptionService extends BaseService
|
||||
$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]['drugCount'] = $item['amount']; // 药品数量
|
||||
$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']);
|
||||
Log::getInstance()->info("上报处方平台失败:" , $result['resultDesc']);
|
||||
return false;
|
||||
}
|
||||
throw new BusinessException("上报处方平台失败");
|
||||
|
||||
Log::getInstance()->info("上报处方平台失败:操作编码:" , $result['resultCode']);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $arg;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user