Closed Masswear closed 5 years ago
I guess that means that I have to call your code? If so, could you pls give me skeleton example that I can expand on?
No, it means that the user should be able to override the internal calculation of episodes with compute_internal_gaps
by providing episode start- and end dates per patient per medication class. Either as separate variable in the dataset or as separate dataset.
I've been looking at this: currently, the episodes do not explicitly care about medication class (i.e., only a change in medication class might trigger a new episode), so what I propose is:
In CMA_per_episode()
if you pass me an extra argument treat.episodes
of type data.frame
and structure:
patid
the patient IDepisode.ID
the episode unique ID (increasing sequentially)episode.start
the episode start dateend.episode.gap.days
the corresponding gap days of the last event in this episodeepisode.duration
the episode duration in daysepisode.end
the episode end date(i.e., in the same format as compute.treatment.episodes()
would have returned), I can use it internally instead of calling compute.treatment.episodes()
.
Would this work for you?
In principle yes, but the data.frame
structure would ideally look like this:
patid
the patient IDepisode.ID
the episode unique ID (increasing sequentially)medication.class
the medication class for which this episode is validepisode.start
the episode start dateepisode.end
the episode end dateThis would reflect the situation in clinical practice, where medications are prescribed for specific durations, but durations don't need to be the same for each medication.
end.episode.gap.days
is not known before CMA calculation and episode.duration
is redundant when episode.start
and episode.end
are given.
Users can now specify the parameter treat.epi
for CMA_per_episode
, in the form of a data.frame
containing the treatment episodes. It must contain the patient ID (as given in ID.colname
), the episode unique ID (increasing sequentially, episode.ID
), the episode start date (episode.start
), the episode duration in days (episode.duration
), and the episode end date (episode.end
).
If treat.epi
is specified, it overrides the default computation of treatment episodes by gap days. The medication.class
column is not required because CMA_per_episode
should only be used for single treatments. This option would make sense for a polypharmacy version of the function.
As an alternative to calculating CMA_per_episode based on gap lenght, give option to provide episode start and end dates as arguments, e.g.: