diff --git a/R/ae_listing.R b/R/ae_listing.R index 7e8355b..715ce6e 100644 --- a/R/ae_listing.R +++ b/R/ae_listing.R @@ -106,14 +106,14 @@ format_ae_listing <- function(outdata, display_unique_records = FALSE) { new_name <- c("SITEID", "SITENUM", "USUBJID", "SUBJID", "SEX", "RACE", "AGE", obs_group, "EPOCH", "ASTDY", par_var, "ADURN", "AESEV", "AESER", "AEREL", "AREL", "AEACN", - "AEOUT", "AEDOSDUR") - name_mapping <- c("Site_Number", "Site_Number", "Participant_ID", "Participant_ID", "Gender", "Race", "Age", "Treatment_Group", "Onset_Epoch", + "AEOUT", "AEDOSDUR", "ATOXGRN") + name_mapping <- c("Site_Number", "Site_Number", "Unique_Participant_ID", "Participant_ID", "Gender", "Race", "Age", "Treatment_Group", "Onset_Epoch", "Relative_Day_of_Onset", "Adverse_Event", "Duration", "Intensity", "Serious", "Related", "Related", "Action_Taken", - "Outcome", "Total_Dose_on_Day_of_AE_Onset") + "Outcome", "Total_Dose_on_Day_of_AE_Onset", "Maximum_Toxicity_Grade") names(name_mapping) <- new_name - res_columns <- lapply(toupper(names(res)), function(x) { - if (x %in% names(name_mapping)) {name_mapping[[x]]} + res_columns <- lapply(names(res), function(x) { + if (toupper(x) %in% names(name_mapping)) {name_mapping[[toupper(x)]]} else {x} }) |> unlist() @@ -128,7 +128,7 @@ format_ae_listing <- function(outdata, display_unique_records = FALSE) { # Participant ID if ("USUBJID" %in% toupper(names(res))) { - res$Participant_ID <- res$USUBJID + res$Unique_Participant_ID <- res$USUBJID } if ("SUBJID" %in% toupper(names(res))) { res$Participant_ID <- res$SUBJID @@ -140,6 +140,7 @@ format_ae_listing <- function(outdata, display_unique_records = FALSE) { res$Race <- tools::toTitleCase(tolower(res$RACE)) res$Age <- res$AGE + res$Treatment_Group <- res[[obs_group]] attr(res$Treatment_Group, "label") <- NULL @@ -176,6 +177,11 @@ format_ae_listing <- function(outdata, display_unique_records = FALSE) { res$Intensity <- propercase(res$AESEV) } + # Maximum toxicity grade + if ("ATOXGRN" %in% toupper(names(res))) { + res$Maximum_Toxicity_Grade <- res$ATOXGRN + } + # Serious if ("AESER" %in% toupper(names(res))) { res$Serious <- propercase(res$AESER) diff --git a/R/prepare_ae_forestly.R b/R/prepare_ae_forestly.R index fadc629..f1b2ff4 100644 --- a/R/prepare_ae_forestly.R +++ b/R/prepare_ae_forestly.R @@ -46,8 +46,8 @@ prepare_ae_forestly <- function( parameter = NULL, reference_group = NULL, ae_listing_display = c( - "USUBJID", "SEX", "RACE", "AGE", "ASTDY", "AESEV", "AESER", - "AEREL", "AEACN", "AEOUT", "SITEID", "ADURN", "ADURU" + "USUBJID", "SITEID", "SEX", "RACE", "AGE", "ASTDY", "AESER", + "AEREL", "AEACN", "AEOUT", "ADURN", "ADURU" ), ae_listing_unique = FALSE) { diff --git a/man/prepare_ae_forestly.Rd b/man/prepare_ae_forestly.Rd index 3d43723..db6e851 100644 --- a/man/prepare_ae_forestly.Rd +++ b/man/prepare_ae_forestly.Rd @@ -10,8 +10,8 @@ prepare_ae_forestly( observation = NULL, parameter = NULL, reference_group = NULL, - ae_listing_display = c("USUBJID", "SEX", "RACE", "AGE", "ASTDY", "AESEV", "AESER", - "AEREL", "AEACN", "AEOUT", "SITEID", "ADURN", "ADURU"), + ae_listing_display = c("USUBJID", "SITEID", "SEX", "RACE", "AGE", "ASTDY", "AESER", + "AEREL", "AEACN", "AEOUT", "ADURN", "ADURU"), ae_listing_unique = FALSE ) }