Runtime constraint for container attribute ‘Occurrences’?

Is there a way to specify in a template that out of two sibling nodes with ‘Occurrences’ set to ‘0…1’, exactly one (not less and not more) should be used in a composition?

To illustrate my question, here is a simple template with two ‘any events’ nodes (one ‘any events’ node renamed ‘Point in time’ and the other renamed ‘Episode baseline’):

This template allows for compositions with:

  1. either ‘point in time’ or ‘episode baseline’ having a content
  2. both ‘point in time’ and ‘episode baseline’ having a content
  3. neither ‘point in time’ nor ‘episode baseline’ having a content

How can I constrain this template, so that only compositions with content for either ‘point in time’ or ‘episode baseline’ (i.e. the list item 1 in the list above) are valid?

Hi Emmanuel,

In theory, this could be asserted via the cardinality attribute which is exists on any openEHR container.
like a LIST
So something like OBSERVATION.data.history.events.items cardinality 1…1

However, long ago we stopped using cardinality constraints like this in archetypes and templates as there were very few simple use-cases like this and it was quite difficult for tooling to explain the difference between ‘occurrences’ and ‘cardinality’ to newbies. The interaction between the two was also tricky at times.

So we were actually pretty pleased when Better decided not expose cardinality in Archetyper designer.

The question really, is if you set this (technically correct) who will actually understand it as meeting your requirement. I would just specify separately, even if we could set cardinality in modelling tools

Hi Ian,

Thank you for your clear explanation. Given this background, your recommendation sounds like a good approach.