inst/shinyApps/QueryLibrary/queries/general/G10.md

G10: Find parents for a given concept

This query accepts a concept ID as the input and returns all concepts that are its immediate parents of that concept. Parents are concepts that have a hierarchical relationship to the given concepts. Hierarchical relationships are defined in the relationship table. The query returns only the immediate parent concepts that are directly linked to the input concept and not all ancestors.

Query

SELECT
  a.concept_id       AS parent_concept_id,
  a.concept_name     AS parent_concept_name,
  a.concept_code     AS parent_concept_code,
  a.concept_class_id AS parent_concept_class_id,
  a.vocabulary_id    AS parent_concept_vocab_id
FROM @vocab.concept_ancestor ca
  JOIN @vocab.concept a ON ca.ancestor_concept_id = a.concept_id
  JOIN @vocab.concept d ON ca.descendant_concept_id = d.concept_id
WHERE 
  ca.min_levels_of_separation = 1 AND
  ca.descendant_concept_id = 192671 AND
  a.invalid_reason IS NULL
;

Input

| Parameter | Example | Mandatory | Notes | | --- | --- | --- | --- | | Concept ID | 192671 | Yes | Gastrointestinal hemorrhage |

Output

| Field | Description | | --- | --- | | Parent_Concept_ID | Concept ID of parent concept | | Parent_Concept_Name | Name of parent concept | | Parent_Concept_Code | Concept Code of parent concept | | Parent_Concept_Class_ID | Concept Class of parent concept | | Parent_Concept_Vocab_ID | Vocabulary parent concept is derived from as vocabulary code |

Example output record

| Field | Value | | --- | --- | | Parent_Concept_ID | 4000610 | | Parent_Concept_Name | Disease of gastrointestinal tract | | Parent_Concept_Code | 119292006 | | Parent_Concept_Class_ID | Clinical finding | | Parent_Concept_Vocab_ID | SNOMED |

Documentation

https://github.com/OHDSI/CommonDataModel/wiki/CONCEPT_ANCESTOR



OHDSI/QueryLibrary documentation built on Aug. 1, 2023, 5:42 a.m.