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

add subject disposition #2004

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/Report_StudyInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Report_StudyInfo <- function(
"ParticipantEnrollment"
)
show_table <- study_status_table %>%
dplyr::filter(.data$Param %in% subcols) %>%
dplyr::filter(tolower(.data$Param) %in% tolower(subcols)) %>%
gt_StudyInfo(id = strId)

strId_hide <- paste0(strId, "_hide")
Expand Down
9 changes: 6 additions & 3 deletions inst/examples/3_ReportingWorkflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ lSource <- list(
Source_PD = clindata::ctms_protdev,
Source_LB = clindata::rawplus_lb,
Source_STUDCOMP = clindata::rawplus_studcomp,
Source_SDRGCOMP = clindata::rawplus_sdrgcomp %>% dplyr::filter(.data$phase == 'Blinded Study Drug Completion'),
Source_SDRGCOMP = clindata::rawplus_sdrgcomp %>%
dplyr::filter(.data$phase == 'Blinded Study Drug Completion'),
Source_DATACHG = clindata::edc_data_points,
Source_DATAENT = clindata::edc_data_pages,
Source_QUERY = clindata::edc_queries,
Expand All @@ -23,7 +24,8 @@ lRaw <- list(
Raw_PD = lSource$Source_PD %>%
rename(subjid = subjectenrollmentnumber),
Raw_LB = lSource$Source_LB,
Raw_STUDCOMP = lSource$Source_STUDCOMP,
Raw_STUDCOMP = lSource$Source_STUDCOMP %>%
select(subjid, compyn),
Raw_SDRGCOMP = lSource$Source_SDRGCOMP,
Raw_DATACHG = lSource$Source_DATACHG %>%
rename(subject_nsv = subjectname),
Expand All @@ -39,7 +41,8 @@ lRaw <- list(
rename(InvestigatorLastName = pi_last_name) %>%
rename(City = city) %>%
rename(State = state) %>%
rename(Country = country),
rename(Country = country) %>%
rename(Status = site_status),
Raw_STUDY = lSource$Source_STUDY %>%
rename(studyid = protocol_number) %>%
rename(Status = status)
Expand Down
20 changes: 18 additions & 2 deletions inst/workflow/1_mappings/COUNTRY.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@ steps:
name: RunQuery
params:
df: Mapped_SUBJ
strQuery: "SELECT country as GroupID, COUNT(DISTINCT subjid) as ParticipantCount, COUNT(DISTINCT invid) as SiteCount FROM df GROUP BY country"
strQuery: |
SELECT
country as GroupID,
COUNT(DISTINCT subjid) as ParticipantCount,
SUM(CASE WHEN Status == 'Active' THEN 1 ELSE 0 END) as ActiveParticipantCount,
COUNT(DISTINCT invid) as SiteCount
FROM df
GROUP BY country
- output: Temp_CountryCountsWide_ActiveParticipants
name: CalculatePercentage
params:
data: Temp_CountryCountsWide
strCurrentCol: ActiveParticipantCount
strTargetCol: ParticipantCount
strPercVal: PercentParticipantsActive
strPercStrVal: ActiveParticipants
- output: Mapped_COUNTRY
name: MakeLongMeta
params:
data: Temp_CountryCountsWide
data: Temp_CountryCountsWide_ActiveParticipants
strGroupLevel: "Country"

24 changes: 21 additions & 3 deletions inst/workflow/1_mappings/SITE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ spec:
InvestigatorLastName:
type: character
source_col: pi_last_name
site_status:
Status:
type: character
source_col: site_status
City:
type: character
source_col: city
Expand All @@ -35,6 +36,8 @@ spec:
type: character
subjid:
type: character
Status:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this Status, right? looks like a duplicate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one captures subject status, to count the number of active subjects at the site.

type: character
steps:
- output: Temp_CTMSSiteWide
name: RunQuery
Expand All @@ -50,11 +53,26 @@ steps:
name: RunQuery
params:
df: Mapped_SUBJ
strQuery: "SELECT invid as GroupID, COUNT(DISTINCT subjid) as ParticipantCount, COUNT(DISTINCT invid) as SiteCount FROM df GROUP BY invid"
strQuery: |
SELECT
invid as GroupID,
COUNT(DISTINCT subjid) as ParticipantCount,
SUM(CASE WHEN Status == 'Active' THEN 1 ELSE 0 END) as ActiveParticipantCount,
COUNT(DISTINCT invid) as SiteCount
FROM df
GROUP BY invid
- output: Temp_SiteCountsWide_ActiveParticipants
name: CalculatePercentage
params:
data: Temp_SiteCountsWide
strCurrentCol: ActiveParticipantCount
strTargetCol: ParticipantCount
strPercVal: PercentParticipantsActive
strPercStrVal: ActiveParticipants
- output: Temp_SiteCounts
name: MakeLongMeta
params:
data: Temp_SiteCountsWide
data: Temp_SiteCountsWide_ActiveParticipants
strGroupLevel: "Site"
- output: Mapped_SITE
name: bind_rows
Expand Down
25 changes: 22 additions & 3 deletions inst/workflow/1_mappings/STUDY.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ spec:
type: character
protocol_title:
type: character
status:
Status:
type: character
source_col: status
num_plan_site:
type: integer
num_plan_subj:
Expand Down Expand Up @@ -41,6 +42,8 @@ spec:
type: character
subjid:
type: character
Status:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another duplicate Status as far as i can tell

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, Mapped_SUBJ$Status is used to calculate the number of active subjects. Raw_STUDY$Status is a study-level attribute.

type: character
steps:
- output: Temp_CTMSStudyWide
name: RunQuery
Expand All @@ -61,7 +64,14 @@ steps:
name: RunQuery
params:
df: Mapped_SUBJ
strQuery: "SELECT studyid as GroupID, COUNT(DISTINCT subjid) as ParticipantCount, COUNT(DISTINCT invid) as SiteCount FROM df GROUP BY studyid"
strQuery: |
SELECT
studyid as GroupID,
COUNT(DISTINCT subjid) as ParticipantCount,
SUM(CASE WHEN Status == 'Active' THEN 1 ELSE 0 END) as ActiveParticipantCount,
COUNT(DISTINCT invid) as SiteCount
FROM df
GROUP BY studyid
- output: Temp_CountTargetsWide
name: left_join
params:
Expand All @@ -84,13 +94,22 @@ steps:
strTargetCol: ParticipantTarget
strPercVal: PercentParticipantsEnrolled
strPercStrVal: ParticipantEnrollment
- output: Temp_CountTargetsWide_ActiveParticipants
name: CalculatePercentage
params:
data: Temp_CountTargetsWide_addsitepts
strCurrentCol: ActiveParticipantCount
strTargetCol: ParticipantCount
strPercVal: PercentParticipantsActive
strPercStrVal: ActiveParticipants
- output: Temp_CountTargetsPercs
name: MakeLongMeta
params:
data: Temp_CountTargetsWide_addsitepts
data: Temp_CountTargetsWide_ActiveParticipants
strGroupLevel: "Study"
- output: Mapped_STUDY
name: bind_rows
params:
Temp_CTMSStudy: Temp_CTMSStudy
Temp_CountTargetsPercs: Temp_CountTargetsPercs

27 changes: 25 additions & 2 deletions inst/workflow/1_mappings/SUBJ.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,32 @@ spec:
type: character
timeonstudy:
type: integer
Raw_STUDCOMP:
subjid:
type: character
compyn:
type: character
steps:
- output: Temp_SUBJ
name: left_join
params:
x: Raw_SUBJ
"y": Raw_STUDCOMP
by: subjid
- output: Mapped_SUBJ
name: RunQuery
params:
df: Raw_SUBJ
strQuery: "SELECT * FROM df WHERE enrollyn == 'Y'"
df: Temp_SUBJ
strQuery: |
SELECT *,
CASE
WHEN compyn == 'Y' THEN 'Completed'
WHEN compyn == 'N' THEN 'Discontinued'
WHEN enrollyn == 'Y' THEN 'Active'
WHEN enrollyn == 'N' THEN 'Screen Failure'
WHEN enrollyn == '' THEN 'In Screening'
ELSE 'Unknown'
END as Status
FROM df
WHERE enrollyn == 'Y'

2 changes: 2 additions & 0 deletions tests/testthat/_snaps/Report_StudyInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@
<tbody class="gt_table_body">
<tr><td headers="Description" class="gt_row gt_left">Nickname</td>
<td headers="Value" class="gt_row gt_right">Nickname</td></tr>
<tr><td headers="Description" class="gt_row gt_left">Status</td>
<td headers="Value" class="gt_row gt_right">Ongoing</td></tr>
</tbody>


Expand Down
Loading
Loading