diff --git a/Laravel/app/Http/Controllers/API/Third/PacsController.php b/Laravel/app/Http/Controllers/API/Third/PacsController.php index d383275..f28b450 100644 --- a/Laravel/app/Http/Controllers/API/Third/PacsController.php +++ b/Laravel/app/Http/Controllers/API/Third/PacsController.php @@ -16,10 +16,17 @@ public function GetEntrustInfo(){ $visitSqNo = request('visitSqNo');//门诊挂号流水号/住院流水号 $dateRange = request('dateRange');//医嘱开单日期 $requestNo = request('requestNo');//申请单号 + $dev = request('dev');//开发调试模式 + $testdate = request('testdate');//测试日期 // 判断所有字段是否都为空 if (empty($orderNo) && empty($idCardNumber) && empty($visitSqNo) && empty($dateRange) && empty($requestNo)) { return \Yz::JsonError("缺失查询条件"); } + + $queryDate = date('Y-m-d'); + if ($dev == 1 && !empty($testdate)) { + $queryDate = $testdate; + } $entrust_list=DB::table('s_list')->select( "list_status", "is_nullify", @@ -52,8 +59,10 @@ public function GetEntrustInfo(){ "diagnosisName", "idCardNumber", "reservation_sources as reservation_sources_id", + "reservation_department_code", + "doctor_code", - )->where(['reservation_date'=>date('Y-m-d'),'is_pay'=>1,'is_del'=>0,'is_nullify'=>0]); + )->where(['reservation_date'=>$queryDate,'is_pay'=>1,'is_del'=>0,'is_nullify'=>0]); if(isset($dateRange)){ if(!is_array($dateRange)) return \Yz::JsonError("日期范围必须是数组"); $entrust_list=$entrust_list->whereBetween('entrust_date',[$dateRange[0],$dateRange[1]]); @@ -79,6 +88,7 @@ public function GetEntrustInfo(){ foreach ($entrust_list as $entrust) { $entrust->reservation_sources_name=null; + $source = null; if(!empty($entrust->reservation_sources_id)){ $source=DB::table('s_department_resources') ->where('id',$entrust->reservation_sources_id) @@ -88,6 +98,50 @@ public function GetEntrustInfo(){ $entrust->reservation_sources_name = $parts[0]; } } + + // 组装 info 字段 + $entrust->info = [ + 'deptId' => '', + 'deptName' => '', + 'roomId' => '', + 'roomName' => '', + 'scheduleName' => '', + 'reservationDepartmentCode' => (string)($entrust->reservation_department_code ?? ''), + 'reservationDepartment' => (string)($entrust->reservation_department ?? ''), + 'entrustCode' => (string)($entrust->entrust_code ?? ''), + 'entrust' => (string)($entrust->entrust ?? ''), + 'doctorCode' => (string)($entrust->doctor_code ?? ''), + 'doctor' => (string)($entrust->doctor ?? ''), + 'implementDepartment' => (string)($entrust->implement_department ?? ''), + 'wardcode' => (string)($entrust->wardcode ?? ''), + 'warddesc' => (string)($entrust->warddesc ?? ''), + 'RISRAcceptDeptCode' => (string)($entrust->RISRAcceptDeptCode ?? ''), + ]; + if (!empty($entrust->RISRAcceptDeptCode)) { + $deptRoom = DB::table('s_department') + ->where('department_number', $entrust->RISRAcceptDeptCode) + ->where('is_del', 0) + ->first(); + if ($deptRoom) { + $entrust->info['roomId'] = (string)$deptRoom->id; + $entrust->info['roomName'] = (string)$deptRoom->department_name; + if ($deptRoom->pid == 0) { + $entrust->info['deptId'] = (string)$deptRoom->id; + $entrust->info['deptName'] = (string)$deptRoom->department_name; + } else { + $deptParent = DB::table('s_department') + ->where('id', $deptRoom->pid) + ->where('is_del', 0) + ->first(); + $entrust->info['deptId'] = (string)($deptParent->id ?? $deptRoom->id); + $entrust->info['deptName'] = (string)($deptParent->department_name ?? $deptRoom->department_name); + } + } + } + if ($source) { + $entrust->info['scheduleName'] = (string)$source->department_resources_name; + } + $patientHisTypeMap = [ 0 => '03', // I - 住院 1 => '01', // O - 门诊