Triage Option Callbacks

When a triage option is selected, TriageOption.select should be called. This will execute TriageOption.callback if it is defined. A triage option callback needs to be of the type triageOptionCallback in order to take advantage of the provided arguments. This function will be called in your application when a symptom is selected. This callback function is your chance to process the selected triage option with references to the current encounter, most acute symptom, the triage option and any other arguments that you would like to provide from your application.

The callback should handle the arguments (encounter, symptom, triageOption, any) where:

  • encounter is the current encounter summary
  • symptom is the symptom that the selected triage option was matched against
  • triageOption for a reference to the triage option itself
  • any is an object with any other arguments you want to provide to the callback from within your application.

A simple triage option could look like this:

{
    'level_min': 0,
    'level_max': 100,
    'button_text': 'Check In for Visit',
    'icon': 'fa fa-plus',
    'urgentcare': true,
    'callback': function(encounter, symptom, option) {
        window.location('www.ourhospital.com/urgentcare/wait-times?symptom='+encodeURIComponent(symptom.text)+'&topic='+encodeURIComponent(encounter.topicsViewed[0].title)+'&age='+encodeURIComponent(encounter.ageGroup));
    }
}

This triage option callback function will link to our urgent care wait times webpage with url parameters providing the text for the current symptom as well as the topic name and age group for the symptom check.

Example Implementation

In app/config.js we override the default triage options and we declare a few of them with callbacks. In our First Aid triage option we utilize the callback to navigate to the first aid state in our application. We use the first_aid_id associated with the selected system to perform this navigation.

{
    'level_min': 0,
    'level_max': 100,
    'button_text': 'See First Aid',
    'icon': 'fa fa-plus',
    'first_aid': true,
    'callback': function(encounter, symptom, option, $state) {
        $state.go('topic.special', { type: 'image', id: symptom.first_aid_id }).then(function() {
            $state.reload();
        })
    }
}

In our example application we provide $state as the any object in our triage option callback. This allows us to navigate to any state within our application based on the properties of the encounter, symptom or triage option. Here we use it to go to the special topic state, with the topic type of image and the id from symptom.first_aid_id.