|
@@ -318,6 +318,10 @@
|
|
|
and a.hospital_id = b.hospital_id and b.is_deleted = 'N'
|
|
|
</select>
|
|
|
<select id="getCheckWorkPage" resultType="com.diagbot.dto.CheckWorkDTO">
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM
|
|
|
+ (
|
|
|
SELECT
|
|
|
mbi.behospital_code behospitalCode,
|
|
|
mbi.`name`,
|
|
@@ -437,26 +441,152 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- <if test="doctorIds !=null and doctorIds.size > 0">
|
|
|
- and (mbi.doctor_id IN
|
|
|
- <foreach collection="doctorIds" item="item" open="(" close=")" separator=",">
|
|
|
+ <if test="wards !=null and wards.size > 0">
|
|
|
+ AND mbi.ward_code IN
|
|
|
+ <foreach collection="wards" item="item" open="(" close=")" separator=",">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- <if test="depts !=null and depts.size > 0 and (medoups!=null and medoups.size==0)">
|
|
|
- or mbi.beh_dept_id in
|
|
|
- <foreach collection="depts" item="item" open="(" close=")" separator=",">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="depts !=null and depts.size > 0">
|
|
|
+ AND mbi.beh_dept_id in
|
|
|
+ <foreach collection="depts" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="medoups !=null and medoups.size > 0">
|
|
|
+ AND medoup.`code` IN
|
|
|
+ <foreach collection="medoups" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ mbi.behospital_code behospitalCode,
|
|
|
+ mbi.`name`,
|
|
|
+ mbi.file_code fileCode,
|
|
|
+ mbi.sex,
|
|
|
+ TIMESTAMPDIFF(
|
|
|
+ DAY,
|
|
|
+ ifnull(mhp.birthday, mbi.birthday),
|
|
|
+ mbi.behospital_date
|
|
|
+ ) AS birthday,
|
|
|
+ mhp.age,
|
|
|
+ mbi.ward_code wardCode,
|
|
|
+ mbi.ward_name wardName,
|
|
|
+ mbi.beh_dept_id deptId,
|
|
|
+ mbi.beh_dept_name behDeptName,
|
|
|
+ mbi.leave_hospital_date leaveHospitalDate,
|
|
|
+ mhp.behospital_day_num + 0 behospitalDayNum,
|
|
|
+ mbi.doctor_id doctorId,
|
|
|
+ mbi.doctor_name doctorName,
|
|
|
+ mqi.score_res scoreRes,
|
|
|
+ mqi.`level`,
|
|
|
+ mbi.diagnose,
|
|
|
+ CASE
|
|
|
+ WHEN mbt.behospital_type = '出院病人' THEN
|
|
|
+ '6'
|
|
|
+ WHEN mbt.behospital_type = '死亡病人' THEN
|
|
|
+ '6'
|
|
|
+ WHEN mbt.behospital_type = '危重病人' THEN
|
|
|
+ '4'
|
|
|
+ WHEN mbt.behospital_type = '抢救病人' THEN
|
|
|
+ '5'
|
|
|
+ WHEN mbt.behospital_type = '手术病人' THEN
|
|
|
+ '2'
|
|
|
+ WHEN mbt.behospital_type = '疑难病人' THEN
|
|
|
+ '3'
|
|
|
+ WHEN mbt.behospital_type = '输血病人' THEN
|
|
|
+ '4'
|
|
|
+ ELSE
|
|
|
+ '0'
|
|
|
+ END AS score,
|
|
|
+ CASE
|
|
|
+ WHEN ISNULL(mci.job_create_time) THEN
|
|
|
+ '未生成'
|
|
|
+ ELSE
|
|
|
+ '已生成'
|
|
|
+ END AS creatStatus,
|
|
|
+ mci.job_create_time jobCreateTime,
|
|
|
+ mci.job_creator jobCreator,
|
|
|
+ mci.job_creator_name jobCreatorName,
|
|
|
+ mci.check_time checkTime,
|
|
|
+ mci.job_distribution_time jobDistributionTime,
|
|
|
+ medoup.`code` medoupCode,
|
|
|
+ medoup.`name` medoupName
|
|
|
+ FROM
|
|
|
+ med_behospital_info mbi
|
|
|
+ LEFT JOIN med_home_page mhp ON mbi.behospital_code = mhp.behospital_code
|
|
|
+ AND mbi.hospital_id = mhp.hospital_id
|
|
|
+ AND mhp.is_deleted = 'N'
|
|
|
+ LEFT JOIN bas_doctor_info doctor ON doctor.doctor_id = mbi.doctor_id
|
|
|
+ AND doctor.is_deleted = 'N'
|
|
|
+ LEFT JOIN sys_medoup medoup ON medoup.`code` = doctor.group_id
|
|
|
+ AND medoup.is_deleted = 'N'
|
|
|
+ LEFT JOIN med_check_info mci ON mbi.behospital_code = mci.behospital_code
|
|
|
+ AND mbi.hospital_id = mci.hospital_id
|
|
|
+ AND mci.is_deleted = 'N'
|
|
|
+ LEFT JOIN med_qcresult_info mqi ON mbi.behospital_code = mqi.behospital_code
|
|
|
+ AND mbi.hospital_id = mqi.hospital_id
|
|
|
+ AND mqi.is_deleted = 'N'
|
|
|
+ JOIN med_behospital_type mbt ON mbi.behospital_code = mbt.behospital_code
|
|
|
+ AND mbi.hospital_id = mbt.hospital_id
|
|
|
+ AND mbt.is_deleted = 'N'
|
|
|
+ WHERE
|
|
|
+ mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N' and mqi.score_res is not null
|
|
|
+ AND mci.check_id is null
|
|
|
+ AND mbi.beh_dept_id in (2015,2019)
|
|
|
+ <if test="startDate != null">
|
|
|
+ <![CDATA[ AND mbi.leave_hospital_date >= #{startDate}]]>
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null">
|
|
|
+ <![CDATA[ AND mbi.leave_hospital_date < #{endDate}]]>
|
|
|
+ </if>
|
|
|
+ <if test="creatStatus != null and creatStatus == '1'.toString()">
|
|
|
+ AND mci.job_create_time is not null
|
|
|
+ <if test="jobType != null and jobType != ''">
|
|
|
+ AND mci.job_type=#{jobType}
|
|
|
</if>
|
|
|
- )
|
|
|
</if>
|
|
|
-
|
|
|
- <if test="wards !=null and wards.size > 0">
|
|
|
- AND mbi.ward_code IN
|
|
|
- <foreach collection="wards" item="item" open="(" close=")" separator=",">
|
|
|
+ <if test="creatStatus != null and creatStatus == '0'.toString()">
|
|
|
+ AND mci.job_create_time is null
|
|
|
+ </if>
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ AND mbi.`name` like CONCAT('%',#{name},'%')
|
|
|
+ </if>
|
|
|
+ <if test="behospitalCode != null and behospitalCode != ''">
|
|
|
+ AND mbi.behospital_code like CONCAT('%',#{behospitalCode},'%')
|
|
|
+ </if>
|
|
|
+ <if test="smallDay != null">
|
|
|
+ <![CDATA[ AND mhp.behospital_day_num >= #{smallDay}]]>
|
|
|
+ </if>
|
|
|
+ <if test="bigDay != null">
|
|
|
+ <![CDATA[ AND mhp.behospital_day_num <= #{bigDay}]]>
|
|
|
+ </if>
|
|
|
+ <if test="doctorName != null and doctorName != ''">
|
|
|
+ AND mbi.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
|
|
|
+ </if>
|
|
|
+ <if test="diagnose != null and diagnose != ''">
|
|
|
+ AND mbi.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
|
|
|
+ </if>
|
|
|
+ <if test="level != null and level != ''">
|
|
|
+ AND mqi.`level`= #{level}
|
|
|
+ </if>
|
|
|
+ <if test="isPlacefile != null and isPlacefile != ''">
|
|
|
+ AND mbi.is_placefile = #{isPlacefile}
|
|
|
+ </if>
|
|
|
+ <if test="values !=null and values.size > 0">
|
|
|
+ and mbt.`value` in
|
|
|
+ <foreach collection="values" item="item" open="(" close=")" separator=",">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="doctorIds !=null and doctorIds.size > 0">
|
|
|
+ and mbi.doctor_id IN
|
|
|
+ <foreach collection="doctorIds" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ ) a
|
|
|
</select>
|
|
|
|
|
|
<!--通过住院号,取消核查任务-->
|