# Storing codes of two external terminologies **Category:** [Terminology](https://discourse.openehr.org/c/terminology/59) **Created:** 2022-02-16 06:36 UTC **Views:** 1793 **Replies:** 37 **URL:** https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364 --- ## Post #1 by @sangeeta.nbose 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) --- ## Post #2 by @joostholslag 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. --- ## Post #3 by @Dileep_V_S 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 --- ## Post #4 by @siljelb 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`. --- ## Post #5 by @joostholslag 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.*” https://specifications.openehr.org/releases/AM/latest/ADL2.html#_value_sets_sub_section --- ## Post #6 by @joostholslag 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? --- ## Post #7 by @damoca 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|453x500](upload://fKndaFQEGIkWERdiSOL7q8Fk14L.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|246x151](upload://7ZmG5eMYN13lYWy8gOtHCLKzpD6.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|245x133](upload://7jekWFCNRV0u92lmoTE1k609AR9.png) --- ## Post #8 by @siljelb [quote="damoca, post:7, topic:2364"] 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. [/quote] 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 ? --- ## Post #9 by @damoca I was thinking in constraining the acceptable terminologies, not the actual coded values, of course. --- ## Post #10 by @sangeeta.nbose 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 ? --- ## Post #11 by @joostholslag For that case you store multiple term mappings at run time like Silje remarked. 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. --- ## Post #12 by @sangeeta.nbose 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). --- ## Post #13 by @Seref Here comes my bull in a china shop moment :grin: : 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? :grin: ? I'd be very happy to be educated if the above is wrong. --- ## Post #14 by @birger.haarbrandt Hi @sangeeta.nbose, this is a snipped from within a composition to create a mapping: ``` "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: ``` { "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 " } ``` --- ## Post #15 by @siljelb [quote="Seref, post:13, topic:2364"] I’d be very happy to be educated if the above is wrong. [/quote] I'm not sure I understand what the question is? 😅 --- ## Post #16 by @Seref [quote="siljelb, post:15, topic:2364"] I’m not sure I understand what the question is? [/quote] Now I'm confused :smiley: 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) :grin: --- ## Post #17 by @sangeeta.nbose 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. --- ## Post #18 by @sangeeta.nbose 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. --- ## Post #19 by @joostholslag 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?u=joostholslag) to add `~` as a fifth option to indicate a somewhat match (e.g. machine learning suggestion). Is this also your usecase? --- ## Post #20 by @sangeeta.nbose 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. --- ## Post #21 by @sangeeta.nbose for e.g. trying to find out how to traverse the list and get the code_string for 'snomed-ct' (This is an addition to my post showing the mappings as a list) --- ## Post #22 by @ian.mcnicoll I'm a bit wary of the value of even the broad match categories. the degree of 'match' is highly contextual and not solely a function of the codes themselves but of the direct downstream usage of the codes. --- ## Post #23 by @thomas.beale Right - but you can't outguess every subsequent use, and we also have to let openEHR users work such things out for themselves. We are not the terminology-matching police after all ;) --- ## Post #24 by @mikael [quote="thomas.beale, post:23, topic:2364, full:true"] We are not the terminology-matching police after all ;) [/quote] But I would say that there are rational reasons for us to be that in the future. --- ## Post #25 by @thomas.beale [quote="mikael, post:24, topic:2364"] But I would say that there are rational reasons for us to be that in the future. [/quote] Goes to wardrobe, looks for old uniform from military service days... --- ## Post #26 by @mikael [quote="thomas.beale, post:25, topic:2364, full:true"] Goes to wardrobe, looks for old uniform from military service days... [/quote] Do you do the same for archetype development? --- ## Post #27 by @sangeeta.nbose Hi.. Just updating that I couldnt use the 'match' for storing a number, The field accepts only a single character. Will figure out some other attributes. Do share, if any recommendations. --- ## Post #28 by @bna You are right @Seref - and I have recently come across the need to set this constraint at design time. In our system we can query a terminology service and get back the terminology with mappings. But for some use-cases I want to add the terminology as local to the archetype or template with bindings. This will be useful for self-contained deployment of an OPT with some UI or integration resources without the need for a specific terminology service. I would love to see a solution for this in the modelling domain. --- ## Post #29 by @ian.mcnicoll I think this probably needs some extra thinking at SEC, as this is different from setting bindings. I'm not clear how it would be supported in ADL/ADL2 right now. --- ## Post #30 by @Pau_Corral Hi David, Coming back to this topic, let me see if i understood correctly: The use case that I am trying to express is the CODED_TEXT validation that happens when storing a code_string into the CDR and terminology_id is checked to see if it contains the code_string. Having a term (codi_string) that for different reasons may have seen its term set (terminology_id) modified over time, in order to capture all possibilities in the design time, using AD it is necessary to add as many CODED_TEXT as terminology_id for that term? --- ## Post #31 by @damoca Hello Pau, I will make the assumption that when you say "terminology_id is checked to see if it contains the code_string", you are literally saying that you want to check if the code comes from the terminology, and not checking if the code is part of a specific subset or reference set. If it was the latter case, there is no mystery: just add as many terminology binding in the archetype as you need for every subset you have. And then you could check if the code is part of any of them. ![image|690x492](upload://dPpxTLJVfYXw6PBv5fAAenLwC93.png) But, following the initial assumption, you are saying that the terminology_id is modified over time. So, for example, you have a terminology identified as "MY_TERMINOLOGY_ORIGINAL_NAME" that at some point was renamed as "MY_TERMINOLOGY_NEW_NAME". So, in the data instances you might have stored values as CODE_X::MY_TERMINOLOGY_ORIGINAL_NAME or as CODE_X::MY_TERMINOLOGY_NEW_NAME To represent that, one option is what you said, add as many DV_CODED_TEXT as you need, one for each terminology_id. Bear in mind that you would also need to constrain the parent items attribute cardinality to 0..1 so that this is interpreted as alternative DV_CODED_TEXT and not as multiple instances. ![image|690x109](upload://vykSiBGgx5aF3bpMm2EhsYb8N8s.png) Another option would be to just add one DV_CODED_TEXT and specify multiple terminologies for it. I have never done this with the Archetype Designer, but I think it is something like this: ![image|606x500](upload://7npzZSroHDbYTRAOmeDHtwNuoLI.png) --- ## Post #32 by @Pau_Corral Hi! Thanks for the answer David. Let me explore a bit more this option that you mentioned [quote="damoca, post:31, topic:2364, full:true"] Another option would be to just add one DV_CODED_TEXT and specify multiple terminologies for it. I have never done this with the Archetype Designer, but I think it is something like this: ![image|606x500](upload://7npzZSroHDbYTRAOmeDHtwNuoLI.png) [/quote] This seems a possibility which I didn't know AD is able to do. However, when creating a template, it seems to be necessary to select one or the other ![image|346x500](upload://1sG820d9sDcFP379DmUViRHSike.png) This is what the OPT for that template says - it does not mention catalog_2. In the use case of having to check one code in more than one value set (in my screenshot "catalog_1" and "catalog_2"), are we back to having to implement as many CODED_TEXT as terminology_id? Thanks! --- ## Post #33 by @damoca You are right, I just did it myself and it seems that the AD don't like to leave open alternatives in templates. I can't remember if that is explicitly forbidden in the specifications. Anyone has a clue? --- ## Post #34 by @ian.mcnicoll Hi Pau, I'm still not quite sure what you are asking here. Using the FHIR Terminology naming we have a Codesystem - the full set of unique terms in a terminology i.e the whole of SNOMED-CT or the whole of a local data dictionary Codeset like Gender. Valueset - a subset of one or more Codesystem terms, organised in to some sort of use-case specific list e.g DiabetesDiagnoses I would not expect the terminology_id (Codesystem id) to change but the Valueset may well change over time. The terminology_id is captured in the CDR but not the Valueset from where it originated. Did you really mean that the terminology_id might change? Could you give some examples? --- ## Post #35 by @damoca [quote="ian.mcnicoll, post:34, topic:2364"] I would not expect the terminology_id (Codesystem id) to change but the Valueset may well change over time. [/quote] I don't know the specific case that @Pau_Corral is facing, but if we look at the specifications, the terminology_id attribute is of type TERMINOLOGY_ID, that at the end is just a String value. But that string has a specific formatting that includes the version of the terminology: ![image|690x366](upload://qXo5j1Kw3bCQZmboWt5ZaDn2zRu.png) So, at least in theory, for every new version of a terminology, we will have a new terminology id. Probably it's not the intended functionality, but that's what I can interpret from the spec. PD. I love when we dig into such small details :sweat_smile: --- ## Post #36 by @borut.fabjan Hi Silje, term_mapping (RM) or term_binding (AM), that is the question :grinning: In AD you can define term_binding(s) for data structure elements or value sets. ![Screenshot 2024-04-29 at 16.52.04|587x282](upload://lWt5QTRRwbSQhaCeIDdgX33QRRr.png) ![Screenshot 2024-04-29 at 17.12.07|690x215](upload://qxQS2zrVMQO6P3uqBU77wDPR1eJ.png) ![Screenshot 2024-04-29 at 16.50.36|626x339](upload://spn3YG9kyo5MkI5jp3O5T4SQQEK.png) This is supported for quite some time ;) --- ## Post #37 by @david.alonso ¿ How to model the use case of allowing a System to accept for the SAME ELEMENT, TWO DIFFERENT TERMINOLOGIES, that CAN NOT BE MAPPED? In our use case there is a functional need to record diagnostics either with ICD-10 or ATIC. ATIC Terminology is used in Catalonia as nursing vocabulary in electronic health record, development of care standards, and data analysis on the provision of nursing care. The thing is, there is NO MAPPING between both terminologies (at least not bidirectional), as ATIC is more specific and granular. There is a partial mapping from ATIC to ICD-10, but not from ICD-10 to ATIC, as it is not always possible to have a 1 to 1 correspondence. There are ICD-10 with NO ATIC correspondence. On the other hand, (n) ATIC could match one single ICD-10. But by doing the conversion you would lose granular information. ![image|690x170](upload://wbELpEm0SvSc9lG9ncV5eJ5AviR.png) So, can you indicate to the implementer something like this? ![image|593x500](upload://qtm5q4GxXeUjfjPktNmstH09v7q.png) This would be like indicating / saying ? Accept values for ICD-10 OR ATIC terminologies. Both are valid terminologies. Or… are we saying… both terminologies are equivalent / mapped. (Which we do NOT want). As a plan B we where tempted to do this in the TEMPLATE ![image|690x268](upload://8VOiQPsFY8AdNwgBS1ThRBk1wLM.png) But probably this would be modelling based on visualization arguments. Any feedback or other solutions for that use case would be welcome. --- ## Post #38 by @damoca I have some comments. The first thing to consider is that a mapping in a DV_TEXT is not necessarily 1-to-1. You can use the "match" attribute of the TERM_MAPPING to define the type of the mapping (even if there is not known mapping at all). So, that should not be a worry for you. ![image|625x500](upload://j55AWJkk3UyImhG3krkRErWPXCR.png) The second thing is that a mapping is always linked to an original value, that would be the DV_CODED_TEXT.defining_code. With your proposals I understand that you want to allow that the original value can be either an ICD10 or an ATIC code. And then you can make a partial mapping to the other terminology. That is certainly a valid approach, but you have to be aware that it can complicate the future querying and use of the information, since you will always have to support or duplicate queries for both terminologies. I guess that it is not possible to decide for just one reference terminology (the most granular one) in the defining_code, and add the other one in the mapping when possible/necessary. But that would be in my opinion the best approach. --- **Canonical:** https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364 **Original content:** https://discourse.openehr.org/t/storing-codes-of-two-external-terminologies/2364