Skip to content

Use external concept counts#1117

Open
cebarboza wants to merge 18 commits into
OHDSI:developfrom
mi-erasmusmc:useExternalConceptCounts
Open

Use external concept counts#1117
cebarboza wants to merge 18 commits into
OHDSI:developfrom
mi-erasmusmc:useExternalConceptCounts

Conversation

@cebarboza
Copy link
Copy Markdown
Collaborator

Hi,

I would like to submit this contribution related to #1067.

  • Export of externalConceptCounts() to create that table in the write schema.
  • useExternalConceptCountsTable parameter in runDiagnostics.
  • Changes to R/ConceptSets.R to useExternalConceptCountsTable when TRUE or create a new table as default when FALSE.
  • Changes inst/sql/sql_server/CreateConceptCountTable.sql to remove the ExternalConceptCountsTable if needed.

Please let me know what you think to see if we can work on this changes!

Copy link
Copy Markdown
Collaborator

@azimov azimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this could speed up the phenotyping process quite significantly - using Achilles counts as well somewhat conflicts with this branch. I think that is probably a better approach in general as users should be running this anyway as part of an ETL process.

However, I don't want to hold things up too much. This code should make it into the next release with a few minor changes suggested here.

Comment thread R/ConceptCountsTable.R Outdated
Comment thread R/ConceptCountsTable.R Outdated
Comment thread R/ConceptCountsTable.R
Comment thread R/ConceptCountsTable.R Outdated
Comment thread R/RunDiagnostics.R Outdated
Comment thread R/RunDiagnostics.R Outdated
Comment thread R/ConceptCountsTable.R Outdated
@cebarboza
Copy link
Copy Markdown
Collaborator Author

Hi!

I tried to cover most of the comments, please let me know if there is any more feedback. Especially for the testing. Thanks a lot, and sorry for the delay.

Comment thread R/RunDiagnostics.R
#' diagnostics to.
#' @param cohortDefinitionSet Data.frame of cohorts must include columns cohortId, cohortName, json, sql
#' @param cohortTableNames Cohort Table names used by CohortGenerator package
#' @param conceptCountsTable Concepts count table name. The default is "#concept_counts" to create a temporal concept counts table.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THese changes look good but you need to run devtools::document() (or the build in rstudio) to add the changes to include these parameters. Doing this should get the build to finish and I can then merge in your changes.

Copy link
Copy Markdown
Collaborator

@azimov azimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor changes:

  • The tests should be improved to run on all platforms, not just sqlite
  • The build fails because the new arguments are not documented yet with devtools::document

I can likely fix the latter one once merged in to develop. However, I would like tests to at least pass before doing this

Comment thread tests/testthat/test-other.R Outdated

# Creating externalConceptCounts
sql_lite_path <- file.path(test_path(), "4448testEunomia.sqlite")
connectionDetails <- createConnectionDetails(dbms= "sqlite", server = sql_lite_path)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't stope a test sqlite file - instead use Eunomia::getEunomiaConnectionDetails().

If to use a dataset that is not the standard MI data you can download it prior to running the tests:

https://ohdsi.github.io/Eunomia/reference/downloadEunomiaData.html

Comment thread tests/testthat/test-other.R Outdated
test_that("Creating and checking externalConceptCounts table", {

# Creating externalConceptCounts
sql_lite_path <- file.path(test_path(), "4448testEunomia.sqlite")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was not checked in, so tests fail. However, I would not like to add this file unless you have a specific use case for it (e.g. some specifically modified tables - but then I would prefer to see the sql that generates this as it will be easier to maintain).

Comment thread tests/testthat/test-other.R Outdated
conceptCountsTableIsTemp = FALSE,
removeCurrentTable = TRUE)

concept_counts_info <- querySql(connection, "PRAGMA table_info(concept_counts)")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command will only work on sqlite

expect_equal(result$a, c(1, 2, 3, 4, 5))
})

test_that("Creating and checking externalConceptCounts table", {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test will only run on sqlite. I would prefer tests across all database platforms. These are setup in the setup.R file for you:

https://github.com/OHDSI/CohortDiagnostics/blob/main/tests/testthat/setup.R

So you can just use the connectionDetails variable which should already be available to you.

For example see this test:

connectionDetails = connectionDetails,

@azimov azimov mentioned this pull request Aug 14, 2024
@ablack3 ablack3 closed this Sep 13, 2024
@ablack3 ablack3 reopened this Sep 17, 2024
@PRijnbeek
Copy link
Copy Markdown

What is the current status of this? is it added to an upcoming release? and if so when is this release planned (there are no due dates on the milestones in this package)?

@ablack3
Copy link
Copy Markdown
Collaborator

ablack3 commented Dec 2, 2024

What is the current status of this? is it added to an upcoming release? and if so when is this release planned (there are no due dates on the milestones in this package)?

Current status is that it will be included in the upcoming release. There are a few things left to do to get R check working.

It is part of the 3.4 release - https://github.com/OHDSI/CohortDiagnostics/milestone/3

There is no planned release date yet. @azimov should we set a release date for 3.4?

@azimov
Copy link
Copy Markdown
Collaborator

azimov commented Dec 2, 2024

What is the current status of this? is it added to an upcoming release? and if so when is this release planned (there are no due dates on the milestones in this package)?

Current status is that it will be included in the upcoming release. There are a few things left to do to get R check working.

It is part of the 3.4 release - https://github.com/OHDSI/CohortDiagnostics/milestone/3

There is no planned release date yet. @azimov should we set a release date for 3.4?

The other changes that are in the 3.4.0 are relatively small and shouldn't take long - we can set a date for a few weeks from now or whenever this PR is finished

@azimov
Copy link
Copy Markdown
Collaborator

azimov commented Mar 25, 2025

@ablack3 @cebarboza Any update on this PR? I would like to start testing 3.4.0 next week. If this can make it in it would be great, otherwise we can shelve this for a future date.

@ablack3
Copy link
Copy Markdown
Collaborator

ablack3 commented Mar 26, 2025

Hi @azimov, I'm looking at it now. Your request that we test the createConceptCounts table on all database systems will make the tests run longer. I made the change though so we can see how long it takes.

ablack3 added 2 commits March 26, 2025 13:03
Merge branch 'useExternalConceptCounts' of github.com:ohdsi/CohortDiagnostics into useExternalConceptCounts

# Conflicts:
#	tests/testthat/test-other.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants