original_string: public function matchHealthcareStaff($name, $organizationId, $create = true)
      {
          $cacheId = __CLASS__ . '_' . __FUNCTION__;
          $matches = $this->cache->load($cacheId);
  
          if (! $matches) {
              $matches = array();
              $select     = $this->db->select();
              $select->from('gems__agenda_staff')
                      ->order('gas_name');
  
              $result = $this->db->fetchAll($select);
              foreach ($result as $row) {
                  foreach (explode('|', $row['gas_match_to']) as $match) {
                      $matches[$match][$row['gas_id_organization']] = $row['gas_filter'] ? false : $row['gas_id_staff'];
                  }
              }
              $this->cache->save($matches, $cacheId, array('staff'));
          }
  
          if (isset($matches[$name])) {
              if ($organizationId) {
                  if (isset($matches[$name][$organizationId])) {
                      return $matches[$name][$organizationId];
                  }
              } else {
                  // Return the first location among the organizations
                  return reset($matches[$name]);
              }
          }
  
          if (! $create) {
              return null;
          }
  
          $result = $this->addHealthcareStaff($name, $organizationId);
  
          return $result['gas_filter'] ? false : $result['gas_id_staff'];
      }
code: public function matchHealthcareStaff($name, $organizationId, $create = true)
      {
          $cacheId = __CLASS__ . '_' . __FUNCTION__;
          $matches = $this->cache->load($cacheId);
  
          if (! $matches) {
              $matches = array();
              $select     = $this->db->select();
              $select->from('gems__agenda_staff')
                      ->order('gas_name');
  
              $result = $this->db->fetchAll($select);
              foreach ($result as $row) {
                  foreach (explode('|', $row['gas_match_to']) as $match) {
                      $matches[$match][$row['gas_id_organization']] = $row['gas_filter'] ? false : $row['gas_id_staff'];
                  }
              }
              $this->cache->save($matches, $cacheId, array('staff'));
          }
  
          if (isset($matches[$name])) {
              if ($organizationId) {
                  if (isset($matches[$name][$organizationId])) {
                      return $matches[$name][$organizationId];
                  }
              } else {
                  // Return the first location among the organizations
                  return reset($matches[$name]);
              }
          }
  
          if (! $create) {
              return null;
          }
  
          $result = $this->addHealthcareStaff($name, $organizationId);
  
          return $result['gas_filter'] ? false : $result['gas_id_staff'];
      }
code_tokens: public function matchHealthcareStaff ( $ name , $ organizationId , $ create = true ) { $ cacheId = __CLASS__ . '_' . __FUNCTION__ ; $ matches = $ this -> cache -> load ( $ cacheId ) ; if ( ! $ matches ) { $ matches = array ( ) ; $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__agenda_staff' ) -> order ( 'gas_name' ) ; $ result = $ this -> db -> fetchAll ( $ select ) ; foreach ( $ result as $ row ) { foreach ( explode ( '|' , $ row [ 'gas_match_to' ] ) as $ match ) { $ matches [ $ match ] [ $ row [ 'gas_id_organization' ] ] = $ row [ 'gas_filter' ] ? false : $ row [ 'gas_id_staff' ] ; } } $ this -> cache -> save ( $ matches , $ cacheId , array ( 'staff' ) ) ; } if ( isset ( $ matches [ $ name ] ) ) { if ( $ organizationId ) { if ( isset ( $ matches [ $ name ] [ $ organizationId ] ) ) { return $ matches [ $ name ] [ $ organizationId ] ; } } else { // Return the first location among the organizations return reset ( $ matches [ $ name ] ) ; } } if ( ! $ create ) { return null ; } $ result = $ this -> addHealthcareStaff ( $ name , $ organizationId ) ; return $ result [ 'gas_filter' ] ? false : $ result [ 'gas_id_staff' ] ; }
docstring: Find a healt care provider for the name and organization.
  
  @param string $name The name to match against
  @param int $organizationId Organization id
  @param boolean $create Create a match when it does not exist
  @return int gas_id_staff staff id
docstring_tokens: Find a healt care provider for the name and organization .