Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KH-501: Visit and Patient attributes to correctly show coded and free-text values #19

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions analytics/dsl/flattening/queries/patients.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ SELECT
person_attribute pa
LEFT JOIN person_attribute_type pa_type ON pa.person_attribute_type_id = pa_type.person_attribute_type_id
LEFT JOIN concept c ON pa.`value` = c.uuid
LEFT JOIN concept_name cn ON c.concept_id = cn.concept_id
LEFT JOIN concept_name cn ON c.concept_id = cn.concept_id AND cn.locale_preferred = true AND cn.locale = 'en' AND cn.voided = false
WHERE
pa.person_id = patient.patient_id
AND cn.locale_preferred = true
AND cn.locale = 'en'
AND cn.voided = false
) AS a
pa.person_id = patient.patient_id AND pa.voided = false
) AS a WHERE a.attribute_value IS NOT NULL
) AS attributes,
person.dead AS dead,
person.death_date AS death_date,
Expand Down
9 changes: 3 additions & 6 deletions analytics/dsl/flattening/queries/visits.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SELECT
), ' / '
)
FROM (
SELECT
SELECT DISTINCT
va.visit_id,
vat.name AS attribute_type_name,
CASE
Expand All @@ -25,13 +25,10 @@ SELECT
visit_attribute va
LEFT JOIN visit_attribute_type vat ON va.attribute_type_id = vat.visit_attribute_type_id
LEFT JOIN concept c ON va.value_reference = c.uuid
LEFT JOIN concept_name cn ON c.concept_id = cn.concept_id
LEFT JOIN concept_name cn ON c.concept_id = cn.concept_id AND cn.locale_preferred = true AND cn.locale = 'en' AND cn.voided = false
WHERE
va.visit_id = visit.visit_id
AND cn.locale_preferred = true
AND cn.locale = 'en'
AND cn.voided = false
) AS a
) AS a WHERE a.attribute_value IS NOT NULL
) AS visit_attributes,
person.gender AS patient_gender,
person.birthdate AS patient_birthdate,
Expand Down