# FHIR value set with different code system in a DV\_CODED\_TEXT constraint

**URL:** https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005
**Category:** HL7 FHIR
**Tags:** fhir, archetype, archetype-designer
**Created:** [23 July 2025 22:18 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005 "2025-07-23T22:18:10Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [23 July 2025 22:18 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/1 "2025-07-23T22:18:10Z")

</div>

Hi,

In FHIR a `value set` can have codes from many `code systems`, there is a URI to identify the whole `value set`, and each `code system` also has it’s own URI.

In data instances, nodes that are bound to a `value set` will have the `code system` URI alongside with the code and not the `value set` URI.

So how is this modeled in openEHR to constraint a DV\_CODED\_TEXT terminology\_id?

Should we use the `value set` URI? Or the many `code system` URIs associated with the `value set`?

Thanks!

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [23 July 2025 22:32 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/2 "2025-07-23T22:32:52Z")

</div>

In the Archetype Designer I tried to add two constraint\_bindings with the `code system` URIs, though when exporting the OPT, only one appears, it’s like AD totally ignores the constraints. I’ll test in LinkEHR exports the right constraint in the OPT.

```json
	constraint_binding = <
		["Otras relaciones de contactos del paciente"] = <
			items = <
				["ac0001"] = <http://terminology.hl7.org/yyy>
			>
		>
		["Relaciones de contactos del paciente"] = <
			items = <
				["ac0001"] = <http://terminology.hl7.org/xxx>
			>
		>
	>

```

```xml
              <children xsi:type="C_COMPLEX_OBJECT">
                <rm_type_name>DV_CODED_TEXT</rm_type_name>
                <occurrences>
                  ...
                </occurrences>
                <node_id />
                <attributes xsi:type="C_SINGLE_ATTRIBUTE">
                  <rm_attribute_name>defining_code</rm_attribute_name>
                  <existence>
                     ...
                  </existence>
                  <children xsi:type="C_CODE_REFERENCE">
                    <rm_type_name>CODE_PHRASE</rm_type_name>
                    <occurrences>
                      ...
                    </occurrences>
                    <node_id />
                    <referenceSetUri>http://terminology.hl7.org/yyy</referenceSetUri>
                  </children>
                </attributes>
              </children>

```

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [23 July 2025 22:57 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/3 "2025-07-23T22:57:58Z")

</div>

No luck with LinkEHR, there are some bugs in the last Linux version that prevent me to even create the archetype with a DV\_CODED\_TEXT node. @damoca @yampeku

---

<div class="post-metadata">

### Author: ![yampeku](https://discourse.openehr.org/user_avatar/discourse.openehr.org/yampeku/32/25_2.png) [@yampeku](https://discourse.openehr.org/u/yampeku)
#### Post date: [23 July 2025 23:01 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/4 "2025-07-23T23:01:55Z")

</div>

Even with the generic tree editor (non-openEHR specific) is giving you an error?. That’s really weird, happy to create the example or exporting some ADL into OPT

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [23 July 2025 23:20 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/5 "2025-07-23T23:20:39Z")

</div>

If I create, for instance a PERSON with details \> tree \> element, there is no option for adding a DV\_CODED\_TEXT directly, so I added a DV\_TEXT and set it to use the subclass DV\_CODED\_TEXT. Then the editor started to do strange things, like removing items from the ontology.

After that, it didn’t allow me to add constraints.

Then I created an ADMIN\_ENTRY with tree \> element, there the DV\_CODED\_TEXT appears as an option. Then in the constraints, I can’t add a constraint\_binding (constraint ref), I can’t find an option to do so. I see options to add existing terminologies but not a custom URL like:

```auto
["ac0001"] = <http://terminology.hl7.org/yyy>

```

---

<div class="post-metadata">

### Author: ![yampeku](https://discourse.openehr.org/user_avatar/discourse.openehr.org/yampeku/32/25_2.png) [@yampeku](https://discourse.openehr.org/u/yampeku)
#### Post date: [24 July 2025 07:14 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/6 "2025-07-24T07:14:57Z")

</div>

terminologies are defined on a file inside linkEHR data folder, you can add them there if needed. In principle you should be able to add acXXXX codes whenever you can define a string constraint (in generic editor) for openEHR specific editor, you should be able to define over “Code” classes too

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [24 July 2025 12:19 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/7 "2025-07-24T12:19:16Z")

</div>

Thanks @yampeku the only thing I need to to set two FHIR `code system` URIs as the constraint\_bindings for ac000X on a DV\_CODED\_TEXT, not adding the full terminology.

Can I do that in LinkEHR?

In Archetype Designer I can do it just by setting the constraint of the DV\_CODED\_TEXT to `external terminologies`, but the AE removes the second constraint when exporting the OPT.

---

<div class="post-metadata">

### Author: ![yampeku](https://discourse.openehr.org/user_avatar/discourse.openehr.org/yampeku/32/25_2.png) [@yampeku](https://discourse.openehr.org/u/yampeku)
#### Post date: [24 July 2025 12:27 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/8 "2025-07-24T12:27:29Z")

</div>

In principle is straightforward  
From the DV\_TEXT itself you can define a constraint ref

 ![imagen](https://discourse.openehr.org/uploads/default/original/2X/9/90e9362840693d7c3aa0ce57c940a1f42eed8e0d.png)  
These would be bound to the same acxxxx code.  
You’ll have to add the vocabularies to data/linkEHR/teminology/terminology.xml in order to be able to add them as bindings

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [24 July 2025 14:38 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/9 "2025-07-24T14:38:38Z")

</div>

@yampeku did you try to export an OPT that includes that archetype? Will that have the two URIs? Thanks!

---

<div class="post-metadata">

### Author: ![yampeku](https://discourse.openehr.org/user_avatar/discourse.openehr.org/yampeku/32/25_2.png) [@yampeku](https://discourse.openehr.org/u/yampeku)
#### Post date: [24 July 2025 14:49 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/10 "2025-07-24T14:49:15Z")

</div>

while the reference is being stored as an acXXXX code the acXXXX themselves are not being exported in the OPT, which makes sense as there is only term\_definitions and term\_bindings defined in the OPT xml schema [https://specifications.openehr.org/releases/ITS-XML/Release-2.0.0/components/AM/Release-1.4/Template.xsd](https://specifications.openehr.org/releases/ITS-XML/Release-2.0.0/components/AM/Release-1.4/Template.xsd)

 ![imagen](https://discourse.openehr.org/uploads/default/original/2X/c/c22a2a20b3c01773023a39b78a6c9c5bae8ddda2.png)

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [26 July 2025 19:19 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/11 "2025-07-26T19:19:15Z")

</div>

I’ll look at that. What’s strange is that in the OPT’s I’ve seen and in the ones exported from the AD, what gets exported is the URI in `referenceSetUri`, not the ac code in `reference`.

Which OPT schema is used in LinkEHR? Does it allow both? Can it allow to put multiple `referenceSetUri` with the URIs? (which is the case I’m trying to model, because once I export the OPT and use it on a system, the system doesn’t have access to the original archetypes, so there is no way to look for those URIs referenced by the ac code).

Thanks!

---

<div class="post-metadata">

### Author: ![grahamegrieve](https://discourse.openehr.org/user_avatar/discourse.openehr.org/grahamegrieve/32/3602_2.png) [@grahamegrieve](https://discourse.openehr.org/u/grahamegrieve)
#### Post date: [27 July 2025 07:10 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/12 "2025-07-27T07:10:09Z")

</div>

> Should we use the `value set` URI? Or the many `code system` URIs associated with the `value set` ?

I’m not answering the archetype editor question, but from a FHIR point of view, the answer is very clear: you use the code system URI in the DV\_CODED\_TEXT, not the value set - the value set URI belongs in the constraint. (I think that’s what I see in this thread, so I’m answering the original question)

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [27 July 2025 23:25 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/13 "2025-07-27T23:25:05Z")

</div>

> [@grahamegrieve](#):
>
> you use the code system URI in the DV\_CODED\_TEXT

Thanks @grahamegrieve this is clear for me, I think it was Loyd that help me understand that in the FHIR community chat.

My question is about how to model that in openEHR, since editors don’t seem to handle this case very well, especially when exporting the final template to be used in a CDR, which seems like a problem for current integrations using openEHR and FHIR (as I’m working on at this very moment).

Only in one archetype editor it seems possible to put multiple `code system` URI constraints on a single DV\_CODED\_TEXT, in the rest it doesn’t seem possible, but in all the exported template has just one URI.

Maybe that’s an item to consider by the group working in the openEHR+FHIR collaboration agreement: this should be supported by openEHR tools.

---

<div class="post-metadata">

### Author: ![ian.mcnicoll](https://discourse.openehr.org/user_avatar/discourse.openehr.org/ian.mcnicoll/32/4430_2.png) [@ian.mcnicoll](https://discourse.openehr.org/u/ian.mcnicoll)
#### Post date: [28 July 2025 08:23 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/14 "2025-07-28T08:23:27Z")

</div>

ADL2 does handle this a little better but TBH I would just offload the whole responsibility to a FHIR server-based Valueset and Codesystems. I’m not sure I see the need to replicate that functionality in openEHR.

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [28 July 2025 13:50 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/15 "2025-07-28T13:50:52Z")

</div>

Tough how can we implement the constraint in 1.4? 2 Is not an option.

Using an external server works for validation, not at design time. Or I’m missing something?

---

<div class="post-metadata">

### Author: ![ian.mcnicoll](https://discourse.openehr.org/user_avatar/discourse.openehr.org/ian.mcnicoll/32/4430_2.png) [@ian.mcnicoll](https://discourse.openehr.org/u/ian.mcnicoll)
#### Post date: [28 July 2025 16:57 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/16 "2025-07-28T16:57:55Z")

</div>

You can hook ArchetypecDesigner up to a fhir TS. id create the Valueset manually ir with snapper snd host in a local fhir service

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [28 July 2025 18:54 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/17 "2025-07-28T18:54:21Z")

</div>

@ian.mcnicoll I don’t understand how that setup is going to help with the constraint needed in the opt. Can you expand?

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [29 July 2025 05:59 UTC](https://discourse.openehr.org/t/fhir-value-set-with-different-code-system-in-a-dv-coded-text-constraint/7005/18 "2025-07-29T05:59:02Z")

</div>

I think formally, all OPTs 1.4 need is to be able to have multiple (1..\*) referenceSetUri at the C\_CODE\_REFERENCE level, which right now is 1..1 (implicit because it doesn’t have minOccurs or maxOccurs):

> <https://github.com/openEHR/specifications-ITS-XML/blob/master/components/AM/Release-1.4/Template.xsd#L119>

That will allow multiple terminology\_id values allowed for a single DV\_CODED\_TEXT node.

Though I can update our own XSDs easily, it’s a pain to remember this case on every OPT export from modeling tools and needing to manually add the missing refs, but life isn’t perfect. Another option is to build our own modeling tool to comply with these practical requirements.

Anyway, I’m wondering why this case isn’t more frequent in openEHR modeling, or how modelers workaround this issue, because it seems a pretty common case in the FHIR world.

Again, I think this is something the FHIR-openEHR collaboration group might take into account, though I’m not sure who is in that group from the openEHR side. I would love to help if I knew how to participate in that group.

Best,  
Pablo.
