|
|
|
@ -72,10 +72,6 @@ public function CheckAppointment()
|
|
|
|
$patientType = $mapping[$visitTypeCode] ?? 9;
|
|
|
|
$patientType = $mapping[$visitTypeCode] ?? 9;
|
|
|
|
foreach ($data_v['itemList'] as $item_k => $item) {
|
|
|
|
foreach ($data_v['itemList'] as $item_k => $item) {
|
|
|
|
// 检查科室是否参与预约
|
|
|
|
// 检查科室是否参与预约
|
|
|
|
$dept = DB::table('s_department')->where('department_number', $item["execDeptCode"])->where('appointment_enabled', 1)->first();
|
|
|
|
|
|
|
|
if (!$dept) {
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(false, '该科室未参与预约', []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$entrust_ids[] = $item['orderNo'];
|
|
|
|
$entrust_ids[] = $item['orderNo'];
|
|
|
|
$termCodes[] = $item['termCode'];
|
|
|
|
$termCodes[] = $item['termCode'];
|
|
|
|
//查询库里是否存在该检医嘱
|
|
|
|
//查询库里是否存在该检医嘱
|
|
|
|
@ -159,11 +155,13 @@ public function CheckAppointment()
|
|
|
|
->join('s_source_roster_detail_device', 's_check_item_device.device_id', '=', 's_source_roster_detail_device.device_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_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')
|
|
|
|
->join('s_department_resources', 's_source_roster_detail.resources_id', '=', 's_department_resources.id')
|
|
|
|
|
|
|
|
->join('s_department', 's_department_resources.department_id', '=', 's_department.id')
|
|
|
|
->where('s_source_roster_detail.status', 1)
|
|
|
|
->where('s_source_roster_detail.status', 1)
|
|
|
|
->where('s_source_roster_detail.is_del', 0)
|
|
|
|
->where('s_source_roster_detail.is_del', 0)
|
|
|
|
->where('s_department_resources.is_del', 0)
|
|
|
|
->where('s_department_resources.is_del', 0)
|
|
|
|
->where('s_department_resources.department_resources_status', 1)
|
|
|
|
->where('s_department_resources.department_resources_status', 1)
|
|
|
|
->where('s_department_resources.appointment_enabled', 1)
|
|
|
|
->where('s_department_resources.appointment_enabled', 1)
|
|
|
|
|
|
|
|
->where('s_department.appointment_enabled', 1)
|
|
|
|
->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType])
|
|
|
|
->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType])
|
|
|
|
->count();
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -185,11 +183,13 @@ public function CheckAppointment()
|
|
|
|
->join('s_source_roster_detail_device', 's_check_item_device.device_id', '=', 's_source_roster_detail_device.device_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_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')
|
|
|
|
->join('s_department_resources', 's_source_roster_detail.resources_id', '=', 's_department_resources.id')
|
|
|
|
|
|
|
|
->join('s_department', 's_department_resources.department_id', '=', 's_department.id')
|
|
|
|
->where('s_source_roster_detail.status', 1)
|
|
|
|
->where('s_source_roster_detail.status', 1)
|
|
|
|
->where('s_source_roster_detail.is_del', 0)
|
|
|
|
->where('s_source_roster_detail.is_del', 0)
|
|
|
|
->where('s_department_resources.is_del', 0)
|
|
|
|
->where('s_department_resources.is_del', 0)
|
|
|
|
->where('s_department_resources.department_resources_status', 1)
|
|
|
|
->where('s_department_resources.department_resources_status', 1)
|
|
|
|
->where('s_department_resources.appointment_enabled', 1)
|
|
|
|
->where('s_department_resources.appointment_enabled', 1)
|
|
|
|
|
|
|
|
->where('s_department.appointment_enabled', 1)
|
|
|
|
->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType])
|
|
|
|
->whereRaw("FIND_IN_SET(?, s_source_roster_detail.patient_type)", [$patientType])
|
|
|
|
->distinct()
|
|
|
|
->distinct()
|
|
|
|
->pluck('s_department_resources.department_resources_name')
|
|
|
|
->pluck('s_department_resources.department_resources_name')
|
|
|
|
@ -202,6 +202,146 @@ public function CheckAppointment()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function CheckAppointmentTest()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
$password = request('password');
|
|
|
|
|
|
|
|
$id = request('id');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 密码校验
|
|
|
|
|
|
|
|
if ($password !== '609384AA-E90D-4BE7-8317-3D6D7DE0A442') {
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(false, '密钥错误', []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询 s_list 记录
|
|
|
|
|
|
|
|
$sList = DB::table('s_list')->where('id', $id)->first();
|
|
|
|
|
|
|
|
if (!$sList) {
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(false, '未找到该记录', []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 反向映射 patient_type → visitTypeCode(0→03住院, 1→01门诊, 2→02急诊, 3→04体检)
|
|
|
|
|
|
|
|
$patientTypeMapping = [0 => '03', 1 => '01', 2 => '02', 3 => '04'];
|
|
|
|
|
|
|
|
$visitTypeCode = $patientTypeMapping[$sList->patient_type] ?? '09';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = [
|
|
|
|
|
|
|
|
's_list_info' => [
|
|
|
|
|
|
|
|
'id' => $sList->id,
|
|
|
|
|
|
|
|
'entrust_id' => $sList->entrust_id,
|
|
|
|
|
|
|
|
'entrust_code' => $sList->entrust_code,
|
|
|
|
|
|
|
|
'entrust' => $sList->entrust,
|
|
|
|
|
|
|
|
'reg_num' => $sList->reg_num,
|
|
|
|
|
|
|
|
'episodeid' => $sList->episodeid,
|
|
|
|
|
|
|
|
'app_num' => $sList->app_num,
|
|
|
|
|
|
|
|
'RISRAcceptDeptCode' => $sList->RISRAcceptDeptCode,
|
|
|
|
|
|
|
|
'implement_department' => $sList->implement_department,
|
|
|
|
|
|
|
|
'patient_type' => $sList->patient_type,
|
|
|
|
|
|
|
|
'visitTypeCode' => $visitTypeCode,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 调用 HIS 接口查询申请单
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
|
|
|
'visitSqNo' => $sList->episodeid,
|
|
|
|
|
|
|
|
'requestNo' => $sList->app_num,
|
|
|
|
|
|
|
|
'visitTypeCode' => $visitTypeCode,
|
|
|
|
|
|
|
|
'feeFlag' => 0,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$His = new HisController();
|
|
|
|
|
|
|
|
$hisRes = $His::Get('查询检查申请单', $data);
|
|
|
|
|
|
|
|
$result['his_query'] = [
|
|
|
|
|
|
|
|
'params' => $data,
|
|
|
|
|
|
|
|
'response' => $hisRes,
|
|
|
|
|
|
|
|
'success' => ($hisRes['code'] == 200),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 检查科室是否参与预约
|
|
|
|
|
|
|
|
$dept = DB::table('s_department')
|
|
|
|
|
|
|
|
->where('department_number', $sList->RISRAcceptDeptCode)
|
|
|
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result['department_check'] = [
|
|
|
|
|
|
|
|
'department_number' => $sList->RISRAcceptDeptCode,
|
|
|
|
|
|
|
|
'department_name' => $dept->department_name ?? '未找到',
|
|
|
|
|
|
|
|
'found' => $dept ? true : false,
|
|
|
|
|
|
|
|
'appointment_enabled' => $dept ? ($dept->appointment_enabled == 1) : false,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 检查项目 → 设备 → 检查室链路
|
|
|
|
|
|
|
|
$item = DB::table('s_check_item')
|
|
|
|
|
|
|
|
->where('item_code', $sList->entrust_code)
|
|
|
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$roomCheck = [];
|
|
|
|
|
|
|
|
if ($item) {
|
|
|
|
|
|
|
|
$devices = DB::table('s_check_item_device')
|
|
|
|
|
|
|
|
->where('item_id', $item->id)
|
|
|
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($devices as $device) {
|
|
|
|
|
|
|
|
$rooms = DB::table('s_source_roster_detail_device')
|
|
|
|
|
|
|
|
->where('s_source_roster_detail_device.device_id', $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)
|
|
|
|
|
|
|
|
->whereRaw('FIND_IN_SET(?, s_source_roster_detail.patient_type)', [$sList->patient_type])
|
|
|
|
|
|
|
|
->select(
|
|
|
|
|
|
|
|
's_source_roster_detail.id as schedule_id',
|
|
|
|
|
|
|
|
's_source_roster_detail.date as schedule_date',
|
|
|
|
|
|
|
|
's_department_resources.id as room_id',
|
|
|
|
|
|
|
|
's_department_resources.department_resources_name as room_name',
|
|
|
|
|
|
|
|
's_department_resources.appointment_enabled as room_appointment_enabled'
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($rooms as $room) {
|
|
|
|
|
|
|
|
$roomCheck[] = [
|
|
|
|
|
|
|
|
'device_id' => $device->device_id,
|
|
|
|
|
|
|
|
'room_id' => $room->room_id,
|
|
|
|
|
|
|
|
'room_name' => $room->room_name,
|
|
|
|
|
|
|
|
'room_appointment_enabled' => $room->room_appointment_enabled == 1,
|
|
|
|
|
|
|
|
'schedule_date' => $room->schedule_date,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result['room_check'] = [
|
|
|
|
|
|
|
|
'item_found' => $item ? true : false,
|
|
|
|
|
|
|
|
'item_name' => $item->item_name ?? '未找到',
|
|
|
|
|
|
|
|
'device_count' => isset($devices) ? count($devices) : 0,
|
|
|
|
|
|
|
|
'room_count' => count($roomCheck),
|
|
|
|
|
|
|
|
'rooms' => $roomCheck,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 综合结论
|
|
|
|
|
|
|
|
$hasEnabledRoom = false;
|
|
|
|
|
|
|
|
foreach ($roomCheck as $r) {
|
|
|
|
|
|
|
|
if ($r['room_appointment_enabled']) {
|
|
|
|
|
|
|
|
$hasEnabledRoom = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result['overall_result'] = [
|
|
|
|
|
|
|
|
'can_redirect' => $result['department_check']['appointment_enabled'] && $hasEnabledRoom,
|
|
|
|
|
|
|
|
'department_ok' => $result['department_check']['appointment_enabled'],
|
|
|
|
|
|
|
|
'room_ok' => $hasEnabledRoom,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(true, '诊断完成', $result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(false, '接口异常:' . $e->getMessage(), [
|
|
|
|
|
|
|
|
'error_file' => $e->getFile(),
|
|
|
|
|
|
|
|
'error_line' => $e->getLine()
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function QueryHisShenQingDan()
|
|
|
|
function QueryHisShenQingDan()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|