Default Values

Syntax

In ADL, it is possible to specify a default value for any object node. This is usually limited to locally specialised archetypes and templates, since default values are usually specific to local contexts or use cases. However they may validly be used in any archetype.

Default values are expressed in any regular object instance syntax, including ODIN syntax and JSON, since they are instances of objects rather than constraints. They are introduced using a pseudo-attribute _default, followed by the '=' symbol, and then a block in the chosen syntax. The following shows the syntax in ODIN.

    --
    -- ODIN embedded in ADL
    --
    /path[idN].../value ∈ {
        TYPE ∈ {
            _default = (TYPE) <
                attribute_1 = <value_1>
                attribute_2 = <value_2>
                ...
                attribute_N = <value_N>
            >
        }
    }

The JSON equivalent is shown below.

    --
    -- JSON embedded in ADL
    --
    /path[idN].../value ∈ {
        TYPE ∈ {
            _default = (json) <#
                {
                    "_type": "TYPE",
                    "attribute_1": value_1,
                    "attribute_2": value_2,
                    ...
                    "attribute_N": value_N
                }
            #>
        }
    }

A default value is either of the same type as specified by the corresponding archetype node (i.e. the first occurrence of 'TYPE' in each of the above examples) or any subtype allowed by the reference model. Accordingly, the second occurrence of 'TYPE' in both ODIN and JSON cases above represents either the same type as the first, or a subtype.

Examples

Within a template, a default value can be defined to support the situation where only one value is possible for a data item due to the specific nature of the template. For example, a blood pressure archetype may allow a number of possible values for 'patient position', such as 'lying', and 'sitting', 'standing'. When used in a hospital, the patient will usually be lying so a default value for this can be set, as shown in the following example:

    /data[id2]/events[id6]/state[id7]/items[id8]/value ∈ {
        DV_CODED_TEXT ∈ {
            _default = (DV_CODED_TEXT) <
                defining_code = <[snomed_ct::163033001|lying BP|]>
            >
        }
    }

The example above only sets the default value, but it could have also modified the constraint on the value object as well, as in the following version, where the standing blood pressure possibility from the archetype has been removed:

    /data[id2]/events[id6]/state[id7]/items[id8]/value ∈ {
        DV_CODED_TEXT ∈ {
            defining_code ∈ {
                [snomed_ct::163035008|sitting BP|],
                [snomed_ct::163033001|lying BP|]
            }
            _default = (DV_CODED_TEXT) <
                defining_code = <[snomed_ct::163033001|lying BP|]>
            >
        }
    }

Note that in the above, the standard brief syntax for a CODE_PHRASE (also the equivalent class Terminology_code) is used. In the JSON format, the default value in the above examples is as follows:

    /data[id2]/events[id6]/state[id7]/items[id8]/value ∈ {
        DV_CODED_TEXT ∈ {
            _default = (json) <#
                {
                    "_type": "DV_CODED_TEXT",
                    "defining_code": {
                        "terminology_id": "snomed_ct",
                        "code_string":    "163033001",
                        "value":          "lying BP"
                    }
                }
            #>
        }
    }