Error importing templates to openEHR toolkit

Hi,I am trying to import this OPT exported from Archetype designer and getting this error. Not sure what is wrong.

I am able to import it into EHRBase and add compositions

ERROR cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://schemas.openehr.org/v1":default_value}'. One of '{"http://schemas.openehr.org/v1":rm_type_name}' is expected. line #: 3107 >>>
ERROR cvc-complex-type.2.4.b: The content of element 'default_value' is not complete. One of '{"http://schemas.openehr.org/v1":issuer}' is expected. line #: 3107 >>>

EHRN-AyushEHRV2-Prescription.v2.4.opt (161.2 KB)

<constraints>
        <attributes>
            <rm_attribute_name>value</rm_attribute_name>
            <children>
                <default_value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DV_IDENTIFIER"/>
            </children>
            <differential_path>[openEHR-EHR-COMPOSITION.encounter.v1]/content[openEHR-EHR-INSTRUCTION.medication_order.v3]/protocol[at0005]/items[at0004]</differential_path>
        </attributes>
    </constraints>

It looks like you have a default_value partially set without an actual default value, or it is possible that the .opt is not being populated correctly for Identifiers

Thanks @ian.mcnicoll

Can you share a proper example?

Also is there a way to fix this from archetype designer?

It is just a guess but I suspect you have something ‘set’ as a default value in AD on the Medication order Order Identifier node and the openEHR toolkit does not recognise it.

Alternatively, edit the .opt to remove the ‘constraints’ tag’ at the end of the xml .opt

Hi @Dileep_V_S according to the XML schema it seems your example is OK, though I’m wonder if you really need those extra constraints

REF: specifications-ITS-XML/components/ALL/Template.xsd at Release-1.0.2 · openEHR/specifications-ITS-XML · GitHub

Basically what the schema says is that default_value is a DATA_TYPE, and DV_IDENTIFIER has all its attributes as optional, so an empty DV_IDENTIFIER should be valid, though it might not be useful.

It might be that the schema we have loaded in the Toolkit doesn’t have that constraints section. I’ll look into it.

Best,
Pablo.

Thanks @pablo I am not aware of any constraints that I have added to cause this issue.

I am getting the same error for all the templates that I have tried. All of them exported from Archtype designer. So could it be something to do with my settings in Archetype designer

Sorry, My Bad.

Many other templates are working fine. So nothing wrong with the designer

Can you export a . Template Zip fileset, so we can look at the original template?

EHRN-AyushEHRV2-Prescription.v2.4.zip (233.4 KB)

@ian.mcnicoll Find attached

@Dileep_V_S The constraints element in the OPT should be exported only if you set some constraint like the default value of a node, in other cases the OPT won’t have those constraints at the end.

I have several templates loaded in the Toolkit, none of them have constraints and all work OK. I need to look at the schema just in case we don’t have it there.

The Archetype Designer does export something that is not in the openEHR OPT schemas that is the matches_negated which isn’t a valid OPT 1.4 element. Though in the Toolkit I have added a relaxed schema that contains that node, but in general when I export an OPT form the AD I always strip those elements from it.

Another strange thing, though valid, is that the namespaces are declared in intermediate elements, where in generate NSs are declared in the root element. Though if you see the generated XML it’s like a concatenation of different XMLs since the indentation is broken, I believe it doesn’t have a single XML object serialized to a string, but several ones then all are appended together. This also complicates viewing the XML and correct node folding functionalities.