diff --git a/LegendMedCentral/DataPulls.R b/LegendMedCentral/DataPulls.R index 18a066e8..b6b11c4a 100644 --- a/LegendMedCentral/DataPulls.R +++ b/LegendMedCentral/DataPulls.R @@ -33,7 +33,7 @@ getIndications <- function(connection) { } getSubgroups <- function(connection) { - sql <- "SELECT DISTINCT interaction_covariate_id AS subgroup_id, covariate_name AS subgroup_name + sql <- "SELECT DISTINCT interaction_covariate_id AS subgroup_id, covariate_name AS subgroup_name FROM ( SELECT DISTINCT interaction_covariate_id FROM cm_interaction_result @@ -57,7 +57,7 @@ getExposures <- function(connection, filterByCmResults = TRUE) { ON exposure.exposure_id = exposure_group.exposure_id {@filter_by_cm_results} ? { INNER JOIN exposure_ids - ON exposure_ids.exposure_id = exposure.exposure_id + ON exposure_ids.exposure_id = exposure.exposure_id } ;" sql <- SqlRender::renderSql(sql, filter_by_cm_results = filterByCmResults)$sql @@ -104,13 +104,13 @@ getDatabaseDetails <- function(connection, databaseId) { getIndicationForExposure <- function(connection, exposureIds = c()) { - sql <- "SELECT exposure_id, indication_id FROM single_exposure_of_interest WHERE" + sql <- "SELECT exposure_id, indication_id FROM single_exposure_of_interest WHERE" sql <- paste(sql, paste0("exposure_id IN (", paste(exposureIds, collapse = ", "), ")")) - + sql <- SqlRender::translateSql(sql, targetDialect = connection@dbms)$sql indications <- querySql(connection, sql) colnames(indications) <- SqlRender::snakeCaseToCamelCase(colnames(indications)) - return(indications) + return(indications) } getTcoDbs <- function(connection, @@ -118,8 +118,12 @@ getTcoDbs <- function(connection, comparatorIds = c(), outcomeIds = c(), databaseIds = c(), - operator = "AND") { + operator = "AND", + limit = 0) { sql <- "SELECT target_id, comparator_id, outcome_id, database_id FROM cohort_method_result WHERE analysis_id = 1" + if (limit != 0) { + sql <- gsub("SELECT target_id", sprintf("SELECT TOP %s target_id", limit), sql) + } parts <- c() if (length(targetIds) != 0) { parts <- c(parts, paste0("target_id IN (", paste(targetIds, collapse = ", "), ")")) @@ -140,6 +144,7 @@ getTcoDbs <- function(connection, sql <- paste(sql, "AND", paste(parts, collapse = " OR ")) } } + sql <- paste0(sql, ";") sql <- SqlRender::translateSql(sql, targetDialect = connection@dbms)$sql tcoDbs <- querySql(connection, sql) colnames(tcoDbs) <- SqlRender::snakeCaseToCamelCase(colnames(tcoDbs)) @@ -275,7 +280,7 @@ getSubgroupResults <- function(connection, if (length(subgroupIds) != 0) { parts <- c(parts, paste0("interaction_covariate_id IN (", paste(subgroupIds, collapse = ", "), ")")) } - + if (length(parts) != 0) { sql <- paste(sql, "WHERE", paste(parts, collapse = " AND ")) } diff --git a/LegendMedCentral/PlotsAndTables.R b/LegendMedCentral/PlotsAndTables.R index 216360e6..885986b3 100644 --- a/LegendMedCentral/PlotsAndTables.R +++ b/LegendMedCentral/PlotsAndTables.R @@ -37,18 +37,18 @@ createAbstract <- function(connection, tcoDb) { comparatorName <- uncapitalize(exposures$exposureName[match(tcoDb$comparatorId, exposures$exposureId)]) outcomeName <- uncapitalize(outcomes$outcomeName[match(tcoDb$outcomeId, outcomes$outcomeId)]) indicationId <- uncapitalize(exposures$indicationId[match(tcoDb$targetId, exposures$exposureId)]) - + results <- getMainResults(connection, targetIds = tcoDb$targetId, comparatorIds = tcoDb$comparatorId, outcomeIds = tcoDb$outcomeId, databaseIds = tcoDb$databaseId) - + studyPeriod <- getStudyPeriod(connection = connection, targetId = tcoDb$targetId, comparatorId = tcoDb$comparatorId, - databaseId = tcoDb$databaseId) - + databaseId = tcoDb$databaseId) + writeAbstract(outcomeName, targetName, comparatorName, tcoDb$databaseId, studyPeriod, results) } @@ -58,10 +58,10 @@ writeAbstract <- function(outcomeName, databaseId, studyPeriod, mainResults) { - + minYear <- substr(studyPeriod$minDate, 1, 4) maxYear <- substr(studyPeriod$maxDate, 1, 4) - + abstract <- paste0( "We conduct a large-scale study on the incidence of ", outcomeName, " among new users of ", targetName, " and ", comparatorName, " from ", minYear, " to ", maxYear, " in the ", databaseId, " database. ", "Outcomes of interest are estimates of the hazard ratio (HR) for incident events between comparable new users under on-treatment and intent-to-treat risk window assumptions. ", @@ -69,8 +69,8 @@ writeAbstract <- function(outcomeName, "We identify ", mainResults[1, "targetSubjects"], " ", targetName, " and ", mainResults[1, "comparatorSubjects"], " ", comparatorName, " patients for the on-treatment design, totaling ", round(mainResults[1, "targetDays"] / 365.24), " and ", round(mainResults[1, "comparatorDays"] / 365.24), " patient-years of observation, and ", mainResults[1, "targetOutcomes"], " and ", mainResults[1, "comparatorOutcomes"], " events respectively. ", "We control for measured confounding using propensity score trimming and stratification or matching based on an expansive propensity score model that includes all measured patient features before treatment initiation. ", "We account for unmeasured confounding using negative and positive controls to estimate and adjust for residual systematic bias in the study design and data source, providing calibrated confidence intervals and p-values. ", - "In terms of ", outcomeName, ", ", targetName, " has a ", judgeHazardRatio(mainResults[1, "calibratedCi95Lb"], mainResults[1, "calibratedCi95Ub"]), - " risk as compared to ", comparatorName, " [HR: ", prettyHr(mainResults[1, "calibratedRr"]), ", 95% confidence interval (CI) ", + "In terms of ", outcomeName, ", ", targetName, " has a ", judgeHazardRatio(mainResults[1, "calibratedCi95Lb"], mainResults[1, "calibratedCi95Ub"]), + " risk as compared to ", comparatorName, " [HR: ", prettyHr(mainResults[1, "calibratedRr"]), ", 95% confidence interval (CI) ", prettyHr(mainResults[1, "calibratedCi95Lb"]), " - ", prettyHr(mainResults[1, "calibratedCi95Ub"]), "]." ) @@ -169,7 +169,7 @@ prepareSubgroupTable <- function(subgroupResults, output = "latex") { rnd <- function(x) { ifelse(x > 10, sprintf("%.1f", x), sprintf("%.2f", x)) } - + subgroupResults$hrr <- paste0(rnd(subgroupResults$rrr), " (", rnd(subgroupResults$ci95Lb), @@ -182,8 +182,8 @@ prepareSubgroupTable <- function(subgroupResults, output = "latex") { subgroupResults$p[subgroupResults$p == "NA"] <- "" subgroupResults$calibratedP <- sprintf("%.2f", subgroupResults$calibratedP) subgroupResults$calibratedP[subgroupResults$calibratedP == "NA"] <- "" - - if (any(grepl("on-treatment", subgroupResults$analysisDescription)) && + + if (any(grepl("on-treatment", subgroupResults$analysisDescription)) && any(grepl("intent-to-treat", subgroupResults$analysisDescription))) { idx <- grepl("on-treatment", subgroupResults$analysisDescription) onTreatment <- subgroupResults[idx, c("interactionCovariateName", @@ -203,7 +203,7 @@ prepareSubgroupTable <- function(subgroupResults, output = "latex") { "hrr", "p", "calibratedP")] - } + } table$interactionCovariateName <- gsub("Subgroup: ", "", table$interactionCovariateName) if (output == "latex") { table$interactionCovariateName <- gsub(">=", "$\\\\ge$ ", table$interactionCovariateName) @@ -375,13 +375,13 @@ plotPs <- function(ps, targetName, comparatorName) { plotAllPs <- function(ps) { ps <- rbind(data.frame(targetName = ps$targetName, comparatorName = ps$comparatorName, - x = ps$preferenceScore, - y = ps$targetDensity, + x = ps$preferenceScore, + y = ps$targetDensity, group = "Target"), data.frame(targetName = ps$targetName, comparatorName = ps$comparatorName, - x = ps$preferenceScore, - y = ps$comparatorDensity, + x = ps$preferenceScore, + y = ps$comparatorDensity, group = "Comparator")) ps$group <- factor(ps$group, levels = c("Target", "Comparator")) plot <- ggplot2::ggplot(ps, ggplot2::aes(x = x, y = y, color = group, group = group, fill = group)) + @@ -422,7 +422,7 @@ plotCovariateBalanceScatterPlot <- function(balance, beforeLabel = "Before strat ggplot2::scale_x_continuous(beforeLabel, limits = limits) + ggplot2::scale_y_continuous(afterLabel, limits = limits) + ggplot2::theme(text = theme) - + return(plot) } @@ -631,16 +631,16 @@ plotScatter <- function(controlResults) { plotLargeScatter <- function(d, xLabel) { d$Significant <- d$ci95Lb > 1 | d$ci95Ub < 1 - + oneRow <- data.frame(nLabel = paste0(formatC(nrow(d), big.mark = ","), " estimates"), meanLabel = paste0(formatC(100 * mean(!d$Significant, na.rm = TRUE), digits = 1, format = "f"), "% of CIs includes 1")) - + breaks <- c(0.1, 0.25, 0.5, 1, 2, 4, 6, 8, 10) theme <- ggplot2::element_text(colour = "#000000", size = 12) themeRA <- ggplot2::element_text(colour = "#000000", size = 12, hjust = 1) themeLA <- ggplot2::element_text(colour = "#000000", size = 12, hjust = 0) - + alpha <- 1 - min(0.95 * (nrow(d)/50000)^0.1, 0.95) plot <- ggplot2::ggplot(d, ggplot2::aes(x = logRr, y = seLogRr)) + ggplot2::geom_vline(xintercept = log(breaks), colour = "#AAAAAA", lty = 1, size = 0.5) + @@ -879,6 +879,12 @@ uncapitalize <- function(x) { substr(y, 1, 1) <- tolower(substr(y, 1, 1)) y <- gsub("aCE", "ACE", y) y <- gsub("CCB)", "CCBs)", y) + y <- gsub("aAD", "AAD", y) + y <- gsub("a1B", "A1B", y) + y <- gsub("aRB", "ARB", y) + y <- gsub("dVs", "DVs", y) + y <- gsub("lDs", "LDs", y) + y <- gsub("tZs", "TZs", y) y }) result <- paste(terms, collapse = " and ") @@ -900,40 +906,40 @@ createDocument <- function(targetId, template = "template.Rnw", workingDirectory = "temp", emptyWorkingDirectory = TRUE) { - + if (missing(outputFile)) { stop("Must provide an output file name") } - + currentDirectory <- getwd() on.exit(setwd(currentDirectory)) - + input <- file(template, "r") - + name <- paste0("paper_", targetId, "_", comparatorId, "_", outcomeId, "_", databaseId) - + if (!dir.exists(workingDirectory)) { dir.create(workingDirectory) } - + workingDirectory <- file.path(workingDirectory, name) - + if (!dir.exists(workingDirectory)) { dir.create(workingDirectory) } - + if (is.null(setwd(workingDirectory))) { stop(paste0("Unable to change directory into: ", workingDirectory)) } - + system(paste0("cp ", file.path(currentDirectory, "pnas-new.cls"), " .")) system(paste0("cp ", file.path(currentDirectory, "widetext.sty"), " .")) system(paste0("cp ", file.path(currentDirectory, "pnasresearcharticle.sty"), " .")) system(paste0("cp ", file.path(currentDirectory, "Sweave.sty"), " .")) - + texName <- paste0(name, ".Rnw") output <- file(texName, "w") - + while (TRUE) { line <- readLines(input, n = 1) if (length(line) == 0) { @@ -949,25 +955,25 @@ createDocument <- function(targetId, } close(input) close(output) - + Sweave(texName) system(paste0("pdflatex ", name)) system(paste0("pdflatex ", name)) - + # Save result workingName <- file.path(workingDirectory, name) workingName <- paste0(workingName, ".pdf") - + setwd(currentDirectory) - + system(paste0("cp ", workingName, " ", outputFile)) - + if (emptyWorkingDirectory) { # deleteName = file.path(workingDirectory, "*") # system(paste0("rm ", deleteName)) unlink(workingDirectory, recursive = TRUE) } - + invisible(outputFile) } diff --git a/LegendMedCentral/global.R b/LegendMedCentral/global.R index 22779dcd..51502b14 100644 --- a/LegendMedCentral/global.R +++ b/LegendMedCentral/global.R @@ -13,10 +13,10 @@ connectionDetails <- createConnectionDetails(dbms = "postgresql", password = Sys.getenv("shinydbPw"), schema = Sys.getenv("shinydbSchema")) connection <- connect(connectionDetails) - +indications <- getIndications(connection) exposures <- getExposures(connection) -exposures$exposureName <- sapply(exposures$exposureName, uncapitalize) - +exposures$exposureGroup[exposures$exposureGroup == "Drug" | exposures$exposureGroup == "Procedure"] <- "Drug or procedure" +exposureGroups <- unique(exposures[, c("indicationId", "exposureGroup")]) outcomes <- getOutcomes(connection) databases <- getDatabases(connection) diff --git a/LegendMedCentral/server.R b/LegendMedCentral/server.R index ae04305e..09e9ae29 100644 --- a/LegendMedCentral/server.R +++ b/LegendMedCentral/server.R @@ -6,6 +6,8 @@ shinyServer(function(input, output, session) { connection <- DatabaseConnector::connect(connectionDetails) + currentChoices <- reactiveValues() + session$onSessionEnded(function() { writeLines("Closing connection") DatabaseConnector::disconnect(connection) @@ -13,9 +15,14 @@ shinyServer(function(input, output, session) { searchResults <- reactive({ query <- parseQueryString(session$clientData$url_search) - if (is.null(query$term)) { - return(NULL) - } else { + if (!is.null(query$structured)) { + targetIds <- exposures$exposureId[exposures$exposureName == query$target] + comparatorIds <- exposures$exposureId[exposures$exposureName == query$comparator] + outcomeIds <- outcomes$outcomeId[outcomes$outcomeName == query$outcome] + databaseIds <- databases$databaseId[databases$databaseId == query$database] + tcoDbs <- getTcoDbs(connection, targetIds = targetIds, comparatorIds = comparatorIds, outcomeIds = outcomeIds, databaseIds = databaseIds, limit = 100) + return(tcoDbs) + } else if (!is.null(query$term)) { parts <- strsplit(query$term, " ")[[1]] outcomeIds <- c() exposureIds <- c() @@ -31,7 +38,7 @@ shinyServer(function(input, output, session) { databaseIds <- c(databaseIds, match) } else { match <- outcomes$outcomeId[outcomeDist == min(outcomeDist)] - writeLines(paste("Matched", part, "to outcome ID", match)) + writeLines(paste("Matched", part, "to outcome", outcomes$outcomeName[outcomes$outcomeId == match])) outcomeIds <- c(outcomeIds, match) } } else { @@ -41,14 +48,20 @@ shinyServer(function(input, output, session) { databaseIds <- c(databaseIds, match) } else { match <- exposures$exposureId[exposureDist == min(exposureDist)] - writeLines(paste("Matched", part, "to exposure ID", match)) + writeLines(paste("Matched", part, "to exposure", exposures$exposureName[exposures$exposureId == match])) exposureIds <- c(exposureIds, match) } } } + if (length(outcomeIds) == 0) { + # Don't want negative or positive controls + outcomeIds <- outcomes$outcomeId + } tcoDbs <- getTcoDbsStrict(connection, exposureIds = exposureIds, outcomeIds = outcomeIds, databaseIds = databaseIds) return(tcoDbs) - } + } else { + return(NULL) + } }) selectedTcoDb <- reactive({ @@ -65,22 +78,15 @@ shinyServer(function(input, output, session) { } }) - # Maintain contents of search box: - observe({ - query <- parseQueryString(session$clientData$url_search) - if (!is.null(query$term)) - updateTextInput(session, "query", value = query$term) - }) - output$isSearchPage <- reactive({ query <- parseQueryString(session$clientData$url_search) - return(is.null(query$targetId) && is.null(query$term)) + return(is.null(query$targetId) && is.null(query$term) && is.null(query$structured)) }) outputOptions(output, "isSearchPage", suspendWhenHidden = FALSE) output$isSearchResultPage <- reactive({ query <- parseQueryString(session$clientData$url_search) - return(is.null(query$targetId) && !is.null(query$term)) + return(is.null(query$targetId) && (!is.null(query$term) || !is.null(query$structured))) }) outputOptions(output, "isSearchResultPage", suspendWhenHidden = FALSE) @@ -89,7 +95,107 @@ shinyServer(function(input, output, session) { return(!is.null(query$targetId)) }) outputOptions(output, "isAbstractPage", suspendWhenHidden = FALSE) + + # setExposureGroupChoices <- function(indicationId) { + # if (indicationId == "All") { + # filterExposureGroups <- unique(exposureGroups$exposureGroup) + # } else { + # filterExposureGroups <- unique(exposureGroups$exposureGroup[exposureGroups$indicationId == indicationId]) + # } + # if (is.null(currentChoices$exposureGroups) || !isTRUE(all.equal(currentChoices$exposureGroups, filterExposureGroups))) { + # currentChoices$exposureGroups <- filterExposureGroups + # writeLines(paste("Setting exposure groups to ", paste(filterExposureGroups, collapse = ", "))) + # updateSelectInput(session = session, + # inputId = "exposureGroup", + # choices = c("All", filterExposureGroups)) + # } + # } + + # setTcoChoices <- function(indicationId, exposureGroup) { + setTcoChoices <- function(exposureGroup) { + # if (indicationId == "All") { + filteredExposures <- exposures + filteredOutcomes <- outcomes + # } else { + # filteredExposures <- exposures[exposures$indicationId == indicationId, ] + # filteredOutcomes <- outcomes[outcomes$indicationId == indicationId, ] + # } + if (exposureGroup == "All") { + filteredExposures <- filteredExposures + } else { + filteredExposures <- filteredExposures[filteredExposures$exposureGroup == exposureGroup, ] + } + + if (is.null(currentChoices$exposures) || !isTRUE(all.equal(currentChoices$exposures, filteredExposures$exposureName))) { + # writeLines(paste("Setting target to ", paste(filteredExposures$exposureName, collapse = ", "), ", selection to", input$target)) + currentChoices$exposures <- filteredExposures$exposureName + updateSelectInput(session = session, + inputId = "target", + choices = c("All", unique(filteredExposures$exposureName))) + updateSelectInput(session = session, + inputId = "comparator", + choices = c("All", unique(filteredExposures$exposureName))) + } + if (is.null(currentChoices$outcomes) || currentChoices$outcomes != filteredOutcomes) { + currentChoices$outcomes <- filteredOutcomes + updateSelectInput(session = session, + inputId = "outcome", + choices = c("All", unique(filteredOutcomes$outcomeName))) + } + } + + # Maintain contents of search box: + observe({ + query <- parseQueryString(session$clientData$url_search) + isolate({ + if (!is.null(query$structured)) { + # print("Parsing query string") + updateRadioButtons(session = session, + inputId = "queryType", + selected = "Structured") + # updateSelectInput(session = session, + # inputId = "indication", + # selected = query$indication) + # setExposureGroupChoices(query$indication) + writeLines(paste("Setting exposure group selection to ", query$exposureGroup)) + updateSelectInput(session = session, + inputId = "exposureGroup", + selected = query$exposureGroup) + # setTcoChoices(query$indication, query$exposureGroup) + setTcoChoices(query$exposureGroup) + updateSelectInput(session = session, + inputId = "target", + selected = query$target) + updateSelectInput(session = session, + inputId = "comparator", + selected = query$comparator) + updateSelectInput(session = session, + inputId = "outcome", + selected = query$outcome) + updateSelectInput(session = session, + inputId = "database", + selected = query$database) + # print("Done parsing query string") + } else { + if (!is.null(query$term)) + updateTextInput(session, "query", value = query$term) + } + }) + }, priority = 0) + + # observe({ + # indicationId <- input$indication + # writeLines(paste("Indication has been set to", indicationId)) + # setExposureGroupChoices(indicationId) + # }) + observe({ + # indicationId <- input$indication + exposureGroup <- input$exposureGroup + # writeLines(paste("Indication has been set to", indicationId, ", exposure group selection has been set to", exposureGroup)) + # setTcoChoices(indicationId, exposureGroup) + setTcoChoices(exposureGroup) + }, priority = 10) output$searchResults <- renderDataTable({ tcoDbs <- searchResults() @@ -97,19 +203,43 @@ shinyServer(function(input, output, session) { return(NULL) } else { titles <- createTitle(tcoDbs) - titles <- paste0("", - titles, - "
LEGEND version 1.0, October 2018
") + if (input$queryType == "Free-text") { + titles <- paste0("", + titles, + "
LEGEND version 1.0, October 2018
") + } else { + titles <- paste0("", + titles, + "
LEGEND version 1.0, October 2018
") + } options <- list(pageLength = 15, searching = FALSE, lengthChange = TRUE, diff --git a/LegendMedCentral/ui.R b/LegendMedCentral/ui.R index 5e92a4f9..771a3f12 100644 --- a/LegendMedCentral/ui.R +++ b/LegendMedCentral/ui.R @@ -3,17 +3,37 @@ library(DT) source("widgets.R") shinyUI(fluidPage(style = "width:1000px;", - titlePanel(title=div(img(src="logo.png", height = 50, width = 50), - "LegendMed Central"), - windowTitle = "PubLegend Central"), - verticalLayout(div(style = "background-color: #AAAAAA;", tags$table(border = 0, width = "100%", tags$tr(tags$td(HTML(" ")), tags$td(textInput("query", label = "", placeholder = "Enter your search here", width = "100%")), tags$td(HTML(" ")), tags$td(align = "left", searchButton("searchButton", "Search", "query"))))), - conditionalPanel("output.isSearchResultPage == true", dataTableOutput("searchResults")), - conditionalPanel("output.isAbstractPage == true", - uiOutput("abstract"), - downloadLink("pdf", - label = paste("Generate and download report PDF") - ) - ) - ) + titlePanel(title = div(img(src = "logo.png", height = 50, width = 50), + "LegendMed Central"), + windowTitle = "PubLegend Central"), + verticalLayout( + div(style = "background-color: #CCCCCC; padding: 8px;", + radioButtons("queryType", label = NULL, choices = c("Free-text", "Structured"), inline = TRUE), + conditionalPanel("input.queryType == 'Free-text'", + textInput("query", label = "", placeholder = "Enter your search here", width = "100%"), + searchButton("textSearchButton", "Search", structured = FALSE) + ), + conditionalPanel("input.queryType == 'Structured'", + fluidRow( + # column(4, selectInput("indication", "Indication", c("All", indications$indicationId))), + column(4, selectInput("exposureGroup", "Exposure group", c("All", unique(exposureGroups$exposureGroup)))) + ), + fluidRow( + column(4, selectInput("target", "Target", c("All", unique(exposures$exposureName)))), + column(4, selectInput("comparator", "Comparator", c("All", unique(exposures$exposureName)))) + ), + selectInput("outcome", "Outcome", c("All", unique(outcomes$outcomeName))), + selectInput("database", "Database", c("All", databases$databaseId)), + searchButton("structuredSearchButton", "Search", structured = TRUE) + ) + ), + conditionalPanel("output.isSearchResultPage == true", dataTableOutput("searchResults")), + conditionalPanel("output.isAbstractPage == true", + uiOutput("abstract"), + downloadLink("pdf", + label = paste("Generate and download report PDF") + ) + ) ) - ) +) +) diff --git a/LegendMedCentral/widgets.R b/LegendMedCentral/widgets.R index 24ad53df..080f58ec 100644 --- a/LegendMedCentral/widgets.R +++ b/LegendMedCentral/widgets.R @@ -1,12 +1,28 @@ -searchButton <- function(inputId, label, queryInput, ...) { - script <- " - var link=document.createElement('a'); - link.id = 'searchLink'; - link.href='?term='+encodeURI(document.getElementById('%id%').value); - document.body.appendChild(link); - document.getElementById('searchLink').click(); - return false; - " - script <- gsub("%id%", queryInput, script) - tags$button(type = "button", onclick = script, label, ...) +searchButton <- function(inputId, label, structured) { + if (structured) { + script <- " + var link = document.createElement('a'); + link.id = 'searchLink'; + link.href = '?structured=true' + // link.href = link.href + '&indication=' + encodeURI(document.getElementById('indication').value); + link.href = link.href + '&exposureGroup=' + encodeURI(document.getElementById('exposureGroup').value); + link.href = link.href + '&target=' + encodeURI(document.getElementById('target').value); + link.href = link.href + '&comparator=' + encodeURI(document.getElementById('comparator').value); + link.href = link.href + '&outcome=' + encodeURI(document.getElementById('outcome').value); + link.href = link.href + '&database=' + encodeURI(document.getElementById('database').value); + document.body.appendChild(link); + document.getElementById('searchLink').click(); + return false; + " + } else { + script <- " + var link = document.createElement('a'); + link.id = 'searchLink'; + link.href = '?term=' + encodeURI(document.getElementById('query').value); + document.body.appendChild(link); + document.getElementById('searchLink').click(); + return false; + " + } + tags$button(type = "button", onclick = script, label) }