Skip to content

Feature Request: Add pctpt_to_hours() to parse PCTPT values into hours #2916

@jeffreyad

Description

@jeffreyad

Feature Idea

Implement a utility function pctpt_to_hours() that converts pharmacokinetic/pharmacodynamic timepoint strings (PCTPT) into numeric hours. The function should handle common dose-centric formats like Predose, Post-dose (hours/minutes), and simple time-only values, returning NA_real_ for non-numeric event markers (e.g., EOI, EOS, EOT) or unrecognized inputs.

Relevant Input

example <- pharmaversesdtm::pc %>% 
  select(USUBJID, PCTPT) %>% 
  mutate(
    hours = pctpt_to_hours(PCTPT)
  ) %>% 
  print(n = 20)

Relevant Output

# A tibble: 4,572 × 4
   USUBJID     VISIT    PCTPT              hours
   <chr>       <chr>    <chr>              <dbl>
 1 01-701-1015 BASELINE Pre-dose          0     
 2 01-701-1015 BASELINE 5 Min Post-dose   0.0833
 3 01-701-1015 BASELINE 30 Min Post-dose  0.5   
 4 01-701-1015 BASELINE 1h Post-dose      1     
 5 01-701-1015 BASELINE 1.5h Post-dose    1.5   
 6 01-701-1015 BASELINE 2h Post-dose      2     
 7 01-701-1015 BASELINE 4h Post-dose      4     
 8 01-701-1015 BASELINE 6h Post-dose      6     
 9 01-701-1015 BASELINE 8h Post-dose      8     
10 01-701-1015 BASELINE 12h Post-dose    12     
11 01-701-1015 BASELINE 16h Post-dose    16     
12 01-701-1015 BASELINE 24h Post-dose    24     
13 01-701-1015 BASELINE 36h Post-dose    36     
14 01-701-1015 BASELINE 48h Post-dose    48     
15 01-701-1015 BASELINE 0-6h Post-dose    6     
16 01-701-1015 BASELINE 6-12h Post-dose  12     
17 01-701-1015 BASELINE 12-24h Post-dose 24     
18 01-701-1015 BASELINE 24-48h Post-dose 48     
19 01-701-1023 BASELINE Pre-dose          0     
20 01-701-1023 BASELINE 5 Min Post-dose   0.0833

Reproducible Example/Pseudo Code

No response

Metadata

Metadata

Type

No type

Projects

Status

Archive

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions