Lookup Tables

List

URL: https://www.commcarehq.org/a/[domain]/api/[version]/lookup_table/

Sample output:

{                                                                                                                                                                                                                                                                               
  "meta": {                                                                                                                                                                                                                                                                     
    "limit": 20,                                                                                                                                                                                                                                                                
    "next": null,                                                                                                                                                                                                                                                               
    "offset": 0,                                                                                                                                                                                                                                                                
    "previous": null,                                                                                                                                                                                                                                                           
    "total_count": 6                                                                                                                                                                                                                                                            
  },                                                                                                                                                                                                                                                                            
  "objects": [                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                           
      "fields": [                                                                                                                                                                                                                                                               
        {                                                                                                                                                                                                                                                                       
          "field_name": "name",                                                                                                                                                                                                                                                 
          "properties": ["lang"]                                                                                                                                                                                                                                                      
        },                                                                                                                                                                                                                                                                      
        {                                                                                                                                                                                                                                                                       
          "field_name": "price",                                                                                                                                                                                                                                                   
          "properties": []                                                                                                                                                                                                                                                      
        }                                                                                                                                                                                                                                                                       
      ],                                                                                                                                                                                                                                                                        
      "id": "bcf49791f7f04f09bd46262097e107f2",                                                                                                                                                                                                                                 
      "is_global": true,                                                                                                                                                                                                                                                        
      "item_attributes": [],                                                                                                                                                                                                                                                    
      "resource_uri": "",                                                                                                                                                                                                                                                       
      "tag": "vaccines"                                                                                                                                                                                                                                                       
    },                                                                                                                                                                                                                                                                         
    ....
  ]
}


Create

URL: https://www.commcarehq.org/a/[domain]/api/[version]/lookup_table/

Supported Methods:

MethodDescription
POSTCreate lookup table


Input Parameters:


Name 

Description 

tag*

Lookup table name

fields*

Fields and their properties for the lookup table to have

is_globalBoolean if the lookup table is accessible to all users. Default: false


Returns 201 Created on success


Sample input:

Single Group:

JSON Input
{
  "tag": "vaccines", 
  "fields": [
    {"field_name": "name", "properties": ["lang"]},
    {"field_name": "price", "properties": []},
  ],
  "is_global": true	
}


Individual

URL: https://www.commcarehq.org/a/[domain]/api/[version]/lookup_table/[lookup_table id]


Supported Methods:


MethodDescription
GETGet lookup table
PUTEdit lookup table
DELETEDelete lookup table

Input Parameters For Editing: 

Name 

Description 

name

Lookup table name

fields

Fields and their properties for the lookup table to have

is_globalBoolean if the lookup table is accessible to all users.

 Sample input:

JSON Input
{
  "tag": "vaccines", 
  "fields": [
    {"field_name": "name", "properties": ["lang"]},
    {"field_name": "price", "properties": []},
  ]
}

 

Lookup Table Rows

List

URL: https://www.commcarehq.org/a/[domain]/api/[version]/lookup_table_item/

Supported Methods:

MethodDescription
GETList lookup table rows

Sample output:

{                                                                                                                                                                                                                                                                               
  "meta": {                                                                                                                                                                                                                                                                     
    "limit": 20,                                                                                                                                                                                                                                                                
    "next": null,                                                                                                                                                                                                                                                               
    "offset": 0,                                                                                                                                                                                                                                                                
    "previous": null,                                                                                                                                                                                                                                                           
    "total_count": 15                                                                                                                                                                                                                                                           
  },                                                                                                                                                                                                                                                                            
  "objects": [                                                                                                                                                                                                                                                                  
    {                                                                                                                                                                                                                                                                           
      "data_type_id": "bcf49791f7f04f09bd46262097e107f2",                                                                                                                                                                                                                       
      "fields": {                                                                                                                                                                                                                                                               
        "name": {                                                                                                                                                                                                                                                                 
          "field_list": [                                                                                                                                                                                                                                                       
            {                                                                                                                                                                                                                                                                   
              "field_value": "MMR",                                                                                                                                                                                                                                             
              "properties": {"lang": "en"}                                                                                                                                                                                                                                                  
            }                                                                                                                                                                                                                                                                   
          ]                                                                                                                                                                                                                                                                     
        },                                                                                                                                                                                                                                                                      
        "price": {                                                                                                                                                                                                                                                               
          "field_list": [                                                                                                                                                                                                                                                       
            {                                                                                                                                                                                                                                                                   
              "field_value": "7",                                                                                                                                                                                                                                             
              "properties": {}                                                                                                                                                                                                                                                  
            }                                                                                                                                                                                                                                                                   
          ]                                                                                                                                                                                                                                                                     
        }                                                                                                                                                                                                                                                                       
      },                                                                                                                                                                                                                                                                        
      "id": "e8433b25e60c4e228b0c7a679af2847b",                                                                                                                                                                                                                                 
      "item_attributes": {},	
      "sort_key": 2

    },
    ...
  ]
}


Create

URL: https://www.commcarehq.org/a/[domain]/api/[version]/lookup_table_item/

Supported Methods:

MethodDescription
POSTCreate a new lookup table row


Input Parameters:


Name 

Description 

data_type_id*

ID of a lookup table

fields*

Fields and their properties for the lookup table to have


Returns 201 Created on successful creation


Sample input:

Single row:

JSON Input
{
  "data_type_id": "bcf49791f7f04f09bd46262097e107f2", 
  "fields": {
    "name": {                                                                                                                                                                                                                                                                 
      "field_list": [                                                                                                                                                                                                                                                       
        {                                                                                                                                                                                                                                                                   
          "field_value": "MMR",                                                                                                                                                                                                                                             
          "properties": {"lang": "en"}                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                   
      ]                                                                                                                                                                                                                                                                     
    },                                                                                                                                                                                                                                                                      
    "price": {                                                                                                                                                                                                                                                               
      "field_list": [                                                                                                                                                                                                                                                       
        {                                                                                                                                                                                                                                                                   
          "field_value": "7",                                                                                                                                                                                                                                             
          "properties": {}                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                   
      ]                                                                                                                                                                                                                                                                     
    }                                                                                                                                                                                                                                                                       
  }
}


Individual

URL: https://www.commcarehq.org/a/[domain]/api/[version]/lookup_table_item/[lookup_table_item id]


Supported Methods:


MethodDescription
GETGet lookup table row
PUTEdit lookup table row
DELETEDelete lookup table row

Input Parameters For Editing: 

Name 

Description 

data_type_id*

ID of a lookup table

fields*

Fields and their properties for the lookup table to have

 Sample input:

JSON Input
{
  "data_type_id": "bcf49791f7f04f09bd46262097e107f2", 
  "fields": {
    "name": {                                                                                                                                                                                                                                                                 
      "field_list": [                                                                                                                                                                                                                                                       
        {                                                                                                                                                                                                                                                                   
          "field_value": "MMR",                                                                                                                                                                                                                                             
          "properties": {"lang": "en"}                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                   
      ]                                                                                                                                                                                                                                                                     
    },                                                                                                                                                                                                                                                                      
    "price": {                                                                                                                                                                                                                                                               
      "field_list": [                                                                                                                                                                                                                                                       
        {                                                                                                                                                                                                                                                                   
          "field_value": "10",                                                                                                                                                                                                                                             
          "properties": {}                                                                                                                                                                                                                                                  
        }                                                                                                                                                                                                                                                                   
      ]                                                                                                                                                                                                                                                                     
    }                                                                                                                                                                                                                                                                       
  }

}



  • No labels