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
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
Binary file modified inst/testdata/data/FinnGenR13_countsOnly.sqlite
Binary file not shown.
31 changes: 29 additions & 2 deletions 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)
320136 # Disorder of respiratory …# big
)

CDMdbHandler <- HadesExtras_createCDMdbHandlerFromList(test_cohortTableHandlerConfig, loadConnectionChecksLevel = "basicChecks")
Expand All @@ -17,7 +18,6 @@ helper_createSqliteDatabaseFromDatabase(
pathToSqliteDatabase = "inst/testdata/data/FinnGenR13_countsOnly.sqlite"
)


# Test
connection <- DatabaseConnector::connect(DatabaseConnector::createConnectionDetails(dbms = "sqlite", server = "inst/testdata/data/FinnGenR13_countsOnly.sqlite"))

Expand All @@ -30,6 +30,13 @@ dplyr::tbl(connection, "concept") |>
dplyr::pull(n) |>
expect_gt(0)

dplyr::tbl(connection, "concept") |>
dplyr::count(concept_id) |>
dplyr::filter(n > 1) |>
dplyr::count() |>
dplyr::pull(n) |>
expect_equal(0)

dplyr::tbl(connection, "concept_ancestor") |>
dplyr::count() |>
dplyr::pull(n) |>
Expand All @@ -40,7 +47,27 @@ dplyr::tbl(connection, "code_counts") |>
dplyr::pull(n) |>
expect_gt(0)

dplyr::tbl(connection, "code_counts") |>
dplyr::count(concept_id) |>
dplyr::filter(n > 1) |>
dplyr::count() |>
dplyr::pull(n) |>
expect_equal(0)


dplyr::tbl(connection, "stratified_code_counts") |>
dplyr::count() |>
dplyr::pull(n) |>
expect_gt(0)


#
Sys.setenv(HADESEXTAS_TESTING_ENVIRONMENT = "OnlyCounts-FinnGen")
source("tests/testthat/setup.R")

CDMdbHandler <- HadesExtras_createCDMdbHandlerFromList(test_cohortTableHandlerConfig, loadConnectionChecksLevel = "basicChecks")

conceptId <- 317009

report.html <- createReport(conceptId, CDMdbHandler, showsMappings = FALSE)
browseURL(report.html)
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
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