|
@@ -2758,7 +2758,9 @@
|
|
|
|
|
|
<!-- 条目缺陷质控评分页(内页)-->
|
|
|
<select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
|
|
|
- SELECT DISTINCT
|
|
|
+ SELECT t.*
|
|
|
+ FROM
|
|
|
+ (SELECT DISTINCT
|
|
|
t1.hospital_id AS hospitalId,
|
|
|
t1.behospital_code AS behospitalCode,
|
|
|
t1.bed_code AS bedCode,
|
|
@@ -2783,12 +2785,17 @@
|
|
|
t1.diagnose,
|
|
|
t1.ward_name AS wardName,
|
|
|
t2.age,
|
|
|
- t1.file_code AS fileCode
|
|
|
+ t1.file_code AS fileCode,
|
|
|
+ t1.checkStatus
|
|
|
FROM
|
|
|
(
|
|
|
SELECT DISTINCT
|
|
|
tt1.*
|
|
|
FROM
|
|
|
+ (SELECT
|
|
|
+ be.*,
|
|
|
+ mci.status AS checkStatus
|
|
|
+ FROM
|
|
|
(
|
|
|
SELECT DISTINCT
|
|
|
a.hospital_id,
|
|
@@ -2882,7 +2889,12 @@
|
|
|
DATE( a.behospital_date ),
|
|
|
DATE( a.leave_hospital_date ))> 30
|
|
|
</if>
|
|
|
- ) tt1
|
|
|
+ )be
|
|
|
+ left join med_check_info mci
|
|
|
+ on mci.is_deleted='N'
|
|
|
+ and be.hospital_id=mci.hospital_id
|
|
|
+ and be.behospital_code=mci.behospital_code
|
|
|
+ )tt1
|
|
|
<if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
|
|
|
,med_medical_record tt2
|
|
|
WHERE
|
|
@@ -2913,6 +2925,11 @@
|
|
|
AND t2.is_deleted = 'N'
|
|
|
AND t3.is_deleted = 'N'
|
|
|
</if>
|
|
|
+ ) t
|
|
|
+ where 1=1
|
|
|
+ <if test="qcResultShortPageVO.checkStatus != null">
|
|
|
+ AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
<!-- 条目缺陷质控评分页-科室(内页)-->
|
|
@@ -3502,22 +3519,24 @@
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
- bc1.file_code,
|
|
|
- bc1.diagnose,
|
|
|
- bc1.behospitalCode,
|
|
|
- bc1.behospitalDate,
|
|
|
- bc1.leaveHospitalDate
|
|
|
+ r1.file_code,
|
|
|
+ r1.diagnose,
|
|
|
+ r1.behospital_code AS behospitalCode,
|
|
|
+ r1.behospital_date AS behospitalDate,
|
|
|
+ r1.leave_hospital_date AS leaveHospitalDate,
|
|
|
+ r2.behospital_code AS lastBehospitalCode,
|
|
|
+ r2.behospital_date AS lastBehospitalDate,
|
|
|
+ r2.leave_hospital_date AS lastLeaveHospitalDate,
|
|
|
+ TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDay
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
+ ( @rownum := @rownum + 1 ) AS rownum,
|
|
|
t1.file_code,
|
|
|
t1.diagnose,
|
|
|
- t1.behospital_code AS behospitalCode,
|
|
|
- t1.leave_hospital_date AS leaveHospitalDate,
|
|
|
- t2.behospital_code AS lastBehospitalCode,
|
|
|
- t2.behospital_date AS lastBehospitalDate,
|
|
|
- t1.behospital_date AS behospitalDate,
|
|
|
- t2.leave_hospital_date AS lastLeaveHospitalDate
|
|
|
+ t1.behospital_code,
|
|
|
+ t1.behospital_date,
|
|
|
+ t1.leave_hospital_date
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
@@ -3535,8 +3554,9 @@
|
|
|
med_behospital_info a
|
|
|
WHERE
|
|
|
a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = '1'
|
|
|
+ AND a.is_placefile = 1
|
|
|
AND a.qc_type_id != 0
|
|
|
+ AND IFNULL( a.diagnose, '' )!= ''
|
|
|
<if test="hospitalId != null and hospitalId != ''">
|
|
|
AND a.hospital_id = #{hospitalId}
|
|
|
</if>
|
|
@@ -3546,7 +3566,6 @@
|
|
|
<if test="endDate != null">
|
|
|
<![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
</if>
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
GROUP BY
|
|
|
a.file_code,
|
|
|
a.diagnose
|
|
@@ -3574,75 +3593,16 @@
|
|
|
tt1.diagnose,
|
|
|
tt2.behospital_date DESC
|
|
|
) t1,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_code,
|
|
|
- tt2.behospital_date,
|
|
|
- tt2.leave_hospital_date
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- FROM
|
|
|
- med_behospital_info a
|
|
|
- WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = 1
|
|
|
- AND a.qc_type_id != 0
|
|
|
- AND a.hospital_id = 1
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
- GROUP BY
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- HAVING
|
|
|
- count(*)> 1
|
|
|
- ) tt1,
|
|
|
- med_behospital_info tt2
|
|
|
- WHERE
|
|
|
- tt2.is_deleted = 'N'
|
|
|
- AND tt2.is_placefile = 1
|
|
|
- AND tt2.qc_type_id != 0
|
|
|
- AND tt1.file_code = tt2.file_code
|
|
|
- AND tt1.diagnose = tt2.diagnose
|
|
|
- <if test="hospitalId != null and hospitalId != ''">
|
|
|
- AND tt2.hospital_id = #{hospitalId}
|
|
|
- </if>
|
|
|
- <if test="startDate != null">
|
|
|
- <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="endDate != null">
|
|
|
- <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
- </if>
|
|
|
- ORDER BY
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_date DESC
|
|
|
- ) t2
|
|
|
- WHERE
|
|
|
- t1.file_code = t2.file_code
|
|
|
- AND t1.diagnose = t2.diagnose
|
|
|
- AND t1.behospital_code != t2.behospital_code
|
|
|
- AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
|
|
|
- SELECT
|
|
|
- bc2.file_code,
|
|
|
- bc2.diagnose,
|
|
|
- bc2.lastBehospitalCode,
|
|
|
- bc2.lastBehospitalDate,
|
|
|
- bc2.lastLeaveHospitalDate
|
|
|
- FROM
|
|
|
- (
|
|
|
+ ( SELECT @rownum := 0 ) r
|
|
|
+ ) r1
|
|
|
+ LEFT JOIN (
|
|
|
SELECT
|
|
|
- t1.file_code,
|
|
|
- t1.diagnose,
|
|
|
- t1.behospital_code AS behospitalCode,
|
|
|
- t1.leave_hospital_date AS leaveHospitalDate,
|
|
|
- t2.behospital_code AS lastBehospitalCode,
|
|
|
- t2.behospital_date AS lastBehospitalDate,
|
|
|
- t1.behospital_date AS behospitalDate,
|
|
|
- t2.leave_hospital_date AS lastLeaveHospitalDate
|
|
|
+ ( @INDEX := @INDEX + 1 ) AS rownum,
|
|
|
+ t2.file_code,
|
|
|
+ t2.diagnose,
|
|
|
+ t2.behospital_code,
|
|
|
+ t2.behospital_date,
|
|
|
+ t2.leave_hospital_date
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
@@ -3660,8 +3620,9 @@
|
|
|
med_behospital_info a
|
|
|
WHERE
|
|
|
a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = '1'
|
|
|
+ AND a.is_placefile = 1
|
|
|
AND a.qc_type_id != 0
|
|
|
+ AND IFNULL( a.diagnose, '' )!= ''
|
|
|
<if test="hospitalId != null and hospitalId != ''">
|
|
|
AND a.hospital_id = #{hospitalId}
|
|
|
</if>
|
|
@@ -3671,7 +3632,6 @@
|
|
|
<if test="endDate != null">
|
|
|
<![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
</if>
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
GROUP BY
|
|
|
a.file_code,
|
|
|
a.diagnose
|
|
@@ -3698,60 +3658,17 @@
|
|
|
tt1.file_code,
|
|
|
tt1.diagnose,
|
|
|
tt2.behospital_date DESC
|
|
|
- ) t1,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_code,
|
|
|
- tt2.behospital_date,
|
|
|
- tt2.leave_hospital_date
|
|
|
- FROM
|
|
|
- (
|
|
|
+ ) t2,(
|
|
|
SELECT
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- FROM
|
|
|
- med_behospital_info a
|
|
|
- WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = 1
|
|
|
- AND a.qc_type_id != 0
|
|
|
- AND a.hospital_id = 1
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
- GROUP BY
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- HAVING
|
|
|
- count(*)> 1
|
|
|
- ) tt1,
|
|
|
- med_behospital_info tt2
|
|
|
- WHERE
|
|
|
- tt2.is_deleted = 'N'
|
|
|
- AND tt2.is_placefile = 1
|
|
|
- AND tt2.qc_type_id != 0
|
|
|
- AND tt1.file_code = tt2.file_code
|
|
|
- AND tt1.diagnose = tt2.diagnose
|
|
|
- <if test="hospitalId != null and hospitalId != ''">
|
|
|
- AND tt2.hospital_id = #{hospitalId}
|
|
|
- </if>
|
|
|
- <if test="startDate != null">
|
|
|
- <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="endDate != null">
|
|
|
- <![CDATA[AND tt2.leave_hospital_date < DATE(#{endDate})]]>
|
|
|
- </if>
|
|
|
- ORDER BY
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_date DESC
|
|
|
- ) t2
|
|
|
- WHERE
|
|
|
- t1.file_code = t2.file_code
|
|
|
- AND t1.diagnose = t2.diagnose
|
|
|
- AND t1.behospital_code != t2.behospital_code
|
|
|
- AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
|
|
|
+ @INDEX := 0
|
|
|
+ ) r
|
|
|
+ ) r2 ON r1.file_code = r2.file_code
|
|
|
+ AND r1.rownum = r2.rownum - 1
|
|
|
) t
|
|
|
+ WHERE
|
|
|
+ t.diffDay IS NOT NULL
|
|
|
+ AND t.diffDay BETWEEN 0
|
|
|
+ AND 31
|
|
|
</select>
|
|
|
|
|
|
<!-- 病案首页质控病历数统计-全院(首页)-->
|
|
@@ -3871,10 +3788,14 @@
|
|
|
t1.gmt_create AS gradeTime,
|
|
|
t1.diagnose,
|
|
|
t1.ward_name AS wardName,
|
|
|
+ t1.status AS checkStatus,
|
|
|
t2.age,
|
|
|
t2.file_code AS fileCode
|
|
|
FROM
|
|
|
(
|
|
|
+ SELECT be.*,mci.status
|
|
|
+ FROM
|
|
|
+ (
|
|
|
SELECT DISTINCT
|
|
|
tt1.*
|
|
|
FROM
|
|
@@ -3960,431 +3881,21 @@
|
|
|
AND tt2.mode_id = tt3.id
|
|
|
AND tt3.`name` = '手术记录'
|
|
|
</if>
|
|
|
- <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==5">
|
|
|
- ,(
|
|
|
- SELECT
|
|
|
- bc1.file_code,
|
|
|
- bc1.diagnose,
|
|
|
- bc1.behospitalCode,
|
|
|
- bc1.behospitalDate,
|
|
|
- bc1.leaveHospitalDate
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- t1.file_code,
|
|
|
- t1.diagnose,
|
|
|
- t1.behospital_code AS behospitalCode,
|
|
|
- t1.leave_hospital_date AS leaveHospitalDate,
|
|
|
- t2.behospital_code AS lastBehospitalCode,
|
|
|
- t2.behospital_date AS lastBehospitalDate,
|
|
|
- t1.behospital_date AS behospitalDate,
|
|
|
- t2.leave_hospital_date AS lastLeaveHospitalDate
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_code,
|
|
|
- tt2.behospital_date,
|
|
|
- tt2.leave_hospital_date
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- FROM
|
|
|
- med_behospital_info a
|
|
|
- WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = 1
|
|
|
- AND a.qc_type_id != 0
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- GROUP BY
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- HAVING
|
|
|
- count(*)> 1
|
|
|
- ) tt1,
|
|
|
- med_behospital_info tt2
|
|
|
- WHERE
|
|
|
- tt2.is_deleted = 'N'
|
|
|
- AND tt2.is_placefile = 1
|
|
|
- AND tt2.qc_type_id != 0
|
|
|
- AND tt1.file_code = tt2.file_code
|
|
|
- AND tt1.diagnose = tt2.diagnose
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- ORDER BY
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_date DESC
|
|
|
- ) t1,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_code,
|
|
|
- tt2.behospital_date,
|
|
|
- tt2.leave_hospital_date
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- FROM
|
|
|
- med_behospital_info a
|
|
|
+ ) be
|
|
|
+ <if test="qcResultShortPageVO.checkStatus != null">
|
|
|
+ ,med_check_info mci
|
|
|
WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = 1
|
|
|
- AND a.qc_type_id != 0
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- GROUP BY
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- HAVING
|
|
|
- count(*)> 1
|
|
|
- ) tt1,
|
|
|
- med_behospital_info tt2
|
|
|
- WHERE
|
|
|
- tt2.is_deleted = 'N'
|
|
|
- AND tt2.is_placefile = 1
|
|
|
- AND tt2.qc_type_id != 0
|
|
|
- AND tt1.file_code = tt2.file_code
|
|
|
- AND tt1.diagnose = tt2.diagnose
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- ORDER BY
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_date DESC
|
|
|
- ) t2
|
|
|
- WHERE
|
|
|
- t1.file_code = t2.file_code
|
|
|
- AND t1.diagnose = t2.diagnose
|
|
|
- AND t1.behospital_code != t2.behospital_code
|
|
|
- AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
|
|
|
- SELECT
|
|
|
- bc2.file_code,
|
|
|
- bc2.diagnose,
|
|
|
- bc2.lastBehospitalCode,
|
|
|
- bc2.lastBehospitalDate,
|
|
|
- bc2.lastLeaveHospitalDate
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- t1.file_code,
|
|
|
- t1.diagnose,
|
|
|
- t1.behospital_code AS behospitalCode,
|
|
|
- t1.leave_hospital_date AS leaveHospitalDate,
|
|
|
- t2.behospital_code AS lastBehospitalCode,
|
|
|
- t2.behospital_date AS lastBehospitalDate,
|
|
|
- t1.behospital_date AS behospitalDate,
|
|
|
- t2.leave_hospital_date AS lastLeaveHospitalDate
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_code,
|
|
|
- tt2.behospital_date,
|
|
|
- tt2.leave_hospital_date
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- FROM
|
|
|
- med_behospital_info a
|
|
|
- WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = 1
|
|
|
- AND a.qc_type_id != 0
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- GROUP BY
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- HAVING
|
|
|
- count(*)> 1
|
|
|
- ) tt1,
|
|
|
- med_behospital_info tt2
|
|
|
- WHERE
|
|
|
- tt2.is_deleted = 'N'
|
|
|
- AND tt2.is_placefile = 1
|
|
|
- AND tt2.qc_type_id != 0
|
|
|
- AND tt1.file_code = tt2.file_code
|
|
|
- AND tt1.diagnose = tt2.diagnose
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- ORDER BY
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_date DESC
|
|
|
- ) t1,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_code,
|
|
|
- tt2.behospital_date,
|
|
|
- tt2.leave_hospital_date
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- FROM
|
|
|
- med_behospital_info a
|
|
|
- WHERE
|
|
|
- a.is_deleted = 'N'
|
|
|
- AND a.is_placefile = 1
|
|
|
- AND a.qc_type_id != 0
|
|
|
- AND IFNULL( a.diagnose, '' )!= ''
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND a.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND a.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- GROUP BY
|
|
|
- a.file_code,
|
|
|
- a.diagnose
|
|
|
- HAVING
|
|
|
- count(*)> 1
|
|
|
- ) tt1,
|
|
|
- med_behospital_info tt2
|
|
|
- WHERE
|
|
|
- tt2.is_deleted = 'N'
|
|
|
- AND tt2.is_placefile = 1
|
|
|
- AND tt2.qc_type_id != 0
|
|
|
- AND tt1.file_code = tt2.file_code
|
|
|
- AND tt1.diagnose = tt2.diagnose
|
|
|
- <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
|
|
|
- AND tt2.hospital_id = #{qcResultShortPageVO.hospitalId}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.startDate != null">
|
|
|
- <![CDATA[ AND tt2.leave_hospital_date >= DATE(#{qcResultShortPageVO.startDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.endDate != null ">
|
|
|
- <![CDATA[AND tt2.leave_hospital_date < DATE(#{qcResultShortPageVO.endDate})]]>
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behDeptName != null and qcResultShortPageVO.behDeptName != ''">
|
|
|
- AND tt2.beh_dept_name = #{qcResultShortPageVO.behDeptName}
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
|
|
|
- AND tt2.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
|
|
|
- AND tt2.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
|
|
|
- AND (tt2.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
|
|
|
- OR tt2.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
|
|
|
- </if>
|
|
|
- <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
|
|
|
- AND (tt2.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
|
|
|
- OR tt2.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
|
|
|
- </if>
|
|
|
- ORDER BY
|
|
|
- tt1.file_code,
|
|
|
- tt1.diagnose,
|
|
|
- tt2.behospital_date DESC
|
|
|
- ) t2
|
|
|
- WHERE
|
|
|
- t1.file_code = t2.file_code
|
|
|
- AND t1.diagnose = t2.diagnose
|
|
|
- AND t1.behospital_code != t2.behospital_code
|
|
|
- AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
|
|
|
- ) tt2
|
|
|
- WHERE
|
|
|
- tt1.behospital_code = tt2.behospitalCode
|
|
|
+ mci.is_deleted = 'N'
|
|
|
+ AND be.hospital_id = mci.hospital_id
|
|
|
+ AND be.behospital_code = mci.behospital_code
|
|
|
+ AND mci.status = #{qcResultShortPageVO.checkStatus}
|
|
|
</if>
|
|
|
- ) t1
|
|
|
+ <if test="qcResultShortPageVO.checkStatus == null">
|
|
|
+ LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
|
|
|
+ AND be.hospital_id = mci.hospital_id
|
|
|
+ AND be.behospital_code = mci.behospital_code
|
|
|
+ </if>
|
|
|
+ )t1
|
|
|
<if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
|
|
|
,med_home_page t2
|
|
|
WHERE
|
|
@@ -4412,7 +3923,7 @@
|
|
|
AND t1.behospital_code = t2.behospital_code
|
|
|
AND t2.leave_hospital_type = '非医嘱离院'
|
|
|
</if>
|
|
|
- <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3 or qcResultShortPageVO.leaveHosType == 5">
|
|
|
+ <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
|
|
|
LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
|
|
|
AND t1.hospital_id = t2.hospital_id
|
|
|
AND t1.behospital_code = t2.behospital_code
|