Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/getConceptsWithCodeCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ getConceptsWithCodeCounts <- function(
sql <- SqlRender::translate(sql, targetDialect = connection@dbms)
concepts <- DatabaseConnector::dbGetQuery(connection, sql) |>
tibble::as_tibble() |>
dplyr::mutate(standard_concept = dplyr::if_else(is.na(standard_concept), FALSE, TRUE))
dplyr::mutate(standard_concept = dplyr::if_else(is.na(standard_concept), FALSE, TRUE)) |>
dplyr::mutate(concept_id = as.double(concept_id))

return(concepts)
}
Expand Down
2 changes: 2 additions & 0 deletions inst/sql/sql_server/createCodeCountsTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ temp_concept_ancestor AS (
SELECT DISTINCT
maps_to_concept_id, calendar_year, gender_concept_id, age_decile, record_counts
FROM @resultsDatabaseSchema.@stratifiedCodeCountsTable
-- do not take if maps_to_concept_id is a standard concept
WHERE concept_id != maps_to_concept_id
)
GROUP BY
maps_to_concept_id
Expand Down
4 changes: 2 additions & 2 deletions inst/testdata/config/atlasDev_databasesConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ BQ5k:
bigint: integer64
tempEmulationSchema: atlas-development-270609.sandbox
cdm:
cdmDatabaseSchema: atlas-development-270609.etl_sam_r12_5k_omop
vocabularyDatabaseSchema: atlas-development-270609.etl_sam_r12_5k_omop
cdmDatabaseSchema: atlas-development-270609.finngen_omop_r13_v3_test
vocabularyDatabaseSchema: atlas-development-270609.finngen_omop_r13_v3_test
resultsDatabaseSchema: atlas-development-270609.sandbox
cohortTable:
cohortDatabaseSchema: atlas-development-270609.sandbox
Expand Down
Binary file modified inst/testdata/data/FinnGenR13_countsOnly.sqlite
Binary file not shown.
3 changes: 2 additions & 1 deletion inst/testdata/data/createTestingData.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ source("tests/testthat/setup.R")
conceptIds <- c(
317009, # Snomed: Asthma
45596282, # ICD10: Asthma
21601855 # ATC level 4: C10AA (Statins)
21601855, # ATC level 4: C10AA (Statins)
2010001615 # test endpoint
)

CDMdbHandler <- HadesExtras_createCDMdbHandlerFromList(test_cohortTableHandlerConfig, loadConnectionChecksLevel = "basicChecks")
Expand Down
5 changes: 4 additions & 1 deletion tests/testmanual/manualtest-timeplotview.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ conceptId <- 782748

conceptId <- 21602735

conceptId <- 2010001615 # test endpoint


results <- getCodeCounts(
CDMdbHandler,
conceptId = conceptId
conceptId = conceptId,
codeCountsTable = "code_counts"
)


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if (testingDatabase %in% c("AtlasDevelopment-DBI")) {
pathToYalmFile = system.file("testdata", "config", "atlasDev_databasesConfig.yml", package = "ROMOPAPI")
)

test_cohortTableHandlerConfig <- test_databasesConfig[[1]]$cohortTableHandler
test_cohortTableHandlerConfig <- test_databasesConfig[[2]]$cohortTableHandler
}


Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-createCodeCountsTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_that("createStratifiedCodeCountsTable works with duplicated counts", {
createStratifiedCodeCountsTable(CDMdbHandler, domains = domain, stratifiedCodeCountsTable = stratifiedCodeCountsTable)
)

stratifiedCodeCounts <- CDMdbHandler$connectionHandler$tbl(paste0(resultsDatabaseSchema, ".", stratifiedCodeCountsTable))
stratifiedCodeCounts <- CDMdbHandler$connectionHandler$tbl(I(paste0(resultsDatabaseSchema, ".", stratifiedCodeCountsTable)))

# check that the table was created
stratifiedCodeCounts |>
Expand Down Expand Up @@ -99,7 +99,7 @@ test_that("createCodeCountsTables works", {
# - Check if the table was created
resultsDatabaseSchema <- CDMdbHandler$resultsDatabaseSchema
cdmDatabaseSchema <- CDMdbHandler$cdmDatabaseSchema
code_counts <- CDMdbHandler$connectionHandler$tbl(paste0(resultsDatabaseSchema, ".", codeCountsTable))
code_counts <- CDMdbHandler$connectionHandler$tbl(I(paste0(resultsDatabaseSchema, ".", codeCountsTable)))

# check that the table was created with correct columns
code_counts |>
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-getConceptsWithCodeCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test_that("getConceptsWithCodeCounts works", {

# Check that all concept_ids are unique
result |>
dplyr::count(concept_id) |>
dplyr::count(concept_id, sort = TRUE) |>
dplyr::filter(n > 1) |>
nrow() |>
expect_equal(0)
Expand Down