|
@@ -209,27 +209,86 @@
|
|
|
lastAverageValue,
|
|
|
lastYearAverageValue
|
|
|
FROM
|
|
|
- (SELECT
|
|
|
- dept.id,
|
|
|
- dept.NAME,
|
|
|
- t1.averageValue,
|
|
|
- t2.lastAverageValue,
|
|
|
- t3.lastYearAverageValue
|
|
|
+ (SELECT DISTINCT
|
|
|
+ id,
|
|
|
+ NAME
|
|
|
+ FROM
|
|
|
+ ((
|
|
|
+ SELECT DISTINCT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME
|
|
|
FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b
|
|
|
+ WHERE
|
|
|
+ a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ <![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
+ <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
+ </if>
|
|
|
+ ) UNION
|
|
|
(
|
|
|
- SELECT
|
|
|
- a.dept_id AS id,
|
|
|
- a.dept_name AS NAME
|
|
|
+ SELECT DISTINCT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME
|
|
|
FROM
|
|
|
- bas_dept_info a
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b
|
|
|
WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.station = '住院'
|
|
|
+ a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ <![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
+ <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
+ </if>
|
|
|
+ ) UNION
|
|
|
+ (
|
|
|
+ SELECT DISTINCT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b
|
|
|
+ WHERE
|
|
|
+ a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ <![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
<if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
</if>
|
|
|
+ <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
|
|
|
+ </if>
|
|
|
<if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
- AND a.dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
</if>
|
|
|
) dept
|
|
|
LEFT JOIN (
|
|
@@ -355,19 +414,81 @@
|
|
|
t3.lastYearAverageValue
|
|
|
FROM
|
|
|
(
|
|
|
- SELECT
|
|
|
- a.dept_id AS id,
|
|
|
- a.dept_name AS NAME
|
|
|
+ SELECT DISTINCT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME
|
|
|
FROM
|
|
|
- bas_dept_info a
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b
|
|
|
WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.station = '住院'
|
|
|
+ a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ <![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
<if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
</if>
|
|
|
+ <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
|
|
|
+ </if>
|
|
|
<if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
- AND a.dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
+ </if>
|
|
|
+ ) UNION
|
|
|
+ (
|
|
|
+ SELECT DISTINCT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b
|
|
|
+ WHERE
|
|
|
+ a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ <![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
+ <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
+ </if>
|
|
|
+ ) UNION
|
|
|
+ (
|
|
|
+ SELECT DISTINCT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME
|
|
|
+ FROM
|
|
|
+ med_behospital_info a,
|
|
|
+ med_home_page b
|
|
|
+ WHERE
|
|
|
+ a.hospital_id = b.hospital_id
|
|
|
+ AND a.behospital_code = b.behospital_code
|
|
|
+ AND a.is_deleted = 'N'
|
|
|
+ AND b.is_deleted = 'N'
|
|
|
+ <![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
+ <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
|
|
|
+ </if>
|
|
|
+ <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
</if>
|
|
|
) dept
|
|
|
LEFT JOIN (
|