@@ -40,6 +40,8 @@ use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\PatientFollow;
|
||||
use App\Model\PatientHistoryInquiry;
|
||||
use App\Model\PatientHistoryInquiry as PatientHistoryInquiryModel;
|
||||
use App\Model\DoctorPharmacy;
|
||||
use App\Model\Pharmacy;
|
||||
use App\Model\Popup;
|
||||
use App\Model\Product;
|
||||
use App\Model\ProductPlatformAmount;
|
||||
@@ -1199,9 +1201,24 @@ class UserDoctorService extends BaseService
|
||||
$result['message'] = "成功";
|
||||
$result['data'] = [];
|
||||
|
||||
// 校验医生是否已配置有效的默认药房
|
||||
$doctor_id = $user_info['client_user_id'] ?? 0;
|
||||
$default_pharmacy = DoctorPharmacy::getDoctorDefaultPharmacy($doctor_id);
|
||||
if (empty($default_pharmacy) || empty($default_pharmacy->Pharmacy) || $default_pharmacy->Pharmacy->status != 1 || empty($default_pharmacy->Pharmacy->pharmacy_code)) {
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "您尚未配置默认药房或药房已停用,请前往【我的-药房设置】完成绑定后再开具处方";
|
||||
return success($result);
|
||||
}
|
||||
|
||||
$result['data']['default_pharmacy'] = [
|
||||
'pharmacy_id' => (string)$default_pharmacy->Pharmacy->pharmacy_id,
|
||||
'pharmacy_code' => $default_pharmacy->Pharmacy->pharmacy_code,
|
||||
'pharmacy_name' => $default_pharmacy->Pharmacy->pharmacy_name,
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
return success($result);
|
||||
@@ -1462,6 +1479,22 @@ class UserDoctorService extends BaseService
|
||||
$doctor_advice = $this->request->input('doctor_advice');
|
||||
$prescription_product = $this->request->input('prescription_product');
|
||||
$disease_desc = $this->request->input('disease_desc'); // 病情主诉
|
||||
$input_pharmacy_id = $this->request->input('pharmacy_id');
|
||||
|
||||
// 获取开方药房
|
||||
$pharmacy = null;
|
||||
if (isset($input_pharmacy_id) && $input_pharmacy_id !== '') {
|
||||
$pharmacy = Pharmacy::getValidPharmacy($input_pharmacy_id);
|
||||
} else {
|
||||
$doctor_default = DoctorPharmacy::getDoctorDefaultPharmacy($user_info['client_user_id'] ?? 0);
|
||||
if ($doctor_default && $doctor_default->Pharmacy && $doctor_default->Pharmacy->status == 1) {
|
||||
$pharmacy = $doctor_default->Pharmacy;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pharmacy) || empty($pharmacy['pharmacy_code'])) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未找到有效的开方药房或药房已被停用,无法开具处方");
|
||||
}
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
@@ -1635,6 +1668,9 @@ class UserDoctorService extends BaseService
|
||||
$data['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$data['patient_age'] = $order_inquiry['patient_age'];
|
||||
$data['doctor_advice'] = $doctor_advice;
|
||||
$data['pharmacy_id'] = $pharmacy['pharmacy_id'];
|
||||
$data['pharmacy_code'] = $pharmacy['pharmacy_code'];
|
||||
$data['pharmacy_name'] = $pharmacy['pharmacy_name'];
|
||||
$order_prescription = OrderPrescription::addOrderPrescription($data);
|
||||
if (empty($order_prescription)) {
|
||||
Db::rollBack();
|
||||
@@ -1689,6 +1725,12 @@ class UserDoctorService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"药品" . $product['product_name'] . "已被删除,无法开具");
|
||||
}
|
||||
|
||||
// 校验药品所属药房是否与处方药房一致
|
||||
if (!empty($product['pharmacy_code']) && $product['pharmacy_code'] !== $pharmacy['pharmacy_code']) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "药品【" . $product['product_name'] . "】不属于当前药房");
|
||||
}
|
||||
|
||||
// 检测药品是否超出最大可开数
|
||||
if ($item['prescription_product_num'] > $product['prescription_num']) {
|
||||
// 库存不足
|
||||
|
||||
Reference in New Issue
Block a user