                         ON (treatments_agg.contact_event_id = dce.id)
                 WHERE
                     dce.disease_name = 'Hepatitis B Pregnancy Event' AND
-                    dme.actual_delivery_date IS NOT NULL;
+                    dce.birth_date IS NOT NULL;
 ;
 
 CREATE TABLE morb_sec_juris AS

                                                    WHEN hepb_dose3_date IS NULL AND hepb_comvax4_date IS NULL THEN
                                                        5 -- fdd = COALESCE(hepb_dose2_date, hepb_comvax2_date) + INTERVAL '6 months', act = "Needs Hepatitis B Dose 3"
                                                    WHEN
                                                        COALESCE(  -- between 9 and 18 months old
                                                            (now() - COALESCE(dce.birth_date, dme_2.actual_delivery_date)) BETWEEN (interval '30 days' * 9) AND (interval '30 days' * 18),
                                                            dce.age_in_years BETWEEN .6 AND 1.5

                    CASE WHEN contact_type = 'Infant' AND treatments_agg.total_doses >= 5 THEN 1 ELSE 0 END AS five_dose,
                    CASE WHEN contact_type = 'Infant' AND treatments_agg.total_doses >= 6 THEN 1 ELSE 0 END AS six_dose,
                    CASE WHEN contact_type = 'Infant' AND hbig_vacc_date IS NOT NULL THEN 1 ELSE 0 END AS recvd_hbig,
                    CASE WHEN
                        contact_type = 'Infant' AND
                        (trisano.get_contact_hbsag_before(dce.id, NULL)).lab_test_date <=
                            dce.birth_date + INTERVAL '12 months' AND
                        (trisano.get_contact_antihb_after(dce.id, NULL)).lab_test_date <=
                            dce.birth_date + INTERVAL '12 months'
                    THEN 1 ELSE 0 END AS serotest_12m,
                    CASE WHEN
                        contact_type = 'Infant' AND
                        (trisano.get_contact_hbsag_before(dce.id, NULL)).lab_test_date <=
                            dce.birth_date + INTERVAL '15 months' AND
                        (trisano.get_contact_antihb_after(dce.id, NULL)).lab_test_date <=
                            dce.birth_date + INTERVAL '15 months'
                    THEN 1 ELSE 0 END AS serotest_15m,
                    CASE WHEN contact_type = 'Infant' AND ((trisano.get_contact_hbsag_after(dce.id, NULL)).lab_test_date IS NOT NULL OR (trisano.get_contact_antihb_after(dce.id, NULL)).lab_test_date IS NOT NULL) THEN 1 ELSE 0 END AS total_serotest,
                    CASE WHEN contact_type = 'Infant' AND (trisano.get_contact_antihb_after(dce.id, NULL)).test_result ~ 'Positive / Reactive' THEN 1 ELSE 0 END AS positive_antihb,
                    CASE WHEN contact_type = 'Infant' AND (trisano.get_contact_hbsag_after(dce.id, NULL)).test_result ~ 'Positive / Reactive' THEN 1 ELSE 0 END AS positive_hbsag,
                    CASE
                        WHEN contact_type = 'Infant' AND
                            hepb_comvax1_date IS NOT NULL OR
