The tracker is the central access point doing anything with tracks or tokens.

Tracker contains a number of getXxx functions to create Token, Survey, RespondentTrack, [Survey]SourceInterface and TrackEngine objects.

Tracker also offers \MUtil_Model_ModelAbstract children for RespondentTracks, Surveys, Tokens and Tracks.

Other object classes accessible through gems_Tracker are TokenLibrary (defines how tokens are created and checked), TokenSelect (\Gems_Tracker_Token_TokenSelect extension) and TokenValidator.

Other functions are general utility functions, e.g. checkTrackRounds(), createToken(), processCompletedTokens() and recalculateTokens().

package Gems
subpackage Tracker
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.4
inherited_from \Gems_Loader_TargetLoaderAbstract

 Methods

__construct()

__construct(\type $container, array $dirs) 

Parameters

$container

\type

A container acting as source fro \MUtil_Registry_Source

$dirs

array

The directories where to look for requested classes

__construct()

__construct(mixed $container, array $dirs) 
Inherited

Parameters

$container

mixed

A container acting as source for \MUtil_Registry_Source

$dirs

array

The directories where to look for requested classes

__get()

__get($name) 
Inherited

Parameters

$name

Add prefixed paths to the registry of paths

addPrefixPath(string $prefix, $path, boolean $prepend = true) : \Gems_Loader_LoaderAbstract
Inherited

Parameters

$prefix

string

$path

$prepend

boolean

Put path at the beginning of the stack (has no effect when prefix / dir already set)

Returns

\Gems_Loader_LoaderAbstract(continuation pattern)

Add one or more survey sourceclasses

addSourceClasses(array $stack) 

Parameters

$stack

array

classname / description array of sourceclasses

Called after the check that all required registry values have been set correctly has run.

afterRegistry() : void
Inherited

Allows the loader to set resources.

answerRegistryRequest(string $name, mixed $resource) : boolean
Inherited

Parameters

$name

string

Name of resource to set

$resource

mixed

The resource.

Returns

booleanTrue if $resource was OK

Should be called after answering the request to allow the Target to check if all required registry values have been set correctly.

checkRegistryRequestsAnswers() : boolean
Inherited

Returns

booleanFalse if required values are missing.

Checks tracks for changes to the track and round definitions and corrects them.

checkTrackRounds(string $batchId, integer $userId = null, string $cond = null) : \Gems_Task_TaskRunnerBatch

Does recalculate changed tracks

inherited_from \Gems_Tracker_TrackerInterface::checkTrackRounds()

Parameters

$batchId

string

A unique identifier for the current batch

$userId

integer

Id of the user who takes the action (for logging)

$cond

string

Optional where statement for selecting tracks

Returns

\Gems_Task_TaskRunnerBatchA batch to process the changes

Create a new track for a patient

createRespondentTrack(integer $respondentId, integer $organizationId, integer $trackId, integer $userId, mixed $respTrackData = array(), array $trackFieldsData = array()) : \Gems_Tracker_RespondentTrack
inherited_from \Gems_Tracker_TrackerInterface::createRespondentTrack()

Parameters

$respondentId

integer

The real patientId (grs_id_user), not the patientnr (gr2o_patient_nr)

$organizationId

integer

$trackId

integer

$userId

integer

Id of the user who takes the action (for logging)

$respTrackData

mixed

Optional array containing field values or the start date.

$trackFieldsData

array

Returns

\Gems_Tracker_RespondentTrackThe newly created track

Creates a new token with a new random token Id

createToken(array $tokenData, integer $userId = null) : string

Parameters

$tokenData

array

The other new data for the token

$userId

integer

Id of the user who takes the action (for logging)

Returns

string

Dynamically load and create a [Gems|Project]_Tracker class

createTrackClass(string $className, mixed $param1 = null, mixed $param2 = null) : object
inherited_from \Gems_Tracker_TrackerInterface::createTrackClass()

Parameters

$className

string

$param1

mixed

$param2

mixed

Returns

object

Utility function for detecting unchanged values.

filterChangesOnly(array $oldValues, array $newValues) : array
inherited_from \Gems_Tracker_TrackerInterface::filterChangesOnly()

Parameters

$oldValues

array

$newValues

array

Returns

array

Removes all unacceptable characters from the input token and inserts any fixed characters left out

filterToken(string $tokenId) : string
inherited_from \Gems_Tracker_TrackerInterface::filterToken()

Parameters

$tokenId

string

Returns

stringReformatted token

Returns an array of all field id's for all tracks that have a code id

getAllCodeFields() : array
inherited_from \Gems_Tracker_TrackerInterface::getAllCodeFields()

Returns

arrayid => code

Get an appointment object

getAppointment(mixed $appointmentData) : \Gems_Agenda_Appointment
inherited_from \Gems_Tracker_TrackerInterface::getAppointment()

Parameters

$appointmentData

mixed

Appointment id or array containing appintment data

Returns

\Gems_Agenda_Appointment

Returns a form to ask for a token

getAskTokenForm(mixed $args_array = null) : \Gems_Tracker_Form_AskTokenForm
inherited_from \Gems_Tracker_TrackerInterface::getAskTokenForm()

Parameters

$args_array

mixed

\MUtil_Ra::args array for Form initiation.

Returns

\Gems_Tracker_Form_AskTokenForm

Allows the loader to know the resources to set.

getRegistryRequests() : array
Inherited

Returns those object variables defined by the subclass but not at the level of this definition.

Can be overruled.

Returns

arrayof string names

getRespondentTrack()

getRespondentTrack(mixed $respTrackData) : \Gems_Tracker_RespondentTrack
inherited_from \Gems_Tracker_TrackerInterface::getRespondentTrack()

Parameters

$respTrackData

mixed

Track id or array containing trackdata

Returns

\Gems_Tracker_RespondentTrack

Load project specific model or general Gems model otherwise

getRespondentTrackModel() : \Gems_Tracker_Model_RespondentTrackModel
inherited_from \Gems_Tracker_TrackerInterface::getRespondentTrackModel()

Returns

\Gems_Tracker_Model_RespondentTrackModel

Get all tracks for a respondent

getRespondentTracks(integer $respondentId, integer $organizationId, mixed $order = array('gr2t_start_date')) : array

Specify the optional $order to sort other than on start date

inherited_from \Gems_Tracker_TrackerInterface::getRespondentTracks()

Parameters

$respondentId

integer

$organizationId

integer

$order

mixed

The column(s) and direction to order by

Returns

arrayof \Gems_Tracker_RespondentTrack

Retrieve a SourceInterface with a given id

getSource(mixed $sourceData) : \Gems_Tracker_Source_SourceInterface

Should only be called by \Gems_Tracker, \Gems_Tracker_Survey or \Gems_Tracker_Token (or should this one use \Gems_Tracker_Survey instead?)

inherited_from \Gems_Tracker_TrackerInterface::getSource()

Parameters

$sourceData

mixed

Gems source id or array containing gems source data

Returns

\Gems_Tracker_Source_SourceInterface

Returns all registered source classes

getSourceClasses() : array
inherited_from \Gems_Tracker_TrackerInterface::getSourceClasses()

Returns

arrayOf classname => description

Returns all registered database source classes

getSourceDatabaseClasses() : array
inherited_from \Gems_Tracker_TrackerInterface::getSourceDatabaseClasses()

Returns

arrayOf classname => description

getSurvey()

getSurvey(mixed $surveyData) : \Gems_Tracker_Survey
inherited_from \Gems_Tracker_TrackerInterface::getSurvey()

Parameters

$surveyData

mixed

Gems survey id or array containing gems survey data

Returns

\Gems_Tracker_Survey

getSurveyBySourceId()

getSurveyBySourceId(mixed $sourceSurveyId, integer $sourceId) : \Gems_Tracker_Survey
inherited_from \Gems_Tracker_TrackerInterface::getSurveyBySourceId()

Parameters

$sourceSurveyId

mixed

The source survey id

$sourceId

integer

The gems source id of the source

Returns

\Gems_Tracker_Survey

getSurveyModel()

getSurveyModel(\Gems_Tracker_Survey $survey, \Gems_Tracker_Source_SourceInterface $source) : \Gems_Tracker_SurveyModel
inherited_from \Gems_Tracker_TrackerInterface::getSurveyModel()

Parameters

$survey

\Gems_Tracker_Survey

$source

\Gems_Tracker_Source_SourceInterface

Returns

\Gems_Tracker_SurveyModel

getToken()

getToken(mixed $tokenData) : \Gems_Tracker_Token
inherited_from \Gems_Tracker_TrackerInterface::getToken()

Parameters

$tokenData

mixed

Token id or array containing tokendata

Returns

\Gems_Tracker_Token

getTokenFilter()

getTokenFilter() : \Gems_Tracker_Token_TokenFilter
inherited_from \Gems_Tracker_TrackerInterface::getTokenFilter()

Returns

\Gems_Tracker_Token_TokenFilter

Use this function only within \Gems_Tracker!!

getTokenLibrary() : \Gems_Tracker_Token_TokenLibrary
inherited_from \Gems_Tracker_TrackerInterface::getTokenLibrary()

Returns

\Gems_Tracker_Token_TokenLibrary

Returns a token model of the specified class with full display information

getTokenModel(string $modelClass = 'StandardTokenModel') : \Gems_Tracker_Model_StandardTokenModel
inherited_from \Gems_Tracker_TrackerInterface::getTokenModel()

Parameters

$modelClass

string

Optional class to use instead of StandardTokenModel. Must be subclass.

Returns

\Gems_Tracker_Model_StandardTokenModel

Create a select statement on the token table

getTokenSelect($fields = '*') : \Gems_Tracker_Token_TokenSelect
inherited_from \Gems_Tracker_TrackerInterface::getTokenSelect()

Parameters

$fields

Returns

\Gems_Tracker_Token_TokenSelect

getTokenValidator()

getTokenValidator() : \Gems_Tracker_Token_TokenValidator
inherited_from \Gems_Tracker_TrackerInterface::getTokenValidator()

Returns

\Gems_Tracker_Token_TokenValidator

Get the allowed display groups for tracks in this project.

getTrackDisplayGroups() : array
inherited_from \Gems_Tracker_TrackerInterface::getTrackDisplayGroups()

Returns

array

getTrackEngine()

getTrackEngine(mixed $trackData) : \Gems_Tracker_Engine_TrackEngineInterface
inherited_from \Gems_Tracker_TrackerInterface::getTrackEngine()

Parameters

$trackData

mixed

Gems track id or array containing gems track data

Returns

\Gems_Tracker_Engine_TrackEngineInterface

Returns dummy objects for all registered track engines class names

getTrackEngineClasses() : array
Static

Instead of creating another object layer all classes defined by getTrackEngineClassNames() are loaded with dummy data so that the TrackEngineInterface functions containing general class information can be used.

see
static $dummyClasses Cache array
inherited_from \Gems_Tracker_TrackerInterface::getTrackEngineClasses()

Returns

arrayOf \Gems_Tracker_Engine_TrackEngineInterface

Return the edit snippets for editing or creating a new track

getTrackEngineEditSnippets() : array
inherited_from \Gems_Tracker_TrackerInterface::getTrackEngineEditSnippets()

Returns

arrayof snippet names for creating a new track engine

Returns all registered track engines classes for use in drop down lists.

getTrackEngineList(boolean $extended = false, boolean $userCreatableOnly = false) : array
inherited_from \Gems_Tracker_TrackerInterface::getTrackEngineList()

Parameters

$extended

boolean

When true return a longer name.

$userCreatableOnly

boolean

Return only the classes that can be created by the user interface

Returns

arrayOf classname => description

Simple function for a default track model.

getTrackModel() : \Gems_Tracker_Model_TrackModel
inherited_from \Gems_Tracker_TrackerInterface::getTrackModel()

Returns

\Gems_Tracker_Model_TrackModel

Checks the token table to see if there are any answered surveys to be processed

processCompletedTokens(integer $respondentId, integer $userId = null, integer $orgId = null, boolean $quickCheck = false) : boolean

If the survey was started (and the token was forwarded to limesurvey) we need to check if is was completed. If so, we might want to check the track the survey is in to enable or disable future rounds

Does not reflect changes to tracks or rounds.

inherited_from \Gems_Tracker_TrackerInterface::processCompletedTokens()

Parameters

$respondentId

integer

Id of the respondent to check for or NULL

$userId

integer

Id of the user who takes the action (for logging)

$orgId

integer

Optional Id of the organization to check for

$quickCheck

boolean

Check only tokens with recent gto_start_time's

Returns

booleanDid we find new answers?

Recalculates the fields in tracks.

recalcTrackFields(string $batchId, integer $userId = null, string $cond = null) : \Gems_Task_TaskRunnerBatch

Does recalculate changed tracks

inherited_from \Gems_Tracker_TrackerInterface::recalcTrackFields()

Parameters

$batchId

string

A unique identifier for the current batch

$userId

integer

Id of the user who takes the action (for logging)

$cond

string

Optional where statement for selecting tracks

Returns

\Gems_Task_TaskRunnerBatchA batch to process the changes

Recalculates all token dates, timing and results and outputs text messages.

recalculateTokens(string $batch_id, integer $userId = null, string $cond = null) : \Gems_Task_TaskRunnerBatch

Does not reflect changes to tracks or rounds.

inherited_from \Gems_Tracker_TrackerInterface::recalculateTokens()

Parameters

$batch_id

string

A unique identifier for the current batch

$userId

integer

Id of the user who takes the action (for logging)

$cond

string

Returns

\Gems_Task_TaskRunnerBatchA batch to process the changes

Refreshes the tokens in the source

refreshTokenAttributes(string $batch_id, string $cond = null) : \Gems_Task_TaskRunnerBatch
inherited_from \Gems_Tracker_TrackerInterface::refreshTokenAttributes()

Parameters

$batch_id

string

A unique identifier for the current batch

$cond

string

An optional where statement

Returns

\Gems_Task_TaskRunnerBatchA batch to process the changes

Remove token from cache for saving memory

removeToken(string|\Gems_Tracker_Token $token) : \Gems_Tracker
inherited_from \Gems_Tracker_TrackerInterface::removeToken()

Parameters

$token

string\Gems_Tracker_Token

Returns

\Gems_Tracker(continuation pattern)

Recalculates all token dates, timing and results and outputs text messages.

synchronizeSources(integer $sourceId = null, integer $userId = null) : \Gems_Task_TaskRunnerBatch

Does not reflect changes to tracks or rounds.

inherited_from \Gems_Tracker_TrackerInterface::synchronizeSources()

Parameters

$sourceId

integer

A source identifier

$userId

integer

Id of the user who takes the action (for logging)

Returns

\Gems_Task_TaskRunnerBatchA batch to process the synchronization

Add a subdirectory / sub name to a list of class load paths

_cascadedDirs(array $dirs, string $cascade, boolean $fullClassnameFallback = true) : array
Inherited

Parameters

$dirs

array

prefix => path

$cascade

string

The sub directories to cascade to

$fullClassnameFallback

boolean

Allows full class name specification instead of just plugin name part

Returns

arrayprefix => path

Returns $this->$name, creating the item if it does not yet exist.

_getClass(string $name, string $className = null, array $arguments = array()) : mixed
Inherited

Parameters

$name

string

The $name of the variable to store this object in.

$className

string

Class name or null if the same as $name, prepending $this->_dirs.

$arguments

array

Class initialization arguments.

Returns

mixedInstance of $className

Create or loads the class. When only loading, this function returns a StaticCall object that can be invoked lazely.

_loadClass(string $name, boolean $create = false, array $arguments = array()) : mixed
Inherited
see
see

Parameters

$name

string

The class name, minus the part in $this->_dirs.

$create

boolean

Create the object, or only when an \MUtil_Registry_TargetInterface instance.

$arguments

array

Class initialization arguments.

Returns

mixedA class instance or a \MUtil_Lazy_StaticCall object

Filters the names that should not be requested.

filterRequestNames(string $name) : boolean
Inherited

Can be overriden.

Parameters

$name

string

Returns

boolean

Returns all registered track engines class names

getTrackEngineClassNames() : array

Returns

arrayOf classname

Checks the token table to see if there are any answered surveys to be processed

processTokensBatch(string $batch_id, \Gems_Tracker_Token_TokenSelect $tokenSelect, integer $userId) : \Gems_Task_TaskRunnerBatch

If the survey was started (and the token was forwarded to limesurvey) we need to check if is was completed. If so, we might want to check the track the survey is in to enable or disable future rounds

Does not reflect changes to tracks or rounds.

Parameters

$batch_id

string

A unique identifier for the current batch

$tokenSelect

\Gems_Tracker_Token_TokenSelect

Select statements selecting tokens

$userId

integer

Id of the user who takes the action (for logging)

Returns

\Gems_Task_TaskRunnerBatchA batch to process the changes

Replaces a null or empty userId with that of the current user

_checkUserId(integer $userId = null) : integer

Parameters

$userId

integer

Returns

integer

 Properties

 

Set to true to get detailed information on all tracker actions

$verbose : boolean

Default

false
Static
 

The prefix/path location to look for classes.

$_dirs : array

Default

The standard value is

  • => application/classes
  • Gems => library/Gems/classes

But an alternative could be:

  • Demopulse => application/classes
  • Pulse => application/classes
  • Gems => library/Gems/classes
 

$_loader

$_loader : \MUtil_Loader_PluginLoader

Default

 

This variable holds all registered source classes, may be changed in derived classes

$_sourceClasses : array

Default

array('LimeSurvey1m9Database' => 'Lime Survey 1.90 DB', 'LimeSurvey1m91Database' => 'Lime Survey 1.91+ DB', 'LimeSurvey2m00Database' => 'Lime Survey 2.00 DB')
 

Allows sub classes of \Gems_Loader_LoaderAbstract to specify the subdirectory where to look for.

$cascade : string

Default

'Tracker'
 

Allows sub classes of \Gems_Loader_LoaderAbstract to specify the subdirectory where to look for.

$cascade : string

Default

null
 

$currentUser

$currentUser : \Gems_User_User

Default

 

$db

$db : \Zend_Db_Adapter_Abstract

Default

 

$loader

$loader : \Gems_Loader

Default

 

$logger

$logger : \Gems_Log

Default

 

$session

$session : \Zend_Session

Default

 

$translate

$translate : \Zend_Translate

Default

 

of \Gems_Tracker_RespondentTrack

$_respTracks : array

Default

array()
 

of \Gems_Tracker_SourceInterface

$_sources : array

Default

array()
 

of \Gems_Survey

$_surveys : array

Default

array()
 

$_tokenLibrary

$_tokenLibrary : \Gems_Tracker_TokenLibrary

Default

 

of \Gems_Tracker_Model_StandardTokenModel

$_tokenModels : array

Default

array()
 

of \Gems_Tracker_Token

$_tokens : array

Default

array()
 

of \Gems_Tracker_Engine_TrackEngineInterface

$_trackEngines : array

Default

array()

 Constants

 

DB_DATETIME_FORMAT

DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss' 
 

DB_DATE_FORMAT

DB_DATE_FORMAT = 'yyyy-MM-dd'