set @start_date = '2016-07-01';
set @end_date = now();
select * from view_patient_positive where
id in (select id_patient from tracking_infant where timestampdiff(month,dob,@start_date)<=59 and timestampdiff(month,dob,@end_date)>=6)
and
linked_to_id_patient = 0 and
(id in (select id_patient from tracking_followup where date between @start_date and @end_date)
or
id in (select id_patient from testing_specimen where date_blood_taken between @start_date and @end_date
or pcr_result_date between @start_date and @end_date
))
Comments