Skip to content

Commit

Permalink
Merge pull request #142 from openpharma/jt-resolve_merge_conflicts_main
Browse files Browse the repository at this point in the history
Resolve merge conflicts `main`
  • Loading branch information
LDSamson authored Nov 20, 2024
2 parents f271502 + a9488cc commit 906daf8
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 89 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.0.9008
Version: 0.1.1.9008
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-6252-7639")),
Expand Down
13 changes: 11 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## Changed

- Added `pkgdown` GHA workflow to automatically update documentation site with PRs & pushes to `main` and `dev`
- Generalized `merge_meta_with_data()` to allow user-defined processing functions.
- Added a feature where, in applicable tables, a user can navigate to a form by double-clicking a table row.
- Fixed warnings in `apply_edc_specific_changes` due to the use of a vector within `dplyr::select`.
Expand All @@ -12,7 +11,17 @@

## Bug fixes

- When using the `shinyproxy` deployment configuration, the user name is now expected to be base64 encoded, and will now be base64 encoded by `clinsight` by default, so that the app can also handle non-ASCII signs in user names that are stored in HTTP headers. To display the user name correctly, use base64 encoding in the `application.yml` in ShinyProxy settings (for example: `http-headers.X_SP_USERNAME: "#{T(java.util.Base64).getEncoder().encodeToString(oidcUser.getFullName().getBytes())}"`).

# clinsight 0.1.1

## Changed

- Added `pkgdown` GHA workflow to automatically update documentation site with pushes to `main`

## Bug fixes

- Fixed inconsistencies in app messages when saving a review for a form with items with different review states (with some items reviewed previously by a different reviewer, and some items being completely new).
- Fixed a bug where clinsight deployed with `shinyproxy` would crash when a user with non-ASCII letters in their name would attempt to login. In this new version, when using the `shinyproxy` deployment configuration, the user name is now expected to be base64 encoded, and will now be base64 encoded by `clinsight` by default, so that the app can also handle non-ASCII signs in user names that are stored in HTTP headers. To display the user name correctly, use base64 encoding in the `application.yml` in ShinyProxy settings (for example: `http-headers.X_SP_USERNAME: "#{T(java.util.Base64).getEncoder().encodeToString(oidcUser.getFullName().getBytes())}"`).

# clinsight 0.1.0

Expand Down
2 changes: 1 addition & 1 deletion R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' the `header widgets` ([mod_header_widgets_server()]), and the `query page`
#' ([mod_queries_server()])
#'
#' @param input,output,session Internal parameters for {shiny}.
#' @param input,output,session Internal parameters for `shiny`.
#' @seealso [app_ui()], [run_app()]
#'
app_server <- function(
Expand Down
2 changes: 1 addition & 1 deletion R/fct_data_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ get_form_level_data <- function(
#' @param value_column A string containing the column name with the item values.
#' @param id_column The columns identifying a unique participant (subject_id).
#'
#' @return as data frame with an additional column named "base_{varname}".
#' @return as data frame with an additional column named "base_`varname`".
#' @export
#' @examples
#' library(dplyr)
Expand Down
1 change: 0 additions & 1 deletion R/fct_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -755,4 +755,3 @@ decode_base64 <- function(
}
rawToChar(decoded)
}

2 changes: 2 additions & 0 deletions R/mod_query_add.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ mod_query_add_server <- function(
db_path, query_id = new_query$query_id, n = new_query$n
)
query_in_db <- unique(query_in_db[names(new_query)])
query_in_db <- query_in_db[query_in_db$timestamp == new_query$timestamp[1], ]

if(identical(new_query, query_in_db)){
r$query_data <- dplyr::bind_rows(r$query_data, new_query)
}
Expand Down
27 changes: 19 additions & 8 deletions R/mod_review_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,34 @@ mod_review_forms_server <- function(
tables = "all_review_data"
)

review_row_db <- db_get_review(
# Contains multiple rows, one for each item.
updated_rows_db <- db_get_review(
db_path, subject = review_row$subject_id, form = review_row$item_group
)
review_row_db <- unique(review_row_db[names(review_row)])
)[c(names(review_row), "event_name", "item_name", "form_repeat")]
# Within a form, only items with a changed review state are updated and
# contain the new (current) time stamp.
updated_rows_db <- updated_rows_db[
updated_rows_db$timestamp == review_row$timestamp[1],
]

review_row_db <- unique(updated_rows_db[names(review_row)])
if(identical(review_row_db, review_row)){
cat("Update review data and status in app\n")
r$review_data <- r$review_data |>
dplyr::rows_update(review_row, by = c("subject_id", "item_group"))
dplyr::rows_update(
updated_rows_db,
by = c("subject_id", "item_group", "event_name", "item_name", "form_repeat")
)
}

review_row_memory <- review_row |>
dplyr::left_join(r$review_data, by = names(review_row))
review_row_memory <- unique(review_row_memory[names(review_row)])
updated_items_memory <- sort(with(r$review_data, item_name[
reviewer == review_row$reviewer[1] & timestamp == review_row$timestamp[1]
]))
updated_items_db <- sort(updated_rows_db$item_name)

review_save_error(any(
!identical(review_row_db, review_row),
!identical(review_row_memory, review_row_db)
!identical(updated_items_db, updated_items_memory)
))

if(review_save_error()){
Expand Down
2 changes: 1 addition & 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.0.9008
golem_version: 0.1.1.9008
app_prod: no
user_identification: test_user
study_data: !expr clinsight::clinsightful_data
Expand Down
2 changes: 1 addition & 1 deletion man/app_server.Rd

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

2 changes: 1 addition & 1 deletion man/get_base_value.Rd

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

52 changes: 32 additions & 20 deletions tests/testthat/_snaps/mod_review_forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,48 @@
Code
print(dplyr::select(r$review_data, -timestamp), width = Inf)
Output
# A tibble: 2 x 12
# A tibble: 4 x 12
id subject_id event_name item_group form_repeat item_name
<int> <chr> <chr> <chr> <dbl> <chr>
1 2 361 Visit 5 Vital signs 4 Systolic blood pressure
2 1 885 Any visit Adverse events 1 AE Number
event_date edit_date_time reviewed comment reviewer
<chr> <chr> <chr> <chr> <chr>
1 2023-07-01 2023-08-30 01:01:01 No "" ""
2 2023-08-15 2023-09-30 01:01:01 Yes "" "test_name (Medical Monitor)"
status
<chr>
1 new
2 old
1 3 361 Visit 5 Vital signs 4 Systolic blood pressure
2 4 361 Visit 6 Vital signs 5 Systolic blood pressure
3 1 885 Any visit Adverse events 1 Atrial Fibrillation
4 2 885 Any visit Adverse events 2 Cystitis
event_date edit_date_time reviewed comment
<chr> <chr> <chr> <chr>
1 2023-07-01 2023-08-30 01:01:01 Yes "another comment"
2 2023-08-01 2023-08-02 01:01:01 No ""
3 2023-08-15 2023-09-30 01:01:01 Yes "test comment"
4 2023-09-01 2023-10-01 01:01:01 Yes ""
reviewer status
<chr> <chr>
1 "Reviewer 2" old
2 "" new
3 "Reviewer 1" old
4 "test_name (Medical Monitor)" old

---

Code
print(dplyr::select(r$review_data, -timestamp), width = Inf)
Output
# A tibble: 2 x 12
# A tibble: 4 x 12
id subject_id event_name item_group form_repeat item_name
<int> <chr> <chr> <chr> <dbl> <chr>
1 2 361 Visit 5 Vital signs 4 Systolic blood pressure
2 1 885 Any visit Adverse events 1 AE Number
event_date edit_date_time reviewed comment
<chr> <chr> <chr> <chr>
1 2023-07-01 2023-08-30 01:01:01 No ""
2 2023-08-15 2023-09-30 01:01:01 No "test review"
1 3 361 Visit 5 Vital signs 4 Systolic blood pressure
2 4 361 Visit 6 Vital signs 5 Systolic blood pressure
3 1 885 Any visit Adverse events 1 Atrial Fibrillation
4 2 885 Any visit Adverse events 2 Cystitis
event_date edit_date_time reviewed comment
<chr> <chr> <chr> <chr>
1 2023-07-01 2023-08-30 01:01:01 Yes "another comment"
2 2023-08-01 2023-08-02 01:01:01 No ""
3 2023-08-15 2023-09-30 01:01:01 No "test review"
4 2023-09-01 2023-10-01 01:01:01 No "test review"
reviewer status
<chr> <chr>
1 "" new
2 "test_name (Medical Monitor)" new
1 "Reviewer 2" old
2 "" new
3 "test_name (Medical Monitor)" new
4 "test_name (Medical Monitor)" new

29 changes: 14 additions & 15 deletions tests/testthat/fixtures/make_review_testdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@

make_review_testdata <- function(){
data.frame(
subject_id = c("885", "361"),
event_name = c("Any visit", "Visit 5"),
item_group = c("Adverse events", "Vital signs"),
form_repeat = c(1, 4),
item_name = c("AE Number", "Systolic blood pressure"),
event_date = c("2023-08-15", "2023-07-01"),
edit_date_time = c("2023-09-30 01:01:01", "2023-08-30 01:01:01")
subject_id = c("885", "885", "361", "361"),
event_name = c("Any visit", "Any visit", "Visit 5", "Visit 6"),
item_group = c("Adverse events", "Adverse events", "Vital signs", "Vital signs"),
form_repeat = c(1, 2, 4, 5),
item_name = c("Atrial Fibrillation", "Cystitis", "Systolic blood pressure", "Systolic blood pressure"),
event_date = c("2023-08-15", "2023-09-01", "2023-07-01", "2023-08-01"),
edit_date_time = c("2023-09-30 01:01:01", "2023-10-01 01:01:01", "2023-08-30 01:01:01", "2023-08-02 01:01:01")
) |>
dplyr::mutate(
reviewed = "No",
comment = "",
reviewer = "",
timestamp = "2000-01-01 01:01:01",
status = "new"
reviewed = c("Yes", "No", "Yes", "No"),
comment = c("test comment", "", "another comment", ""),
reviewer = c("Reviewer 1", "", "Reviewer 2", ""),
timestamp = c("2000-01-01 01:01:01", "", "2023-09-01 01:01:01", ""),
status = c("old", "new", "old", "new")
)
}

fixture_path <- system.file("tests/testthat/fixtures", package = "clinsight")
db_temp_connect(paste0(fixture_path, "/review_testdb.sqlite"), {
if ("all_review_data" %in% DBI::dbListTables(con))
DBI::dbRemoveTable(con, "all_review_data")
unlink(file.path(fixture_path, "review_testdb.sqlite"))
db_temp_connect(file.path(fixture_path, "review_testdb.sqlite"), {
db_add_primary_key(con, "all_review_data", make_review_testdata())
db_add_log(con)
})
Binary file modified tests/testthat/fixtures/review_testdb.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-mod_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe(
app$click("test-report-create_report")
app$wait_for_idle(800)
app$set_inputs("test-report-include_from_date" = "2023-01-01")
app$wait_for_idle()
app$wait_for_idle(800)
app$expect_values()

pdf_report_path <- app$get_download("test-report-report")
Expand Down
Loading

0 comments on commit 906daf8

Please sign in to comment.