Skip to content

Commit

Permalink
Merge pull request #24 from OHDSI/develop
Browse files Browse the repository at this point in the history
Develop v007
  • Loading branch information
mdlavallee92 authored May 16, 2024
2 parents e1f0936 + ced111d commit 6f06202
Show file tree
Hide file tree
Showing 83 changed files with 238 additions and 256 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Ulysses
Title: Automate OHDSI Study Setup
Version: 0.0.6
Version: 0.0.7
Authors@R:
person("Martin", "Lavallee", , "[email protected]", role = c("aut", "cre"))
Description: Automates setup of OHDSI study and provides functions to assist on improving organization
Expand Down Expand Up @@ -28,7 +28,8 @@ Imports:
usethis,
whisker,
withr,
yaml
yaml,
RJSONIO
Suggests:
knitr,
rmarkdown,
Expand Down
112 changes: 58 additions & 54 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
Ulysses 0.0.6
Ulysses 0.0.7
=============

* correct start_study vignette
* add fix in initConfig
* fix importAtlasCohorts => use RJSONIO with digits
* change all keyring fns to use only db.
* update function to review credentials
* fix and simplify cohortManifest function #26
* fix migration bug #25

Ulysses 0.0.5
=============
* Add functions to import credentials
* Add functions to import ATLAS assets
* Write vignettes to creds and ATLAS
* add folder cohorts/conceptSets/json
# Ulysses 0.0.6

Ulysses 0.0.4
=============
* Finalize Directory
* Finalize meta fields for _study.yml
* Reconfigure `newOhdsiStudy()` with better meta inputs
* Add functions to interface with _study.yml
* Reroute makeFiles to directory and meta fields
* Add `makeMigrationsScript()` template
* Update study hub website format
* Update vignette
- correct start_study vignette
- add fix in initConfig

# Ulysses 0.0.5

Ulysses 0.0.3
=============
- Add functions to import credentials
- Add functions to import ATLAS assets
- Write vignettes to creds and ATLAS
- add folder cohorts/conceptSets/json

* add study hub builder
* convert all documents to qmd
* add functions to define study settings prior to build
* add cohort functions
- `cohortManifest` lists cohorts used in study
- `makeCohortDetails` renders human-readable file to convey cohort definitions
- add versioning to cohort definitions
# Ulysses 0.0.4

Ulysses 0.0.2
=============
- Finalize Directory
- Finalize meta fields for \_study.yml
- Reconfigure `newOhdsiStudy()` with better meta inputs
- Add functions to interface with \_study.yml
- Reroute makeFiles to directory and meta fields
- Add `makeMigrationsScript()` template
- Update study hub website format
- Update vignette

* Add keyring functions and update SetupKeyring.R template
* Update repository request email template
* Add git function to publish repo to remote
* Fix bugs in HowToRun and KeyringSetup template
# Ulysses 0.0.3

Ulysses 0.0.1
=============
- add study hub builder
- convert all documents to qmd
- add functions to define study settings prior to build
- add cohort functions
- `cohortManifest` lists cohorts used in study
- `makeCohortDetails` renders human-readable file to convey cohort definitions
- add versioning to cohort definitions

# Ulysses 0.0.2

- Add keyring functions and update SetupKeyring.R template
- Update repository request email template
- Add git function to publish repo to remote
- Fix bugs in HowToRun and KeyringSetup template

# Ulysses 0.0.1

* Add initial functionality
* file templates for:
- Analysis script
- Cohort Details
- Contribution Guidelines
- Example Script
- How to run
- Internal function file
- Meeting minutes
- News
- Email templates
- Readme
- Results report
- Study Protocol
- Study SAP
- Config.yml
* initialize ohdsi study in R
* Added a `NEWS.md` file to track changes to the package.
- Add initial functionality
- file templates for:
- Analysis script
- Cohort Details
- Contribution Guidelines
- Example Script
- How to run
- Internal function file
- Meeting minutes
- News
- Email templates
- Readme
- Results report
- Study Protocol
- Study SAP
- Config.yml
- initialize ohdsi study in R
- Added a `NEWS.md` file to track changes to the package.
42 changes: 18 additions & 24 deletions R/atlas.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @export
setAtlasCredentials <- function(keyringName = "atlas",
keyringPassword = "ohdsi") {
creds <- c("baseurl", "authMethod", "user", "password")
creds <- c("baseUrl", "authMethod", "user", "password")

keyringFn <- purrr::safely(maybeUnlockKeyring)
tt <- keyringFn(keyringName = keyringName, keyringPassword)
Expand All @@ -24,18 +24,16 @@ setAtlasCredentials <- function(keyringName = "atlas",
# set credentials
purrr::walk(
creds,
~set_cred(
~set_cred2(
cred = .x,
db = db,
keyringName = keyringName)
db = keyringName)
)

# check credentials
purrr::walk(
creds,
~checkDatabaseCredential(
cred = .x,
db = db,
keyringName = keyringName,
verbose = FALSE)
)
Expand Down Expand Up @@ -67,20 +65,12 @@ format_cohort_expression <- function(expression) {
circe$EndStrategy <- NULL
}

circeJson <- jsonlite::toJSON(circe, pretty = TRUE, auto_unbox = TRUE) |>
as.character()
return(circeJson)
}


format_cs_expression <- function(expression) {

circeJson <- jsonlite::toJSON(expression, pretty = TRUE, auto_unbox = TRUE) |>
as.character()
circeJson <- RJSONIO::toJSON(circe, digits = 23)

return(circeJson)
}


# Function to get a cohort from atlas by Id
get_cohort_from_atlas <- function(cohortId,
authFirst = FALSE,
Expand All @@ -89,7 +79,8 @@ get_cohort_from_atlas <- function(cohortId,
# check to unlock keyring
maybeUnlockKeyring(keyringName = keyringName, keyringPassword = keyringPassword)

baseUrl <- keyring::key_get("atlas_baseurl", keyring = "atlas")
baseUrl <- keyring::key_get("baseUrl", keyring = keyringName)


if (authFirst) {

Expand All @@ -101,9 +92,9 @@ get_cohort_from_atlas <- function(cohortId,

ROhdsiWebApi::authorizeWebApi(
baseUrl = baseUrl,
authMethod = keyring::key_get("atlas_authMethod", keyring = "atlas"),
webApiUsername = keyring::key_get("atlas_user", keyring = "atlas"),
webApiPassword = keyring::key_get("atlas_password", keyring = "atlas")
authMethod = keyring::key_get("authMethod", keyring = keyringName),
webApiUsername = keyring::key_get("user", keyring = keyringName),
webApiPassword = keyring::key_get("password", keyring = keyringName)
)
}

Expand All @@ -127,7 +118,10 @@ get_cs_from_atlas <- function(id,
# check to unlock keyring
maybeUnlockKeyring(keyringName = keyringName, keyringPassword = keyringPassword)

baseUrl <- keyring::key_get("atlas_baseurl", keyring = "atlas")
baseUrl <- keyring::key_get(
service = "baseUrl",
keyring = keyringName
)

if (authFirst) {

Expand All @@ -139,9 +133,9 @@ get_cs_from_atlas <- function(id,

ROhdsiWebApi::authorizeWebApi(
baseUrl = baseUrl,
authMethod = keyring::key_get("atlas_authMethod", keyring = "atlas"),
webApiUsername = keyring::key_get("atlas_user", keyring = "atlas"),
webApiPassword = keyring::key_get("atlas_password", keyring = "atlas")
authMethod = keyring::key_get("authMethod", keyring = keyringName),
webApiUsername = keyring::key_get("user", keyring = keyringName),
webApiPassword = keyring::key_get("password", keyring = keyringName)
)
}

Expand All @@ -151,7 +145,7 @@ get_cs_from_atlas <- function(id,
tb <- tibble::tibble(
id = cs$id,
name = cs$name,
expression = format_cs_expression(cs$expression),
expression = RJSONIO::toJSON(cs$expression, digits = 23),
saveName = glue::glue("{id}_{name}") |> snakecase::to_snake_case()
)

Expand Down
Loading

0 comments on commit 6f06202

Please sign in to comment.