Skip to contents

Applies every eligibility criterion in the parsed study specification. Calls skeleton_eligible_combine() at the end to AND them into one eligible column.

Usage

tteplan_apply_exclusions(skeleton, spec, enrollment_spec)

Arguments

skeleton

A data.table skeleton (person-week panel).

spec

Parsed study specification from tteplan_read_spec().

enrollment_spec

Enrollment spec from the plan (must contain enrollment_id), as returned by plan[[i]].

Value

The skeleton (modified by reference), with eligibility columns added and a combined eligible column.

Details

The function applies five groups of criteria, in this order:

  • calendar years, from inclusion_criteria$isoyears

  • global inclusion criteria, from inclusion_criteria$criteria

  • enrollment-specific additional inclusion, such as an age range

  • global exclusion criteria

  • enrollment-specific additional exclusion criteria

A global inclusion criterion applies to every enrollment. It declares type: has_event, and an implementation block that names a source_variable and a window. It adds one eligible_has_<variable>_<window> column to the skeleton.

A washout declares implementation$type, a source_variable, a value and a window. All four rule blocks accept one. no_prior_value keeps a person-week when no prior week in the window holds value, and adds eligible_no_<variable>_<window>. only_prior_value keeps a person-week when every prior week in the window that holds an observation holds value, and adds eligible_only_<variable>_<window>. A prior week with no observation violates neither rule.