# Bug in export of ORDINAL texts defined in templates **Category:** [Archetype Designer](https://discourse.openehr.org/c/archetype-designer/30) **Created:** 2023-03-10 17:51 UTC **Views:** 897 **Replies:** 3 **URL:** https://discourse.openehr.org/t/bug-in-export-of-ordinal-texts-defined-in-templates/3670 --- ## Post #1 by @erik.sundvall Hi! When trying to be [a bit too clever](https://discourse.openehr.org/t/how-to-use-the-symptom-sign-screening-questionnaire-archetype/1984/13?u=erik.sundvall) 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: ![image|653x500](upload://4n4s6D0mQO9hm4tXovwNglHnXtU.png) If you use the form preview's "Export to JSON"... ![image|690x171](upload://fIVmmpfNpVVnRLdRcepnqbELtk8.png) ...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... ![image|582x499, 50%](upload://ye6qbiyYe5GeuZ59Y4La8LNoS5A.png) ...and Betters in form builder tool: ![image|506x500, 50%](upload://qpj86V2ltxXfW0QlAs5ya5XS00b.png) Here is the file-set with test archetypes/template... [openEHR-EHR-CLUSTER.followup_question.v0.adl|attachment](upload://rQ8szUZVEVJiuvtmDLdaBwXozAj.adl) (4.6 KB) [openEHR-EHR-CLUSTER.followup_question-ctcae.v0.adl|attachment](upload://zReQKTMMU1fNRNlPeYhvtb0TruJ.adl) (6.3 KB) [openEHR-EHR-CLUSTER.followup_question-ctcae_test.v0.adl|attachment](upload://nQQtACNMfRoPRoi3di2JQONHDpo.adl) (7.3 KB) [openEHR-EHR-COMPOSITION.encounter.v1.adl|attachment](upload://9avJTbDIPuPNszo0hP95B4D0EXW.adl) (36.4 KB) [openEHR-EHR-EVALUATION.container.v0.adl|attachment](upload://cbsJwUK2t7vZRijxk0jkxZuPLP2.adl) (5.8 KB) [test of ordinal selection defentition in template.opt|attachment](upload://le0mBOafKKttNsVsmsZpZ9NZBE7.opt) (41.7 KB) [test of ordinal selection defentition in template.t.json|attachment](upload://ykR3Ty8ZX31RDusuSl24obChfBb.json) (90.0 KB) ...and some screenshots from the editor showing the intended content that only gets partially exported: ![image|690x361, 50%](upload://92t5tlrg59OaKqVZSDMpYhFCbg3.png) ![image|690x379, 50%](upload://AlrNzSckyZxlZ5mbVIQJm2TivAL.png) ![image|690x344, 50%](upload://y5S4Ip2MUaNiQHvMDtSomAvrsY5.png) @borut.fabjan when would you guess that a release with the bug fixed will appear? --- ## Post #2 by @borut.fabjan Hi, often there's a thin line between a bug, new modelling pattern or some murky detail in the spec. ;) 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"> 1|one 2|two 3|three === 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. --- ## Post #3 by @erik.sundvall 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](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](https://discourse.openehr.org/t/limitation-preventing-multilingual-repeated-parts-in-the-opt-operational-template-export-format/2760) 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](https://github.com/regionstockholm/background_and_examples/blob/main/AE_ORDINAL_export_bugs/test%202%20of%20ordinal%20selection%20defentition%20in%20template.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 ` < items id="text">mild B (sv) < items id="description">B1 `and then it works like a charm to import the [manually patched test 2 of ordinal selection defentition in template.sv.opt]([upload://evg9ggM5ETDnvLXohKxqzsAzq6Q.opt](https://github.com/regionstockholm/background_and_examples/blob/main/AE_ORDINAL_export_bugs/manually%20patched%20test%202%20of%20ordinal%20selection%20defentition%20in%20template.sv.opt)) to form building tools: ![image|599x500](upload://mJBrzWEr7WvjCEhpXXHUAKdiXr4.png) If you do a A [diff between the exported and patched file](https://github.com/regionstockholm/background_and_examples/commit/ccde6e9bfbf5a4cb9f52c63521f264fceb25449e) then it shows what's missing in the current export. 3. 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](https://github.com/regionstockholm/background_and_examples/commit/3686761ca01f64967be82a6c939a2053a97d58a3) to get a hint of the likely pattern (this has not been tested by importing to tools yet). --- ## Post #4 by @borut.fabjan Hi Erik, export to .OPT fixed with AD 1.24.6. DV_ORDINAL valueSet defined at template level is now exported to .OPT ``` Followup question Follow-up question that may be used e.g. in questionnaires after answering 'Yes' to questions like "Do you experience any symptoms of ..." Question Question directed to the end user. Additional followup details one two three ``` --- **Canonical:** https://discourse.openehr.org/t/bug-in-export-of-ordinal-texts-defined-in-templates/3670 **Original content:** https://discourse.openehr.org/t/bug-in-export-of-ordinal-texts-defined-in-templates/3670