|
|
|
@ -109,7 +109,7 @@
|
|
|
|
|
bed_number,is_sign,signer,sign_time
|
|
|
|
|
</sql>
|
|
|
|
|
<select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
|
|
|
|
|
select
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List" />
|
|
|
|
|
from archive_master
|
|
|
|
|
where id = #{id,jdbcType=NVARCHAR}
|
|
|
|
@ -1024,19 +1024,19 @@
|
|
|
|
|
where id = #{id,jdbcType=NVARCHAR}
|
|
|
|
|
</delete>
|
|
|
|
|
<insert id="insert" parameterType="com.emr.entity.Archive_Master">
|
|
|
|
|
insert into archive_master (id, patient_id, inp_no,
|
|
|
|
|
visit_id, name, sex,
|
|
|
|
|
dept_name, discharge_date_time, ArchiveState,
|
|
|
|
|
admission_date_time, dept_admission_to, check_doctor,
|
|
|
|
|
check_datetime, checked_doctor, checked_datetime,
|
|
|
|
|
LockInfo, DOCTOR_IN_CHARGE, ID_NO,
|
|
|
|
|
insert into archive_master (id, patient_id, inp_no,
|
|
|
|
|
visit_id, name, sex,
|
|
|
|
|
dept_name, discharge_date_time, ArchiveState,
|
|
|
|
|
admission_date_time, dept_admission_to, check_doctor,
|
|
|
|
|
check_datetime, checked_doctor, checked_datetime,
|
|
|
|
|
LockInfo, DOCTOR_IN_CHARGE, ID_NO,
|
|
|
|
|
DISCHARGE_DISPOSITION, dept_code_lend,isscaned,first_instance)
|
|
|
|
|
values (#{id,jdbcType=NVARCHAR}, #{patientId,jdbcType=NVARCHAR}, #{inpNo,jdbcType=NVARCHAR},
|
|
|
|
|
#{visitId,jdbcType=NVARCHAR}, #{name,jdbcType=NVARCHAR}, #{sex,jdbcType=NVARCHAR},
|
|
|
|
|
#{deptName,jdbcType=NVARCHAR}, #{dischargeDateTime,jdbcType=NVARCHAR}, #{archivestate,jdbcType=NVARCHAR},
|
|
|
|
|
#{admissionDateTime,jdbcType=NVARCHAR}, #{deptAdmissionTo,jdbcType=NVARCHAR}, #{checkDoctor,jdbcType=NVARCHAR},
|
|
|
|
|
#{checkDatetime,jdbcType=NVARCHAR}, #{checkedDoctor,jdbcType=NVARCHAR}, #{checkedDatetime,jdbcType=NVARCHAR},
|
|
|
|
|
#{lockinfo,jdbcType=NVARCHAR}, #{doctorInCharge,jdbcType=NVARCHAR}, #{idNo,jdbcType=NVARCHAR},
|
|
|
|
|
values (#{id,jdbcType=NVARCHAR}, #{patientId,jdbcType=NVARCHAR}, #{inpNo,jdbcType=NVARCHAR},
|
|
|
|
|
#{visitId,jdbcType=NVARCHAR}, #{name,jdbcType=NVARCHAR}, #{sex,jdbcType=NVARCHAR},
|
|
|
|
|
#{deptName,jdbcType=NVARCHAR}, #{dischargeDateTime,jdbcType=NVARCHAR}, #{archivestate,jdbcType=NVARCHAR},
|
|
|
|
|
#{admissionDateTime,jdbcType=NVARCHAR}, #{deptAdmissionTo,jdbcType=NVARCHAR}, #{checkDoctor,jdbcType=NVARCHAR},
|
|
|
|
|
#{checkDatetime,jdbcType=NVARCHAR}, #{checkedDoctor,jdbcType=NVARCHAR}, #{checkedDatetime,jdbcType=NVARCHAR},
|
|
|
|
|
#{lockinfo,jdbcType=NVARCHAR}, #{doctorInCharge,jdbcType=NVARCHAR}, #{idNo,jdbcType=NVARCHAR},
|
|
|
|
|
#{dischargeDisposition,jdbcType=NVARCHAR}, #{deptCodeLend,jdbcType=NVARCHAR}, #{isscaned,jdbcType=NVARCHAR}, #{firstInstance,jdbcType=NVARCHAR})
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="insertSelective" parameterType="com.emr.entity.Archive_Master">
|
|
|
|
@ -1579,112 +1579,112 @@
|
|
|
|
|
INNER JOIN Archive_Master_Following f on m.ID=f.master_id
|
|
|
|
|
where 1=1 AND f.following_type in('11','12')
|
|
|
|
|
<if test="inpNo != null and inpNo != ''">
|
|
|
|
|
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
|
|
|
|
|
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="visitId != null and visitId != ''">
|
|
|
|
|
and m.visit_id=#{visitId,jdbcType=NCHAR}
|
|
|
|
|
and m.visit_id=#{visitId,jdbcType=NCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
and m.name like '%'+#{name,jdbcType=NCHAR}+'%'
|
|
|
|
|
and m.name like '%'+#{name,jdbcType=NCHAR}+'%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="archivestate != null and archivestate != ''">
|
|
|
|
|
and m.ArchiveState=#{archivestate,jdbcType=NVARCHAR}
|
|
|
|
|
and m.ArchiveState=#{archivestate,jdbcType=NVARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="handleName != null and handleName != ''">
|
|
|
|
|
and f.handle_name=#{handleName,jdbcType=NVARCHAR}
|
|
|
|
|
and f.handle_name=#{handleName,jdbcType=NVARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="followingContent != null and followingContent != ''">
|
|
|
|
|
and f.following_content=#{followingContent,jdbcType=NVARCHAR}
|
|
|
|
|
and f.following_content=#{followingContent,jdbcType=NVARCHAR}
|
|
|
|
|
</if>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
|
|
|
|
and f.handle_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
|
|
|
|
|
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="startDate != null and startDate != ''">
|
|
|
|
|
and f.handle_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDate != null and endDate != ''">
|
|
|
|
|
and f.handle_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
|
|
|
|
and f.handle_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
|
|
|
|
|
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="startDate != null and startDate != ''">
|
|
|
|
|
and f.handle_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDate != null and endDate != ''">
|
|
|
|
|
and f.handle_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
ORDER BY f.handle_time desc
|
|
|
|
|
</select>
|
|
|
|
|
</select>
|
|
|
|
|
<!--留观病历查询-->
|
|
|
|
|
<select id="getObservationRecordList" resultType="com.emr.entity.Archive_Master">
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
patient_id,
|
|
|
|
|
inp_no,
|
|
|
|
|
visit_id,
|
|
|
|
|
NAME,
|
|
|
|
|
CONVERT ( nvarchar ( 19 ), admission_date_time, 23 ) admission_date_time,
|
|
|
|
|
CONVERT ( nvarchar ( 19 ), discharge_date_time, 23 ) discharge_date_time,
|
|
|
|
|
ArchiveState,
|
|
|
|
|
CASE
|
|
|
|
|
SELECT
|
|
|
|
|
id,
|
|
|
|
|
patient_id,
|
|
|
|
|
inp_no,
|
|
|
|
|
visit_id,
|
|
|
|
|
NAME,
|
|
|
|
|
CONVERT ( nvarchar ( 19 ), admission_date_time, 23 ) admission_date_time,
|
|
|
|
|
CONVERT ( nvarchar ( 19 ), discharge_date_time, 23 ) discharge_date_time,
|
|
|
|
|
ArchiveState,
|
|
|
|
|
CASE
|
|
|
|
|
|
|
|
|
|
WHEN death_flag = '1' THEN
|
|
|
|
|
'是' ELSE '否'
|
|
|
|
|
END death_flag
|
|
|
|
|
FROM
|
|
|
|
|
Archive_Master
|
|
|
|
|
WHERE
|
|
|
|
|
inp_no LIKE 'LG%'
|
|
|
|
|
AND ArchiveState != '已归档'
|
|
|
|
|
<if test="patientId != null and patientId != ''">
|
|
|
|
|
AND patient_id LIKE '%' + #{patientId} + '%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="inpNo != null and inpNo != ''">
|
|
|
|
|
AND inp_no LIKE '%' + #{inpNo} + '%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="visitId != null and visitId != ''">
|
|
|
|
|
AND visit_id = #{visitId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
AND name LIKE '%' + #{name} + '%'
|
|
|
|
|
</if>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
|
|
|
|
and 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 discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDate != null and endDate != ''">
|
|
|
|
|
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="startDateTo != null and startDateTo != '' and endDateTo != null and endDateTo != ''">
|
|
|
|
|
and admission_date_time between CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120) and
|
|
|
|
|
#{endDateTo,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="startDateTo != null and startDateTo != ''">
|
|
|
|
|
and admission_date_time >= CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDateTo != null and endDateTo != ''">
|
|
|
|
|
and admission_date_time <= #{endDateTo,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
<if test="archivestate != null and archivestate != ''">
|
|
|
|
|
AND ArchiveState = #{archivestate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deathFlag != null and deathFlag != ''">
|
|
|
|
|
AND death_flag = #{deathFlag}
|
|
|
|
|
</if>
|
|
|
|
|
WHEN death_flag = '1' THEN
|
|
|
|
|
'是' ELSE '否'
|
|
|
|
|
END death_flag
|
|
|
|
|
FROM
|
|
|
|
|
Archive_Master
|
|
|
|
|
WHERE
|
|
|
|
|
inp_no LIKE 'LG%'
|
|
|
|
|
AND ArchiveState != '已归档'
|
|
|
|
|
<if test="patientId != null and patientId != ''">
|
|
|
|
|
AND patient_id LIKE '%' + #{patientId} + '%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="inpNo != null and inpNo != ''">
|
|
|
|
|
AND inp_no LIKE '%' + #{inpNo} + '%'
|
|
|
|
|
</if>
|
|
|
|
|
<if test="visitId != null and visitId != ''">
|
|
|
|
|
AND visit_id = #{visitId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
AND name LIKE '%' + #{name} + '%'
|
|
|
|
|
</if>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
|
|
|
|
and 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 discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDate != null and endDate != ''">
|
|
|
|
|
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="startDateTo != null and startDateTo != '' and endDateTo != null and endDateTo != ''">
|
|
|
|
|
and admission_date_time between CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120) and
|
|
|
|
|
#{endDateTo,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
<when test="startDateTo != null and startDateTo != ''">
|
|
|
|
|
and admission_date_time >= CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120)
|
|
|
|
|
</when>
|
|
|
|
|
<when test="endDateTo != null and endDateTo != ''">
|
|
|
|
|
and admission_date_time <= #{endDateTo,jdbcType=NCHAR}+ ' 23:59:59'
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
<if test="archivestate != null and archivestate != ''">
|
|
|
|
|
AND ArchiveState = #{archivestate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deathFlag != null and deathFlag != ''">
|
|
|
|
|
AND death_flag = #{deathFlag}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<!--封存查询-->
|
|
|
|
|
<!--封存查询-->
|
|
|
|
|
<select id="selectStorageByCol" parameterType="com.emr.entity.Archive_Master_Vo" resultMap="BaseResultMap2">
|
|
|
|
|
select m.id ,m.inp_no,m.visit_id,m.name,ISNULL(f.name, m.dept_name) dept_name,m.discharge_date_time,m.ArchiveState,m.sex,m.ID_NO,
|
|
|
|
|
ISNULL(c.name, m.dept_admission_to) dept_admission_to
|
|
|
|
|
,m.admission_date_time,m.DISCHARGE_DISPOSITION,d.handle_time,d.handle_name,d.following_type
|
|
|
|
|
from(select * from Archive_Master where ArchiveState!='作废') m
|
|
|
|
|
LEFT JOIN(
|
|
|
|
|
select master_id ,handle_time ,handle_name,following_type from (
|
|
|
|
|
select ROW_NUMBER() over(partition by master_id order by handle_time desc) RowNum
|
|
|
|
|
,Archive_Master_Following.*
|
|
|
|
|
from Archive_Master_Following where 1=1 ) as t1 where 1=1 and RowNum = 1 and following_type='11'
|
|
|
|
|
select master_id ,handle_time ,handle_name,following_type from (
|
|
|
|
|
select ROW_NUMBER() over(partition by master_id order by handle_time desc) RowNum
|
|
|
|
|
,Archive_Master_Following.*
|
|
|
|
|
from Archive_Master_Following where 1=1 ) as t1 where 1=1 and RowNum = 1 and following_type='11'
|
|
|
|
|
) d
|
|
|
|
|
on m.id=d.master_id
|
|
|
|
|
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
|
|
|
|
|