| compute_event_durations {AdhereR} | R Documentation |
Computation of event durations.
Description
Computes event durations based on dispensing, prescription, and other data (e.g.
hospitalization data) and returns a data.frame which can be used with the
CMA constructors in AdhereR.
Usage
compute_event_durations(
disp.data = NULL,
presc.data = NULL,
special.periods.data = NULL,
ID.colname,
medication.class.colnames,
disp.date.colname,
total.dose.colname,
presc.date.colname,
presc.daily.dose.colname,
presc.duration.colname,
visit.colname,
split.on.dosage.change = TRUE,
force.init.presc = FALSE,
force.presc.renew = FALSE,
trt.interruption = c("continue", "discard", "carryover")[1],
special.periods.method = trt.interruption,
carryover = FALSE,
date.format = "%d.%m.%Y",
suppress.warnings = FALSE,
return.data.table = FALSE,
progress.bar = TRUE,
...
)
Arguments
disp.data |
A |
presc.data |
A |
special.periods.data |
Optional, |
ID.colname |
A string, the name of the column in |
medication.class.colnames |
A |
disp.date.colname |
A string, the name of the column in
|
total.dose.colname |
A string, the name of the column in
|
presc.date.colname |
A string, the name of the column in
|
presc.daily.dose.colname |
A string, the name of the column in
|
presc.duration.colname |
A string, the name of the column in
|
visit.colname |
A string, the name of the column in
|
split.on.dosage.change |
Logical or string. If |
force.init.presc |
Logical. If |
force.presc.renew |
Logical or string. If |
trt.interruption |
can be either of "continue", "discard",
"carryover", or a string. It indicates how to handle durations during
treatment interruptions (see |
special.periods.method |
can be either of continue, discard,
carryover, or custom. It indicates how to handle durations during special periods.
With continue, special periods have no effect on durations and event start dates.
With discard, durations are truncated at the beginning of special periods and the
remaining quantity is discarded. With carryover, durations are truncated
at the beginning of a special period and a new event with the remaining duration
is created after the end of the end of the special period. With custom, the
mapping has to be included in |
carryover |
Logical, if |
date.format |
A string giving the format of the dates used in
the |
suppress.warnings |
Logical, if |
return.data.table |
Logical, if |
progress.bar |
Logical, if |
... |
other possible parameters. |
Details
Computation of CMAs requires a supply duration for medications dispensed to patients. If medications are not supplied for fixed durations but as a quantity that may last for various durations based on the prescribed dose, the supply duration has to be calculated based on dispensed and prescribed doses. Treatments may be interrupted and resumed at later times, for which existing supplies may or may not be taken into account. Patients may be hospitalized or incarcerated, and may not use their own supplies during these periods. This function calculates supply durations, taking into account the aforementioned situations and providing various parameters for flexible adjustments.
Value
A list with the following elements:
-
event_durations: Adata.tableordata.framewith the following columns:-
ID.colnamethe unique patient ID, as given by theID.colnameparameter. -
medication.class.colnamesthe column(s) with classes/types/groups of medication, as given by themedication.class.colnamesparameter. -
disp.date.colnamethe date of the dispensing event, as given by thedisp.date.colnemaparameter. -
total.dose.colnamethe total dispensed dose, as given by thetotal.dose.colnameparameter. -
presc.daily.dose.colnamethe prescribed daily dose, as given by thepresc.daily.dose.colnameparameter. -
DISP.STARTthe start date of the dispensing event, either the same as indisp.date.colnameor a later date in case of dosage changes or treatment interruptions/hospitalizations. -
DURATIONthe calculated duration of the supply, based on the total dispensed dose and the prescribed daily dose, starting from theDISP.STARTdate. -
episode.start: the start date of the current prescription episode. -
episode.end: the end date of the current prescription episode. Can be before the start date of the dispensing event if dispensed during a treatment interruption. -
SPECIAL.DURATIONthe number of days during the current duration affected by special durations or treatment interruptions of type "continue". -
CARRYOVER.DURATIONthe number of days after the current duration affected by special durations or treatment interruptions of type "carryover". -
EVENT.ID: in case of multiple events with the same dispensing date (e.g. for dosage changes or interruptions); a unique ID starting at 1 for the first event -
tot.presc.interruptionsthe total number of prescription interruptions per patient for a specific medication. -
tot.dosage.changesthe total number of dosage changes per patient for a specific medication.
-
-
prescription_episodes: Adata.tableordata.framewith the following columns:-
ID.colname: the unique patient ID, as given by theID.colnameparameter. -
medication.class.colnames: the column(s) with classes/types/groups of medication, as given by themedication.class.colnamesparameter. -
presc.daily.dose.colname: the prescribed daily dose, as given by thepresc.daily.dose.colnameparameter. -
episode.start: the start date of the prescription episode. -
episode.duration: the duration of the prescription episode in days. -
episode.end: the end date of the prescription episode.
-
-
special_periods: Adata.tableordata.frame, thespecial.periods.datawith an additional columnSPECIAL.DURATION: the number of days betweenDATE.INandDATE.OUT -
ID.colnamethe name of the columns containing the unique patient ID, as given by theID.colnameparameter. -
medication.class.colnamesthe name(s) of the column(s) indisp.dataandpresc.datacontaining the classes/types/groups of medication, as given by themedication.class.colnamesparameter. -
disp.date.colnamethe name of the column indisp.datacontaining the dispensing date, as given in thedisp.date.colnameparameter. -
total.dose.colnamethe name of the column indisp.datacontaining the total dispensed dose, as given by thetotal.dose.colnameparameter. -
presc.date.colnamethe name of the column inpresc.datacontaining the prescription date, as given in thepresc.date.colnameparameter. -
presc.daily.dose.colnamethe name of the column inpresc.datacontaining the daily prescribed dose, as given by thepresc.daily.dose.colnameparameter. -
presc.duration.colnamethe name of the column inpresc.datacontaining the duration of the prescription, as given by thepresc.duration.colnameparameter. -
visit.colnamethe name of the column containing the number of the visit, as given by thevisit.colnameparameter -
split.on.dosage.changewhether to split the dispensing event on days with dosage changes and create a new event with the new dosage for the remaining supply, as given by thesplit.on.dosage.changeparameter. -
force.init.prescwhether the date of the first prescription event was set back to the date of the first dispensing event, when the first prescription event was after the first dispensing event for a specific medication, as given by theforce.init.prescparameter. -
force.presc.renewwhether a new prescription was required for all medications for every prescription event (visit), as given by theforce.presc.renewparameter. -
trt.interruptionhow durations during treatment interruptions were handled, as given by thetrt.interruptionparameter. -
special.periods.methodas given by thespecial.periods.methodparameter. -
date.formatthe format of the dates, as given by thedate.formatparameter.
Examples
## Not run:
event_durations <- compute_event_durations(disp.data = durcomp.dispensing,
presc.data = durcomp.prescribing,
special.periods.data = durcomp.hospitalisation,
ID.colname = "ID",
presc.date.colname = "DATE.PRESC",
disp.date.colname = "DATE.DISP",
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",
split.on.dosage.change = TRUE,
force.init.presc = TRUE,
force.presc.renew = TRUE,
trt.interruption = "continue",
special.periods.method = "continue",
date.format = "%Y-%m-%d",
suppress.warnings = FALSE,
return.data.table = TRUE);
## End(Not run)