Skip to content

Inline Dictionary

Inline Dictionary

Inline Dictionaries can be created in two different ways, through the Dictionary editor or by using the endpoints directly. The Swagger documentation contains more info on the API endpoints available.

This is a specific dictionary structure that is easily readable for the defined attributes.

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

  • description - (optional) - 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 - (optional) - 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
  • contractVersion - (required) - This states which type of dictionary, for inline dictionaries this attribute value will always be 2.

  • attributes - (optional) - this is a list of attributes, each attribute has fields that contain further information about them:

    • name - (required) - the name of the attribute
    • description - (optional) - a description for what the attribute represents
    • datatype - (optional; default: string) - this is the datatype (see Datatypes); must define a datatype
    • required - (optional; default: false) - should this attribute always be required when save or upsert
    • precision - (optional) - for numeric, non-integer types
    • attributes - (optional) - a list of attributes, the attributes will be defined and may contain the same definitions as an attribute at the root level.

Datatypes

  • string
  • decimal
  • integer
  • long
  • date
  • datetime
  • boolean
  • node
  • string[]
  • decimal[]
  • short[]
  • integer[]
  • long[]
  • date[]
  • datetime[]
  • boolean[]
  • node[]

Example Schema

{
  "collection": "example_collection", 

  "description" : "This is an example description",

  "undefinedAttributesAction": "KEEP",

  "contractVersion": "2",

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

  "attributes": [
    {
        "name": "example_string",
        "description": "This attribute is an example for a string attribute",
        "datatype": "string",
        "required": true
    }, {
        "name": "example_integer",
        "description": "This attribute is an example for an integer attribute",
        "datatype": "integer",
        "required": false
    }, {
       "name": "example_decimal",
       "description": "This attribute is an example for a decimal attribute",
       "datatype": "decimal",
       "required": false, 
       "precision": 2
    }, {
       "name": "example_boolean",
       "description": "This attribute is an example for a boolean attribute",
       "datatype": "boolean",
       "required": false
    },{
       "name": "example_string_list",
       "description": "This attribute is an example for a list of strings",
       "datatype": "string[]",
       "required": false 
    },{
       "name": "example_node",
       "description": "This attribute is an example for a node attribute",
       "datatype": "node",
       "required": false, 
       "attributes": [
          {
              "name": "nodes_string",
              "datatype": "string",
              "required": false
          },
          {
              "name": "other_node_string",
              "datatype": "string",
              "required": true
          }] 
    }]
}

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",
  "contractVersion": "2",
  "indexes": [
    {
      "unique": true,
      "attributes": [
        "id"
      ]
    }
  ],
  "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",
  "contractVersion": "2",
  "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
        }
      ]
    }
  ],
  "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"
    },
    {
      "name": "phone_numbers",
      "datatype": "decimal",
      "attributes": [
        {
          "name": "phone_type",
          "required": true
        },
        {
          "name": "phone_num",
          "required": true
        }
      ]
    },
    {
      "name": "ages",
      "datatype": "integer[]"
    },
    {
      "name": "home_address", 
      "datatype": "node",
      "attributes": [
        {
          "name": "street",
          "required": true
        },
        {
          "name": "city"
        },
        {
          "name": "state"
        },
        {
          "name": "zipcode",
          "required": true
        }
      ] 
    } 
  ]
}

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"
    }
  ]
}