# Storing codes of two external terminologies

**URL:** https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364
**Category:** Terminology
**Created:** [16 February 2022 06:36 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364 "2022-02-16T06:36:14Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![sangeeta.nbose](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sangeeta.nbose/32/1121_2.png) [@sangeeta.nbose](https://discourse.openehr.org/u/sangeeta.nbose)
#### Post date: [16 February 2022 06:36 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/1 "2022-02-16T06:36:14Z")

</div>

Hi… I would like to store a UMLS code and and a snomed code while storing certain clinical values. The two codes will be needed for two different downstream systems. In the archetype designer I see the possibility of binding a DV\_CODED\_TEXT value to one terminology, not multiple.

Or is there a better way to address my problem, than binding to 2 terminology codes ?

Thanks much  
Sangeeta Bose(Karkinos Healthcare)

---

<div class="post-metadata">

### Author: ![joostholslag](https://discourse.openehr.org/user_avatar/discourse.openehr.org/joostholslag/32/1981_2.png) [@joostholslag](https://discourse.openehr.org/u/joostholslag)
#### Post date: [16 February 2022 07:04 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/2 "2022-02-16T07:04:08Z")

</div>

I’m quite sure it would be valid ADL to add multiple term bindings. Could be AD doesn’t support this, but you could try via manual ADL editing.

---

<div class="post-metadata">

### Author: ![Dileep\_V\_S](https://discourse.openehr.org/user_avatar/discourse.openehr.org/dileep_v_s/32/664_2.png) [@Dileep\_V\_S](https://discourse.openehr.org/u/Dileep_V_S)
#### Post date: [16 February 2022 07:20 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/3 "2022-02-16T07:20:44Z")

</div>

Hi,  
I think Sangeetha is looking to add more than one terminology bindings to the same DV\_CODED\_TXT data.

I my reading of the specs, I think it is not possible without repeating the value.

Regards

---

<div class="post-metadata">

### Author: ![siljelb](https://discourse.openehr.org/user_avatar/discourse.openehr.org/siljelb/32/12_2.png) [@siljelb](https://discourse.openehr.org/u/siljelb)
#### Post date: [16 February 2022 10:51 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/4 "2022-02-16T10:51:18Z")

</div>

The [DV\_TEXT](https://specifications.openehr.org/releases/RM/latest/data_types.html#_dv_text_class) `mappings` element is intended for adding any number of additional codes. A DV\_CODED\_TEXT still needs a single `defining_code` to be the main one though.

Using the [TERM\_MAPPING](https://specifications.openehr.org/releases/RM/latest/data_types.html#_term_mapping_class) class, you can specify whether the additional codes are identical to, broader or narrower than the `defining_code`.

---

<div class="post-metadata">

### Author: ![joostholslag](https://discourse.openehr.org/user_avatar/discourse.openehr.org/joostholslag/32/1981_2.png) [@joostholslag](https://discourse.openehr.org/u/joostholslag)
#### Post date: [17 February 2022 06:55 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/5 "2022-02-17T06:55:27Z")

</div>

Hi Dileep,

Maybe there is a difference between adl1 vs 2:  
Adl2 spec: “ _Bindings may be defined for a given set of terms for more than one terminology, enabling the different bindings to be used in different contexts, e.g. hospital deployment versus aged care._”

> **[Archetype Definition Language 2 (ADL2)](https://specifications.openehr.org/releases/AM/latest/ADL2.html#_value_sets_sub_section)**
>
> openEHR Archetype Definition Language 2 (ADL2)

---

<div class="post-metadata">

### Author: ![joostholslag](https://discourse.openehr.org/user_avatar/discourse.openehr.org/joostholslag/32/1981_2.png) [@joostholslag](https://discourse.openehr.org/u/joostholslag)
#### Post date: [17 February 2022 06:58 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/6 "2022-02-17T06:58:04Z")

</div>

Hi Silje,  
Mappings are intended for run time mapping of individual patient data, right?  
Since Sangeeta talked about AD, I think he’s looking for design time binding of the meaning of a concept (archetype/template). Single defining code makes sense, but is again a different concept. Or am I missing something from your message?

---

<div class="post-metadata">

### Author: ![damoca](https://discourse.openehr.org/user_avatar/discourse.openehr.org/damoca/32/2606_2.png) [@damoca](https://discourse.openehr.org/u/damoca)
#### Post date: [17 February 2022 07:36 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/7 "2022-02-17T07:36:51Z")

</div>

I think @siljelb is on the right track, and also @joostholslag saying that this might be a limitation of the AD.

My interpretation of the original question is that @sangeeta.nbose wants to store a single textual value, but having it mapped to two different codes. If we model the following DV\_CODED\_TEXT in the AD, we are in fact defining alternative defining\_code values, i.e. we will use one coding system or the other in the instances. But if we want both we need to store the DV\_TEXT\_CODE twice.

 ![image](https://discourse.openehr.org/uploads/default/original/2X/6/6e5e9aee5a50c51503dcac94e2b5cb78455c9b1b.png)

As @siljelb said, the right thing to do is to constrain the mapping attribute, but it does not seem that the AD supports it. I show it using LinkEHR.  
 ![image](https://discourse.openehr.org/uploads/default/original/2X/3/37ff09e8a20fbf5433b6ecc81dbbac82776c3ec4.png)

And finally, one important detail. The mapping attribute is also part of DV\_TEXT. So we can use it to define two term mappings associated to one text value without needing to have a main defining\_code (which is only part of the DV\_CODED\_TEXT data type)  
 ![image](https://discourse.openehr.org/uploads/default/original/2X/3/333bbcc8219aa5a9fa8be52044bbe465071f89e7.png)

---

<div class="post-metadata">

### Author: ![siljelb](https://discourse.openehr.org/user_avatar/discourse.openehr.org/siljelb/32/12_2.png) [@siljelb](https://discourse.openehr.org/u/siljelb)
#### Post date: [17 February 2022 07:58 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/8 "2022-02-17T07:58:36Z")

</div>

> [@damoca](#):
>
> My interpretation of the original question is that @sangeeta.nbose wants to store a single textual value, but having it mapped to two different codes.

This is my understanding too. However, I didn’t understand, as @joostholslag points out, that she wanted to do the mapping in the template and not at run time. In that case AD certainly needs to add support for this. How does this look from your end, @borut.fabjan ?

---

<div class="post-metadata">

### Author: ![damoca](https://discourse.openehr.org/user_avatar/discourse.openehr.org/damoca/32/2606_2.png) [@damoca](https://discourse.openehr.org/u/damoca)
#### Post date: [17 February 2022 08:02 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/9 "2022-02-17T08:02:19Z")

</div>

I was thinking in constraining the acceptable terminologies, not the actual coded values, of course.

---

<div class="post-metadata">

### Author: ![sangeeta.nbose](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sangeeta.nbose/32/1121_2.png) [@sangeeta.nbose](https://discourse.openehr.org/u/sangeeta.nbose)
#### Post date: [17 February 2022 13:56 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/10 "2022-02-17T13:56:48Z")

</div>

An example intention would be … Patient shows ‘sign/symptom’ such as ‘headache’. I would like to store the ‘headache’ as the value and also the umls code and the snomed code for headache. This would be a runtime activity. But I would need to design my template/archetype to accept the multiple terminologies isnt it ?

---

<div class="post-metadata">

### Author: ![joostholslag](https://discourse.openehr.org/user_avatar/discourse.openehr.org/joostholslag/32/1981_2.png) [@joostholslag](https://discourse.openehr.org/u/joostholslag)
#### Post date: [17 February 2022 14:22 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/11 "2022-02-17T14:22:28Z")

</div>

For that case you store multiple term mappings at run time like Silje remarked. [Data Types Information Model](https://specifications.openehr.org/releases/RM/latest/data_types.html#_term_mapping_class)

You don’t _need_ to do anything at design time to be able to store those. But you _can_ record (multiple) term bindings at design time. It’s important these should be considered implementation guidance and not automatically recorded as mappings in patient data for clinical safety reasons.

---

<div class="post-metadata">

### Author: ![sangeeta.nbose](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sangeeta.nbose/32/1121_2.png) [@sangeeta.nbose](https://discourse.openehr.org/u/sangeeta.nbose)
#### Post date: [22 February 2022 10:03 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/12 "2022-02-22T10:03:02Z")

</div>

Thanks all… I am a little confused about storing multiple term mappings. Is there any sample code I can refer. (I do not see the support for setting the TERM\_MAPPING attribute in AD. But as I understand it, I do not need to do anything design time).

---

<div class="post-metadata">

### Author: ![Seref](https://discourse.openehr.org/user_avatar/discourse.openehr.org/seref/32/13_2.png) [@Seref](https://discourse.openehr.org/u/Seref)
#### Post date: [22 February 2022 10:21 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/13 "2022-02-22T10:21:45Z")

</div>

Here comes my bull in a china shop moment 😁 :

Using the `mappings` of `DV_TEXT`, one can indeed store N mappings with references to various terminologies as @siljelb says. However, I cannot see a way to constraint what those terminologies are allowed to be. I.e. you can record mappings to terminologies, but you cannot force validation to reject data if it contains a mapping to a code from SuperDuperAstrologyChartBasedCodingSystem©

You can record the fact that a value must be from a particular terminology, and its subset etc, if you go with `DV_CODED_TEXT` as @damoca mentions, and that can be expressed at the archetype level.

So if you want to make the terminology of the mapping part of validation, use `DV_CODED_TEXT` in your archetype, or specialise `DV_TEXT` fields of the archetype you’re re-using to `DV_CODED_TEXT` in a template.

If you’re ok with users using any terminology, which means you’ll only query for the ones you’re interested in when using the data, and not be concerned about codes from terminologies you don’t care about, then stay with `DV_TEXT`.

Can I join the clinical modelling experts group now? 😁 ? I’d be very happy to be educated if the above is wrong.

---

<div class="post-metadata">

### Author: ![birger.haarbrandt](https://discourse.openehr.org/user_avatar/discourse.openehr.org/birger.haarbrandt/32/24_2.png) [@birger.haarbrandt](https://discourse.openehr.org/u/birger.haarbrandt)
#### Post date: [22 February 2022 18:18 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/14 "2022-02-22T18:18:58Z")

</div>

Hi @sangeeta.nbose,

this is a snipped from within a composition to create a mapping:

```auto
    "setting": {
      "_type": "DV_CODED_TEXT",
      "value": "other care",
      "defining_code": {
        "terminology_id": {
          "value": "openehr"
        },
        "code_string": "238"
      },
      "mappings": {
        "_type": "TERM_MAPPING",
        "match": "=",
        "purpose": {
          "_type": "DV_CODED_TEXT",
          "value": "test",
          "defining_code": {
            "terminology_id": {
              "value": "local"
            },
            "code_string": "test value"
          }
        },
        "target": {
          "terminology_id": {
            "value": "SNOMED-CT"
          },
          "code_string": "345356676789"
        }
      }
    },

```

Hope this helps

P.S. simply use the RM paths in EHRbase for (partial) querying:

```auto
{
  "q":"select
c/content[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]/data[at0001]/events[at0002]/data[at0003]/items[openEHR-EHR-CLUSTER.specimen.v1]/items[at0029]/value/mappings/target/code_string
from EHR e
contains COMPOSITION c
"
}

```

---

<div class="post-metadata">

### Author: ![siljelb](https://discourse.openehr.org/user_avatar/discourse.openehr.org/siljelb/32/12_2.png) [@siljelb](https://discourse.openehr.org/u/siljelb)
#### Post date: [23 February 2022 07:43 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/15 "2022-02-23T07:43:30Z")

</div>

> [@Seref](#):
>
> I’d be very happy to be educated if the above is wrong.

I’m not sure I understand what the question is? 😅

---

<div class="post-metadata">

### Author: ![Seref](https://discourse.openehr.org/user_avatar/discourse.openehr.org/seref/32/13_2.png) [@Seref](https://discourse.openehr.org/u/Seref)
#### Post date: [23 February 2022 08:47 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/16 "2022-02-23T08:47:46Z")

</div>

> [@siljelb](#):
>
> I’m not sure I understand what the question is?

Now I’m confused 😃 I tried to answer @sangeeta.nbose 's question, then implicitly asked if my answer was correct. I’ll stop here before go into an [infinite loop](https://en.wikipedia.org/wiki/Infinite_loop) 😁

---

<div class="post-metadata">

### Author: ![sangeeta.nbose](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sangeeta.nbose/32/1121_2.png) [@sangeeta.nbose](https://discourse.openehr.org/u/sangeeta.nbose)
#### Post date: [1 March 2022 09:17 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/17 "2022-03-01T09:17:35Z")

</div>

Thank you so much @birger.haarbrandt . The code helped… we have this working now. Just one last question… For storing multiple mappings… I would need to make this a list with multiple mappings. Would this be right.?  
“mappings”: [  
{  
“\_type”: “TERM\_MAPPING”,  
“match”: “=”,  
“target”: {  
“terminology\_id”: {  
“value”: “SNOMED-CT”  
},  
“code\_string”: “345356676789”  
}  
}  
{  
“\_type”: “TERM\_MAPPING”,  
“match”: “=”,  
“target”: {  
“terminology\_id”: {  
“value”: “UMLS”  
},  
“code\_string”: “1234”  
}  
}  
]

If so, how would the RM path work out for accessing the individual item in the list ? Thanks for all your help.

---

<div class="post-metadata">

### Author: ![sangeeta.nbose](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sangeeta.nbose/32/1121_2.png) [@sangeeta.nbose](https://discourse.openehr.org/u/sangeeta.nbose)
#### Post date: [2 March 2022 05:19 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/18 "2022-03-02T05:19:01Z")

</div>

Hi… I. have another question too… Can I use the ‘match’ field to store an accuracy number. It would be my information on the accuracy of the mapping of the source value with the target code. ‘Match’ is a char, so i would be able to store the number… but just checking if there are are guidelines against it.

---

<div class="post-metadata">

### Author: ![joostholslag](https://discourse.openehr.org/user_avatar/discourse.openehr.org/joostholslag/32/1981_2.png) [@joostholslag](https://discourse.openehr.org/u/joostholslag)
#### Post date: [2 March 2022 06:46 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/19 "2022-03-02T06:46:12Z")

</div>

Hi Sangeeta, I think technically you can use any character, other should confirm this. But only 4 characters are specified in the TERM\_MAPPING class to have meaning. I [rencentlh proposed](https://discourse.openehr.org/t/semi-structured-narrative-data/2007/27) to add `~` as a fifth option to indicate a somewhat match (e.g. machine learning suggestion). Is this also your usecase?

---

<div class="post-metadata">

### Author: ![sangeeta.nbose](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sangeeta.nbose/32/1121_2.png) [@sangeeta.nbose](https://discourse.openehr.org/u/sangeeta.nbose)
#### Post date: [2 March 2022 08:28 UTC](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364/20 "2022-03-02T08:28:45Z")

</div>

Yes @joostholslag my use case would be a machine learning suggestion… but I do have a confidence number… Hence was looking at using ‘match’ for storing the number.

[Next page](https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364.md?page=2)
