original_string: protected function findRespondentTrackFor(array $row)
      {
          if (! (isset($row[$this->patientNrField], $row[$this->orgIdField]) &&
                  $row[$this->patientNrField] &&
                  $row[$this->orgIdField])) {
              return null;
          }
  
          $trackId = $this->getTrackId();
          if (! $trackId) {
              return null;
          }
  
          $select = $this->db->select();
          $select->from('gems__respondent2track', array('gr2t_id_respondent_track'))
                  ->joinInner(
                          'gems__respondent2org',
                          'gr2t_id_user = gr2o_id_user AND gr2t_id_organization = gr2o_id_organization',
                          array()
                          )
                  ->where('gr2o_patient_nr = ?', $row[$this->patientNrField])
                  ->where('gr2o_id_organization = ?', $row[$this->orgIdField])
                  ->where('gr2t_id_track = ?');
  
  
          $select->order(new \Zend_Db_Expr("CASE
              WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NULL THEN 1
              WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NOT NULL THEN 2
              ELSE 3 END ASC"))
                  ->order('gr2t_start_date DESC')
                  ->order('gr2t_end_date DESC')
                  ->order('gr2t_created');
  
          $respTrack = $this->db->fetchOne($select);
  
          if ($respTrack) {
              return $respTrack;
          }
  
          return null;
      }
code: protected function findRespondentTrackFor(array $row)
      {
          if (! (isset($row[$this->patientNrField], $row[$this->orgIdField]) &&
                  $row[$this->patientNrField] &&
                  $row[$this->orgIdField])) {
              return null;
          }
  
          $trackId = $this->getTrackId();
          if (! $trackId) {
              return null;
          }
  
          $select = $this->db->select();
          $select->from('gems__respondent2track', array('gr2t_id_respondent_track'))
                  ->joinInner(
                          'gems__respondent2org',
                          'gr2t_id_user = gr2o_id_user AND gr2t_id_organization = gr2o_id_organization',
                          array()
                          )
                  ->where('gr2o_patient_nr = ?', $row[$this->patientNrField])
                  ->where('gr2o_id_organization = ?', $row[$this->orgIdField])
                  ->where('gr2t_id_track = ?');
  
  
          $select->order(new \Zend_Db_Expr("CASE
              WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NULL THEN 1
              WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NOT NULL THEN 2
              ELSE 3 END ASC"))
                  ->order('gr2t_start_date DESC')
                  ->order('gr2t_end_date DESC')
                  ->order('gr2t_created');
  
          $respTrack = $this->db->fetchOne($select);
  
          if ($respTrack) {
              return $respTrack;
          }
  
          return null;
      }
code_tokens: protected function findRespondentTrackFor ( array $ row ) { if ( ! ( isset ( $ row [ $ this -> patientNrField ] , $ row [ $ this -> orgIdField ] ) && $ row [ $ this -> patientNrField ] && $ row [ $ this -> orgIdField ] ) ) { return null ; } $ trackId = $ this -> getTrackId ( ) ; if ( ! $ trackId ) { return null ; } $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__respondent2track' , array ( 'gr2t_id_respondent_track' ) ) -> joinInner ( 'gems__respondent2org' , 'gr2t_id_user = gr2o_id_user AND gr2t_id_organization = gr2o_id_organization' , array ( ) ) -> where ( 'gr2o_patient_nr = ?' , $ row [ $ this -> patientNrField ] ) -> where ( 'gr2o_id_organization = ?' , $ row [ $ this -> orgIdField ] ) -> where ( 'gr2t_id_track = ?' ) ; $ select -> order ( new \ Zend_Db_Expr ( "CASE
              WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NULL THEN 1
              WHEN gr2t_start_date IS NOT NULL AND gr2t_end_date IS NOT NULL THEN 2
              ELSE 3 END ASC" ) ) -> order ( 'gr2t_start_date DESC' ) -> order ( 'gr2t_end_date DESC' ) -> order ( 'gr2t_created' ) ; $ respTrack = $ this -> db -> fetchOne ( $ select ) ; if ( $ respTrack ) { return $ respTrack ; } return null ; }
docstring: If the token can be created find the respondent track for the token
  
  @param array $row
  @return int|null
docstring_tokens: If the token can be created find the respondent track for the token