Code tables

A code table is a Cúram specific datatype that is used for collections of commonly used constants. They allow for a locale independent way of encoding values. For example, a status code table might contain the values 'Open' and 'Closed'. In French these values would be 'Ouvert' and 'Ferme'. Rather than have the client and server try to interpret these translated values, the values are encoded, for example, the codes 'O' and 'C' might be used to represent the status.

For a Curam REST API resource representation, a code table is represented as a JSON object containing the following four properties:

An example of a code table JSON object
"addressType": {
     "tableName": "AddressType",
     "value": "AT1",
     "description": "Private",
     "parentCodeTable": null
}

For PUT and POST methods, only the value property is required to be provided. All other properties will be ignored. A shorthand way of specifying the code table value is also available, where the content of the value property can be passed up directly. The following inputs are accepted for a code table value in a PUT and POST method:

"addressType": {
     "tableName": "AddressType",
     "value": "AT1",
     "description": "Private",     
     "parentCodeTable": null}
"addressType": {"value": "AT1"
}
"addressType": "AT1"

The Cúram generated Swagger document contains a reference to the code table that represents the full list of entries that can be specified for a particular field. For example, a property that is related to the AddressType code table would contain the following documentation:

"The value of this property must be an item from the AddressType code table. See /codetables/AddressType"

This documentation refers to the /codetables/{table_name} resource, which supports a GET method that can be called to retrieve the code table entries for the specified table name. This is helpful where a user interface needs to display the full list of available code table entries in a drop down select list.

The result of a GET request for the /codetables resource contains the full list of localized entries, along with the default code table entry. For example:

{{ 
    "tableName" : "AddressType", 
    "defaultValue" : "AT1", 
    "codeItems" : [ {   
        "value" : "AT1",   
        "description" : "Business",   
        "sortOrder" : 0 
    }, {   
        "value" : "AT2",   
        "description" : "Institutional",   
        "sortOrder" : 0 
    }, {   
        "value" : "AT3",   
        "description" : "Mailing",   
        "sortOrder" : 0 
     } ]}