jeniferfleurant

PNLS taux de positivité

Apr 5th, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.48 KB | None | 0 0
  1. SELECT
  2.     pcr1.id_patient,
  3.     child.patient_code AS child_code,
  4.     pcr1.date_of_birth,
  5.     pcr1.date_blood_taken AS date_pcr1,
  6.     result1.name AS pcr1_result,
  7.     IF(pcr2.which_pcr = 2,
  8.         pcr2.date_blood_taken,
  9.         '') AS date_pcr2,
  10.     result2.name AS pcr2_result,
  11.     CONCAT(tm.mother_city_code,
  12.             '/',
  13.             tm.mother_hospital_code,
  14.             '/',
  15.             tm.mother_code) AS mother_code,
  16.     IF(mother.id IS NOT NULL,
  17.         'mother on hiv',
  18.         'mother not on hiv') AS mother_status,
  19.     is_PTME,
  20.     PTME_date
  21. FROM
  22.     testing_specimen AS pcr1
  23.         LEFT JOIN
  24.     (SELECT
  25.         *
  26.     FROM
  27.         testing_specimen
  28.     WHERE
  29.         which_pcr = 2) pcr2 ON pcr2.id_patient = pcr1.id_patient
  30.         LEFT JOIN
  31.     testing_mereenfant tm ON pcr1.id_patient = tm.id_patient
  32.         LEFT JOIN
  33.     patient mother ON mother.patient_code = CONCAT(tm.mother_city_code,
  34.             '/',
  35.             tm.mother_hospital_code,
  36.             '/',
  37.             tm.mother_code)
  38.         LEFT JOIN
  39.     tracking_motherbasicinfo ON tracking_motherbasicinfo.id_patient = mother.id
  40.         LEFT JOIN
  41.     lookup_testing_specimen_result AS result1 ON result1.id = pcr1.pcr_result
  42.         LEFT JOIN
  43.     lookup_testing_specimen_result AS result2 ON result2.id = pcr2.pcr_result
  44.         LEFT JOIN
  45.     patient AS child ON child.id = pcr1.id_patient
  46. WHERE
  47.     pcr1.which_pcr = 1
  48.         AND pcr1.date_of_birth BETWEEN '2016-01-01' AND '2018-12-31'
Advertisement
Add Comment
Please, Sign In to add comment