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

Pass AttrSwapFields to nested translators #1126

Merged
merged 2 commits into from
Jan 14, 2025
Merged

Conversation

dexamundsen
Copy link
Contributor

@dexamundsen dexamundsen commented Jan 14, 2025

Issue
image

When changing the slider to 17 - 100 it also produces another incorrect query for top 10 conditions, procedures, labs and drugs. The query is matching domain occurrence id to person_id which gives incorrect results:

root cause - the attribute swap function is initialized on one filter translator, but not applied when it is actually translated to sql since it is done by a different filter translator. Possible fix - pass on attribute swap object

before change

SELECT COUNT(DISTINCT person_id) AS T_CTDT, procedure, T_DISP_procedure 
FROM `vwb-dev-blissful-eggplant-4805.aou_test_data_SC2023Q3R2_index_121624`.T_ENT_procedureOccurrence 
WHERE id IN (
	SELECT person_id 
	FROM `vwb-dev-blissful-eggplant-4805.aou_test_data_SC2023Q3R2_index_121624`.T_ENT_heartRate 
	WHERE value_numeric BETWEEN 17.0 AND 100.0) 
GROUP BY procedure, T_DISP_procedure 
ORDER BY T_CTDT DESC 
LIMIT 1000000

debug:
added swapAttributeField (id / person_id) to GroupHasItemsFilterTranslator in BQRelationshipFilterTranslator.foreignKeyOnSelectEntity (object @387bd4ac)
checking attributeSwapFields (id) in BQRelationshipFilterTranslator.foreignKeyOnFilterEntity (object @5fc6cc6b)

after changes

SELECT COUNT(DISTINCT person_id) AS T_CTDT, procedure, T_DISP_procedure 
FROM `vwb-dev-blissful-eggplant-4805.aou_test_data_SC2023Q3R2_index_121624`.T_ENT_procedureOccurrence 
WHERE person_id IN (
	SELECT person_id 
	FROM `vwb-dev-blissful-eggplant-4805.aou_test_data_SC2023Q3R2_index_121624`.T_ENT_heartRate 
	WHERE value_numeric BETWEEN 17.0 AND 100.0) 
GROUP BY procedure, T_DISP_procedure 
ORDER BY T_CTDT DESC 
LIMIT 1000000

also fixes bug in the top 10 charts for conditions, procedures, labs and drugs queries.
When selecting a Physical Measurement criteria first time in the query produced is incorrect and referencing columns that don’t exist in the entity table. Example query (T_RCNT_heartRatePerson_NOHIER doesn’t exist in T_ENT_measurementOccurrence table

SELECT COUNT(DISTINCT person_id) AS T_CTDT, measurement, T_DISP_measurement
FROM `all-of-us-ehr-dev.SR2023Q3R2`.T_ENT_measurementOccurrence
WHERE T_RCNT_heartRatePerson_NOHIER > 0
GROUP BY measurement, T_DISP_measurement
ORDER BY T_CTDT DESC
LIMIT 1000000

after change

SELECT COUNT(DISTINCT person_id) AS T_CTDT, measurement, T_DISP_measurement 
FROM `vwb-dev-blissful-eggplant-4805.aou_test_data_SC2023Q3R2_index_121624`.T_ENT_measurementOccurrence 
WHERE person_id IN (
    SELECT person_id 
    FROM `vwb-dev-blissful-eggplant-4805.aou_test_data_SC2023Q3R2_index_121624`.T_ENT_heartRate) 
GROUP BY measurement, T_DISP_measurement 
ORDER BY T_CTDT DESC 
LIMIT 1000000

@dexamundsen dexamundsen self-assigned this Jan 14, 2025
@dexamundsen dexamundsen merged commit 23050e1 into main Jan 14, 2025
8 checks passed
@dexamundsen dexamundsen deleted the dexamundsen/0113 branch January 14, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants