Specialize section in the OPT2

I used Generic lab test result example simple and converted it to OPT2 using Nedap’s great VSCode extension.

The resulting “openEHR-EHR-COMPOSITION.report-result.v1.0.4.opt2” has a “specialize” section which is not expected by the ANTLR4 openEHR/adl-antlr Adl2.g4 grammar:


But it is in the grammar that Archie is using: Adl.g4. (@pieterbos)

And it is not in the wolandscat/openEHR-antlr4 Adl2Parser.g4. (@thomas.beale)

OPT2 specifications say that the “specialize” section should be omitted from the OPT2 (bullet #2):

“no specialisation statement - an OPT is considered a ‘top-level’ standalone artefact;”

Without the specialize section in an OPT 2 you do not know which archetype is being specialized. So it is necessary to have it there, and I consider it an error in the ANTLR grammar if it is missing.

1 Like

@thomas.beale should I create an issue in specpr about this? The OPT2 spec says the specialise section should be removed, and it is missing from the grammar.

However, that means with just an OPT2 it is impossible to know which archetype is used at the root of the OPT, and you would need both the OPT2 and the source template to know this. This would make the OPT2 no longer the standalone artifact it is intended to be. Hence, I think the specialize section is necessary in the OPT2 adl, and the text about removing that section should be removed from the OPT2 spec.
OPT 1.4 also contains this information, meaning that omitting this will further complicate migration from 1.4 to 2.

Agreed that this is an issue that we should address?

I think so. I did think about this a long time ago, and came to the conclusion that we didn’t need it, but now can’t remember how that made sense :wink: So, yes, PR…

Done. this includes two other issues with opt 2:

  • the grammar does not allow for structure to appear below a use_archetype in three, while the AOM says it is the way to do this.
  • node id replacement with archetype ref is ADL 1.4 style, and not legal in the grammar - I think it should not be specified in AOM 2.