parent
9f53e9551e
commit
145045b34b
@ -1998,26 +1998,11 @@ class PatientOrderService extends BaseService
|
||||
$params['is_delete'] = 0;
|
||||
$order_prescription = OrderPrescription::getWithPage($params, ['*'], $page, $per_page);
|
||||
|
||||
// 创建新的数据副本,初始化为空,保留分页信息
|
||||
$order_prescription_new = [];
|
||||
if (!empty($order_prescription)) {
|
||||
// 复制分页信息等非data字段
|
||||
foreach ($order_prescription as $key => $value) {
|
||||
if ($key !== 'data') {
|
||||
$order_prescription_new[$key] = $value;
|
||||
}
|
||||
}
|
||||
$order_prescription_new['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($order_prescription['data'])) {
|
||||
foreach ($order_prescription['data'] as $item) {
|
||||
// 复制原始item数据
|
||||
$new_item = $item;
|
||||
|
||||
foreach ($order_prescription['data'] as &$item) {
|
||||
//处理抄方情况
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $new_item['order_inquiry_id'];
|
||||
$params['order_inquiry_id'] = $item['order_inquiry_id'];
|
||||
$OrderInquiry = OrderInquiry::getOne($params);
|
||||
if (!empty($OrderInquiry)) {
|
||||
//为抄方订单
|
||||
@ -2028,22 +2013,23 @@ class PatientOrderService extends BaseService
|
||||
$fields = ['doctor_id','user_name','doctor_title'];
|
||||
$UserDoctor = UserDoctor::getOne($params, $fields);
|
||||
if (!empty($UserDoctor)) {
|
||||
$new_item['UserDoctor'] = $UserDoctor;
|
||||
// 使用 setRelation 方法覆盖已加载的关联数据
|
||||
$item->setRelation('UserDoctor', $UserDoctor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($new_item['UserDoctor'])) {
|
||||
$new_item['UserDoctor']['doctor_title'] = DoctorTitleCode::getMessage($new_item['UserDoctor']['doctor_title']);
|
||||
// 获取 UserDoctor 关联对象并修改 doctor_title
|
||||
$userDoctor = $item->getRelation('UserDoctor');
|
||||
if (!empty($userDoctor)) {
|
||||
// 修改模型属性
|
||||
$userDoctor->doctor_title = DoctorTitleCode::getMessage($userDoctor->doctor_title);
|
||||
}
|
||||
|
||||
// 将处理后的数据添加到新数组中
|
||||
$order_prescription_new['data'][] = $new_item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success($order_prescription_new);
|
||||
return success($order_prescription);
|
||||
} catch (\Throwable $e) {
|
||||
Log::getInstance("PatientOrderService-getPatientPrescriptionOrderList")->error("获取处方订单列表异常", [
|
||||
'message' => $e->getMessage(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user