Navigation

  • index
  • next |
  • previous |
  • InspectOMOP 0.2.3 documentation »
  • API Reference »
  • inspectomop.queries.general.related_concepts_for_concept_id

inspectomop.queries.general.related_concepts_for_concept_id¶

inspectomop.queries.general.related_concepts_for_concept_id(concept_id, inspector, return_columns=None)¶

Find all concepts related to a concept_id.

Parameters:
  • concept_id (int) – concept_id of interest from the concept table

  • inspector (inspectomop.inspector.Inspector)

  • return_columns (list of str, optional) –

    • optional subset of columns to return from the query

    • columns : [‘relationship_polarity’,’relationship_id’, ‘relationship_name’, ‘concept_id’, ‘concept_name’, ‘concept_code’, ‘concept_class_id’, ‘vocabulary_id’, ‘vocabulary_name’]

Returns:

results

Return type:

sqlalchemy.sql.expression.Executable

Notes

Original SQL

G07: Find concepts that have a relationship with a given concept:

SELECT
    'Relates to' relationship_polarity,
    CR.relationship_ID,
    RT.relationship_name,
    D.concept_Id concept_id,
    D.concept_Name concept_name,
    D.concept_Code concept_code,
    D.concept_class_id concept_class_id,
    D.vocabulary_id concept_vocab_ID,
    VS.vocabulary_name concept_vocab_name
FROM
    concept_relationship CR,
    concept A,
    concept D,
    vocabulary VA,
    vocabulary VS,
    relationship RT
WHERE
    CR.concept_id_1 = A.concept_id AND
    A.vocabulary_id = VA.vocabulary_id AND
    CR.concept_id_2 = D.concept_id AND
    D.vocabulary_id = VS.vocabulary_id AND
    CR.relationship_id = RT.relationship_ID AND
    A.concept_id = 192671 AND
    sysdate BETWEEN CR.valid_start_date AND CR.valid_end_date
UNION ALL
SELECT
    'Is related by' relationship_polarity,
    CR.relationship_ID,
    RT.relationship_name,
    A.concept_Id concept_id,
    A.concept_name concept_name,
    A.concept_code concept_code,
    A.concept_class_id concept_class_id,
    A.vocabulary_id concept_vocab_ID,
    VA.Vocabulary_Name concept_vocab_name
FROM
    concept_relationship CR,
    concept A,
    concept D,
    vocabulary VA,
    vocabulary VS,
    relationship RT
WHERE
    CR.concept_id_1 = A.concept_id AND
    A.vocabulary_id = VA.vocabulary_id AND
    CR.concept_id_2 = D.concept_id AND
    D.vocabulary_id = VS.vocabulary_id AND
    CR.relationship_id = RT.relationship_ID AND
    D.concept_id = 192671 AND
    sysdate BETWEEN CR.valid_start_date AND CR.valid_end_date;

Table of Contents

  • Installation
  • Usage
  • API Reference
    • Inspector
    • Connection
    • Results
    • Queries
      • Care Site
      • Condition
      • Drug
      • General
      • Observation
      • Payer Plan
      • Person

This Page

  • Show Source

Quick search

Navigation

  • index
  • next |
  • previous |
  • InspectOMOP 0.2.3 documentation »
  • API Reference »
  • inspectomop.queries.general.related_concepts_for_concept_id
© Copyright 2026, Jonathan Badger. Created using Sphinx 9.1.0.