From 2a2f08731641061e738b6a14e500e49dee07e5bd Mon Sep 17 00:00:00 2001 From: Anthony Sena Date: Mon, 9 Jun 2025 14:34:22 -0400 Subject: [PATCH 1/3] Modifications to support new SCCS v6 module specification structure --- inst/protocol/self-control-case-series.qmd | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/inst/protocol/self-control-case-series.qmd b/inst/protocol/self-control-case-series.qmd index 3717865..2379bb5 100644 --- a/inst/protocol/self-control-case-series.qmd +++ b/inst/protocol/self-control-case-series.qmd @@ -9,9 +9,9 @@ package <- "SelfControlledCaseSeries" eo <- do.call( what = rbind, args = lapply( - X = 1:length(SelfControlledCaseSeriesModuleSettings$settings$exposuresOutcomeList), + X = 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList), FUN = function(k){ - x <- SelfControlledCaseSeriesModuleSettings$settings$exposuresOutcomeList[[k]] + x <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList[[k]] data.frame( setting = ifelse(is.null(x$jsonId), 1, x$jsonId), #k, outcomeId = rep(x$outcomeId, length(x$exposures)), @@ -32,9 +32,9 @@ if(is.null(negativeControls)){ neg <- do.call( what = rbind, args = lapply( - X = 1:length(SelfControlledCaseSeriesModuleSettings$settings$exposuresOutcomeList), + X = 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList), FUN = function(k){ - x <- SelfControlledCaseSeriesModuleSettings$settings$exposuresOutcomeList[[k]] + x <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList[[k]] data.frame( cohortId = rep(x$outcomeId, length(x$exposures)), outcomeConceptId = rep(x$outcomeId, length(x$exposures)), @@ -153,7 +153,7 @@ The design requires the user to specify the target population of interest, an op In this specification there are ``r length(unique(eoOfInt$parentIdTarget))`` unique parent exposure cohorts (``r nrow(unique(eoOfInt[, c('exposureId', 'nestingId')]))`` unique exposure and indications combinations), see @sec-sccs-eo. There is a total of ``r length(unique(eoOfInt$nestingId))`` unique indications. A total of ``r length(unique(eoOfInt$parentIdOutcome))`` parent outcome cohorts (``r length(unique(eoOfInt$outcomeId))`` unique outcomes with subsets). -In total there are ``r length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysisList)`` different self controlled case series analysis designs (see @sec-sccs-analysis). +In total there are ``r length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsAnalysisList)`` different self controlled case series analysis designs (see @sec-sccs-analysis). ### Exposure Indication Outcomes {#sec-sccs-eo} @@ -305,9 +305,9 @@ cat('\n\n') ```{r sccs_analyses, echo=FALSE, results = 'asis'} -for(i in 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysisList)){ +for(i in 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsAnalysisList)){ - analysisSetting <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysisList[[i]] + analysisSetting <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsAnalysisList[[i]] cat( paste0('#### Analysis ', analysisSetting$analysisId,': ', analysisSetting$description, ' \n'), @@ -476,8 +476,8 @@ settingDf <- getSettingsTable( ```{r sccs_diagnostics, echo=FALSE, results = 'asis'} -if('sccsDiagnosticThresholds' %in% names(SelfControlledCaseSeriesModuleSettings$settings)){ - diagSetting <- SelfControlledCaseSeriesModuleSettings$settings$sccsDiagnosticThresholds +if('sccsDiagnosticThresholds' %in% names(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications)){ + diagSetting <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsDiagnosticThresholds diagSettings <- getSettingsTable( package = package, From fe6d9ca91db20c4a0a8b6244435a8753b04b0a5a Mon Sep 17 00:00:00 2001 From: Anthony Sena Date: Mon, 9 Jun 2025 14:48:35 -0400 Subject: [PATCH 2/3] Mandate SCCS v6 or higher --- DESCRIPTION | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8693e57..f385ebc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,7 +34,9 @@ Suggests: PatientLevelPrediction, remotes, rmarkdown, - SelfControlledCaseSeries, + SelfControlledCaseSeries (>= 6.0.0), testthat +Remotes: + ohdsi/SelfControlledCaseSeries@version_6 RoxygenNote: 7.3.2 Encoding: UTF-8 From 84d09b8d42cc601a41ff230169c0220b7f13b55d Mon Sep 17 00:00:00 2001 From: jreps Date: Mon, 16 Jun 2025 10:27:15 -0400 Subject: [PATCH 3/3] backwards compatibility edits for SCCS - edits to make the code check the json spec matches the installed package for SCCS (a warning is printed when there is a mismatch) - extracts the SCCS setting depending on old and new json spec. --- DESCRIPTION | 4 +- inst/protocol/self-control-case-series.qmd | 48 +++++++++++++++++----- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f385ebc..8693e57 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,9 +34,7 @@ Suggests: PatientLevelPrediction, remotes, rmarkdown, - SelfControlledCaseSeries (>= 6.0.0), + SelfControlledCaseSeries, testthat -Remotes: - ohdsi/SelfControlledCaseSeries@version_6 RoxygenNote: 7.3.2 Encoding: UTF-8 diff --git a/inst/protocol/self-control-case-series.qmd b/inst/protocol/self-control-case-series.qmd index 2379bb5..2f4b267 100644 --- a/inst/protocol/self-control-case-series.qmd +++ b/inst/protocol/self-control-case-series.qmd @@ -6,12 +6,41 @@ output: html_document package <- "SelfControlledCaseSeries" +# check using old or new SCCS setting +if('sccsAnalysesSpecifications' %in% names(SelfControlledCaseSeriesModuleSettings$settings)){ + + # check packageVersion >= 6.0.0 and warn if < 6.0.0 + if(utils::compareVersion( + a = as.character(utils::packageVersion("SelfControlledCaseSeries")), + b = "6.0.0" + ) == -1){ + warning('Installed SelfControlledCaseSeries is less than version 6 but json created using package version 6 or higher.') + } + + # set exposuresOutcomeList + sccsSettings <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications + +} else{ + + # check packageVersion < 6.0.0 and warn if >= 6.0.0 + if(utils::compareVersion( + a = as.character(utils::packageVersion("SelfControlledCaseSeries")), + b = "6.0.0" + ) == 0){ + warning('Installed SelfControlledCaseSeries is version 6 or more but json created using package less than version 6.') + } + + # set exposuresOutcomeList + sccsSettings <- SelfControlledCaseSeriesModuleSettings$settings + +} + eo <- do.call( what = rbind, args = lapply( - X = 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList), + X = 1:length(sccsSettings$exposuresOutcomeList), FUN = function(k){ - x <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList[[k]] + x <- sccsSettings$exposuresOutcomeList[[k]] data.frame( setting = ifelse(is.null(x$jsonId), 1, x$jsonId), #k, outcomeId = rep(x$outcomeId, length(x$exposures)), @@ -32,9 +61,9 @@ if(is.null(negativeControls)){ neg <- do.call( what = rbind, args = lapply( - X = 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList), + X = 1:length(sccsSettings$exposuresOutcomeList), FUN = function(k){ - x <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$exposuresOutcomeList[[k]] + x <- sccsSettings$exposuresOutcomeList[[k]] data.frame( cohortId = rep(x$outcomeId, length(x$exposures)), outcomeConceptId = rep(x$outcomeId, length(x$exposures)), @@ -153,7 +182,7 @@ The design requires the user to specify the target population of interest, an op In this specification there are ``r length(unique(eoOfInt$parentIdTarget))`` unique parent exposure cohorts (``r nrow(unique(eoOfInt[, c('exposureId', 'nestingId')]))`` unique exposure and indications combinations), see @sec-sccs-eo. There is a total of ``r length(unique(eoOfInt$nestingId))`` unique indications. A total of ``r length(unique(eoOfInt$parentIdOutcome))`` parent outcome cohorts (``r length(unique(eoOfInt$outcomeId))`` unique outcomes with subsets). -In total there are ``r length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsAnalysisList)`` different self controlled case series analysis designs (see @sec-sccs-analysis). +In total there are ``r length(sccsSettings$sccsAnalysisList)`` different self controlled case series analysis designs (see @sec-sccs-analysis). ### Exposure Indication Outcomes {#sec-sccs-eo} @@ -305,9 +334,9 @@ cat('\n\n') ```{r sccs_analyses, echo=FALSE, results = 'asis'} -for(i in 1:length(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsAnalysisList)){ +for(i in 1:length(sccsSettings$sccsAnalysisList)){ - analysisSetting <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsAnalysisList[[i]] + analysisSetting <- sccsSettings$sccsAnalysisList[[i]] cat( paste0('#### Analysis ', analysisSetting$analysisId,': ', analysisSetting$description, ' \n'), @@ -475,9 +504,8 @@ settingDf <- getSettingsTable( ```{r sccs_diagnostics, echo=FALSE, results = 'asis'} - -if('sccsDiagnosticThresholds' %in% names(SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications)){ - diagSetting <- SelfControlledCaseSeriesModuleSettings$settings$sccsAnalysesSpecifications$sccsDiagnosticThresholds +if('sccsDiagnosticThresholds' %in% names(sccsSettings)){ + diagSetting <- sccsSettings$sccsDiagnosticThresholds diagSettings <- getSettingsTable( package = package,