jeniferfleurant

Enfants Positifs 6-59 mois sur une période donnée

Sep 21st, 2017
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.56 KB | None | 0 0
  1. set @start_date=  '2016-07-01';
  2. set @end_date = '2018-07-31';
  3. select count(id_patient) as total_positif, count(infant) as dead_abandon,
  4. count(followup) as muac_followup, count(odk) as muac_odk,
  5. sum(if(followup is not null or odk is not null,1,0)) as with_muac, sum(if(followup is not null and odk is not null,1,0)) as overlap
  6.  
  7. from(
  8. select id_patient, infant,
  9. followup,odk
  10. from(
  11. select testing_specimen.id_patient from testing_specimen where timestampdiff(month,date_of_birth,@start_date)<60 and timestampdiff(month,date_of_birth,@end_date)>=6 and pcr_result=1
  12. union
  13. select testing_result.id_patient from testing_result left join tracking_infant on tracking_infant.id_patient=testing_result.id_patient where timestampdiff(month,dob,@start_date)<60 and timestampdiff(month,dob,@end_date)>=6 and result=1
  14. union
  15. select tracking_followup.id_patient from tracking_followup left join tracking_infant on tracking_infant.id_patient=tracking_followup.id_patient where timestampdiff(month,dob,@start_date)<60 and timestampdiff(month,dob,@end_date)>=6
  16. )j
  17. left join
  18. (select distinct tracking_followup.id_patient as followup from tracking_followup where mid_arm_circumference >0)o
  19. on followup = j.id_patient
  20.  
  21. left join
  22. (
  23.     SELECT distinct patient.id as odk FROM openfn.odk_child_visit left join caris_db.patient on patient.patient_code=odk_child_visit.patient_code
  24. where muac>0 and patient.id is not null
  25. )e
  26. on j.id_patient=odk
  27. left join
  28. (select distinct id_patient as infant from tracking_infant where is_dead=1 or is_abandoned=1
  29. )xy on j.id_patient=infant
  30. #group by id_patient
  31. )juo
Advertisement
Add Comment
Please, Sign In to add comment