     events.id,
     events.parent_id AS dw_morbidity_events_id,
     p.name,
-    c.code_description AS place_type,
+    pt.place_types AS place_type,
     prtpl.date_of_exposure,
     ad.street_number,
     ad.street_name,

    LEFT JOIN places
        ON (places.entity_id = p.secondary_entity_id)
    LEFT JOIN (
        -- Just in case there are places with multiple types. We only want it to create one record
        -- XXX erm, this won't work. It's on Josh's TODO list
        SELECT DISTINCT ON (place_id) place_id, type_id FROM places_types
    ) pt
        ON (pt.place_id = places.id)
    LEFT JOIN codes c
        ON (c.id = pt.type_id AND c.deleted_at IS NULL)
    LEFT JOIN organisms org
        ON (org.id = lr.organism_id)
;

        ON (p.event_id = events.id)
    JOIN places pl
        ON (pl.entity_id = p.secondary_entity_id)
    LEFT JOIN (
        SELECT place_id, trisano.text_join_agg(code_description, ', ') AS place_types
        FROM
            codes repagc
            JOIN places_types repag_pt
                ON (repag_pt.type_id = repagc.id)
        GROUP BY place_id 
    ) pt
        ON (pt.place_id = pl.id)
--    RIGHT JOIN events
--        ON (p.event_id = events.id)
WHERE
