Skip to content

Commit

Permalink
Adds parser for American Journal of Medicine [amjmed]
Browse files Browse the repository at this point in the history
  • Loading branch information
AGCooper committed Jun 14, 2019
1 parent 9c536ff commit bba6608
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
20 changes: 20 additions & 0 deletions amjmed/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2018-05-18",
"status": "beta",
"domains": [
"www.amjmed.com"
],
"recognize": {
"rid": [
"title_id",
"unitid",
"pii"
]
},
"name": "amjmed",
"longname": "American Journal of Medicine",
"describe": "Recognizes the accesses to the platform American Journal of Medicine",
"docurl": "http://ang.couperin.org/platforms/5aff19ae901b3295ca5e5dfe",
"contact": "alexander.cooper@emory.edu",
"pkb": false
}
60 changes: 60 additions & 0 deletions amjmed/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env node

'use strict';
const Parser = require('../.lib/parser.js');

/**
* Recognizes the accesses to the platform American Journal of Medicine
* @param {Object} parsedUrl an object representing the URL to analyze
* main attributes: pathname, query, hostname
* @param {Object} ec an object representing the EC whose URL is being analyzed
* @return {Object} the result
*/
module.exports = new Parser(function analyseEC(parsedUrl, ec) {
let result = {};
let path = parsedUrl.pathname;
// uncomment this line if you need parameters
// let param = parsedUrl.query || {};

// use console.error for debuging
// console.error(parsedUrl);

let match;

if ((match = /^\/article\/(.*)\/fulltext$/i.exec(path)) !== null) {
// https://www.amjmed.com:443/article/S0002-9343(17)30403-5/fulltext
result.rtype = 'ARTICLE';
result.mime = 'HTML';
result.title_id = match[1];
result.unitid = match[1];
result.pii = match[1].replace(/[-()]/g, '');
} else if ((match = /^\/article\/(.*)\/pdf$/i.exec(path)) !== null) {
// https://www.amjmed.com:443/article/S0002-9343(18)30008-1/pdf
result.rtype = 'ARTICLE';
result.mime = 'PDF';
result.title_id = match[1];
result.unitid = match[1];
result.pii = match[1].replace(/[-()]/g, '');
} else if ((match = /^\/article\/(.*)\/ppt$/i.exec(path)) !== null) {
// https://www.amjmed.com:443/article/S0002-9343(18)30409-1/ppt
result.rtype = 'SUPPL';
result.mime = 'MISC';
result.title_id = match[1];
result.unitid = match[1];
result.pii = match[1].replace(/[-()]/g, '');
} else if (/content|current|issue|issues|mmaeducation|supplements/i.test(path)) {
// https://www.amjmed.com:443/issues
result.rtype = 'TOC';
result.mime = 'HTML';
if ((match = /^\/issue\/(.*)$/i.exec(path)) !== null) {
result.title_id = match[1];
result.unitid = match[1];
}
} else if (/^\/action\/doSearch/i.test(path)) {
// https://www.amjmed.com:443/action/doSearchSecure?searchType=quick&searchText=ethanol&occurrences=all&journalCode=ajm&searchScope=fullSite&code=ajm-site
result.rtype = 'SEARCH';
result.mime = 'HTML';
}

return result;
});
5 changes: 5 additions & 0 deletions amjmed/test/amjmed.2018-05-18.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
out-title_id;out-unitid;out-pii;out-rtype;out-mime;in-url
S0002-9343(17)30403-5;S0002-9343(17)30403-5;S0002934317304035;ARTICLE;HTML;https://www.amjmed.com:443/article/S0002-9343(17)30403-5/fulltext
S0002-9343(18)30008-1;S0002-9343(18)30008-1;S0002934318300081;ARTICLE;PDF;https://www.amjmed.com:443/article/S0002-9343(18)30008-1/pdf
;;;TOC;HTML;https://www.amjmed.com:443/issues
;;;SEARCH;HTML;https://www.amjmed.com:443/action/doSearchSecure?searchType=quick&searchText=ethanol&occurrences=all&journalCode=ajm&searchScope=fullSite&code=ajm-site

0 comments on commit bba6608

Please sign in to comment.