Skip to content

Commit

Permalink
KH-535: Added obs_group_uuid column to flattened observations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruhanga committed Jun 18, 2024
1 parent d24e7d9 commit 649e2ae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions analytics/dsl/export/tables/observations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CREATE TABLE observations (
visit_uuid VARCHAR,
location_uuid VARCHAR,
obs_uuid VARCHAR,
obs_group_uuid VARCHAR,
patient_uuid VARCHAR,
question_uuid VARCHAR
)
4 changes: 3 additions & 1 deletion analytics/dsl/flattening/queries/observations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SELECT
obs.obs_id AS obs_id,
obs.voided AS obs_voided,
location.name AS location,
obs_datetime AS obs_date_time,
obs.obs_datetime AS obs_date_time,
concept_concept_name.name AS question_label,
concept_concept_name.name AS question_mapping,
value_concept_name.name AS answer_coded,
Expand All @@ -29,10 +29,12 @@ SELECT
visit.uuid AS visit_uuid,
location.uuid AS location_uuid,
obs.uuid AS obs_uuid,
parent_obs.uuid AS obs_group_uuid,
patient.uuid AS patient_uuid,
concept.uuid AS question_uuid
FROM
obs
LEFT JOIN obs parent_obs ON parent_obs.obs_id = obs.obs_group_id
LEFT JOIN concept_name value_concept_name ON obs.value_coded = value_concept_name.concept_id AND value_concept_name.locale LIKE 'en' AND value_concept_name.voided = false AND value_concept_name.locale_preferred = true
AND obs.value_coded IS NOT NULL
LEFT JOIN encounter encounter ON obs.encounter_id = encounter.encounter_id
Expand Down
1 change: 1 addition & 0 deletions analytics/liquibase/analytics/changelogs/0001-init.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<column name="visit_uuid" type="VARCHAR"/>
<column name="location_uuid" type="VARCHAR"/>
<column name="obs_uuid" type="VARCHAR"/>
<column name="obs_group_uuid" type="VARCHAR"/>
<column name="patient_uuid" type="VARCHAR"/>
<column name="question_uuid" type="VARCHAR"/>
</createTable>
Expand Down

0 comments on commit 649e2ae

Please sign in to comment.