Advertisement
jeniferfleurant

infant for test rapid

Aug 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.49 KB | None | 0 0
  1. SELECT
  2.     patient.patient_code, date_of_birth, date_blood_taken,
  3.     name AS pcr_result,
  4.     pcr_result_date,
  5.     positive_pcr_1 as test_rapid_date_1,
  6.     positive_pcr_2 as test_rapid_date_2,
  7.     CONCAT(mother_city_code,
  8.             '/',
  9.             mother_hospital_code,
  10.             '/',
  11.             mother_code) AS code_mere_form,
  12.     if(p.id is null, 'no', 'yes') as mother_on_hiv
  13. FROM
  14.     (SELECT
  15.         id_patient, pcr_result, pcr_result_date, date_of_birth,date_blood_taken
  16.     FROM
  17.         testing_specimen ts1
  18.     WHERE
  19.         date_blood_taken = (SELECT
  20.                 MIN(date_blood_taken)
  21.             FROM
  22.                 testing_specimen ts2
  23.             WHERE
  24.                 ts1.id_patient = ts2.id_patient)
  25.             AND date_blood_taken >= '2018-10-01'
  26.             AND TIMESTAMPDIFF(MONTH, date_of_birth, NOW()) BETWEEN '18' AND '36') a
  27.         LEFT JOIN
  28.     patient ON patient.id = a.id_patient
  29.         LEFT JOIN
  30.     lookup_testing_specimen_result ON lookup_testing_specimen_result.id = pcr_result
  31.         LEFT JOIN
  32.     tracking_infant ON a.id_patient = tracking_infant.id_patient
  33.         LEFT JOIN
  34.     testing_mereenfant ON testing_mereenfant.id_patient = a.id_patient
  35.             LEFT JOIN
  36.     patient p ON p.patient_code =     CONCAT(mother_city_code,
  37.             '/',
  38.             mother_hospital_code,
  39.             '/',
  40.             mother_code)
  41.         LEFT JOIN
  42.     tracking_motherbasicinfo ON tracking_motherbasicinfo.id_patient = p.id
  43.  
  44. GROUP BY a.id_patient
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement