Skip to content

Commit

Permalink
Update to handle urine records #2392
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyad committed Mar 29, 2024
1 parent fc102b3 commit 62c91cd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Updates of Existing Functions

- Created three unit tests for `get_summary_records()`. (#2304)
- Templates for ADPC, ADPPK and ADPP are updated to handle urine records. (#2392)

## Breaking Changes

Expand Down
5 changes: 3 additions & 2 deletions inst/templates/ad_adpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ adpc_nrrlt <- adpc_arrlt %>%

adpc_aval <- adpc_nrrlt %>%
mutate(
PARCAT1 = PCSPEC,
ATPTN = case_when(
EVID == 1 ~ 0,
TRUE ~ PCTPTNUM
Expand Down Expand Up @@ -444,7 +445,7 @@ adpc_dtype <- bind_rows(adpc_aval, dtype) %>%

adpc_base <- adpc_dtype %>%
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = exprs(STUDYID, USUBJID, PARAMCD, PARCAT1, BASETYPE),
source_var = AVAL,
new_var = BASE,
filter = ABLFL == "Y"
Expand All @@ -459,7 +460,7 @@ adpc_aseq <- adpc_chg %>%
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
order = exprs(ADTM, BASETYPE, EVID, AVISITN, ATPTN, DTYPE),
order = exprs(ADTM, BASETYPE, EVID, AVISITN, ATPTN, PARCAT1, DTYPE),
check_type = "error"
) %>%
# Remove temporary variables
Expand Down
7 changes: 5 additions & 2 deletions inst/templates/ad_adpp.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ param_lookup <- tibble::tribble(
"TCEND", "TCEND", "Time of CEND", 17, # non Cdisc Term
"TLST", "TLST", "Time of Last Nonzero Conc", 18,
"TMAX", "TMAX", "Time of CMAX", 19,
"VSSO", "VSSO", "Vol Dist Steady State Obs", 20
"VSSO", "VSSO", "Vol Dist Steady State Obs", 20,
"RCAMINT", "RCAMINT", "Ae", 21,
"RENALCL", "RENALCL", "CLR", 22
)

# ASSIGN AVALCAT1
Expand Down Expand Up @@ -100,8 +102,9 @@ adpp_aval <- adpp_pp %>%
select(param_lookup, PPTESTCD, PARAMCD),
by = "PPTESTCD"
) %>%
## Calculate AVAL and AVALC ----
## Calculate PARCAT1, AVAL and AVALC ----
mutate(
PARCAT1 = PPCAT,
AVAL = PPSTRESN,
AVALC = PPSTRESC,
AVALU = PPSTRESU,
Expand Down
9 changes: 5 additions & 4 deletions inst/templates/ad_adppk.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ adppk_aval <- adppk_aprlt %>%
# Derive CMT
CMT = case_when(
EVID == 1 ~ 1,
TRUE ~ 2
PCSPEC == "PLASMA" ~ 2,
TRUE ~ 3
),
# Derive BLQFL/BLQFN
BLQFL = case_when(
Expand Down Expand Up @@ -321,7 +322,7 @@ adppk_aseq <- adppk_aval %>%
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
order = exprs(AFRLT, EVID),
order = exprs(AFRLT, EVID, CMT),
check_type = "error"
) %>%
# Derive PARAM and PARAMN
Expand All @@ -335,8 +336,8 @@ adppk_aseq <- adppk_aval %>%
-DOMAIN, -starts_with("min"), -starts_with("max"), -starts_with("EX"),
-starts_with("PC"), -ends_with("first"), -ends_with("prev"),
-ends_with("DTM"), -ends_with("DT"), -ends_with("TM"), -starts_with("VISIT"),
-starts_with("AVISIT"), -starts_with("PARAM"),
-ends_with("TMF"), -starts_with("TRT"), -starts_with("ATPT"), -DRUG
-starts_with("AVISIT"), -ends_with("TMF"), -starts_with("TRT"),
-starts_with("ATPT"), -DRUG
)

#---- Derive Covariates ----
Expand Down
14 changes: 8 additions & 6 deletions vignettes/pk_adnca.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ variables.
adpc_aval <- adpc_nrrlt %>%
mutate(
PARCAT1 = PCSPEC,
ATPTN = case_when(
EVID == 1 ~ 0,
TRUE ~ PCTPTNUM
Expand Down Expand Up @@ -827,7 +828,7 @@ Finally we derive `PARAM` and `PARAMN` from a lookup table.
adpc_base <- adpc_dtype %>%
# Derive BASE
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = exprs(STUDYID, USUBJID, PARAMCD, PARCAT1, BASETYPE),
source_var = AVAL,
new_var = BASE,
filter = ABLFL == "Y"
Expand All @@ -842,7 +843,7 @@ adpc_aseq <- adpc_chg %>%
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
order = exprs(ADTM, BASETYPE, EVID, AVISITN, ATPTN, DTYPE),
order = exprs(ADTM, BASETYPE, EVID, AVISITN, ATPTN, PARCAT1, DTYPE),
check_type = "error"
) %>%
# Remove temporary variables
Expand Down Expand Up @@ -1164,7 +1165,8 @@ adppk_aval <- adppk_aprlt %>%
# Derive CMT
CMT = case_when(
EVID == 1 ~ 1,
TRUE ~ 2
PCSPEC == "PLASMA" ~ 2,
TRUE ~ 3
),
# Derive BLQFL/BLQFN
BLQFL = case_when(
Expand Down Expand Up @@ -1225,7 +1227,7 @@ adppk_aseq <- adppk_aval %>%
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
order = exprs(AFRLT, EVID),
order = exprs(AFRLT, EVID, CMT),
check_type = "error"
) %>%
# Derive PARAM and PARAMN
Expand All @@ -1239,8 +1241,8 @@ adppk_aseq <- adppk_aval %>%
-DOMAIN, -starts_with("min"), -starts_with("max"), -starts_with("EX"),
-starts_with("PC"), -ends_with("first"), -ends_with("prev"),
-ends_with("DTM"), -ends_with("DT"), -ends_with("TM"), -starts_with("VISIT"),
-starts_with("AVISIT"), -starts_with("PARAM"),
-ends_with("TMF"), -starts_with("TRT"), -starts_with("ATPT"), -DRUG
-starts_with("AVISIT"), -ends_with("TMF"), -starts_with("TRT"),
-starts_with("ATPT"), -DRUG
)
```

Expand Down

0 comments on commit 62c91cd

Please sign in to comment.