forked from ohdsi-studies/StudyRepoTemplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
WITH init_data AS ( | ||
SELECT cohort_definition_id, | ||
DATEDIFF(day, cohort_start_date, cohort_end_date) AS value | ||
FROM @cohort_database_schema.@cohort_table | ||
WHERE cohort_definition_id IN (@target_ids) | ||
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
WITH tab as ( | ||
SELECT cohort_definition_id, cohort_start_date, min(drug_exposure_start_date) as drug_exposure_date | ||
FROM @cohort_database_schema.@cohort_table coh | ||
JOIN @cdm_database_schema.drug_exposure de | ||
ON coh.subject_id = de.person_id | ||
AND de.drug_concept_id IN ( | ||
SELECT concept_id | ||
FROM @cohort_database_schema.drug_codesets | ||
) | ||
AND de.drug_exposure_start_date >= coh.cohort_start_date | ||
AND de.drug_exposure_start_date <= coh.cohort_end_date | ||
WHERE coh.cohort_definition_id IN (@target_ids) | ||
GROUP BY cohort_definition_id, subject_id, cohort_start_date | ||
ORDER BY cohort_definition_id), | ||
init_data AS( | ||
SELECT cohort_definition_id, | ||
DATEDIFF(day, cohort_start_date, drug_exposure_date) AS value | ||
FROM tab | ||
), |