@ -549,12 +549,12 @@
m.visit_id,
m.name,
m.dept_name,
CONVERT ( VARCHAR ( 20 ), m.discharge_date_time, 120 ) discharge_date_time,
m.discharge_date_time,
m.ArchiveState,
m.sex,
m.ID_NO,
m.dept_admission_to,
CONVERT ( VARCHAR ( 20 ), m.admission_date_time, 120 ) admission_date_time,
m.admission_date_time,
m.DISCHARGE_DISPOSITION
FROM
archive_master m
@ -1163,78 +1163,167 @@
</where>
order by m.create_time desc
</select>
<!-- 退回总次数、总费用和总评分 -->
<select id= "masterTotalList" parameterType= "com.emr.entity.Emr_Fault_Vo" resultMap= "BaseResultMap2" >
select DISTINCT m.id archive_detail_id,e.creater,m.inp_no,m.visit_id,m.name,convert(varchar,m.discharge_date_time,120) discharge_date_time,a.total_back_fee,a.total_back_num,#{backFee,jdbcType=NCHAR} back_fee,
m.dept_name dept_admission_to,d.name as deptName,m.ArchiveState,isnull(m.score,0) score,m.DOCTOR_IN_CHARGE
from(
select DISTINCT master_id,count(*) total_back_num,count(*)* #{backFee,jdbcType=NCHAR} total_back_fee from Archive_Master_Following where following_type=9 group by master_id
) a
LEFT JOIN Archive_Master m
on a.master_id=m.id
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where typeCode='dept_code' )) d
on m.dept_name=d.code
LEFT JOIN Archive_Master_Following f
on m.id=f.master_id
LEFT JOIN emr_fault_detail e
on e.archive_detail_id=m.id
<where > 1=1 and m.ArchiveState not in('作废','已封存','') and m.ArchiveState is not null and m.Is_Valid!=1 and total_back_num>0 and f.following_type=9
<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= "archivestate!= null and archivestate!= ''" >
and m.ArchiveState in
<foreach item= "item" collection= "archivestate.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</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= "doctorInCharge!= null and doctorInCharge!= ''" >
and m.DOCTOR_IN_CHARGE in
<foreach item= "item" collection= "doctorInCharge.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
<if test= "dischargeDateTime != null" >
and m.discharge_date_time = #{dischargeDateTime,jdbcType=NVARCHAR}
</if>
<if test= "creater!= null and creater!= ''" >
and e.creater in
<foreach item= "item" collection= "creater.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
<choose >
<when test= "startDate != null and startDate != '' and endDate != null and endDate != ''" >
and CONVERT(VARCHAR(20),m.discharge_date_time,23) between CONVERT(VARCHAR(20),#{startDate,jdbcType=NCHAR},23) and
CONVERT(VARCHAR(20),#{endDate,jdbcType=NCHAR},23)
</when>
<when test= "startDate != null and startDate != ''" >
and CONVERT(VARCHAR(20),m.discharge_date_time,23) >= CONVERT(VARCHAR(20),#{startDate,jdbcType=NCHAR},23)
</when>
<when test= "endDate != null and endDate != ''" >
and CONVERT(VARCHAR(20),m.discharge_date_time,23) < =CONVERT(VARCHAR(20),#{endDate,jdbcType=NCHAR},23)
</when>
</choose>
<if test= "updater!= null and updater!= ''" >
and t.id in
<foreach item= "item" collection= "updater.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
</where>
</select>
<!-- 退回总次数、总费用和总评分2023 - 09 - 13优化去掉创建人 -->
<!-- <select id="masterTotalList" parameterType="com.emr.entity.Emr_Fault_Vo" resultMap="BaseResultMap2"> -->
<!-- select DISTINCT m.id archive_detail_id,e.creater,m.inp_no,m.visit_id,m.name,convert(varchar,m.discharge_date_time,120) discharge_date_time,a.total_back_fee,a.total_back_num,#{backFee,jdbcType=NCHAR} back_fee, -->
<!-- m.dept_name dept_admission_to,d.name as deptName,m.ArchiveState,isnull(m.score,0) score,m.DOCTOR_IN_CHARGE -->
<!-- from( -->
<!-- select DISTINCT master_id,count(*) total_back_num,count(*)* #{backFee,jdbcType=NCHAR} total_back_fee from Archive_Master_Following where following_type=9 group by master_id -->
<!-- ) a -->
<!-- LEFT JOIN Archive_Master m -->
<!-- on a.master_id=m.id -->
<!-- LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where typeCode='dept_code' )) d -->
<!-- on m.dept_name=d.code -->
<!-- LEFT JOIN Archive_Master_Following f -->
<!-- on m.id=f.master_id -->
<!-- LEFT JOIN emr_fault_detail e -->
<!-- on e.archive_detail_id=m.id -->
<!-- <where> 1=1 and m.ArchiveState not in('作废','已封存','') and m.ArchiveState is not null and m.Is_Valid!=1 and total_back_num>0 and f.following_type=9 -->
<!-- <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="archivestate!= null and archivestate!= ''"> -->
<!-- and m.ArchiveState in -->
<!-- <foreach item="item" collection="archivestate.split(',')" open="(" separator="," close=")"> -->
<!-- #{item} -->
<!-- </foreach> -->
<!-- </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="doctorInCharge!= null and doctorInCharge!= ''"> -->
<!-- and m.DOCTOR_IN_CHARGE in -->
<!-- <foreach item="item" collection="doctorInCharge.split(',')" open="(" separator="," close=")"> -->
<!-- #{item} -->
<!-- </foreach> -->
<!-- </if> -->
<!-- <if test="dischargeDateTime != null"> -->
<!-- and m.discharge_date_time = #{dischargeDateTime,jdbcType=NVARCHAR} -->
<!-- </if> -->
<!-- <if test="creater!= null and creater!= ''"> -->
<!-- and e.creater in -->
<!-- <foreach item="item" collection="creater.split(',')" open="(" separator="," close=")"> -->
<!-- #{item} -->
<!-- </foreach> -->
<!-- </if> -->
<!-- <choose> -->
<!-- <when test="startDate != null and startDate != '' and endDate != null and endDate != ''"> -->
<!-- and CONVERT(VARCHAR(20),m.discharge_date_time,23) between CONVERT(VARCHAR(20),#{startDate,jdbcType=NCHAR},23) and -->
<!-- CONVERT(VARCHAR(20),#{endDate,jdbcType=NCHAR},23) -->
<!-- </when> -->
<!-- <when test="startDate != null and startDate != ''"> -->
<!-- and CONVERT(VARCHAR(20),m.discharge_date_time,23) >= CONVERT(VARCHAR(20),#{startDate,jdbcType=NCHAR},23) -->
<!-- </when> -->
<!-- <when test="endDate != null and endDate != ''"> -->
<!-- and CONVERT(VARCHAR(20),m.discharge_date_time,23) <=CONVERT(VARCHAR(20),#{endDate,jdbcType=NCHAR},23) -->
<!-- </when> -->
<!-- </choose> -->
<!-- <if test="updater!= null and updater!= ''"> -->
<!-- and t.id in -->
<!-- <foreach item="item" collection="updater.split(',')" open="(" separator="," close=")"> -->
<!-- #{item} -->
<!-- </foreach> -->
<!-- </if> -->
<!-- </where> -->
<!-- </select> -->
<select id= "masterTotalList" parameterType= "com.emr.entity.Emr_Fault_Vo" resultMap= "BaseResultMap2" >
SELECT DISTINCT
m.id archive_detail_id,
m.inp_no,
m.visit_id,
m.name,
discharge_date_time,
a.total_back_fee,
a.total_back_num,
#{ backFee,jdbcType = NCHAR } back_fee,
m.ArchiveState,
isnull( m.score, 0 ) score,
m.dept_name,
m.DOCTOR_IN_CHARGE
FROM
(
SELECT DISTINCT
master_id,
COUNT ( * ) total_back_num,
COUNT ( * ) * #{ backFee,
jdbcType = NCHAR } total_back_fee
FROM
Archive_Master_Following
WHERE
following_type = 9
GROUP BY
master_id
) a
LEFT JOIN Archive_Master m ON a.master_id= m.id
<where > 1=1 and m.ArchiveState not in('作废','已封存','') and m.ArchiveState is not null and m.Is_Valid!=1 and total_back_num>0
<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= "archivestate!= null and archivestate!= ''" >
and m.ArchiveState in
<foreach item= "item" collection= "archivestate.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</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= "doctorInCharge!= null and doctorInCharge!= ''" >
and m.DOCTOR_IN_CHARGE in
<foreach item= "item" collection= "doctorInCharge.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
<if test= "dischargeDateTime != null" >
and m.discharge_date_time = #{dischargeDateTime,jdbcType=NVARCHAR}
</if>
<if test= "creater!= null and creater!= ''" >
and e.creater in
<foreach item= "item" collection= "creater.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
<choose >
<when test= "startDate != null and startDate != '' and endDate != null and endDate != ''" >
and CONVERT(VARCHAR(20),m.discharge_date_time,23) between CONVERT(VARCHAR(20),#{startDate,jdbcType=NCHAR},23) and
CONVERT(VARCHAR(20),#{endDate,jdbcType=NCHAR},23)
</when>
<when test= "startDate != null and startDate != ''" >
and CONVERT(VARCHAR(20),m.discharge_date_time,23) >= CONVERT(VARCHAR(20),#{startDate,jdbcType=NCHAR},23)
</when>
<when test= "endDate != null and endDate != ''" >
and CONVERT(VARCHAR(20),m.discharge_date_time,23) < =CONVERT(VARCHAR(20),#{endDate,jdbcType=NCHAR},23)
</when>
</choose>
<if test= "updater!= null and updater!= ''" >
and t.id in
<foreach item= "item" collection= "updater.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
</where>
</select>
<!-- 退回总次数、总费用和总评分 -->
<select id= "masterTotalListTwo" parameterType= "com.emr.entity.Emr_Fault_Vo" resultMap= "BaseResultMap2" >
@ -1651,5 +1740,22 @@ WHERE
archive_detail_id = #{ masterId }
GROUP BY archive_detail_id
</select>
<select id= "totalBackFee" resultType= "com.emr.entity.Emr_Fault_Vo" >
SELECT DISTINCT
master_id,
COUNT ( * ) total_back_num,
COUNT ( * ) * #{ backFee,
jdbcType = NCHAR } total_back_fee
FROM
Archive_Master_Following
WHERE
following_type = 9
and master_id in
<foreach item= "item" collection= "ids.split(',')" open= "(" separator= "," close= ")" >
#{item}
</foreach>
GROUP BY
master_id
</select>
</mapper>