Updates a cohort by applying a new query.

cb_apply_query(cohort, query, keep_query = TRUE)

Arguments

cohort

A cohort object. (Required) See constructor function cb_create_cohort or cb_load_cohort

query

A phenotype query defined using the phenotype function and logic operators (see example below)

keep_query

If True, combines the newly supplied query with the pre-existing query. Otherwise, pre-existing query is overwritten. (Default: TRUE)

Value

The updated cohort object.

Examples

if (FALSE) {
A <- phenotype(id = 13, from = "2016-01-21", to = "2017-02-13")
B <- phenotype(id = 4, value = "Cancer")

A_not_B <- A & !B

my_cohort <- cb_load_cohort(cohort_id = "612f37a57673ed0ddeaf1333", cb_version = "v2")

my_cohort <- cb_apply_query(my_cohort, query = A_not_B, keep_query = F)
}