Skip to content

Commit

Permalink
restricting cases to first outcome in TAR
Browse files Browse the repository at this point in the history
- restricting cases to first outcome in TAR
  • Loading branch information
jreps committed Sep 19, 2024
1 parent 67c253d commit 147d70a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Characterization
Type: Package
Title: Characterizations of Cohorts
Version: 2.0.1
Version: 2.0.1.9000
Date: 2024-08-21
Authors@R: c(
person("Jenna", "Reps", , "[email protected]", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion inst/sql/sql_server/CaseCohortsPart1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ and datediff(day, op.observation_period_start_date, o.cohort_start_date) >= @min
IF OBJECT_ID('tempdb..#case_exclude', 'U') IS NOT NULL DROP TABLE #case_exclude;

-- people with outcome prior
select
select distinct
t.subject_id,
t.cohort_start_date,
t.cohort_end_date,
Expand Down
15 changes: 11 additions & 4 deletions inst/sql/sql_server/CaseCohortsPart2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

-- 1) get all the people with the outcome in TAR
IF OBJECT_ID('tempdb..#cases_tar', 'U') IS NOT NULL DROP TABLE #cases_tar;
-- cases
-- cases (first outcome date)
select
t.subject_id,
t.cohort_start_date,
t.cohort_end_date,
o.cohort_start_date as outcome_start_date,
o.cohort_end_date as outcome_end_date,
min(o.cohort_start_date) as outcome_start_date,
min(o.cohort_end_date) as outcome_end_date,
t.cohort_definition_id as target_cohort_id,
o.cohort_definition_id as outcome_cohort_id
into #cases_tar
Expand All @@ -19,7 +19,14 @@ where
o.cohort_start_date <= dateadd(day, @tar_end, t.@tar_end_anchor)
and
-- outcome starts (ends?) after TAR start
o.cohort_start_date >= dateadd(day, @tar_start, t.@tar_start_anchor);
o.cohort_start_date >= dateadd(day, @tar_start, t.@tar_start_anchor)
-- make sure to only get first outcome date during TAR
group by
t.subject_id,
t.cohort_start_date,
t.cohort_end_date,
t.cohort_definition_id,
o.cohort_definition_id;

-- add the cases for specific TAR
insert into #cases
Expand Down

0 comments on commit 147d70a

Please sign in to comment.