AdhereR
AdhereR copied to clipboard
Encapsulate settings for default argument values and overrides based on CMA
For CMA_per_episode and CMA_sliding_windows (and most likely CMA_polypharmacy), the code for CMA-specific arguments is duplicated. This makes maintenance harder and can be a risk if new CMAs with specific default arguments are added.
A generic function that returns a list of arguments based on CMA , e.g.
# function that generates CMA-specific arguments
default.arguments <- function(CMA.to.apply){
if( CMA.to.apply %in% c("CMA1", "CMA2", "CMA3", "CMA4") )
{ default.arguments <- list(carry.only.for.same.medication = FALSE, ...) }
...
return(default.arguments)
}
# generate CMA-specific arguments
params <- default.arguments(CMA.to.apply)
# call CMA.to.apply with the CMA-specific arguments
CMA <- do.call(CMA.to.apply, c(list(data = DATA), params))
good idea: will do