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: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ROMOPMappingTools
Title: Tools for Working with OMOP CDM Mappings
Version: 2.0.4
Version: 2.1.0
Authors@R:
person("Javier", "Gracia-Tabuenca", , "javier.graciatabuenca@tuni.fi", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-2455-0598"))
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ROMOPMappingTools 2.1.0

- Fixed concept_ancestor table generation. ICD10fi hierarchy was not correct, and duplicated rows were present in the table.
- Added DRUG_STRENGTH table generation. This was missing, and created warnings in the DQD validation.
- Fixed errors due to DatabaseConnector v7.0.0.

# ROMOPMappingTools 2.0.5

- Fixed a bug in Usagi to STCM table conversion with respect to source parents
Expand Down
2 changes: 1 addition & 1 deletion R/appendUsagiFileToSTCMtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ appendUsagiFileToSTCMtable <- function(
#

# check if the sourceToConceptMapTable exists
listTables <- DBI::dbListTables(connection, vocabularyDatabaseSchema)
listTables <- DatabaseConnector::getTableNames(connection, vocabularyDatabaseSchema)
if (!sourceToConceptMapTable %in% listTables) {
stop(paste0("The sourceToConceptMapTable ", sourceToConceptMapTable, " does not exist in the vocabularyDatabaseSchema ", vocabularyDatabaseSchema))
}
Expand Down
4 changes: 2 additions & 2 deletions R/databasesFromAndToCSV.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ omopVocabularyCSVsToDuckDB <- function(
"CONCEPT_RELATIONSHIP",
"CONCEPT_SYNONYM",
"DOMAIN",
# "DRUG_STRENGTH", TEMP: loading makes error, leave out at the moment
"DRUG_STRENGTH",
"RELATIONSHIP",
"VOCABULARY"
)
Expand Down Expand Up @@ -113,7 +113,7 @@ duckdbToOMOPVocabularyCSVs <- function(
OMOPVocabularyTableNames |>
stringr::str_to_lower() |>
checkmate::assertSubset(
DatabaseConnector::dbListTables(connection)
DatabaseConnector::getTableNames(connection)
)

pathToOMOPVocabularyCSVsFolder |> checkmate::assertDirectoryExists()
Expand Down
2 changes: 1 addition & 1 deletion R/updateUsagiFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ updateUsagiFile <- function(
# Check if required tables exist
# tables <- DatabaseConnector::getTableNames(condlnection, vocabularyDatabaseSchema)
# TEMP untill solved https://github.com/OHDSI/DatabaseConnector/issues/299
tableNames <- DatabaseConnector::dbListTables(connection, vocabularyDatabaseSchema)
tableNames <- DatabaseConnector::getTableNames(connection, vocabularyDatabaseSchema)
c("concept", "concept_relationship", "domain") |>
checkmate::assertSubset(tableNames)

Expand Down
2 changes: 1 addition & 1 deletion R/validateCDMtablesWithDQD.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ validateCDMtablesWithDQD <- function(connectionDetails, vocabularyDatabaseSchema
validationResultsFolder |> checkmate::assertDirectory()

connection <- DatabaseConnector::connect(connectionDetails)
tableNames <- DatabaseConnector::dbListTables(connection, vocabularyDatabaseSchema)
tableNames <- DatabaseConnector::getTableNames(connection, vocabularyDatabaseSchema)
DatabaseConnector::disconnect(connection)

OMOPVocabularyTableNames <- c(
Expand Down
2 changes: 1 addition & 1 deletion R/validateUsagiFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ validateUsagiFile <- function(
# Check if required tables exist
# tables <- DatabaseConnector::getTableNames(condlnection, vocabularyDatabaseSchema)
# TEMP untill solved https://github.com/OHDSI/DatabaseConnector/issues/299
tableNames <- DatabaseConnector::dbListTables(connection, vocabularyDatabaseSchema)
tableNames <- DatabaseConnector::getTableNames(connection, vocabularyDatabaseSchema)
c("concept", "concept_relationship", "domain") |>
checkmate::assertSubset(tableNames)

Expand Down
9 changes: 7 additions & 2 deletions inst/sql/sql_server/CONCEPT_RELATIONSHIPToANCESTOR.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ WITH RECURSIVE ancestor_cte AS (
FROM #relationships
) AS r
)
SELECT DISTINCT *
FROM ancestor_cte_self_reference;
SELECT
ancestor_concept_id,
descendant_concept_id,
MIN(min_levels_of_separation) as min_levels_of_separation,
MAX(max_levels_of_separation) as max_levels_of_separation
FROM ancestor_cte_self_reference
GROUP BY ancestor_concept_id, descendant_concept_id;


-- 4- Remove the temporary table
Expand Down
2 changes: 1 addition & 1 deletion inst/testdata/VOCABULARIES/ICD10fi/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# ICD10fi v1.0.0

- Brought from old FinOMOP "Tietoriihi" GitLab with some minor fixes.
- Mappings of 12 of the codes fixed in 2023-03.
- Mappings of 12 of the codes fixed in 2023-03.
14 changes: 7 additions & 7 deletions tests/testthat/test-appendUsagiFileToSTCMTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_that("test appendUsagiFileToSTCMTable appends the usagi file to the sourceT
expect_equal(nrowUsagiFile)

stcmTable |>
dplyr::filter(TARGET_CONCEPT_ID != 0L) |>
dplyr::filter(target_concept_id != 0L) |>
dplyr::count() |> dplyr::pull(n) |>
expect_equal(nrowUsagiFileMapped)

Expand Down Expand Up @@ -71,7 +71,7 @@ test_that("test appendUsagiFileToSTCMTable appends the usagi file to the sourceT
expect_equal(nrowUsagiFile)

stcmTable |>
dplyr::filter(TARGET_CONCEPT_ID != 0L) |>
dplyr::filter(target_concept_id != 0L) |>
dplyr::count() |> dplyr::pull(n) |>
expect_equal(nrowUsagiFileMapped)

Expand All @@ -84,7 +84,7 @@ test_that("test appendUsagiFileToSTCMTable appends the usagi file to the sourceT
"source_domain", "source_parents_concept_ids"))

stcmTable |>
dplyr::filter(is.na(SOURCE_PARENTS_CONCEPT_IDS)) |>
dplyr::filter(is.na(source_parents_concept_ids)) |>
nrow() |>
expect_equal(0)

Expand Down Expand Up @@ -119,14 +119,14 @@ test_that("test appendUsagiFileToSTCMTable appends the ICD10fi usagi file to the

# For source code C18.62 the parent concept IDs should be ICD10 code C18.6 with concept_id 45552246
stcmTable |>
dplyr::filter(SOURCE_CODE == "C18.62") |>
dplyr::pull(SOURCE_PARENTS_CONCEPT_IDS) |>
dplyr::filter(source_code == "C18.62") |>
dplyr::pull(source_parents_concept_ids) |>
expect_equal("45552246")

# For source code Y94.1 the parent concept IDs should be ICD10fi code Y94 with concept_id 2000503727
stcmTable |>
dplyr::filter(SOURCE_CODE == "Y94.1") |>
dplyr::pull(SOURCE_PARENTS_CONCEPT_IDS) |>
dplyr::filter(source_code == "Y94.1") |>
dplyr::pull(source_parents_concept_ids) |>
expect_equal("2000503725")

})
8 changes: 8 additions & 0 deletions tests/testthat/test-conceptRelationshipToAncestorTables.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ test_that("conceptRelationshipToAncestorTables creates CONCEPT_ANCESTOR table fr
dplyr::pull(n) |>
expect_equal(c(1,8,16))


# check ancestor_concept_id and descendant_concept_id are unique
ancestor |>
dplyr::distinct(ancestor_concept_id, descendant_concept_id) |>
nrow() |>
expect_equal(ancestor |> nrow())


})
Loading