Skip to content

Commit

Permalink
standardizing sccs
Browse files Browse the repository at this point in the history
- standardizing sccs
  • Loading branch information
jreps committed Aug 4, 2023
1 parent c82addd commit 00842e1
Show file tree
Hide file tree
Showing 10 changed files with 825 additions and 761 deletions.
69 changes: 0 additions & 69 deletions R/helpers-sccsDataPulls.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,76 +130,7 @@ sccsGetAnalyses <- function(
return(result2)
}

getSccsResults <- function(connectionHandler,
resultDatabaseSettings,
exposureIds,
outcomeIds,
databaseIds,
analysisIds) {
sql <- "
SELECT
sr.*,
ds.cdm_source_abbreviation as database_name,
sds.mdrr,
sds.ease,
sds.time_trend_p,
sds.pre_exposure_p,
sds.mdrr_diagnostic,
sds.ease_diagnostic,
sds.time_trend_diagnostic,
sds.pre_exposure_diagnostic,
sds.unblind,
sc.covariate_name,
sc.era_id,
sc.covariate_analysis_id,
a.description,
eos.outcome_id
FROM @schema.@sccs_table_prefixresult sr
INNER JOIN
@schema.@database_table_prefix@database_table ds
ON sr.database_id = ds.database_id
INNER JOIN
@schema.@sccs_table_prefixdiagnostics_summary sds ON (
sds.exposures_outcome_set_id = sr.exposures_outcome_set_id AND
sds.database_id = sr.database_id AND
sds.analysis_id = sr.analysis_id AND
sds.covariate_id = sr.covariate_id
)
INNER JOIN
@schema.@sccs_table_prefixcovariate sc ON (
sc.exposures_outcome_set_id = sr.exposures_outcome_set_id AND
sc.database_id = sr.database_id AND
sc.analysis_id = sr.analysis_id AND
sc.covariate_id = sr.covariate_id
)
INNER JOIN @schema.@sccs_table_prefixexposures_outcome_set eos
ON
eos.exposures_outcome_set_id = sr.exposures_outcome_set_id
INNER JOIN
@schema.@sccs_table_prefixanalysis a
on a.analysis_id = sr.analysis_id
WHERE sr.analysis_id IN (@analysis_ids)
AND sr.database_id IN (@database_ids)
AND eos.outcome_id IN (@outcome_ids)
AND sc.era_id IN (@exposure_ids)
"

results <- connectionHandler$queryDb(
sql,
schema = resultDatabaseSettings$schema,
database_table_prefix = resultDatabaseSettings$databaseTablePrefix,
database_table = resultDatabaseSettings$databaseTable,
sccs_table_prefix = resultDatabaseSettings$sccsTablePrefix,
database_ids = paste(quoteLiterals(databaseIds), collapse = ','),
analysis_ids = analysisIds,
outcome_ids = paste(outcomeIds, collapse = ','),
exposure_ids = paste(exposureIds, collapse = ','),
snakeCaseToCamelCase = TRUE
)

return(results)
}

getSccsModel <- function(connectionHandler,
resultDatabaseSettings,
Expand Down
6 changes: 0 additions & 6 deletions R/helpers-sccsPlots.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
prettyHr <- function(x) {
result <- sprintf("%.2f", x)
result[is.na(x) | x > 100] <- "NA"
return(result)
}

convertToStartDate <- function(year, month) {
return(as.Date(sprintf(
"%s-%s-%s",
Expand Down
106 changes: 16 additions & 90 deletions R/sccs-diagnosticsSummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
sccsDiagnosticsSummaryViewer <- function(id) {
ns <- shiny::NS(id)

shiny::div(
inputSelectionViewer(ns("input-selection")),
shinydashboard::box(
status = 'info',
width = '100%',
title = shiny::span('Diagnostic Results'),
solidHeader = TRUE,

shiny::conditionalPanel(
condition = 'input.generate != 0',
ns = shiny::NS(ns("input-selection")),

shiny::tabsetPanel(
type = 'pills',
id = ns('diagnosticsTablePanel'),
Expand All @@ -40,107 +39,29 @@ sccsDiagnosticsSummaryViewer <- function(id) {
)
)
)
)

}

sccsDiagnosticsSummaryServer <- function(
id,
connectionHandler,
resultDatabaseSettings
resultDatabaseSettings,
inputSelected
) {

shiny::moduleServer(
id,
function(input, output, session) {

targetIds <- getSccsDiagTargets(
connectionHandler = connectionHandler,
resultDatabaseSettings = resultDatabaseSettings
)
outcomeIds <- getSccsDiagOutcomes(
connectionHandler = connectionHandler,
resultDatabaseSettings = resultDatabaseSettings
)
analysisIds <- getSccsDiagAnalyses(
connectionHandler = connectionHandler,
resultDatabaseSettings = resultDatabaseSettings
)

inputSelected <- inputSelectionServer(
id = "input-selection",
inputSettingList = list(
createInputSetting(
rowNumber = 1,
columnWidth = 6,
varName = 'targetIds',
uiFunction = 'shinyWidgets::pickerInput',
uiInputs = list(
label = 'Target: ',
choices = targetIds,
selected = targetIds[1],
multiple = T,
options = shinyWidgets::pickerOptions(
actionsBox = TRUE,
liveSearch = TRUE,
size = 10,
liveSearchStyle = "contains",
liveSearchPlaceholder = "Type here to search",
virtualScroll = 50
)
)
),
createInputSetting(
rowNumber = 1,
columnWidth = 6,
varName = 'outcomeIds',
uiFunction = 'shinyWidgets::pickerInput',
uiInputs = list(
label = 'Outcome: ',
choices = outcomeIds,
selected = outcomeIds[1],
multiple = T,
options = shinyWidgets::pickerOptions(
actionsBox = TRUE,
liveSearch = TRUE,
size = 10,
liveSearchStyle = "contains",
liveSearchPlaceholder = "Type here to search",
virtualScroll = 50
)
)
),

createInputSetting(
rowNumber = 2,
columnWidth = 12,
varName = 'analysisIds',
uiFunction = 'shinyWidgets::pickerInput',
uiInputs = list(
label = 'Analysis: ',
choices = analysisIds,
selected = analysisIds[1],
multiple = T,
options = shinyWidgets::pickerOptions(
actionsBox = TRUE,
liveSearch = TRUE,
size = 10,
liveSearchStyle = "contains",
liveSearchPlaceholder = "Type here to search",
virtualScroll = 50
)
)
)
)
)

data <- shiny::reactive({

getSccsAllDiagnosticsSummary(
connectionHandler = connectionHandler,
resultDatabaseSettings = resultDatabaseSettings,
targetIds = inputSelected()$targetIds,
outcomeIds = inputSelected()$outcomeIds,
analysisIds = inputSelected()$analysisIds
targetIds = inputSelected()$exposure,
outcomeIds = inputSelected()$outcome,
analysisIds = inputSelected()$analysis

Check warning on line 64 in R/sccs-diagnosticsSummary.R

View check run for this annotation

Codecov / codecov/patch

R/sccs-diagnosticsSummary.R#L59-L64

Added lines #L59 - L64 were not covered by tests
)
})

Expand Down Expand Up @@ -370,6 +291,11 @@ getSccsAllDiagnosticsSummary <- function(
outcomeIds,
analysisIds = NULL
) {

if(is.null(targetIds)){
return(NULL)

Check warning on line 296 in R/sccs-diagnosticsSummary.R

View check run for this annotation

Codecov / codecov/patch

R/sccs-diagnosticsSummary.R#L296

Added line #L296 was not covered by tests
}

sql <- "
SELECT
d.cdm_source_abbreviation as database_name,
Expand Down
Loading

0 comments on commit 00842e1

Please sign in to comment.