Bug in export of ORDINAL texts defined in templates

Hi!

When trying to be a bit too clever and use the (now multilingual!) support to make ORDINAL type selection and value list definition in templates (rather than only in archetypes), then I encountered what I believe to be an export bug in Archetype Designer (AD).

The text labels of ordinals defined at template level (as opposed to archetype level) do not get exported to e.g. operational templates (OPT) or web templates (WT). However they do seem to be saved in ADs built-in native (.t.json) format and do re-appear in the editor UI when closing and reopeing the template in the editor.

You can even detect the bug in AD’s form preview (that likely also uses the export function) see red marks below:

If you use the form preview’s “Export to JSON”…

…then you can note that the values get set as expected:

        "container": [
            {
                "followup_question_with_ctcae_test": [
                    {"ordinal_type_and_content_defined_in_archetype": [ "at0.3" ] }
                ],
                "followup_question_with_ctcae": [
                    { "ordinal_type_set_in_archetype_and_ordinal_content_defined_in_template": [ "at0.0.2" ] }
                ],
                "followup_question": [
                    { "ordinal_type_set_in_template_and_ordinal_content_defiend_in_template": [ "at0.2" ]  }
                ]
            }
        ]

The exported OPT from AD shows up without the same labels in both in Cambios’s preview tool…

…and Betters in form builder tool:

Here is the file-set with test archetypes/template…
openEHR-EHR-CLUSTER.followup_question.v0.adl (4.6 KB)
openEHR-EHR-CLUSTER.followup_question-ctcae.v0.adl (6.3 KB)
openEHR-EHR-CLUSTER.followup_question-ctcae_test.v0.adl (7.3 KB)
openEHR-EHR-COMPOSITION.encounter.v1.adl (36.4 KB)
openEHR-EHR-EVALUATION.container.v0.adl (5.8 KB)
test of ordinal selection defentition in template.opt (41.7 KB)
test of ordinal selection defentition in template.t.json (90.0 KB)

…and some screenshots from the editor showing the intended content that only gets partially exported:

@borut.fabjan when would you guess that a release with the bug fixed will appear?

Hi,

often there’s a thin line between a bug, new modelling pattern or some murky detail in the spec. :wink:

The core issue is related to ADL14 approach to specialisation within template.
Legacy .OET solved the problem by hacking id & text into same value:

           archetype_id="openEHR-EHR-CLUSTER.followup_question-ctcae.v0"
           max="1" path="/data[at0001]/items[at0004]" xsi:type="tem:CLUSTER">
           <Rule max="1"
               name="Ordinal type set in archetype and ordinal content defined in template" path="/items[at0002.1]">
               <constraint xsi:type="tem:ordinalConstraint">
                   <includedValues>1|one</includedValues>
                   <includedValues>2|two</includedValues>
                   <includedValues>3|three</includedValues>
               </constraint>
           </Rule>

===
To overcome & bridge the differences between ADL14/ADL2 we store template artefact in a AD native format.
However some of this differences may potentially get lost when exported.

This can be fixed, but requires a change in despecialisation rules for .OPT.

1 Like

Hi!

I have tried but probably not completely succeded to understand the meaning and implications of @borut.fabjan’s response .

I made new tests with an enhanced test file with an extra repetition of the node B: (repeated node is marked BB:) see image below. The test file also has language translations (a proper one to Swedish and a bad incomplete one in German). The file and fileset are available in https://github.com/regionstockholm/background_and_examples/tree/main/AE_ORDINAL_export_bugs

Please confirm/reject and possibly enlighten regarding the following assumptions:

  1. The native format of Archetype Designer (AD) handles and stores (even multilingual) specialisations of ORDINALs at template level. Yes?

  2. Export of ORDINALs defined at template level is supported by AE for openEHR 1.4 .OET template files. (A separate file export per translataion language needed.) The output will be in the by @borut.fabjan above described “1|one” format (hack) for the original language of the template, but does not work for translations (exported file shows the template’s original language in ORDINALs instead).

  3. Export of ORDINALs defined at template level could become supported by AE for Operational Templates .OPT (1.4) files (If you have repeated/redefined nodes, then a separate file export per translataion language is likely needed, and don’t forget the l10n annotation trick for the repeated nodes.) If you select Swedish as primary language when exporing you get a file like test 2 of ordinal selection defentition in template.sv.opt
    BUT there is currently a bug in AE OPT export code for term definitions of template level specialized ORDINALs (no matter if exporting in original language or translated language) so you have to patch the files (manually or via script) to include snippets like <term_definitions code="at0.0.1"> < items id="text">mild B (sv)</items> < items id="description">B1</items> </term_definitions>and then it works like a charm to import the
    manually patched test 2 of ordinal selection defentition in template.sv.opt to form building tools:


    If you do a A diff between the exported and patched file then it shows what’s missing in the current export.

  4. Export of ORDINALs defined at template level could become supported by AE for web templates (.json). The file format can support multilingual such support, but the export code is broken/missing and exported web templates likely need to be patched in adding both a missing “label” node and missing content of “localizedLabels” language specific sub nodes, see diff of started (not yet completed) manual patch to get a hint of the likely pattern (this has not been tested by importing to tools yet).

1 Like

Hi Erik,

export to .OPT fixed with AD 1.24.6.
DV_ORDINAL valueSet defined at template level is now exported to .OPT

<term_definitions code="at0000">
    <items id="text">Followup question</items>
    <items id="description">Follow-up question that may be used e.g. in questionnaires after answering 'Yes' to questions like "Do you experience any symptoms of ..."</items>
</term_definitions>
<term_definitions code="at0002">
    <items id="text">Question</items>
    <items id="description">Question directed to the end user.</items>
</term_definitions>
<term_definitions code="at0004">
    <items id="text">Additional followup details</items>
    <items id="description"></items>
</term_definitions>
<term_definitions code="at0.0.1">
    <items id="text">one</items>
    <items id="description"></items>
</term_definitions>
<term_definitions code="at0.0.2">
    <items id="text">two</items>
    <items id="description"></items>
</term_definitions>
<term_definitions code="at0.0.3">
    <items id="text">three</items>
    <items id="description"></items>
</term_definitions>
1 Like