|
|
|
@ -1369,8 +1369,14 @@
|
|
|
|
|
<select id="selectOverdue" parameterType="com.emr.entity.Archive_Master_Vo" resultMap="BaseResultMap2">
|
|
|
|
|
select m.id,m.patient_id, m.inp_no,m.visit_id,m.name,m.discharge_date_time
|
|
|
|
|
,CONVERT(varchar(10),m.admission_date_time, 120)admission_date_time,t.name dept_admission_to,g.name dept_name,m.DOCTOR_IN_CHARGE,m.death_flag,
|
|
|
|
|
d.*,[dbo].[getWorkday](m.discharge_date_time,d.create_time) overdue from archive_master m
|
|
|
|
|
LEFT JOIN(select master_id archive_detail_id,handle_time create_time,handle_name first_instance from (
|
|
|
|
|
d.*,[dbo].[getWorkday](m.discharge_date_time,d.create_time) overdue from
|
|
|
|
|
(select
|
|
|
|
|
id, patient_id, inp_no, visit_id, name, sex, dept_name, CONVERT(varchar(10),discharge_date_time, 120)discharge_date_time, ArchiveState,
|
|
|
|
|
admission_date_time, dept_admission_to, check_doctor, check_datetime, checked_doctor, transfer_dept,
|
|
|
|
|
checked_datetime, LockInfo, DOCTOR_IN_CHARGE, ID_NO, DISCHARGE_DISPOSITION, dept_code_lend,isscaned,is_scanning,
|
|
|
|
|
cmt_doctor,cmt_nurse,doctor_name,nurse_name,cmt_doctor_date,cmt_nurse_date,emr_doctor_cmt,emr_nure_cmt,death_flag,
|
|
|
|
|
bed_number,is_sign,signer,sign_time from archive_master) m
|
|
|
|
|
LEFT JOIN(select master_id archive_detail_id,CONVERT(varchar(10),handle_time, 120) create_time,handle_name first_instance from (
|
|
|
|
|
select ROW_NUMBER() over(partition by master_id order by handle_time asc) RowNum
|
|
|
|
|
,Archive_Master_Following.*
|
|
|
|
|
from Archive_Master_Following where 1=1 and following_type ='5' ) as t1 where 1=1 and RowNum = 1
|
|
|
|
@ -1437,17 +1443,88 @@
|
|
|
|
|
and d.create_time <= #{createTimeEnd,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
<if test="deathFlag != null and deathFlag != ''">
|
|
|
|
|
and m.death_flag = #{deathFlag,jdbcType=NVARCHAR}
|
|
|
|
|
<if test="deathFlag == '0'.toString()">
|
|
|
|
|
and [dbo].[getWorkday](m.discharge_date_time,d.create_time)>3
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deathFlag == '1'.toString()">
|
|
|
|
|
and [dbo].[getWorkday](m.discharge_date_time,d.create_time)>7
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="overdueDays != null and overdueDays != ''">
|
|
|
|
|
and m.death_flag ='0'
|
|
|
|
|
and convert(int,[dbo].[getWorkday](m.discharge_date_time,d.create_time))-convert(int,#{overdueDays,jdbcType=INTEGER})>0
|
|
|
|
|
union
|
|
|
|
|
select m.id,m.patient_id, m.inp_no,m.visit_id,m.name,m.discharge_date_time
|
|
|
|
|
,CONVERT(varchar(10),m.admission_date_time, 120)admission_date_time,t.name dept_admission_to,g.name dept_name,m.DOCTOR_IN_CHARGE,m.death_flag,
|
|
|
|
|
d.*,[dbo].[getWorkday](m.discharge_date_time,d.create_time) overdue from
|
|
|
|
|
(select
|
|
|
|
|
id, patient_id, inp_no, visit_id, name, sex, dept_name, CONVERT(varchar(10),discharge_date_time, 120)discharge_date_time, ArchiveState,
|
|
|
|
|
admission_date_time, dept_admission_to, check_doctor, check_datetime, checked_doctor, transfer_dept,
|
|
|
|
|
checked_datetime, LockInfo, DOCTOR_IN_CHARGE, ID_NO, DISCHARGE_DISPOSITION, dept_code_lend,isscaned,is_scanning,
|
|
|
|
|
cmt_doctor,cmt_nurse,doctor_name,nurse_name,cmt_doctor_date,cmt_nurse_date,emr_doctor_cmt,emr_nure_cmt,death_flag,
|
|
|
|
|
bed_number,is_sign,signer,sign_time from archive_master) m
|
|
|
|
|
LEFT JOIN(select master_id archive_detail_id,CONVERT(varchar(10),handle_time, 120) create_time,handle_name first_instance from (
|
|
|
|
|
select ROW_NUMBER() over(partition by master_id order by handle_time asc) RowNum
|
|
|
|
|
,Archive_Master_Following.*
|
|
|
|
|
from Archive_Master_Following where 1=1 and following_type ='5' ) as t1 where 1=1 and RowNum = 1
|
|
|
|
|
) d
|
|
|
|
|
on m.id=d.archive_detail_id
|
|
|
|
|
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
|
|
|
|
|
typeCode='dept_code' )) t
|
|
|
|
|
on m.dept_admission_to=t.code
|
|
|
|
|
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
|
|
|
|
|
typeCode='dept_code' )) g
|
|
|
|
|
on m.dept_name=g.code
|
|
|
|
|
where 1=1
|
|
|
|
|
and m.death_flag ='1'
|
|
|
|
|
<if test="id != null and id != ''">
|
|
|
|
|
and m.id = #{id,jdbcType=NVARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="inpNo != null and inpNo != ''">
|
|
|
|
|
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="visitId != null and visitId != ''">
|
|
|
|
|
and m.visit_id=#{visitId,jdbcType=NCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
and m.name like '%'+#{name,jdbcType=NCHAR}+'%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deptName!= null and deptName!= ''">
|
|
|
|
|
and m.dept_name in
|
|
|
|
|
<foreach item="item" collection="deptName.split(',')" open="(" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deptAdmissionTo != null and deptAdmissionTo!=''">
|
|
|
|
|
and m.dept_admission_to in
|
|
|
|
|
<foreach item="item" collection="deptAdmissionTo.split(',')" open="(" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="dischargeDateTime != null">
|
|
|
|
|
and m.discharge_date_time = #{dischargeDateTime,jdbcType=NVARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
|
|
|
|
and m.discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
|
|
|
|
|
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="startDate != null and startDate != ''">
|
|
|
|
|
and m.discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDate != null and endDate != ''">
|
|
|
|
|
and m.discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
<if test="createTime != null">
|
|
|
|
|
and d.create_time = #{createTime,jdbcType=NVARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="createTimeStart != null and createTimeStart != '' and createTimeEnd != null and createTimeEnd != ''">
|
|
|
|
|
and d.create_time between CONVERT(VARCHAR(10),#{createTimeStart,jdbcType=NCHAR},120) and
|
|
|
|
|
#{createTimeEnd,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="createTimeStart != null and createTimeStart != ''">
|
|
|
|
|
and d.create_time >= CONVERT(VARCHAR(10),#{createTimeStart,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="createTimeEnd != null and createTimeEnd != ''">
|
|
|
|
|
and d.create_time <= #{createTimeEnd,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
and [dbo].[getWorkday](m.discharge_date_time,d.create_time)>7
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<!--封存日志-->
|
|
|
|
|