You are here

function biblio_pm_import_ids in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/pubmed/biblio_pm.module \biblio_pm_import_ids()
  2. 7.2 modules/pubmed/biblio_pm.module \biblio_pm_import_ids()

Imports multiple PMIDs.

Parameters

array $pmids:

array $terms:

bool $batch:

string $session_id:

Return value

array

2 calls to biblio_pm_import_ids()
biblio_pm_biblio_import in modules/pubmed/biblio_pm.module
biblio_pm_cron in modules/pubmed/biblio_pm.module

File

modules/pubmed/biblio_pm.module, line 268

Code

function biblio_pm_import_ids($pmids, $terms = array(), $batch = FALSE, $session_id = NULL) {
  module_load_include('php', 'biblio_pm', 'EntrezClient');
  $retmax = 100;
  $resmax = count($pmids);
  $start = 0;
  $Eclient = new BiblioEntrezClient();
  $Eclient
    ->post($pmids);
  $Eclient
    ->setReturnMax($retmax);
  $nids = array();
  $dups = array();
  while ($start < $resmax && ($result = $Eclient
    ->fetchRecords($start))) {
    $start += count($result
      ->xpath('//PubmedArticle'));
    list($nid, $dup) = _biblio_pm_create_node_from_xml($result, $terms, $batch, $session_id);
    $nids = array_merge($nids, $nid);
    $dups = array_merge($dups, $dup);
  }
  return array(
    $nids,
    $dups,
  );
}