jeniferfleurant

Positif under 5 with muac

Oct 23rd, 2017
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.25 KB | None | 0 0
  1. USE caris_db;
  2. SET @start_date= '2016-10-01';
  3. SET @end_date='2017-09-30';
  4.  
  5. select left(patient_code,8) as hospital,
  6. count(*) as total from
  7. (
  8. select distinct patient_code from tracking_followup left join patient on patient.id=tracking_followup.id_patient
  9. left join tracking_infant on patient.id=tracking_infant.id_patient
  10.  where date between @start_date and @end_date and (mid_arm_circumference>0 or weight>0) and timestampdiff(month,dob,date)<60 and timestampdiff(month,dob,date)>=6
  11. union
  12. select distinct odk_child_visit.patient_code from openfn.odk_child_visit
  13. left join patient on patient.patient_code=odk_child_visit.patient_code
  14. left join tracking_infant on patient.id=id_patient
  15. where
  16. date_of_visit between @start_date and @end_date and (muac>0 or weight_kg>0) and timestampdiff(month,dob,date_of_visit)<60 and timestampdiff(month,dob,date_of_visit)>=6
  17. union
  18. select patient_code from testing_mereenfant
  19. left join testing_specimen on testing_specimen.id_patient=testing_mereenfant.id_patient
  20. left join patient on patient.id=testing_mereenfant.id_patient
  21. where pcr_result=1 and infant_weight>0 and date between @start_date and @end_date and timestampdiff(month,infant_dob,date)<60 and timestampdiff(month,infant_dob,date)>=6
  22. )a
  23. group by left(patient_code,8)
Advertisement
Add Comment
Please, Sign In to add comment