Skip to content

Commit

Permalink
Update AggregateCovariates.R
Browse files Browse the repository at this point in the history
- adding checks for unique cohort_definition_ids
  • Loading branch information
jreps committed May 17, 2024
1 parent 9e2e281 commit d97b243
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions R/AggregateCovariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ createAggregateCovariateSettings <- function(

checkmate::reportAssertions(errorMessages)

# check unique Ts and Os
if(length(targetIds) != length(unique(targetIds))){
message('targetIds have duplicates - making unique')
targetIds <- unique(targetIds)

Check warning on line 140 in R/AggregateCovariates.R

View check run for this annotation

Codecov / codecov/patch

R/AggregateCovariates.R#L139-L140

Added lines #L139 - L140 were not covered by tests
}
if(length(outcomeIds) != length(unique(outcomeIds))){
message('outcomeIds have duplicates - making unique')
outcomeIds <- unique(outcomeIds)

Check warning on line 144 in R/AggregateCovariates.R

View check run for this annotation

Codecov / codecov/patch

R/AggregateCovariates.R#L143-L144

Added lines #L143 - L144 were not covered by tests
}


# create list
result <- list(
targetIds = targetIds,
Expand Down Expand Up @@ -201,6 +212,11 @@ computeAggregateCovariateAnalyses <- function(
outcomeIds = aggregateCovariateSettings$outcomeIds
)

# check cohortDefinitionIds are unique
if(sum(table(cohortDetails$cohortDefinitionIds> 1)) != 0){
stop('Unique constrain on cohortDefinitionIds failed')

Check warning on line 217 in R/AggregateCovariates.R

View check run for this annotation

Codecov / codecov/patch

R/AggregateCovariates.R#L217

Added line #L217 was not covered by tests
}

# for each time-at-risk get case details
for(i in 1:length(aggregateCovariateSettings$riskWindowStart)){
cohortDetails <- rbind(
Expand Down

0 comments on commit d97b243

Please sign in to comment.