Date: July 28 2021
Summary: How to explore ancestors and descendants of OHDSI concepts
Keywords: #ohdsi #sql #ancestor #descendant #r #archive
EHDEN Academy
We install the OHDSI dummy database, Eunomia
, to write our queries:
install.packages(c("SqlRender", "DatabaseConnector", "remotes"))
remotes::install_github("ohdsi/Eunomia", ref = "v1.0.0")
We will also install the package knitr
for viewing and working with resulting tables easily:
install.packages("knitr")
Here we load the DatabaseConnector
library to connect to Eunomia
:
library('DatabaseConnector')
And set a connection to Eunomia
connectionDetails <-Eunomia::getEunomiaConnectionDetails()
connection <- connect(connectionDetails)
First we need to write our SQL query as follows:
sql <- "
SELECT max_levels_of_separation, concept.*
FROM @cdm.concept_ancestor
JOIN concept ON ancestor_concept_id = concept_id
WHERE descendant_concept_id = 313217
ORDER BY max_levels_of_separation
"
And then we can run our SQL query and return the results as follows:
result <- renderTranslateQuerySql(connection, sql,cdm ="main")
knitr::kable(result)
First we need to write our SQL query as follows:
sql <- "
SELECT max_levels_of_separation, concept.*
FROM @cdm.concept_ancestor
JOIN concept ON descendant_concept_id = concept_id
WHERE descendant_concept_id = 4478217
ORDER BY max_levels_of_separation
"
And then we can run our SQL query and return the results as follows:
result <- renderTranslateQuerySql(connection, sql,cdm ="main")
knitr::kable(result)
Zelko, Jacob. Exploring Ancestors and Descendants of a Concept. https://jacobzelko.com/07282021202459-exploring-ancestors-concept. July 28 2021.