Skip to content

Using Selectors and sql options

Aditya Chinchure edited this page Aug 29, 2020 · 4 revisions

Selectors and sql-options

A selector defines criteria on which data is selected (from any data source) and is a part of the LEAP API.

You can find examples of these being used: API Examples

There are three main types of selectors:

1. Simple selector

selector = "[field1] = 1 and [field2] < 1960"

2. Selector for getData REDCap endpoint

selector = {
"type": "default",  
"useLocalData": True,
"filter": "[field1] = 1 and [field2] < 1960",
"fields": ["field3", "field4"] or "field5"
}

The useLocalData option will allow Site Algo to save a copy of the obtained data in the first iteration so that in can be used in future iterations without re-loading the dataset from REDCap (or CSV).

3. Selector for getQueryResult REDCap endpoint

selector = {
"type": "sql", 
"useLocalData": True,
"sql_func": "count", 
"sql_options": {...}
}

Here, sql_options can contain any object that the SQL generator function will require. Since sql_options can be complex, you can run Selector Verification first.