You are here

function biblio_pm_fetch_pmid in Bibliography Module 7

Fetches the article for the given PMID and returns a biblio node object.

Returns an empty node object if the PMID is not found.

Parameters

int $pmid:

Return value

stdClass $node

File

modules/pubmed/biblio_pm.module, line 297

Code

function biblio_pm_fetch_pmid($pmid) {
  $node = new stdClass();
  $Eclient = new BiblioEntrezClient();
  $paser = new BiblioEntrezPubmedArticle();
  try {
    $xml = $Eclient
      ->fetch($pmid);
  } catch (Exception $e) {
    return $node;
  }
  $articles = $xml
    ->xpath('//PubmedArticle');
  if (count($articles)) {
    $node = $paser
      ->setArticle($articles[0])
      ->getBiblioAsObject();
    if (!empty($node)) {
      $node->type = 'biblio';
      node_object_prepare($node);
    }
  }
  return $node;
}