SQLlite每月间隔生成应回访日期截止到截止日期
时间:2020-05-28 访问量:1173
insert into 应回访明细(业务编号,科室,患者,性别,年龄,出生日期,居住地,来院渠道,诊断,治疗,病理,管床医生,特殊备注,客户分类,应回访日期,是否回访,类别)
select ':业务编号' as 业务编号,':科室' as 科室,':患者' as 患者,':性别' as 性别,':年龄' as 年龄,
(case when :出生日期 is null then null else ':出生日期' end) as 出生日期,':居住地' as 居住地,
':来院渠道' as 来院渠道,':诊断' as 诊断,':治疗' as 治疗,':病理' as 病理,':管床医生' as 管床医生,':特殊备注' as 特殊备注,
':客户分类' as 客户分类,date(':日期','+' ||cast((:间隔月数*号+号) as var(2)) ||' month') as 应回访日期,'False' as 是否回访,'住院部' as 类别
from 序列
where date(':日期','+' ||cast((:间隔月数*号+号) as var(2)) ||' month')<=':截止日期'
and date(':日期','+' ||cast((:间隔月数*号+号) as var(2)) ||' month') not in (select 应回访日期 from 应回访明细 where 业务编号=':业务编号')