123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.diagbot.mapper.MedCheckInfoMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.MedCheckInfo">
- <id column="id" property="id" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_create" property="gmtCreate" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="behospital_code" property="behospitalCode" />
- <result column="hospital_id" property="hospitalId" />
- <result column="check_id" property="checkId" />
- <result column="check_name" property="checkName" />
- <result column="check_time" property="checkTime" />
- <result column="status" property="status" />
- <result column="check_type" property="checkType" />
- <result column="job_creator" property="jobCreator" />
- <result column="job_creator_name" property="jobCreatorName" />
- <result column="job_create_time" property="jobCreateTime" />
- <result column="job_type" property="jobType" />
- <result column="job_distributor" property="jobDistributor" />
- <result column="job_distribution_name" property="jobDistributionName" />
- <result column="job_distribution_time" property="jobDistributionTime" />
- </resultMap>
- <!--获取核查人员用户科室、姓名、角色-->
- <select id="getCheckUser" resultType="com.diagbot.dto.CheckUserDTO">
- SELECT DISTINCT
- a.id doctorId,
- a.linkman doctorName,
- c.dept_id deptId,
- d.dept_name deptName,
- b.role_id roleId
- from
- sys_user a,sys_user_role b,sys_user_dept c ,bas_dept_info d
- where a.id = b.user_id and a.is_deleted = "N" and b.is_deleted = "N" and c.is_deleted = "N" and a.id = c.user_id
- and d.dept_id = c.dept_id and c.hospital_id = d.hospital_id
- and c.hospital_id = #{hospitalId}
- <if test="roleIds !=null and roleIds.size()!=0 and roleId ==null and userId ==null">
- and b.role_id in
- <foreach collection="roleIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="roleIds !=null and roleIds.size()!=0 and roleId !=null and userId !=null">
- and (b.role_id in
- <foreach collection="roleIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or (b.role_id =#{roleId} and a.id = #{userId}))
- </if>
- <if test="deptIds !=null and deptIds.size()!=0">
- and c.dept_id in
- <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deptStations !=null and deptStations.size()!=0">
- and d.station in
- <foreach collection="deptStations" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <!--通过核查人员id获取核查人员的核查任务数-->
- <select id="getJobNumByUserId" resultType="com.diagbot.dto.DeptCheckUserDTO">
- SELECT
- check_id doctorId,
- count(*) as jobNum
- from
- med_check_info
- where is_deleted = 'N' and job_distribution_name is not null
- <if test="jobType != null and jobType != ''">
- and job_type = #{jobType}
- </if>
- <if test="userList !=null">
- and check_id in
- <foreach collection="userList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- GROUP BY check_id
- </select>
- <!--获取待分配核查任务列表-->
- <select id="getCheckList" resultType="com.diagbot.dto.CheckJobDTO">
- SELECT
- a.behospital_code behospitalCode,
- a.beh_dept_name behospitalDept,
- a.doctor_name attendingDoctor,
- a.leave_hospital_date leaveHospitalDate,
- a.`name`,
- b.`value`,
- a.id
- from
- (select
- a.behospital_code,
- a.`name`,
- a.beh_dept_name,
- a.doctor_name,
- a.leave_hospital_date,
- a.hospital_id,
- a.beh_dept_id,
- b.id
- from
- med_behospital_info a ,med_check_info b
- where a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N'
- and b.is_deleted = 'N' and b.job_distribution_name is NULL and b.`status` = 0
- <if test="jobType !=null and jobType != ''">
- and b.job_type = #{jobType}
- </if>
- <if test="startTime != null and startTime != ''">
- <![CDATA[ AND b.job_create_time >= #{startTime}]]>
- </if>
- <if test="endTime != null and endTime != ''">
- <![CDATA[ AND b.job_create_time < #{endTime}]]>
- </if>
- <if test="behosDateStart != null and behosDateStart != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null and behosDateEnd != ''">
- <![CDATA[ AND a.leave_hospital_date < #{behosDateEnd}]]>
- </if>
- <if test="doctorName !=null and doctorName != ''">
- and a.doctor_name = #{doctorName}
- </if>
- <if test="behospitalCode !=null and behospitalCode != ''">
- and a.behospital_code = #{behospitalCode}
- </if>
- <if test="name !=null and name != ''">
- and a.`name` LIKE CONCAT('%',#{name},'%')
- </if>
- <if test="deptList !=null and deptList.size()!=0 and jobType ==0">
- and a.beh_dept_id in
- <foreach collection="deptList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="deptList !=null and deptList.size()!=0 and jobType ==1">
- and a.beh_dept_id not in
- <foreach collection="deptList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- ) a LEFT JOIN med_behospital_type b on a.behospital_code = b.behospital_code
- and a.hospital_id = b.hospital_id and b.is_deleted = 'N' ORDER BY b.`value` DESC ,a.leave_hospital_date DESC
- </select>
- <!--获取指定核查人员的核查任务-->
- <select id="getCheckListByUserId" resultType="com.diagbot.dto.CheckJobDTO">
- SELECT
- a.behospital_code behospitalCode,
- a.beh_dept_name behospitalDept,
- a.doctor_name attendingDoctor,
- a.leave_hospital_date leaveHospitalDate,
- a.`name`,b.`value`,
- a.id
- from
- (select
- a.behospital_code,
- a.`name`,
- a.beh_dept_name,
- a.doctor_name,
- a.leave_hospital_date,
- a.hospital_id,
- a.beh_dept_id,
- b.id
- from
- med_behospital_info a ,med_check_info b
- where a.behospital_code = b.behospital_code and a.hospital_id = b.hospital_id and a.is_deleted = 'N'
- and b.is_deleted = 'N' and b.`status` = 0
- <if test="startTime != null and startTime != ''">
- <![CDATA[ AND b.job_create_time >= #{startTime}]]>
- </if>
- <if test="endTime != null and endTime != ''">
- <![CDATA[ AND b.job_create_time < #{endTime}]]>
- </if>
- <if test="behosDateStart != null and behosDateStart != ''">
- <![CDATA[ AND a.leave_hospital_date >= #{behosDateStart}]]>
- </if>
- <if test="behosDateEnd != null and behosDateEnd != ''">
- <![CDATA[ AND a.leave_hospital_date < #{behosDateEnd}]]>
- </if>
- <if test="checkId !=null and checkId != ''">
- and b.check_id = #{checkId}
- </if>
- ) a LEFT JOIN med_behospital_type b on a.behospital_code = b.behospital_code
- and a.hospital_id = b.hospital_id and b.is_deleted = 'N' ORDER BY b.`value` DESC ,a.leave_hospital_date DESC
- </select>
- <select id="getCheckWorkPage" resultType="com.diagbot.dto.CheckWorkDTO">
- SELECT
- mbi.behospital_code behospitalCode,
- mbi.name,
- mbi.file_code fileCode,
- mbi.sex,
- mhp.age,
- mbi.beh_dept_name behospitalDept,
- mbi.leave_hospital_date leaveHospitalDate,
- mhp.behospital_day_num behospitalDayNum,
- mbi.doctor_name attendingDoctor,
- 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_name jobCreatorName,
- mci.check_time checkTime,
- mci.job_distribution_time jobDistributionTime
- 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 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'
- LEFT 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
- <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'">
- AND mci.job_create_time is not null
- <if test="jobType != null and jobType != ''">
- AND mci.job_type=#{jobType}
- </if>
- </if>
- <if test="creatStatus != null and creatStatus == 0">
- 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="departments !=null and departments.size > 0">
- and mbi.beh_dept_id in
- <foreach collection="departments" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </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>
- </select>
- <!--通过住院号,取消核查任务-->
- <update id="deleteBatchCodes">
- <foreach collection="list" item="item" separator=";">
- delete from
- med_check_info
- where behospital_code = #{item} and is_deleted = 'N'
- </foreach>
- </update>
- <select id="checkedRecordList" resultType="com.diagbot.dto.CheckedRecordListDTO">
- SELECT *
- from
- (select
- b.behospital_code as behospitalCode,
- a.`status` as status,
- b.beh_dept_id as behDeptId,
- b.beh_dept_name as behDeptName,
- b.`name` as name,
- b.file_code as fileCode,
- b.doctor_name as doctorName,
- b.leave_hospital_date as leaveHospitalDate,
- a.job_create_time as jobCreateTime,
- a.job_distribution_time as jobDistributionTime,
- a.check_id as checkId,
- a.check_name as checkName,
- a.check_time as checkTime,
- c.`level` as level,
- c.score_res as scoreRes,
- case when a.check_type='0' and FIND_IN_SET(b.beh_dept_id,#{currentDeptIds}) then 0 else 1 end as isDel
- from med_check_info a join med_behospital_info b on a.hospital_id=b.hospital_id and
- a.behospital_code=b.behospital_code
- join med_qcresult_info c on b.hospital_id=c.hospital_id and b.behospital_code=c.behospital_code and
- b.is_deleted='N'
- where a.hospital_id=#{hospitalId} and a.is_deleted='N'
- and b.hospital_id=#{hospitalId} and b.is_deleted='N'
- and c.hospital_id=#{hospitalId}
- and a.check_id in
- <foreach collection="currentGeneralUserIds" item="currentGeneralUserId" separator="," close=")" open="(">
- #{currentGeneralUserId}
- </foreach>
- <if test="status!=null">
- and a.`status`=#{status}
- </if>
- <if test="behDeptId!=null and behDeptId!=''">
- and b.beh_dept_id=#{behDeptId}
- </if>
- <if test="name!=null and name!=''">
- and b.`name` like concat('%',#{name},'%')
- </if>
- <if test="behospitalCode!=null and behospitalCode!=''">
- and b.behospital_code like concat('%',#{behospitalCode},'%')
- </if>
- <if test="doctorName!=null and doctorName!=''">
- and b.doctor_name like concat('%',#{doctorName},'%')
- </if>
- <if test="jobDistributionTimeStart!=null">
- and a.job_distribution_time >= #{jobDistributionTimeStart}
- </if>
- <if test="jobDistributionTimeEnd!=null">
- and #{jobDistributionTimeEnd} >= a.job_distribution_time
- </if>
- <if test="checkName!=null and checkName!=''">
- and a.check_name like concat('%',#{checkName},'%')
- </if>
- <if test="level!=null and level!=''">
- and c.`level`=#{level}
- </if>
- <if test="checkJobTypes!=null and checkJobTypes.size>0">
- and a.job_type in
- <foreach collection="checkJobTypes" item="checkJobType" separator="," close=")" open="(">
- #{checkJobType}
- </foreach>
- </if>
- ) tab
- where isDel>0
- order by jobDistributionTime desc
- </select>
- </mapper>
|