These ids were not being populated. In fact, pmcid appeared to be a placeholder. I made some adjustments so that the information made it into the database (more of a fix). The patch also includes some code that looks up the information based on DOI when available (more of a feature).

Comments

rjerome’s picture

In the presave nodeapi hook, I'm not sure why you are calling the insert hook?

      if ($Eclient->count() == 1) {
        $node->biblio_pubmed_id = (string) $result->IdList->Id;
        drupal_set_message(t("Located PubMed ID: !id", array('!id' => $node->biblio_pubmed_id)));
        if (isset($node->nid)) {
          _biblio_pm_insert($node);
        }
      }
        if ($Eclient->count() == 1) {
          $node->biblio_pmcid = (string) $result->IdList->Id;
          drupal_set_message(t("Located PMC ID: !id", array('!id' => $node->biblio_pmcid)));
          if (isset($node->nid) && (!isset($node->biblio_pubmed_id) || empty($node->biblio_pubmed_id))) {
            _biblio_pm_insert($node);
          }
        }
stackpr’s picture

It calls the insert hook when the nid is already set because the update hook lacks the necessary functionality if the PMID is added during a node edit.

The update hook is called after presave when the node is being edited, but it never inserts a row into the pubmed table:

  if (isset($node->biblio_pubmed_id) && !empty($node->biblio_pubmed_id)) {
    $node->biblio_pm_changed = time();
    drupal_write_record('biblio_pubmed', $node, 'nid');
  }

If the pmid or pmcid is added after initial node creation, then the data needs to be inserted at some point.

The other alternative (probably cleaner) would be to pack the update method with a little more logic. After the initial write, it could check to confirm that a row has been affected and insert the data if it has not. As a side note, it also does not appear that you can remove a PMID from a node since it would not make it past the condition that does the write, although I am not sure whether that is the intended behavior (I don't mind it).

rjerome’s picture

Oh yeah, I was thinking it did an "insert" on the node (which already existed), but it's doing an insert on the pmid which doesn't exist yet.

rjerome’s picture

I guess the only other thing that worries me about this one is that it might severely impact bulk imports, since it could be doing two Pubmed queries for every entry. Import files with 5 - 10 thousand entries are not uncommon, so perhaps there should be admin option to turn this feature on/off.

Ron.

stackpr’s picture

Status: Needs review » Active

Good to know about that use case. I'll shift this logic into a configurable cron run and submit a new patch.

rjerome’s picture

Good idea.

ursula’s picture

I also need to display and to edit PMIDs and PMC IDs. The PMC IDs are particularly tricky.

My question here is: are you planning to also add the PMID and PMCID to the edit form for biblio entries as well? The reasoning for that is below. If there are no plans already, I might undertake this myself (in the D7 version).

After our publications are published, most journals deposit the manuscript at PubMed Central themselves. For these, the initial PMC ID is "PMCID TBD by Journal".

Some journals don't do that, so we deposit ourselves, and get a different type of number:
NIHMS ID

Both, the "TBD by Journal" and the NIHMS ID will have to get updated manually, once the PMCID has been generated. Additionally, the editor will have to see easily (a view) which PMCIDs are not yet final.

For this, there needs to be the possibility to edit the PMCID. I can do this by adding a field to the biblio content type. However, since a table for the PMIDs and the PMCIDs is already there, this seems to be overly redundant.
It is very important for us to be able to have up-2-date PMCIDs, because NIH requires these in the grant reports.

stackpr’s picture

Title: Populate pubmed and pmc id » Automatically populate pubmed_id and pmcid using DOI via cron
Assigned: Unassigned » stackpr

I suggest starting a new issue - I've adjusted this issue title to disambiguate.

I might expose it on the form, but you need a views handler on top of the form field. Also, the data structure is currently inadequate for your use case (the PMID and PMCID are both stored as integers, and there is no NIHMS ID).

stackpr’s picture

Assigned: stackpr » Unassigned
Status: Active » Needs review
StatusFileSize
new13.64 KB

I've attached an updated patch that moves this logic into the cron job:

  1. New settings have defaults so that existing installations are unaffected by the change.
  2. Removed the cron checkbox since it was perfectly redundant with the "reject" setting.
  3. Added extra new setting to also allow a site to update these on save, including a warning about sluggishness on bulk imports.
  4. Cron hook is restructured based on new settings. NOTE: The cron was actually not working before - it would check PM, but the includes/biblio.import.export file was not included such that the biblio_node_save function was unavailable
  5. Cron groups the searches/changes into one list of required checks before applying the throttle limit, so the throttle still indicates the "number of items to check per cron run".

My cron tests show both that updates still work and that checks for new IDs also work.

ursula’s picture

Thanks for the suggestions, I started another issue.

stevecory’s picture

Is it possible to display the PMCID in the Citation in Drupal 7? I cannot find where to add it to the styling.

stackpr’s picture

That is a complicated question because of the numerous use cases. The PMCID variable is available to the citeproc stylesheets. You can edit the stylesheet by going to Site Configuration > Biblio settings > CiteProc > CiteProc Style Manager.

Alternately, depending on where you are trying to make it appear, you can go to admin/settings/biblio/basic and enable it in the Lookup Links section. In either case, this particular question should probably move to another (documentation) issue if this does not solve it for you.

stevecory’s picture

Issue summary: View changes
StatusFileSize
new72.89 KB

The PMCID should appear at the end of the Biblio: Biblio Citation field. Similar to how the PubMed link appears at the end of the Citation
http://impact.unc.edu/view/biblio/journals
with the exception that it displays the actual number (e.g. PMC3685206 that would link to
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3685206/ )

The *.csl files won't be editied for my lack of knowledge of the system variable names and required syntax (XML?).

Only DOI, PubMed and Google Scholar appear under "Lookup Links" in the "Links" section of the
Administation > Configuration > Content authoring > Biblio settings > Preferences.
The PMCID does not appear under the Lookup Links.

The PubMed ID and PMC ID fields are not accessible via the Biblio Content Type or the
Administation > Configuration > Content authoring > Biblio settings > Fields.

liam morland’s picture

Status: Needs review » Closed (outdated)

This version is no longer maintained. If this issue is still relevant to the Drupal 7 version, please re-open and provide details.