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

Use omopDataset variable throughout servey SQL #1081

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ SELECT distinct
ac.name AS answer_concept_name,
sv.survey_concept_id as survey_version_concept_id,
svc.concept_name as survey_version_name
FROM `all-of-us-ehr-dev.SR2023Q3R2.observation` AS o
JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS ps
FROM `${omopDataset}.observation` AS o
JOIN `${omopDataset}.prep_survey` AS ps
ON ps.concept_id = o.observation_source_concept_id
AND (
(CAST(ps.value AS INT64) = o.value_source_concept_id)
Expand All @@ -120,21 +120,21 @@ FROM `all-of-us-ehr-dev.SR2023Q3R2.observation` AS o
)
AND ps.subtype = 'ANSWER'
AND survey IN ('February2021COVID19Part', 'July2020Covid19Particip', 'May2020Covid19Participa')
JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS ps_survey
JOIN `${omopDataset}.prep_survey` AS ps_survey
ON ps_survey.survey = ps.survey
AND ps_survey.subtype = 'SURVEY'
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.concept` AS sc
LEFT JOIN `${omopDataset}.concept` AS sc
ON sc.concept_id = ps_survey.concept_id
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS qc
LEFT JOIN `${omopDataset}.prep_survey` AS qc
ON qc.concept_id = o.observation_source_concept_id
AND qc.subtype = 'QUESTION'
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS ac
LEFT JOIN `${omopDataset}.prep_survey` AS ac
ON ac.concept_id = o.observation_source_concept_id
AND CAST(ac.value AS INT64) = o.value_source_concept_id
AND ac.subtype = 'ANSWER'
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.survey_conduct` AS sv
LEFT JOIN `${omopDataset}.survey_conduct` AS sv
ON sv.survey_conduct_id = o.questionnaire_response_id
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.concept` AS svc
LEFT JOIN `${omopDataset}.concept` AS svc
ON svc.concept_id = sv.survey_concept_id
WHERE sv.survey_concept_id IN (
2100000002, 2100000003, 2100000004, 2100000005, 2100000006, 2100000007
Expand All @@ -156,8 +156,8 @@ SELECT distinct
ac.name AS answer_concept_name,
sv.survey_concept_id as survey_version_concept_id,
svc.concept_name as survey_version_name
FROM `all-of-us-ehr-dev.SR2023Q3R2.observation` AS o
JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS ps
FROM `${omopDataset}.observation` AS o
JOIN `${omopDataset}.prep_survey` AS ps
ON ps.concept_id = o.observation_source_concept_id
AND (
(CAST(ps.value AS INT64) = o.value_source_concept_id)
Expand All @@ -166,21 +166,21 @@ FROM `all-of-us-ehr-dev.SR2023Q3R2.observation` AS o
)
AND ps.subtype = 'ANSWER'
AND survey IN ('NewYearMinuteSurveyOnCO')
JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS ps_survey
JOIN `${omopDataset}.prep_survey` AS ps_survey
ON ps_survey.survey = ps.survey
AND ps_survey.subtype = 'SURVEY'
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.concept` AS sc
LEFT JOIN `${omopDataset}.concept` AS sc
ON sc.concept_id = ps_survey.concept_id
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS qc
LEFT JOIN `${omopDataset}.prep_survey` AS qc
ON qc.concept_id = o.observation_source_concept_id
AND qc.subtype = 'QUESTION'
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.prep_survey` AS ac
LEFT JOIN `${omopDataset}.prep_survey` AS ac
ON ac.concept_id = o.observation_source_concept_id
AND CAST(ac.value AS INT64) = o.value_source_concept_id
AND ac.subtype = 'ANSWER'
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.survey_conduct` AS sv
LEFT JOIN `${omopDataset}.survey_conduct` AS sv
ON sv.survey_conduct_id = o.questionnaire_response_id
LEFT JOIN `all-of-us-ehr-dev.SR2023Q3R2.concept` AS svc
LEFT JOIN `${omopDataset}.concept` AS svc
ON svc.concept_id = sv.survey_concept_id
WHERE sv.survey_concept_id IN (
905047, 905055, 765936, 1741006
Expand Down