Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #49: add get_terms() from admiral.test #50

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.