the cedar ledge

Exploring Ancestors and Descendants of a Concept

Date: July 28 2021

Summary: How to explore ancestors and descendants of OHDSI concepts

Keywords: #ohdsi #sql #ancestor #descendant #r #archive

Bibliography

EHDEN Academy

Table of Contents

    1. Setting Up Environment
      1. Installation Requirements
      2. Making Connection to Eunomia
      3. Querying Ancestors from OHDSI
      4. Querying Descendants from OHDSI
  1. How To Cite
  2. References:
  3. Discussion:

Setting Up Environment

Installation Requirements

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")

Making Connection to Eunomia

Here we load the DatabaseConnector library to connect to Eunomia:

library('DatabaseConnector')

And set a connection to Eunomia

connectionDetails <-Eunomia::getEunomiaConnectionDetails()
connection <- connect(connectionDetails)

Querying Ancestors from OHDSI

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)

Querying Descendants from OHDSI

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)

How To Cite

Zelko, Jacob. Exploring Ancestors and Descendants of a Concept. https://jacobzelko.com/07282021202459-exploring-ancestors-concept. July 28 2021.

References:

Discussion:

CC BY-SA 4.0 Jacob Zelko. Last modified: May 19, 2024. Website built with Franklin.jl and the Julia programming language.