Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- pcr1.id_patient,
- child.patient_code AS child_code,
- pcr1.date_of_birth,
- pcr1.date_blood_taken AS date_pcr1,
- result1.name AS pcr1_result,
- IF(pcr2.which_pcr = 2,
- pcr2.date_blood_taken,
- '') AS date_pcr2,
- result2.name AS pcr2_result,
- CONCAT(tm.mother_city_code,
- '/',
- tm.mother_hospital_code,
- '/',
- tm.mother_code) AS mother_code,
- IF(mother.id IS NOT NULL,
- 'mother on hiv',
- 'mother not on hiv') AS mother_status,
- is_PTME,
- PTME_date
- FROM
- testing_specimen AS pcr1
- LEFT JOIN
- (SELECT
- *
- FROM
- testing_specimen
- WHERE
- which_pcr = 2) pcr2 ON pcr2.id_patient = pcr1.id_patient
- LEFT JOIN
- testing_mereenfant tm ON pcr1.id_patient = tm.id_patient
- LEFT JOIN
- patient mother ON mother.patient_code = CONCAT(tm.mother_city_code,
- '/',
- tm.mother_hospital_code,
- '/',
- tm.mother_code)
- LEFT JOIN
- tracking_motherbasicinfo ON tracking_motherbasicinfo.id_patient = mother.id
- LEFT JOIN
- lookup_testing_specimen_result AS result1 ON result1.id = pcr1.pcr_result
- LEFT JOIN
- lookup_testing_specimen_result AS result2 ON result2.id = pcr2.pcr_result
- LEFT JOIN
- patient AS child ON child.id = pcr1.id_patient
- WHERE
- pcr1.which_pcr = 1
- AND pcr1.date_of_birth BETWEEN '2016-01-01' AND '2018-12-31'
Advertisement
Add Comment
Please, Sign In to add comment