Skip to content

Commit

Permalink
Update matchCohorts.R
Browse files Browse the repository at this point in the history
  • Loading branch information
catalamarti committed May 3, 2024
1 parent 2b0b6c6 commit c0b91c8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions R/matchCohorts.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ matchCohorts <- function(cohort,
# Delete controls that are not in observation
cli::cli_inform(c("*" = "Removing pairs that were not in observation at index date"))
cdm[[control]] <- observationControl(cdm[[control]])
cli::cli_inform(c("*" = "Excluding target"))
cdm[[target]] <- observationTarget(cdm, target, control)

# Check ratio
Expand Down Expand Up @@ -471,15 +472,15 @@ infiniteMatching <- function(cdm, target, control){
observationControl <- function(x) {
x |>
dplyr::select(-"cohort_start_date", -"cohort_end_date") |>
PatientProfiles::addInObservation(indexDate = "index_date") |>
dplyr::filter(.data$in_observation == 1) |>
dplyr::select(
"cohort_definition_id", "subject_id", "cohort_start_date" = "index_date",
"cluster_id"
) |>
dplyr::rename("cohort_start_date" = "index_date") |>
PatientProfiles::addFutureObservation(
futureObservationName = "cohort_end_date", futureObservationType = "date"
) |>
dplyr::filter(!is.na(.data$cohort_end_date)) |>
dplyr::select(
"cohort_definition_id", "subject_id", "cohort_start_date",
"cohort_end_date", "cluster_id"
) |>
dplyr::compute(name = tableName(x), temporary = FALSE) |>
omopgenerics::recordCohortAttrition(
reason = "Exclude individuals not in observation"
Expand Down

0 comments on commit c0b91c8

Please sign in to comment.