Revised October 2012
Description
The answer of the question is evaluated, and in turn will receive next question or the result if final question is reached.
<URLBASE>/answer
Logic
When the user request received, the presence and validity of the token_id and question_id or the sub_question_id are checked. The token_id, question_id, sub_question_id and the selected option_ids will be saved to DB. Corresponding option values and the next_rule of the current question is retrieved from DB. The next_rule is then evaluated using the corresponding sub_question option_values. According to the output of the evaluated next_rule next step is determined. According to the next step, API may return the next question, an error message or the result.
Sample Request Format of Questionnaire Type 1
{
"key": "qtye456ceger",
"token_id": 21,
"question_id": "1",
"answers": [
{
"sub_question_id": "1",
"option_id": "1"
},
{
"sub_question_id": "2",
"option_id": "2"
},
{
"sub_question_id": "3",
"option_id": "3"
},
{
"sub_question_id": "4",
"option_id": "4"
}
]
}
{
"token_id": 21,
"question_id": "2",
"user_specified_sub_question" : "Sample sub question",
"answers": [
{
"sub_question_id": "0",
"option_id": "6"
},
{
"sub_question_id": "1",
"option_id": "7"
},
{
"sub_question_id": "2",
"option_id": "6"
},
{
"sub_question_id": "3",
"option_id": "6"
},
{
"sub_question_id": "4",
"option_id": "6"
}
]
}
| token_id | required |
| question_id | required |
| answers | required, Each entry must have a 'sub_question_id' and its selected 'option_id'. |
Sample Request Format of Questionnaire Type 2
{
"key": "qtye456ceger",
'token_id' : 21,
'sub_question_id': '8',
'answers' : [
{
"question_id" : '3',
"option_id" : '2'
},
{
"question_id" : '4',
"option_id" : '4'
},
{
"question_id" : '6',
"option_id" : '1'
}
]
}
| token_id | required |
| sub_question_id | required |
| answers | required, Each entry must have a 'question_id' and its selected 'option_id'. |
(GET|POST)
{
"status": 1,
"sub_question": {
"sub_question_id": 11,
"name": "Hallucinogens(LSD, acid, mushrooms, PCP, Special K, ecstasy, etc.)",
"questions": [
{
"question_id": 3,
"description": "In the past three months, how often have you used the substances you mentioned(first drug, second drug, etc)?",
"comment": null,
"options": [
{
"name": "Never",
"option_id": 1,
"option_value": 0,
"question_id": 3
},
{
"name": "Once or Twice",
"option_id": 2,
"option_value": 2,
"question_id": 3
},
]
},
{
"question_id": 4,
"description": "In the past three months, how often you had a strong desire or urge to use(first drug, second drug, etc)?",
"comment": null,
"options": [
{
"name": "Never",
"option_id": 1,
"option_value": 0,
"question_id": 4
},
{
"name": "Once or Twice",
"option_id": 2,
"option_value": 3,
"question_id": 4
},
]
},
{
// Another question
},
.
.
.
]
}
}
Response fields
| status | Status of the API request |
| errors | Errors if any |
| messages | Messages if any |
| sub_question | Includes sub_question_id, its name and questions. |
| questions | An array which includes all the questions. Each question has its question_id, description, comment if any and its available options. |
| options | An array which includes all the option of the current question.Each option has an option_id and name. |
Attention
Due to the lapse in government funding, the information on this web site may not be up to date, transactions submitted via the web site may not be processed, and the agency may not be able to respond to inquiries until appropriations are enacted. Updates regarding government operating status and resumption of normal operations can be found at
Looking for Treatment?
Use the SAMHSA Treatment Locator or 1-800-662-HELP.
Helpline open during government shutdown
