/***
Copyright 2009 - MindTouch
USAGE:
PubMedDocumentSummary(doc : xml, format : str)
Renders a PubMed entry as a reference summary.
PARAMETERS:
doc : xml
PubMed entry to render.
format : str
(optional, one of "reference", "brief", "user"; default: "reference") display format for result
***/
// read parameters
var doc = $0 ?? $doc;
var format = $1 ?? $format;
// initialize local variables
var isbn;
var isbnref;
var pmid = xml.text(doc["Id"]);
// compute list of authors
var authors = [ xml.text(item) foreach var item in doc["Item[@Name='AuthorList']/Item[@Name='Author']"] ];
switch(#authors) {
case 0: let authors = '';
case 1: let authors = authors[0];
case 2: let authors = authors[0] .. ' and ' .. authors[1];
default: let authors = string.join(list.splice(authors, #authors - 1), ', ') .. ', and ' .. authors[-1];
}
// compute title
var title = xml.text(doc["Item[@Name='Title']"]);
if(#title && !string.endswith(title, '.')) let title ..= '.';
// compute origin with publication date
var origin = xml.text(doc["Item[@Name='Source']"]);
if(#origin && !string.endswith(origin, '.')) let origin ..= '.';
let origin ..= ' ' .. xml.text(doc["Item[@Name='PubDate']"]);
// compute volume/issue reference
var volume = xml.text(doc["Item[@Name='Volume']"]);
if(#volume) {
let origin ..= '; ' .. volume;
var issue = xml.text(doc["Item[@Name='Issue']"]);
if(#issue) let origin ..= '(' .. issue .. ')';
}
// compute pages
var pages = xml.text(doc["Item[@Name='Pages']"]);
if(#pages) let origin ..= ':' .. pages;
// TODO (steveb): what is DOI?
var doi = xml.text(doc["Item[@Name='DOI']"]);
// compute codes
var codes = '';
if(#doi) let codes ..= ' doi:' .. doi;
if(#pmid) let codes ..= ' pmid:' .. pmid;
if(#isbn) let codes ..= ' isbn:' .. isbn;
if(#codes && !string.endswith(codes, '.')) let codes ..= '.';
// determine citation style
var aTitle;
var aHref;
if(#doi) {
let aTitle = "View or buy article from publisher";
let aHref = "http://dx.doi.org/" & doi;
} else if(#pmid) {
let aTitle = "View or buy article from publisher (if available)";
let aHref = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?cmd=prlinks&dbfrom=pubmed&retmode=ref" & { id: pmid };
} else {
let aTitle = "Book information at isbndb.org";
let aHref = "http://isbndb.com/d/book/" & ("$" .. isbnref .. ".html");
}
switch(format) {
case "brief":
<span class="pubmed-ref">
<span class="pmid"> pmid </span>
<span class="title" id=(pmid)> title </span>
<span class="authors"> authors </span>
<span class="origin"> origin </span>
</span>
case "user":
// format for user profiles
<span class="pubmed-ref">
authors .. title .. origin
</span>
case "debug":
web.pre(xml.format(doc));
case "reference":
default:
<a title=(aTitle) href=(aHref) class="pubmed-ref" >
<span class="authors">authors</span>
' ';
<span class="title"> title </span>
' '; origin;
</a>
if(#pmid) {
' ';
<a title=("PMID " .. pmid) class="external" href=("http://www.ncbi.nlm.nih.gov/pubmed/" & pmid & { dopt: "Abstract" })> "PubMed" </a>;
' ';
<a title=("PMID " .. pmid) class="external" href=("http://www.hubmed.org/display.cgi" & { uids: pmid })> "HubMed" </a>;
}
codes;
}
No references found.