Hi @mc1995,
I will try to describe in a bit informal way by providing an example of the serialized data: the template provides the metadata which describe how an openEHR data instance (= composition) is allowed to look like.
Here is an excerpt from a template (in WebTemplate format):
{
"id": "diástole",
"name": "Diástole",
"localizedName": "Diástole",
"rmType": "DV_QUANTITY",
"nodeId": "at0005",
"min": 0,
"max": 1,
"localizedNames": {
"es-ar": "Diástole",
"pt-br": "Diastólica"
},
"localizedDescriptions": {
"es-ar": "Presión arterial sistémica mínima - medido durante la diástole o fase de relajación del ciclo cardíaco.",
"pt-br": "Pressão arterial sistêmica mínima - medida na fase diastólica ou de dilatação do ciclo cardíaco."
},
"aqlPath": "/content[openEHR-EHR-OBSERVATION.blood_pressure.v2]/data[at0001]/events[at1042]/data[at0003]/items[at0005]/value",
"inputs": [
{
"suffix": "magnitude",
"type": "DECIMAL",
"validation": {
"precision": {
"min": 0,
"minOp": ">=",
"max": 0,
"maxOp": "<="
},
"range": {
"min": 0.0,
"minOp": ">=",
"max": 1000.0,
"maxOp": "<"
}
}
},
{
"suffix": "unit",
"type": "CODED_TEXT",
"list": [
{
"value": "mm[Hg]",
"label": "mm[Hg]",
"localizedLabels": {
"es-ar": "mmHg",
"pt-br": "mmHg"
},
"validation": {
"precision": {
"min": 0,
"minOp": ">=",
"max": 0,
"maxOp": "<="
},
"range": {
"min": 0.0,
"minOp": ">=",
"max": 1000.0,
"maxOp": "<"
}
}
}
]
}
]
}
It describes that there can be an an instance of the openEHR Reference Model class (DV_QUANTITY) at a specific path (/content[openEHR-EHR-OBSERVATION.blood_pressure.v2]/data[at0001]/events[at1042]/data[at0003]/items[at0005]) within a composition and which is allowed to be in a specific range (0 … 1000) and can occur 0 or 1 times within the entry and has unit mm[HG]
The excerpt of the composition/data instance (in this example represented in the so called flat format) that can be derived from the Template might look like the following:
"virtal_signs/presión_arterial/any_event_en:0/diástole|magnitude": 90.0,
"virtal_signs/presión_arterial/any_event_en:0/diástole|unit": "mm[Hg]",
the same dats represented as canonical JSON format:
{
"name": {
"value": "Diástole",
"_type": "DV_TEXT"
},
"value": {
"_type": "DV_QUANTITY",
"units": "mm[Hg]",
"magnitude": 90.0
},
"_type": "ELEMENT",
"archetype_node_id": "at0005"
},
The validation inside the openEHR server will check if the composition does not violate the constraints provided within the template.
Put a bit differently: while a Template necessarily resembles an openEHR composition by using classes that allow describing constraints on the classes from the openEHR Reference Model (which compositions consist of), they have different attributes and functions.
Hope this helps. Someone might elaborate a bit on the differences on the class definitions, but I personally like to take a look at examples first.