Skip to content

Commit d6652de

Browse files
committed
Pages and Years in PubMed.
1 parent 8780465 commit d6652de

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

dbs/pubmed.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,29 @@ function pubMedParse(xml) {
8484
}
8585
var abstr1 = path(article, ['Abstract', 0, 'AbstractText', 0, '_']);
8686
var abstr2 = path(article, ['Abstract', 0, 'AbstractText', 0]);
87+
var pagesStr = path(article, ['Pagination', 0, 'MedlinePgn', 0]);
88+
var spage, epage,
89+
pages = /([0-9]{1,}) *- *([0-9]{1,})/.exec(pagesStr);
90+
if (pages) {
91+
spage = pages[1];
92+
epage = pages[2];
93+
} else {
94+
spage = pagesStr;
95+
}
96+
var issueYear = path(article, ['Journal', 0, 'JournalIssue', 0, 'PubDate', 0, 'Year', 0]);
97+
var articleYear = path(article, ['ArticleDate', 0, 'Year', 0]);
8798
return {
8899
source: 'PubMed',
89100
authors: authors,
90101
doi: doipath,
91102
href: typeof doipath !== 'undefined' ? "http://dx.doi.org/" + doipath : undefined,
92103
title: path(article, ['ArticleTitle', 0]),
93-
year: path(article, ['ArticleDate', 0, 'Year', 0]),
104+
year: articleYear || issueYear,
94105
publishedIn: path(article, ['Journal', 0, 'Title', 0]),
95106
volume: path(article, ['Journal', 0, 'JournalIssue', 0, 'Volume', 0]),
96107
issue: path(article, ['Journal', 0, 'JournalIssue', 0, 'Issue', 0]),
97-
spage: undefined,
98-
epage: undefined,
108+
spage: spage || undefined,
109+
epage: epage,
99110
firstauthor: authors[0] || [],
100111
editors: undefined,
101112
fullCitation: undefined,

0 commit comments

Comments
 (0)