|
|
|
@ -181,6 +181,10 @@
|
|
|
|
|
<!--带科室出院浏览公共查询条件-->
|
|
|
|
|
<sql id="beHospitalSeach">
|
|
|
|
|
and ArchiveState != '1024' and ArchiveState != '128' and YEAR(discharge_date_time) != '1801'
|
|
|
|
|
/**根据待审核节点查询*/
|
|
|
|
|
<include refid="selectByInfo"></include>
|
|
|
|
|
/**根据审核状态查询*/
|
|
|
|
|
<include refid="selectByStatus"></include>
|
|
|
|
|
<if test="inpNo != null and inpNo != ''">
|
|
|
|
|
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
|
|
|
|
|
</if>
|
|
|
|
@ -285,32 +289,31 @@
|
|
|
|
|
WHERE
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="isSuccess == 1">
|
|
|
|
|
ISNULL( count, 0 ) = (
|
|
|
|
|
SELECT
|
|
|
|
|
COUNT( assort_id )
|
|
|
|
|
FROM
|
|
|
|
|
zd_assort
|
|
|
|
|
WHERE
|
|
|
|
|
print_flag = 0
|
|
|
|
|
AND is_check = 1)
|
|
|
|
|
AND inspectionCount is null
|
|
|
|
|
inspectionCount is null
|
|
|
|
|
AND count = (
|
|
|
|
|
CASE
|
|
|
|
|
WHEN substring(
|
|
|
|
|
m.inp_no,
|
|
|
|
|
LEN ( m.inp_no ),
|
|
|
|
|
LEN ( m.inp_no )) = 'B' THEN
|
|
|
|
|
(( SELECT count( assort_id ) FROM zd_assort WHERE is_check = 1 ) - 2 ) ELSE ( SELECT count( assort_id ) FROM zd_assort WHERE is_check = 1 ) END)
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
ISNULL( count, 0 ) != (
|
|
|
|
|
SELECT
|
|
|
|
|
COUNT( assort_id )
|
|
|
|
|
FROM
|
|
|
|
|
zd_assort
|
|
|
|
|
WHERE
|
|
|
|
|
print_flag = 0
|
|
|
|
|
AND is_check = 1)
|
|
|
|
|
OR inspectionCount is not null
|
|
|
|
|
inspectionCount is not null
|
|
|
|
|
OR count is null
|
|
|
|
|
OR count != (
|
|
|
|
|
CASE
|
|
|
|
|
WHEN substring(
|
|
|
|
|
m.inp_no,
|
|
|
|
|
LEN ( m.inp_no ),
|
|
|
|
|
LEN ( m.inp_no )) = 'B' THEN
|
|
|
|
|
(( SELECT count( assort_id ) FROM zd_assort WHERE is_check = 1 ) - 2 ) ELSE ( SELECT count( assort_id ) FROM zd_assort WHERE is_check = 1 ) END)
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
<include refid="beHospitalSeach"></include>
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<!--带审核节点查询-->
|
|
|
|
|
<!--<!–待审核节点查询–>
|
|
|
|
|
<sql id="selectByApproveRole">
|
|
|
|
|
<if test="infoId != null">
|
|
|
|
|
<if test="infoId == 1">
|
|
|
|
@ -350,7 +353,106 @@
|
|
|
|
|
ON m.id = temp1.master_id
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
</sql>-->
|
|
|
|
|
<!--按待审核节点-->
|
|
|
|
|
<sql id="selectByInfo">
|
|
|
|
|
<if test="infoId != null">
|
|
|
|
|
<choose>
|
|
|
|
|
<!--医生-->
|
|
|
|
|
<when test="infoId == 2">
|
|
|
|
|
AND ArchiveState IN ('1','16','48','512','256','272','304','768')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="infoId == 3">
|
|
|
|
|
AND ArchiveState IN ('2','18','50','514')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="infoId == 4">
|
|
|
|
|
AND ArchiveState IN ('6','22','54','518')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="infoId == 5">
|
|
|
|
|
AND ArchiveState IN ('1','2','6','14','256','512','514','518','526','768')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="infoId == 6">
|
|
|
|
|
AND ArchiveState IN ('16','18','22','30','272')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="infoId == 7">
|
|
|
|
|
AND ArchiveState IN ('62')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="infoId == 8">
|
|
|
|
|
AND ArchiveState IN ('64','1024')
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</if>
|
|
|
|
|
</sql>
|
|
|
|
|
<!--按已审核节点-->
|
|
|
|
|
<sql id="selectYesByInfo">
|
|
|
|
|
<if test="status != null and status != ''">
|
|
|
|
|
<choose>
|
|
|
|
|
<!--医生-->
|
|
|
|
|
<when test="status == 2">
|
|
|
|
|
AND ArchiveState IN ('2','18','50','514','6','22','54','518','14','30','526','64','1024')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="status == 3">
|
|
|
|
|
AND ArchiveState IN ('6','22','54','518','14','30','526','64','1024')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="status == 4">
|
|
|
|
|
AND ArchiveState IN ('14','30','526','64','1024')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="status == 5">
|
|
|
|
|
AND ArchiveState IN ('16','18','22','40','528','48','50','54','304','64','1024')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="status == 6">
|
|
|
|
|
AND ArchiveState IN ('48','50','54','304','64','1024')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="status == 7">
|
|
|
|
|
AND ArchiveState IN ('64')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="status == 8">
|
|
|
|
|
AND ArchiveState IN ('128')
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</if>
|
|
|
|
|
</sql>
|
|
|
|
|
<!--按审核状态查询-->
|
|
|
|
|
<sql id="selectByStatus">
|
|
|
|
|
<if test="archivestate != null and archivestate != ''">
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="archivestate == 1">
|
|
|
|
|
<!--已审核-->
|
|
|
|
|
<include refid="selectYesByInfo"></include>
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
<!--未审核-->
|
|
|
|
|
AND
|
|
|
|
|
(
|
|
|
|
|
<foreach collection="status.split(',')" item="item" separator="or">
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="item == 2">
|
|
|
|
|
ArchiveState IN ('1','16','48','512','256','272','304','768')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="item == 3">
|
|
|
|
|
ArchiveState IN ('2','18',
|
|
|
|
|
'50','514')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="item == 4">
|
|
|
|
|
ArchiveState IN ('6','22','54','518')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="item == 5">
|
|
|
|
|
ArchiveState IN ('1','2','6','14','256','512','514','518','526','768')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="item == 6">
|
|
|
|
|
ArchiveState IN ('16','18','22','30','272')
|
|
|
|
|
</when>
|
|
|
|
|
<when test="item == 7">
|
|
|
|
|
ArchiveState IN ('62')
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
</if>
|
|
|
|
|
</sql>
|
|
|
|
|
<!--公共查询字段-->
|
|
|
|
|
<sql id="selectColumms">
|
|
|
|
|
m.id,m.patient_id,m.inp_no,m.visit_id,m.name,m.sex,m.
|
|
|
|
|
dept_name,m.discharge_date_time,m.ArchiveState,m.admission_date_time,m.
|
|
|
|
@ -366,105 +468,16 @@
|
|
|
|
|
INNER JOIN (<include refid="searchSuccessForMasterIdList"></include>) temp
|
|
|
|
|
ON m.id = temp.id
|
|
|
|
|
</if>
|
|
|
|
|
/**带状态查询*/
|
|
|
|
|
<if test="archivestate != null and archivestate != ''">
|
|
|
|
|
/**待审批*/
|
|
|
|
|
<if test="archivestate == 0">
|
|
|
|
|
inner join
|
|
|
|
|
(select archive_flow_info.master_id from archive_flow_info
|
|
|
|
|
inner join
|
|
|
|
|
(
|
|
|
|
|
<if test="role != 4">
|
|
|
|
|
select MAX(createtime) createtime,master_id from archive_flow_info
|
|
|
|
|
<if test="operRole != null">
|
|
|
|
|
where oper_role = ${operRole}
|
|
|
|
|
</if>
|
|
|
|
|
group by master_id) temp
|
|
|
|
|
on archive_flow_info.master_id = temp.master_id and archive_flow_info.createtime = temp.createtime and
|
|
|
|
|
archive_flow_info.target_step_id in (${status})) archive_flow_info
|
|
|
|
|
on archive_flow_info.master_id = m.id
|
|
|
|
|
</if>
|
|
|
|
|
/**护士长*/
|
|
|
|
|
<if test="role == 4">
|
|
|
|
|
SELECT master_id,MAX( createtime ) createtime FROM archive_flow_info group by master_id,oper_role) temp
|
|
|
|
|
on archive_flow_info.master_id = temp.master_id and archive_flow_info.createtime = temp.createtime
|
|
|
|
|
where archive_flow_info.target_step_id = 7
|
|
|
|
|
group by archive_flow_info.master_id having(COUNT( archive_flow_info.master_id)) = 2
|
|
|
|
|
) archive_flow_info
|
|
|
|
|
on archive_flow_info.master_id = m.id and m.ArchiveState != '64'
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
/**已审批*/
|
|
|
|
|
<if test="archivestate == 1">
|
|
|
|
|
INNER JOIN
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
archive_flow_info.master_id
|
|
|
|
|
FROM
|
|
|
|
|
archive_flow_info
|
|
|
|
|
INNER JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
MAX(createtime) createtime,
|
|
|
|
|
master_id
|
|
|
|
|
FROM
|
|
|
|
|
archive_flow_info
|
|
|
|
|
<if test="operRole != null">
|
|
|
|
|
where oper_role = ${operRole}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY
|
|
|
|
|
master_id
|
|
|
|
|
) temp ON archive_flow_info.master_id = temp.master_id
|
|
|
|
|
AND archive_flow_info.createtime = temp.createtime
|
|
|
|
|
AND start_step_id >= ${status}
|
|
|
|
|
and target_step_id != 9 and target_step_id != 10
|
|
|
|
|
) archive_flow_info
|
|
|
|
|
on archive_flow_info.master_id = m.id
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
/**根据审核节点查询*/
|
|
|
|
|
<include refid="selectByApproveRole"></include>
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="infoId != null and infoId == 1">
|
|
|
|
|
AND temp3.approveCount IS NULL
|
|
|
|
|
</if>
|
|
|
|
|
<include refid="beHospitalSeach"></include>
|
|
|
|
|
<if test="archivestate != null and archivestate != '' and archivestate == 0 and role == 1">
|
|
|
|
|
UNION ALL
|
|
|
|
|
select <include refid="selectColumms"></include>
|
|
|
|
|
from archive_master m
|
|
|
|
|
/**带状态查询*/
|
|
|
|
|
left join (select archive_flow_info.master_id from archive_flow_info
|
|
|
|
|
inner join
|
|
|
|
|
(select MAX(createtime) createtime,master_id from archive_flow_info
|
|
|
|
|
<if test="operRole != null">
|
|
|
|
|
where oper_role = ${operRole}
|
|
|
|
|
</if>
|
|
|
|
|
group by master_id) temp
|
|
|
|
|
on archive_flow_info.master_id = temp.master_id and archive_flow_info.createtime = temp.createtime where target_step_id != 9 and target_step_id != 10)
|
|
|
|
|
archive_flow_info
|
|
|
|
|
on m.id = archive_flow_info.master_id
|
|
|
|
|
/**带完整性查询*/
|
|
|
|
|
<if test="isSuccess != null and isSuccess != ''">
|
|
|
|
|
INNER JOIN (<include refid="searchSuccessForMasterIdList"></include>) temp
|
|
|
|
|
ON m.id = temp.id
|
|
|
|
|
</if>
|
|
|
|
|
/**根据审核节点查询*/
|
|
|
|
|
<include refid="selectByApproveRole"></include>
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="infoId != null and infoId == 1">
|
|
|
|
|
AND temp3.approveCount IS NULL
|
|
|
|
|
</if>
|
|
|
|
|
and archive_flow_info.master_id is null
|
|
|
|
|
<include refid="beHospitalSeach"></include>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="userName != null and userName != ''">
|
|
|
|
|
union all
|
|
|
|
|
select <include refid="selectColumms"></include> from archive_transfer_dept_user
|
|
|
|
|
inner join
|
|
|
|
|
archive_master m
|
|
|
|
|
on m.id = archive_transfer_dept_user.master_id
|
|
|
|
|
where user_name = #{userName}
|
|
|
|
|
<include refid="beHospitalSeach1"></include>
|
|
|
|
|
union all
|
|
|
|
|
select <include refid="selectColumms"></include> from archive_transfer_dept_user
|
|
|
|
|
inner join
|
|
|
|
|
archive_master m
|
|
|
|
|
on m.id = archive_transfer_dept_user.master_id
|
|
|
|
|
where user_name = #{userName}
|
|
|
|
|
<include refid="beHospitalSeach1"></include>
|
|
|
|
|
</if>
|
|
|
|
|
) m
|
|
|
|
|
ORDER BY m.discharge_date_time desc
|
|
|
|
|