Require at most N occurrences of a query within a window

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

Arguments

x

Maximum integer count of allowed 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")
# At most 1 T2DM diagnosis before index
atMost(1, conditionOccurrence(t2dm), duringInterval(eventStarts(-365, 0)))
#> An object of class "Criteria"
#> Slot "occurrence":
#> An object of class "Occurrence"
#> Slot "type":
#> [1] "atMost"
#> 
#> Slot "count":
#> [1] 1
#> 
#> 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] 365
#> 
#> 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
#> 
#>