diff --git a/DESCRIPTION b/DESCRIPTION index f3e5f67..55475b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,8 @@ Imports: SqlRender, stringr, stringdist, - tidyr + tidyr, + tidyselect Suggests: readr, remotes, diff --git a/NAMESPACE b/NAMESPACE index 9cffce1..b0614e4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,8 +9,10 @@ export(getConceptAncestor) export(getConceptDescendant) export(getConceptIdDetails) export(getConceptPrevalenceCounts) +export(getConceptRecordCount) export(getConceptRelationship) export(getConceptSynonym) +export(getCountOfSourceCodesMappedToStandardConcept) export(getDomain) export(getDrugIngredients) export(getExcludedConceptsInConceptSetExpression) diff --git a/R/FindOrphanConcepts.R b/R/FindOrphanConcepts.R index 8542cb1..ef4e65b 100644 --- a/R/FindOrphanConcepts.R +++ b/R/FindOrphanConcepts.R @@ -61,7 +61,7 @@ findOrphanConcepts <- function(connectionDetails = NULL, orphan_concept_table = paste0(tempTableName, "oo") ) DatabaseConnector::executeSql(connection, sql) - + sql <- "SELECT * FROM @orphan_concept_table;" orphanConcepts <- DatabaseConnector::renderTranslateQuerySql( diff --git a/R/GetConceptRecordCount.R b/R/GetConceptRecordCount.R new file mode 100644 index 0000000..1d27c95 --- /dev/null +++ b/R/GetConceptRecordCount.R @@ -0,0 +1,331 @@ +# Copyright 2022 Observational Health Data Sciences and Informatics +# +# This file is part of ConceptSetDiagnostics +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#' Given conceptId(s) get the record count. +#' +#' @description +#' Given conceptId(s) get the record count. +#' +#' @template Connection +#' +#' @template ConceptIds +#' +#' @template CdmDatabaseSchema +#' +#' @template VocabularyDatabaseSchema +#' +#' @template TempEmulationSchema +#' +#' @param minCellCount The minimum cell count for fields containing person/subject count. +#' +#' @return +#' Returns a tibble data frame. +#' +#' @export +# function: getConceptRecordCount ---- +getConceptRecordCount <- function(conceptIds, + connection = NULL, + connectionDetails = NULL, + cdmDatabaseSchema, + vocabularyDatabaseSchema = cdmDatabaseSchema, + tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), + minCellCount = 0) { + if (is.null(connection)) { + connection <- DatabaseConnector::connect(connectionDetails) + on.exit(DatabaseConnector::disconnect(connection)) + } + + tempTableName <- loadTempConceptTable( + conceptIds = conceptIds, + connection = connection, + tempEmulationSchema = tempEmulationSchema + ) + + domains <- + getDomainInformation(packageName = "ConceptSetDiagnostics") + domains <- domains$wide %>% + dplyr::filter(.data$isEraTable == FALSE) + # filtering out ERA tables because they are supposed to be derived tables, and counting them is double counting + + sqlDdlDrop <- + "DROP TABLE IF EXISTS @concept_count_temp;" + sqlDdlCreate <- " + CREATE TABLE @concept_count_temp ( + concept_id INT, + event_year INT, + event_month INT, + concept_is_standard VARCHAR(1), + concept_count BIGINT, + subject_count BIGINT + );" + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sqlDdlDrop, + tempEmulationSchema = tempEmulationSchema, + concept_count_temp = paste0(tempTableName, "cc"), + progressBar = FALSE, + reportOverallTime = FALSE + ) + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sqlDdlCreate, + tempEmulationSchema = tempEmulationSchema, + concept_count_temp = paste0(tempTableName, "cc"), + progressBar = FALSE, + reportOverallTime = FALSE + ) + # REASON for many SQL --DISTINCT subject_count cannot be computed from aggregation query of calendar month level data + sql1 <- "INSERT INTO @concept_count_temp + SELECT @domain_concept_id concept_id, + YEAR(@domain_start_date) event_year, + MONTH(@domain_start_date) event_month, + 'Y' concept_is_standard, + COUNT_BIG(*) concept_count, + COUNT_BIG(DISTINCT person_id) subject_count + FROM @cdm_database_schema.@domain_table dt + WHERE @domain_concept_id IN ( + SELECT DISTINCT concept_id + FROM @concept_id_universe + ) + AND YEAR(@domain_start_date) > 0 + AND @domain_concept_id > 0 + GROUP BY @domain_concept_id, + YEAR(@domain_start_date), + MONTH(@domain_start_date);" + sql2 <- " INSERT INTO @concept_count_temp + SELECT @domain_concept_id concept_id, + YEAR(@domain_start_date) event_year, + 0 AS event_month, + 'Y' concept_is_standard, + COUNT_BIG(*) concept_count, + COUNT_BIG(DISTINCT person_id) subject_count + FROM @cdm_database_schema.@domain_table + WHERE @domain_concept_id IN ( + SELECT DISTINCT concept_id + FROM @concept_id_universe + ) + AND YEAR(@domain_start_date) > 0 + AND @domain_concept_id > 0 + GROUP BY @domain_concept_id, + YEAR(@domain_start_date);" + sql3 <- "INSERT INTO @concept_count_temp + SELECT @domain_concept_id concept_id, + 0 as event_year, + 0 as event_month, + 'Y' concept_is_standard, + COUNT_BIG(*) concept_count, + COUNT_BIG(DISTINCT person_id) subject_count + FROM @cdm_database_schema.@domain_table dt + WHERE @domain_concept_id IN ( + SELECT DISTINCT concept_id + FROM @concept_id_universe + ) + AND YEAR(@domain_start_date) > 0 + AND @domain_concept_id > 0 + GROUP BY @domain_concept_id;" + + + sql4 <- "INSERT INTO @concept_count_temp + SELECT @domain_concept_id concept_id, + YEAR(@domain_start_date) event_year, + MONTH(@domain_start_date) event_month, + 'N' concept_is_standard, + COUNT_BIG(*) concept_count, + COUNT_BIG(DISTINCT person_id) subject_count + FROM @cdm_database_schema.@domain_table dt + LEFT JOIN ( + SELECT concept_id + FROM @vocabulary_database_schema.CONCEPT + WHERE standard_concept = 'S' + ) std + ON @domain_concept_id = std.concept_id + WHERE @domain_concept_id IN ( + SELECT DISTINCT concept_id + FROM @concept_id_universe + ) + AND YEAR(@domain_start_date) > 0 + AND @domain_concept_id > 0 + AND std.concept_id IS NULL + GROUP BY @domain_concept_id, + YEAR(@domain_start_date), + MONTH(@domain_start_date);" + sql5 <- " INSERT INTO @concept_count_temp + SELECT @domain_concept_id concept_id, + YEAR(@domain_start_date) event_year, + 0 AS event_month, + 'N' concept_is_standard, + COUNT_BIG(*) concept_count, + COUNT_BIG(DISTINCT person_id) subject_count + FROM @cdm_database_schema.@domain_table dt + LEFT JOIN ( + SELECT concept_id + FROM @vocabulary_database_schema.CONCEPT + WHERE standard_concept = 'S' + ) std ON @domain_concept_id = std.concept_id + WHERE @domain_concept_id IN ( + SELECT DISTINCT concept_id + FROM @concept_id_universe + ) + AND YEAR(@domain_start_date) > 0 + AND @domain_concept_id > 0 + AND std.concept_id IS NULL + GROUP BY @domain_concept_id, + YEAR(@domain_start_date);" + sql6 <- " INSERT INTO @concept_count_temp + SELECT @domain_concept_id concept_id, + 0 AS event_year, + 0 AS event_month, + 'N' concept_is_standard, + COUNT_BIG(*) concept_count, + COUNT_BIG(DISTINCT person_id) subject_count + FROM @cdm_database_schema.@domain_table dt + LEFT JOIN ( + SELECT concept_id + FROM @vocabulary_database_schema.CONCEPT + WHERE standard_concept = 'S' + ) std ON @domain_concept_id = std.concept_id + WHERE @domain_concept_id IN ( + SELECT DISTINCT concept_id + FROM @concept_id_universe + ) + AND YEAR(@domain_start_date) > 0 + AND @domain_concept_id > 0 + AND std.concept_id IS NULL + GROUP BY @domain_concept_id;" + + for (i in (1:nrow(domains))) { + rowData <- domains[i, ] + + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sql1, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainConceptId, + cdm_database_schema = cdmDatabaseSchema, + domain_start_date = rowData$domainStartDate, + concept_count_temp = paste0(tempTableName, "cc"), + concept_id_universe = tempTableName, + progressBar = FALSE, + reportOverallTime = FALSE + ) + + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sql2, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainConceptId, + cdm_database_schema = cdmDatabaseSchema, + domain_start_date = rowData$domainStartDate, + concept_count_temp = paste0(tempTableName, "cc"), + concept_id_universe = tempTableName, + progressBar = FALSE, + reportOverallTime = FALSE + ) + + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sql3, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainConceptId, + cdm_database_schema = cdmDatabaseSchema, + domain_start_date = rowData$domainStartDate, + concept_count_temp = paste0(tempTableName, "cc"), + concept_id_universe = tempTableName, + progressBar = FALSE, + reportOverallTime = FALSE + ) + } + + for (i in (1:nrow(domains))) { + rowData <- domains[i, ] + if (nchar(rowData$domainSourceConceptId) > 4) { + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sql4, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainSourceConceptId, + cdm_database_schema = cdmDatabaseSchema, + domain_start_date = rowData$domainStartDate, + concept_count_temp = paste0(tempTableName, "cc"), + concept_id_universe = tempTableName, + vocabulary_database_schema = vocabularyDatabaseSchema, + progressBar = FALSE, + reportOverallTime = FALSE + ) + + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sql5, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainSourceConceptId, + cdm_database_schema = cdmDatabaseSchema, + domain_start_date = rowData$domainStartDate, + concept_count_temp = paste0(tempTableName, "cc"), + concept_id_universe = tempTableName, + vocabulary_database_schema = vocabularyDatabaseSchema, + progressBar = FALSE, + reportOverallTime = FALSE + ) + + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sql6, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainSourceConceptId, + cdm_database_schema = cdmDatabaseSchema, + domain_start_date = rowData$domainStartDate, + concept_count_temp = paste0(tempTableName, "cc"), + concept_id_universe = tempTableName, + vocabulary_database_schema = vocabularyDatabaseSchema, + progressBar = FALSE, + reportOverallTime = FALSE + ) + } + } + retrieveSql <- "SELECT concept_id, event_year, event_month, + sum(concept_count) concept_count, + max(subject_count) subject_count + FROM @concept_count_temp c + GROUP BY concept_id, event_year, event_month + ORDER By concept_id, event_year, event_month;" + data <- renderTranslateQuerySql( + connection = connection, + sql = retrieveSql, + concept_count_temp = paste0(tempTableName, "cc"), + snakeCaseToCamelCase = TRUE + ) %>% + dplyr::tibble() %>% + dplyr::filter(.data$subjectCount > minCellCount) + + # i was thinking of keeping counts at the table level - but the file size became too big + # so i decided to not include them + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sqlDdlDrop, + tempEmulationSchema = tempEmulationSchema, + concept_count_temp = paste0(tempTableName, "cc"), + progressBar = FALSE, + reportOverallTime = FALSE + ) + return(data) +} diff --git a/R/GetCountOfSourceCodesMappedToStandardConcept.R b/R/GetCountOfSourceCodesMappedToStandardConcept.R new file mode 100644 index 0000000..6a267cc --- /dev/null +++ b/R/GetCountOfSourceCodesMappedToStandardConcept.R @@ -0,0 +1,170 @@ +# Copyright 2022 Observational Health Data Sciences and Informatics +# +# This file is part of ConceptSetDiagnostics +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#' Given conceptId(s) get the counts of occurrence with mapping. +#' +#' @description +#' Given conceptId(s) get the counts of occurrence with mapping. +#' +#' @template Connection +#' +#' @template ConceptIds +#' +#' @template CdmDatabaseSchema +#' +#' @template TempEmulationSchema +#' +#' @param minCellCount The minimum cell count for fields containing person/subject count. +#' +#' @return +#' Returns a tibble data frame. +#' +#' @export +# function: getCountOfSourceCodesMappedToStandardConcept ---- +getCountOfSourceCodesMappedToStandardConcept <- function(conceptIds, + connection = NULL, + connectionDetails = NULL, + cdmDatabaseSchema, + tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), + minCellCount = 0) { + if (is.null(connection)) { + connection <- DatabaseConnector::connect(connectionDetails) + on.exit(DatabaseConnector::disconnect(connection)) + } + + tempTableName <- loadTempConceptTable( + conceptIds = conceptIds, + connection = connection, + tempEmulationSchema = tempEmulationSchema + ) + + domains <- + getDomainInformation(packageName = "ConceptSetDiagnostics") + domains <- domains$wide %>% + dplyr::filter(nchar(.data$domainSourceConceptId) > 1) + + sqlConceptMapping <- + " DROP TABLE IF EXISTS @concept_mapping_table; + CREATE TABLE @concept_mapping_table (concept_id INT, + source_concept_id INT, + domain_table VARCHAR(20), + concept_count BIGINT, + subject_count BIGINT);" + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sqlConceptMapping, + tempEmulationSchema = tempEmulationSchema, + concept_mapping_table = paste0(tempTableName, "cc"), + progressBar = FALSE, + reportOverallTime = FALSE + ) + + sqlMapping <- " + INSERT INTO @concept_mapping_table + SELECT @domain_concept_id concept_id, + @domain_source_concept_id source_concept_id, + '@domainTableShort' domain_table, + COUNT(*) AS concept_count, + COUNT(DISTINCT person_id) AS subject_count + FROM @cdm_database_schema.@domain_table + WHERE + @domain_source_concept_id IS NOT NULL + AND @domain_source_concept_id > 0 + AND @domain_concept_id IN + (SELECT concept_id FROM @concept_id_table) + GROUP BY @domain_concept_id, + @domain_source_concept_id + ORDER BY @domain_concept_id, + @domain_source_concept_id;" + + conceptMapping <- list() + for (i in (1:nrow(domains))) { + rowData <- domains[i, ] + + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sqlMapping, + tempEmulationSchema = tempEmulationSchema, + domain_table = rowData$domainTable, + domain_concept_id = rowData$domainConceptId, + domain_source_concept_id = rowData$domainSourceConceptId, + cdm_database_schema = cdmDatabaseSchema, + concept_id_table = tempTableName, + concept_mapping_table = paste0(tempTableName, "cc"), + domainTableShort = rowData$domainTableShort, + reportOverallTime = FALSE, + progressBar = FALSE + ) + } + sql <- "SELECT DISTINCT * + FROM @concept_mapping_table + ORDER BY domain_table, + concept_id, + source_concept_id, + concept_count, + subject_count;" + conceptMapping <- + DatabaseConnector::renderTranslateQuerySql( + connection = connection, + sql = sql, + concept_mapping_table = paste0(tempTableName, "cc"), + snakeCaseToCamelCase = TRUE, + tempEmulationSchema = tempEmulationSchema + ) + conceptMapping <- conceptMapping %>% + dplyr::arrange( + .data$domainTable, + .data$conceptId, + .data$sourceConceptId, + .data$conceptCount, + .data$subjectCount + ) %>% + dplyr::tibble() + + if (nrow(conceptMapping) > 0) { + conceptMapping <- dplyr::bind_rows( + conceptMapping, + conceptMapping %>% + dplyr::group_by( + .data$conceptId, + .data$sourceConceptId + ) %>% + dplyr::summarise( + conceptCount = sum(.data$conceptCount), + subjectCount = max(.data$subjectCount), + .groups = "keep" + ) %>% + dplyr::mutate(domainTable = "All") + ) %>% + dplyr::distinct() + } + + conceptMapping <- conceptMapping %>% + dplyr::filter(.data$subjectCount > minCellCount) + + sqlDdlDrop <- + "DROP TABLE IF EXISTS @concept_mapping_table;" + DatabaseConnector::renderTranslateExecuteSql( + connection = connection, + sql = sqlDdlDrop, + concept_mapping_table = paste0(tempTableName, "cc"), + tempEmulationSchema = tempEmulationSchema, + progressBar = FALSE, + reportOverallTime = FALSE + ) + return(conceptMapping) +} diff --git a/R/Private.R b/R/Private.R index ca8f5d7..dd437ce 100644 --- a/R/Private.R +++ b/R/Private.R @@ -118,3 +118,168 @@ dropTempConceptTable <- concept_id_table = tempTableName ) } + + +#' Get domain information +#' +#' @param packageName e.g. 'CohortDiagnostics' +#' +#' @return +#' A list with two tibble data frame objects with domain information represented in wide and long format respectively. +getDomainInformation <- function(packageName = NULL) { + domains <- + readr::read_csv(system.file(file.path("csv", "domains.csv"), + package = "ConceptSetDiagnostics" + ), + col_types = readr::cols() + ) + + domains <- domains %>% + .replaceNaInDataFrameWithEmptyString() %>% + dplyr::mutate(domainTableShort = stringr::str_sub( + string = toupper(.data$domain), + start = 1, + end = 2 + )) %>% + dplyr::mutate( + domainTableShort = dplyr::case_when( + stringr::str_detect(string = tolower(.data$domain), pattern = "era") ~ paste0(.data$domainTableShort, "E"), + TRUE ~ .data$domainTableShort + ) + ) + + domains$domainConceptIdShort <- + stringr::str_replace_all( + string = sapply( + stringr::str_extract_all( + string = camelCaseToTitleCase(snakeCaseToCamelCase(domains$domainConceptId)), + pattern = "[A-Z]" + ), + paste, + collapse = " " + ), + pattern = " ", + replacement = "" + ) + domains$domainSourceConceptIdShort <- + stringr::str_replace_all( + string = sapply( + stringr::str_extract_all( + string = camelCaseToTitleCase(snakeCaseToCamelCase(domains$domainSourceConceptId)), + pattern = "[A-Z]" + ), + paste, + collapse = " " + ), + pattern = " ", + replacement = "" + ) + domains <- domains %>% + dplyr::mutate(isEraTable = stringr::str_detect( + string = .data$domainTable, + pattern = "era" + )) + data <- list() + data$wide <- domains + data$long <- dplyr::bind_rows( + data$wide %>% + dplyr::select( + .data$domainTableShort, + .data$domainTable, + .data$domainConceptIdShort, + .data$domainConceptId + ) %>% + dplyr::rename( + domainFieldShort = .data$domainConceptIdShort, + domainField = .data$domainConceptId + ), + data$wide %>% + dplyr::select( + .data$domainTableShort, + .data$domainSourceConceptIdShort, + .data$domainTable, + .data$domainSourceConceptId + ) %>% + dplyr::rename( + domainFieldShort = .data$domainSourceConceptIdShort, + domainField = .data$domainSourceConceptId + ) + ) %>% + dplyr::distinct() %>% + dplyr::filter(.data$domainFieldShort != "") %>% + dplyr::mutate(eraTable = stringr::str_detect( + string = .data$domainTable, + pattern = "era" + )) %>% + dplyr::mutate(isSourceField = stringr::str_detect( + string = .data$domainField, + pattern = "source" + )) + return(data) +} + +.replaceNaInDataFrameWithEmptyString <- function(data) { + # https://github.com/r-lib/tidyselect/issues/201 + data %>% + dplyr::collect() %>% + dplyr::mutate(dplyr::across( + tidyselect:::where(is.character), + ~ tidyr::replace_na(.x, as.character("")) + )) %>% + dplyr::mutate(dplyr::across( + tidyselect:::where(is.logical), + ~ tidyr::replace_na(.x, as.character("")) + )) %>% + dplyr::mutate(dplyr::across( + tidyselect:::where(is.numeric), + ~ tidyr::replace_na(.x, as.numeric("")) + )) +} + + +# private function - not exported +camelCaseToTitleCase <- function(string) { + string <- gsub("([A-Z])", " \\1", string) + string <- gsub("([a-z])([0-9])", "\\1 \\2", string) + substr(string, 1, 1) <- toupper(substr(string, 1, 1)) + return(string) +} + +# private function - not exported +snakeCaseToCamelCase <- function(string) { + string <- tolower(string) + for (letter in letters) { + string <- + gsub(paste("_", letter, sep = ""), toupper(letter), string) + } + string <- gsub("_([0-9])", "\\1", string) + return(string) +} + +# private function - not exported +camelCaseToSnakeCase <- function(string) { + string <- gsub("([A-Z])", "_\\1", string) + string <- tolower(string) + string <- gsub("([a-z])([0-9])", "\\1_\\2", string) + return(string) +} + +# private function - not exported +titleCaseToCamelCase <- function(string) { + string <- stringr::str_replace_all( + string = string, + pattern = " ", + replacement = "" + ) + substr(string, 1, 1) <- tolower(substr(string, 1, 1)) + return(string) +} + +# private function - not exported +quoteLiterals <- function(x) { + if (is.null(x)) { + return("") + } else { + return(paste0("'", paste(x, collapse = "', '"), "'")) + } +} diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 96731be..eac562e 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,5 +2,5 @@ pandoc: 2.17.1.1 pkgdown: 2.0.6 pkgdown_sha: ~ articles: {} -last_built: 2022-07-22T02:24Z +last_built: 2022-07-22T22:11Z diff --git a/docs/reference/getConceptRecordCount.html b/docs/reference/getConceptRecordCount.html new file mode 100644 index 0000000..795baa7 --- /dev/null +++ b/docs/reference/getConceptRecordCount.html @@ -0,0 +1,128 @@ + +
getConceptRecordCount.Rd
Given conceptId(s) get the record count.
+getConceptRecordCount(
+ conceptIds,
+ connection = NULL,
+ connectionDetails = NULL,
+ cdmDatabaseSchema,
+ vocabularyDatabaseSchema = cdmDatabaseSchema,
+ tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"),
+ minCellCount = 0
+)
An array of Concept ids.
An object of type connection
as created using the
+connect
function in the
+DatabaseConnector package. Can be left NULL if connectionDetails
+is provided, in which case a new connection will be opened at the start
+of the function, and closed when the function finishes.
An object of type connectionDetails
as created using the
+createConnectionDetails
function in the
+DatabaseConnector package. Can be left NULL if connection
is
+provided.
Schema name where your patient-level data in OMOP CDM format resides. +Note that for SQL Server, this should include both the database and +schema name, for example 'cdm_data.dbo'.
The schema name of containing the vocabulary tables.
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp +tables, provide a schema with write privileges where temp tables can be created.
The minimum cell count for fields containing person/subject count.
Returns a tibble data frame.
+getCountOfSourceCodesMappedToStandardConcept.Rd
Given conceptId(s) get the counts of occurrence with mapping.
+getCountOfSourceCodesMappedToStandardConcept(
+ conceptIds,
+ connection = NULL,
+ connectionDetails = NULL,
+ cdmDatabaseSchema,
+ tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"),
+ minCellCount = 0
+)
An array of Concept ids.
An object of type connection
as created using the
+connect
function in the
+DatabaseConnector package. Can be left NULL if connectionDetails
+is provided, in which case a new connection will be opened at the start
+of the function, and closed when the function finishes.
An object of type connectionDetails
as created using the
+createConnectionDetails
function in the
+DatabaseConnector package. Can be left NULL if connection
is
+provided.
Schema name where your patient-level data in OMOP CDM format resides. +Note that for SQL Server, this should include both the database and +schema name, for example 'cdm_data.dbo'.
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp +tables, provide a schema with write privileges where temp tables can be created.
The minimum cell count for fields containing person/subject count.
Returns a tibble data frame.
+getDomainInformation.Rd
Get domain information
+getDomainInformation(packageName = NULL)
e.g. 'CohortDiagnostics'
A list with two tibble data frame objects with domain information represented in wide and long format respectively.
+getConceptPrevalenceCounts()
get concept id count
Given conceptId(s) get the record count.
getConceptSynonym()
given a list of conceptIds, get their synonyms
Given conceptId(s) get the counts of occurrence with mapping.
Get all the domain id(s) in the vocabulary schema.
Get domain information