Skip to content

Commit

Permalink
Fixed case count in createStudyPopulation() when restricting time i…
Browse files Browse the repository at this point in the history
…n prior `getDbSccsData()` call, e.g. by defining a study period and/or nesting cohort.
  • Loading branch information
Admin_mschuemi authored and Admin_mschuemi committed May 22, 2024
1 parent 6d71bca commit 34ded03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: SelfControlledCaseSeries
Type: Package
Title: Self-Controlled Case Series
Version: 5.1.1
Date: 2024-01-29
Version: 5.1.2
Date: 2024-05-22
Authors@R: c(
person("Martijn", "Schuemie", , "schuemie@ohdsi.org", role = c("aut", "cre")),
person("Patrick", "Ryan", role = c("aut")),
Expand Down Expand Up @@ -55,6 +55,6 @@ Remotes:
License: Apache License 2.0
LinkingTo: Rcpp
NeedsCompilation: yes
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
SelfControlledCaseSeries 5.1.2
==============================

Bugfixes

1. Fixed error in SQL about "#case_in_period".

2. Fixed case count in `createStudyPopulation()` when restricting time in prior `getDbSccsData()` call, e.g. by defining a study period and/or nesting cohort.


SelfControlledCaseSeries 5.1.1
==============================

Expand Down
10 changes: 9 additions & 1 deletion R/StudyPopulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ createStudyPopulation <- function(sccsData,
metaData$outcomeId <- unique(outcomes$eraId)
metaData$attrition <- attrition

# Restrict cases to those that have at least one outcome between start and end:
cases <- outcomes %>%
select("caseId", "eraStartDay") %>%
inner_join(cases,
by = join_by("caseId", between("eraStartDay", "startDay", "endDay"))) %>%
select(-"eraStartDay") %>%
distinct()

cases <- cases %>%
select("observationPeriodId", "caseId", "personId", "observationPeriodStartDate", "ageAtObsStart", "startDay", "endDay", "noninformativeEndCensor")

Expand All @@ -263,7 +271,7 @@ createStudyPopulation <- function(sccsData,

countOutcomes <- function(outcomes, cases, description) {
counts <- outcomes %>%
inner_join(cases, by = join_by("caseId")) %>%
inner_join(cases, by = join_by("caseId"), between("eraStartDay", "startDay", "endDay")) %>%
group_by(.data$eraId) %>%
summarise(
outcomeSubjects = n_distinct(.data$personId),
Expand Down

0 comments on commit 34ded03

Please sign in to comment.