Skip to content

Commit

Permalink
Merge branch 'develop' into issue294
Browse files Browse the repository at this point in the history
  • Loading branch information
jreps authored Oct 4, 2024
2 parents ca27644 + b5cb001 commit 4204fa9
Show file tree
Hide file tree
Showing 150 changed files with 1,049 additions and 712 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/R_CMD_check_Hades.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"}

env:
GITHUB_PAT: ${{ secrets.GH_TOKEN }}
Expand Down Expand Up @@ -50,6 +51,7 @@ jobs:
CDM5_SPARK_USER: ${{ secrets.CDM5_SPARK_USER }}
CDM5_SPARK_PASSWORD: ${{ secrets.CDM5_SPARK_PASSWORD }}
CDM5_SPARK_CONNECTION_STRING: ${{ secrets.CDM5_SPARK_CONNECTION_STRING }}
_JAVA_OPTIONS: -Xss3m

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: OhdsiShinyModules
Type: Package
Title: Repository of Shiny Modules for OHDSI Result Viewers
Version: 3.0.0
Version: 3.0.2
Authors@R: c(
person("Jenna", "Reps", email = "[email protected]", role = c("aut", "cre")),
person("Nathan", "Hall", role = c("aut")),
Expand Down Expand Up @@ -62,4 +62,4 @@ Suggests:
Remotes:
ohdsi/ReportGenerator,
ohdsi/ResultModelManager
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
OhdsiShinyModules v3.0.2
========================
- Fixed bug with orphan concepts not loading

OhdsiShinyModules v3.0.1
========================
- Bug fixes

OhdsiShinyModules v3.0.0
========================
- Removed CohortMethod/SCCS/EvidenceSyntheis modules as these
are replaced with Estimation

OhdsiShinyModules v2.2.1
========================
- Fixed issue in DatabaseConnector check for pooled connections of sqlite databases on cohort diagnotiscs load (from main hotfix)
Expand Down
2 changes: 1 addition & 1 deletion R/OhdsiShinyModules.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
#' @keywords internal
#' @importFrom dplyr %>%
#' @importFrom rlang .data
"_PACKAGE"
"_PACKAGE"
3 changes: 3 additions & 0 deletions R/characterization-cohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@ characterizatonGetCohortComparisonDataContinuous <- function(
-"settingId", -"targetCohortId", -"outcomeCohortId",
-"cohortType") %>%
dplyr::relocate("databaseName", .after = "covariateName")

# fill missing values with 0
res[is.na(res)] <- 0
}

shiny::incProgress(4/4, detail = paste("Done"))
Expand Down
5 changes: 1 addition & 4 deletions R/characterization-incidence.R
Original file line number Diff line number Diff line change
Expand Up @@ -1697,9 +1697,6 @@ getIncidenceData <- function(
){
if(!is.null(targetIds) & !is.null(outcomeIds)){

print(targetIds)
print(outcomeIds)

shiny::withProgress(message = 'Getting incidence data', value = 0, {

sql <- 'select d.cdm_source_abbreviation, i.*, ct1.cohort_name as target_name, ct2.cohort_name as outcome_name
Expand Down Expand Up @@ -1901,4 +1898,4 @@ characterizationGetCiTars <- function(connectionHandler,
niceColNames = colDefCsv$niceName,
tooltipText = colDefCsv$toolTip
)
}
}
20 changes: 15 additions & 5 deletions R/cohort-diagnostics-characterization.R
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ cohortDiagCharacterizationModule <- function(
params$time_id <- ""
params$use_database_id <- TRUE
params$database_table <- dataSource$databaseTable
params$database_table_prefix <- dataSource$databaseTablePrefix
params$database_name <- ifelse(tolower(dataSource$databaseTable) == 'database_meta_data', 'cdm_source_name', 'database_name')
return(params)
})

Expand Down Expand Up @@ -1054,11 +1056,11 @@ cohortDiagCharacterizationModule <- function(
FROM @results_database_schema.@table_prefixtemporal_covariate_ref tcr
INNER JOIN @results_database_schema.@table_prefixtemporal_analysis_ref tar ON tar.analysis_id = tcr.analysis_id
INNER JOIN @results_database_schema.@table_prefixtemporal_covariate_value tcv ON tcr.covariate_id = tcv.covariate_id
INNER JOIN @results_database_schema.@database_table db ON db.database_id = tcv.database_id
INNER JOIN @results_database_schema.@database_table_prefix@database_table db ON db.database_id = tcv.database_id
WHERE tcr.covariate_id IS NOT NULL
"

selectSt <- "db.database_name,
selectSt <- "db.@database_name as database_name,
tcr.covariate_name,
tar.analysis_name,
is_binary,
Expand All @@ -1076,13 +1078,21 @@ cohortDiagCharacterizationModule <- function(
# Select casees for each db
for (i in 1:length(timeIds)) {
timeId <- timeIds[i]
tplSql <- c(tplSql, SqlRender::render(selectTemplate, i = i, time_id = timeId))
havingSql <- c(havingSql, SqlRender::render(havingTemplate, time_id = timeId))
tplSql <- c(tplSql, SqlRender::render(
sql = selectTemplate,
i = i,
time_id = timeId)
)
havingSql <- c(havingSql, SqlRender::render(
sql = havingTemplate,
time_id = timeId
)
)
}

tplSql <- paste(tplSql, collapse = ", \n")
groupClause <- SqlRender::render("
GROUP BY db.database_name, tcr.covariate_name, tar.analysis_name, tcr.concept_id, is_binary
GROUP BY db.@database_name, tcr.covariate_name, tar.analysis_name, tcr.concept_id, is_binary
HAVING @having_clasuse
", having_clasuse = paste(havingSql, collapse = " OR\n"))

Expand Down
2 changes: 1 addition & 1 deletion R/cohort-diagnostics-databaseInformation.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ getExecutionMetadata <- function(dataSource, databaseId) {


getDatabaseMetadata <- function(dataSource, databaseTable) {
data <- loadResultsTable(dataSource, "metadata", required = TRUE, cdTablePrefix = dataSource$cdTablePrefix)
data <- loadResultsTable(dataSource, "metadata", required = TRUE, cdTablePrefix = dataSource$cdTablePrefix, databaseTablePrefix = dataSource$databaseTablePrefix)
data <- data %>%
tidyr::pivot_wider(
id_cols = c("startTime", "databaseId"),
Expand Down
41 changes: 31 additions & 10 deletions R/cohort-diagnostics-main.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

# NOTE: here it would be nice to use dbplyr tables - this would allow lazy loading of resources
# however, renaming the columns causes an error and its not obvious how it could be resolved
loadResultsTable <- function(dataSource, tableName, required = FALSE, cdTablePrefix = "") {
selectTableName <- paste0(cdTablePrefix, tableName)
loadResultsTable <- function(dataSource, tableName, required = FALSE, cdTablePrefix = "", databaseTablePrefix = "") {
selectTableName <- paste0(ifelse(!tolower(tableName) == 'database_meta_data', cdTablePrefix,databaseTablePrefix), tableName)
resultsTablesOnServer <-
tolower(.availableTables(dataSource$connectionHandler, dataSource$schema))

Expand All @@ -47,9 +47,20 @@ loadResultsTable <- function(dataSource, tableName, required = FALSE, cdTablePre

tryCatch(
{
table <- dataSource$connectionHandler$queryDb("SELECT * FROM @schema.@table",
schema = dataSource$schema,
table = selectTableName)

if(tolower(tableName) == 'database_meta_data'){
table <- dataSource$connectionHandler$queryDb(
"SELECT *, cdm_source_name as database_name FROM @schema.@table",
schema = dataSource$schema,
table = selectTableName
)
} else{
table <- dataSource$connectionHandler$queryDb(
"SELECT * FROM @schema.@table",
schema = dataSource$schema,
table = selectTableName
)
}
},
error = function(err) {
stop(
Expand Down Expand Up @@ -224,7 +235,13 @@ createCdDatabaseDataSource <- function(
dbms = connectionHandler$dbms(),
resultsTablesOnServer = .availableTables(connectionHandler, resultDatabaseSettings$schema),
cdTablePrefix = resultDatabaseSettings$cdTablePrefix,
prefixTable = function(tableName) { paste0(resultDatabaseSettings$cdTablePrefix, tableName) },
prefixTable = function(tableName) {
if(tableName != resultDatabaseSettings$databaseTable){
return(paste0(resultDatabaseSettings$cdTablePrefix, tableName))
} else{
return(paste0(resultDatabaseSettings$databaseTablePrefix, tableName))
}
},
prefixVocabTable = function(tableName) {
# don't prexfix table if we us a dedicated vocabulary schema
if (resultDatabaseSettings$vocabularyDatabaseSchema == resultDatabaseSettings$schema)
Expand All @@ -235,8 +252,8 @@ createCdDatabaseDataSource <- function(
cgTable = resultDatabaseSettings$cgTable,
cgTablePrefix = resultDatabaseSettings$cgTablePrefix,
useCgTable = FALSE,
databaseTable = "database",
databaseTablePrefix = "cd_",
databaseTable = resultDatabaseSettings$databaseTable,#"database",
databaseTablePrefix = resultDatabaseSettings$databaseTablePrefix,#"cd_",
dataModelSpecifications = modelSpec
)

Expand Down Expand Up @@ -317,6 +334,7 @@ createCdDatabaseDataSource <- function(

getDatabaseTable <- function(dataSource) {
databaseTable <- loadResultsTable(dataSource, dataSource$prefixTable(dataSource$databaseTable), required = TRUE)

if (nrow(databaseTable) > 0 &
"vocabularyVersion" %in% colnames(databaseTable)) {
databaseTable <- databaseTable %>%
Expand Down Expand Up @@ -475,7 +493,7 @@ cohortDiagnosticsServer <- function(id,
if ("includedSourceConcept" %in% dataSource$enabledReports)
selection["Concepts In Data Source"] <- "conceptsInDataSource"

if ("orphanConcepts" %in% dataSource$enabledReports)
if ("orphanConcept" %in% dataSource$enabledReports)
selection["Orphan Concepts"] <- "orphanConcepts"

if ("indexEventBreakdown" %in% dataSource$enabledReports)
Expand Down Expand Up @@ -603,6 +621,9 @@ cohortDiagnosticsServer <- function(id,
if (!hasData(targetCohortId())) {
return(NULL)
}
if (sum(c('cohortId','conceptSetName') %in% colnames(dataSource$conceptSets)) !=2) {
return(NULL)
}
dataSource$conceptSets %>%
dplyr::filter(.data$cohortId == targetCohortId()) %>%
dplyr::mutate(name = .data$conceptSetName) %>%
Expand Down Expand Up @@ -744,4 +765,4 @@ cohortDiagnosticsServer <- function(id,

)

}
}
Loading

0 comments on commit 4204fa9

Please sign in to comment.