Sending an SMS via Assessments (Forms)

This article is part of the assessment builder guide. You will require administration access to view the pages mentioned in this article.

Although Trigger Scripting (Workflow Engine) is not covered here, below is some sample to code which send an SMS to the patient on approval of the assessment that references this script.


Step 1: Create the Trigger Script


Trigger Class Details

Type: Assessment

Name: Send SMS on Approval

Version: 1.0


Trigger Script


Trigger: After Approval

State: User Initiated

Name: Send SMS

Version: 1.0

Order: 20

Code

=====================================================

 CODE

=====================================================

var now = new Date;

var location = '[LOCATION_CODE]';

var msg_template = '[MESSAGE_TYPE_CODE]';

var patient = assessment.current_assessment.patient;


patient.send_sms(location, msg_template, now);


=====================================================

END OF CODE

=====================================================

N.B. 

The Message  Template must be a configured Patient SMS template.

The location uses the location's code.


=====================================================

EXAMPLE CODE

=====================================================

var now = new Date;

var location = 'Clintel Clinic';

var msg_template = 'PATIENT_WELCOME';

var patient = assessment.current_assessment.patient;


patient.send_sms(location, msg_template, now);


=====================================================

END OF EXAMPLE CODE

=====================================================


Step 2: Reference the Trigger Script in the Assessment 

When creating an assessment that sends an SMS after it is approved, make sure under 


Which trigger-able classes does this assessment support?

The trigger script you just created is ticked. See New Assessment for details on creating a new assessment.