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

Diff: devex vs dev #128

Draft
wants to merge 90 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
53a79e5
Add basic excel button
aclark02-arcus Oct 29, 2024
e31bf06
try moving the button to the right, but failed.
aclark02-arcus Nov 4, 2024
4c0c9bd
Add helper function for DT renderDT() to determine the appropriate dt…
aclark02-arcus Nov 4, 2024
0d7fee5
Merge pull request #126 from openpharma/jt-update_devex_workflows
aclark02-arcus Nov 4, 2024
d9d19dc
update news
aclark02-arcus Nov 4, 2024
8576890
Add a default & custom excel filename for any & all listings with a d…
aclark02-arcus Nov 4, 2024
674b75c
clean up some code
aclark02-arcus Nov 4, 2024
b3e8819
move button to right-hand side so that it's not he first thing you see.
aclark02-arcus Nov 4, 2024
d271dfb
boost 'em' slightly for spacing of excel button
aclark02-arcus Nov 4, 2024
15adcb6
Changed 'excel' text on download button to an icon
aclark02-arcus Nov 4, 2024
67a624c
Increment version number to 0.1.0.9005
aclark02-arcus Nov 4, 2024
be88fae
update golem config version
aclark02-arcus Nov 4, 2024
b146fe9
add new json files
aclark02-arcus Nov 4, 2024
785f90d
remove timestamp from the downloadable excel filenames
aclark02-arcus Nov 5, 2024
85bbbce
update json files after removing timestamp
aclark02-arcus Nov 5, 2024
43ea7ef
updating json files now after actually changing them to be sans times…
aclark02-arcus Nov 5, 2024
3278dc5
update json snaps for feature 03
aclark02-arcus Nov 5, 2024
7d65a24
update jsons for study_forms mod snaps
aclark02-arcus Nov 5, 2024
37d556e
Merge branch 'dev' into devex
aclark02-arcus Nov 6, 2024
eadd755
fix merge conflicts
aclark02-arcus Nov 6, 2024
72b4350
update w/ whack snaps that remove col reorder ext
aclark02-arcus Nov 6, 2024
0d991b7
update to be more flexible and reference default args for
aclark02-arcus Nov 6, 2024
ee2f6ea
update json snaps that now include col reorder
aclark02-arcus Nov 6, 2024
fc2e446
update description by adding devexVersion and reverting Version field.
aclark02-arcus Nov 8, 2024
130b274
Update NEWS.md with "`devex` changes" section
aclark02-arcus Nov 11, 2024
bd9d8e0
Merge pull request #122 from openpharma/ac-96
aclark02-arcus Nov 11, 2024
24e3050
Resolve merge conflict with `devex`
jthompson-arcus Nov 19, 2024
a3fd9b9
Merge branch 'jt-99-review_by_row' into jt-99-review_by_row-devex
jthompson-arcus Nov 19, 2024
993035f
Resolve merge conflicts with `dev`
jthompson-arcus Nov 20, 2024
22f4b76
Merge branch 'jt-99-review_by_row' into jt-99-review_by_row-devex
jthompson-arcus Nov 20, 2024
7dc72a9
Merge `db_get_query()` changes
jthompson-arcus Nov 20, 2024
b359324
Merge pull request #143 from openpharma/jt-resolve_merge_conflicts_dev
aclark02-arcus Nov 20, 2024
2d0d704
Add very basic checkbox column to tables
jthompson-arcus Nov 21, 2024
d436332
Merge branch 'jt-99-review_by_row' into jt-99-review_by_row_for_reals
jthompson-arcus Nov 21, 2024
f56c780
Merge branch 'jt-99-review_by_row' into jt-99-review_by_row_for_reals
jthompson-arcus Nov 22, 2024
67d817f
"Highlight" rows when check status changed
jthompson-arcus Nov 22, 2024
7939b3c
Grab id's for `o_reviewed`
jthompson-arcus Nov 22, 2024
e3bb3ed
Add input handler
jthompson-arcus Nov 22, 2024
6e258a2
Capture row index info
jthompson-arcus Nov 25, 2024
a42049b
Standardize callbacks and renders
jthompson-arcus Nov 25, 2024
7ba17d9
Add missing observers
jthompson-arcus Nov 25, 2024
f0dfcc3
Add study form observers
jthompson-arcus Nov 25, 2024
9f0e4de
Add `anti_join()`s back
jthompson-arcus Nov 25, 2024
b703bec
First pass at integration in review module
jthompson-arcus Nov 25, 2024
5fd5747
Fix couple of issues
jthompson-arcus Nov 25, 2024
5956269
Remove row selection
jthompson-arcus Nov 25, 2024
d9f49e8
Fix bug on study forms
jthompson-arcus Nov 25, 2024
e2b9953
Resolve merge conflict with `jt-99-review_by_row`
jthompson-arcus Dec 2, 2024
2493779
Integrate "form_reviewed" checkbox
jthompson-arcus Dec 2, 2024
0cb8710
Update tables from overall checkbox
jthompson-arcus Dec 2, 2024
2894351
Update `app-feature-1` snapshots
jthompson-arcus Dec 2, 2024
b27d95d
Update app-feature-3-002.json
jthompson-arcus Dec 2, 2024
36f843a
Update app_feature_04.md
jthompson-arcus Dec 2, 2024
e98afa0
Create custom.js
jthompson-arcus Dec 2, 2024
a353f5d
Fix warnings and errors in `mod_common_forms` test
jthompson-arcus Dec 2, 2024
579d80e
Repair part of `mod_review_form` tests
jthompson-arcus Dec 3, 2024
a7fda21
Properly handle partially reviewed rows
jthompson-arcus Dec 3, 2024
310eff2
Repair interactivity between overall checkbox and tables
jthompson-arcus Dec 3, 2024
5a78643
Clean up table name
jthompson-arcus Dec 3, 2024
365206d
Update `app_feature_01` JSONs
jthompson-arcus Dec 3, 2024
d10e475
Fix issue with setting input for checkbox
jthompson-arcus Dec 3, 2024
1982650
Update `app_feature_03` JSONs
jthompson-arcus Dec 3, 2024
5d45431
Reset review reactiveValues after save
jthompson-arcus Dec 3, 2024
96e795e
Repair study form test
jthompson-arcus Dec 3, 2024
f4a71ad
Update test-mod_review_forms.R
jthompson-arcus Dec 3, 2024
54f7f55
Add rudimentary progress bar
jthompson-arcus Dec 4, 2024
05a3ee4
Resolve merge conflicts with `dev`
jthompson-arcus Dec 4, 2024
2473133
Add transition to progress bar
jthompson-arcus Dec 4, 2024
3123136
Wrap Shiny bindings
jthompson-arcus Dec 5, 2024
b987708
Clean up readability of checkbox render function
jthompson-arcus Dec 5, 2024
f637dd0
Update `app-feature-01` JSONs
jthompson-arcus Dec 5, 2024
7144bd8
Update `app-feature-02` JSON
jthompson-arcus Dec 5, 2024
e6fe7ee
Update `app-feature-03` JSONs
jthompson-arcus Dec 5, 2024
d6a2ff9
Add bottom margin to progress bar
jthompson-arcus Dec 5, 2024
f0a19e7
Update `mod_study_forms` JSONs
jthompson-arcus Dec 5, 2024
bfc864f
Spruce up progress bar output object
jthompson-arcus Dec 5, 2024
f896b4f
Merge pull request #147 from openpharma/jt-update_devex
aclark02-arcus Dec 5, 2024
e9ab76d
Update custom.css
jthompson-arcus Dec 5, 2024
c6ef036
Fix "form already reviewed" indicator
jthompson-arcus Dec 5, 2024
a36d7cf
Update version
jthompson-arcus Dec 5, 2024
4de107d
Resolve merge conflicts with `devex`
jthompson-arcus Dec 5, 2024
bbd6a74
""
jthompson-arcus Dec 5, 2024
a746b2e
Only review selected subject
jthompson-arcus Dec 5, 2024
546b4e4
Save updated status in DOM
jthompson-arcus Dec 5, 2024
c07540a
Set `server=FALSE` for the moment
jthompson-arcus Dec 5, 2024
fa953b5
Resolve merge conflicts with `jt-99-review_by_row_for_reals`
jthompson-arcus Dec 6, 2024
ddc0eee
Update `app-feature-1` JSONs
jthompson-arcus Dec 6, 2024
31346b6
Update `app-feature-3` JSON
jthompson-arcus Dec 6, 2024
52c5d42
Update `study_forms` JSONs
jthompson-arcus Dec 6, 2024
1306692
Merge pull request #148 from openpharma/jt-99-review_by_row-devex
jthompson-arcus Dec 6, 2024
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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Package: clinsight
Title: ClinSight
Version: 0.1.1.9011
DevexVersion: 9001
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-6252-7639")),
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
- Added form type as a class to be used in `create_table()` to display tables.
- Add a logging table to the DB for reviews.
- Simplify pulling data from DB for reviews.
- Review data by records IDs instead of subject & form

## Bug fixes

- The test-coverage GHA workflow is updated so that codecov uploads work again.

## `devex` changes
- Added `Excel` download button to Queries table & patient listings that need review.
- Added helper function to automatically determine when adding said excel button is appropriate.
- Review data by records IDs instead of subject & form

# clinsight 0.1.1

## Changed
Expand Down
3 changes: 3 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ app_server <- function(
})
check_appdata(app_data, meta)

session$userData$review_records <- reactiveValues()
session$userData$update_checkboxes <- reactiveValues()

res_auth <- authenticate_server(
all_sites = app_vars$Sites$site_code,
credentials_db = credentials_db,
Expand Down
29 changes: 29 additions & 0 deletions R/fct_data_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,35 @@ add_missing_columns <- function(
data
}

#' Configure DT helper
#'
#' Small wrapper that helps handle some messiness preparing the correct `DT`
#' dom, extensions, & options when needed. Specifically, when & how to add an
#' Excel download button.
#'
#' @param data A data frame used for display in a DT table. Number of rows will
#' be assessed
#' @param table_name character string, usually the form name
#'
#' @keywords internal
#' @return list with three named objects: `dom`, `exts`, and `opts`
dt_config <- function(data, table_name = "form") {
default_args<- formals(datatable_custom)
if(nrow(data) > 0 & isTRUE(get_golem_config("allow_listing_download"))) {
dt_dom <- 'Bfti'
dt_exts <- c("Buttons", eval(default_args$extensions))
dt_opts <- list(buttons=list(list(extend = 'excel',
text = '<i class="fa-solid fa-download"></i>',
filename = paste("clinsight", gsub(" ", "-", table_name), sep = ".")
)))
} else {
dt_dom <- default_args$dom |> eval()
dt_exts <- default_args$extensions |> eval()
dt_opts <- default_args$options |> eval()
}
return(list(dom = dt_dom, exts = dt_exts, opts = dt_opts))
}

#' Custom interactive datatable
#'
#' Small wrapper around [DT::datatable()]. Will be used to create tables in a
Expand Down
12 changes: 12 additions & 0 deletions R/fct_tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ create_table.default <- function(
stopifnot(is.character(keep_vars))
stopifnot(is.character(name_column))
stopifnot(is.character(value_column))
if ("reviewed" %in% names(data)) {
data <- dplyr::mutate(
data,
o_reviewed = dplyr::case_when(
any(reviewed == "No") & any(reviewed == "Yes") ~ list(list(reviewed = NA, ids = id)),
any(reviewed == "Yes") ~ list(list(reviewed = TRUE, ids = id)),
.default = list(list(reviewed = FALSE, ids = id))
),
.by = dplyr::all_of(keep_vars))
keep_vars <- c("o_reviewed", keep_vars)
}
df <- data[c(keep_vars, name_column, value_column)] |>
tidyr::pivot_wider(
names_from = {{name_column}},
Expand Down Expand Up @@ -298,6 +309,7 @@ create_table.medication <- function(
) |>
dplyr::arrange(dplyr::desc(in_use), dplyr::desc(`Start Date`)) |>
dplyr::select(
dplyr::any_of("o_reviewed"),
dplyr::all_of(c(keep_vars, "Name")),
dplyr::everything(),
-dplyr::all_of(c("in_use", "Active Ingredient", "Trade Name",
Expand Down
111 changes: 104 additions & 7 deletions R/mod_common_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
ns <- session$ns

data_active <- reactive({
req(!is.null(input$show_all_data))
shiny::validate(need(
!is.null(r$filtered_data[[form]]),
paste0("Warning: no data found in the database for the form '", form, "'.")
Expand Down Expand Up @@ -125,15 +126,90 @@
SAE_data <- data_active() |>
dplyr::filter(grepl("Yes", `Serious Adverse Event`)) |>
dplyr::select(dplyr::any_of(
c("subject_id","form_repeat", "Name", "AESI", "SAE Start date",
c("o_reviewed", "subject_id","form_repeat", "Name", "AESI", "SAE Start date",
"SAE End date", "CTCAE severity", "Treatment related",
"Treatment action", "Other action", "SAE Category",
"SAE Awareness date", "SAE Date of death", "SAE Death reason")
)) |>
adjust_colnames("^SAE ")
if(!input$show_all_data) SAE_data$subject_id <- NULL
datatable_custom(SAE_data, rename_vars = table_names, rownames= FALSE,
title = "Serious Adverse Events", escape = FALSE)

# determine DT dom / exts / opts
DT <- dt_config(SAE_data,
table_name = paste("SAE", ifelse(input$show_all_data,
"all_patients", r$subject_id), sep = "."))
datatable_custom(
SAE_data,
rename_vars = c("Review Status" = "o_reviewed", table_names),
rownames = FALSE,
title = "Serious Adverse Events",
escape = FALSE,
dom = DT$dom,
extensions = DT$exts,
selection = "none",
callback = checkbox_callback,
options = append(list(
columnDefs = list(list(
targets = 0,
render = checkbox_render
)),
createdRow = checkbox_create_callback
),
DT$opts))
}, server = FALSE)

observeEvent(data_active(), {
session$userData$update_checkboxes[[form]] <- NULL
session$userData$review_records[[form]] <- data.frame(id = integer(), reviewed = character())
})

observeEvent(input$common_form_table_review_selection, {
session$userData$update_checkboxes[[form]] <- NULL

Check warning on line 167 in R/mod_common_forms.R

View check run for this annotation

Codecov / codecov/patch

R/mod_common_forms.R#L167

Added line #L167 was not covered by tests

session$userData$review_records[[form]] <-
dplyr::rows_upsert(
session$userData$review_records[[form]],
input$common_form_table_review_selection,
by = "id"
) |>
dplyr::filter(!is.na(reviewed)) |>
dplyr::semi_join(
subset(r$review_data, subject_id == r$subject_id & item_group == form),
by = "id"
) |>
dplyr::anti_join(
subset(r$review_data, subject_id == r$subject_id & item_group == form),
by = c("id", "reviewed")
) |>
dplyr::arrange(id)

Check warning on line 184 in R/mod_common_forms.R

View check run for this annotation

Codecov / codecov/patch

R/mod_common_forms.R#L169-L184

Added lines #L169 - L184 were not covered by tests
})

observeEvent(session$userData$update_checkboxes[[form]], {
checked <- session$userData$update_checkboxes[[form]]

Check warning on line 188 in R/mod_common_forms.R

View check run for this annotation

Codecov / codecov/patch

R/mod_common_forms.R#L188

Added line #L188 was not covered by tests

update_cbs(ns("common_form_table"), checked)
update_cbs(ns("SAE_table"), checked)

Check warning on line 191 in R/mod_common_forms.R

View check run for this annotation

Codecov / codecov/patch

R/mod_common_forms.R#L190-L191

Added lines #L190 - L191 were not covered by tests
})

observeEvent(input$SAE_table_review_selection, {
session$userData$update_checkboxes[[form]] <- NULL

Check warning on line 195 in R/mod_common_forms.R

View check run for this annotation

Codecov / codecov/patch

R/mod_common_forms.R#L195

Added line #L195 was not covered by tests

session$userData$review_records[[form]] <-
dplyr::rows_upsert(
session$userData$review_records[[form]],
input$SAE_table_review_selection,
by = "id"
) |>
dplyr::filter(!is.na(reviewed)) |>
dplyr::semi_join(
subset(r$review_data, subject_id == r$subject_id & item_group == form),
by = "id"
) |>
dplyr::anti_join(
subset(r$review_data, subject_id == r$subject_id & item_group == form),
by = c("id", "reviewed")
) |>
dplyr::arrange(id)

Check warning on line 212 in R/mod_common_forms.R

View check run for this annotation

Codecov / codecov/patch

R/mod_common_forms.R#L197-L212

Added lines #L197 - L212 were not covered by tests
})

output[["common_form_table"]] <- DT::renderDT({
Expand All @@ -145,10 +221,31 @@
dplyr::select(-dplyr::starts_with("SAE"))
}
if(!input$show_all_data) df$subject_id <- NULL
datatable_custom(df, rename_vars = table_names, rownames= FALSE,
title = form, escape = FALSE)
})


# determine DT dom / exts / opts
DT <- dt_config(df,
table_name = paste(form, ifelse(input$show_all_data,
"all_patients", r$subject_id), sep = "."))
datatable_custom(
df,
rename_vars = c("Review Status" = "o_reviewed", table_names),
rownames= FALSE,
title = form,
escape = FALSE,
dom = DT$dom,
extensions = DT$exts,
selection = "none",
callback = checkbox_callback,
options = append(list(
columnDefs = list(list(
targets = 0,
render = checkbox_render
)),
createdRow = checkbox_create_callback
),
DT$opts))
}, server = FALSE)

})
}

Expand Down
8 changes: 7 additions & 1 deletion R/mod_queries.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,17 @@ mod_queries_server <- function(id, r, navinfo, all_forms, db_path, table_names){
query_cols <- c("resolved", query_cols)
table_title <- "All queries"
}

# determine DT dom / exts / opts
DT <- dt_config(initial_queries()[query_cols],
table_name = paste(ifelse(input$show_resolved, "all", "open"),
"queries", sep = "."))
datatable_custom(
initial_queries()[query_cols],
table_names,
title = table_title,
callback = dblclick_to_form(ns("go_to_form"))
callback = dblclick_to_form(ns("go_to_form")),
dom = DT$dom, extensions = DT$exts, options = DT$opts
)
})

Expand Down
Loading
Loading