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
del_flag = 0
and status = 1
and name like concat('%', #{name}, '%')
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 q.name like concat('%', #{name}, '%')
and q.tenant_id = #{tenantId}
group by q.id
order by q.`tenant_id`,q.`create_time` desc
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
AND tenant_id = #{tenantId}
and id = #{id}
and name like concat('%', #{name}, '%')
and status = #{status}
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
AND r.tenant_id = #{tenantId}
AND r.queue_id is null
AND r.queue_id = #{id}
AND r.task_flag = #{taskFlag}
AND r.phone =#{phone}
AND r.name =#{name}
group by r.patient_id, r.tenant_id
order by r.create_time desc
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
v_fms_patient_queue_relation r
left join
v_fms_followup_queue q
on r.queue_id = q.id or q.id is null
WHERE r.del_flag = 0
AND r.tenant_id = #{tenantId}
AND r.queue_id is null
AND r.queue_id = #{id}
AND r.task_flag = #{taskFlag}
group by r.patient_id, r.tenant_id
order by r.create_time desc
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
AND r.tenant_id = #{tenantId}
AND r.queue_id is null
AND r.queue_id = #{id}
AND r.task_flag = #{taskFlag}
AND r.phone =#{phone}
AND r.name =#{name}
group by r.patient_id, r.tenant_id
order by r.create_time desc
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
t.del_flag = 0
AND t.tenant_id = #{tenantId}
and t.queue_id = #{dto.queueId}
AND t.status = #{dto.status}
-- 0待随访 1即将超期(结束时间 - 当前时间 小于 队列配置临近提醒时间) 2超期(结束时间 小于 当前时间)
AND DATEDIFF(t.end_time , NOW()) < q.remind_time and t.end_time > NOW()
AND t.end_time < NOW()
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}, '%'))
AND t.age >= #{dto.startAge}
AND t.age <= #{dto.endAge}
order by t.update_time DESC
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
AND t.tenant_id = #{dto.tenantId}
t.queue_id = #{dto.queueId}
AND t.status = #{dto.status}
-- 0待随访 1即将超期(结束时间 - 当前时间 小于 队列配置临近提醒时间) 2超期(结束时间 小于 当前时间)
AND DATEDIFF(t.end_time , NOW()) < q.remind_time and t.end_time > NOW()
AND t.end_time < NOW()
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}, '%'))
AND t.age >= #{dto.startAge}
AND t.age <= #{dto.endAge}
order by t.update_time DESC
UPDATE fms_followup_task
SET status = 2, lost_reason = #{dto.reason}
WHERE id =#{dto.id}
UPDATE fms_followup_task
SET status = 1, followuper = #{dto.followuper},
followup_time = #{dto.followupTime}, followup_text = #{dto.followupText}
WHERE id =#{dto.id}
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
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}