针灸质控中心平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

386 lines
15 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.acupuncture.system.persist.dao.FmsFollowupDao">
<select id="queryCommonQueue" resultType="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupQueueVO">
select
id,
name,
followup_method as followupMethod,
followup_type as followupType,
frequency,
followup_month as followupMonth,
person_in_charge as personInCharge,
person_in_charge_username as personInChargeUsername,
status,
create_by as createBy,
remind_time as remindTime,
follow_window_adys as followWindowAdys
from
fms_followup_queue
<where>
del_flag = 0
and status = 1
<if test="name != null and name != ''">
and name like concat('%', #{name}, '%')
</if>
</where>
</select>
<select id="queryAll" resultType="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupQueueVO">
select
q.id,
q.name,
q.followup_method as followupMethod,
q.followup_type as followupType,
q.frequency,
q.followup_month as followupMonth,
q.person_in_charge as personInCharge,
q.person_in_charge_username as personInChargeUsername,
q.status,
q.tenant_id as tenantId,
q.create_by as createBy,
q.create_time as createTime,
q.remind_time as remindTime,
q.follow_window_adys as followWindowAdys,
t.name as tenantName
from
all_fms_followup_queue q
left join
dms_tenant t on q.tenant_id = t.id
where
q.del_flag = 0
and t.del_flag = 0
<if test="name != null and name != ''">
and q.name like concat('%', #{name}, '%')
</if>
<if test="tenantId != null">
and q.tenant_id = #{tenantId}
</if>
group by q.id
order by q.`tenant_id`,q.`create_time` desc
</select>
<select id="selectQueueList" resultType="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupQueueVO">
SELECT id,
name,
followup_method as followupMethod,
followup_type as followupType,
frequency,
followup_month as followupMonth,
person_in_charge as personInCharge,
person_in_charge_username as personInChargeUsername,
status,
follow_window_adys as followWindowAdys,
remind_time remindTime,
create_by as createBy,
create_time as createTime
FROM fms_followup_queue
WHERE del_flag = 0
<if test="tenantId != null">
AND tenant_id = #{tenantId}
</if>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name like concat('%', #{name}, '%')
</if>
<if test="status != null">
and status = #{status}
</if>
</select>
<resultMap id="BaseResultMap" type="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupPatient">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="pinyinFull" property="pinyinFull"/>
<result column="pinyinSimple" property="pinyinSimple"/>
<result column="gender" property="gender"/>
<result column="birthDate" property="birthDate"/>
<result column="ethnicity" property="ethnicity"/>
<result column="educationYears" property="educationYears"/>
<result column="phone" property="phone"/>
<result column="dischargeTime" property="dischargeTime"/>
<result column="idCardType" property="idCardType"/>
<result column="idCard" property="idCard"/>
<result column="tenantId" property="tenantId"/>
<result column="createBy" property="createBy"/>
<result column="createTime" property="createTime"/>
<result column="tenantName" property="tenantName"/>
<collection property="queueList" ofType="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupPatient$QueueVo">
<result column="queueId" property="queueId" />
<result column="queueName" property="queueName" />
</collection>
</resultMap>
<select id="queryPatient" resultMap="BaseResultMap">
select
r.patient_id as id,
r.queue_id as queueId,
r.name,
r.pinyin_full as pinyinFull,
r.pinyin_simple as pinyinSimple,
r.gender,
r.birth_date as birthDate,
r.ethnicity,
r.education_years as educationYears,
r.phone,
r.discharge_time as dischargeTime,
r.id_card_type as idCardType,
r.id_card as idCard,
r.tenant_id as tenantId,
r.create_by as createBy,
r.create_time as createTime,
q.name as queueName,
q.remind_time as remindTime,
q.follow_window_adys as followWindowAdys
FROM fms_patient_queue_relation r
left join
fms_followup_queue q
on r.queue_id = q.id or q.id is null
WHERE r.del_flag = 0
<if test="tenantId != null">
AND r.tenant_id = #{tenantId}
</if>
<if test="haveQueue != null">
AND r.queue_id is null
</if>
<if test="id != null">
AND r.queue_id = #{id}
</if>
<if test="taskFlag != null">
AND r.task_flag = #{taskFlag}
</if>
group by r.patient_id, r.tenant_id
order by r.create_time desc
</select>
<select id="adminQueryPatient" resultMap="BaseResultMap">
select
r.patient_id as id,
r.queue_id as queueId,
r.name,
r.pinyin_full as pinyinFull,
r.pinyin_simple as pinyinSimple,
r.gender,
r.birth_date as birthDate,
r.ethnicity,
r.education_years as educationYears,
r.phone,
r.discharge_time as dischargeTime,
r.id_card_type as idCardType,
r.id_card as idCard,
r.tenant_id as tenantId,
r.create_by as createBy,
r.create_time as createTime,
q.name as queueName,
q.remind_time as remindTime,
q.follow_window_adys as followWindowAdys,
d.name as tenantName
FROM v_fms_patient_queue_relation r
left join
all_fms_followup_queue q on r.queue_id = q.id or q.id is null
left join
dms_tenant d on r.tenant_id = d.id
WHERE r.del_flag = 0
<if test="tenantId != null">
AND r.tenant_id = #{tenantId}
</if>
<if test="haveQueue != null">
AND r.queue_id is null
</if>
<if test="id != null">
AND r.queue_id = #{id}
</if>
<if test="taskFlag != null">
AND r.task_flag = #{taskFlag}
</if>
group by r.patient_id, r.tenant_id
order by r.create_time desc
</select>
<select id="selectTaskList" resultType="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupTaskVO"
parameterType="com.acupuncture.system.domain.dto.FmsFollowupDto$FollowupTaskQueryDTO">
SELECT
t.id as id,
t.patient_id as patientId,
t.name,
t.gender,
t.age,
t.ethnicity,
t.education_years as educationYears,
t.phone,
t.id_card_type as idCardType,
t.id_card as idCard,
t.tenant_id as tenantId,
t.queue_id as queueId,
t.times,
t.start_time as startTime,
t.end_time as endTime,
t.status,
t.lost_reason as reason,
t.followuper,
t.followup_time as followupTime,
t.followup_text as followupText,
t.create_by as createBy,
t.create_time as createTime,
q.name as queueName,
d.name as tenantName,
t.lost_reason as reason,
t.start_time as startTime,
t.end_time as endTime,
q.remind_time as remindTime,
q.follow_window_adys as followWindowAdys
FROM fms_followup_task t
left join
fms_followup_queue q
on t.queue_id = q.id and q.del_flag = 0
left join
dms_tenant d on d.id = t.tenant_id and d.del_flag = 0
<where>
t.del_flag = 0
<if test="tenantId != null">
AND t.tenant_id = #{tenantId}
</if>
<if test="dto.queueId != null">
and t.queue_id = #{dto.queueId}
</if>
<if test="dto.status != null">
AND t.status = #{dto.status}
</if>
<if test="dto.childStatus != null">
-- 0待随访 1即将超期(结束时间 - 当前时间 小于 队列配置临近提醒时间) 2超期(结束时间 小于 当前时间)
<if test="dto.childStatus == 1">
AND DATEDIFF(t.end_time , NOW()) &lt; q.remind_time and t.end_time &gt; NOW()
</if>
<if test="dto.childStatus == 2">
AND t.end_time &lt; NOW()
</if>
</if>
<if test="dto.keywords != null and dto.keywords != ''">
AND (t.name LIKE CONCAT('%', #{dto.keywords}, '%')
OR t.phone LIKE CONCAT('%', #{dto.keywords}, '%')
OR t.id_card LIKE CONCAT('%', #{dto.keywords}, '%')
OR t.name LIKE CONCAT('%', #{dto.keywords}, '%'))
</if>
<if test="dto.startAge != null">
AND t.age >= #{dto.startAge}
</if>
<if test="dto.endAge != null">
AND t.age &lt;= #{dto.endAge}
</if>
</where>
order by t.update_time DESC
</select>
<select id="adminSelectTaskList" resultType="com.acupuncture.system.domain.vo.FmsFollowupVo$FollowupTaskVO"
parameterType="com.acupuncture.system.domain.dto.FmsFollowupDto$FollowupTaskQueryDTO">
SELECT
t.id as id,
t.patient_id as patientId,
t.name,
t.gender,
t.age,
t.ethnicity,
t.education_years as educationYears,
t.phone,
t.id_card_type as idCardType,
t.id_card as idCard,
t.tenant_id as tenantId,
t.queue_id as queueId,
t.times,
t.start_time as startTime,
t.end_time as endTime,
t.status,
t.lost_reason as reason,
t.followuper,
t.followup_time as followupTime,
t.followup_text as followupText,
t.create_by as createBy,
t.create_time as createTime,
q.name as queueName,
d.name as tenantName,
t.lost_reason as reason,
t.start_time as startTime,
t.end_time as endTime,
q.remind_time as remindTime,
q.follow_window_adys as followWindowAdys
FROM v_fms_followup_task t
left join
all_fms_followup_queue q
on t.queue_id = q.id and q.del_flag = 0
left join
dms_tenant d on d.id = t.tenant_id and d.del_flag = 0
<where>
<if test="dto.tenantId != null">
AND t.tenant_id = #{dto.tenantId}
</if>
<if test="dto.queueId != null">
t.queue_id = #{dto.queueId}
</if>
<if test="dto.status != null">
AND t.status = #{dto.status}
</if>
<if test="dto.childStatus != null">
-- 0待随访 1即将超期(结束时间 - 当前时间 小于 队列配置临近提醒时间) 2超期(结束时间 小于 当前时间)
<if test="dto.childStatus == 1">
AND DATEDIFF(t.end_time , NOW()) &lt; q.remind_time and t.end_time &gt; NOW()
</if>
<if test="dto.childStatus == 2">
AND t.end_time &lt; NOW()
</if>
</if>
<if test="dto.keywords != null and dto.keywords != ''">
AND (t.name LIKE CONCAT('%', #{dto.keywords}, '%')
OR t.phone LIKE CONCAT('%', #{dto.keywords}, '%')
OR t.id_card LIKE CONCAT('%', #{dto.keywords}, '%')
OR t.name LIKE CONCAT('%', #{dto.keywords}, '%'))
</if>
<if test="dto.startAge != null">
AND t.age >= #{dto.startAge}
</if>
<if test="dto.endAge != null">
AND t.age &lt;= #{dto.endAge}
</if>
</where>
order by t.update_time DESC
</select>
<update id="updateStatusToLost" parameterType="com.acupuncture.system.domain.dto.FmsFollowupDto$FollowupLostDTO">
UPDATE fms_followup_task
SET status = 2, lost_reason = #{dto.reason}
WHERE id =#{dto.id}
</update>
<update id="completeFollowup" parameterType="com.acupuncture.system.domain.dto.FmsFollowupDto$FollowupCompleteDTO">
UPDATE fms_followup_task
SET status = 1, followuper = #{dto.followuper},
followup_time = #{dto.followupTime}, followup_text = #{dto.followupText}
WHERE id =#{dto.id}
</update>
<select id="queryQueueListByPatientId" resultType="com.acupuncture.system.domain.vo.PmsTreatmentVo$TreatmentVO$QueueVo">
SELECT
r.queue_id AS queueId,
q.NAME AS queueName
FROM
fms_patient_queue_relation r
LEFT JOIN fms_followup_queue q ON q.id = r.queue_id
WHERE
r.del_flag = 0
AND r.patient_id = #{patientId}
</select>
<select id="adminQueryQueueListByPatientId" resultType="com.acupuncture.system.domain.vo.PmsTreatmentVo$TreatmentVO$QueueVo">
SELECT
r.queue_id AS queueId,
q.NAME AS queueName
FROM
v_fms_patient_queue_relation r
LEFT JOIN v_fms_followup_queue q ON q.id = r.queue_id
WHERE
r.del_flag = 0
AND r.patient_id = #{patientId}
</select>
</mapper>