Skip to content

Template Configuration Reference

basharmsen edited this page Jun 25, 2021 · 1 revision

General description of the template folder structure

The templates are stored in the folder /SnomedTemplateService/SnomedTemplateService.Web/SnomedTemplates. For each organisation that owns templates, a subfolder of this folder should be created. Each template should be stored as an XML file in the folder that corresponds to its owner. The XML format for these template files is described in this document.

In addition to the organization folders the root of the templates folder contains an XML file named tags.xml. In a template file one can assign tags to a template that can be used in the frontend for searching templates. Each tag that is used in the template files should be defined in tags.xml. The format of this file is also described in this document.

XML schema and Examples

In the /model folder of the repository one can find an example and an XML schema for both the template files and the tags file. Some constraints are not checked by the XML schema. When this is the case it will be explicitly mentioned in this specification. The constraints for tags.xml and the template files are also checked when the application is started.

The XML schemas can also be very useful when writing templates. For some XML editors (e.g. Visual Studio) specifying an XML schema adds support for autocomplete. (For Visual Studio see here)

Multilingual Elements

Several elements in tags.xml and the template files consist of a dictionary of translations of some string. The structure of the elements that are translated is as follows:

  <???>
    <txt lang="[ISO 639-1 code #1]">
      [TEXT]
    </txt>
    <txt lang="[ISO 639-1 code #2]">
      [TEXT]
    </txt>
    ...
  </???>

So the content of these multilingual elements consists of a list of <txt> elements, each containing a translation of the string. The language of a translation should be specified as a ISO 639-1 language code (This ISO 639-1 code isn't checked in the XML schema.) in the lang attribute of the <txt> element. To specify an empty string for some language, leave the <txt> element for that language out.

Languages that don't have a ISO 639-1 code are not supported.

Specification of the Tags File

The tags file is pretty simple: The root element is a <tags> element containing a list of <tag> elements. These <tag>s are multilingual elements and besides that they have an id attribute that is used when a tag is referred to in a template file. The id of a tag must be unique so that it can be used for these references.

When a translation isn't available, for some frontend language and some tag, then a default language is used. For this purpose the root element <tags> has a mandatory attribute defaultLang containing a ISO 639-1 language code (The ISO 639-1 code isn't checked in the XML schema). For each tag a translation for this language should exist (This constraint isn't checked in the XML schema).

Specification of the Template Files

A template file consists of the following elements:

template (path: '/template', card: [1..1])

The root element of the file should be a <template> element.

author (path: '/template/authors/author', card: [1..*])

The authors of a template are specified in a collection <authors> that contains one or more <author> elements of a complex type. The children of <author> are <name> and <contact>.

name (path: '/template/authors/author/name', card: [1..1])

This is a text element that contains the name of the author.

contact (path: '/template/authors/author/contact', card: [1..1])

This is a text element that contains the mail address of the author.

title (path: '/template/title', card: [1..1])

This is a multilingual element that contains the translations for the title of the template.

description (path: '/template/description', card: [0..1])

This is a multilingual element that contains the translations for the description of the template.

snomedVersion (path: '/template/snomedVersion', card: [1..1])

This is a text element that contains the identifier of the SNOMED CT version.

snomedBranch (path: '/template/snomedBranch', card: [1..1])

This is a text element that contains the identifier of the SNOMED CT branch.

stringFormat (path: '/template/stringFormat', card: [1..1])

This element is a multilingual field and contains a format string for a human-readable string that can be used to represent the expression. In this string, place holders of the form [x/y] can be used. Each of these is replaced by the preferred term of the concept that is entered in the corresponding slot. [x/y] corresponds to the slot that is contained in the attribute group with index y (0-based) and that has index x (also 0-based) within this group. So [0/1] is replaced by the preferred term for the first slot in the second group.

Placeholders for attributes of nested expressions are not supported.

tag (path: '/template/tags/tag', card: [1..*])

The <tag> elemements are references to the tags in the tags file and are used in the frontend to search for templates. Tags are assigned by adding references to the actual tags in the tags.xml file. A <tag> element in the template file is an empty element which has a id attribute that refers to the tag in tags.xml file having the same id.

etl (path: '/template/etl', card: [1..1])

This is the actual template specified as an ETL expression (see ETL specification). To check the syntax of an ETL expression one can use the SNOMED CT ETL Parser.

item (path: '/template/items/item', card: [0..*])

The XML element <items> contains item specific information associated with fragments of the ETL expression (e.g. slots and constant attributes). Each <item> in this collection has a required name attribute to associate a fragment with its info. To specify the info for some fragment: 1) add a info slot for it in the ETL (see ETL specification), 2) specify the name for the info slot and 3) add an <item> element to the <items> collection that has the same name as the info slot.

title (path: '/template/items/item/title', card: [1..1])

A multilingual field containing the translations for the title for the ETL fragment.

description (path: '/template/items/item/description', card: [0..1])

A multilingual field containing the translations for the description for the ETL fragment.

defaultLang attribute (path: '/template@defaultLang', Required)

The ISO 639-1 language code of the default language (This ISO 639-1 code isn't checked in the XML schema). The default language is used when the template doesn't support the language requested in the frontend. To make this possible the template must support the default Language. A template supports a language when a non-empty translation exists for all mulilingual fields that have minimal cardinality > 0 (I.e <title>, <stringFormat> and the <title> of all <item>s). The constraint that the default language must be supported isn't checked in the XML schema.