Combine events with overlapping start/end dates.

stockpile_events(events, states = NULL, gap = 1L, id_var = "patient_id")

Arguments

events

Event file

states

Events of interest in the data. If NULL, assume all events are of interest.

gap

Gap (in days) to apply in prescriptions of the same type. Useful when the gap should only apply to link together identical states (if the allowable gap is to be applied universally, can be added to end prior to using the function)

id_var

Group identifier in the data. Default is patient_id