From 99819b7e9039c3a792e749903dfb1969b5f236c1 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Thu, 16 Jul 2026 23:52:35 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=A3=80=E6=9F=A5=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=E4=B8=8B=E6=94=BE=E5=88=B0?= =?UTF-8?q?=E7=A7=91=E5=AE=A4=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/DevicesController.php | 44 +++ .../Controllers/API/Third/YiJiController.php | 62 ++- .../Services/Admin/YeWu/DevicesService.php | 107 +++++- .../Services/Admin/YeWu/PlanListService.php | 23 +- Laravel/routes/api.php | 5 + YiJi-admin/src/api/api.js | 20 + .../Yewu/DepartmentResourcesSave.vue | 18 +- YiJi-admin/src/router/index.js | 9 +- .../src/views/YeWu/DeviceCheckItemBind.vue | 353 ++++++++++++++++++ 9 files changed, 628 insertions(+), 13 deletions(-) create mode 100644 YiJi-admin/src/views/YeWu/DeviceCheckItemBind.vue diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php index f9b4a9a..3108202 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/DevicesController.php @@ -39,4 +39,48 @@ public function Del() return $service->Del($id); } + // 获取当前用户科室下的设备列表 + public function GetDeptList(Request $request) + { + $userid = $request->get('userid'); + $service = new DevicesService(); + return $service->GetDeptList($userid); + } + + // 获取设备已绑定的检查项目 + public function GetBindItems() + { + $device_id = request('device_id'); + $service = new DevicesService(); + return $service->GetBindItems($device_id); + } + + // 绑定检查项目到设备 + public function BindItem() + { + $item_id = request('item_id'); + $device_id = request('device_id'); + $service = new DevicesService(); + return $service->BindItem($item_id, $device_id); + } + + // 解除绑定 + public function UnbindItem() + { + $item_id = request('item_id'); + $device_id = request('device_id'); + $service = new DevicesService(); + return $service->UnbindItem($item_id, $device_id); + } + + // 获取未绑定的检查项目(分页) + public function GetUnboundItems() + { + $device_id = request('device_id'); + $keyword = request('keyword'); + $page = request('page'); + $pageSize = request('pageSize'); + $service = new DevicesService(); + return $service->GetUnboundItems($device_id, $keyword, $page, $pageSize); + } } diff --git a/Laravel/app/Http/Controllers/API/Third/YiJiController.php b/Laravel/app/Http/Controllers/API/Third/YiJiController.php index 1dd3512..5d04709 100644 --- a/Laravel/app/Http/Controllers/API/Third/YiJiController.php +++ b/Laravel/app/Http/Controllers/API/Third/YiJiController.php @@ -13,6 +13,7 @@ class YiJiController extends Controller //查询是否跳转医技 public function CheckAppointment() { + try { $cardNo = request('cardNo');//病人id $visitSqNo = request('visitSqNo');//门诊挂号流水号/住院流水号 @@ -20,10 +21,14 @@ public function CheckAppointment() $moOrderList = request('OrderNoList');//医嘱号列表(数组) $visitTypeCode = request('visitTypeCode');// 01:门诊 02:急诊 03:住院 04:体检 05:互联网 09:其他 - - $is_redirect = false; + $patientTypeMapping = ['03' => 0, '01' => 1, '02' => 2, '04' => 3]; + $patientType = $patientTypeMapping[$visitTypeCode] ?? 9; $is_redirect = false; $url = ""; $entrust_ids = []; + $termCodes = []; + if (!is_array($requestNoList)) { + return \Yz::JsonReturn(false, 'requestNoList 参数必须是数组', []); + } foreach ($requestNoList as $requestNo) { //1.查询his,获取申请单全部检查项目 $data = [ @@ -33,8 +38,12 @@ public function CheckAppointment() 'feeFlag' => 0, ]; + $debug_roc_url = 'http://192.168.80.39:7801/roc/order-service/api/v1/apply/pacs/apply/create/query'; + $debug_roc_params = $data; + $His = new HisController(); $res = $His::Get("查询检查申请单", $data); + $debug_hisResponse = $res; if ($res['code'] == 200) { $res_data = $res['data']; foreach ($res_data as $data_k => $data_v) { @@ -63,6 +72,7 @@ public function CheckAppointment() $patientType = $mapping[$visitTypeCode] ?? 9; foreach ($data_v['itemList'] as $item_k => $item) { $entrust_ids[] = $item['orderNo']; + $termCodes[] = $item['termCode']; //查询库里是否存在该检医嘱 $db_item = DB::table('s_list')->where(['entrust_id' => $item['orderNo']])->first(); if (!$db_item) { @@ -134,13 +144,57 @@ public function CheckAppointment() - if (true) { + // 检查是否有诊室参与预约 + $termCodes = array_unique($termCodes); + $hasEnabledRoom = 0; + if (!empty($termCodes)) { + $hasEnabledRoom = DB::table('s_check_item') + ->whereIn('s_check_item.item_code', $termCodes) + ->join('s_check_item_device', 's_check_item.id', '=', 's_check_item_device.item_id') + ->join('s_source_roster_detail_device', 's_check_item_device.device_id', '=', 's_source_roster_detail_device.device_id') + ->join('s_source_roster_detail', 's_source_roster_detail_device.roster_detail_id', '=', 's_source_roster_detail.id') + ->join('s_department_resources', 's_source_roster_detail.resources_id', '=', 's_department_resources.id') + ->where('s_source_roster_detail.status', 1) + ->where('s_source_roster_detail.is_del', 0) + ->where('s_department_resources.is_del', 0) + ->where('s_department_resources.department_resources_status', 1) + ->where('s_department_resources.appointment_enabled', 1) + ->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType]) + ->count(); + } + + if ($hasEnabledRoom > 0) { $is_redirect = true; $url = $this->build_yiji_url($cardNo, $entrust_ids, $visitSqNo); } else { $is_redirect = false; + $url = ''; + } + + // 查询执行诊室名称 + $roomNames = []; + if (!empty($termCodes)) { + $roomNames = DB::table('s_check_item') + ->whereIn('s_check_item.item_code', $termCodes) + ->join('s_check_item_device', 's_check_item.id', '=', 's_check_item_device.item_id') + ->join('s_source_roster_detail_device', 's_check_item_device.device_id', '=', 's_source_roster_detail_device.device_id') + ->join('s_source_roster_detail', 's_source_roster_detail_device.roster_detail_id', '=', 's_source_roster_detail.id') + ->join('s_department_resources', 's_source_roster_detail.resources_id', '=', 's_department_resources.id') + ->where('s_source_roster_detail.status', 1) + ->where('s_source_roster_detail.is_del', 0) + ->where('s_department_resources.is_del', 0) + ->where('s_department_resources.department_resources_status', 1) + ->where('s_department_resources.appointment_enabled', 1) + ->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType]) + ->distinct() + ->pluck('s_department_resources.department_resources_name') + ->toArray(); + } + + return \Yz::JsonReturn(true, '查询成功', ['is_redirect' => $is_redirect, 'url' => $url, 'room_names' => $roomNames, 'debug_termCodes' => $termCodes, 'debug_hisResponse' => $debug_hisResponse ?? [], 'debug_roc_url' => $debug_roc_url ?? '', 'debug_roc_params' => $debug_roc_params ?? []]); + } catch (\Exception $e) { + return \Yz::JsonReturn(false, '接口异常:' . $e->getMessage(), ['error_file' => $e->getFile(), 'error_line' => $e->getLine()]); } - return \Yz::JsonReturn(true, '查询成功', ['is_redirect' => $is_redirect, 'url' => $url]); } function QueryHisShenQingDan() diff --git a/Laravel/app/Services/Admin/YeWu/DevicesService.php b/Laravel/app/Services/Admin/YeWu/DevicesService.php index 09c4ac4..93b92d4 100644 --- a/Laravel/app/Services/Admin/YeWu/DevicesService.php +++ b/Laravel/app/Services/Admin/YeWu/DevicesService.php @@ -12,7 +12,7 @@ public function GetList($searchInfo,$page,$pageSize){ $where[]=['device_name','like','%'.$searchInfo['name'].'%']; } $count= $list->where($where)->count(); - $list= $list->where($where)->skip(($page-1)*$pageSize) // 跳过前9999条记录 + $list= $list->where($where)->skip(($page-1)*$pageSize) ->take($pageSize)->get(); return \Yz::Return(true, '查询成功', ['list'=>$list,'count'=>$count]); } @@ -48,4 +48,109 @@ public function Del($id){ return \Yz::Return(false, '删除失败'); } } + + // 获取当前用户科室下的设备列表 + public function GetDeptList($userid) + { + $user = DB::table('users')->where('id', $userid)->first(); + if (!$user || !$user->department_id) { + return \Yz::Return(true, '查询成功', []); + } + $list = DB::table('s_devices') + ->join('s_department_resources_device', 's_devices.id', '=', 's_department_resources_device.device_id') + ->where('s_department_resources_device.department_id', $user->department_id) + ->where('s_devices.is_del', 0) + ->where('s_devices.status', 1) + ->select('s_devices.*', + DB::raw('(SELECT COUNT(*) FROM s_check_item_device WHERE device_id = s_devices.id) AS bind_count')) + ->distinct() + ->orderBy('s_devices.id') + ->get(); + return \Yz::Return(true, '查询成功', $list); + } + + // 获取设备已绑定的检查项目 + public function GetBindItems($device_id) + { + $list = DB::table('s_check_item_device') + ->join('s_check_item', 's_check_item_device.item_id', '=', 's_check_item.id') + ->leftJoin('s_check_item_class', 's_check_item.item_class_id', '=', 's_check_item_class.id') + ->where('s_check_item_device.device_id', $device_id) + ->where('s_check_item.is_del', 0) + ->select('s_check_item.id', 's_check_item.item_code', 's_check_item.item_name', + 's_check_item_class.item_class_name') + ->orderBy('s_check_item.id') + ->get(); + return \Yz::Return(true, '查询成功', $list); + } + + // 绑定检查项目到设备 + public function BindItem($item_id, $device_id) + { + // 检查是否已存在 + $exists = DB::table('s_check_item_device') + ->where('item_id', $item_id) + ->where('device_id', $device_id) + ->first(); + if ($exists) { + return \Yz::Return(false, '该绑定关系已存在'); + } + $id = DB::table('s_check_item_device')->insertGetId([ + 'item_id' => $item_id, + 'device_id' => $device_id, + ]); + if ($id) { + return \Yz::Return(true, '绑定成功'); + } else { + return \Yz::Return(false, '绑定失败'); + } + } + + // 解除绑定 + public function UnbindItem($item_id, $device_id) + { + $deleted = DB::table('s_check_item_device') + ->where('item_id', $item_id) + ->where('device_id', $device_id) + ->delete(); + if ($deleted) { + return \Yz::Return(true, '解绑成功'); + } else { + return \Yz::Return(false, '解绑失败'); + } + } + + // 获取未绑定的检查项目(分页,排除已绑定的) + public function GetUnboundItems($device_id, $keyword, $page, $pageSize) + { + $list = DB::table('s_check_item') + ->leftJoin('s_check_item_class', 's_check_item.item_class_id', '=', 's_check_item_class.id') + ->where('s_check_item.is_del', 0) + ->where('s_check_item.status', 1) + ->whereNotNull('s_check_item.sheetType') + ->where('s_check_item.sheetType', '!=', '') + ->whereNotExists(function ($query) use ($device_id) { + $query->select(DB::raw(1)) + ->from('s_check_item_device') + ->whereColumn('s_check_item_device.item_id', 's_check_item.id') + ->where('s_check_item_device.device_id', $device_id); + }); + + if (!empty($keyword)) { + $list->where(function ($q) use ($keyword) { + $q->where('s_check_item.item_name', 'like', '%' . $keyword . '%') + ->orWhere('s_check_item.item_code', 'like', '%' . $keyword . '%'); + }); + } + + $count = $list->count(); + $items = $list->select('s_check_item.id', 's_check_item.item_code', 's_check_item.item_name', + 's_check_item_class.item_class_name') + ->orderBy('s_check_item.id') + ->skip(($page - 1) * $pageSize) + ->take($pageSize) + ->get(); + + return \Yz::Return(true, '查询成功', ['list' => $items, 'count' => $count]); + } } diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php index 4763045..9fc61e8 100644 --- a/Laravel/app/Services/Admin/YeWu/PlanListService.php +++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php @@ -138,6 +138,7 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ AND a.STATUS = 1 AND a.is_del = 0 AND b.is_del = 0 + AND b.appointment_enabled = 1 AND c.appointment_type_id = ?", $canshu); foreach ($plan as $p) { @@ -178,6 +179,7 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ AND a.STATUS = 1 AND a.is_del = 0 AND b.is_del = 0 + AND b.appointment_enabled = 1 AND c.appointment_type_id IN ($appointment_types_placeholders)", $canshu); $mergedPlan = []; @@ -194,6 +196,15 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ $plan = array_values($mergedPlan); } //遍历列表 把超过当前时间的放在后面 + // debug: 查看plan中的resources_id + $debugAllRids = []; + foreach ($plan as $p) { + $debugAllRids[] = $p->resources_id; + } + $debugAllRids = array_unique($debugAllRids); + $debugPlanCount = count($plan); + $debugSkipped = []; // 记录被跳过的 + $debugPassed = []; // 记录通过的 $pl1 = []; $pl2 = []; $pp = []; @@ -201,7 +212,9 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ foreach ($plan as $key => $p) { // //病人类型不符合的过滤掉 $planPatientType = explode(",", $p->patient_type); - if (!empty(array_diff($commPatientType, $planPatientType))) { + $diff = array_diff($commPatientType, $planPatientType); + if (!empty($diff)) { + $debugSkipped[] = ['rid' => $p->resources_id, 'reason' => 'patient_type', 'planTypes' => $p->patient_type, 'commTypes' => $commPatientType, 'diff' => array_values($diff)]; continue; } @@ -209,10 +222,13 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ if (!empty($allItemRules)) { $rulePass = $this->checkPlanAgainstRules($p, $allItemRules); if (!$rulePass) { + $debugSkipped[] = ['rid' => $p->resources_id, 'reason' => 'rule']; continue; } } + $debugPassed[] = $p->resources_id; + //过期的排在后面 $time = $p->date . ' ' . $p->end_time; if ($time > $nowtime) { @@ -245,6 +261,11 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ 'zhanWeiCount'=>$zhanweiCount, 'earliestPlan'=>$earliestPlan, 'is_emergency' => $allEmergency, + 'debug_commonDevice' => $commonDevice, + 'debug_planCount' => $debugPlanCount ?? 0, + 'debug_allRids' => $debugAllRids ?? [], + 'debug_skipped' => $debugSkipped ?? [], + 'debug_passedRids' => array_values(array_unique($debugPassed ?? [])), ]); } diff --git a/Laravel/routes/api.php b/Laravel/routes/api.php index 2c6de24..b724585 100644 --- a/Laravel/routes/api.php +++ b/Laravel/routes/api.php @@ -57,6 +57,11 @@ Route::post('admin/SaveDeviceList','App\Http\Controllers\API\Admin\YeWu\DevicesController@Save');//admin后台保存设备列表 Route::post('admin/GetEnableDeviceList','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetEnableList');//admin后台可用设备列表 Route::post('admin/DelDevice','App\Http\Controllers\API\Admin\YeWu\DevicesController@Del');//admin后台删除设备列表 + Route::post('admin/GetDeptDeviceList','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetDeptList');//获取当前科室下的设备列表 + Route::post('admin/GetDeviceBindItems','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetBindItems');//获取设备已绑定的检查项目 + Route::post('admin/BindItemToDevice','App\Http\Controllers\API\Admin\YeWu\DevicesController@BindItem');//绑定检查项目到设备 + Route::post('admin/UnbindItemFromDevice','App\Http\Controllers\API\Admin\YeWu\DevicesController@UnbindItem');//解除绑定 + Route::post('admin/GetUnboundCheckItems','App\Http\Controllers\API\Admin\YeWu\DevicesController@GetUnboundItems');//获取未绑定的检查项目(分页) Route::post('admin/ItemBindDevice','App\Http\Controllers\API\Admin\YeWu\CheckItemController@BindDevice');//admin后台检查项目绑定设备 Route::post('admin/GetYuYueTypes','App\Http\Controllers\API\Admin\YeWu\YuYueTypeController@GetTypes');//admin后台获取预约类型 Route::post('admin/SaveItemInfo','App\Http\Controllers\API\Admin\YeWu\CheckItemController@Save');//admin后台保存检查项目信息 diff --git a/YiJi-admin/src/api/api.js b/YiJi-admin/src/api/api.js index 630ac98..a89b262 100644 --- a/YiJi-admin/src/api/api.js +++ b/YiJi-admin/src/api/api.js @@ -140,6 +140,26 @@ export const GetEnableDeviceList = (data = {}) => { export const ItemBindDevice = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/ItemBindDevice', data: data }) } +//admin后台获取当前科室下的设备列表 +export const GetDeptDeviceList = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetDeptDeviceList', data: data }) +} +//admin后台获取设备已绑定的检查项目 +export const GetDeviceBindItems = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetDeviceBindItems', data: data }) +} +//admin后台绑定检查项目到设备 +export const BindItemToDevice = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/BindItemToDevice', data: data }) +} +//admin后台解除绑定 +export const UnbindItemFromDevice = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/UnbindItemFromDevice', data: data }) +} +//admin后台获取未绑定的检查项目(分页) +export const GetUnboundCheckItems = (data = {}) => { + return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetUnboundCheckItems', data: data }) +} //admin后台获取预约类型 export const GetYuYueTypes = (data = {}) => { return axios({ url: import.meta.env.VITE_APP_API + 'v1/admin/GetYuYueTypes', data: data }) diff --git a/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue b/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue index e70d264..ad0f418 100644 --- a/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue +++ b/YiJi-admin/src/components/Yewu/DepartmentResourcesSave.vue @@ -1,22 +1,26 @@