jeniferfleurant icon

PTME

jeniferfleurant | PRO | 10/15/18 06:21:13 PM UTC | 0 ⭐ | 326 πŸ‘οΈ | Never ⏰ | []
MySQL |

1.33 KB

|

None

|

0 πŸ‘

/

0 πŸ‘Ž

select concat(first_name, ' ', last_name) as nom_prenom, name as hospital, patient_code, dob, PTME_date, dpa, ddr, actual_delivery_date, telephone, telephone2, address 
from tracking_motherbasicinfo left join patient on patient.id = tracking_motherbasicinfo.id_patient
left join 
(select id_patient_mother, dpa, ddr, actual_delivery_date from tracking_pregnancy tp1 where dpa=(select max(dpa) from tracking_pregnancy tp2 where tp1.id_patient_mother=tp2.id_patient_mother))x
Β on x.id_patient_mother = tracking_motherbasicinfo.id_patient
left join lookup_hospital on concat(lookup_hospital.city_code,'/',lookup_hospital.hospital_code) = left(patient_code,8)
where patient.id is not null and linked_to_id_patient=0 and is_PTME = 1 and is_dead !=1 and year(tracking_motherbasicinfo.created_at) = 2018 
and left(patient_code,8) in 
('MAR/CALM', 'STM/CSPP', 'SMA/CSSM', 'GON/CDIR', 'MCH/HCHM', 'HIN/CSMD', 'ARC/SADA', 'PAP/FONP', 'PAP/FOND', 'MON/CSPM', 'PAP/CNSR', 'PAP/CSAB', 'PAP/CSLB', 'PAP/CNSR', 'PAP/GCHO', 'PIG/CSSR', 'CAP/CMCD', 'CAP/CDSF', 'PIG/HOBP', 'CAP/CMSO', 'CAP/CSBL', 'CAP/CMSC', 'CAP/CSLF', 'CAP/CSLJ', 'CAP/CSLS', 'CAP/CALC', 'PDP/CSAF', 'LAT/HNDP', 'BOM/CSBH', 'PDP/CMEB', 'JER/CSSH', 'JER/CSSJ', 'JER/HHFJ', 'DMA/HCDM', 'MIR/CSPT', 'MIR/CDSA', 'MIR/CSJF', 'CAY/CSAL', 'CAY/CDSL', 'CAY/CSIV', 'CAY/SHLI', 'JAC/CALB')
group by id_patient_mother

Comments