ADL v1.4 "existence" default value

I’m parsing some ADL v1.4 using the very helpful antlr4 grammars and using an archetype from the CKM which can be downloaded in both XML and ADL to check how I’m doing. I have a question about the existence parameter.

The specification says “The default existence constraint, if none is shown, is {1..1}.” so I’d take the below snippet of cADL

events cardinality matches {1..*; unordered} matches {

to end up in XML as something like the below

        <attributes xsi:type="C_MULTIPLE_ATTRIBUTE">
          <rm_attribute_name>events</rm_attribute_name>
          <existence>
            <lower_included>true</lower_included>
            <upper_included>true</upper_included>
            <lower_unbounded>false</lower_unbounded>
            <upper_unbounded>false</upper_unbounded>
            <lower>1</lower>
            <upper>1</upper>
          </existence>

However in the XML downloaded from CKM, the lower is 0, which doesn’t match the spec. My question is - have I found a bug in the CKM XML output, or is my interpretation of the spec/the spec itself wrong?

It’s not clear for me if you uploaded and downloaded the same archetype, and in the upload it was 1..1 and in the download it was 0..1. That’s a quick test to find if the issue is in the CKM.

Both are openEHR-EHR-OBSERVATION.blood_pressure.v2 https://ckm.openehr.org/ckm/archetypes/1013.1.3574.

If you look at the XML v1.4 for the attribute events under HISTORY[at0001] the snippet of XML is

        <node_id>at0001</node_id>
        <attributes xsi:type="C_MULTIPLE_ATTRIBUTE">
          <rm_attribute_name>events</rm_attribute_name>
          <existence>
            <lower_included>true</lower_included>
            <upper_included>true</upper_included>
            <lower_unbounded>false</lower_unbounded>
            <upper_unbounded>false</upper_unbounded>
            <lower>0</lower>
            <upper>1</upper>
          </existence>

and the relevant snippet of ADL is

			HISTORY[at0001] matches {    -- History
				events cardinality matches {1..*; unordered} matches {

The existence of events is not explicitly given in the ADL and thus my thought is that it should have 1..1 existence in the XML but this is not the case and it is 0..1.

You are not the first to be confused: Confused on cardinality for Protocol - #3 by sebastian.garde

In ADL 1.4, an unstated existence historically defaulted to 1..1 (mandatory) as you noted. However, modern interpretations and ADL 2 derive effective constraints and defaults directly from the underlying Reference Model (RM) or treat unstated constraints as optional/implicit.

If you want your ADL parser to be ready for ADL2, I suggest you also use the RM during parsing ADL 1.4. The defaults for HISTORY.events should be taken from the RM HISTORY class where they are optional.

Check the ADL 2.4 (experimental) radio button on the bottom of ADL tab in CKM. There is also ANTLR4 for ADL2.