@ -285,7 +285,16 @@
<sql id= "selectByApproveRole" >
<if test= "infoId != null" >
<if test= "infoId == 1" >
LEFT JOIN ( SELECT master_id, COUNT( id ) approveCount FROM archive_flow_info WHERE step_index = 1 GROUP BY master_id HAVING ( COUNT( id )) = 2 ) temp3 ON m.id = temp3.master_id
LEFT JOIN (
<if test= "operRole != null" >
<if test= "operRole == 4" >
select master_id,master_id approveCount from ( select master_id,step_index from archive_flow_info where step_index in (1,2) group by master_id,step_index) temp group by master_id having(COUNT(master_id)) = 2
</if>
<if test= "operRole != 4" >
SELECT master_id,master_id approveCount FROM archive_flow_info WHERE step_index = 1 and oper_role = ${operRole}
</if>
</if>
) temp3 ON m.id = temp3.master_id
</if>
<if test= "infoId != 1" >
INNER JOIN
@ -316,7 +325,7 @@
<!-- - 出院 -->
<select id= "selectByColumn" parameterType= "com.emr.entity.Archive_Master_Vo" resultMap= "BaseResultMap2" >
select m.id,m.patient_id,m.inp_no,m.visit_id,m.name,m.sex,m.
select * from (select 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.
dept_admission_to,m.LockInfo,m.DOCTOR_IN_CHARGE
from archive_master m
@ -332,17 +341,25 @@
inner join
(select archive_flow_info.master_id from archive_flow_info
inner join
(select MAX(createtime) createtime,master_id from archive_flow_info 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 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" >
inner join
(select master_id from archive_flow_info where target_step_id in (${status}) group by master_id
having COUNT(master_id) =
2) temp1
on archive_flow_info.master_id = temp1.master_id
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>
/**已审批*/
@ -359,19 +376,16 @@
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 != #{status}
INNER JOIN (
SELECT
master_id
FROM
archive_flow_info
WHERE
start_step_id = #{status}
) temp1 ON archive_flow_info.master_id = temp1.master_id) archive_flow_info
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>
@ -389,7 +403,14 @@
dept_admission_to,m.LockInfo,m.DOCTOR_IN_CHARGE
from archive_master m
/**带状态查询*/
left join (select master_id from archive_flow_info where start_step_id in(${status}) group by master_id)
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
/**带完整性查询*/
@ -406,7 +427,9 @@
and archive_flow_info.master_id is null
<include refid= "beHospitalSeach" > </include>
</if>
) m
ORDER BY m.discharge_date_time desc
</select>
<!-- 终审 -->