jeniferfleurant

mother pcr info merenfant

Apr 12th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.38 KB | None | 0 0
  1. USE caris_db;
  2. SET @start_date= '2019-01-01';
  3. SET @end_date='2019-03-31';
  4. SELECT
  5.     patient.patient_code,
  6.     infant_dob,
  7.     date as date_de_prelevement,
  8.     lookup_testing_birth_location.name AS accouchement,
  9.     lookup_testing_specimen_result.name as result,
  10.     testing_specimen.pcr_result_date,
  11.     infant_birth_location_describe,
  12.     lookup_testing_nutrition.name as nutrition,
  13.     response.name as arv_before_after,
  14.     cotrim.name as on_cotrim,
  15.     infant_on_cotrimoxazole_date,
  16.     infant_why_cotrimoxazole_not_given_describe,
  17.     lookup_testing_infant_arv_prophylaxis.name as arv_prophylaxis,
  18.     infant_prophylaxis_arv_regime_describe,
  19.     concat(mother_city_code,'/',mother_hospital_code,'/',mother_code) as code_mere,
  20.     lookup_testing_response.name as 'Est-ce que la femme a été placée sous ARV?',
  21.     mother_on_arv_start_date,
  22.     if(x.patient_code is not null, 'yes','no') as 'on hivhaiti?',
  23.     if(club_patient.id_patient is not null,'yes','no')as 'enrolled in club',
  24.     date_de_creation_caris,
  25.     is_PTME,
  26.     PTME_date
  27. FROM
  28.     testing_mereenfant
  29.         LEFT JOIN
  30.     patient ON patient.id = testing_mereenfant.id_patient
  31.         LEFT JOIN
  32.     lookup_testing_birth_location ON lookup_testing_birth_location.id = infant_birth_location
  33.         LEFT JOIN
  34.     lookup_testing_nutrition ON lookup_testing_nutrition.id = infant_nutrition
  35.     left join
  36.     lookup_testing_response on lookup_testing_response.id=mother_on_arv
  37.     left join lookup_response cotrim on cotrim.id=infant_on_cotrimoxazole
  38.     left join lookup_testing_infant_arv_prophylaxis on lookup_testing_infant_arv_prophylaxis.id=infant_prophylaxis_arv_regime
  39.     left join (
  40.     select patient_code, patient.id, is_PTME, tracking_motherbasicinfo.created_at as date_de_creation_caris, PTME_date from tracking_motherbasicinfo
  41.     left join patient on patient.id=id_patient
  42.     )x on x.patient_code = concat(mother_city_code,'/',mother_hospital_code,'/',mother_code)
  43.     left join
  44.     club_patient on club_patient.id_patient=x.id
  45.     left join testing_specimen on testing_specimen.id_patient=testing_mereenfant.id_patient
  46.     left join lookup_testing_specimen_result on testing_specimen.pcr_result=lookup_testing_specimen_result.id
  47.     left join lookup_response as response on response.id = testing_mereenfant.infant_prophylaxis_arv_regime_before_or_after
  48.     WHERE
  49.     date BETWEEN @start_date AND @end_date
Advertisement
Add Comment
Please, Sign In to add comment