ADL2 generation appears to be incorrect

Having a look at the openEHR-EHR-OBSERVATION.waterlow_score.v0.0.1-alpha (random choice), in its ADL1.4 form as shown on CKM, there is a term (again, random) at0116, which is the code of an ELEMENT node.

Here is the ADL1.4 form:

				CLUSTER[at0066] occurrences matches {0..1} matches {    -- Skin type visual risk areas
					items cardinality matches {1..*; unordered} matches {
						ELEMENT[at0116] occurrences matches {0..1} matches {    -- Healthy
							value matches {
								0|[local::at0116]
							}
					}
...

terminology
                ...
    		    ["at0116"] = <
					text = <"Healthy">
					description = <"The skin appears healthy.">
				>

Here is the ADL2.4 form:

    CLUSTER[at0066] occurrences matches {0..1} matches {    -- Skin type visual risk areas
        items cardinality matches {1..*; unordered} matches {
            ELEMENT[at0116] occurrences matches {0..1} matches {
                value matches {
                    DV_ORDINAL[at9033] matches {
                        [value, symbol] matches {
                            [{0}, {[at117]}]
                        }
                    }
                }
            }
...
terminology
        ...
            ["at117"] = <
                text = <"Healthy">
                description = <"The skin appears healthy.">
            >

In the ADL 1.4 form, an at code is reused both as a node identifier and as a value. This is bad design for many reasons (and one of the things id-coded archetypes fixed), but the real problem is that i the ADL2 generated form, there is no at0116 code definition at all, but there is a new at117 value code. It looks like the converter is synthesising the at117 from the original at0116, for use as a value code, but forgetting to keep the at0116 term definition in the terminology. Maybe @sebastian.garde could take a look, also the Archie maintainers?

I hate to note (but feel compelled): but the new ADL2.4 coding idea, applied to the above archetype, with the generator fixed, will result in both an at117 value code, for the at0116 node, and an at0117 node (here at0117 is an id code), for the next node. I.e. both at117 and at0117. That’s going to be pretty confusing.

I have run a recent ADL2 format dump of CKM through some new tools, and there are too many problems for me to count at the moment, the above is just a randomly chosen one. I would imagine there are some simple code changes possible to fix most problems.

Hi Thomas,

I have seen this myself in FerroEHR as well.

FerroEHR validates every ADL 2 archetype against the AOM 2 and ADL 2 rules when it is uploaded. Of the 322 archetypes in the 2013 CKM ADL 2 export, 91 cannot be loaded: each one is refused with a 422 that names the rule it breaks. The run had SNOMED CT (International 2026-11-01) and LOINC 2.83 served, so every term binding was checked too, and I checked the findings against the development releases of the RM and AM.

The full list, with each archetype, the rule and the exact error, is here: upstream(ADL2): 91 archetypes of the 2013 CKM ADL 2 export fail AOM 2 validation · Issue #4512 · FerroHEALTH/FerroEHR · GitHub

In short:

  • 62 constrain property on DV_QUANTITY. No RM release defines that attribute, so this looks like the conversion carrying the ADL 1.4 C_DV_QUANTITY.property into an attribute position.
  • 19 break other rules: constraint codes with no definition (VACDF, the same pattern as your waterlow_score example), languages missing from the parent (VALC), invalid differential paths (VDIFP), slots restated instead of narrowed (VDSSM, VDSSID), duplicated node ids (VCOSU), and LOINC bindings to codes that do not exist (VETDF: apgar binds its answer codes without the check digit). Every SNOMED CT binding resolves.
  • 9 are specialisations whose parent is itself refused, so they may be fine once the parent is fixed.
  • 1 (microscopy_prostate_carcinoma, which constrains is_integral) is our own limitation, not the archetype’s, and we are fixing it.

A template whose constituent archetype is refused then also fails later, for example openEHR-EHR-COMPOSITION.t_encounter_opt_test.v1.0.0, which refers to openEHR-EHR-OBSERVATION.apgar.v1.

I hope the list helps @sebastian.garde and the Archie maintainers find the converter cases. If most of them come down to a handful of code-mapping rules, as you suspect, the property group should be the first one to look at.

CKM uses Archie. We are doing a big CKM upgrade next week and this will also update the converter from Archie.
I believe there were some changes and fixes in that area. Even then, Archie’s at-code system based conversion is still on a branch, so I assume adl2.4 conversion may not yet be 100% stable…like adl2.4 itself.

Hey all! I checked these points against Archie’s current ADL 2.4 work (the adl_2.4_support branch). That branch was still very much in progress, but we’re not too far away from releasing our initial ADL 2.4 support.

Someone replied to your post.

[MattijsK] MattijsK Mattijs Kuhlmann SEC member
2 November

Hey all! I checked these points against Archie’s current ADL 2.4 work (the adl_2.4_support branch). That branch was still very much in progress, but we’re not too far away from releasing our initial ADL 2.4 support.

  • waterlow_score (at117 instead of at0116): fixed on that branch. The at-coded conversion now keeps at0116, both as node id and as ordinal value, and defines it in the terminology.
  • DV_QUANTITY.property: Archie writes this on purpose, because the ADL2 spec constrains property on DV_QUANTITY in many of its examples. The RM spec doesn’t define that attribute, though. Which one should we follow here? Is the RM missing property, or should ADL2 not use it?

It’s a real annoyance. Since it does not constrain anything real, I think it should be considered an ADL1.4. anomaly (one of my bad ideas from a very long time ago, so you can blame me;) and the ADL1.4 → ADL2 converter should strip it out completely. To do that, you’ll need to code some sort of ‘exceptions list’ or ‘adjustments list’. But if it is removed from the ADL2 archetypes, it will make everyone’s lives easier.

  • The FerroEHR list is based on the 2013 ADL2 export, which predates Archie’s converter, so most findings don’t apply to the current output. A few do, and we created issues for them:

  • Issues · openEHR/archie · GitHub the converter crashes on constraints like [openEHR::] (e.g. lab_test)

  • Issues · openEHR/archie · GitHub ADL 1.4 specialisations that add codes like at0006 instead of at0.1

that is wrong, even in ADL1.4!

  • Issues · openEHR/archie · GitHub specialised slots get lost (already known)

  • Some findings are problems in the source archetypes themselves, e.g. missing LOINC check digits in apgar and a specialisation that extends its parent’s value set in auscultation-chest.

Leave those for the ADL2-based compiler to find…

While I agree it is not a proper attribute, it is not true that it is making everyone’s lives easier. Certainly not mine if you just want to state or show that the quantity is - say - a length.

What I mean is that every tool that contains a compiler has to have special code to handle this anomaly. The original idea (you probably remember!) was to allow pseudo-attributes to be constrained in the archetype that did not exist in the target RM. The problem with this however is that no tool can tell the difference between such attributes and outright errors (e.g. a real attribute, but spelled wrongly due to manual editing). I’ve looked at 2 or 3 ways to deal with it in my new tools, and they’re all ugly. The worst is possibly adding a fake attribute with some special meta-type to the RM (i.e. to BMMs). But then other tools like code generators that assume an RM is an orthodox model will fail in unexpected ways, unless you put special rules there as well.

I agree with @borut.jures from last year when he said the same thing - and he has done a lot of code generation from models, so I think he’s also coming from a tooling perspective.

I don’t see the utility of property in an archetype. It constrains nothing. You might say that we need a way to lock the property down while modelling, so as to allow the correct selection of units. I agree with that, but that’s a knowledge question, not a model or data question. For example, modelling of BP should proceed as follows:

  • I want define an ELEMENT to represent systolic BP (I know it will be units of pressure)
  • In a knowledge-based tool, I type in ‘systolic blood..’ to find an entity from a medical ontology
  • That ontology, if constructed properly will have IS-A relationships that go up to some entity that means ‘pressure in a vessel’, and then ‘pressure’, which has a meta-property ‘is-measurable’
  • The ‘pressure’ ontology code is used to find pressure units in the ontology or maybe in a units knowledge service or DB (it might even be super smart and know which units are preferentially used in medicine)
  • I will get a choice of ‘Pa’ + SI modifiers (k, m, etc) and ‘mm[Hg]’, maybe even ‘N/m^2’ or other pressure units
  • I choose mm[Hg], since that’s what is used in medicine

There is no ‘property’ needed in the RM or archetype to achieve the above.

Well it constrains the property.
I can at least imagine high-level (~abstract) archetypes where you want to do this without selecting individual units.
In such cases, you may not want to add all possible units you can possible use m, cm, µm, but forget about - say - dm and km, and miles and feet.
Here you may well just want to say: This is a length, measured in whatever way.

Further down - say in a template or a specialisation - you then constrain this down to your units.

For BP it is (traditionally) clear and 1:1 - but of course some country at some stage may find this archaic and might want to use SI units, Pascal in this case, sometime in the future.

If you/clinical modellers do not want to support the above either because it is simply not needed at all or because it is somewhat useful but not worth the extra complexity, you don’t need it and we can get rid of it.
I certainly agree with your argument of proper separation, and understand the pain.
But nonetheless, in the end, this shifts the complexity, away from core tooling to modelling tooling like AD, conversion tooling (as you suggest yourself above) and also governance tooling like ckm.

One thing to at least consider as an alternative:
It could also just be a function instead of a full attribute.
Functions have been constrained in one or two places as well, e.g. the EVENT offset.
Even though this is always a bit problematic as well, I don’t think anybody has found a way around constraining EVENT.offset in e.g. the APGAR archetype so far…?

Yes. I seem to recall that it was removed from Archetyoe Designer adl output and needed to be i troduced becausevall of the reasons above

What ‘property’? There’s no ‘property’ property in the RM class. It does constrain the notional property of the measurable entity we are trying to model, but that’s an ontology question, not a data question.

Yes, we’ve talked about that previously. But semantically that’s a constraint on the units property of DV_QUANTITY, which is just defined as a String.

Here’s an idea: we could create a new type Units, and treat it as a primitive type (like Terminology_code). In the SPLASH type system, I actually make all the ‘string’ types like Uuid (string form), Uri, Object_id (+ descendants) inherit from String (we didn’t do this in openEHR, but I’ve come around to seeing it as a better modelling approach, and it also creates less nesting in data). It would be possible then to add more C_primitive_object types to the AOM, of which one could be C_units (just as we already have C_terminology_code). That would provide a place to allow physical property to be constrained - but now it would be a property in the archetype meta-model, not in the RM, where it is not needed.

I remember challenging that attribute in the past for not being part of the RM, though it’s not an ADL2 specific problem…

TL;DR the property constraint shouldn’t be an attribute in the archetype but a terminological constraint.

I think my analysis at that time was that the constraint over “DV_QUANTITY.property” was really a constraint over “DV_QUANTITY.units”, though since units is a String, there are not unit semantics there to apply the physical property constraint. The real issue is the property constraint is really a terminology constraint that’s specific for UCUM. For instance if units were a DV_CODED_TEXT or CODE_PHRASE instead, the constraint would be in a binding for the code like “openEHR-EHR-OBSERVATION.fundoscopic_examination.v0.adl: [“ac0002”] = terminology:SNOMED-CT/408733002?subset=Diabetic%20Retinopathy%20Study%20field”

But with UCUM and property: [“ac0002”] = terminology:UCUM?property=125

Though we made some changes in this direction by adding the units_system and units_display_name to "emulate’ a DV_CODED_TEXT to prevent breaking changes, the ideal solution would be to make the units coded (DV_CODED_TEXT or CODE_PHRASE).

That is certainly one solution, and some people like units as Snomed codes, which I personally think is a terrible idea. UCUM has it right - units are concretely very special strings resulting from a special ontology of physical properties, units, multipliers, and combining rules.

CKM has been upgraded now and this is one of the things fixed by updating the version of the Archie branch mentioned by Mattijs, see

For all the details on all the CKM changes, see https://openehr.atlassian.net/wiki/spaces/healthmod/pages/3989012483/CKM+Release+1.22.0