Skip to content

Commit

Permalink
Resolve merge conflicts with dev
Browse files Browse the repository at this point in the history
Merge branch 'dev' into jt-99-review_by_row_for_reals

# Conflicts:
#	R/mod_common_forms.R
#	R/mod_study_forms.R
#	tests/testthat/_snaps/app_feature_01/app-feature-1-002.json
#	tests/testthat/_snaps/app_feature_01/app-feature-1-002_.png
#	tests/testthat/_snaps/app_feature_01/app-feature-1-003.json
#	tests/testthat/_snaps/app_feature_01/app-feature-1-004.json
#	tests/testthat/_snaps/app_feature_01/app-feature-1-004_.png
#	tests/testthat/_snaps/app_feature_01/app-feature-1-005.json
#	tests/testthat/_snaps/app_feature_01/app-feature-1-005_.png
#	tests/testthat/_snaps/app_feature_03/app-feature-3-002.json
#	tests/testthat/_snaps/mod_study_forms/study_forms-001.json
#	tests/testthat/_snaps/mod_study_forms/study_forms-002.json
  • Loading branch information
jthompson-arcus committed Jan 15, 2025
2 parents be53eab + ec9bebb commit 4fbccfd
Show file tree
Hide file tree
Showing 32 changed files with 634 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clinsight
Title: ClinSight
Version: 0.1.1.9015
Version: 0.1.1.9016
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-6252-7639")),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Review data by records IDs instead of subject & form
- Make query handling a configurable option
- Changed the legend to display 'significance pending' instead of 'significance unknown'.
- Added `Excel` download button to Queries table & patient listings that need review.

## Bug fixes

Expand Down
28 changes: 27 additions & 1 deletion R/fct_data_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ add_missing_columns <- function(
#' @param rename_vars An optional named character vector. If provided, it will
#' rename any column names found in this vector to the provided name.
#' @param title Optional. Character string with the title of the table.
#' @param selection See [DT::datatable()]. Default set to 'single'.
#' @param selection See [DT::datatable()]. Default set to 'single'.
#' @param extensions See [DT::datatable()]. Default set to 'Scroller'.
#' @param dom See \url{https://datatables.net/reference/option/dom}. A div
#' element will be inserted before the table for the table title. Default set
Expand All @@ -531,6 +531,12 @@ add_missing_columns <- function(
#' * Non-modifiable defaults:
#' * `dom`: Defined by the `dom` parameter.
#' * `initComplete`: Defaults to a function to insert table title into dataTable container.
#' @param allow_listing_download Logical, whether to allow the user to download
#' the table as an Excel file. Defaults to the `allow_listing_download`
#' configuration option in `golem-config.yml`, but can be overwritten here if
#' needed.
#' @param export_label Character string with the table export label. Only used
#' for downloadable tables (if `allow_listing_download` is `TRUE`).
#' @param ... Other optional arguments that will be passed to [DT::datatable()].
#'
#' @return A `DT::datatable` object.
Expand All @@ -545,6 +551,8 @@ datatable_custom <- function(
extensions = c("Scroller", "ColReorder"),
dom = "fti",
options = list(),
allow_listing_download = NULL,
export_label = NULL,
...
){
stopifnot(is.data.frame(data))
Expand All @@ -557,6 +565,10 @@ datatable_custom <- function(
stopifnot(is.null(title) | is.character(title))
stopifnot(grepl("t", dom, fixed = TRUE))
stopifnot(is.list(options))
allow_listing_download <- allow_listing_download %||%
get_golem_config("allow_listing_download")
stopifnot(is.null(allow_listing_download) | is.logical(allow_listing_download))
stopifnot(is.null(export_label) | is.character(export_label))

default_opts <- list(
scrollY = 400,
Expand All @@ -582,6 +594,20 @@ datatable_custom <- function(
),
dom = gsub(pattern = "(t)", replacement = '<"header h5">\\1', dom)
)

# This will conditionally add a download button to the table
if(nrow(data) > 0 & isTRUE(allow_listing_download)) {
export_label <- export_label %||% "_label.missing_"
extensions <- c("Buttons", extensions)
fixed_opts[["buttons"]] <- list(list(
extend = 'excel',
text = '<i class="fa-solid fa-download"></i>',
filename = paste("clinsight", export_label, sep = "."),
title = paste0(export_label, " | extracted from ClinSight")
))
fixed_opts[["dom"]] <- paste0('B', fixed_opts[["dom"]])
}

opts <- default_opts |>
modifyList(options) |>
modifyList(fixed_opts)
Expand Down
6 changes: 4 additions & 2 deletions R/mod_navigate_review.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ mod_navigate_review_server <- function(
df[["reviewed"]] <- NULL
if(!input$show_all_data) df$subject_id <- NULL
datatable_custom(df, table_names,
callback = dblclick_to_form(ns("go_to_form")))
callback = dblclick_to_form(ns("go_to_form")),
allow_listing_download = FALSE)
})

queries_table_data <- reactive({
Expand Down Expand Up @@ -158,7 +159,8 @@ mod_navigate_review_server <- function(
pageLength = -1
),
rownames = FALSE,
selection = "none"
selection = "none",
allow_listing_download = FALSE
)
})

Expand Down
11 changes: 9 additions & 2 deletions R/mod_queries.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,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


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")),
export_label = paste(ifelse(input$show_resolved, "all", "open"),
"queries", sep = ".")
)
})

Expand Down Expand Up @@ -184,7 +190,8 @@ mod_queries_server <- function(id, r, navinfo, all_forms, db_path, table_names){
),
class = "row-border hover",
rownames = FALSE,
selection = "none"
selection = "none",
allow_listing_download = FALSE
)
})
})
Expand Down
6 changes: 4 additions & 2 deletions R/mod_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ mod_report_server <- function(id, r, rev_data, db_path, table_names){
})

output[["review_completed_table"]] <- DT::renderDT({
datatable_custom(selected_review_data(), table_names, rownames = FALSE)
datatable_custom(selected_review_data(), table_names, rownames = FALSE,
allow_listing_download = FALSE)
})

output[["queries_raised_table"]] <- DT::renderDT({
req(query_data())
datatable_custom(selected_query_data()[, -1], table_names, rownames = FALSE)
datatable_custom(selected_query_data()[, -1], table_names, rownames = FALSE,
allow_listing_download = FALSE)
})

output[["report"]] <- downloadHandler(
Expand Down
5 changes: 5 additions & 0 deletions R/mod_review_form_tbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ mod_review_form_tbl_server <- function(
rename_vars = c("Review Status" = "o_reviewed", table_names),
rownames= FALSE,
title = title,
export_label = paste(
simplify_string(form),
ifelse(show_all(), "all_patients", r$subject_id),
sep = "."
),
escape = FALSE,
selection = "none",
callback = checkbox_callback,
Expand Down
3 changes: 2 additions & 1 deletion R/mod_start_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ mod_start_page_server <- function(id, r, rev_data, navinfo, all_forms, table_nam
tab <- datatable_custom(
dplyr::select(rev_data$overview(), -needs_review),
rename_vars = table_names,
callback = dblclick_to_form(ns("go_to_patient"))
callback = dblclick_to_form(ns("go_to_patient")),
allow_listing_download = FALSE
)
if(length(bold_rows) == 0) return(tab)
DT::formatStyle(
Expand Down
5 changes: 5 additions & 0 deletions inst/app/www/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
--cs-marking: #97b0f8;
}

.dataTables_wrapper .dt-buttons {
padding-left: 0.75em;
float: right;
}

.bslib-value-box .value-box-area {
padding: 0.1rem 0rem 0.1rem 1rem;
}
Expand Down
3 changes: 2 additions & 1 deletion inst/golem-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
golem_name: clinsight
golem_version: 0.1.1.9015
golem_version: 0.1.1.9016
app_prod: no
user_identification: test_user
study_data: !expr clinsight::clinsightful_data
Expand All @@ -11,6 +11,7 @@ default:
Medical Monitor: medical_monitor
Data Manager: data_manager
allow_to_review: [admin, medical_monitor]
allow_listing_download: TRUE
allow_query_inputs: TRUE
dev:
golem_wd: !expr golem::pkg_path()
Expand Down
10 changes: 10 additions & 0 deletions man/datatable_custom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 44 additions & 1 deletion tests/testthat/_snaps/app_feature_01/app-feature-1-002.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
"filter": "none",
"vertical": false,
"extensions": [
"Buttons",
"Scroller",
"ColReorder"
],
Expand Down Expand Up @@ -328,7 +329,15 @@
],
"rowCallback": "rowCallback",
"initComplete": "function() {\n$(this.api().table().container()).find('.header').html(\"Adverse events\")\n}",
"dom": "f<\"header h5\">ti",
"dom": "Bf<\"header h5\">ti",
"buttons": [
{
"extend": "excel",
"text": "<i class=\"fa-solid fa-download\"><\/i>",
"filename": "clinsight.adverse_events.BEL_04_772",
"title": "adverse_events.BEL_04_772 | extracted from ClinSight"
}
],
"order": [

],
Expand Down Expand Up @@ -423,6 +432,40 @@
"attachment": null,
"all_files": true
},
{
"name": "jszip",
"version": "1.13.6",
"src": {
"href": "jszip-1.13.6"
},
"meta": null,
"script": "jszip.min.js",
"stylesheet": null,
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-buttons-bootstrap5",
"version": "1.13.6",
"src": {
"href": "dt-ext-buttons-bootstrap5-1.13.6"
},
"meta": null,
"script": [
"js/dataTables.buttons.min.js",
"js/buttons.html5.min.js",
"js/buttons.colVis.min.js",
"js/buttons.print.min.js",
"js/buttons.bootstrap5.min.js"
],
"stylesheet": "css/buttons.bootstrap5.min.css",
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-scroller-bootstrap5",
"version": "1.13.6",
Expand Down
Binary file modified tests/testthat/_snaps/app_feature_01/app-feature-1-002_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 44 additions & 1 deletion tests/testthat/_snaps/app_feature_01/app-feature-1-003.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
"filter": "none",
"vertical": false,
"extensions": [
"Buttons",
"Scroller",
"ColReorder"
],
Expand Down Expand Up @@ -328,7 +329,15 @@
],
"rowCallback": "rowCallback",
"initComplete": "function() {\n$(this.api().table().container()).find('.header').html(\"Adverse events\")\n}",
"dom": "f<\"header h5\">ti",
"dom": "Bf<\"header h5\">ti",
"buttons": [
{
"extend": "excel",
"text": "<i class=\"fa-solid fa-download\"><\/i>",
"filename": "clinsight.adverse_events.BEL_04_772",
"title": "adverse_events.BEL_04_772 | extracted from ClinSight"
}
],
"order": [

],
Expand Down Expand Up @@ -423,6 +432,40 @@
"attachment": null,
"all_files": true
},
{
"name": "jszip",
"version": "1.13.6",
"src": {
"href": "jszip-1.13.6"
},
"meta": null,
"script": "jszip.min.js",
"stylesheet": null,
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-buttons-bootstrap5",
"version": "1.13.6",
"src": {
"href": "dt-ext-buttons-bootstrap5-1.13.6"
},
"meta": null,
"script": [
"js/dataTables.buttons.min.js",
"js/buttons.html5.min.js",
"js/buttons.colVis.min.js",
"js/buttons.print.min.js",
"js/buttons.bootstrap5.min.js"
],
"stylesheet": "css/buttons.bootstrap5.min.css",
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-scroller-bootstrap5",
"version": "1.13.6",
Expand Down
Loading

0 comments on commit 4fbccfd

Please sign in to comment.