> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omophub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Check Concept Relations

> Check whether an OMOP concept has any relationships without loading the full relationship payload - a lightweight existence check for ETL validation.

## Overview

This lightweight endpoint quickly determines whether a concept has any relationships to other concepts. This is useful for UI components, validation logic, or filtering concepts that are isolated vs. connected in the terminology network.

## Path Parameters

<ParamField path="conceptId" type="integer" required>
  The unique OMOP concept ID to check for relationships
</ParamField>

## Query Parameters

<ParamField query="relationship_types" type="string">
  Comma-separated list of relationship types to check (e.g., "Maps to", "Is a")
</ParamField>

<ParamField query="vocabulary_ids" type="string">
  Comma-separated list of vocabulary IDs to limit relationship check
</ParamField>

<ParamField query="include_reverse" type="boolean" default="true">
  Include reverse relationships (concepts that relate to this concept)
</ParamField>

<ParamField query="include_invalid" type="boolean" default="true">
  Include relationships to invalid/deprecated concepts
</ParamField>

<ParamField query="vocab_release" type="string">
  Specific vocabulary release version (e.g., "2024.1")
</ParamField>

## Response

<ResponseField name="success" type="boolean" required>
  Indicates whether the request was successful
</ResponseField>

<ResponseField name="data" type="object" required>
  Response data containing relationship check results

  <Expandable title="data">
    <ResponseField name="concept_id" type="integer">
      The concept ID that was checked
    </ResponseField>

    <ResponseField name="has_relations" type="boolean">
      Whether this concept has any relationships matching the specified criteria
    </ResponseField>

    <ResponseField name="relation_summary" type="object">
      Summary information about relationships (when has\_relations is true)

      <Expandable title="relation_summary">
        <ResponseField name="total_count" type="integer">
          Total number of relationships found
        </ResponseField>

        <ResponseField name="outbound_count" type="integer">
          Number of outbound relationships (from this concept)
        </ResponseField>

        <ResponseField name="inbound_count" type="integer">
          Number of inbound relationships (to this concept)
        </ResponseField>

        <ResponseField name="relationship_types" type="array">
          Array of relationship types found (up to 10 most common)
        </ResponseField>

        <ResponseField name="connected_vocabularies" type="array">
          Array of vocabularies that have related concepts (up to 10)
        </ResponseField>

        <ResponseField name="has_standard_mappings" type="boolean">
          Whether concept has mappings to standard concepts
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="checks_performed" type="object">
      Details about what was checked

      <Expandable title="checks_performed">
        <ResponseField name="included_relationship_types" type="array">
          Relationship types included in the check
        </ResponseField>

        <ResponseField name="included_vocabularies" type="array">
          Vocabularies included in the check
        </ResponseField>

        <ResponseField name="included_reverse_relations" type="boolean">
          Whether reverse relationships were checked
        </ResponseField>

        <ResponseField name="included_invalid_relations" type="boolean">
          Whether invalid relationships were checked
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="meta" type="object" required>
  Response metadata and API information

  <Expandable title="meta">
    <ResponseField name="request_id" type="string">
      Unique request identifier for debugging
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of the response
    </ResponseField>

    <ResponseField name="vocab_release" type="string">
      Vocabulary release version used
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.omophub.com/v1/concepts/201826/relations/any" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  concept_id = 201826  # Type 2 diabetes
  url = f"https://api.omophub.com/v1/concepts/{concept_id}/relations/any"
  params = {
      "relationship_types": "Maps to,Is a",
      "include_reverse": True
  }

  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  response = requests.get(url, params=params, headers=headers)
  data = response.json()

  if data['data']['has_relations']:
      print(f"✓ Concept {concept_id} has relationships")
      summary = data['data']['relation_summary']
      print(f"  - Total: {summary['total_count']}")
      print(f"  - Standard mappings: {'Yes' if summary['has_standard_mappings'] else 'No'}")
  else:
      print(f"✗ Concept {concept_id} has no relationships")
  ```

  ```javascript JavaScript theme={null}
  const conceptId = 201826; // Type 2 diabetes
  const response = await fetch(`https://api.omophub.com/v1/concepts/${conceptId}/relations/any`, {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  const relationCheck = await response.json();
  const data = relationCheck.data;

  if (data.has_relations) {
    console.log(`Concept ${conceptId} has ${data.relation_summary.total_count} relationships`);
    console.log('Relationship types:', data.relation_summary.relationship_types);
  } else {
    console.log(`Concept ${conceptId} has no relationships`);
  }
  ```

  ```bash cURL (filtered check) theme={null}
  curl -X GET "https://api.omophub.com/v1/concepts/201826/relations/any?relationship_types=Maps%20to&vocabulary_ids=ICD10CM,ICD9CM" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python (batch validation) theme={null}
  import requests

  def validate_concept_connectivity(concept_ids):
      """
      Check which concepts have standard mappings for data quality validation
      """
      connected_concepts = []
      isolated_concepts = []

      for concept_id in concept_ids:
          url = f"https://api.omophub.com/v1/concepts/{concept_id}/relations/any"
          params = {
              "relationship_types": "Maps to",
              "vocabulary_ids": "SNOMED,ICD10CM,ICD9CM"
          }

          response = requests.get(url, params=params, headers={
              "Authorization": "Bearer YOUR_API_KEY"
          })

          data = response.json()
          concept_data = data['data']

          if concept_data['has_relations'] and concept_data['relation_summary']['has_standard_mappings']:
              connected_concepts.append({
                  'concept_id': concept_id,
                  'total_mappings': concept_data['relation_summary']['total_count'],
                  'vocabularies': concept_data['relation_summary']['connected_vocabularies']
              })
          else:
              isolated_concepts.append(concept_id)

      print(f"Connected concepts: {len(connected_concepts)}")
      print(f"Isolated concepts: {len(isolated_concepts)}")

      return connected_concepts, isolated_concepts

  # Validate a set of cardiovascular concepts
  cardiovascular_concepts = [201826, 4182210, 313217, 320128, 434557]
  connected, isolated = validate_concept_connectivity(cardiovascular_concepts)

  for concept in connected[:3]:  # Show top 3
      print(f"Concept {concept['concept_id']}: {concept['total_mappings']} mappings across {len(concept['vocabularies'])} vocabularies")
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "concept_id": 201826,
      "has_relations": true,
      "relation_summary": {
        "total_count": 15,
        "outbound_count": 8,
        "inbound_count": 7,
        "relationship_types": ["Maps to", "Is a", "Has finding site", "May be a"],
        "connected_vocabularies": ["SNOMED", "ICD10CM", "ICD9CM"],
        "has_standard_mappings": true
      },
      "checks_performed": {
        "included_relationship_types": ["all"],
        "included_vocabularies": ["all"],
        "included_reverse_relations": true,
        "included_invalid_relations": false
      }
    },
    "meta": {
      "request_id": "req_check_relations_123",
      "timestamp": "2024-12-22T10:00:00Z",
      "vocab_release": "2025.2"
    }
  }
  ```
</ResponseExample>

## Usage Examples

### Simple Relationship Check

Check if a concept has any relationships:

```bash theme={null}
curl -X GET "https://api.omophub.com/v1/concepts/201826/relations/any" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Check for Standard Mappings

Check if concept has "Maps to" relationships:

```bash theme={null}
curl -G "https://api.omophub.com/v1/concepts/201826/relations/any" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "relationship_types=Maps to"
```

### Check Cross-Vocabulary Relations

Check relationships to specific vocabularies:

```bash theme={null}
curl -X GET "https://api.omophub.com/v1/concepts/201826/relations/any?vocabulary_ids=ICD10CM,ICD9CM" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

### Batch Checking in Applications

Use in loops or batch processing to filter connected concepts:

```javascript theme={null}
const conceptIds = [201826, 4182210, 313217];
const connectedConcepts = [];

for (const id of conceptIds) {
  const response = await fetch(`/v1/concepts/${id}/relations/any`);
  const result = await response.json();
  const data = result.data;

  if (data.has_relations && data.relation_summary.has_standard_mappings) {
    connectedConcepts.push({
      concept_id: id,
      relation_count: data.relation_summary.total_count
    });
  }
}
```

## Important Notes

* **Performance optimized** - Much faster than fetching full relationship data
* **Filtering support** - All the same filters as the full relations endpoint
* **UI integration** - Perfect for showing relationship icons or badges
* **Batch processing** - Ideal for filtering large concept lists
* **Standard mappings** - The `has_standard_mappings` flag is useful for data quality checks

## Related Endpoints

* [Get Concept Relationships](/api-reference/concepts/get-concept-relationships) - Get full relationship data
* [Batch Hierarchy Queries](/api-reference/concepts/batch-hierarchy-queries) - Check relationships for multiple concepts
