# NOT RUN {
# select medication class of interest and compute event durations
disp_data <- durcomp.dispensing[ID == 3 & grepl("J01EE01", ATC.CODE)]
presc_data <- durcomp.prescribing[ID == 3 & grepl("J01EE01", ATC.CODE)]
event_durations_list <- compute_event_durations(disp.data = disp_data,
presc.data = presc_data,
special.periods.data = durcomp.hospitalisation,
special.periods.method = "carryover",
ID.colname = "ID",
presc.date.colname = "DATE.PRESC",
disp.date.colname = "DATE.DISP",
date.format = "%Y-%m-%d",
medication.class.colnames = c("ATC.CODE",
"UNIT",
"FORM"),
total.dose.colname = "TOTAL.DOSE",
presc.daily.dose.colname = "DAILY.DOSE",
presc.duration.colname = "PRESC.DURATION",
visit.colname = "VISIT",
force.init.presc = TRUE,
force.presc.renew = TRUE,
split.on.dosage.change = TRUE,
trt.interruption = "carryover",
suppress.warnings = FALSE,
return.data.table = TRUE,
progress.bar = FALSE)
event_durations <- prune_event_durations(event_durations_list,
include = c("special periods"),
medication.class.colnames = "ATC.CODE",
days.within.out.date.1 = 7,
days.within.out.date.2 = 30,
keep.all = TRUE)
# cover special periods
special_periods <- event_durations_list$special_periods
event_durations_covered <- cover_special_periods(events.data = event_durations,
special.periods.data = special_periods,
ID.colname = "ID",
medication.class.colnames = "ATC.CODE",
disp.start.colname = "DISP.START",
duration.colname = "DURATION",
days.before = 7,
days.after = 7,
date.format = "%Y-%m-%d")
# }
Run the code above in your browser using DataLab