|
@@ -202,9 +202,33 @@
|
|
|
|
|
|
<!-- 按科室统计平均住院天数 (分页)-->
|
|
|
<select id="getAverageDayNumPage" resultType="com.diagbot.dto.AverageStatisticsDTO">
|
|
|
- SELECT t.*
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ NAME,
|
|
|
+ averageValue,
|
|
|
+ lastAverageValue,
|
|
|
+ lastYearAverageValue
|
|
|
FROM
|
|
|
(SELECT
|
|
|
+ dept.id,
|
|
|
+ dept.NAME,
|
|
|
+ t1.averageValue,
|
|
|
+ t2.lastAverageValue,
|
|
|
+ t3.lastYearAverageValue
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.dept_id AS id,
|
|
|
+ a.dept_name AS NAME
|
|
|
+ FROM
|
|
|
+ bas_dept_info a
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND a.station = '住院'
|
|
|
+ AND a.hospital_id = 1
|
|
|
+ ) dept
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
a.beh_dept_id AS id,
|
|
|
a.beh_dept_name AS NAME,
|
|
|
count(*) AS num,
|
|
@@ -219,35 +243,196 @@
|
|
|
AND a.is_deleted = 'N'
|
|
|
AND b.is_deleted = 'N'
|
|
|
<![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
|
|
|
- AND a.hospital_id = #{filterPageVO.hospitalId}
|
|
|
+ <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>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) t1 ON dept.id = t1.id
|
|
|
+ AND dept.NAME = t1.
|
|
|
+ NAME LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME,
|
|
|
+ count(*) AS num,
|
|
|
+ round( sum( CAST( b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS lastAverageValue,
|
|
|
+ round( sum( CAST( b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
|
|
|
+ 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="filterPageVO.startDate != null and filterPageVO.startDate != ''">
|
|
|
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
|
|
|
+ <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
|
|
|
</if>
|
|
|
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
|
|
|
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
|
|
|
+ <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
|
|
|
</if>
|
|
|
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
|
|
|
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
|
|
|
+ <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
</if>
|
|
|
GROUP BY
|
|
|
a.beh_dept_id,
|
|
|
a.beh_dept_name
|
|
|
+ ) t2 ON dept.id = t2.id
|
|
|
+ AND dept.NAME = t2.
|
|
|
+ NAME LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME,
|
|
|
+ count(*) AS num,
|
|
|
+ round( sum( CAST( b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS lastYearAverageValue,
|
|
|
+ round( sum( CAST( b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
|
|
|
+ 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>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) t3 ON dept.id = t3.id
|
|
|
+ AND dept.NAME = t3.NAME
|
|
|
ORDER BY
|
|
|
- round(sum(CAST( b.behospital_day_num AS DECIMAL ))/ count(*),2 ) DESC)t
|
|
|
+ t1.averageValue DESC,
|
|
|
+ t2.lastAverageValue DESC,
|
|
|
+ t3.lastYearAverageValue DESC
|
|
|
+ )t
|
|
|
</select>
|
|
|
|
|
|
<!-- 按科室统计平均费用(分页) -->
|
|
|
<select id="getAverageFeePage" resultType="com.diagbot.dto.AverageStatisticsDTO">
|
|
|
- SELECT t.*
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ NAME,
|
|
|
+ averageValue,
|
|
|
+ lastAverageValue,
|
|
|
+ lastYearAverageValue
|
|
|
FROM
|
|
|
(SELECT
|
|
|
- a.beh_dept_id as id,
|
|
|
- a.beh_dept_name as name,
|
|
|
+ dept.id,
|
|
|
+ dept.NAME,
|
|
|
+ t1.averageValue,
|
|
|
+ t2.lastAverageValue,
|
|
|
+ t3.lastYearAverageValue
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.dept_id AS id,
|
|
|
+ a.dept_name AS NAME
|
|
|
+ FROM
|
|
|
+ bas_dept_info a
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 'N'
|
|
|
+ AND a.station = '住院'
|
|
|
+ AND a.hospital_id = 1
|
|
|
+ ) dept
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME,
|
|
|
count(*) AS num,
|
|
|
- round( sum( CAST(b.total_fee AS DECIMAL ))/ count(*), 2 ) AS averageValue,
|
|
|
- round( sum( CAST(b.total_fee AS DECIMAL )), 2 ) AS totleValue
|
|
|
+ round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS averageValue,
|
|
|
+ round( sum( CAST( b.total_fee AS DECIMAL )), 2 ) AS totleValue
|
|
|
+ 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>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) t1 ON dept.id = t1.id
|
|
|
+ AND dept.NAME = t1.
|
|
|
+ NAME LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME,
|
|
|
+ count(*) AS num,
|
|
|
+ round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS lastAverageValue,
|
|
|
+ round( sum( CAST( b.total_fee AS DECIMAL )), 2 ) AS totleValue
|
|
|
+ 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>
|
|
|
+ GROUP BY
|
|
|
+ a.beh_dept_id,
|
|
|
+ a.beh_dept_name
|
|
|
+ ) t2 ON dept.id = t2.id
|
|
|
+ AND dept.NAME = t2.
|
|
|
+ NAME LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ a.beh_dept_id AS id,
|
|
|
+ a.beh_dept_name AS NAME,
|
|
|
+ count(*) AS num,
|
|
|
+ round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS lastYearAverageValue,
|
|
|
+ round( sum( CAST( b.total_fee AS DECIMAL )), 2 ) AS totleValue
|
|
|
FROM
|
|
|
med_behospital_info a,
|
|
|
med_home_page b
|
|
@@ -257,22 +442,27 @@
|
|
|
AND a.is_deleted = 'N'
|
|
|
AND b.is_deleted = 'N'
|
|
|
<![CDATA[AND a.qc_type_id <>0 ]]>
|
|
|
- <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
|
|
|
- AND a.hospital_id = #{filterPageVO.hospitalId}
|
|
|
+ <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
|
|
|
+ AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
|
|
|
</if>
|
|
|
- <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
|
|
|
- <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
|
|
|
+ <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
|
|
|
+ <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
|
|
|
</if>
|
|
|
- <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
|
|
|
- <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
|
|
|
+ <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
|
|
|
+ <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
|
|
|
</if>
|
|
|
- <if test="filterPageVO.name != null and filterPageVO.name != ''">
|
|
|
- AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
|
|
|
+ <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
|
|
|
+ AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
|
|
|
</if>
|
|
|
GROUP BY
|
|
|
a.beh_dept_id,
|
|
|
a.beh_dept_name
|
|
|
+ ) t3 ON dept.id = t3.id
|
|
|
+ AND dept.NAME = t3.NAME
|
|
|
ORDER BY
|
|
|
- round(sum(CAST( b.total_fee AS DECIMAL ))/ count(*),2 ) DESC)t
|
|
|
+ t1.averageValue DESC,
|
|
|
+ t2.lastAverageValue DESC,
|
|
|
+ t3.lastYearAverageValue DESC
|
|
|
+ )t
|
|
|
</select>
|
|
|
</mapper>
|