Following pathway functions are available in Program JS at the item level.


# Function Name Description
1 doc_value(); Returns value of current item.

Return value:

array - for multi-select
string - all other item types.
json - for blood pressure

For blood pressure item type following json will be returned:

{systolic: <systolic value>,
diastolic: <diastolic value>}


e.g:

var value = doc_value();
var numberValue = parseInt(doc_value());


if doc_value()= INPUT, return #;

Conditional Pathway with yes/no or single select
"If patient picks "yes", go to item #, otherwise, go to other #"
if (doc_value() == 'yes') {
        return #;
} else {
        return #;
}

"If patient picks option 1 or 3, go to item #, otherwise, go to other #"
if (parseInt(doc_value()) == 1 ||
        parseInt(doc_value()) == 3) {
        return #;
} else {
        return #;
}


Conditional Pathway w/input value examples
"If patient input is greater than or equal to 100, go to #, otherwise, go to other #"
if (parseInt(doc_value()) >= 100) {
        return #;
} else {
        return #;
}

"If patient systolic BP is greater than or equal to 130 and less than 150 OR patient diastolic BP is greater than or equal to 80 and less than or equal to 90, go to #, otherwise, go to other #"

var bloodPressure = doc_value();
if ((bloodPressure.systolic >= 130 &&
                bloodPressure.systolic <
                150) || (bloodPressure.diastolic >=
                80 && bloodPressure.diastolic <
                90)) {
        return #;
}
2 doc_item_value(item #); Returns value of a specific item by its item number.

Parameters:

item #: Number.  Returns value of an item with this item number.

Return value:

array - for multi-select
string - all other item types.
json - for blood pressure

For blood pressure item type following json will be returned:

{systolic: <systolic value>,
diastolic: <diastolic value>}


e.g:
var value = doc_value(10);
var numberValue = parseInt(doc_value(10));


if doc_item_value(10)= INPUT, return #;
3 doc_values_count(); Returns total number of values selected for a multi-select item type.

Return value: number

e.g:

var count = doc_values_count();
4 doc_value(index); For multi-select items this returns a particular value based on array index for current item.

Parameters:

index: Number. Element number in array to return. First element is 0.

Return value: string

e.g:

var elementValue = doc_value(0);
5 doc_item_value(item #, index); For multi-select items this returns a particular value based on array index for a specific item.

Parameters:

item #: Number. Returns value of an item with this item number.
index: Number. Element number of an array to return. The first element is 0.

Return value: string

e.g:

var elementValue = doc_value(1, 0);
6 doc_correct_response(); Returns true if the response for current item is correct, false otherwise.

The correct response is determined by comparing the value specified by user and values available in the correct response attribute of the item.

e.g:

var response = doc_correct_response();
7 doc_send_smartlist(provider_alias, carepgoram_alias, add_to_dashboard, date_offset); Send the specified careprogram to user. If the user's email address is available then send Care Program invitation as email, otherwise if phone numer is available then an SMS will be sent. 



Parameters:

provider_alias: String. Alias or virtual path or provider. If empty then the current provider will be assumed.


careprogram_alias: String. Alias or virtual path of Care Program to send.


add_to_dashboard: Boolean, If true, Care Program will be added to provider's dashboard. 


date_offset: String. If a date or a date and time are specified then that will be sent to the patient as anchor date. If no date is specified then the date will be inherited from current CareProgram. 


If an offset is specified instead of a date then the date will be inherited from current CareProgram and offset will be applied to calculate the anchor date.


e.g:


doc_send_smartlist('abc hospital','total-knee-replacement', true, '05/11/2017');

doc_send_smartlist('/abc-hospital','/total-knee-replacement', true, '05/11/2017');


8 doc_sl_date(); Returns anchor date of current CareProgram.

Return value: Date

var anchorDate = doc_sl_date();
9 doc_item_due_date(); Returns due date for current item.

Return value: Date.

e.g:

var dueDate = doc_item_due_date();
10 doc_reset_state(); Reset state of current item.

e.g:

doc_reset_state();

Used in a single select question - "if the patient selects option 1, advance them to next question (item 4). If they select any other option, reset item state to not-complete and try again." 

if (parseInt(doc_value()) == 1) {
        return 4;
} else doc_reset_state("null"); {
        return 3;
}

11 doc_provider_notification(notification_label, message); Sends notification to all providers that have receive notification access.

Parameters:

notification_label: String. An array of labels to set for notification.
message: String. Message to send with notification.

e.g:

"notify me if my patient's heart rate exceeds 100bpm"

if (parseInt(doc_value()) >= 100)doc_provider_notification('High Risk','Heart rate is over 100bpm'); return #;



12 doc_add_label(label); Adds label to current item. To add multiple labels, call this function multiple times.

Parameters:

label: String. Label to add.

e.g:

doc_add_label('High Risk');
13 doc_disable_root(item #); Disable root item of a branch. Once a root item is disabled, the root item will not be displayed in the daily list.

Parameters:

item #: Number. The item number of root item to disable.

e.g:

doc_disable_root(20);
14 doc_enable_root(item #);
Enable root item of a branch. Once a root item is enabled, the root item will be displayed in the daily list.

Parameters:

item #: Number. The item number of root item to enable.

e.g:

doc_enable_root(20);
15 doc_maual_flow(); Return true if pathway function being executed was initiated through a manual user flow. Manual flow is when a user explicitly takes an action on an item that results in a pathway flow.

When pathway function gets executed in the background as a result of continuous monitoring item, this will return false.

e.g:

doc_manual_flow();
16 doc_set_global(global_value_name, value); Assigns object to a global value. Global values are like global variables with scope of entire CareProgram. Once a global value is set, it can be fetched or set again from any item in the CareProgram.

If a value is set again, it will override the existing value.

Parameters:

global_value_name: String. Name to assign to the global value.
value: Object. Value defined as any javascript object.

e.g:

doc_set_global("HR_STATE", "HIGH");

17 doc_get_global(global_value_name);
Gets global value. It will return an Object, that was set using doc_set_global.

e.g:

var heartRateState = doc_get_global("HR_STATE");
18 _END When _END is returned, the lightbox will be closed. This is only available on web.

e.g: return _END;
19 _END_SHOW_ACTIVITY_CENTER When _END_SHOW_ACTIVITY_CENTER is returned, the lightbox will be closed and the user will be taken to activity center page. This is only available on the web.

e.g: return _END_SHOW_ACTIVITY_CENTER;
20 _END_OPEN_EXPLORE_RESOURCES
When _END_OPEN_EXPLORE_RESOURCES is returned, the lightbox will be closed and the first category under explore resources section will be opened. This is only available on the web.

e.g: return _END_OPEN_EXPLORE_RESOURCES;