Skip to content

Commit

Permalink
database diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn committed Sep 28, 2024
1 parent 62352d6 commit 2c3e81c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Suggests:
DBI,
gt,
omock,
OmopSketch,
testthat (>= 3.0.0),
knitr,
RPostgres,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export("%>%")
export(codelistDiagnostics)
export(cohortDiagnostics)
export(cohortToPopulationDiagnostics)
export(databaseDiagnostics)
export(reportDiagnostics)
export(shinyDiagnostics)
importFrom(magrittr,"%>%")
Expand Down
15 changes: 15 additions & 0 deletions R/databaseDiagnostics.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


#' Database diagnostics
#'
#' @param cdm CDM reference
#'
#' @return
#' @export
#'
#' @examples
databaseDiagnostics <- function(cdm){

OmopSketch::summariseOmopSnapshot(cdm)

}
14 changes: 14 additions & 0 deletions man/databaseDiagnostics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tests/testthat/test-databaseDiagnostics.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test_that("multiplication works", {
cdm_local <- omock::mockCdmReference() |>
omock::mockPerson(nPerson = 100) |>
omock::mockObservationPeriod() |>
omock::mockConditionOccurrence() |>
omock::mockDrugExposure() |>
omock::mockObservation() |>
omock::mockMeasurement() |>
omock::mockCohort(name = "my_cohort", numberCohorts = 2)

db <- DBI::dbConnect(duckdb::duckdb())
cdm <- CDMConnector::copyCdmTo(con = db, cdm = cdm_local,
schema ="main", overwrite = TRUE)

db_diag <- databaseDiagnostics(cdm)
expect_no_error(OmopSketch::tableOmopSnapshot(db_diag))

CDMConnector::cdmDisconnect(cdm = cdm)

})

0 comments on commit 2c3e81c

Please sign in to comment.