> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.emtelligent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emtelligent.com/_mcp/server.

# Relation Concept Links

The relation concept links feature links relations to concepts. This resembles the concept links in found entities.

Example NLP API results:

* relation_links.json
* relation_links.txt

Specifically the following is a snippet showing an example of a qualifier relation's concept links:

```python
"qualifiers": [
  {
    "label": "RQ0",
    "attributes": {
      "confidence": 1.0,
      "qualifier_type": "size/severity"
    },
    "args": {
      "qualifier": {
        "ref": "E1",
        "text": [
          "mild"
        ]
      },
      "qualifies": {
        "ref": "E3",
        "text": [
          "mitral regurgitation"
        ]
      }
    },
    "concept_links": [
      "Csnomed8"
    ]
  },
```

## Changed

### Python API

All the relations now have a `.concepts` attribute which is a list of [Concept](/nlp/python/reference/data#emtelliprodataconcept) objects.

Example usage:

```python
import json
import pathlib
from emtellipro.data import AnnotatedDocument

json_data = pathlib.Path('data/relation_links.json').read_text()
doc_dict = json.loads(json_data)['documents'][0]
ann_doc = AnnotatedDocument(doc_dict)

for qualifier_relation in ann_doc.relations['qualifier']:
    print(
        qualifier_relation.qualifier,
        qualifier_relation.qualifies,
    )

    for concept in qualifier_relation.concepts:
        print(concept.ontology, concept.concept_id, concept.description)
```

**`Output of above code.`**

```text title="Output of above code."
['mild'] ['mitral regurgitation']
snomed 838451005 Mild mitral valve regurgitation (disorder)
['localized'] ['injury']
```

### Database changes

There are no schema changes for this new feature.

Since the relation is linked to a concept (similar to how the found entities are linked to concepts), this new concept link is stored in the database by creating a new discontinuous found entity for each relation that has a concept link.

For each relation with at least one concept link, we create a new found entity that merges the arguments of the relation together. The attributes are merged together, and the spans and locations are the union of the two individual found entities.

From the example above, we should now have a new found entity in the data for 'mild mitral regurgitation'. This is a discontinuous entity, so there will be two rows in the `foundentityspan` table.

```sql
SELECT found_entity_id, concept_ontology, concept_id, start, "end", text
FROM foundentityconcept
JOIN foundentityspan
USING (found_entity_id)
WHERE concept_id = '838451005';
```

And if we run that, we should see the following result:

```bash
 found_entity_id | concept_ontology | concept_id | start | end |         text
-----------------+------------------+------------+-------+-----+----------------------
           13574 | snomed           | 838451005  |    16 |  20 | mild
           13574 | snomed           | 838451005  |    29 |  49 | mitral regurgitation
  (2 rows)
```

Since the new discontinuous found entity is created from two existing found entities, you will now see 3 found entities in the database:

```text
 found_entity_id | concept_ontology | concept_id | start | end |         text
-----------------+------------------+------------+-------+-----+----------------------
           13565 | snomed           | 255604002  |    16 |  20 | mild
           13567 | snomed           | 48724000   |    29 |  49 | mitral regurgitation
           13574 | snomed           | 838451005  |    16 |  20 | mild
           13574 | snomed           | 838451005  |    29 |  49 | mitral regurgitation
```

Found entities 13565 and 13567 are the original two found entities that are combined to create 13574; the original two found entities retain their individual concept links while the new found entity has a new concept link that was copied from the relation that generated it.