Example of a Simple Definition Set

Overview

The following examples illustrate a very simple Instrument and its accompanying configurations. The Instrument defines two fields to be collected. There is a Calculation Set definition that provides some post-Assessment calculations to perform on the Assessment data. There are examples of how this Instrument can be represented in both a Web Form and an SMS Interaction. Finally, there is an example Assessment that could result from this Instrument.

It is not required to produce a full suite of configurations for every Instrument; this is only an example of what is possible.

Instrument

{
  "id": "urn:examples:simple",
  "version": "1.0",

  "title": "A Simple Example",

  "record": [
    {
      "id": "name",
      "type": "text",
      "required": true
    },

    {
      "id": "birthdate",
      "type": "date"
    }
  ]
}

Calculation Set

{
  "instrument": {
    "id": "urn:examples:simple",
    "version": "1.0"
  },

  "calculations": [
    {
      "id": "uppercase_name",
      "type": "text",
      "method": "python",
      "options": {
        "expression": "assessment['name'].upper()"
      }
    },

    {
      "id": "birth_year",
      "type": "integer",
      "method": "htsql",
      "options": {
        "expression": "year($birthdate)"
      }
    }
  ]
}

Web Form

{
  "instrument": {
    "id": "urn:examples:simple",
    "version": "1.0"
  },

  "defaultLocalization": "en",
  "title": {
    "en": "A Web Form for the Simple Example"
  },

  "pages": [
    {
      "id": "page1",
      "elements": [
        {
          "type": "text",
          "options": {
            "text": {
              "en": "Please answer this short questionnaire."
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "name",
            "text": {
              "en": "What is your full name?"
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "birthdate",
            "text": {
              "en": "What date were you born?"
            },
            "help": {
              "en": "Please enter the date in YYYY-MM-DD format."
            }
          }
        }
      ]
    }
  ]
}

SMS Interaction

{
  "instrument": {
    "id": "urn:examples:simple",
    "version": "1.0"
  },

  "defaultLocalization": "en",

  "steps": [
    {
      "type": "text",
      "options": {
        "text": {
          "en": "Please answer this short questionnaire."
        }
      }
    },

    {
      "type": "question",
      "options": {
        "fieldId": "name",
        "text": {
          "en": "What is your full name?"
        }
      }
    },

    {
      "type": "question",
      "options": {
        "fieldId": "birthdate",
        "text": {
          "en": "What date were you born?"
        }
      }
    }
  ]
}

Assessment

{
  "instrument": {
    "id": "urn:examples:simple",
    "version": "1.0"
  },

  "values": {
    "name": {
      "value": "John Smith"
    },

    "birthdate": {
      "value": "1983-10-29"
    }
  },

  "meta": {
    "calculations": {
      "uppercase_name": "JOHN SMITH",
      "birth_year": 1983
    }
  }
}