|
@@ -106,4 +106,220 @@
|
|
|
a.doctor_name
|
|
|
)t
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="getEntryDefectImprove" resultType="com.diagbot.dto.GetEntryDefectImproveDTO">
|
|
|
+ select
|
|
|
+ t6.hospitalId,
|
|
|
+ t6.deptId,
|
|
|
+ t6.deptName,
|
|
|
+ t6.casesId,
|
|
|
+ t6.casesName,
|
|
|
+ t6.entryName,
|
|
|
+ t6.entryId,
|
|
|
+ t6.totalNum,
|
|
|
+ t6.improveleNum,
|
|
|
+ t6.handleNum,
|
|
|
+ t6.handleStr
|
|
|
+ from(
|
|
|
+ SELECT
|
|
|
+ t5.hospital_id AS hospitalId,
|
|
|
+ t5.dept_id AS deptId,
|
|
|
+ t5.dept_name AS deptName,
|
|
|
+ t5.cases_id AS casesId,
|
|
|
+ t5. NAME AS casesName,
|
|
|
+ t5.entryName,
|
|
|
+ t5.cases_entry_id AS entryId,
|
|
|
+ sum(t5.totalNum) AS totalNum,
|
|
|
+ sum(t5.improveleNum) AS improveleNum,
|
|
|
+ sum(t5.totalNum)-sum(t5.improveleNum) AS handleNum,
|
|
|
+ concat( ROUND((sum(t5.totalNum)-sum(t5.improveleNum))/ sum(t5.totalNum)* 100, 2 ), '%' ) AS handleStr
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t4.hospital_id,
|
|
|
+ t4.dept_id,
|
|
|
+ t4.dept_name,
|
|
|
+ t4.behospital_code,
|
|
|
+ t4.cases_id,
|
|
|
+ t4. NAME,
|
|
|
+ t4.entryName,
|
|
|
+ t4.cases_entry_id,
|
|
|
+ count(t4.msgSec) AS totalNum,
|
|
|
+ CASE
|
|
|
+ WHEN count(t4.msg) > 0
|
|
|
+ AND count(t4.msgSec) - count(t4.msg) <= 0 THEN
|
|
|
+ count(t4.msgSec)
|
|
|
+ WHEN count(t4.msg) > 0
|
|
|
+ AND count(t4.msgSec) - count(t4.msg) > 0 THEN
|
|
|
+ count(t4.msgSec) - count(t4.msg)
|
|
|
+ WHEN count(t4.msg) = 0
|
|
|
+ AND count(t4.msgSec) - count(t4.msg) > 0 THEN
|
|
|
+ 0
|
|
|
+ END AS improveleNum
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t3.hospital_id,
|
|
|
+ t3.dept_id,
|
|
|
+ t3.dept_name,
|
|
|
+ t3.behospital_code,
|
|
|
+ t3.cases_id,
|
|
|
+ t3. NAME,
|
|
|
+ t3.msg AS entryName,
|
|
|
+ t3.cases_entry_id,
|
|
|
+ CASE
|
|
|
+ WHEN t3.is_deleted = 'N' THEN
|
|
|
+ t3.msg
|
|
|
+ END AS msg,
|
|
|
+ CASE
|
|
|
+ WHEN t3.is_deleted = 'Y' THEN
|
|
|
+ t3.msg
|
|
|
+ END AS msgSec
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t1.hospital_id,
|
|
|
+ t1.dept_id,
|
|
|
+ t1.dept_name,
|
|
|
+ t2.behospital_code,
|
|
|
+ t2.cases_id,
|
|
|
+ t3. NAME,
|
|
|
+ t2.cases_entry_id,
|
|
|
+ t2.msg,
|
|
|
+ t2.is_deleted
|
|
|
+ FROM
|
|
|
+ med_click_info t1,
|
|
|
+ med_qcresult_detail t2,
|
|
|
+ qc_cases t3
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t1.hospital_id = t2.hospital_id
|
|
|
+ AND t1.qcresult_info_id = t2.qcresult_info_id
|
|
|
+ AND t2.cases_id = t3.id
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ AND t1.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
+ and t1.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ and t1.dept_name like CONCAT('%',#{deptName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="casesName != null and casesName != ''">
|
|
|
+ and t3.name like CONCAT('%',#{casesName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="entryName != null and entryName != ''">
|
|
|
+ and t2.msg like CONCAT('%',#{entryName},'%')
|
|
|
+ </if>
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ tt1.hospital_id,
|
|
|
+ tt1.dept_id,
|
|
|
+ tt1.dept_name,
|
|
|
+ tt1.behospital_code,
|
|
|
+ tt1.cases_id,
|
|
|
+ tt1.name,
|
|
|
+ tt1.cases_entry_id,
|
|
|
+ tt1.msg,
|
|
|
+ tt1.is_deleted
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT DISTINCT
|
|
|
+ t1.hospital_id,
|
|
|
+ t1.dept_id,
|
|
|
+ t1.dept_name,
|
|
|
+ t2.qcresult_info_id,
|
|
|
+ t2.behospital_code,
|
|
|
+ t2.cases_id,
|
|
|
+ t2.cases_entry_id,
|
|
|
+ t2.msg,
|
|
|
+ t3. NAME,
|
|
|
+ t2.is_deleted,
|
|
|
+ t2.gmt_create AS gmTime
|
|
|
+ FROM
|
|
|
+ med_click_info t1,
|
|
|
+ med_qcresult_detail t2,
|
|
|
+ qc_cases t3
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ AND t2.is_deleted = 'Y'
|
|
|
+ AND t1.hospital_id = t2.hospital_id
|
|
|
+ AND t1.qcresult_info_id = t2.qcresult_info_id
|
|
|
+ AND t2.cases_id = t3.id
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ AND t1.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
+ and t1.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ and t1.dept_name like CONCAT('%',#{deptName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="casesName != null and casesName != ''">
|
|
|
+ and t3.name like CONCAT('%',#{casesName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="entryName != null and entryName != ''">
|
|
|
+ and t2.msg like CONCAT('%',#{entryName},'%')
|
|
|
+ </if>
|
|
|
+ ORDER BY
|
|
|
+ t2.gmt_create
|
|
|
+ ) tt1,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t2.qcresult_info_id,
|
|
|
+ t2.behospital_code,
|
|
|
+ min(t2.gmt_create) AS gmTime
|
|
|
+ FROM
|
|
|
+ med_click_info t1,
|
|
|
+ med_click_info t2
|
|
|
+ WHERE
|
|
|
+ t1.is_deleted = 'N'
|
|
|
+ and t1.is_deleted = 'N'
|
|
|
+ and t1.behospital_code =t2.behospital_code
|
|
|
+ <if test="hospitalId != null and hospitalId != ''">
|
|
|
+ and t1.hospital_id = #{hospitalId}
|
|
|
+ </if>
|
|
|
+ <if test="deptId != null and deptId != ''">
|
|
|
+ and t1.dept_id = #{deptId}
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ and t1.dept_name like CONCAT('%',#{deptName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ AND t1.gmt_create >= #{startDate}]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[ AND t1.gmt_create <= #{endDate}]]>
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ t2.behospital_code
|
|
|
+ ) tt2
|
|
|
+ WHERE
|
|
|
+ tt1.behospital_code = tt2.behospital_code
|
|
|
+ AND tt1.qcresult_info_id = tt2.qcresult_info_id
|
|
|
+ ) t3
|
|
|
+ GROUP BY
|
|
|
+ t3.dept_id,
|
|
|
+ t3.dept_name,
|
|
|
+ t3.behospital_code,
|
|
|
+ t3.cases_id,
|
|
|
+ t3.cases_entry_id,
|
|
|
+ t3.is_deleted
|
|
|
+ ) t4
|
|
|
+ GROUP BY
|
|
|
+ t4.dept_id,
|
|
|
+ t4.dept_name,
|
|
|
+ t4.behospital_code,
|
|
|
+ t4.cases_id,
|
|
|
+ t4.cases_entry_id
|
|
|
+ ) t5
|
|
|
+ GROUP BY
|
|
|
+ t5.dept_id,
|
|
|
+ t5.dept_name,
|
|
|
+ t5.cases_id,
|
|
|
+ t5.cases_entry_id)t6
|
|
|
+ where
|
|
|
+ t6.totalNum != 0
|
|
|
+ </select>
|
|
|
</mapper>
|