Awell Health Developer Hub
Dev Hub

The onEvent function is called whenever orchestration or design (preview) activates a Custom Action. It will publish a message that is received by the extension server, which automatically finds the right Custom Action and calls the onEvent function defined in that action.

onEvent with callbacks

The onEvent function has a couple of parameters that will be useful when developing an extension:

  1. Payload: not only gives you access to the values of your extension settings and action fields but also to patient and pathway-related data.
  2. Callbacks: they allow you to communicate with the Design (preview) or Orchestration engine and delegate back control to them. An extension should either call the onComplete or onError function.
01

Payload

The payload allows you to access the values of your extension settings, action fields, and patient data.

01

onComplete callback

The onComplete callback can be called to confirm your activity has been completed and can be called with the following (optional) parameters:

  • Data points: allows you to ingest values in the pathway through data points which can then be used by the pathway builder for conditional logic, variables, and more.
  • Events: activity events can be used to provide more granular info on what the extension does. These events will be displayed under the "updates" tab in Awell Studio & Awell Care.
01

Important: If you do not call the onComplete function, the activity will not be completed by the extension server. However, the activity can still be completed elsewhere (e.g. Awell Hosted Pages) by calling the completeExtensionActivity mutation.

onError callback

The onError callback can be called to let Awell know something went wrong with running your extension code.

An activity that calls onError will still be completed, however the "resolution" of the activity will be marked as "failed".

The function can be called with the following (optional) parameter:

  • Events: activity events can be used to provide more granular info on what the extension does. These events will be displayed under the "updates" tab in Awell Studio & Awell Care.
01

Helpers

The helpers object contains useful functions that can be used in your extension. The following functions are available:

httpsAgent

A function returns an https agent that can be used to make requests to external APIs using the mTLS protocol.

01

AwellSdk

A promise that resolves to the Awell SDK. The Awell SDK can be used to interact with the Awell API using an API key from your tenant. If you do not already have an API key, calling this function will generate one for you.

01

Have an idea for something to make your extension-building life easier? Let us know!