     e.type = 'PlaceEvent'
 ;
 
--- CREATE TABLE dw_answers AS
--- SELECT
---     *,
---     CASE
---         WHEN EXISTS (
---             SELECT 1
---             FROM events
---             WHERE
---                 events.id = a.event_id AND
---                 events.type = 'MorbidityEvent'
---         )
---         THEN TRUE::BOOLEAN
---         ELSE FALSE::BOOLEAN
---     END AS is_morbidity,
---     CASE
---         WHEN EXISTS (
---             SELECT 1
---             FROM events
---             WHERE
---                 events.id = a.event_id AND
---                 events.type = 'ContactEvent'
---         )
---         THEN TRUE::BOOLEAN
---         ELSE FALSE::BOOLEAN
---     END AS is_contact,
---     CASE
---         WHEN EXISTS (
---             SELECT 1
---             FROM events
---             WHERE
---                 events.id = a.event_id AND
---                 events.type = 'PlaceEvent'
---         )
---         THEN TRUE::BOOLEAN
---         ELSE FALSE::BOOLEAN
---     END AS is_place,
---     CASE
---         WHEN EXISTS (
---             SELECT 1
---             FROM events
---             WHERE
---                 events.id = a.event_id AND
---                 events.type = 'EncounterEvent'
---         )
---         THEN TRUE::BOOLEAN
---         ELSE FALSE::BOOLEAN
---     END AS is_encounter
--- FROM answers a;
+ALTER TABLE dw_place_answers
+    ADD CONSTRAINT dw_place_answers_pkey PRIMARY KEY (id);
+CREATE INDEX dw_place_answers_event_id
+    ON dw_place_answers (event_id);
+CREATE INDEX dw_place_answers_question_id
+    ON dw_place_answers (question_id);
 
 CREATE TABLE dw_morbidity_diseases AS
 SELECT


ALTER TABLE dw_encounters
    ADD CONSTRAINT pk_dw_encounters PRIMARY KEY (id);

CREATE INDEX dw_encounters_parent ON dw_encounters (dw_morbidity_events_id);

CREATE TABLE dw_encounters_labs AS
SELECT
    events.id,
    events.id AS dw_encounters_id,
    lr.id AS dw_lab_results_id
FROM

    e.type = 'MorbidityEvent'
;

ALTER TABLE dw_morbidity_answers
    ADD CONSTRAINT dw_morbidity_answers_pkey PRIMARY KEY (id);
CREATE INDEX dw_morbidity_answers_event_id
    ON dw_morbidity_answers (event_id);
CREATE INDEX dw_morbidity_answers_question_id
    ON dw_morbidity_answers (question_id);

CREATE TABLE dw_contact_answers AS
SELECT
    a.*
