Skip to content

Commit a89a163

Browse files
committed
[DC-1022] updates required_labs query to include concept_ancestor_extension
Signed-off-by: Krishna Kalluri <[email protected]>
1 parent c7b1502 commit a89a163

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

data_steward/tools/generate_concept_ancestor_extension.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
concept_relationship stores two types of relationships
33
1) hierarchical relationships: 'is_a' / 'subsume' that defines the hierarchy of the vocabulary;
4-
2.) associative relationships: relationships across the hierarchy such as Drug A
4+
2) associative relationships: relationships across the hierarchy such as Drug A
55
'is an indication of' Condition B. The concept_ancestor table is built based on 'Is A' and 'Subsume' relationships
66
recursively so any ancestor/descendent pairs (regardless of the levels of separation) are pre-computed for us.
77
@@ -20,7 +20,7 @@
2020

2121
LOGGER = logging.getLogger(__name__)
2222

23-
CONCEPT_ANCESTOR_EXT = 'concept_ancestor_extension'
23+
CONCEPT_ANCESTOR_EXTENSION = 'concept_ancestor_extension'
2424

2525
CONCEPT_ANCESTOR_EXT_QUERY = '''
2626
DECLARE
@@ -129,7 +129,7 @@
129129

130130
def generate_concept_ancestor_extension(project_id, dataset_id):
131131
"""
132-
generates concept ancestor extension table from the concept relationship table for for LOINC hierarchy
132+
generates concept ancestor extension table from the concept relationship table for LOINC hierarchy
133133
:param project_id: identifier for project id
134134
:param dataset_id: identifier for dataset
135135
:return: Bq job result

data_steward/validation/metrics/required_labs_sql.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
FROM UNNEST([36208978, 36206173, 36208195, 36207527, 36210656, 40782521, 40779250, 40772590]) AS excluded_ancestor_concept_id
1818
),
1919
20+
concept_ancestor AS
21+
(
22+
SELECT
23+
*
24+
FROM
25+
`{project_id}.{vocab_dataset_id}.concept_ancestor`
26+
UNION ALL
27+
SELECT
28+
*
29+
FROM
30+
`{project_id}.{vocab_dataset_id}.concept_ancestor_extension`
31+
)
32+
2033
get_direct_parents_loinc_group AS
2134
(
2235
-- We use left joins because there are concepts that don`t have a LONIC_Group type ancestor in concept_ancestor
@@ -36,7 +49,7 @@
3649
ON
3750
m.Measurement_OMOP_ID = c1.concept_id
3851
LEFT JOIN
39-
`{project_id}.{vocab_dataset_id}.concept_ancestor` AS ca
52+
concept_ancestor AS ca
4053
ON
4154
m.Measurement_OMOP_ID = ca.descendant_concept_id
4255
AND ca.min_levels_of_separation = 1
@@ -70,7 +83,7 @@
7083
ON
7184
m.Measurement_OMOP_ID = c1.concept_id
7285
LEFT JOIN
73-
`{project_id}.{vocab_dataset_id}.concept_ancestor` AS ca
86+
concept_ancestor AS ca
7487
ON
7588
m.Measurement_OMOP_ID = ca.descendant_concept_id
7689
AND ca.min_levels_of_separation IN (1, 2)
@@ -138,7 +151,7 @@
138151
COALESCE(ca1.min_levels_of_separation, -1) AS distance
139152
FROM get_direct_parents_loinc_group AS lg
140153
LEFT JOIN
141-
`{project_id}.{vocab_dataset_id}.concept_ancestor` AS ca1
154+
concept_ancestor AS ca1
142155
ON
143156
lg.parent_concept_id = ca1.ancestor_concept_id
144157
AND ca1.min_levels_of_separation <> 0
@@ -164,7 +177,7 @@
164177
COALESCE(ca1.min_levels_of_separation, -1) AS distance
165178
FROM get_ancestors_loinc_hierarchy_distinct AS lh
166179
LEFT JOIN
167-
`{project_id}.{vocab_dataset_id}.concept_ancestor` AS ca1
180+
concept_ancestor AS ca1
168181
ON
169182
lh.ancestor_concept_id = ca1.ancestor_concept_id
170183
AND ca1.min_levels_of_separation <> 0

0 commit comments

Comments
 (0)