ddediu / AdhereR

Computation of adherence to medications from Electronic Healthcare Data in R
26 stars 6 forks source link

Remove redundant arguments in cover_special_periods #198

Closed jowendl closed 1 year ago

jowendl commented 1 year ago

According to the name and their description the arguments "disp.date.colname" ("A string, the name of the column in events.data containing the dispensation start date (in the format given in the date.format parameter).") and "disp.start.colname" seem to be the same, but both have to be defined when calling the function. This leads to an error message.

The example code of the corresponding help file does not work because of this bug.

thank you

Masswear commented 1 year ago

Thanks for raising this issue. Although the arguments disp.date.colname and disp.start.colname can be identical, they are not the same. While disp.date.colname refers to the original dispensing date in the dispensing dataset, disp.start.colname might differ from the former in case of dosage changes, treatment interruptions or special periods of type carryover. For CMA versions accounting for carryover, there will be no difference between the two choices, as long as the events take place within the observation period. If an event start gets pushed out of the observation period (e.g., because of carryover during a special period), this will affect CMA calculation. Generally, it is appropriate to use DISP.START as input for CMA calculations.

To use cover_special_periods, both disp.date.colname and disp.start.colname need to be defined, as well as episode.start.colname and episode.end.colname. The function description and example code in the corresponding help file is not accurate in this regard and will be updated during an upcoming release.

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", disp.date.colname = "DATE.DISP", episode.start.colname = "episode.start", episode.end.colname = "episode.end", duration.colname = "DURATION", days.before = 7, days.after = 7, date.format = "%Y-%m-%d")