Compare characteristics of cohort matched to database population
matchedDiagnostics.Rd
A summary of the cohort that is matched to the original cohort that has been given by the user. Such summary contains basic cohort summary including number of visits within one year prior of the cohort_start_date, as well as a large scale charactersitics using the following domians of OMOP CDM:
* condition_occurrence * visit_occurrence * measurement * procedure_occurrence * observation * drug_exposure
Examples
# \donttest{
cdm_local <- omock::mockCdmReference() |>
omock::mockPerson(nPerson = 100) |>
omock::mockObservationPeriod() |>
omock::mockConditionOccurrence() |>
omock::mockDrugExposure() |>
omock::mockObservation() |>
omock::mockMeasurement() |>
omock::mockCohort(name = "my_cohort")
cdm_local$visit_occurrence <- dplyr::tibble(
person_id = 1L,
visit_occurrence_id = 1L,
visit_concept_id = 1L,
visit_start_date = as.Date("2000-01-01"),
visit_end_date = as.Date("2000-01-01"),
visit_type_concept_id = 1L)
cdm_local$procedure_occurrence <- dplyr::tibble(
person_id = 1L,
procedure_occurrence_id = 1L,
procedure_concept_id = 1L,
procedure_date = as.Date("2000-01-01"),
procedure_type_concept_id = 1L)
db <- DBI::dbConnect(duckdb::duckdb())
cdm <- CDMConnector::copyCdmTo(con = db,
cdm = cdm_local,
schema ="main",
overwrite = TRUE)
result <- cdm$my_cohort |> matchedDiagnostics()
#> • Taking 1000 person sample of cohorts
#> • Generating a age and sex matched cohorts
#> Starting matching
#> Warning: Multiple records per person detected. The matchCohorts() function is designed
#> to operate under the assumption that there is only one record per person within
#> each cohort. If this assumption is not met, each record will be treated
#> independently. As a result, the same individual may be matched multiple times,
#> leading to inconsistent and potentially misleading results.
#> ℹ Creating copy of target cohort.
#> • 1 cohort to be matched.
#> ℹ Creating controls cohorts.
#> ℹ Excluding cases from controls
#> • Matching by gender_concept_id and year_of_birth
#> • Removing controls that were not in observation at index date
#> • Excluding target records whose pair is not in observation
#> • Adjusting ratio
#> Binding cohorts
#> ✔ Done
#> ℹ adding demographics columns
#> ℹ adding tableIntersectCount 1/1
#> ℹ summarising data
#> ✔ summariseCharacteristics finished!
#> • Running large scale characterisation
#> ℹ Summarising large scale characteristics
#>
#> - getting characteristics from table condition_occurrence (1 of 6)
#> - getting characteristics from table visit_occurrence (2 of 6)
#> - getting characteristics from table measurement (3 of 6)
#> - getting characteristics from table procedure_occurrence (4 of 6)
#> - getting characteristics from table observation (5 of 6)
#> - getting characteristics from table drug_exposure (6 of 6)
CDMConnector::cdm_disconnect(cdm)
# }