Doctorlink has joined HealthHerohealthheroLearn More
doctorlink

Unique Scenarios

Unique Scenarios

While most questions are fairly straight forward, some scenarios may pop up where you need to handle things a little differently.

Combination Answers

Sometimes, when you receive a question with a set of answers, you'll also get some information in the data property. This information could include validCombinations and display. If these are present then you've come across a set of combination answers. In the example below, this takes the form of a set of answers pertaining to your weight in various units of measurement.

Figure 1: a question with multiple answers in combination
Figure 1: a question with multiple answers in combination

Validation

We sometimes don't need to enter all fields, i.e. if you answer in stone or pounds, there is no need to answer in kg, as well. In many of these situations we want to make sure the user can only enter values into certain fields.

This validation can be done on the client-side using the data.validCombinations property, e.g. "validCombinations": [ [778], [779], [780], [778,779] ] - each set of answerIds gives a valid combination. You couldn't, for example, fill out answer 778 and 780 as the combination doesn't exist within the array. This validation is done on the server-side already. However, if you choose to implement it client-side to prevent unnecessary API calls, you may.

Display

Some answers should be grouped, or separated, into their own sections. When this is needed, a data.display property will be included in the response. This will be an array of objects containing a header -the text that should begin the section- and its answers -an array of answer Ids contained within this section.

In the example (see Figure 1,) answers 778 & 779 are in the first section, with no header. The second section contains only 1 answer (780) and is preceded by its header "OR". This indicates a visual representation of the validCombinations property, i.e. you may enter a value into either of the top 2 answers OR the bottom answer.

Response Example

Below is a partial response example. This data, within the question object, will be the same no matter which API you use - Traversal or Chat.

{
    ...,
    "questions": [
        {
            "nodeId": 258,
            "questionId": 342,
            "displayText": "How much do you weigh?\n<span class=\"e24subtext\">Enter your weight in any combination of stones and lbs, or in kilograms. If pregnant, enter your weight before pregnancy.</span>",
            "title": "Your proportions matter, so be honest...",
            "answers": [
                {
                    "nodeId": 258,
                    "questionId": 342,
                    "answerId": 778,
                    "controlType": "Number",
                    "displayText": "stones",
                    ...
                },
                {
                    "nodeId": 258,
                    "questionId": 342,
                    "answerId": 779,
                    "controlType": "Number",
                    "displayText": "lb (pounds)",
                    ...
                },
                {
                    "nodeId": 258,
                    "questionId": 342,
                    "answerId": 780,
                    "controlType": "Number",
                    "displayText": "kg",
                    ...
                }
            ],
            "explanation": "",
            "data": {
                "validCombinations": [
                    [
                        778
                    ],
                    [
                        779
                    ],
                    [
                        780
                    ],
                    [
                        778,
                        779
                    ]
                ],
                "display": [
                    {
                        "header": "",
                        "answers": [
                            778,
                            779
                        ]
                    },
                    {
                        "header": "OR",
                        "answers": [
                            780
                        ]
                    }
                ],
                ...
            }
        }
    ],
    ...
}

Code shortened by '...' for brevity.

Suppressing None of the above

If the response contains a property called “SuppressNone”, the “None of the above” answer can be hidden.

Json Response

{
    "traversalId": "...",
    "algoId": xxxx,
    "nodes": [{
            ...
            "questions": [{
                    "nodeId": 93,
                    "questionId": 27490,
                    "displayText": "What are you using to treat your hair loss?",
                    "title": null,
                    "answers": [{
                            "nodeId": 93,
                            "questionId": 27490,
                            "answerId": 35386,
                            "controlType": "Checkbox",
                            "controlValue": null,
                            "controlChecked": false,
                            "displayText": "Finasteride / Propecia tablets",
                            "explanation": "",
                            "data": {}
                        }, {
                            "nodeId": 93,
                            "questionId": 27490,
                            "answerId": 35387,
                            "controlType": "Checkbox",
                            "controlValue": null,
                            "controlChecked": false,
                            "displayText": "Minoxidil / Regaine solution or foam",
                            "explanation": "",
                            "data": {}
                        }, {
                            "nodeId": 93,
                            "questionId": 27490,
                            "answerId": 35252,
                            "controlType": "Checkbox",
                            "controlValue": null,
                            "controlChecked": false,
                            "displayText": "Something else",
                            "explanation": "",
                            "data": {
                                "Properties": {
                                    "Alert": "RedFlag"
                                }
                            }
                        }, {
                            "nodeId": 93,
                            "questionId": 27490,
                            "answerId": 24790,
                            "controlType": "Radio",
                            "controlValue": null,
                            "controlChecked": false,
                            "displayText": "None of the above",
                            "explanation": null,
                            "data": {}
                        }
                    ],
                    "explanation": "",
                    "data": {
                        "media": [],
                        "Properties": {
                            "Pertinent": "Always",
                            "SuppressNone": ""
                        },
                        "minAnswers": 0,
                        "maxAnswers": 2
                    }
                }
            ],
            "isTable": false
        }
    ],
    ...
}

Headers and Footers

Traditional style

  • Loop through all questions in the response, pulling a distinct list of footers.
  • Bind list underneath the table and style appropriately
Visual Example

Traditional style table question with header and footer

Response

Below is a sample response that was used to create the above screenshot.

{
    "traversalId": "730aec55-1f84-42f3-b7f0-5cfc2d1122be",
    "algoId": 3815,
    "nodes": [
        {
            "nodeId": 42,
            "assetId": 16545,
            "errors": [],
            "displayText": "Over the last 2 weeks, how often have you been bothered by the following problems?",
            "title": " ",
            "explanation": "",
            "data": "{\"Properties\":{\"TableColumn\":\"Large\"}}",
            "questions": [
                {
                    "nodeId": 42,
                    "questionId": 13143,
                    "displayText": "Feeling down, depressed, or hopeless",
                    "title": "",
                    "answers": [
                        ...
                    ],
                    "explanation": "",
                    "data": {
                        "Properties": {
                            "Footer": "<span class=\"e24subtext\">Reference: Kroenke K, Spitzer RL, Williams JB. The Patient Health Questionnaire-2: Validity of a Two-Item Depression Screener. Medical Care. 2003;41:1284-92.</span>"
                        }
                    }
                },
                {
                    "nodeId": 42,
                    "questionId": 13142,
                    "displayText": "Little interest or pleasure in doing things",
                    "title": "",
                    "answers": [
                        ...
                    ],
                    "explanation": "",
                    "data": {
                        "Properties": {
                            "Footer": "<span class=\"e24subtext\">Reference: Kroenke K, Spitzer RL, Williams JB. The Patient Health Questionnaire-2: Validity of a Two-Item Depression Screener. Medical Care. 2003;41:1284-92.</span>"
                        }
                    }
                }
            ],
            "isTable": true
        }
    ],
    "assessmentType": 0,
    "algoName": "Age & Gender",
    "errors": [],
    "previousDisabled": false,
    "nextDisabled": false,
    "language": "ENGLISH"
}

Chat style

  • Bind question.header to the top of the current question.
  • Bind question.data.Properties'Footer' to the bottom of the current question.
UI Example

Chat style table question with header and footer

Response Json

Below is a sample response that was used to create the above screenshot.

{
    "traversalId": "d0dd6023-beb2-43be-820b-e1178f55188a",
    "algoId": 3815,
    "nodeId": 42,
    "questions": [
        {
            "algoId": 3815,
            "header": "Over the last 2 weeks, how often have you been bothered by the following problems?",
            "nodeId": 42,
            "questionId": 13143,
            "displayText": "Feeling down, depressed, or hopeless",
            "title": null,
            "answers": [
                ...
            ],
            "explanation": "",
            "data": {
                "Properties": {
                    "Footer": "<span class=\"e24subtext\">Reference: Kroenke K, Spitzer RL, Williams JB. The Patient Health Questionnaire-2: Validity of a Two-Item Depression Screener. Medical Care. 2003;41:1284-92.</span>"
                }
            }
        }
    ],
    "assessmentType": 0,
    "errors": [],
    "completed": false
}