Skip to content

Commit

Permalink
Merge pull request #42 from yuliasidi/main
Browse files Browse the repository at this point in the history
`format_ae_listing` updated to be better aligned with oncology AEs reporting
  • Loading branch information
wangben718 authored May 1, 2024
2 parents 530a141 + d2f653f commit 5480f82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
18 changes: 12 additions & 6 deletions R/ae_listing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions R/prepare_ae_forestly.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
4 changes: 2 additions & 2 deletions man/prepare_ae_forestly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5480f82

Please sign in to comment.