@ -113,6 +113,8 @@
<result column= "flag" jdbcType= "INTEGER" property= "flag" />
<result column= "countNum" jdbcType= "INTEGER" property= "countNum" />
<result column= "handleTimeMax1" jdbcType= "NVARCHAR" property= "handleTimeMax1" />
<result column= "print_flag" jdbcType= "INTEGER" property= "printFlag" />
</resultMap>
<sql id= "Base_Column_List" >
id, patient_id, inp_no, visit_id, name, sex, dept_name, discharge_date_time, ArchiveState,
@ -175,7 +177,7 @@
,ISNULL(printTable.num, 0) printNum
from archive_master m
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) d
typeCode='dept_code' ))d
on m.dept_admission_to=d.code
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) f
@ -247,8 +249,6 @@
and m.admission_date_time < = #{endDateTo,jdbcType=NCHAR}+ ' 23:59:59'
</when>
</choose>
<if test= "checkDoctor != null" >
and m.check_doctor = #{checkDoctor,jdbcType=NVARCHAR}
</if>
@ -415,12 +415,164 @@
ORDER BY discharge_date_time desc
</select>
<!-- <select id="selectByLast" 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.dept_name,CONVERT(varchar(10),m.discharge_date_time, 120) discharge_date_time,m.ArchiveState,CONVERT(varchar(10),m.admission_date_time, 120) admission_date_time, -->
<!-- m.dept_admission_to,m.check_doctor,m.checked_datetime,m.checked_doctor,m.LockInfo,m.DOCTOR_IN_CHARGE,m.ID_NO,m.DISCHARGE_DISPOSITION,m.dept_code_lend,m.isscaned, -->
<!-- m.cmt_doctor,m.cmt_nurse,m.doctor_name,m.nurse_name,m.cmt_doctor_date,m.cmt_nurse_date,m.emr_doctor_cmt,m.emr_nure_cmt,m.death_flag,m.first_instance, -->
<!-- m.is_scanning,m.bed_number,ISNULL(s.numb, 0) numb,ao.C5 is_sign,ISNULL(sNurse.numb, 0) faultNurseNum,ISNULL(sDoctor.numb, 0) faultDoctorNum -->
<!-- ,case when emr_fault_detail.archive_detail_id is not null then '是' else '否' end isFault,ISNULL(printTable.num, 0) printNum -->
<!-- from archive_master m -->
<!-- left join (select distinct archive_detail_id from emr_fault_detail where back_flag in ('6','5')) emr_fault_detail -->
<!-- on emr_fault_detail.archive_detail_id = m.ID -->
<!-- LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag is not null GROUP BY archive_detail_id) s -->
<!-- on m.id=s.archive_detail_id -->
<!-- LEFT JOIN (select distinct masterID,C5 FROM archive_other where sysFlag = '1') ao -->
<!-- on m.id=ao.masterID -->
<!-- LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('2','6') GROUP BY archive_detail_id) sNurse -->
<!-- on m.id=sNurse.archive_detail_id -->
<!-- LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('1','5') GROUP BY archive_detail_id) sDoctor -->
<!-- on m.id=sDoctor.archive_detail_id -->
<!-- LEFT JOIN (select MasterID,COUNT(*) num from archive_printInfo group by MasterID) printTable -->
<!-- on m.id=printTable.MasterID -->
<!-- where 1=1 and ArchiveState in('初审') and m.Is_Valid!=1 -->
<!-- and patindex('%B%',m.inp_no) = 0 and inp_no not like 'LG%' -->
<!-- <if test="isFault != null and isFault != ''"> -->
<!-- <if test="isFault == 1"> -->
<!-- AND emr_fault_detail.archive_detail_id is not null -->
<!-- </if> -->
<!-- <if test="isFault == 0"> -->
<!-- AND emr_fault_detail.archive_detail_id is null -->
<!-- </if> -->
<!-- </if> -->
<!-- <if test="printNum != null and printNum != ''"> -->
<!-- <choose> -->
<!-- <when test="printNum == 1"> -->
<!-- and printTable.MasterID is not null -->
<!-- </when> -->
<!-- <otherwise>and printTable.MasterID is null</otherwise> -->
<!-- </choose> -->
<!-- </if> -->
<!-- <if test="inpNo != null and inpNo != ''"> -->
<!-- and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%' -->
<!-- </if> -->
<!-- <if test="bedNumber != null and bedNumber != ''"> -->
<!-- and m.bed_number like '%'+#{bedNumber,jdbcType=NVARCHAR}+'%' -->
<!-- </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="archivestate != null and archivestate != ''"> -->
<!-- and m.ArchiveState in(#{archivestate,jdbcType=NVARCHAR}) -->
<!-- </if> -->
<!-- <if test="idNo != null and idNo != ''"> -->
<!-- and m.ID_NO like '%'+#{idNo,jdbcType=NCHAR}+'%' -->
<!-- </if> -->
<!-- <if test="sex != null"> -->
<!-- and m.sex = #{sex,jdbcType=NVARCHAR} -->
<!-- </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 = #{deptAdmissionTo,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="dischargeDateTime != null"> -->
<!-- and m.discharge_date_time = #{dischargeDateTime,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <choose> -->
<!-- <when test="startDateTo != null and startDateTo != '' and endDateTo != null and endDateTo != ''"> -->
<!-- and m.discharge_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 m.discharge_date_time >= CONVERT(VARCHAR(10),#{startDateTo,jdbcType=NCHAR},120) -->
<!-- </when> -->
<!-- <when test="endDateTo != null and endDateTo != ''"> -->
<!-- and m.discharge_date_time <= #{endDateTo,jdbcType=NCHAR}+ ' 23:59:59' -->
<!-- </when> -->
<!-- </choose> -->
<!-- <choose> -->
<!-- <when test="startDate != null and startDate != '' and endDate != null and endDate != ''"> -->
<!-- and m.admission_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.admission_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) -->
<!-- </when> -->
<!-- <when test="endDate != null and endDate != ''"> -->
<!-- and m.admission_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59' -->
<!-- </when> -->
<!-- </choose> -->
<!-- <if test="checkDoctor != null"> -->
<!-- and m.check_doctor = #{checkDoctor,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="checkDatetime != null"> -->
<!-- and m.check_datetime = #{checkDatetime,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="checkedDoctor != null"> -->
<!-- and m.checked_doctor = #{checkedDoctor,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="checkedDatetime != null"> -->
<!-- and m.checked_datetime = #{checkedDatetime,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="lockinfo != null"> -->
<!-- and m.LockInfo = #{lockinfo,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="doctorInCharge != null"> -->
<!-- and m.DOCTOR_IN_CHARGE = #{doctorInCharge,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="dischargeDisposition != null"> -->
<!-- and m.DISCHARGE_DISPOSITION = #{dischargeDisposition,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="deptCodeLend != null"> -->
<!-- and m.dept_code_lend = #{deptCodeLend,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="isscaned != null and isscaned != ''"> -->
<!-- and m.isscaned = #{isscaned,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="deathFlag != null and deathFlag != ''"> -->
<!-- and m.death_flag = #{deathFlag,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="isScanning != null and isScanning != ''"> -->
<!-- and m.is_scanning = #{isScanning,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="isSign != null "> -->
<!-- and ao.C5 = #{isSign,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="signer != null and signer != ''"> -->
<!-- and ao.C1 like '%'+#{signer,jdbcType=NCHAR}+'%' -->
<!-- </if> -->
<!-- <choose> -->
<!-- <when test="startSignDate != null and startSignDate != '' and endSignDate != null and endSignDate != ''"> -->
<!-- and m.sign_time between CONVERT(VARCHAR(10),#{startSignDate,jdbcType=NCHAR},120) and -->
<!-- #{endSignDate,jdbcType=NCHAR}+ ' 23:59:59' -->
<!-- </when> -->
<!-- <when test="startSignDate != null and startSignDate != ''"> -->
<!-- and m.sign_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) -->
<!-- </when> -->
<!-- <when test="endSignDate != null and endSignDate != ''"> -->
<!-- and m.sign_time <= #{endSignDate,jdbcType=NCHAR}+ ' 23:59:59' -->
<!-- </when> -->
<!-- </choose> -->
<!-- ORDER BY discharge_date_time desc -->
<!-- </select> -->
<select id= "selectByLast" 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.dept_name,CONVERT(varchar(10),m.discharge_date_time, 120) discharge_date_time,m.ArchiveState,CONVERT(varchar(10),m.admission_date_time, 120) admission_date_time,
m.dept_admission_to,m.check_doctor,m.checked_datetime,m.checked_doctor,m.LockInfo,m.DOCTOR_IN_CHARGE,m.ID_NO,m.DISCHARGE_DISPOSITION,m.dept_code_lend,m.isscaned,
m.cmt_doctor,m.cmt_nurse,m.doctor_name,m.nurse_name,m.cmt_doctor_date,m.cmt_nurse_date,m.emr_doctor_cmt,m.emr_nure_cmt,m.death_flag,m.first_instance,
m.is_scanning,m.bed_number,ISNULL(s.numb, 0) numb,ao.C5 is_sign,ISNULL(sNurse.numb, 0) faultNurseNum,ISNULL(sDoctor.numb, 0) faultDoctorNum
,case when emr_fault_detail.archive_detail_id is not null then '是' else '否' end isFault,ISNULL(printTable.num, 0) printNum
,case when emr_fault_detail.archive_detail_id is not null then '是' else '否' end isFault,m.print_flag as printNum
from archive_master m
left join (select distinct archive_detail_id from emr_fault_detail where back_flag in ('6','5')) emr_fault_detail
on emr_fault_detail.archive_detail_id = m.ID
@ -432,8 +584,6 @@
on m.id=sNurse.archive_detail_id
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('1','5') GROUP BY archive_detail_id) sDoctor
on m.id=sDoctor.archive_detail_id
LEFT JOIN (select MasterID,COUNT(*) num from archive_printInfo group by MasterID) printTable
on m.id=printTable.MasterID
where 1=1 and ArchiveState in('初审') and m.Is_Valid!=1
and patindex('%B%',m.inp_no) = 0 and inp_no not like 'LG%'
<if test= "isFault != null and isFault != ''" >
@ -444,14 +594,17 @@
AND emr_fault_detail.archive_detail_id is null
</if>
</if>
<if test= "printNum != null and printNum != ''" >
<choose >
<when test= "printNum == 1" >
and printTable.MasterID is not null
</when>
<otherwise > and printTable.MasterID is null</otherwise>
</choose>
<if test= "printNum !=null and printNum !=''" >
AND m.print_flag=#{printNum}
</if>
<!-- <if test="printNum != null and printNum != ''"> -->
<!-- <choose> -->
<!-- <when test="printNum == 1"> -->
<!-- and printTable.MasterID is not null -->
<!-- </when> -->
<!-- <otherwise>and printTable.MasterID is null</otherwise> -->
<!-- </choose> -->
<!-- </if> -->
<if test= "inpNo != null and inpNo != ''" >
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
</if>
@ -564,6 +717,9 @@
ORDER BY discharge_date_time desc
</select>
<select id= "selectByUnfile" 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,ISNULL(f.name,m.dept_name) dept_name,CONVERT(varchar(10),m.discharge_date_time, 120) discharge_date_time
,m.ArchiveState,CONVERT(varchar(10),m.admission_date_time, 120) admission_date_time,ISNULL(d.name,m.dept_admission_to) dept_admission_to
@ -1084,6 +1240,9 @@
delete from archive_master
where id = #{id,jdbcType=NVARCHAR}
</delete>
<delete id= "deleteRecordByInp" >
DELETE FROM commomtable WHERE patient_id = #{masterId}
</delete>
<insert id= "insert" parameterType= "com.emr.entity.Archive_Master" >
insert into archive_master (id, patient_id, inp_no,
visit_id, name, sex,
@ -1239,6 +1398,97 @@
</if>
</trim>
</insert>
<insert id= "insertCommonlyUsed" >
insert into commomtable
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "patientId != null" >
patient_id,
</if>
<if test= "admissTimes != null" >
admiss_times,
</if>
<if test= "inpatientNo != null" >
inpatient_no,
</if>
<if test= "name != null" >
name,
</if>
<if test= "sex != null" >
sex,
</if>
<if test= "age != null" >
age,
</if>
<if test= "admissDate != null" >
admiss_date,
</if>
<if test= "disDate != null" >
dis_date,
</if>
<if test= "disDept != null" >
dis_dept,
</if>
<if test= "checkedDatetime != null" >
checked_datetime,
</if>
<if test= "admissId != null" >
admiss_id,
</if>
<if test= "ageMonth != null" >
age_month,
</if>
<if test= "attending != null" >
attending,
</if>
<if test= "admissDays != null" >
admiss_days,
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "patientId != null" >
#{patientId,jdbcType=NVARCHAR},
</if>
<if test= "admissTimes != null" >
#{admissTimes,jdbcType=INTEGER},
</if>
<if test= "inpatientNo != null" >
#{inpatientNo,jdbcType=NVARCHAR},
</if>
<if test= "name != null" >
#{name,jdbcType=NVARCHAR},
</if>
<if test= "sex != null" >
#{sex,jdbcType=NVARCHAR},
</if>
<if test= "age != null" >
#{age,jdbcType=NVARCHAR},
</if>
<if test= "admissDate != null" >
#{admissDate},
</if>
<if test= "disDate != null" >
#{disDate},
</if>
<if test= "disDept != null" >
#{disDept,jdbcType=NVARCHAR},
</if>
<if test= "checkedDatetime != null" >
#{checkedDatetime,jdbcType=NVARCHAR},
</if>
<if test= "admissId != null" >
#{admissId,jdbcType=NVARCHAR},
</if>
<if test= "ageMonth != null" >
#{ageMonth,jdbcType=NVARCHAR},
</if>
<if test= "attending != null" >
#{attending,jdbcType=NVARCHAR},
</if>
<if test= "admissDays != null" >
#{admissDays,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id= "updateByClo" parameterType= "com.emr.entity.Archive_Master" >
update archive_master
<set >
@ -2420,4 +2670,8 @@
</choose>
</where>
</select>
<select id= "selectCommonlyUsed" resultType= "com.emr.entity.Archive_Master" >
select * from archive_master where id =#{id}
</select>
</mapper>