Skip to content

Commit

Permalink
Merge pull request #332 from OHDSI/matching_names
Browse files Browse the repository at this point in the history
new names
  • Loading branch information
edward-burn authored Sep 25, 2024
2 parents ff25b25 + cffe30d commit d68f826
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion R/matchCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ matchCohorts <- function(cohort,
) |>
dplyr::left_join(
settings(cdm[[target]]) |>
dplyr::mutate(
"cohort_name" = paste0(.data$cohort_name, "_matched")) |>
dplyr::select("cohort_definition_id", "target_cohort_name" = "cohort_name"),
by = "cohort_definition_id"
) |>
Expand All @@ -149,6 +151,8 @@ matchCohorts <- function(cohort,
omopgenerics::newCohortTable(
cohortSetRef = settings(cdm[[target]]) |>
dplyr::select("cohort_definition_id", "cohort_name") |>
dplyr::mutate(
"cohort_name" = paste0(.data$cohort_name, "_matched")) |>
dplyr::mutate(
"target_table_name" = omopgenerics::tableName(cohort),
"target_cohort_id" = .data$cohort_definition_id,
Expand Down Expand Up @@ -208,7 +212,7 @@ getNewCohort <- function(cohort, cohortId, control) {
dplyr::relocate(dplyr::all_of(omopgenerics::cohortColumns("cohort"))) |>
omopgenerics::newCohortTable(
cohortSetRef = settings(cohort) |>
dplyr::mutate("cohort_name" = paste0(.data$cohort_name, "_matched")),
dplyr::mutate("cohort_name" = paste0("matched_to_", .data$cohort_name)),
cohortAttritionRef = dplyr::tibble(
"cohort_definition_id" = as.integer(cohortId),
"number_records" = controls |> dplyr::tally() |> dplyr::pull() |> as.integer(),
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-matchCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ test_that("test exactMatchingCohort with a ratio bigger than 1", {
cdm[["new_cohort"]] %>%
cohortCount() |>
dplyr::filter(.data$cohort_definition_id %in% omopgenerics::getCohortId(
cdm$new_cohort, "cohort_1"
cdm$new_cohort, "cohort_1_matched"
)) %>%
dplyr::pull("number_subjects") |>
sum() == 2
Expand All @@ -245,7 +245,7 @@ test_that("test exactMatchingCohort with a ratio bigger than 1", {
cdm[["new_cohort"]] %>%
cohortCount() |>
dplyr::filter(.data$cohort_definition_id %in% omopgenerics::getCohortId(
cdm$new_cohort, "cohort_1_matched"
cdm$new_cohort, "matched_to_cohort_1"
)) %>%
dplyr::pull("number_subjects") |>
sum() == 8
Expand All @@ -254,7 +254,7 @@ test_that("test exactMatchingCohort with a ratio bigger than 1", {
cdm[["new_cohort"]] %>%
cohortCount() |>
dplyr::filter(.data$cohort_definition_id %in% omopgenerics::getCohortId(
cdm$new_cohort, "cohort_2"
cdm$new_cohort, "cohort_2_matched"
)) %>%
dplyr::pull("number_subjects") |>
sum() == 2
Expand All @@ -263,7 +263,7 @@ test_that("test exactMatchingCohort with a ratio bigger than 1", {
cdm[["new_cohort"]] %>%
cohortCount() |>
dplyr::filter(.data$cohort_definition_id %in% omopgenerics::getCohortId(
cdm$new_cohort, "cohort_2_matched"
cdm$new_cohort, "matched_to_cohort_2"
)) %>%
dplyr::pull("number_subjects") |>
sum() == 8
Expand Down

0 comments on commit d68f826

Please sign in to comment.