While a track is used program code can be triggered at various moments
The code to be executed can be project specific, but general GemsTracker code has been defined some of these events. This document describes these events in the order that they are executed by GemsTracker.
In the Track builder you can define survey level events for each survey. See: Menu > Trackbuilder > Surveys > edit survey
Before answering events trigger before the user starts to answer a survey. These events typically exist to pre-set answers for the user, e.g. by copying them from earlier answers or copying them from a track field or patient information.
After completion events trigger as soon as a survey has been completed, but also whenever answers exist while re-checking for answers in the Track builder.
Initially most completion events where created to perform calculations on survey results, but these days these calculation are usually performed in LimeSurvey. We advise you to do so and perform only very complex calculation that e.g. use database look-ups in GemsTracker, as you can write your own calculations in LimeSurvey while you need programmer level access to write them in GemsTracker.
Today after completion events are still used, usually to activate or de-activate follow-up surveys depending on an answer or to update respondent level values or to e.g. trigger uploads of data elsewhere. These events all use project specific code.
When the default answer display is not sufficient for your project, you can choose another display type, e.g. to skip all unanswered values or to add the answers to the same survey in other tracks to the display. More complex displays are also possible, e.g. to use charts.
Each round in a track can also have rounds specific event code. You can set these events when editing track rounds in the track builder. See: Menu: Trackbuilder > Tracks > Show > Rounds > Edit
Whenever a survey has been completed, but also whenever answers exist while re-checking for answers in the Track builder the round changed event is triggered.
While the survey after completion event is triggered as soon as it is noticed that the survey has been completed, GemsTracker waits with the execution of the round changed event until it has checked all other open surveys or even all other checked surveys when in the track builder.
This is to prevent answers in one survey to disable another survey while that survey was already completed.
Round changed event are thus solely used to activate or de-activate follow-up surveys or e.g. to trigger uploads of data elsewhere. All round changed events use project specific code, so if your project does not have such events you cannot choose them in the interface.
You can overrule survey level answer display code, e.g. if you want a different answer display for the first instance of a survey in a track.
When editing tracks in the Track builder you can set track level events. Most events at the track level are project specific, so you will only be able to set then when events have been written for your project. See: Menu > Trackbuilder > Edit
Field update events trigger whenever field values change. This can happen either when a user manually edits a track assigned to a respondent or when the track has an automatically linked field - e.g. an appointment - that changes due to an automatic import.
This event type can be used e.g. to enable or disable tokens depending on the field value. For example not showing the tokens linked to an appointment when the appointment is not set.
Field updates also trigger track recalculation.
Whenever a token date has been edited, a track field has changed or a survey has been answered the track calculation event is triggered. GemsTracker first checks all open surveys for answers or all fields for changes and only then executes a single track recalculation of all dates. The track calculation event is triggered before all dates are recalculated.
This event is used with project specific code only, so usually you can not set it when editing tracks. A good example for this code would be to reset all manually set token dates before track recalculation.
When all surveys have been answered, i.e. the number of answered tracks is identical to the total number of answerable tracks, then the track completion event is triggered as the last event of all triggered events.
This event is used with project specific code only, so usually you can not set it when editing tracks. Often this code is used to start a new track based on the outcome of the previous track.