jeniferfleurant icon

infant for test rapid

jeniferfleurant | PRO | 08/21/19 06:49:23 PM UTC | 0 ⭐ | 6985 👁️ | Never ⏰ | []
MySQL |

1.49 KB

|

None

|

0 👍

/

0 👎

SELECT 
    patient.patient_code, date_of_birth, date_blood_taken,
    name AS pcr_result,
    pcr_result_date,
    positive_pcr_1 as test_rapid_date_1,
    positive_pcr_2 as test_rapid_date_2,
    CONCAT(mother_city_code,
            '/',
            mother_hospital_code,
            '/',
            mother_code) AS code_mere_form,
    if(p.id is null, 'no', 'yes') as mother_on_hiv
FROM
    (SELECT 
        id_patient, pcr_result, pcr_result_date, date_of_birth,date_blood_taken
    FROM
        testing_specimen ts1
    WHERE
        date_blood_taken = (SELECT 
                MIN(date_blood_taken)
            FROM
                testing_specimen ts2
            WHERE
                ts1.id_patient = ts2.id_patient)
            AND date_blood_taken >= '2018-10-01'
            AND TIMESTAMPDIFF(MONTH, date_of_birth, NOW()) BETWEEN '18' AND '36') a
        LEFT JOIN
    patient ON patient.id = a.id_patient
        LEFT JOIN
    lookup_testing_specimen_result ON lookup_testing_specimen_result.id = pcr_result
        LEFT JOIN
    tracking_infant ON a.id_patient = tracking_infant.id_patient
        LEFT JOIN
    testing_mereenfant ON testing_mereenfant.id_patient = a.id_patient
            LEFT JOIN
    patient p ON p.patient_code =     CONCAT(mother_city_code,
            '/',
            mother_hospital_code,
            '/',
            mother_code)
        LEFT JOIN
    tracking_motherbasicinfo ON tracking_motherbasicinfo.id_patient = p.id
 
GROUP BY a.id_patient

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎