/**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     if (!$token->getReceptionCode()->isSuccess()) {
         return;
     }
     $answers = $token->getRawAnswers();
     if (isset($answers['informedconsent'])) {
         $consent = $this->util->getConsent($answers['informedconsent']);
         if ($consent->exists) {
             // Is existing consent description as answer
             $consentCode = $consent->getDescription();
         } else {
             if ($answers['informedconsent']) {
                 // Uses start of consent description as answer (LS has only 5 chars for an answer option)
                 $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_description LIKE ? ORDER BY gco_order", $answers['informedconsent'] . '%');
             } else {
                 $consentCode = false;
             }
             if (!$consentCode) {
                 if ($answers['informedconsent']) {
                     // Code not found, use first positive consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code != ? ORDER BY gco_order", $this->util->getConsentRejected());
                 } else {
                     // Code not found, use first negative consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code = ? ORDER BY gco_order", $this->util->getConsentRejected());
                 }
             }
         }
         $respondent = $token->getRespondent();
         $values = array('gr2o_patient_nr' => $respondent->getPatientNumber(), 'gr2o_id_organization' => $respondent->getOrganizationId(), 'gr2o_consent' => $consentCode);
         $respondent->getRespondentModel()->save($values);
     }
     return false;
 }
 /**
  * Called after loadFormData() in loadForm() before the form is created
  *
  * @return boolean Are we undeleting or deleting?
  */
 public function isUndeleting()
 {
     return !$this->token->getReceptionCode()->isSuccess();
 }
 /**
  * Determines if this particular token should be included
  * in the report
  *
  * @param  \Gems_Tracker_Token $token
  * @return boolean This dummy implementation always returns true
  */
 protected function _isTokenInFilter(\Gems_Tracker_Token $token)
 {
     $result = false;
     // Only if token has a success code
     if ($token->getReceptionCode()->isSuccess()) {
         $result = true;
     }
     if ($result) {
         $tokenInfo = array('code' => $token->getSurvey()->getCode(), 'surveyid' => $token->getSurveyId(), 'tokenid' => $token->getTokenId());
         // Now check if the tokenfilter is true
         if (empty($this->tokenFilter)) {
             $result = true;
         } else {
             $result = false;
             // Now read the filter and split by track code or track id
             foreach ($this->tokenFilter as $filter) {
                 $remaining = array_diff_assoc($filter, $tokenInfo);
                 if (empty($remaining)) {
                     $result = true;
                     break;
                 }
             }
         }
     }
     return $result;
 }