diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 6354093..553b3c8 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -165,11 +165,14 @@ class InquiryService extends BaseService } } - // 检测当前是否符合系统问诊时间 - $inquiryService = new InquiryService(); - $is_system_time_pass = $inquiryService->checkSystemInquiryTime($request_params['inquiry_type']); - if (!$is_system_time_pass && $request_params['inquiry_type'] == 4) { - return fail(HttpEnumCode::HTTP_ERROR, "当前非医生接诊时间"); + // 问诊购药 + if ($request_params['inquiry_type'] == 4){ + // 检测当前是否符合系统问诊时间 + $inquiryService = new InquiryService(); + $is_system_time_pass = $inquiryService->checkSystemInquiryTime($request_params['inquiry_type']); + if (!$is_system_time_pass) { + return fail(HttpEnumCode::HTTP_ERROR, "当前非医生接诊时间"); + } } // 定义优惠卷金额默认值 diff --git a/app/Services/PatientDoctorService.php b/app/Services/PatientDoctorService.php index 8dcb9c7..a635c6f 100644 --- a/app/Services/PatientDoctorService.php +++ b/app/Services/PatientDoctorService.php @@ -318,8 +318,9 @@ class PatientDoctorService extends BaseService } } - // 检测公益问诊-当前患者问诊次数(24小时内两次公益问诊) - if ($inquiry_type == 4){ + // 公益问诊 + if ($inquiry_type == 3){ + // 检测公益问诊-当前患者问诊次数(24小时内两次公益问诊) $params = array(); $params['patient_id'] = $user_info['client_user_id']; $params['inquiry_type'] = $inquiry_type; @@ -335,12 +336,13 @@ class PatientDoctorService extends BaseService } } - // 检测当前是否符合系统问诊时间 - $inquiryService = new InquiryService(); - $is_system_time_pass = $inquiryService->checkSystemInquiryTime($inquiry_type); - if (!$is_system_time_pass){ - // 非坐班时间 - if ($inquiry_type == 4){ + // 问诊购药 + if ($inquiry_type == 4){ + // 检测当前是否符合系统问诊时间 + $inquiryService = new InquiryService(); + $is_system_time_pass = $inquiryService->checkSystemInquiryTime($inquiry_type); + if (!$is_system_time_pass){ + // 非坐班时间 // 问诊购药非坐班时间不允许接诊 $result['status'] = 3; $result['data'] = ""; @@ -349,7 +351,7 @@ class PatientDoctorService extends BaseService } } - // 检测快速、购药问诊是否由可分配医生 + // 检测快速、购药问诊是否有可分配医生 if ($inquiry_type == 2 || $inquiry_type == 4){ $UserDoctorService = new UserDoctorService(); $doctor_id = $UserDoctorService->getInquiryAssignDoctor($inquiry_type,$user_info['client_user_id'],$is_system_time_pass); @@ -362,7 +364,7 @@ class PatientDoctorService extends BaseService return success($result); } } - }catch(\Exception $e){ + }catch(\Throwable $e){ // 错误不做处理,此处只是检测 return success($result); } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 40b19a7..8be6bb1 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -1088,217 +1088,215 @@ class UserDoctorService extends BaseService * 修改处方 * 暂时去除修改处方 * @return array - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function putPrescription(): array { - return fail(HttpEnumCode::HTTP_ERROR, "操作失败"); - - $user_info = $this->request->getAttribute("userInfo") ?? []; - - $order_prescription_id = $this->request->input('order_prescription_id'); - $prescription_icd = $this->request->input('prescription_icd'); - $doctor_advice = $this->request->input('doctor_advice'); - $prescription_product = $this->request->input('prescription_product'); - - // 获取医生信息 - $params = array(); - $params['doctor_id'] = $user_info['client_user_id']; - - $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)) { - return fail(HttpEnumCode::HTTP_ERROR, "非法医生"); - } - - $res = $this->checkDoctorAuth($user_doctor); - if ($res !== true) { - return fail(HttpEnumCode::HTTP_ERROR, $res); - } - - // 获取处方数据 - $params = array(); - $params['order_prescription_id'] = $order_prescription_id; - $params['doctor_id'] = $user_info['client_user_id']; - $order_prescription = OrderPrescription::getOne($params); - if (empty($order_prescription)) { - return fail(); - } - - // 检测处方状态 - if ($order_prescription['prescription_status'] == 4) { - // 已使用 - return fail(HttpEnumCode::HTTP_ERROR, "处方已使用,无法更改"); - } - - if ($order_prescription['is_delete'] == 1) { - // 已使用 - return fail(HttpEnumCode::HTTP_ERROR, "处方已删除,无法更改"); - } - - if ($order_prescription['prescription_status'] == 1 && $order_prescription['pharmacist_audit_status'] == 0) { - // 已使用 - return fail(HttpEnumCode::HTTP_ERROR, "处方审核中,不允许修改"); - } - - // 获取处方订单数据 - $params = array(); - $params['order_inquiry_id'] = $order_prescription['order_inquiry_id']; - $order_inquiry = OrderInquiry::getOne($params); - if (empty($order_inquiry)){ - return fail(HttpEnumCode::SERVER_ERROR,"问诊订单数据为空"); - } - - if ($order_inquiry['inquiry_status'] == 5){ - return fail(HttpEnumCode::HTTP_ERROR,"问诊已完成,无法重开处方"); - } - - if ($order_inquiry['inquiry_status'] == 6){ - return fail(HttpEnumCode::HTTP_ERROR,"问诊已结束,无法重开处方"); - } - - if ($order_inquiry['inquiry_status'] == 7){ - return fail(HttpEnumCode::HTTP_ERROR,"问诊已取消,无法重开处方"); - } - - if ($order_inquiry['inquiry_status'] != 4){ - return fail(HttpEnumCode::HTTP_ERROR,"问诊状态错误,无法重开处方"); - } - - Db::beginTransaction(); - - try { - // 删除订单-处方关联疾病表 - $params = array(); - $params['order_prescription_id'] = $order_prescription_id; - OrderPrescriptionIcd::deleteOrderPrescriptionIcd($params); - - // 处方疾病数据 - foreach ($prescription_icd as $item) { - // 获取疾病信息 - $params = array(); - $params['icd_id'] = $item; - $disease_class_icd = DiseaseClassIcd::getOne($params); - if (empty($disease_class_icd)) { - Db::rollBack(); - return fail(); - } - - // 新增处方疾病 - $data = array(); - $data['order_prescription_id'] = $order_prescription_id; - $data['icd_id'] = $item; - $data['icd_name'] = $disease_class_icd['icd_name']; - $data['icd_code'] = $disease_class_icd['icd_code']; - $order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data); - if (empty($order_prescription_icd)) { - Db::rollBack(); - return fail(); - } - - unset($disease_class_icd); - } - - // 删除订单-处方药品表 - $params = array(); - $params['order_prescription_id'] = $order_prescription_id; - OrderPrescriptionProduct::deleteOrderPrescriptionProduct($params); - - // 处方商品数据 - $product_name = ""; - foreach ($prescription_product as $item) { - // 获取商品数据 - $params = array(); - $params['product_id'] = $item['product_id']; - $product = Product::getWithAmountOne($params); - if (empty($product)) { - Db::rollBack(); - return fail(); - } - - if (empty($product['ProductPlatformAmount'])) { - // 无药品库存数据 - Db::rollBack(); - return fail(); - } - - // 检测药品库存数据 - if ($item['prescription_product_num'] > $product['ProductPlatformAmount']['stock']) { - // 库存不足 - Db::rollBack(); - return fail(HttpEnumCode::HTTP_ERROR, "药品" . $product['product_name'] . "库存不足"); - } - - // 新增订单-处方药品表 - $data = array(); - $data['order_prescription_id'] = $order_prescription_id; - $data['product_id'] = $item['product_id']; - $data['prescription_product_num'] = $item['prescription_product_num']; - $data['product_name'] = $product['product_name']; - $data['product_spec'] = $product['product_spec']; - $data['license_number'] = $product['license_number']; - $data['manufacturer'] = $product['manufacturer']; - $data['single_unit'] = $item['single_unit'] ?? $product['single_unit']; - $data['single_use'] = $item['single_use'] ?? $product['single_use']; - $data['packaging_unit'] = $item['packaging_unit'] ?? $product['packaging_unit']; - $data['frequency_use'] = $item['frequency_use'] ?? $product['frequency_use']; - $data['available_days'] = $item['available_days'] ?? $product['available_days']; - $order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data); - if (empty($order_prescription_product)) { - Db::rollBack(); - return fail(); - } - - $product_name = $product_name . ";" . $product['product_name']; - unset($product); - } - - $OrderPrescriptionService = new OrderPrescriptionService(); - $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']); - if (empty($prescription_open_result['prescription_img_url'])){ - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); - } - - // 修改处方表 - $data = array(); - $data['prescription_img'] = $prescription_open_result['prescription_img_url']; - $data['doctor_created_time'] = date('Y-m-d H:i:s',time()); - $data['prescription_status'] = 1; // 处方状态(1:待审核 3:待使用 4:已失效 5:已使用) - $data['pharmacist_audit_status'] = 0; // 药师审核驳回原因 - $data['pharmacist_fail_reason'] = ""; // 药师审核驳回原因 - $data['platform_audit_status'] = 0; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回) - $data['platform_fail_reason'] = ""; // 处方平台驳回原因 - $data['doctor_created_time'] = date('Y-m-d H:i:s',time()); - if ($order_prescription['doctor_advice'] != $doctor_advice) { - $data['doctor_advice'] = $doctor_advice; // 医嘱 - } - - $params = array(); - $params['order_prescription_id'] = $order_prescription['order_prescription_id']; - OrderPrescription::edit($params,$data); - - // 发送IM消息-处方已开具 - $imService = new ImService(); - $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],6); - - // 加入分配药师队列 - $data = array(); - $data['order_prescription_id'] = $order_prescription_id; - - $message = new AssignPharmacistProducer($data); - $producer = ApplicationContext::getContainer()->get(Producer::class); - $result = $producer->produce($message); - if (!$result) { - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR); - } - - Db::commit(); - } catch (\Exception $e) { - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); - } +// return fail(HttpEnumCode::HTTP_ERROR, "操作失败"); +// +// $user_info = $this->request->getAttribute("userInfo") ?? []; +// +// $order_prescription_id = $this->request->input('order_prescription_id'); +// $prescription_icd = $this->request->input('prescription_icd'); +// $doctor_advice = $this->request->input('doctor_advice'); +// $prescription_product = $this->request->input('prescription_product'); +// +// // 获取医生信息 +// $params = array(); +// $params['doctor_id'] = $user_info['client_user_id']; +// +// $user_doctor = UserDoctor::getOne($params); +// if (empty($user_doctor)) { +// return fail(HttpEnumCode::HTTP_ERROR, "非法医生"); +// } +// +// $res = $this->checkDoctorAuth($user_doctor); +// if ($res !== true) { +// return fail(HttpEnumCode::HTTP_ERROR, $res); +// } +// +// // 获取处方数据 +// $params = array(); +// $params['order_prescription_id'] = $order_prescription_id; +// $params['doctor_id'] = $user_info['client_user_id']; +// $order_prescription = OrderPrescription::getOne($params); +// if (empty($order_prescription)) { +// return fail(); +// } +// +// // 检测处方状态 +// if ($order_prescription['prescription_status'] == 4) { +// // 已使用 +// return fail(HttpEnumCode::HTTP_ERROR, "处方已使用,无法更改"); +// } +// +// if ($order_prescription['is_delete'] == 1) { +// // 已使用 +// return fail(HttpEnumCode::HTTP_ERROR, "处方已删除,无法更改"); +// } +// +// if ($order_prescription['prescription_status'] == 1 && $order_prescription['pharmacist_audit_status'] == 0) { +// // 已使用 +// return fail(HttpEnumCode::HTTP_ERROR, "处方审核中,不允许修改"); +// } +// +// // 获取处方订单数据 +// $params = array(); +// $params['order_inquiry_id'] = $order_prescription['order_inquiry_id']; +// $order_inquiry = OrderInquiry::getOne($params); +// if (empty($order_inquiry)){ +// return fail(HttpEnumCode::SERVER_ERROR,"问诊订单数据为空"); +// } +// +// if ($order_inquiry['inquiry_status'] == 5){ +// return fail(HttpEnumCode::HTTP_ERROR,"问诊已完成,无法重开处方"); +// } +// +// if ($order_inquiry['inquiry_status'] == 6){ +// return fail(HttpEnumCode::HTTP_ERROR,"问诊已结束,无法重开处方"); +// } +// +// if ($order_inquiry['inquiry_status'] == 7){ +// return fail(HttpEnumCode::HTTP_ERROR,"问诊已取消,无法重开处方"); +// } +// +// if ($order_inquiry['inquiry_status'] != 4){ +// return fail(HttpEnumCode::HTTP_ERROR,"问诊状态错误,无法重开处方"); +// } +// +// Db::beginTransaction(); +// +// try { +// // 删除订单-处方关联疾病表 +// $params = array(); +// $params['order_prescription_id'] = $order_prescription_id; +// OrderPrescriptionIcd::deleteOrderPrescriptionIcd($params); +// +// // 处方疾病数据 +// foreach ($prescription_icd as $item) { +// // 获取疾病信息 +// $params = array(); +// $params['icd_id'] = $item; +// $disease_class_icd = DiseaseClassIcd::getOne($params); +// if (empty($disease_class_icd)) { +// Db::rollBack(); +// return fail(); +// } +// +// // 新增处方疾病 +// $data = array(); +// $data['order_prescription_id'] = $order_prescription_id; +// $data['icd_id'] = $item; +// $data['icd_name'] = $disease_class_icd['icd_name']; +// $data['icd_code'] = $disease_class_icd['icd_code']; +// $order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data); +// if (empty($order_prescription_icd)) { +// Db::rollBack(); +// return fail(); +// } +// +// unset($disease_class_icd); +// } +// +// // 删除订单-处方药品表 +// $params = array(); +// $params['order_prescription_id'] = $order_prescription_id; +// OrderPrescriptionProduct::deleteOrderPrescriptionProduct($params); +// +// // 处方商品数据 +// $product_name = ""; +// foreach ($prescription_product as $item) { +// // 获取商品数据 +// $params = array(); +// $params['product_id'] = $item['product_id']; +// $product = Product::getWithAmountOne($params); +// if (empty($product)) { +// Db::rollBack(); +// return fail(); +// } +// +// if (empty($product['ProductPlatformAmount'])) { +// // 无药品库存数据 +// Db::rollBack(); +// return fail(); +// } +// +// // 检测药品库存数据 +// if ($item['prescription_product_num'] > $product['ProductPlatformAmount']['stock']) { +// // 库存不足 +// Db::rollBack(); +// return fail(HttpEnumCode::HTTP_ERROR, "药品" . $product['product_name'] . "库存不足"); +// } +// +// // 新增订单-处方药品表 +// $data = array(); +// $data['order_prescription_id'] = $order_prescription_id; +// $data['product_id'] = $item['product_id']; +// $data['prescription_product_num'] = $item['prescription_product_num']; +// $data['product_name'] = $product['product_name']; +// $data['product_spec'] = $product['product_spec']; +// $data['license_number'] = $product['license_number']; +// $data['manufacturer'] = $product['manufacturer']; +// $data['single_unit'] = $item['single_unit'] ?? $product['single_unit']; +// $data['single_use'] = $item['single_use'] ?? $product['single_use']; +// $data['packaging_unit'] = $item['packaging_unit'] ?? $product['packaging_unit']; +// $data['frequency_use'] = $item['frequency_use'] ?? $product['frequency_use']; +// $data['available_days'] = $item['available_days'] ?? $product['available_days']; +// $order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data); +// if (empty($order_prescription_product)) { +// Db::rollBack(); +// return fail(); +// } +// +// $product_name = $product_name . ";" . $product['product_name']; +// unset($product); +// } +// +// $OrderPrescriptionService = new OrderPrescriptionService(); +// $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']); +// if (empty($prescription_open_result['prescription_img_url'])){ +// Db::rollBack(); +// return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); +// } +// +// // 修改处方表 +// $data = array(); +// $data['prescription_img'] = $prescription_open_result['prescription_img_url']; +// $data['doctor_created_time'] = date('Y-m-d H:i:s',time()); +// $data['prescription_status'] = 1; // 处方状态(1:待审核 3:待使用 4:已失效 5:已使用) +// $data['pharmacist_audit_status'] = 0; // 药师审核驳回原因 +// $data['pharmacist_fail_reason'] = ""; // 药师审核驳回原因 +// $data['platform_audit_status'] = 0; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回) +// $data['platform_fail_reason'] = ""; // 处方平台驳回原因 +// $data['doctor_created_time'] = date('Y-m-d H:i:s',time()); +// if ($order_prescription['doctor_advice'] != $doctor_advice) { +// $data['doctor_advice'] = $doctor_advice; // 医嘱 +// } +// +// $params = array(); +// $params['order_prescription_id'] = $order_prescription['order_prescription_id']; +// OrderPrescription::edit($params,$data); +// +// // 发送IM消息-处方已开具 +// $imService = new ImService(); +// $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],6); +// +// // 加入分配药师队列 +// $data = array(); +// $data['order_prescription_id'] = $order_prescription_id; +// +// $message = new AssignPharmacistProducer($data); +// $producer = ApplicationContext::getContainer()->get(Producer::class); +// $result = $producer->produce($message); +// if (!$result) { +// Db::rollBack(); +// return fail(HttpEnumCode::SERVER_ERROR); +// } +// +// Db::commit(); +// } catch (\Exception $e) { +// Db::rollBack(); +// return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); +// } return success(); } @@ -2583,19 +2581,29 @@ class UserDoctorService extends BaseService $params['inquiry_mode'] = $inquiry_mode; $system_inquiry_config = SystemInquiryConfig::getOne($params); if (!empty($system_inquiry_config)){ - $max_work_num_day = $system_inquiry_config['max_work_num_day']; - } - }else{ - $params = array(); - $params['doctor_id'] = $doctor_id; - $params['inquiry_type'] = $inquiry_type; - $params['inquiry_mode'] = $inquiry_mode; - $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); - if (!empty($doctor_inquiry_config)){ - $max_work_num_day = $doctor_inquiry_config['work_num_day']; + return $system_inquiry_config['max_work_num_day']; } } + // 健康包 + if ($inquiry_type == 1 && $inquiry_mode == 9){ + return 9999; + } + + // 随访包 + if ($inquiry_type == 1 && $inquiry_mode == 8){ + return 9999; + } + + $params = array(); + $params['doctor_id'] = $doctor_id; + $params['inquiry_type'] = $inquiry_type; + $params['inquiry_mode'] = $inquiry_mode; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)){ + return $doctor_inquiry_config['work_num_day']; + } + return $max_work_num_day; }