LEFT JOIN s_department_resources AS b ON a.resources_id = b.id
LEFT JOIN s_source_roster_detail_count AS c ON a.id = c.roster_detail_id
JOIN (
s_department_resources AS b
JOIN s_department_resources_device AS rd ON b.id = rd.rsourece_id AND rd.device_id IN ($placeholders)
LEFT JOIN s_department AS dept ON b.department_id = dept.id
LEFT JOIN s_source_roster_detail AS a ON a.resources_id = b.id AND FIND_IN_SET(?, a.patient_type) AND a.date IN ($appointment_dates_placeholders) AND a.is_del = 0
LEFT JOIN s_source_roster_detail_count AS c ON c.roster_detail_id = a.id AND c.appointment_type_id = ?
LEFT JOIN (
SELECT
roster_detail_id,
rd2.rsourece_id,
GROUP_CONCAT( e.device_name SEPARATOR ', ' ) AS devices
FROM
s_source_roster_detail_device AS d
LEFT JOIN s_devices AS e ON d.device_id = e.id
s_department_resources_device AS rd2
LEFT JOIN s_devices AS e ON rd2.device_id = e.id
WHERE
d.device_id IN ($placeholders)
rd2.device_id IN ($placeholders)
GROUP BY
d.roster_detail_id
) AS dd ON a.id = dd.roster_detail_id
rd2.rsourece_id
) AS dd ON b.id = dd.rsourece_id
WHERE
a.date IN ($appointment_dates_placeholders)
$deptCondition
AND a.STATUS = 1
AND a.is_del = 0
AND b.is_del = 0
b.is_del = 0
AND b.appointment_enabled = 1
$deptCondition
AND (
b.execute_department_id IS NULL
OR b.execute_department_id = 0
@ -206,55 +209,59 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
LEFT JOIN s_department_resources AS b ON a.resources_id = b.id
LEFT JOIN s_source_roster_detail_count AS c ON a.id = c.roster_detail_id
JOIN (
s_department_resources AS b
JOIN s_department_resources_device AS rd ON b.id = rd.rsourece_id AND rd.device_id IN ($placeholders)
LEFT JOIN s_department AS dept ON b.department_id = dept.id
LEFT JOIN s_source_roster_detail AS a ON a.resources_id = b.id AND FIND_IN_SET(?, a.patient_type) AND a.date IN ($appointment_dates_placeholders) AND a.is_del = 0
LEFT JOIN s_source_roster_detail_count AS c ON c.roster_detail_id = a.id AND c.appointment_type_id IN ($appointment_types_placeholders)
LEFT JOIN (
SELECT
roster_detail_id,
rd2.rsourece_id,
GROUP_CONCAT( e.device_name SEPARATOR ', ' ) AS devices
FROM
s_source_roster_detail_device AS d
LEFT JOIN s_devices AS e ON d.device_id = e.id
s_department_resources_device AS rd2
LEFT JOIN s_devices AS e ON rd2.device_id = e.id
WHERE
d.device_id IN ($placeholders)
rd2.device_id IN ($placeholders)
GROUP BY
d.roster_detail_id
) AS dd ON a.id = dd.roster_detail_id
rd2.rsourece_id
) AS dd ON b.id = dd.rsourece_id
WHERE
$deptCondition
AND a.date IN ($appointment_dates_placeholders)
AND a.STATUS = 1
AND a.is_del = 0
AND b.is_del = 0
b.is_del = 0
AND b.appointment_enabled = 1
AND $deptCondition
AND (
b.execute_department_id IS NULL
OR b.execute_department_id = 0
@ -265,11 +272,11 @@ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_typ
AND appointment_enabled = 1
AND department_status = 1
)
)
AND c.appointment_type_id IN ($appointment_types_placeholders)", $canshu);