Zotero ? HubMed Tags

·

First install →this tiny Firefox extension← (a Zotero utility). Then, whenever you store an item in Zotero, it will lookup the PMID from the DOI (if there is one) and bookmark the item in HubMed Tag Storage. You'll need an account there, and it probably won't fail gracefully if you don't. Try it on an example HubMed page, if you like.

I don't recommend keeping it installed for long, but it's a useful demonstration. Basically it's just this so far:


var HubMedZotero = {
  lookupPMIDFromDOI: function(doi){
    var url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=PubMed&retmode=xml&term=" + encodeURIComponent(doi);
    Zotero.Utilities.HTTP.doGet(url, function(r) {
      text = r.responseText;
      var xml = new XML(text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""));
      if (xml.IdList) HubMedZotero.postToHubMed(xml.IdList.Id[0].text().toString());
    });
  },
  postToHubMed: function(pmid){
    Zotero.Utilities.HTTP.doPost(
      'http://www.hubmed.org/tags/item/' + pmid
    );
  }
}
var HubMedZotero_NotifierCallback = {
  notify: function(event, type, ids) {
    if (!ids.length) return;
    var items = Zotero.Items.get(ids);
    for each (var item in items) {        
      var doi = item.getField('DOI');
      if (!doi) return;
      switch (event) {
        case 'add':
          HubMedZotero.lookupPMIDFromDOI(doi);        
        break;
      }
    }
  }
};
var notifierID = Zotero.Notifier.registerObserver(HubMedZotero_NotifierCallback, ['item']);
window.addEventListener('unload', function(e) { Zotero.Notifier.unregisterObserver(notifierID) }, false);