Relation Concept Links

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

Example NLP API results:

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

1"qualifiers": [
2 {
3 "label": "RQ0",
4 "attributes": {
5 "confidence": 1.0,
6 "qualifier_type": "size/severity"
7 },
8 "args": {
9 "qualifier": {
10 "ref": "E1",
11 "text": [
12 "mild"
13 ]
14 },
15 "qualifies": {
16 "ref": "E3",
17 "text": [
18 "mitral regurgitation"
19 ]
20 }
21 },
22 "concept_links": [
23 "Csnomed8"
24 ]
25 },

Changed

Python API

All the relations now have a .concepts attribute which is a list of Concept objects.

Example usage:

1import json
2import pathlib
3from emtellipro.data import AnnotatedDocument
4
5json_data = pathlib.Path('data/relation_links.json').read_text()
6doc_dict = json.loads(json_data)['documents'][0]
7ann_doc = AnnotatedDocument(doc_dict)
8
9for qualifier_relation in ann_doc.relations['qualifier']:
10 print(
11 qualifier_relation.qualifier,
12 qualifier_relation.qualifies,
13 )
14
15 for concept in qualifier_relation.concepts:
16 print(concept.ontology, concept.concept_id, concept.description)
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.

1SELECT found_entity_id, concept_ontology, concept_id, start, "end", text
2FROM foundentityconcept
3JOIN foundentityspan
4USING (found_entity_id)
5WHERE concept_id = '838451005';

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

$ 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:

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.