Skip to content

Classic Dictionary

Dictionary Schema Definition

The JSON dictionary file has a definition of its own. The sections are as follows:

  • collection - (required) - the name of the collection; this is unique and required on subsequent REST calls

  • description - a simple text value for the author to document the use-case for this dictionary

  • undefinedAttributesAction - (default: ERROR) there are 3 available options:

    • ERROR - if data is inserted into the collection/chain and there are mismatched attributes the system will default to ERROR and not insert/update the data;
    • KEEP - if there are additional attributes, the system will keep the extraneous attributes and continue the CRUD operation;
    • REMOVE - if there are additional attributes, the system will remove them before continuing the operation
  • indexes - allows for definitions of possible unique and non-unique indexes; there can be 1-to-many indexes. It is recommended to have at least one index and it should be a business unique key. Each node in the array defines the list of attributes and uniqueness.

    • attributes - (required) - array of attribute names
    • unique - (optional; default: false) - should the index be unique
  • nodeDefs - user can create nodes (document definitions just like rootnode) that can be reused as arrays or subdocuments. (Very similar to how rootnode is defined.)

    • defName - (required) - the name of the node; will be required in the node as refName
    • arrays - (optional) - (see rootnode for info)
    • attributes - (required) - (see rootnode for info)
    • nodes - (optional) - (see rootnode for info)
  • rootnode - (required) - the main definition of the dictionary; there are attributes, subdocuments and arrays

    • arrays - (optional) - this can be an array of primitives (see Datatypes) or another node (see nodeDefs)
      • datatype - (optional; default: string) - this is the datatype (see Datatypes); must define a datatype or a refName
      • refName - (optional) - this is a node; must define a datatype or a nodeRef
      • name - (required) - the name of the array
    • attributes - (required) - 1 to many attributes
      • name - (required) - the name of the array
      • datatype - (optional; default: string) - this is the datatype (see Datatypes); must define a datatype or a refName
      • precision - (optional) - for numeric, non-integer types
      • required - (optional; default: false) - should this attribute always be required when save or upsert
    • nodes - a rootnode can have a another document as a sub-document
      • name - (required) - the name of the node at runtime
      • refName - (required) - the defName of the node that is to be used here

NOTE: From a business perspective, you must specify a unique ‘business’ index for the collection, such as a simple ID or number. You cannot use the reserved keyword _id as the index.

Datatypes

  • string
  • decimal
  • integer
  • long
  • date
  • datetime
  • boolean

Example Schema

{
  "collection": "collection",

  "description": "description",

  "undefinedAttributesAction": "KEEP",

  "indexes": [
    {
      "attributes": [
        "string"
      ],
      "unique": false
    }
  ],

  "nodeDefs": [
    {
      "arrays": [
        {
          "datatype": "string",
          "name": "string",
          "refName": "string"
        }
      ],
      "attributes": [
        {
          "datatype": "string",
          "name": "string",
          "precision": 0,
          "required": false
        }
      ],
      "defName": "string",
      "nodes": [
        {
          "name": "string",
          "refName": "string"
        }
      ]
    }
  ],

  "rootnode": {
    "arrays": [
      {
        "datatype": "string",
        "name": "string",
        "refName": "string"
      }
    ],
    "attributes": [
      {
        "datatype": "string",
        "name": "string",
        "precision": 0,
        "required": false
      }
    ],
    "nodes": [
      {
        "name": "string",
        "refName": "string"
      }
    ]
  }
}

Example 1 - Address

Address is an example of a simple collection. It contains a unique index for performing a more simple update. There are 6 attributes all of which have a default data type of ‘string’.

{
  "collection": "address",
  "indexes": [
    {
      "unique": true,
      "attributes": [
        "id"
      ]
    }
  ],
  "rootnode": {
    "attributes": [
      {
        "name": "id",
        "required": true
      },
      {
        "name": "addr1"
      },
      {
        "name": "addr2"
      },
      {
        "name": "city"
      },
      {
        "name": "state"
      },
      {
        "name": "zip"
      }
    ]
  }
}

Sample Address Data

{
  "id": "1",
  "addr1": "123 Main St",
  "addr2": "Apartment Z",
  "city": "Nowhere",
  "state": "CO",
  "zip": "58220"
}

Example 2 - Person

Person is a slightly more complex example of a dictionary. It contains not only a unique index but 2 other indexes that could help with searches. It also contains a node definition (nodeDef) that allows the user to define of a sub-collection. Notice the ‘required’ fields (street and zipcode) in the node definition of address for street and zip code.

This also includes an example of the array data structure. This can be an array of simple data types or a node definition. The example provided below is for ‘phone_numbers’ and ‘ages’.

{
  "collection": "person",
  "indexes": [
    {
      "attributes": [
        "id"
      ],
      "unique": true
    },
    {
      "attributes": [
        "mrn"
      ]
    },
    {
      "attributes": [
        "address.zipcode"
      ]
    }
  ],
  "nodeDefs": [
    {
      "defName": "address",
      "attributes": [
        {
          "name": "street",
          "required": true
        },
        {
          "name": "city"
        },
        {
          "name": "state"
        },
        {
          "name": "zipcode",
          "required": true
        }
      ]
    },
    {
      "defName": "phone_number",
      "attributes": [
        {
          "name": "phone_type",
          "required": true
        },
        {
          "name": "phone_num",
          "required": true
        }
      ]
    }
  ],
  "rootnode": {
    "attributes": [
      {
        "name": "id",
        "required": true
      },
      {
        "name": "fname",
        "required": true
      },
      {
        "name": "lname",
        "required": true
      },
      {
        "name": "mrn"
      },
      {
        "name": "ssn"
      },
      {
        "name": "dob",
        "datatype": "date"
      },
      {
        "name": "income",
        "datatype": "decimal"
      },
      {
        "name": "num_dependants",
        "datatype": "integer"
      }
    ],
    "arrays": [
      {
        "name": "phone_numbers",
        "refName": "phone_number"
      },
      {
        "name": "ages",
        "datatype": "integer"
      }
    ],
    "nodes": [
      {
        "name": "home_address",
        "refName": "address"
      }
    ]
  }
}

Sample Person Data

{
  "id": "1",
  "fname": "john",
  "lname": "doe",
  "mrn": "sm-0112",
  "ssn": "111-22-3333",
  "dob": "01-01-1980",
  "income": 23450.89,
  "num_dependants": 3,
  "ages": [
    2,
    6,
    9
  ],
  "home_address": {
    "street": "123 Main St",
    "zipcode": "58220"
  },
  "phone_numbers": [
    {
      "phone_type": "home",
      "phone_num": "303-111-2222"
    },
    {
      "phone_type": "mobile",
      "phone_num": "505-999-8888"
    }
  ]
}