# Creating archetypes with alternatives

**URL:** https://discourse.openehr.org/t/creating-archetypes-with-alternatives/15467
**Category:** Technical (archive)
**Created:** [8 February 2017 23:52 UTC](https://discourse.openehr.org/t/creating-archetypes-with-alternatives/15467 "2017-02-08T23:52:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [8 February 2017 23:52 UTC](https://discourse.openehr.org/t/creating-archetypes-with-alternatives/15467/1 "2017-02-08T23:52:15Z")

</div>

Hi,

I’m testing the EHRServer with alternative datatypes for the same ELEMENT.value.

I found the only way of doing that in the Archetype Editor is by setting the node as Any. And there is no way to further constraint the allowed datavalues in the AE.

In the Template Designer I can further constraint that by specifying which specific types can be used, to avoid the possibility of allowing any datavalue to be there. The problem I found is that after setting the allowed datavalues, I can’t set constraints for them, e.g. if I specify Coded Text, I can’t set the code list.

Shouldn’t the datatype constraints be set also on the AE and the constraints per allowed datavalue allowed to be set on the AE and TD?

I’ve seen some ADLs/OPTs from Brazil with alternatives, and I don’t know if they are using another AE/TD or just setting the constraints by hand. For example a problem status archetypes has this which I can’t reproduce in the Ocean’s AE:

ELEMENT[at0082] occurrences matches {0.._} matches { – Unspecified  
value matches {  
DV\_TEXT matches {_}  
DV\_BOOLEAN matches {  
value matches {True, False}  
}  
DV\_COUNT matches {\*}  
}  
}

Thanks!

---

<div class="post-metadata">

### Author: ![Peter\_Gummer](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@Peter\_Gummer](https://discourse.openehr.org/u/Peter_Gummer)
#### Post date: [9 February 2017 00:25 UTC](https://discourse.openehr.org/t/creating-archetypes-with-alternatives/15467/2 "2017-02-09T00:25:32Z")

</div>

Hi Pablo,

The way to produce the ADL that you’ve posted below is with a “Choice” element.

1. Go to the Archetype Editor’s “Definition” tab.  
2. Click the [+] button on the left.  
3. From the drop-down list, select “New element” and “Choice”.  
4. Over on the right of the screen, you will see two buttons, [+] and [-]. Click the [+] button and select “Text”.  
5. Repeatedly click the [+] button to add all of the data types that will be permitted in this element.

Hope that helps,  
Peter

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [9 February 2017 02:59 UTC](https://discourse.openehr.org/t/creating-archetypes-with-alternatives/15467/3 "2017-02-09T02:59:23Z")

</div>

Thanks Peter,

The Choice worked as expected in the AE, but there is an issue with the TD.

I was able to set CODED TEXT, COUNT and DATE TIME, and set constraints to them like this:

ELEMENT[at0005] occurrences matches {0..1} matches { – choice  
value matches {  
DV\_CODED\_TEXT matches {  
defining\_code matches {  
[local::  
at0006, – 11  
at0007, – 22  
at0008] – 33  
}  
}  
DV\_COUNT matches {  
magnitude matches {|0..500|}  
}  
DV\_DATE\_TIME matches {\*}  
}  
}

The problem is when I export OPTs using that archetype, all the constraints are gone, for example, I created a template that only allows CODED TEXT, and the result is this (no codes in the code list of the CODE\_PHRASE):

DV\_CODED\_TEXT true true false false 1 1 defining\_code true true false false 1 1 CODE\_PHRASE true true false false 1 1 openehr 433

---

<div class="post-metadata">

### Author: ![system](https://discourse.openehr.org/uploads/default/original/2X/f/f0a1dedb20c42747bddcafd6c7df9db5f34f003c.svg) [@system](https://discourse.openehr.org/u/system)
#### Post date: [9 February 2017 03:19 UTC](https://discourse.openehr.org/t/creating-archetypes-with-alternatives/15467/4 "2017-02-09T03:19:08Z")

</div>

I copied the wrong CODED TEXT from the OPT, the node that has the code list in the ADL but doesn’t in the OPT, don’t include the CODE PHRASE node:

DV\_CODED\_TEXT true true false false 1 1
