Require exactly N occurrences of a query within a window

exactly(
  x,
  query,
  aperture = duringInterval(eventStarts(-Inf, Inf)),
  distinct = NA,
  countColumn = NA_character_
)

Arguments

x

Integer count of required occurrences.

query

A Query object (e.g. from conditionOccurrence()).

aperture

An EventAperture built with duringInterval. Defaults to all time.

distinct

If TRUE, count distinct values of countColumn.

countColumn

Column to use for distinct counting (e.g. "DOMAIN_CONCEPT").

Value

A Criteria object for use in withAll, withAny, etc.

Examples

t2dm <- cs(descendants(201826L), name = "T2DM")
# No prior T2DM diagnosis at any time before index
exactly(0, conditionOccurrence(t2dm), duringInterval(eventStarts(-Inf, 0)))
#> An object of class "Criteria"
#> Slot "occurrence":
#> An object of class "Occurrence"
#> Slot "type":
#> [1] "exactly"
#> 
#> Slot "count":
#> [1] 0
#> 
#> Slot "isDistinct":
#> [1] NA
#> 
#> Slot "countColumn":
#> [1] NA
#> 
#> 
#> Slot "query":
#> <Capr ConditionOccurrence Query> T2DM 
#> 
#> Slot "aperture":
#> An object of class "EventAperture"
#> Slot "startWindow":
#> An object of class "EventWindow"
#> Slot "event":
#> [1] "start"
#> 
#> Slot "start":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] Inf
#> 
#> Slot "coeff":
#> [1] -1
#> 
#> 
#> Slot "end":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] 0
#> 
#> Slot "coeff":
#> [1] -1
#> 
#> 
#> Slot "index":
#> [1] "startDate"
#> 
#> 
#> Slot "endWindow":
#> An object of class "EventWindow"
#> Slot "event":
#> [1] NA
#> 
#> Slot "start":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] NA
#> 
#> Slot "coeff":
#> [1] NA
#> 
#> 
#> Slot "end":
#> An object of class "Endpoint"
#> Slot "days":
#> [1] NA
#> 
#> Slot "coeff":
#> [1] NA
#> 
#> 
#> Slot "index":
#> [1] NA
#> 
#> 
#> Slot "restrictVisit":
#> [1] FALSE
#> 
#> Slot "ignoreObservationPeriod":
#> [1] FALSE
#> 
#>