diff --git a/R/get_terms.R b/R/get_terms.R new file mode 100644 index 0000000..adb1a58 --- /dev/null +++ b/R/get_terms.R @@ -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) + ) + } +} diff --git a/inst/WORDLIST b/inst/WORDLIST index 9f6a527..a63d02b 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -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 @@ -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 diff --git a/man/get_terms.Rd b/man/get_terms.Rd new file mode 100644 index 0000000..d940320 --- /dev/null +++ b/man/get_terms.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_terms.R +\name{get_terms} +\alias{get_terms} +\title{An example function as expected by the `get_terms_fun` parameter of +`admiral::create_query_data()`} +\usage{ +get_terms(basket_select, version, keep_id, temp_env) +} +\arguments{ +\item{basket_select}{A basket_select object defining the terms} + +\item{version}{MedDRA version} + +\item{keep_id}{Should `GRPID` be included in the output?} + +\item{temp_env}{Temporary environment} +} +\description{ +An example function as expected by the `get_terms_fun` parameter of +`admiral::create_query_data()` +}