# Problem with constraint_binding **Category:** [Clinical (archive)](https://discourse.openehr.org/c/clinical-archive/153) **Created:** 2017-03-15 10:29 UTC **Views:** 5 **Replies:** 24 **URL:** https://discourse.openehr.org/t/problem-with-constraint-binding/15469 --- ## Post #1 by @system Dear readers, I have a problem and I want to ask your advise. The problem is that I want to use openEHR-EHR-EVALUATION.problem_diagnosis.v1 which is in CKM. In that archetype is the item "Problem/Diagnosis name", which is of type DV_TEXT. We want to use it as DV_CODED_TEXT, because we want to add code to the entered name. In this situation where I work, the customer wants to use 2 different codes, one company crerated internal codelist, and ICD10. It seems easy to arrange in the archetype, I think I need to specialize it, because I want to add the constraint-bindings to give room for the codes. The archetype-editor from Ocean allows two constraint-bindings on the same node, like displayed below. But this seems wrong to me. In the reference model in the DV_CODED_TEXT is one CODE_PHRASE (1..1). And CODE_PHRASE has terminology_id and code_string also 1..1 So how will the construct below be interpreted following the specs? constraint_bindings = < ["ETDA"] = < items = < ["ac0001"] = > > ["ICD10"] = < items = < ["ac0001"] = > > > My second question, if you say this is impossible to add two terminology constraints to one data-item, which construct do you advise to make two terminology constraints_bindings available to one DV_CODED_TEXT (or maybe another datavalue-type)? Thanks for any help. Best regards Bert Verhees --- ## Post #2 by @system Hi Bert This is correct. If you were to add those constraints in a specialised archetype, at run-time the submitted term in the defining_code attribute would have to come from one of the two terminologies specified. The constraint can define multiple potential terminologies but only one defining_code is allowed in the instance data. Ian --- ## Post #3 by @yampeku What about having two sibling DV_CODED_TEXT nodes as alternatives on the parent? (or specialize two different ones from the single parent one). That would allow to arbitrarily define constraint binding as needed, and in data only one would be correct one --- ## Post #4 by @system Thanks Ian, that explains. Best regard Bert --- ## Post #5 by @system We are considering that Diego, the fact is that the customer wishes to code the name -item two times. Both coding - systems are not easy to map and the mapping cannot be calculated easily by software. So we need two Dv_coded_text's to carry the codes, and only one value to carry the name. The problem with to Dv_coded_text's is however that it offers two value - fields and that is not what we want. It is a pity that a Dv_coded_text only can carry one code. I don't understand that restriction but we cannot solve that now, I hope this can be considered in a RM change. So I think, we will have two Dv_coded_text's and from one having the value put of in a template if that is possible. I look into that tomorrow. Best regards Bert --- ## Post #6 by @Beatriz_de_Faria_Le1 Perhaps the best solution for the time being is to add an additional diagnosis component with the secondary terminology binding that might be used. This is not so common and would need a BR specialization. Beatriz --- ## Post #7 by @system Hi All The idea was that the code_phrase was directly entered as part of choosing the text from the terminology. Anywhere where coding is done as a secondary process, the code mappings allow multiple codes. I think this meets all the needs you have specified. Mappings allow each terminology to be specified. It is likely in the future that EHRs will have multiple mappings for different purposes and different eras of computing, allowing upgrading of historical data. Cheers, Sam --- ## Post #8 by @system Hi Bert, A dv_coded text can carry a single defining_code but as many code mappings as you wish. This makes sense to me as I would always expect one code to be regarded as the original clinical source of truth, and other mappings to be regarded as secondary. All of these can be queried via AQL. The defining_code should be the one that is selected by the user. I would strongly suggest that you use mappings for this purpose. I would also not bother with trying to place constraints via archetypes or templates. You are really not achieving much that cannot be otherwise simply documented or applied in software. Perhaps I'm still not understanding the requirement here? Ian --- ## Post #9 by @system Hi, I need to defer this discussion to next Monday. I will come back to this. Thanks all for your input. Best regards Bert --- ## Post #10 by @system Hi, Multiple codes create the problem of deciding which one is ‘*the truth*’. One code needs be declared to be ‘*the truth’*. But… ‘*The truth*’ depends on the context the code is used in. So how can one declare what the clinical/administrative/research context is? And… ‘*subject*’ has ‘*associated data*' Is the code used for defining the subject of associated data? Or is the code used to define the data provided itself? Gerard Freriks +31 620347088 [gfrer@luna.nl](mailto:gfrer@luna.nl) Kattensingel 20 2801 CA Gouda the Netherlands --- ## Post #11 by @yampeku I assume that mappings could also contain constraint bindings right? --- ## Post #12 by @Karsten_Hilbert But isn't the "name" field in any coded terminology "just another code" for a concept ? Or, in other words, the "canonical", human\-readable, stylised, formal label for a concept the user of a terminology may wish to actually name differently in day\-to\-day use ? Karsten --- ## Post #13 by @system I'm not sure Diego. I guess so. We definitely need to be able to specify at template level how/if any code bindings should be handled at runtime. I suspect this might need some sort of rules that are a bit more complex than just a simple constraint. This conversation might be a chance to tease out exactly what is required in terms of implementer guidance. I.e. In Bert's case, exactly what does the customer expect to happen.? Is ICD preferred to icpc. How is any actual code mapping carried out. I can supply some similar use cases from uk allergies work where we are transitioning to snomed but need to carry legacy codes. Ian --- ## Post #14 by @system Yes. Any item in an archetype potentially has: - an ad-hoc, locally defined, display name - an official canonical name in a specific language domain - and, in order to disambiguate it, an unique code in - a specific terminology/classification domain Gerard Freriks +31 620347088 [gfrer@luna.nl](mailto:gfrer@luna.nl) Kattensingel 20 2801 CA Gouda the Netherlands --- ## Post #15 by @Karsten_Hilbert Hence the notion that the "name" in\*side\* the terminology domain could be discussed to be ignored in the context of Bert's question such that it becomes   user\-level name     code from domain A     code from domain B in which   name from domain A/B/\.\.\. doesn't occur which means   user\-level name IS TO BE mapped at any rate, typically in a way where user\-level name in clinical artifacts isn't directly associated with particular codes but rather a mapping "relation" \(of whatever kind\) is used\. Karsten --- ## Post #16 by @system It is a customer requirement\. It is a real life problem\. It is not very helpful to me to have discussions about the good, bad or ugly of solutions\. But, of course, go ahead for your own interests\. It is about an international organization which processes data from several countries\. The several countries have independent organizations, and the overall organization cannot enforce a common terminology\. There are two terminologies in this case, and those two terminologies cannot be mapped easily, because the granularity is different\. How this is handled until so far this problem is to add the two required codes to an item\. So everybody was happy\. Now this customer is moving over to OpenEHR, and because DV\_Coded\_Text accepts only one terminology per occurrence, this is a problem\.\. It would be nice to have the RM accept more codes, but that is not likely to happen \(anyway not soon\), although I don't see any problem in having this feature\. So we need to find another solution which is elegant and efficient\. My best guess is, to have two DV\_CODED\_TEXT's in a Cluster, and from one DV\_CODED\_TEXT, have the value\-property put off in the template \(I hope that is possible, I did still not look at that, if it is not possible we need the GUI to handle this, which is, I think, the worst case solution\)\. Thanks, Bert --- ## Post #17 by @Peter_Gummer Hi Bert, I think you have missed the response yesterday from a couple of people, who suggested that you could use the DV\_TEXT \(or DV\_CODED\_TEXT\) mappings\.target:   http://www.openehr.org/releases/RM/latest/docs/data_types/data_types.html#_dv_text_class Your text item could have 2 mappings\. The target of each mapping is a CODE\_PHRASE, which has a terminology id and a code\. Does that help? Peter --- ## Post #18 by @system Thanks Peter, I must have missed it\. blush blush \(missing my regular workstation/email client\) It is indeed the solution\. Sorry for that Best regards Bert --- ## Post #19 by @Heath_Frankel1 Perhaps I have come in at the wrong point of the conversation and missed the original question but I believe that the SEC has already approved a change (or at least got a change proposal from me, I’ll need to follow up to find the Jira card) to add a value to the mappings code phrase. Is this a solution to your issue? Heath --- ## Post #20 by @Heath_Frankel1 See SPECPR-132 and proposed solution in SPECPR-165 which is designed to not break the current schema. They appear to be assigned to R1.1 but not progressed to a CR. Heath --- ## Post #21 by @system I was checking again with the multiple simultaneous terminology mapping on one text item. TERM_MAPPINGS could do, but the archetype-editor, nor the ocean, nor the linkehr support it. The template-editor does not support it well. This makes it unmaintainable for the company I work. I could hack it in the datasets, but I am only on temporary base here, that is why this It seems that other have similar problems, and I think a revise of the RM is necessary. Multiple defining_codes on one DV_CODED_TEXT does not break existing datasets or archetypes. And to support the non-code-hackers, a new check on the tooling (regarding to term-mapping) will be necessary, even to support the existing RM features. Bert --- ## Post #22 by @Heath_Frankel1 You don't need to constrain the TERM_MAPPINGS to use it. Regards Heath [details="(attachments)"] [ATT00001.txt|attachment](upload://wVo1VUuhE7uNus1wRoDBWsBTCDE.txt) (192 Bytes) [/details] --- ## Post #23 by @system What if I want a specific number of Term-mappings? (I want two term-mappings) What if I want a specific terminologies to be used? (that was also part of my question) How do I express/constraint that? Maybe I misunderstand the RM on this point. The organization I work for wants to code a disease/problem with two codes, EDTA (which seems to be an organization-related terminology) and ICD10, not two codes to choose from, but to use both. How can I enforce this? I had, last weeks,another question regarding to the use of terminologies. The organization I work for consists of several organizations in other countries. So the sub-organizations have another ICT-history. I have a problem with DV-QUANTITY. The organization wants to code in LOINC. But because there are different countries involved, they use different units, which have different LOINC-codes. The problem is that LOINC uses (sometimes) different codes for different units, especially when the units are not easy interchangeable, like mol and g (gram) So, we can not add LOINC term-binding to lab-tests, and that is really sad. I don't think that my questions are very extraordinary. There are workarounds (do it in programming-code), but I see no elegant solution inside the current RM. It adds up, and I have to explain it to the customer. Best regards Bert Verhees --- ## Post #24 by @system Just catching up on this conversation - I am unclear on why the original solution Bert proposed here isn't correct. What this says is: - for the ac0001 term constraint in the model, allow the term to be from one of ETDA or ICD10 Since this is set at the archetype level, it is stated as true for all instantiations of the archetype. Now, you might say, what does this 'binding' really mean, practically speaking? Because here we are talking about an external value set, so the codes have to come from one of the bound terminologies / value sets. THere is some potentially useful explanation of the meaning of 'binding' in the [ADL2 specification](http://www.openehr.org/releases/AM/latest/docs/ADL2/ADL2.html#terminology_integration_concrete_codes) (I suggest the whole of section 8 is worth reading). However, if the requirement is to limit the possible run time *mappings* recorded in the data for an original term to coming from only 2 particular terminologies, then the suggestions made here about TERM_MAPPING may apply. Note however that these don't solve the question of how to control the coding of the central DV_CODED_TEXT. - thomas --- ## Post #25 by @system I think, the term-binding applies to myproblem with the DV_Quantity, where we want to allow two units, according to to different LOINC codes (one in mol, and one in g) So we want to connect the term_bindings to the units in the DV_Quantity, not to the DV_Quantity itself. It is just to make sure: the value here entered is a value which must be understood according this LOINC-code. I understand that this is not possible. (If you connect two LOINC-codes to one archetype-node, an error occurs in the Template-Editor (when generating HTML, it does another check through the structures (maybe it is the Template-Editor making a mistake?))). If the Dv_Coded_Text would allow two defining_codes, we would have no problem at all. We would write in the value (derived from Dv_Text) the term we wanted to write (in the organization I work, this would be in Hungarian, Slovenian, German, Dutch......) and we would code it twice, once in EDTA and once in ICD10 so that the other member-organizations would also understand what that data-set is about. Some member-organizations work with EDTA, some with ICD10, so we need both codes. I don't understand the philosophy behind the restriction in Dv_Coded_Text to have only one defining code. But OK, it is like that. So we wanted to find the solution in the Term_mappings, a list of term_mappings in Dv_Text (like Heath (and some others) suggested). It looks very familiar then to Dv_Coded_Text. It has a value to write some text in (DvText-value), and it has multiple mappings as Code_Phrase, like Dv_Coded_Text also has a Code_Phrase in defining_code. So we would like to constrain these mappings to use only code from EDTA and ICD10, and we want to check if the two codes are really used (this is the requirement/problem). And now we find that the archetype-editor does not like constraining the Term_Mappings. So we cannot model it on the level where we do the modeling, in archetypes and templates. We must solve this in software-coding, and that create a breach in our barrier between the software-builders and the data-modelers (which is a kind of spaghetti). Bert --- **Canonical:** https://discourse.openehr.org/t/problem-with-constraint-binding/15469 **Original content:** https://discourse.openehr.org/t/problem-with-constraint-binding/15469