Skip to content

Bug: R script template missing volume unit simplification step #1190

@js3110

Description

@js3110

Description

The Shiny UI applies volume unit simplification after PKNCA_create_data_object() in tab_data.R (lines ~243-260). This step calls simplify_unit() on volume-type parameters and updates PPSTRESU and conversion_factor in the PKNCAdata units table.

The R script template (script_template.R) does not include this step. This means R scripts generated from the app may produce different unit representations for volume parameters compared to the app.

Part of #718. Related: #1191 (another missing step in the R script template).

Relevant code

In inst/shiny/modules/tab_data.R:

pknca_object$units <- pknca_object$units %>%
  mutate(
    PPSTRESU = {
      new_ppstresu <- ifelse(
        PPTESTCD %in% metadata_nca_parameters$PKNCA[
          metadata_nca_parameters$unit_type == "volume"
        ],
        sapply(PPSTRESU, function(x) simplify_unit(x, as_character = TRUE)),
        PPSTRESU
      )
      ifelse(nchar(new_ppstresu) < 3, new_ppstresu, .data[["PPSTRESU"]])
    },
    conversion_factor = ifelse(...)
  )

Definition of Done

  • R script template includes volume unit simplification after PKNCA_create_data_object()
  • Or the simplification is moved into PKNCA_create_data_object() itself so both paths get it automatically
  • App and R script produce identical unit representations for volume parameters

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions