Skip to content

Commit

Permalink
Merge pull request #22 from acornamr/dev
Browse files Browse the repository at this point in the history
v2.6.1
  • Loading branch information
ocelhay committed May 28, 2023
2 parents 7d01f5b + d4132dd commit c801f6e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.Ruserdata
*.DS_Store
*.dcf
.Renviron
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Package: acorn
Type: Package
Title: A Dashboard for ACORN AMR Data
Version: 2.6.0
Version: 2.6.1
Authors@R: c(person(given = "Olivier", family = "Celhay",
email = "olivier.celhay@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "https://orcid.org/0000-0002-2971-9110")),
role = c("aut", "cre"),
comment = c(ORCID = "https://orcid.org/0000-0002-2971-9110")),
person(given = "Paul", family = "Turner",
email = "Pault@tropmedres.ac",
role = c("aut")))
Expand Down
24 changes: 15 additions & 9 deletions inst/acorn/app.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app_version <- "2.6.0" # Make sure that the app version is identical in DESCRIPTION
app_version <- "2.6.1" # Make sure that the app version is identical in DESCRIPTION
session_start_time <- format(Sys.time(), "%Y-%m-%d_%HH%M")

# IMPORTANT: ensure that there is a match between the calls below and:
Expand Down Expand Up @@ -43,13 +43,14 @@ choices_datamanagement <- c("Generate and load .acorn </br> from clinical and la
"Load .acorn </br> from local file",
"Info on </br> loaded .acorn")

code_sites <- c("Run Demo",
"Upload Local .acorn",
readr::read_csv(
file = "./www/data/ACORN2_site_codes.csv",
show_col_types = FALSE) |>
pull(site_code)
)
site_choices <- readr::read_csv(
file = "./www/data/ACORN2_site_codes.csv",
show_col_types = FALSE) |>
shinyWidgets::prepare_choices(
label = site_code,
value = site_code,
group_by = country
)

aware <- read.csv(
file = "./www/data/AWaRe_WHO_2021.csv") |>
Expand Down Expand Up @@ -229,7 +230,12 @@ ui <- page(
div(class = "well",
h5(class = "text_center", i18n$t("Please log in")),
div(class = "text-center", i18n$t("(To log out, close the app.)")),
pickerInput("cred_site", "", choices = code_sites, selected = "Run Demo"),
shinyWidgets::virtualSelectInput(
"cred_site",
"",
site_choices,
hasOptionDescription = TRUE
),
conditionalPanel("input.cred_site != 'Run Demo' && input.cred_site != 'Upload Local .acorn'", div(
textInput("cred_user", tagList(icon("user"), i18n$t("User")), placeholder = "enter user name"),
passwordInput("cred_password", tagList(icon("unlock-alt"), i18n$t("Password")), placeholder = "enter password")
Expand Down
5 changes: 3 additions & 2 deletions inst/acorn/www/data/ACORN2_site_codes.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
site_code,country,city,site_name,lat,lon,acorn_network,comment
site_code,country,city,site_name,lat,lon,acorn_network,comment
KH001,Cambodia,Siem Reap,Angkor Hospital for Children,13.3579855,103.8567,TRUE,
GH001,Ghana,Accra,Korle-Bu Teaching Hospital,5.5372605,-0.22683187,TRUE,
GH002,Ghana,Accra,37 Military Hospital,5.588754786,-0.18410816,TRUE,
Expand All @@ -18,4 +18,5 @@ NG002,Nigeria,Ife,"Obafemi Awolowo University Teaching Hospital, Ife",7.49053224
NG003,Nigeria,Igbo-ora,Ibarapa Rural lab,7.447033504,3.276880573,FALSE,
VN001,Vietnam,Hanoi,National Hospital for Tropical Diseases,21.00231646,105.8389495,TRUE,
VN002,Vietnam,Hue,Hue Central Hospital (Bệnh viện Trung Ương Huế),16.4626133,107.5879476,FALSE,
VN003,Vietnam,Ho Chi Minh City,Children's Hospital 2 (Bệnh viện Nhi Đồng 2),10.7810848,106.702319,FALSE,
VN003,Vietnam,Ho Chi Minh City,Children's Hospital 2 (Bệnh viện Nhi Đồng 2),10.7810848,106.702319,FALSE,
PH001,Philippine,Manila,Philippine General Hospital,,,FALSE,
53 changes: 29 additions & 24 deletions misc/create_encrypted_credentials.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
creds <- readxl::read_excel("/Users/olivier/Documents/Projets/ACORN/Data/ACORN2_cred.xlsx",
sheet = "cred") |>
filter(!is.na(site))
# INSTRUCTIONS:
# - use the R commands below to generate one .rds file per line in ACORN2_cred.xlsx
# - add encrypted_cred_XXX_YYY.rds to the S3 "shared-acornamr" folder
# - rename encrypted_cred_demo.rds into encrypted_cred_demo_demo.rds
# - add encrypted_cred_demo.rds to the app "www/cred" folder

dir <- "/Users/olivier/Documents/Consultances/ACORN/Data"

creds <- readxl::read_excel(
path = glue::glue("{dir}/ACORN2_cred.xlsx"),
sheet = "cred") |>
dplyr::filter(
!is.na(site)
)


for (i in 1:nrow(creds)) {
user <- creds[i, ]

cred <- serialize(
object = list(site = user$site,
user = user$user,
# REDCap
redcap_access = user$redcap_access,
redcap_uri = user$redcap_uri,
redcap_f01f05_api = user$redcap_f01f05_api,
redcap_hai_api = user$redcap_hai_api,
# AWS S3
aws_access = user$aws_access,
aws_bucket = user$aws_bucket,
aws_region = user$aws_region,
aws_key = user$aws_key,
aws_secret = user$aws_secret
object = list(
site = user$site,
user = user$user,
# REDCap
redcap_access = user$redcap_access,
redcap_uri = user$redcap_uri,
redcap_f01f05_api = user$redcap_f01f05_api,
redcap_hai_api = user$redcap_hai_api,
# AWS S3
aws_access = user$aws_access,
aws_bucket = user$aws_bucket,
aws_region = user$aws_region,
aws_key = user$aws_key,
aws_secret = user$aws_secret
),
connection = NULL)

encrypted_cred <- openssl::aes_cbc_encrypt(cred, key = openssl::sha256(charToRaw(user$pwd)))
saveRDS(encrypted_cred, glue::glue("/Users/olivier/Documents/Projets/ACORN/Data/ACORN2_creds/encrypted_cred_{user$site}_{user$user}.rds"))
saveRDS(encrypted_cred, glue::glue("{dir}/ACORN2_creds/encrypted_cred_{user$site}_{user$user}.rds"))
}

# Instructions:
# encrypted_cred_XXX_YYY.rds files should be added to the "shared-acornamr" folder
# "encrypted_cred_demo.rds" should be added to the "www/cred" folder.
# "shared_acornamr_key.rds" and "share-acornamr_sec.rds" should be added to the "www/cred" folder.
# They can be generated with the commands:
# saveRDS("COPY_KEY_HERE", file = "/Users/olivier/Documents/Projets/ACORN/Data/ACORN2_creds/shared_acornamr_key.rds")
# saveRDS("COPY_SECRET_HERE", file = "/Users/olivier/Documents/Projets/ACORN/Data/ACORN2_creds/shared_acornamr_sec.rds")
14 changes: 7 additions & 7 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@
},
"commonmark": {
"Package": "commonmark",
"Version": "1.8.0",
"Version": "1.9.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "2ba81b120c1655ab696c935ef33ea716",
"Hash": "d691c61bff84bd63c383874d2d0c3307",
"Requirements": []
},
"cpp11": {
Expand Down Expand Up @@ -955,12 +955,12 @@
},
"markdown": {
"Package": "markdown",
"Version": "1.1",
"Version": "1.6",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "61e4a10781dd00d7d81dd06ca9b94e95",
"Hash": "c0e8495f796d73f2d2e1a8c6964d67e8",
"Requirements": [
"mime",
"commonmark",
"xfun"
]
},
Expand Down Expand Up @@ -1690,10 +1690,10 @@
},
"xfun": {
"Package": "xfun",
"Version": "0.31",
"Version": "0.39",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "a318c6f752b8dcfe9fb74d897418ab2b",
"Hash": "8f56e9acb54fb525e66464d57ab58bcb",
"Requirements": []
},
"xml2": {
Expand Down

0 comments on commit c801f6e

Please sign in to comment.