Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-ebs-ext committed Jul 21, 2024
1 parent 70338dc commit 03fedf4
Show file tree
Hide file tree
Showing 77 changed files with 7,594 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
R/write_mod_signature.R
.*Rproj
^\.Rproj\.user$
^LICENSE$
^LICENSE\.md$
^README\.Rmd$
^_pkgdown\.yml$
^docs$
^pkgdown$
.lintr
_tests_
^.*\.Rproj$
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @boehringer-ingelheim/davinci
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Checks 🧩

on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
push:
branches:
- main
workflow_dispatch:

jobs:
run-shared-ci:
name: Shared
uses: boehringer-ingelheim/dv.templates/.github/workflows/shared_ci.yml@main
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode
.Rproj.user
.Rhistory
*.Rproj
*.swp
*.sh
.vimlocal
docs
shiny_bookmarks
inst/validation/validation_report.html
tests/test-out.xml
21 changes: 21 additions & 0 deletions .lintr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
linters <- lintr::default_linters # -[ diff with dv.templates 3ca8d7a10cfc7ad2307644dcac603e1f1f0feb72]-
linters <- lintr::modify_defaults(
linters
, line_length_linter = NULL # we see how long lines are when we write them
, indentation_linter = NULL
, trailing_whitespace_linter = NULL
, cyclocomp_linter = NULL # prevents trivial amount of nesting and long but straightforward functions
, object_name_linter = NULL # we have reasons to capitalize. nobody in our team CamelCase. shiny does
, object_length_linter = NULL # we don't type long var names just because
, pipe_continuation_linter = NULL # wickham being overly prescriptive
, trailing_blank_lines_linter = NULL # natural extension of trailing_whitespace_linter, present on the template
)

if(identical(Sys.getenv('CI'), "true")){
linters <- lintr::modify_defaults(
linters
, object_usage_linter = NULL # R lacks var declarations; it's easy to assign to the wrong variable by mistake
) # We only disable this lint rule on github because it fails there because
} # of a long-standing lintr bug

linters
47 changes: 47 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Package: dv.papo
Title: Patient Profile
Version: 2.0.0
Date: 2024-07-02
Authors@R:
c(person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")),
person(given = "Korbinian",
family = "Matthias",
role = c("cre"),
email = "[email protected]"),
person(given = "Miguel",
family = "Lechón",
role = c("aut"),
email = "[email protected]"),
person(given = "Yuzheng",
family = "Ou",
role = "aut")
)
Description: Patient Profile Module.
License: Apache License (>= 2)
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.0
Depends:
R (>= 4.1.0)
Imports:
checkmate,
DT,
ggplot2,
plotly,
rlang,
shiny,
shinyWidgets,
fontawesome
Suggests:
dv.manager (>= 2.1.0),
knitr,
safetyData,
shinytest2,
testthat,
jsonlite,
withr,
dplyr
Remotes: boehringer-ingelheim/dv.manager@main
VignetteBuilder: knitr
Config/testthat/edition: 3
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Boehringer-Ingelheim Pharma GmbH & Co.KG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
14 changes: 14 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by roxygen2: do not edit by hand

S3method("$",pack_of_constants)
S3method("[",pack_of_constants)
S3method("[[",pack_of_constants)
export(explorer_app)
export(mock_patient_profile_UI)
export(mock_patient_profile_app)
export(mock_patient_profile_server)
export(mock_with_mm_app)
export(mod_patient_profile)
export(mod_patient_profile_UI)
export(mod_patient_profile_server)
importFrom(rlang,.data)
62 changes: 62 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# dv.papo 2.0.0

- Major API redesign with the following breaking changes `mod_patient_profile()`:
- The name of the subject-level dataset is now explicitly provided through the `subject_level_dataset_name` parameter.
- `key` has been renamed to `subjid_var`.
- `pt_info` is now called `summary` and has been simplified. It only allows to specify a _single_ dataframe
from which to select columns. Its `row_item` submember has been renamed to `column_count`.
- `tables` is now called `listings` and is a named list of pairs of `dataset` and `default_vars`. This allows
control over which columns are shown by default for each dataset.
- The legacy `basic_info`, `vlines` and `plots` are all now collected under a single `plots` parameter. They have been
restructured for clarity and are also accompanied by a `palette` field that makes it possible for the caller to
specify individual colors. See the main vignette for more information.
- All parameters referring to Study Days have been reframed to point to absolute days. This ensures consistency of the
time axis of plots.
- The module now accepts datetimes as well as dates for easier joint configuration with `dv.clinlines`. The "time"
part of datetimes is simply discarded.
- Configuration helper functions have been removed in favor of documentation templates.
- `jumping_vars` is now called `sender_ids` for consistency across davinci modules.

- The module is now easier to configure because it:
- Makes all of its main three sections (`summary`, `listings` and `plots`) optional, which facilitates having a base
working configuration.
- Provides clear start-up warnings and messages when the module is misconfigured with respect to input datasets.
The app creator can safely assume that if no such message appears, the module will not misbehave when interacted
with due to misconfiguration. Any remaining error rests solely on the module developer's shoulders or on those of
the platform provider.

- Bug fixes:
- Day labels now follow the standard CDISC behavior of skipping day 0 on plots (day 1 refers to the Treatment Start
Date; day -1 is the day before).
- Vertical lines now cross all plots.


# dv.papo 1.0.2

- bugfix: With the new version of dv.filter 2.1.0 the patient selector did not work. This is now fixed.

# dv.papo 1.0.1

- bugfix: Updating patient selector after jumping from another module didn't work. This is now fixed.

# dv.papo 1.0.0

- Primary interface: `mod_patient_profile()`

- Launch mock app for demo and testing via `mock_with_mm_app()`

- Enables bookmarking state of Shiny app via URL

# dv.papo 0.1

* Plot section added.

# dv.papo 0.0.2

* Shinydashboard element removed.

# dv.papo 0.0.1

* Added a `NEWS.md` file to track changes to the package.


76 changes: 76 additions & 0 deletions R/aaa_preface.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# THIS FILE IS NAMED aaa_preface.R SO IT IS LOADED BEFORE ALL OTHER FILES
# DO NOT CHANGE ITS NAME. IT MUST BE THE FIRST ONE ALPHABETICALLY.

#' Build a collection of named constants
#'
#' @param ... Named parameters to be collected as constants
#'
#' @keywords internal
#'
#' @details
#' Shiny uses strings as IDs to link UI and server elements. E.g:
#' foo_UI(id = ns("foo")) ...
#' foo_server(id = "foo")
#'
#' This pattern makes it easy for programmers to fall on the trap of modifying one instance of the string literal "foo"
#' without modifying the rest and be unaware of the problem until a bug is hit. It's also easy to mistakes uses of "foo"
#' as an identifier from other uses (text labels, ...) when, as it's often the case, the parameter is not explicitly
#' named.
#' One easy fix consists in using global variables instead of plain string literals. In the case of the previous
#' example, that would mean:
#' ID_FOO <- "foo"
#' foo_UI(ns(ID_FOO)) ...
#' foo_server(ID_FOO)
#'
#' That simple addition makes the purpose of ID_FOO clear and also fails gracefully when not all ID_FOO instances are
#' updated synchronously along a codebase. It has the drawback of polluting the global namespace with identifier
#' variables. That's easily solved by creating a container of constants, which is the purpose of this pack_of_constants
#' alias.
#' ID <- pack_of_constants(FOO = "foo", BAR = "bar")
#' ID$FOO
#' "foo"
#' ID$BA
#' Error in `$.pack_of_constants`(ID, BA) :
#' Pack of constants "ID" does not contain "BA"
#'
#' The pack of constants is a plain named list that enforces that all elements have unique, non-null names.
#' It is tagged as an S3 object to override its extraction operators.
#'
#' The use of checkmate is unnecessary, but it's a Good Library(TM) and your module should rely on it anyways
pack_of_constants <- function(...) {
result <- list(...)
checkmate::assert_list(result, any.missing = FALSE, names = "unique")
class(result) <- c("pack_of_constants", class(result))
result
}

#' Extract constant from pack
#'
#' @param pack pack_of_constants
#' @param name target constant
#'
#' This function differs from the base list extraction method in that it avoids partial matching of keys and throws
#' an error if the looked-for constant is not contained within the pack.
#'
#' @keywords internal
#'
#' @export
`$.pack_of_constants` <- function(pack, name) {
checkmate::assert_true(name %in% names(pack), .var.name = paste0(deparse(substitute(pack)), "$", name))
NextMethod()
}

# This exports are recent requirement for devtools check https://github.com/r-lib/roxygen2/issues/1592#issue-2121199122
#'
#' @keywords internal
#'
#' @export
`[[.pack_of_constants` <- `$.pack_of_constants`

#' @keywords internal
#' @export
`[.pack_of_constants` <- function(pack, name) {
stop("Invalid pack_of_constants method")
}

poc <- pack_of_constants
Loading

0 comments on commit 03fedf4

Please sign in to comment.