Skip to content

Commit

Permalink
Closes #49: add get_terms() from admiral.test (#50)
Browse files Browse the repository at this point in the history
* #49: add get_terms()

* #49: update wordlist
  • Loading branch information
kaz462 authored Aug 15, 2023
1 parent 2f6bc1b commit db9f031
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 20 deletions.
71 changes: 71 additions & 0 deletions R/get_terms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#' An example function as expected by the `get_terms_fun` parameter of
#' `admiral::create_query_data()`
#'
#' @param basket_select A basket_select object defining the terms
#'
#' @param version MedDRA version
#'
#' @param keep_id Should `GRPID` be included in the output?
#'
#' @param temp_env Temporary environment
get_terms <- function(basket_select,
version,
keep_id,
temp_env) {
if (basket_select$type == "smq") {
if (is.null(temp_env$admiral_smq_db)) {
data("admiral_smq_db", envir = temp_env)
}
if (!is.null(basket_select$name)) {
is_in_smq <- temp_env$admiral_smq_db$smq_name == basket_select$name
} else {
is_in_smq <- temp_env$admiral_smq_db$smq_id == basket_select$id
}
if (basket_select$scope == "NARROW") {
is_in_scope <- temp_env$admiral_smq_db$scope == "narrow"
} else {
is_in_scope <- rep(TRUE, nrow(temp_env$admiral_smq_db))
}
if (keep_id) {
select_id <- c(GRPID = "smq_id")
} else {
select_id <- NULL
}
keep_cols <- c(
TERMNAME = "termname",
SRCVAR = "termvar",
GRPNAME = "smq_name",
select_id
)

structure(
temp_env$admiral_smq_db[is_in_smq & is_in_scope, keep_cols],
names = names(keep_cols)
)
} else if (basket_select$type == "sdg") {
if (is.null(temp_env$admiral_sdg_db)) {
data("admiral_sdg_db", envir = temp_env)
}
if (!is.null(basket_select$name)) {
is_in_sdq <- temp_env$admiral_sdg_db$sdg_name == basket_select$name
} else {
is_in_sdq <- temp_env$admiral_sdg_db$sdg_id == basket_select$id
}
if (keep_id) {
select_id <- c(GRPID = "sdg_id")
} else {
select_id <- NULL
}
keep_cols <- c(
TERMNAME = "termname",
SRCVAR = "termvar",
GRPNAME = "sdg_name",
select_id
)

structure(
temp_env$admiral_sdg_db[is_in_sdq, keep_cols],
names = names(keep_cols)
)
}
}
24 changes: 4 additions & 20 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@ ADEG
ADaM
AE
AELAT
Arancibia
CDISC
Changelog
Contestí
DM
DS
EG
EXLAT
EXLOC
Farrugia
Github
GSK
GRPID
Gopi
LinkedIn
MH
MedDRA
NEI
Onboarding
Pharmacokinetic
Pharmacokinetics
QS
README
Pharmaverse
Rodríguez
SDG
SDTM
Expand All @@ -33,20 +27,10 @@ SUPPDS
SUPPTR
SV
TAs
USUBJIDs
VFQ
Vegesna
ae
admiraldata
admiraltemplate
admiralxxx
adxx
anonymized
dev
nolint
onboarding
pharmaverse
qs
renv
repo
https
Vegesna
22 changes: 22 additions & 0 deletions man/get_terms.Rd

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

0 comments on commit db9f031

Please sign in to comment.