|
@@ -19,5 +19,147 @@
|
|
|
<result column="modifier" property="modifier" />
|
|
|
<result column="remark" property="remark" />
|
|
|
</resultMap>
|
|
|
+ <select id="getDeptDistributionPage" resultType="com.diagbot.dto.GetDeptDistributionDTO">
|
|
|
+ SELECT DISTINCT
|
|
|
+ mbi.behospital_code behospitalCode,
|
|
|
+ mbi.`name`,
|
|
|
+ mbi.file_code fileCode,
|
|
|
+ mbi.sex,
|
|
|
+ mhp.age,
|
|
|
+ mbi.beh_dept_name behDeptName,
|
|
|
+ mbi.behospital_date behospitalDate,
|
|
|
+ mbi.leave_hospital_date leaveHospitalDate,
|
|
|
+ mhp.behospital_day_num + 0 behospitalDayNum,
|
|
|
+ mbi.doctor_name doctorName,
|
|
|
+ mqi.score_res scoreRes,
|
|
|
+ mqi.`level`,
|
|
|
+ mbi.diagnose,
|
|
|
+ mbt.behospital_type behospitalType,
|
|
|
+ mbt.`value`,
|
|
|
+ -- 科室核查
|
|
|
+ ks_mcre.check_name deptChName,
|
|
|
+ IF (
|
|
|
+ ks_mcre.`status` IS NULL,
|
|
|
+ '-1',
|
|
|
+ ks_mcre.`status`
|
|
|
+ ) deptCheckStatus,
|
|
|
+ -- 质控科核查
|
|
|
+ zkk_mcre.check_name quatChName,
|
|
|
+ IF (
|
|
|
+ zkk_mcre.`status` IS NULL,
|
|
|
+ '-1',
|
|
|
+ zkk_mcre.`status`
|
|
|
+ ) quatCheckStatus,
|
|
|
+ -- 院级核查
|
|
|
+ yj_mcre.check_name hospChName,
|
|
|
+ IF (
|
|
|
+ yj_mcre.`status` IS NULL,
|
|
|
+ '-1',
|
|
|
+ yj_mcre.`status`
|
|
|
+ ) hospCheckStatus
|
|
|
+
|
|
|
+ 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'
|
|
|
+ JOIN med_qcresult_info mqi ON mbi.behospital_code = mqi.behospital_code
|
|
|
+ AND mbi.hospital_id = mqi.hospital_id
|
|
|
+ AND mqi.is_deleted = 'N'
|
|
|
+ AND mqi.score_res IS NOT NULL
|
|
|
+ JOIN med_behospital_type mbt ON mbi.behospital_code = mbt.behospital_code
|
|
|
+ AND mbi.hospital_id = mbt.hospital_id
|
|
|
+ AND mbt.is_deleted = 'N'
|
|
|
+ -- 科室核查
|
|
|
+ LEFT JOIN med_check_record ks_mcr ON ks_mcr.hospital_id = mbi.hospital_id
|
|
|
+ AND ks_mcr.behospital_code = mbi.behospital_code
|
|
|
+ AND ks_mcr.is_deleted = 'N'
|
|
|
+ AND ks_mcr.job_type = 0
|
|
|
+ AND ks_mcr.id IN (
|
|
|
+ SELECT
|
|
|
+ max(id)
|
|
|
+ FROM
|
|
|
+ med_check_record
|
|
|
+ WHERE
|
|
|
+ hospital_id = #{getDeptDistributionVO.hospitalId}
|
|
|
+ AND job_type = 0
|
|
|
+ AND work_flow_node_id != 2
|
|
|
+ GROUP BY
|
|
|
+ behospital_code
|
|
|
+ )
|
|
|
+ LEFT JOIN med_check_record_examine ks_mcre ON ks_mcr.id = ks_mcre.check_record
|
|
|
+ AND ks_mcre.is_deleted = 'N'
|
|
|
+ -- 质控科核查
|
|
|
+ LEFT JOIN med_check_record zkk_mcr ON zkk_mcr.hospital_id = mbi.hospital_id
|
|
|
+ AND zkk_mcr.behospital_code = mbi.behospital_code
|
|
|
+ AND zkk_mcr.is_deleted = 'N'
|
|
|
+ AND zkk_mcr.job_type = 1
|
|
|
+ AND zkk_mcr.id IN (
|
|
|
+ SELECT
|
|
|
+ max(id)
|
|
|
+ FROM
|
|
|
+ med_check_record
|
|
|
+ WHERE
|
|
|
+ hospital_id = #{getDeptDistributionVO.hospitalId}
|
|
|
+ AND job_type = 1
|
|
|
+ AND work_flow_node_id != 2
|
|
|
+ GROUP BY
|
|
|
+ behospital_code
|
|
|
+ )
|
|
|
+ LEFT JOIN med_check_record_examine zkk_mcre ON zkk_mcr.id = zkk_mcre.check_record
|
|
|
+ AND zkk_mcre.is_deleted = 'N'
|
|
|
+ -- 院级核查
|
|
|
+ LEFT JOIN med_check_record yj_mcr ON yj_mcr.hospital_id = mbi.hospital_id
|
|
|
+ AND yj_mcr.behospital_code = mbi.behospital_code
|
|
|
+ AND yj_mcr.is_deleted = 'N'
|
|
|
+ AND yj_mcr.job_type = 2
|
|
|
+ AND yj_mcr.id IN (
|
|
|
+ SELECT
|
|
|
+ max(id)
|
|
|
+ FROM
|
|
|
+ med_check_record
|
|
|
+ WHERE
|
|
|
+ hospital_id = #{getDeptDistributionVO.hospitalId}
|
|
|
+ AND job_type = 2
|
|
|
+ AND work_flow_node_id != 2
|
|
|
+ GROUP BY
|
|
|
+ behospital_code
|
|
|
+ )
|
|
|
+ LEFT JOIN med_check_record_examine yj_mcre ON yj_mcr.id = yj_mcre.check_record
|
|
|
+ AND yj_mcre.is_deleted = 'N'
|
|
|
+ WHERE
|
|
|
+ mbi.hospital_id = #{getDeptDistributionVO.hospitalId}
|
|
|
+ AND mbi.is_deleted = 'N'
|
|
|
+ <if test="getDeptDistributionVO.behosDateStart != null and getDeptDistributionVO.behosDateEnd != null ">
|
|
|
+ <![CDATA[ and mbi.behospital_date >= #{getDeptDistributionVO.behosDateStart}]]>
|
|
|
+ <![CDATA[ and mbi.behospital_date <= #{getDeptDistributionVO.behosDateEnd}]]>
|
|
|
+ </if>
|
|
|
+ <if test="getDeptDistributionVO.leaveHosDateStart != null and getDeptDistributionVO.leaveHosDateEnd != null ">
|
|
|
+ <![CDATA[ and mbi.leave_hospital_date >= #{getDeptDistributionVO.leaveHosDateStart}]]>
|
|
|
+ <![CDATA[ and mbi.leave_hospital_date <= #{getDeptDistributionVO.leaveHosDateEnd}]]>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="getDeptDistributionVO.isPlacefile != null and getDeptDistributionVO.isPlacefile!=''">
|
|
|
+ AND mbi.is_placefile = #{getDeptDistributionVO.isPlacefile}
|
|
|
+ </if>
|
|
|
+ <if test="getDeptDistributionVO.name != null and getDeptDistributionVO.name != ''">
|
|
|
+ AND mbi.name like concat('%', #{getDeptDistributionVO.name}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="getDeptDistributionVO.behospitalCode != null and getDeptDistributionVO.behospitalCode != ''">
|
|
|
+ AND mbi.behospital_code like concat('%', #{getDeptDistributionVO.behospitalCode}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="getDeptDistributionVO.deptName != null and getDeptDistributionVO.deptName != ''">
|
|
|
+ AND mbi.beh_dept_name = #{getDeptDistributionVO.deptName}
|
|
|
+ </if>
|
|
|
+ <if test="getDeptDistributionVO.behospitalDayNumStart != null and getDeptDistributionVO.behospitalDayNumStart != ''
|
|
|
+ and getDeptDistributionVO.behospitalDayNumEnd != null and getDeptDistributionVO.behospitalDayNumEnd != ''">
|
|
|
+ <![CDATA[ and mhp.behospital_day_num >= #{getDeptDistributionVO.behospitalDayNumStart}]]>
|
|
|
+ <![CDATA[ and mhp.behospital_day_num <= #{getDeptDistributionVO.behospitalDayNumEnd}]]>
|
|
|
+ </if>
|
|
|
+ <if test="getDeptDistributionVO.doctorName != null and getDeptDistributionVO.doctorName != ''">
|
|
|
+ AND mbi.doctor_name like concat('%', #{getDeptDistributionVO.doctorName}, '%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|