Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/client/components/editor/info-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ export class InfoPanel extends Component {
const citation = document.citation();
// authorProfiles may not be existing for the older documents
const authorProfiles = document.authorProfiles() || citation.authors.authorList;
const { pmid, title = 'Untitled article', reference, doi, abstract } = citation;
const { pmid, title = 'Untitled article', reference, doi, abstract, relations } = citation;

const retractedPubType = _.find( citation.pubTypes, ['UI', 'D016441'] );
const retractFlag = retractedPubType ? h('span.editor-info-flag.super-salient-button.danger', retractedPubType.value) : null;

const hasArticleId = pmid != null || doi != null;
const hasRelatedPapers = !_.isEmpty( document.relatedPapers() );

const hasRelations = !_.isEmpty( relations );

return h('div.editor-info-panel', [
h('div.editor-info-flags', [ retractFlag ]),

Expand Down Expand Up @@ -103,6 +105,13 @@ export class InfoPanel extends Component {
pmid ? h('a.editor-info-link.plain-link', { target: '_blank', href: `${PUBMED_LINK_BASE_URL}${pmid}` }, 'PubMed') : null,
h('a.editor-info-link.plain-link', { target: '_blank', href: `${GOOGLE_SCHOLAR_BASE_URL}${( "\u0022" + title + "\u0022") }`}, 'Google Scholar')
]),
hasRelations ?
h('div.editor-info-relations', relations.map( ({ type, links }, i) => [
h('div.editor-info-relation', { key: i.toString() }, [
h('span.editor-info-relation-type', `${type} `),
h('span.editor-info-links', links.map( ({ url, reference }, j ) => h('a.editor-info-link.plain-link', { key: j.toString(), target: '_blank', href: url }, reference ) ) )
])
])): null,
h('div.editor-info-main-sections', [
abstract ? h('div.editor-info-abstract-section.editor-info-main-section', [
h('div.editor-info-section-title', abstract ? 'Abstract': 'Summary'),
Expand Down
12 changes: 12 additions & 0 deletions src/styles/editor/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@
line-height: 1.4;
}

.editor-info-relations {
margin-bottom: 0.8em;
}

.editor-info-relation {
margin: 0.25em 0;
}

.editor-info-relation-type {
font-style: italic;
}

.editor-info-author-spacer {
margin-right: 0.333em;
}
Expand Down
70 changes: 46 additions & 24 deletions src/util/pubmed.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
import _ from 'lodash';
import { parse as dateParse } from 'date-fns';
import { DOI_LINK_BASE_URL, PUBMED_LINK_BASE_URL } from '../config';
import { fromCamelCase, onlyCapitalizeFirst } from './strings';

const NUM_AUTHORS_SHOWING = 4;

const COMMENTSCORRECTIONS_REFTYPE = Object.freeze({
AssociatedDataset: 'AssociatedDataset',
AssociatedPublication: 'AssociatedPublication',
CommentOn: 'CommentOn',
CommentIn: 'CommentIn',
ErratumIn: 'ErratumIn',
ErratumFor: 'ErratumFor',
ExpressionOfConcernIn: 'ExpressionOfConcernIn',
ExpressionOfConcernFor: 'ExpressionOfConcernFor',
RepublishedFrom: 'RepublishedFrom',
RepublishedIn: 'RepublishedIn',
RetractionOf: 'RetractionOf',
RetractionIn: 'RetractionIn',
UpdateIn: 'UpdateIn',
UpdateOf: 'UpdateOf',
SummaryForPatientsIn: 'SummaryForPatientsIn',
OriginalReportIn: 'OriginalReportIn',
ReprintOf: 'ReprintOf',
ReprintIn: 'ReprintIn',
Cites: 'Cites'
});

/**
* getAuthorName
*
Expand Down Expand Up @@ -209,6 +233,27 @@ const getReferenceString = Journal => {

const getArticleId = ( PubmedArticle, IdType ) => _.get( _.find( _.get( PubmedArticle, ['PubmedData', 'ArticleIdList'], [] ), [ 'IdType', IdType ] ), 'id', null );

const getRelations = PubmedArticle => {
const formatRefSource = refSource => _.trimEnd( refSource, ':;' );// ? _.first( refSource.split(';') ) : 'link';
const commentsCorrections2Link = ({ RefSource, PMID, DOI }) => {
const hasPMID = !_.isNil( PMID );
const hasDOI = !_.isNil( DOI );
if( !hasPMID && !hasDOI ) return null;
const reference = formatRefSource( RefSource );
const url = hasPMID ? `${PUBMED_LINK_BASE_URL}${PMID}` : `${DOI_LINK_BASE_URL}${DOI}`;
return ({ reference, url });
};
const raw = _.get( PubmedArticle, [ 'MedlineCitation', 'CommentsCorrectionsList' ], [] );
const groups = _.groupBy( raw, 'RefType' );
const relations = _.toPairs( groups ).map( ( [ RefType, CommentsCorrectionsList ] ) => {
const type = onlyCapitalizeFirst( fromCamelCase( RefType ) );
const links = CommentsCorrectionsList.map( commentsCorrections2Link );
return ({ type, links });
});

return _.compact( relations );
};

/**
* getPubmedCitation
*
Expand Down Expand Up @@ -238,7 +283,7 @@ const getPubmedCitation = PubmedArticle => {
const doi = getArticleId( PubmedArticle, 'doi' );
const pubTypes = _.get( Article, 'PublicationTypeList' ); //required
const { ISODate } = getPubDate( _.get( Article, ['Journal', 'JournalIssue'] ) );
const relations = _.get( PubmedArticle, [ 'MedlineCitation', 'CommentsCorrectionsList'], [] );
const relations = getRelations( PubmedArticle );

return { title, authors, reference, abstract, pmid, doi, pubTypes, ISODate, relations };
};
Expand Down Expand Up @@ -305,27 +350,4 @@ class ArticleIDError extends Error {
}
}

const COMMENTSCORRECTIONS_REFTYPE = Object.freeze({
AssociatedDataset: 'AssociatedDataset',
AssociatedPublication: 'AssociatedPublication',
CommentOn: 'CommentOn',
CommentIn: 'CommentIn',
ErratumIn: 'ErratumIn',
ErratumFor: 'ErratumFor',
ExpressionOfConcernIn: 'ExpressionOfConcernIn',
ExpressionOfConcernFor: 'ExpressionOfConcernFor',
RepublishedFrom: 'RepublishedFrom',
RepublishedIn: 'RepublishedIn',
RetractionOf: 'RetractionOf',
RetractionIn: 'RetractionIn',
UpdateIn: 'UpdateIn',
UpdateOf: 'UpdateOf',
SummaryForPatientsIn: 'SummaryForPatientsIn',
OriginalReportIn: 'OriginalReportIn',
ReprintOf: 'ReprintOf',
ReprintIn: 'ReprintIn',
Cites: 'Cites'
});


export { getPubmedCitation, createPubmedArticle, ArticleIDError, findOrcidIdentifier, COMMENTSCORRECTIONS_REFTYPE };
10 changes: 9 additions & 1 deletion src/util/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ const stripFinalPeriod = text => {
return text;
};

export { stringDistanceMetric, longestCommonPrefixLength, truncateString, stripFinalPeriod };
const fromCamelCase = str => {
return str.replace(/([a-z])([A-Z])/g, '$1 $2');
};

const onlyCapitalizeFirst = str => {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
};

export { stringDistanceMetric, longestCommonPrefixLength, truncateString, stripFinalPeriod, fromCamelCase, onlyCapitalizeFirst };