Existence of Attributes (AOM, ADL and XML)
There is a problem in ADL 1.4 that is not impacting on software at present but which will have to be addressed in the next version of ADL. In the mean time it is recommended that no statements are made in ADL about the existence of an attribute.
Background
Existence is one constraint statement that can be made using ADL/AOM about attributes in a reference model. In ADL as statement will look something like:
ELEMENT matches { value existence matches {1} matches* }
This indicates that the value attribute has to be present. In fact, to this point such statements do not occur in ADL; only statements that an attributes existence is optional occur.
ELEMENT matches { value existence matches {0..1} matches* }
More about this in a moment.
ADL is a serialisation of the Archetype Object Model (AOM) which is not a direct representation but a human readable mathematical expression. In the AOM the C_ATTRIBUTE class (constraint statements on reference model attributes) has an attribute called existence (interval 0..1) which is mandatory. This means that any statement about an attribute has to make a statement about existence.
The Problem
In the reference parser, if no statement is made in the ADL (which is the current situation in virtually all archetypes) the existence attribute of the C_ATTRIBUTE class in memory is set to {1..1} i.e. mandatory. This contravenes that principle that no statement about something means that the reference model specification is followed. This has arisen because the C_ATTRIBUTE class attribute 'existence' is mandatory and the reference parser has not known about reference models; so mandatory existence of {1..1} was chosen many years ago without fully comprehending the consequences. But such statements are not saved as part of the ADL (as no statement is taken to mean that the attribute is mandatory).
In fact most attributes in the openEHR reference model, as in most reference models, are optional. This is the nub of the issue. Everyone has been assuming that no statement in ADL means the attribute's existence is taken from the reference model. Let us consider what we might usefully say as a constraint statement about the existence of attributes.
Attributes in reference models can only be optional or mandatory. It is clear that there are no valid constraint statements to make about the existence of a mandatory attribute - it exists and that is that. So constraint statements can only be made on an optional attribute, and valid statements are to say that it must exists (existence matches {1..1} = mandatory) or that it must not exist (existence matches {0..0} = prohibited). Most important, statements about existence should only occur when constraining the existence as expressed in the reference model.
XML archetypes differ from ADL in that they are direct serialisations of the AOM. This does mean that XML archetypes do have existence statements and they are virtually all mandatory. These will have to change to be correct constraint statements and be ignored for now.
It is worth noting that similar approaches are taken for occurrences. This will need to be upgraded in the future as well.
The Solution
The solution is to make the statement about existence of an attribute optional. This is achieved by making the 'existence' attribute of C_ATTRIBUTE optional through a change in the AOM specification. This needs to be reflected in the AOM XML Schema and all statements on existence removed from the XML archetypes moving to the next version. The reference parser will then not populate this attribute unless there is a statement in the ADL. These statements will be limited to statements about optional attributes in the reference model and will state that the existence is mandatory or prohibited.
The Work Around
Until the next release, all constraint statements about existence in archetypes (where they do occur) should be ignored. That is to say, we should behave as though there is no ability to constrain existence of archetypes. If it is essential to be able to determine that a container attribute (such as protocol) is mandatory, because for example it has a mandatory element within it, then this can be achieved by setting the cardinality constraint to {1..*}.