From 199923cfe2d8999a063ba6f7d6edae6031d0cf6e Mon Sep 17 00:00:00 2001 From: Olivier Date: Mon, 1 May 2023 01:50:11 -0400 Subject: [PATCH 1/4] refactor: script encryption --- .gitignore | 1 + misc/create_encrypted_credentials.R | 53 ++++++++++++++++------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 6056c31..fcc3440 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .Ruserdata *.DS_Store *.dcf +.Renviron diff --git a/misc/create_encrypted_credentials.R b/misc/create_encrypted_credentials.R index b9ac952..dd2bb43 100644 --- a/misc/create_encrypted_credentials.R +++ b/misc/create_encrypted_credentials.R @@ -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") From b83ab08f3d1ff6dda42af1577492cf2f500b4767 Mon Sep 17 00:00:00 2001 From: Olivier Date: Mon, 1 May 2023 01:50:35 -0400 Subject: [PATCH 2/4] feat: add ph001 to site codes --- inst/acorn/www/data/ACORN2_site_codes.csv | 43 ++++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/inst/acorn/www/data/ACORN2_site_codes.csv b/inst/acorn/www/data/ACORN2_site_codes.csv index 998e6f8..4a2caa6 100644 --- a/inst/acorn/www/data/ACORN2_site_codes.csv +++ b/inst/acorn/www/data/ACORN2_site_codes.csv @@ -1,21 +1,22 @@ -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, -ID001,Indonesia,Jakarta,Pelni Hospital,-6.193081032,106.8036125,FALSE, -ID002,Indonesia,Jakarta,RSCM national referral hospital,-6.197401331,106.8468107,FALSE, -ID003,Indonesia,Depok,RSUI teaching hospital of UI,-6.372964883,106.8295336,FALSE, -KE001,Kenya,Kitale,Kitale County Referral Hospital,1.015953552,35.00895666,TRUE, -KE002,Kenya,Bungoma,Bungoma County Referral Hospital,0.573182439,34.5602382,TRUE, -LA001,Laos,Vientiane,Mahosot Hospital,17.96049105,102.6124687,TRUE, -LA002,Laos,Vientiane,Settathirarath Hospital,17.93451608,102.6485455,TRUE, -MW001,Malawi,Blantyre,Queen Elizabeth Central Hospital,-15.80284645,35.02164226,FALSE, -NP001,Nepal,Kathmandhu,Patan Hospital,27.66844451,85.32058976,TRUE, -NP002,Nepal,Kathmandhu,Kathmandu Model Hospital (KMH),27.70272427,85.32007537,TRUE, -NP003,Nepal,Dharan,B.P. Koirala Institute of Health Sciences (BPKIHS),26.81241414,87.26826434,FALSE,added Sept 2022 -NG001,Nigeria,Ibadan,"University College Hospital, Ibadan",7.401981245,3.902033841,TRUE, -NG002,Nigeria,Ife,"Obafemi Awolowo University Teaching Hospital, Ife",7.490532242,4.54500564,TRUE, -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, \ No newline at end of file +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, +ID001,Indonesia,Jakarta,Pelni Hospital,-6.193081032,106.8036125,FALSE, +ID002,Indonesia,Jakarta,RSCM national referral hospital,-6.197401331,106.8468107,FALSE, +ID003,Indonesia,Depok,RSUI teaching hospital of UI,-6.372964883,106.8295336,FALSE, +KE001,Kenya,Kitale,Kitale County Referral Hospital,1.015953552,35.00895666,TRUE, +KE002,Kenya,Bungoma,Bungoma County Referral Hospital,0.573182439,34.5602382,TRUE, +LA001,Laos,Vientiane,Mahosot Hospital,17.96049105,102.6124687,TRUE, +LA002,Laos,Vientiane,Settathirarath Hospital,17.93451608,102.6485455,TRUE, +MW001,Malawi,Blantyre,Queen Elizabeth Central Hospital,-15.80284645,35.02164226,FALSE, +NP001,Nepal,Kathmandhu,Patan Hospital,27.66844451,85.32058976,TRUE, +NP002,Nepal,Kathmandhu,Kathmandu Model Hospital (KMH),27.70272427,85.32007537,TRUE, +NP003,Nepal,Dharan,B.P. Koirala Institute of Health Sciences (BPKIHS),26.81241414,87.26826434,FALSE,added Sept 2022 +NG001,Nigeria,Ibadan,"University College Hospital, Ibadan",7.401981245,3.902033841,TRUE, +NG002,Nigeria,Ife,"Obafemi Awolowo University Teaching Hospital, Ife",7.490532242,4.54500564,TRUE, +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, +PH001,Philippines,PH001 site city,PH001 site name,,,FALSE, \ No newline at end of file From c51d14e98802daa7ee7b4d12cce53188fd154a33 Mon Sep 17 00:00:00 2001 From: Olivier Date: Sat, 6 May 2023 17:16:11 -0700 Subject: [PATCH 3/4] feat: add ph001 --- DESCRIPTION | 5 +-- inst/acorn/app.R | 25 ++++++++----- inst/acorn/www/data/ACORN2_site_codes.csv | 44 +++++++++++------------ renv.lock | 14 ++++---- 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a550343..7c46235 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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"))) diff --git a/inst/acorn/app.R b/inst/acorn/app.R index b88f1ab..e8eba80 100644 --- a/inst/acorn/app.R +++ b/inst/acorn/app.R @@ -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: @@ -43,13 +43,15 @@ choices_datamanagement <- c("Generate and load .acorn
from clinical and la "Load .acorn
from local file", "Info on
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, + description = site_name + ) aware <- read.csv( file = "./www/data/AWaRe_WHO_2021.csv") |> @@ -229,7 +231,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") diff --git a/inst/acorn/www/data/ACORN2_site_codes.csv b/inst/acorn/www/data/ACORN2_site_codes.csv index 4a2caa6..06b616c 100644 --- a/inst/acorn/www/data/ACORN2_site_codes.csv +++ b/inst/acorn/www/data/ACORN2_site_codes.csv @@ -1,22 +1,22 @@ -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, -ID001,Indonesia,Jakarta,Pelni Hospital,-6.193081032,106.8036125,FALSE, -ID002,Indonesia,Jakarta,RSCM national referral hospital,-6.197401331,106.8468107,FALSE, -ID003,Indonesia,Depok,RSUI teaching hospital of UI,-6.372964883,106.8295336,FALSE, -KE001,Kenya,Kitale,Kitale County Referral Hospital,1.015953552,35.00895666,TRUE, -KE002,Kenya,Bungoma,Bungoma County Referral Hospital,0.573182439,34.5602382,TRUE, -LA001,Laos,Vientiane,Mahosot Hospital,17.96049105,102.6124687,TRUE, -LA002,Laos,Vientiane,Settathirarath Hospital,17.93451608,102.6485455,TRUE, -MW001,Malawi,Blantyre,Queen Elizabeth Central Hospital,-15.80284645,35.02164226,FALSE, -NP001,Nepal,Kathmandhu,Patan Hospital,27.66844451,85.32058976,TRUE, -NP002,Nepal,Kathmandhu,Kathmandu Model Hospital (KMH),27.70272427,85.32007537,TRUE, -NP003,Nepal,Dharan,B.P. Koirala Institute of Health Sciences (BPKIHS),26.81241414,87.26826434,FALSE,added Sept 2022 -NG001,Nigeria,Ibadan,"University College Hospital, Ibadan",7.401981245,3.902033841,TRUE, -NG002,Nigeria,Ife,"Obafemi Awolowo University Teaching Hospital, Ife",7.490532242,4.54500564,TRUE, -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, -PH001,Philippines,PH001 site city,PH001 site name,,,FALSE, \ No newline at end of file +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, +ID001,Indonesia,Jakarta,Pelni Hospital,-6.193081032,106.8036125,FALSE, +ID002,Indonesia,Jakarta,RSCM national referral hospital,-6.197401331,106.8468107,FALSE, +ID003,Indonesia,Depok,RSUI teaching hospital of UI,-6.372964883,106.8295336,FALSE, +KE001,Kenya,Kitale,Kitale County Referral Hospital,1.015953552,35.00895666,TRUE, +KE002,Kenya,Bungoma,Bungoma County Referral Hospital,0.573182439,34.5602382,TRUE, +LA001,Laos,Vientiane,Mahosot Hospital,17.96049105,102.6124687,TRUE, +LA002,Laos,Vientiane,Settathirarath Hospital,17.93451608,102.6485455,TRUE, +MW001,Malawi,Blantyre,Queen Elizabeth Central Hospital,-15.80284645,35.02164226,FALSE, +NP001,Nepal,Kathmandhu,Patan Hospital,27.66844451,85.32058976,TRUE, +NP002,Nepal,Kathmandhu,Kathmandu Model Hospital (KMH),27.70272427,85.32007537,TRUE, +NP003,Nepal,Dharan,B.P. Koirala Institute of Health Sciences (BPKIHS),26.81241414,87.26826434,FALSE,added Sept 2022 +NG001,Nigeria,Ibadan,"University College Hospital, Ibadan",7.401981245,3.902033841,TRUE, +NG002,Nigeria,Ife,"Obafemi Awolowo University Teaching Hospital, Ife",7.490532242,4.54500564,TRUE, +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, +PH001,Philippine,Manila,Philippine General Hospital,,,FALSE, \ No newline at end of file diff --git a/renv.lock b/renv.lock index 3bdf478..67fb46a 100644 --- a/renv.lock +++ b/renv.lock @@ -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": { @@ -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" ] }, @@ -1690,10 +1690,10 @@ }, "xfun": { "Package": "xfun", - "Version": "0.31", + "Version": "0.39", "Source": "Repository", "Repository": "CRAN", - "Hash": "a318c6f752b8dcfe9fb74d897418ab2b", + "Hash": "8f56e9acb54fb525e66464d57ab58bcb", "Requirements": [] }, "xml2": { From d4132dd586e57d2d5ab45cf0eabb45f819ce6cba Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 23 May 2023 19:20:18 -0700 Subject: [PATCH 4/4] feat: remove hospital name from dropdown --- inst/acorn/app.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inst/acorn/app.R b/inst/acorn/app.R index e8eba80..475292d 100644 --- a/inst/acorn/app.R +++ b/inst/acorn/app.R @@ -49,8 +49,7 @@ site_choices <- readr::read_csv( shinyWidgets::prepare_choices( label = site_code, value = site_code, - group_by = country, - description = site_name + group_by = country ) aware <- read.csv(