|
@@ -179,24 +179,32 @@
|
|
|
(
|
|
|
SELECT
|
|
|
t1.hospital_id,
|
|
|
- t1.dept_id,
|
|
|
- t1.dept_name,
|
|
|
+ t1.beh_dept_id AS dept_id,
|
|
|
+ t1.beh_dept_name AS dept_name,
|
|
|
t2.behospital_code,
|
|
|
- t2.cases_id,
|
|
|
- t3. NAME,
|
|
|
- t2.cases_entry_id,
|
|
|
- t2.msg,
|
|
|
- t2.is_deleted
|
|
|
+ t2.qcresult_info_id,
|
|
|
+ t2.gmt_create as gmTime,
|
|
|
+ t3.cases_id,
|
|
|
+ t4. NAME,
|
|
|
+ t3.cases_entry_id,
|
|
|
+ t3.msg,
|
|
|
+ t3.is_deleted
|
|
|
FROM
|
|
|
- med_click_info t1,
|
|
|
- med_qcresult_detail t2,
|
|
|
- qc_cases t3
|
|
|
+ med_behospital_info t1,
|
|
|
+ med_click_info t2,
|
|
|
+ med_qcresult_detail t3,
|
|
|
+ qc_cases t4
|
|
|
WHERE
|
|
|
t1.is_deleted = 'N'
|
|
|
AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'N'
|
|
|
+ AND t4.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
|
|
|
+ AND t1.hospital_id = t3.hospital_id
|
|
|
+ AND t1.behospital_code = t2.behospital_code
|
|
|
+ AND t2.qcresult_info_id = t3.qcresult_info_id
|
|
|
+ AND t3.cases_id = t4.id
|
|
|
+ AND t1.qc_type_id != 0
|
|
|
<if test="hospitalId != null and hospitalId != ''">
|
|
|
AND t1.hospital_id = #{hospitalId}
|
|
|
</if>
|
|
@@ -207,10 +215,16 @@
|
|
|
and t1.dept_name like CONCAT('%',#{deptName},'%')
|
|
|
</if>
|
|
|
<if test="casesName != null and casesName != ''">
|
|
|
- and t3.name like CONCAT('%',#{casesName},'%')
|
|
|
+ and t4.name like CONCAT('%',#{casesName},'%')
|
|
|
</if>
|
|
|
<if test="entryName != null and entryName != ''">
|
|
|
- and t2.msg like CONCAT('%',#{entryName},'%')
|
|
|
+ and t3.msg like CONCAT('%',#{entryName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ AND t1.leave_hospital_date >= #{startDate}]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[ AND t1.leave_hospital_date <= #{endDate}]]>
|
|
|
</if>
|
|
|
UNION
|
|
|
SELECT
|
|
@@ -218,35 +232,43 @@
|
|
|
tt1.dept_id,
|
|
|
tt1.dept_name,
|
|
|
tt1.behospital_code,
|
|
|
+ tt1.qcresult_info_id,
|
|
|
+ tt1.gmTime,
|
|
|
tt1.cases_id,
|
|
|
- tt1.name,
|
|
|
+ tt1. NAME,
|
|
|
tt1.cases_entry_id,
|
|
|
tt1.msg,
|
|
|
tt1.is_deleted
|
|
|
FROM
|
|
|
(
|
|
|
- SELECT DISTINCT
|
|
|
+ SELECT
|
|
|
t1.hospital_id,
|
|
|
- t1.dept_id,
|
|
|
- t1.dept_name,
|
|
|
- t2.qcresult_info_id,
|
|
|
+ t1.beh_dept_id AS dept_id,
|
|
|
+ t1.beh_dept_name AS dept_name,
|
|
|
t2.behospital_code,
|
|
|
- t2.cases_id,
|
|
|
- t2.cases_entry_id,
|
|
|
- t2.msg,
|
|
|
- t3. NAME,
|
|
|
- t2.is_deleted,
|
|
|
- t2.gmt_create AS gmTime
|
|
|
+ t2.qcresult_info_id,
|
|
|
+ t2.gmt_create AS gmTime,
|
|
|
+ t3.cases_id,
|
|
|
+ t4. NAME,
|
|
|
+ t3.cases_entry_id,
|
|
|
+ t3.msg,
|
|
|
+ t3.is_deleted
|
|
|
FROM
|
|
|
- med_click_info t1,
|
|
|
- med_qcresult_detail t2,
|
|
|
- qc_cases t3
|
|
|
+ med_behospital_info t1,
|
|
|
+ med_click_info t2,
|
|
|
+ med_qcresult_detail t3,
|
|
|
+ qc_cases t4
|
|
|
WHERE
|
|
|
t1.is_deleted = 'N'
|
|
|
- AND t2.is_deleted = 'Y'
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t3.is_deleted = 'Y'
|
|
|
+ AND t4.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
|
|
|
+ AND t1.hospital_id = t3.hospital_id
|
|
|
+ AND t1.behospital_code = t2.behospital_code
|
|
|
+ AND t2.qcresult_info_id = t3.qcresult_info_id
|
|
|
+ AND t3.cases_id = t4.id
|
|
|
+ AND t1.qc_type_id != 0
|
|
|
<if test="hospitalId != null and hospitalId != ''">
|
|
|
AND t1.hospital_id = #{hospitalId}
|
|
|
</if>
|
|
@@ -257,28 +279,33 @@
|
|
|
and t1.dept_name like CONCAT('%',#{deptName},'%')
|
|
|
</if>
|
|
|
<if test="casesName != null and casesName != ''">
|
|
|
- and t3.name like CONCAT('%',#{casesName},'%')
|
|
|
+ and t4.name like CONCAT('%',#{casesName},'%')
|
|
|
</if>
|
|
|
<if test="entryName != null and entryName != ''">
|
|
|
- and t2.msg like CONCAT('%',#{entryName},'%')
|
|
|
+ and t3.msg like CONCAT('%',#{entryName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ <![CDATA[ AND t1.leave_hospital_date >= #{startDate}]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ <![CDATA[ AND t1.leave_hospital_date <= #{endDate}]]>
|
|
|
</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_behospital_info t1,
|
|
|
med_click_info t2
|
|
|
WHERE
|
|
|
t1.is_deleted = 'N'
|
|
|
- and t1.is_deleted = 'N'
|
|
|
- and t1.behospital_code =t2.behospital_code
|
|
|
+ AND t2.is_deleted = 'N'
|
|
|
+ AND t1.hospital_id = t2.hospital_id
|
|
|
+ AND t1.behospital_code = t2.behospital_code
|
|
|
+ AND t1.qc_type_id != 0
|
|
|
<if test="hospitalId != null and hospitalId != ''">
|
|
|
- and t1.hospital_id = #{hospitalId}
|
|
|
+ AND t1.hospital_id = #{hospitalId}
|
|
|
</if>
|
|
|
<if test="deptId != null and deptId != ''">
|
|
|
and t1.dept_id = #{deptId}
|
|
@@ -287,16 +314,14 @@
|
|
|
and t1.dept_name like CONCAT('%',#{deptName},'%')
|
|
|
</if>
|
|
|
<if test="startDate != null and startDate != ''">
|
|
|
- <![CDATA[ AND t1.gmt_create >= #{startDate}]]>
|
|
|
+ <![CDATA[ AND t1.leave_hospital_date >= #{startDate}]]>
|
|
|
</if>
|
|
|
<if test="endDate != null and endDate != ''">
|
|
|
- <![CDATA[ AND t1.gmt_create <= #{endDate}]]>
|
|
|
+ <![CDATA[ AND t1.leave_hospital_date <= #{endDate}]]>
|
|
|
</if>
|
|
|
- GROUP BY
|
|
|
- t2.behospital_code
|
|
|
) tt2
|
|
|
WHERE
|
|
|
- tt1.behospital_code = tt2.behospital_code
|
|
|
+ tt1.gmTime = tt2.gmTime
|
|
|
AND tt1.qcresult_info_id = tt2.qcresult_info_id
|
|
|
) t3
|
|
|
GROUP BY
|