Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_single_dose_dataset() - incorrectly deriving ASTDTM and AENDTM #1224

Closed
morrishj opened this issue Jun 16, 2022 · 2 comments · Fixed by #1284
Closed

create_single_dose_dataset() - incorrectly deriving ASTDTM and AENDTM #1224

morrishj opened this issue Jun 16, 2022 · 2 comments · Fixed by #1284
Assignees
Labels
bug Something isn't working programming

Comments

@morrishj
Copy link
Contributor

morrishj commented Jun 16, 2022

What happened?

The create_single_dose_dataset() function is correctly deriving dates for ASTDT and AENDT but not for ASTDTM and AENDTM. The function should split diary card data (where each record covers a range of dates) into one line per date. It does this correctly for ASTDT and AENDT, but it keeps the earliest recorded date for ASTDTM and AENDTM. Please see screenshot attached for example data.

single dose

Session Information

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] purrr_0.3.4       rice_2.0          lubridate_1.7.9   dplyr_1.0.2       admiraltest_0.2.0 admiral_0.7.0    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8       rstudioapi_0.11  magrittr_2.0.3   getPass_0.2-2    hms_0.5.3        tidyselect_1.1.0 R6_2.5.0         rlang_1.0.2      stringr_1.4.0   
[10] httr_1.4.2       tools_4.0.3      cli_3.3.0        ellipsis_0.3.2   digest_0.6.27    assertthat_0.2.1 tibble_3.0.4     lifecycle_0.2.0  crayon_1.3.4    
[19] readr_1.4.0      tidyr_1.1.2      vctrs_0.4.1      curl_4.3         memoise_1.1.0    glue_1.6.2       haven_2.3.1      stringi_1.5.3    compiler_4.0.3  
[28] pillar_1.4.6     forcats_0.5.0    generics_0.1.0   jsonlite_1.7.1   pkgconfig_2.0.3

Reproducible Example

library(dplyr)
library(lubridate)

ex <- tibble::tribble(
  ~USUBJID, ~EXTRT, ~EXDOSFRQ, ~EXSTDTC,              ~EXENDTC,           ~ASTDT,       ~AENDT,       ~ASTDTM,               ~AENDTM,              
  "P01",    "Drug", "QD",      "2022-01-01 12:30",    "2022-01-07",       "2022-01-01", "2022-01-07", "2022-01-01 12:30:00", "2022-01-07 23:59:59",
  "P02",    "Drug", "QD",      "2022-02-06 11:09:12", "2022-02-08 12:00", "2022-02-06", "2022-02-08", "2022-02-06 11:09:12", "2022-02-08 12:00:59"
) %>% 
  mutate(
    ASTDT = ymd(ASTDT),
    AENDT = ymd(AENDT),
    ASTDTM = ymd_hms(ASTDTM),
    AENDTM = ymd_hms(AENDTM)
  )

admiral::create_single_dose_dataset(ex)
# A tibble: 10 x 9
   USUBJID EXTRT EXDOSFRQ EXSTDTC             EXENDTC          ASTDT      AENDT      ASTDTM              AENDTM             
   <chr>   <chr> <chr>    <chr>               <chr>            <date>     <date>     <dttm>              <dttm>             
 1 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-01 2022-01-01 2022-01-01 12:30:00 2022-01-07 23:59:59
 2 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-02 2022-01-02 2022-01-01 12:30:00 2022-01-07 23:59:59
 3 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-03 2022-01-03 2022-01-01 12:30:00 2022-01-07 23:59:59
 4 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-04 2022-01-04 2022-01-01 12:30:00 2022-01-07 23:59:59
 5 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-05 2022-01-05 2022-01-01 12:30:00 2022-01-07 23:59:59
 6 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-06 2022-01-06 2022-01-01 12:30:00 2022-01-07 23:59:59
 7 P01     Drug  ONCE     2022-01-01 12:30    2022-01-07       2022-01-07 2022-01-07 2022-01-01 12:30:00 2022-01-07 23:59:59
 8 P02     Drug  ONCE     2022-02-06 11:09:12 2022-02-08 12:00 2022-02-06 2022-02-06 2022-02-06 11:09:12 2022-02-08 12:00:59
 9 P02     Drug  ONCE     2022-02-06 11:09:12 2022-02-08 12:00 2022-02-07 2022-02-07 2022-02-06 11:09:12 2022-02-08 12:00:59
10 P02     Drug  ONCE     2022-02-06 11:09:12 2022-02-08 12:00 2022-02-08 2022-02-08 2022-02-06 11:09:12 2022-02-08 12:00:59
@morrishj morrishj added bug Something isn't working programming labels Jun 16, 2022
@thomas-neitmann
Copy link
Contributor

Thanks a lot for reporting this @morrishj! I've removed the example you provided which contain calls to accessing Roche data for a little reproducible example that shows the same problem.

@pharmaverse/admiral (especially @amsmith214 & @bundfussr) I feel like not only the --DT variables but also --DTM variables should be populated with calculated values. I'm also not sure how I feel about the original SDTM variables just being retained from the original record. Maybe set to NA instead?

@bundfussr
Copy link
Collaborator

That's a tricky question.

  • We could change start_date and end_date to start_date_prefix and end_date_prefix respectively. Date and Datetime variables with the prefix are populated if they exist in the input dataset. Imputation flag variables with the prefix are set to NA.
  • Regarding retaining variables from the input dataset we have two options:
    • We retain all variables and provide a set_values_to parameter, which could be used to set variables to NA which should not be retained.
    • We retain no variables and provide a keep_source_vars parameter, which could be used to specify the variables which should be retained.

The set_values_to parameter could also be used to set variables like PARAMCD in the case that the single doses should be added to the ADEX dataset as separate parameter.

@anthoward anthoward self-assigned this Jun 28, 2022
@anthoward anthoward linked a pull request Jul 1, 2022 that will close this issue
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working programming
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants