From 6533a38571ad07b59493a873f82c43ca166662f9 Mon Sep 17 00:00:00 2001 From: sa0ChunLuyu Date: Sat, 1 Aug 2026 03:45:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BA=A6=E5=8C=BB=E7=94=9F=E7=AB=AF?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Admin/YeWu/WorkMainController.php | 99 +++++++++++- .../Controllers/API/Third/YiJiController.php | 153 ++++++++++++++++++ .../src/components/Yewu/YuYue202506.vue | 27 +++- 3 files changed, 273 insertions(+), 6 deletions(-) diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php index 0d9389a..423cc68 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php @@ -32,6 +32,8 @@ public function getMainDetail() ->get(); if (!$info) return \Yz::echoError1('没有找到对应医嘱信息'); $itemInfo=[]; + $noDeptInfo=[]; + $noScheduleInfo=[]; foreach ($info as $value){ $ii = DB::table('s_check_item as a') ->leftJoin('s_check_item_device as b','a.id','=','b.item_id') @@ -101,14 +103,101 @@ public function getMainDetail() $generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); $barcodePng = $generator->getBarcode($barcodeContent, $generator::TYPE_CODE_128, 2, 40); $value->barcode = base64_encode($barcodePng); - $itemInfo[]=[ - 'maininfo'=>$value, - 'iteminfo'=>$ii, - 'msg'=>$msg + + // ====== 分类判断:检查室状态 / 诊室资源状态 / 排班配置 ====== + + // ====== 分类判断:检查室状态 / 诊室资源状态 / 排班配置 ====== + + // 链路A:通过 hisExecDepts 查科室状态,同时收集科室名称 + $checkItemRaw = DB::table('s_check_item') + ->where('item_code', $value->entrust_code) + ->where('status', 1) + ->where('is_del', 0) + ->first(['id', 'item_code', 'item_name', 'hisExecDepts']); + + $deptAvailable = false; + $resourceItemPairs = []; + + if ($checkItemRaw && !empty($checkItemRaw->hisExecDepts)) { + $deptCodes = json_decode($checkItemRaw->hisExecDepts, true); + if (!empty($deptCodes) && is_array($deptCodes)) { + $departments = DB::table('s_department') + ->whereIn('department_number', $deptCodes) + ->select('department_number', 'department_name', 'appointment_enabled', 'department_status', 'is_del') + ->get(); + + foreach ($departments as $dept) { + // 收集科室名称(用于前端提示消息) + if (!empty($dept->department_name)) { + $resourceItemPairs[] = [ + 'resource_name' => $dept->department_name, + 'item_name' => $checkItemRaw->item_name, + ]; + } + // 判断科室是否参与预约 + if ($dept->appointment_enabled == 1 && $dept->department_status == 1 && $dept->is_del == 0) { + $deptAvailable = true; + } + } + } + } + + // 是否有设备 + $hasDevice = count($ii) > 0 && !empty($ii[0]->device_id); + + // 链路B:通过设备反查诊室资源是否有效 + $resourceAvailable = false; + if ($hasDevice) { + $deviceIds = $ii->pluck('device_id')->filter()->unique()->values()->toArray(); + $deptIds = DB::table('s_department_resources_device') + ->whereIn('device_id', $deviceIds) + ->pluck('department_id') + ->unique() + ->values() + ->toArray(); + + if (!empty($deptIds)) { + $resourceCount = DB::table('s_department_resources') + ->where(function($q) use ($deptIds) { + $q->whereIn('department_id', $deptIds) + ->orWhereIn('execute_department_id', $deptIds); + }) + ->where('appointment_enabled', 1) + ->where('department_resources_status', 1) + ->where('is_del', 0) + ->count(); + $resourceAvailable = $resourceCount > 0; + } + } + + // 分类归入对应数组 + $entry = [ + 'maininfo' => $value, + 'iteminfo' => $ii, + 'msg' => $msg, ]; + + if (!empty($resourceItemPairs)) { + if (!$deptAvailable) { + $noDeptInfo = array_merge($noDeptInfo, $resourceItemPairs); + } elseif ($hasDevice && !$resourceAvailable) { + $noDeptInfo = array_merge($noDeptInfo, $resourceItemPairs); + } elseif (!$hasDevice) { + $noScheduleInfo = array_merge($noScheduleInfo, $resourceItemPairs); + } else { + $itemInfo[] = $entry; + } + } else { + $itemInfo[] = $entry; + } } - return \Yz::Return(true,'查询完成',['today_date'=>date("Y-m-d"),'info'=>$itemInfo]); + return \Yz::Return(true,'查询完成',[ + 'today_date' => date("Y-m-d"), + 'info' => $itemInfo, + 'no_appointment_dept' => $noDeptInfo, + 'no_schedule' => $noScheduleInfo, + ]); } public function GetList(Request $request) { diff --git a/Laravel/app/Http/Controllers/API/Third/YiJiController.php b/Laravel/app/Http/Controllers/API/Third/YiJiController.php index 0050219..91e0e0b 100644 --- a/Laravel/app/Http/Controllers/API/Third/YiJiController.php +++ b/Laravel/app/Http/Controllers/API/Third/YiJiController.php @@ -149,6 +149,16 @@ public function CheckAppointment() + // ====== HIS 执行科室可预约性检查 ====== + $deptCheckResult = $this->classifyCheckItemsByDept($termCodes); + if (empty($deptCheckResult['normal'])) { + return \Yz::JsonReturn(true, '查询成功', [ + 'is_redirect' => false, + 'url' => '', + 'room_names' => [], + ]); + } + // 检查是否有诊室参与预约 $termCodes = array_unique($termCodes); $execDeptCodes = array_unique($execDeptCodes); @@ -536,6 +546,149 @@ function build_yiji_url($regnum, $entrustid, $episodeid) return "http://192.168.80.76/yiji?$query"; } + /** + * 根据项目编号数组,检查各项目对应的 HIS 执行科室是否可预约 + * 存在至少一个满足条件的科室(appointment_enabled=1, department_status=1, is_del=0) + * 则该项目归入 normal 数组,否则归入 disabled 数组 + * @param array $entrustCodes 项目编号数组 + * @return array ['normal' => [...], 'disabled' => [...]] + */ + private function classifyCheckItemsByDept(array $entrustCodes) + { + $normal = []; + $disabled = []; + + if (empty($entrustCodes)) { + return ['normal' => $normal, 'disabled' => $disabled]; + } + + // 去重 + $entrustCodes = array_unique($entrustCodes); + + // 批量查询检查项目 + $items = DB::table('s_check_item') + ->whereIn('item_code', $entrustCodes) + ->select('item_code', 'item_name', 'hisExecDepts') + ->get() + ->keyBy('item_code'); + + // 收集所有需要查询的科室编号 + $allDeptCodes = []; + $itemDeptMap = []; // item_code => ['item_name' => ..., 'dept_codes' => [...]] + + foreach ($entrustCodes as $code) { + if (!isset($items[$code])) { + // 查不到记录 → 非预约 + $disabled[] = [ + 'entrust_code' => $code, + 'item_name' => '', + 'depts' => [], + 'has_normal_dept' => false, + ]; + continue; + } + + $item = $items[$code]; + $hisExecDepts = $item->hisExecDepts; + + if (empty($hisExecDepts)) { + // hisExecDepts 为空或 null → 非预约 + $disabled[] = [ + 'entrust_code' => $code, + 'item_name' => $item->item_name, + 'depts' => [], + 'has_normal_dept' => false, + ]; + continue; + } + + $deptCodes = json_decode($hisExecDepts, true); + if (empty($deptCodes) || !is_array($deptCodes)) { + // 解析失败或为空 → 非预约 + $disabled[] = [ + 'entrust_code' => $code, + 'item_name' => $item->item_name, + 'depts' => [], + 'has_normal_dept' => false, + ]; + continue; + } + + $itemDeptMap[$code] = [ + 'item_name' => $item->item_name, + 'dept_codes' => $deptCodes, + ]; + $allDeptCodes = array_merge($allDeptCodes, $deptCodes); + } + + if (empty($allDeptCodes)) { + return ['normal' => $normal, 'disabled' => $disabled]; + } + + // 批量查询科室信息 + $allDeptCodes = array_unique($allDeptCodes); + $departments = DB::table('s_department') + ->whereIn('department_number', $allDeptCodes) + ->select('department_number', 'department_name', 'appointment_enabled', 'department_status', 'is_del') + ->get() + ->keyBy('department_number'); + + // 遍历每个项目,判断科室状态 + foreach ($itemDeptMap as $code => $info) { + $deptList = []; + $hasNormal = false; + + foreach ($info['dept_codes'] as $deptCode) { + if (!isset($departments[$deptCode])) { + // 科室不存在 → 算非预约 + $deptList[] = [ + 'dept_code' => $deptCode, + 'dept_name' => '', + 'status' => 'disabled', + 'reason' => '科室不存在', + ]; + continue; + } + + $dept = $departments[$deptCode]; + $isNormal = $dept->appointment_enabled == 1 + && $dept->department_status == 1 + && $dept->is_del == 0; + + $reasons = []; + if ($dept->appointment_enabled != 1) $reasons[] = 'appointment_enabled=' . $dept->appointment_enabled; + if ($dept->department_status != 1) $reasons[] = 'department_status=' . $dept->department_status; + if ($dept->is_del != 0) $reasons[] = 'is_del=' . $dept->is_del; + + $deptList[] = [ + 'dept_code' => $deptCode, + 'dept_name' => $dept->department_name, + 'status' => $isNormal ? 'normal' : 'disabled', + 'reason' => $isNormal ? '' : implode(', ', $reasons), + ]; + + if ($isNormal) { + $hasNormal = true; + } + } + + $entry = [ + 'entrust_code' => $code, + 'item_name' => $info['item_name'], + 'depts' => $deptList, + 'has_normal_dept' => $hasNormal, + ]; + + if ($hasNormal) { + $normal[] = $entry; + } else { + $disabled[] = $entry; + } + } + + return ['normal' => $normal, 'disabled' => $disabled]; + } + /** * 测试获取申请单详情 * 入参: visitSqNo, requestNo, visitTypeCode(HIS 格式) diff --git a/YiJi-admin/src/components/Yewu/YuYue202506.vue b/YiJi-admin/src/components/Yewu/YuYue202506.vue index dbd41c5..d1b7f1f 100644 --- a/YiJi-admin/src/components/Yewu/YuYue202506.vue +++ b/YiJi-admin/src/components/Yewu/YuYue202506.vue @@ -17,6 +17,16 @@ 患者所有检查项目未预约至同一天,请注意是否需手动调整预约 + + + + + +
@@ -298,7 +308,9 @@ const autoMatchTip = `1.未预约状态,如果多个检查项目能在同一个检查室进行检查,系统会自动选中能一起预约的项目,只需要点击一次预约按钮即可完成预约 2.已预约状态,预约到同一个时段的同一个检查室的项目,系统会自动选中,更改预约或取消预约只需点击一次 3.不同状态的预约的预约项目无法一起选中` - let TanChuangMsgDialogVisible=ref(false) + let noAppointmentDeptMsg = ref('') +let noScheduleMsg = ref('') +let TanChuangMsgDialogVisible=ref(false) let crossTimeDialogVisible = ref(false) let crossTimeDialogHtml = ref('') let cachedCrossDialogData = ref(null) // 缓存跨时段 dialog 数据:{ html, idx } @@ -507,6 +519,19 @@ } }) + // 处理不预约项目提示 + if (res.data.no_appointment_dept && res.data.no_appointment_dept.length > 0) { + const deptNames = [...new Set(res.data.no_appointment_dept.map(v => v.resource_name))] + const itemNames = [...new Set(res.data.no_appointment_dept.map(v => v.item_name))] + noAppointmentDeptMsg.value = '注意:' + deptNames.join(',') + '下属的' + itemNames.join(',') + '项目属于不用预约项目!' + } + // 处理未配置排班提示 + if (res.data.no_schedule && res.data.no_schedule.length > 0) { + const deptNames = [...new Set(res.data.no_schedule.map(v => v.resource_name))] + const itemNames = [...new Set(res.data.no_schedule.map(v => v.item_name))] + noScheduleMsg.value = '注意:' + deptNames.join(',') + '下属的' + itemNames.join(',') + '项目未配置排班计划,请联系检查室!' + } + if (tempSelected.length > 0 && !skipRestore) { tempSelected.forEach((v, i) => { entrustTableDate.value.forEach((v2, i2) => {