@ -281,24 +281,45 @@
<include refid= "beHospitalSeach" > </include>
</sql>
<!-- 带审核节点查询 -->
<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
</if>
<if test= "infoId != 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= "roles != null and roles !=''" >
where archive_flow_info.oper_role = #{roles} OR oper_role = 4
</if>
GROUP BY master_id ) temp ON archive_flow_info.master_id = temp.master_id
AND archive_flow_info.createtime = temp.createtime
<choose >
<when test= "infoId > 7" >
AND archive_flow_info.target_step_id = #{infoId}
</when>
<otherwise >
AND archive_flow_info.start_step_id = #{infoId} and archive_flow_info.sumbit_name not like '%退回'
</otherwise>
</choose>
) temp1
ON m.id = temp1.master_id
</if>
</if>
</sql>
<!-- - 出院 -->
<select id= "selectByColumn" parameterType= "com.emr.entity.Archive_Master_Vo" resultMap= "BaseResultMap2" >
select * from (select m.id,m.inp_no,m.visit_id,m.name,m.sex,f.name
dept_name,m.discharge_date_time,m.ArchiveState,m.admission_date_time,d.name
dept_admission_to,m.LockInfo,m.DOCTOR_IN_CHARGE,
datediff(day,m.discharge_date_time,getdate()) -
(select COUNT(1) from emr_holiday_set where date between convert(varchar(10),m.discharge_date_time,120)
and getdate() and flag = 2)-(select CASE
WHEN m.DISCHARGE_DISPOSITION = 5 THEN
dead_days
ELSE
days
END from emr_overtime_set where id = 1) days
select m.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
LEFT JOIN (select code,name from emr_dictionary where parent_id='dept_code') d
on m.dept_admission_to=d.code
LEFT JOIN (select code,name from emr_dictionary where parent_id='dept_code') f
on m.dept_name=f.code
/**带完整性查询*/
<if test= "isSuccess != null and isSuccess != ''" >
INNER JOIN (<include refid= "searchSuccessForMasterIdList" > </include> ) temp
@ -354,26 +375,19 @@
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 m.id,m.inp_no,m.visit_id,m.name,m.sex,f.name
dept_name,m.discharge_date_time,m.ArchiveState,m.admission_date_time,d.name
dept_admission_to,m.LockInfo,m.DOCTOR_IN_CHARGE,
datediff(day,m.discharge_date_time,getdate()) -
(select COUNT(1) from emr_holiday_set where date between convert(varchar(10),m.discharge_date_time,120)
and getdate() and flag = 2)-(select CASE
WHEN m.DISCHARGE_DISPOSITION = 5 THEN
dead_days
ELSE
days
END from emr_overtime_set where id = 1) days
select m.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
LEFT JOIN (select code,name from emr_dictionary where parent_id='dept_code') d
on m.dept_admission_to=d.code
LEFT JOIN (select code,name from emr_dictionary where parent_id='dept_code') f
on m.dept_name=f.code
/**带状态查询*/
left join (select master_id from archive_flow_info where start_step_id in(${status}) group by master_id)
archive_flow_info
@ -383,10 +397,15 @@
INNER JOIN (<include refid= "searchSuccessForMasterIdList" > </include> ) temp
ON m.id = temp.id
</if>
where 1=1 and archive_flow_info.master_id is null
/**根据审核节点查询*/
<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>
) m
ORDER BY m.discharge_date_time desc
</select>
@ -987,4 +1006,40 @@
UPDATE archive_master SET LockInfo = #{lockinfo}
WHERE id IN (${masterIds})
</update>
<!-- - 查询出院工作日 -->
<select id= "selectDaysByMasterIds" resultMap= "BaseResultMap2" >
SELECT
m.id,
datediff(
DAY,
m.discharge_date_time,
getdate ()) - (
SELECT
COUNT( 1 )
FROM
emr_holiday_set
WHERE
date BETWEEN CONVERT ( VARCHAR ( 10 ), m.discharge_date_time, 120 )
AND getdate ()
AND flag = 2
)-(
SELECT
CASE
WHEN
m.DISCHARGE_DISPOSITION = 5 THEN
dead_days ELSE days
END
FROM
emr_overtime_set
WHERE
id = 1
) days
FROM
archive_master m
WHERE
m.id IN(
<foreach collection= "list" item= "item" separator= "," > #{item.id,jdbcType=NVARCHAR}</foreach>
)
</select>
</mapper>