@@ -105,6 +105,7 @@ mod_clinical_timelines_server <- function(module_id,
105105 filter = NULL ,
106106 subjid_var = " USUBJID" ,
107107 start_day = NULL ,
108+ color_palette = NULL ,
108109 ms = 1000 ,
109110 receiver_id = NULL ,
110111 afmm_param = NULL ) {
@@ -137,7 +138,13 @@ mod_clinical_timelines_server <- function(module_id,
137138 checkmate :: assert_list(drug_admin , types = " character" , null.ok = TRUE , add = ac )
138139 checkmate :: assert_subset(
139140 names(drug_admin ),
140- choices = c(" dataset_name" , " start_var" , " end_var" , " detail_var" , " label" , " dose_var" , " dose_unit_var" ),
141+ choices = c(
142+ " dataset_name" ,
143+ " trt_var" ,
144+ " start_var" , " end_var" ,
145+ " detail_var" , " label" ,
146+ " dose_var" , " dose_unit_var"
147+ ),
141148 add = ac
142149 )
143150 checkmate :: assert_list(filter , types = " list" , null.ok = TRUE , add = ac )
@@ -153,7 +160,10 @@ mod_clinical_timelines_server <- function(module_id,
153160 checkmate :: assert_numeric(ms , len = 1 , add = ac )
154161 checkmate :: assert_string(receiver_id , min.chars = 1 , null.ok = TRUE , add = ac )
155162 checkmate :: assert_list(afmm_param , null.ok = TRUE , add = ac )
163+ checkmate :: assert_character(color_palette , null.ok = TRUE , add = ac )
164+ checkmate :: assert_character(names(color_palette ), null.ok = TRUE , unique = TRUE , add = ac )
156165 checkmate :: reportAssertions(ac )
166+ check_valid_color(color_palette )
157167
158168 shiny :: moduleServer(
159169 module_id ,
@@ -201,7 +211,9 @@ mod_clinical_timelines_server <- function(module_id,
201211
202212 # Set a fixed color for each group
203213 colors_groups <- shiny :: reactive({
204- if (nrow(pre_data()) > 0 ) color_lookup(unique(pre_data()$ group ))
214+ if (nrow(pre_data()) > 0 ) {
215+ color_lookup(unique(pre_data()$ group ), color_palette )
216+ }
205217 })
206218
207219 # Add adverse event data that are relevant for filtering
@@ -239,7 +251,7 @@ mod_clinical_timelines_server <- function(module_id,
239251 type = " message"
240252 )
241253 } else if (! is.null(receiver_id )) {
242- afmm_param $ utils $ switch2( afmm_param $ module_names [[ receiver_id ]] )
254+ afmm_param $ utils $ switch2mod( receiver_id )
243255 }
244256 })
245257
@@ -294,7 +306,11 @@ mod_clinical_timelines_server <- function(module_id,
294306# ' (defaults to NULL, using the day of the earliest event to be displayed),
295307# ' \code{boxheight_val} contains a value between 30 and 150 defining the initial height of
296308# ' the individual timeline plot boxes at app launch (defaults to 60).
309+ # ' @param color_palette `[character(1+) | NULL]`
297310# '
311+ # ' A named vector that specifies the colors for drawing events or intervals.
312+ # ' Each name in the vector should correspond to an entry in the legend.
313+ # ' If \code{NULL} (default), the default color palette is used.
298314# ' @param ms `[numeric(1)]`
299315# '
300316# ' Single numeric value indicating how many milliseconds to wait before the plot
@@ -377,19 +393,22 @@ mod_clinical_timelines_server <- function(module_id,
377393# ' \item{\code{dataset_name}: Character name of the dataset that holds drug administration data
378394# ' (e.g. ex domain), as it is called in the datalist that is provided to the
379395# ' \pkg{modulemanager}.}
396+ # ' \item{\code{trt_var}: Character name of the variable that contains the
397+ # ' treatment name which must be present in the dataset mentioned in the
398+ # ' \code{dataset_name} element.}
380399# ' \item{\code{start_var}: Character name of the variable that contains the start dates
381400# ' (e.g. exposure start dates) which must be present in the dataset mentioned in the
382- # ' \code{name } element.}
401+ # ' \code{dataset_name } element.}
383402# ' \item{\code{end_var}: Character name of the variable that contains the end dates
384403# ' (e.g. exposure end dates) which must be present in the dataset mentioned in the
385- # ' \code{name } element.}
404+ # ' \code{dataset_name } element.}
386405# ' \item{\code{detail_var}: Character name of the variable that contains the treatment
387- # ' information. Must exist in the dataset mentioned in the \code{name } element.}
406+ # ' information. Must exist in the dataset mentioned in the \code{dataset_name } element.}
388407# ' \item{\code{label}: Free-text character label for the drug administration event.}
389408# ' \item{\code{dose_var}: Character name of the variable that contains the dosis level
390- # ' information. Must exist in the dataset mentioned in the \code{name } element.}
409+ # ' information. Must exist in the dataset mentioned in the \code{dataset_name } element.}
391410# ' \item{\code{dose_unit_var}: Character name of the variable that contains the dosis
392- # ' unit. Must exist in the dataset mentioned in the \code{name } element.}
411+ # ' unit. Must exist in the dataset mentioned in the \code{dataset_name } element.}
393412# ' }
394413# '
395414# ' \cr
@@ -443,6 +462,7 @@ mod_clinical_timelines <- function(module_id,
443462 start_day = NULL ,
444463 boxheight_val = 60
445464 ),
465+ color_palette = NULL ,
446466 ms = 1000 ,
447467 receiver_id = NULL ) {
448468 # Check validity of arguments that won't be checked in UI/server
@@ -481,6 +501,7 @@ mod_clinical_timelines <- function(module_id,
481501 filter = filter ,
482502 subjid_var = subjid_var ,
483503 start_day = default_plot_settings $ start_day ,
504+ color_palette = color_palette ,
484505 ms = ms ,
485506 receiver_id = receiver_id ,
486507 afmm_param = list (utils = afmm $ utils , module_names = afmm $ module_names )
0 commit comments