Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
cecicampanile committed Dec 17, 2024
1 parent 41a6886 commit 6948bca
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/summariseAllConceptCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ checkFeasibility <- function(omopTable, tableName, conceptId){
#' @param sex TRUE or FALSE. If TRUE code use will be summarised by sex.
#' @param ageGroup A list of ageGroup vectors of length two. Code use will be
#' thus summarised by age groups.
#' @param sample An integer to sample the tables to only that number of records.
#' If NULL no sample is done.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @return A summarised_result object with results overall and, if specified, by
Expand Down
2 changes: 2 additions & 0 deletions R/summariseClinicalRecords.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#' @param ageGroup A list of age groups to stratify results by.
#' @param sex Boolean variable. Whether to stratify by sex (TRUE) or not
#' (FALSE).
#' @param sample An integer to sample the tables to only that number of records.
#' If NULL no sample is done.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @return A summarised_result object.
Expand Down
2 changes: 2 additions & 0 deletions R/summariseConceptSetCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' @param sex TRUE or FALSE. If TRUE code use will be summarised by sex.
#' @param ageGroup A list of ageGroup vectors of length two. Code use will be
#' thus summarised by age groups.
#' @param sample An integer to sample the tables in the cdm object to only that number of records.
#' If NULL no sample is done.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @return A summarised_result object with results overall and, if specified, by
Expand Down
2 changes: 2 additions & 0 deletions R/summariseRecordCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#' @param sex Whether to stratify by sex (TRUE) or not (FALSE).
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @param sample An integer to sample the tables to only that number of records.
#' If NULL no sample is done.
#' @return A summarised_result object.
#' @export
#' @examples
Expand Down
4 changes: 4 additions & 0 deletions man/summariseAllConceptCounts.Rd

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

4 changes: 4 additions & 0 deletions man/summariseClinicalRecords.Rd

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

4 changes: 4 additions & 0 deletions man/summariseConceptSetCounts.Rd

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

4 changes: 4 additions & 0 deletions man/summariseRecordCount.Rd

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

14 changes: 14 additions & 0 deletions tests/testthat/test-summariseAllConceptCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ test_that("dateRange argument works", {
expect_equal(colnames(settings(y)), colnames(settings(x)))
PatientProfiles::mockDisconnect(cdm = cdm)
})
test_that("sample argument works", {
skip_on_cran()
# Load mock database ----
cdm <- cdmEunomia()

expect_no_error(x<-summariseAllConceptCounts(cdm,"drug_exposure", sample = 50))
expect_no_error(y<-summariseAllConceptCounts(cdm,"drug_exposure"))
n <- cdm$drug_exposure |>
dplyr::tally()|>
dplyr::pull(n)
expect_no_error(z<-summariseAllConceptCounts(cdm,"drug_exposure",sample = n))
expect_equal(y,z)
PatientProfiles::mockDisconnect(cdm = cdm)
})

test_that("tableAllConceptCounts() works", {
skip_on_cran()
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-summariseClinicalRecords.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,21 @@ test_that("dateRange argument works", {

})

test_that("sample argument works", {
skip_on_cran()
# Load mock database ----
cdm <- cdmEunomia()

expect_no_error(x<-summariseClinicalRecords(cdm,"drug_exposure", sample = 50))
expect_no_error(y<-summariseClinicalRecords(cdm,"drug_exposure"))
n <- cdm$drug_exposure |>
dplyr::tally()|>
dplyr::pull(n)
expect_no_error(z<-summariseClinicalRecords(cdm,"drug_exposure",sample = n))
expect_equal(y,z)
PatientProfiles::mockDisconnect(cdm = cdm)
})

test_that("tableClinicalRecords() works", {
skip_on_cran()
# Load mock database ----
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-summariseConceptSetCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -558,3 +558,19 @@ test_that("dateRange argument works", {
expect_equal(colnames(settings(z)), colnames(settings(x)))
PatientProfiles::mockDisconnect(cdm = cdm)
})


test_that("sample argument works", {
skip_on_cran()
# Load mock database ----
cdm <- cdmEunomia()

expect_no_error(x<-summariseConceptSetCounts(cdm,conceptSet = list("x" = c(40213260)), sample = 50))
expect_no_error(y<-summariseConceptSetCounts(cdm,conceptSet = list("x" = c(40213260))))
n <- cdm$drug_exposure |>
dplyr::tally()|>
dplyr::pull(n)
expect_no_error(z<-summariseConceptSetCounts(cdm,conceptSet = list("x" = c(40213260)),sample = n))
expect_equal(y,z)
PatientProfiles::mockDisconnect(cdm = cdm)
})
14 changes: 14 additions & 0 deletions tests/testthat/test-summariseRecordCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,17 @@ test_that("dateRnge argument works", {
})


test_that("sample argument works", {
skip_on_cran()
# Load mock database ----
cdm <- cdmEunomia()

expect_no_error(x<-summariseRecordCount(cdm,"drug_exposure", sample = 50))
expect_no_error(y<-summariseRecordCount(cdm,"drug_exposure"))
n <- cdm$drug_exposure |>
dplyr::tally()|>
dplyr::pull(n)
expect_no_error(z<-summariseRecordCount(cdm,"drug_exposure",sample = n))
expect_equal(y,z)
PatientProfiles::mockDisconnect(cdm = cdm)
})

0 comments on commit 6948bca

Please sign in to comment.