 
 CREATE TABLE report4 AS
                 SELECT
-                    dme.id,
+                    dme.id, dce.id AS contact_id, dce.record_number,
                     dme.investigating_jurisdiction,
-                    dme.actual_delivery_date,
+                    COALESCE(dce.birth_date, dme.actual_delivery_date) AS actual_delivery_date,
                     1 AS total,
                     contact_type,
                     disposition,

                                                    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

                        ON (treatments_agg.contact_event_id = dce.id)
                WHERE
                    dce.disease_name = 'Hepatitis B Pregnancy Event' AND
                    dce.birth_date IS NOT NULL;
;

CREATE TABLE morb_sec_juris AS
