                 FROM 
                     trisano.dw_morbidity_events_view
                 WHERE
-                    disease_name = 'Hepatitis B Pregnancy Event'
+                    disease_name = 'Hepatitis B Pregnancy Event' AND
+                    actual_delivery_date IS NULL
                     ;
 
 CREATE TABLE report2 AS

                        SELECT
                            dw_contact_events_id AS contact_event_id,
                            trisano.earliest_date(trisano.array_accum(hbig_vacc_date )) AS hbig_vacc_date,
                            trisano.earliest_date(trisano.array_accum(hebp_dose1_date)) AS hepb_dose1_date,
                            trisano.earliest_date(trisano.array_accum(hepb_dose2_date)) AS hepb_dose2_date,
                            trisano.earliest_date(trisano.array_accum(hepb_dose3_date)) AS hepb_dose3_date,
                            trisano.earliest_date(trisano.array_accum(hepb_dose4_date)) AS hepb_dose4_date,
                            trisano.earliest_date(trisano.array_accum(hepb_dose5_date)) AS hepb_dose5_date,
                            trisano.earliest_date(trisano.array_accum(hepb_dose6_date)) AS hepb_dose6_date
                        FROM (
                            SELECT
                                dw_contact_events_id,
                                CASE WHEN treatment_name = 'HBIG' THEN date_of_treatment ELSE NULL END AS hbig_vacc_date,
                                CASE WHEN treatment_name = 'Hep B Dose 1 Vaccination' THEN date_of_treatment ELSE NULL END AS hebp_dose1_date,
                                CASE WHEN treatment_name = 'Hep B Dose 2 Vaccination' THEN date_of_treatment ELSE NULL END AS hepb_dose2_date,
                                -- The ~ is intentional
                                CASE WHEN treatment_name ~ 'Hep B Dose 3 Vaccination' THEN date_of_treatment ELSE NULL END AS hepb_dose3_date,
                                CASE WHEN treatment_name = 'Hep B Dose 4 Vaccination' THEN date_of_treatment ELSE NULL END AS hepb_dose4_date,
                                CASE WHEN treatment_name = 'Hep B Dose 5 Vaccination' THEN date_of_treatment ELSE NULL END AS hepb_dose5_date,
                                CASE WHEN treatment_name = 'Hep B Dose 6 Vaccination' THEN date_of_treatment ELSE NULL END AS hepb_dose6_date
                            FROM
                                trisano.dw_contact_treatments_events_view dct
                            WHERE
                                treatment_given = 'Yes'
                        ) treatments_split
                        GROUP BY dw_contact_events_id
                    ) treatments_agg
                        ON (treatments_agg.contact_event_id = dce.id)
                WHERE

                        SELECT count(*) FROM trisano.dw_contact_events_view c
                        WHERE dmev.id = c.id AND contact_type = 'Infant'
                    ) AS contact_infants,
                    (
                        SELECT count(*) FROM trisano.dw_contact_events_view c
                        WHERE dmev.id = c.id AND contact_type = 'Infant'
                        AND c.disposition IS NULL
                    ) AS currently_active
                FROM
                    trisano.dw_morbidity_events_view dmev
                WHERE
