42
42
* ==========================================================================
45
* RCS Modification History:
47
* Revision 6.24 2009/06/19 19:27:29 bazhin
48
* Added support for multiple consortium names.
50
* Revision 6.23 2007/12/04 23:29:22 bazhin
51
* MergePubIds() renamed to MergeNonPubmedPubIds(). Merging is
52
* limited to types DOI and OTHER only.
54
* Revision 6.22 2007/12/04 20:07:02 bazhin
55
* Added ability to merge input article ids with ones from med server.
57
* Revision 6.21 2005/02/15 17:45:32 bazhin
58
* Modified MedlineToISO() function: now in addition to Cit-art.Auth-list.ml
59
* slot it also looks at Cit-art.Auth-list.Author.Person-id.ml one
60
* to convert authors names from Medline format to Name-std (last, first,
63
* Revision 6.20 2005/01/28 20:43:00 bazhin
64
* Fixed bug related to preserving input Cit-arts in cases of
65
* lookup without replacement.
67
* Revision 6.19 2004/11/29 17:50:06 bazhin
68
* Removed memory leak in FixPubEquiv() function.
70
* Revision 6.18 2004/11/12 17:35:51 bazhin
71
* Fixed bug related to the converting empty authors list from
72
* medline format to standard one.
74
* Revision 6.17 2004/11/04 17:53:17 bazhin
75
* Reverted FixPubEquiv modification, when not lookup for pmid was
76
* performed, if input Pub-equiv has a Cit-gen with authors, or title,
77
* or journal blocks filled in. Now it does lookup for pmid even if
80
* Revision 6.16 2004/11/02 21:28:35 bazhin
81
* Modifications related to the new MedArch server to be installed.
82
* Does not use Medline ids for lookup, and does not look them up.
84
* Revision 6.15 2004/08/18 17:00:56 bazhin
85
* Fixed bug with medline lookup if both PubMed and Medline ids are present.
87
* Revision 6.14 2004/03/19 18:32:03 bazhin
88
* One more patch related to the previous one.
90
* Revision 6.13 2004/03/19 14:53:18 bazhin
91
* Added function PropogateInPress(), which is called from FixPubEquiv().
92
* It sets Imprint.prepub value to "in-press" if input Cit-art was flagged
93
* as "in-press", but had Medline or/and Pubmed id(s) and successful lookup
94
* returned Cit-art with no article references, such as volume and page
97
* Revision 6.12 2004/03/17 16:59:35 bazhin
98
* Slight modification in ten_authors() function. If the number of input
99
* authors greater than 10 and number of MedArch ones less or equal 11,
100
* or input has more than 25 and MedArch has less or equal 26, then
101
* it will take input set instead of MedArch one.
103
* Revision 6.11 2004/03/16 18:53:37 bazhin
104
* Now does not ignore in-press'ed Cit-arts for lookup.
106
* Revision 6.10 2003/10/01 13:08:33 bazhin
107
* Modified ten_authors() function to handle consortiums properly.
109
* Revision 6.9 2003/09/10 18:47:28 bazhin
110
* "print_pub()" function now is aware of consortiums.
112
* Revision 6.8 2003/03/25 19:14:59 bazhin
113
* Function "ten_authors()" became public (from static).
115
* Revision 6.7 2003/03/12 20:35:02 bazhin
116
* "ten_authors()" function now can handle consortiums.
118
* Revision 6.6 2001/03/08 12:47:44 ostell
119
* made FixPub work if no medline uid returned, but pmid is returned.
121
* Revision 6.5 2000/08/18 17:01:02 kans
122
* added FetchPubPmId, enhanced FixPubEquiv to handle records with pmid but no muid
124
* Revision 6.4 1999/11/17 18:16:15 bazhin
125
* If failed to get pub from MedArch server, then does not return NULL,
127
* Also removed unused variables.
129
* Revision 6.3 1999/11/08 19:32:44 kans
130
* removed unnecessary for loop initialization picked up by IRIX C comnpiler
132
* Revision 6.2 1999/05/06 18:53:53 kans
133
* FixPubEquiv now works on PMID as well as MUID
135
* Revision 6.1 1998/09/14 20:54:51 bazhin
136
* Changes in "ten_authors()" : if successful medline lookup has returned
137
* no authors, then will use input ones.
139
* Revision 6.0 1997/08/25 18:35:48 madden
140
* Revision changed to 6.0
142
* Revision 5.0 1996/05/28 14:11:11 ostell
143
* Set to revision 5.0
145
* Revision 4.4 1996/05/22 17:30:09 kans
146
* changed name of error file, initialize muid in lookup procedure
148
* Revision 4.3 1996/03/12 22:21:07 tatiana
149
* add bullet proof to MedlineToISO function
151
* Revision 4.2 1995/11/02 23:39:28 tatiana
152
* do not accept Medline article with 0 authors
154
* Revision 4.1 1995/08/16 14:28:21 tatiana
155
* modified get_std_auth to handle spaces between initials
157
* Revision 4.0 1995/07/26 13:55:12 ostell
158
* force revision to 4.0
160
* Revision 1.32 1995/06/06 14:34:39 tatiana
161
* bug fixed in print_pub()
163
* Revision 1.30 1995/05/25 22:17:14 kans
166
* Revision 1.29 1995/05/25 18:14:35 kans
167
* additional long and int casts in ErrPostEx
169
* Revision 1.28 1995/05/24 16:13:47 tatiana
170
* add in_press() to avoid lookup for in press articles
172
* Revision 1.24 1995/05/17 17:54:05 epstein
173
* add RCS log revision history
177
46
/** for ErrPostEx() ****/
189
58
#include <medutil.h> /* the interface */
190
59
#include <medarch.h> /* the medarch interface */
191
60
#include <mdrcherr.h> /* the errors interface */
63
static void MUGetStringCallback (XmlObjPtr xop, XmlObjPtr parent, Int2 level, Pointer userdata)
68
if (xop == NULL || userdata == NULL) return;
69
strp = (CharPtr PNTR) userdata;
71
if (StringHasNoText (xop->contents)) return;
73
*strp = StringSave (xop->contents);
76
static void MUGetStringSetCallback (XmlObjPtr xop, XmlObjPtr parent, Int2 level, Pointer userdata)
81
if (xop == NULL || userdata == NULL) return;
82
vnbp = (ValNodeBlockPtr) userdata;
84
if (StringHasNoText (xop->contents)) return;
86
ValNodeCopyStrEx (&(vnbp->head), &(vnbp->tail), 0, xop->contents);
89
static Boolean MULooksLikeISSN (CharPtr str)
95
if (StringHasNoText (str)) return FALSE;
97
if (StringLen (str) != 9) return FALSE;
98
if (str [4] != '-') return FALSE;
100
for (i = 0; i < 9; i++) {
102
if (IS_DIGIT (ch)) continue;
103
if (ch == '-' && i == 4) continue;
104
if (ch == 'X' && i == 8) continue;
111
static Boolean MUIsJournalIndexed (CharPtr journal)
116
CharPtr count = NULL;
119
Boolean rsult = FALSE;
120
CharPtr status = NULL;
125
if (StringHasNoText (journal)) return FALSE;
126
StringNCpy_0 (title, journal, sizeof (title));
131
if (ch == '(' || ch == ')') {
137
TrimSpacesAroundString (title);
138
CompressSpaces (title);
140
if (MULooksLikeISSN (title)) {
141
str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
142
"/entrez/eutils/esearch.fcgi",
143
"db=nlmcatalog&retmax=200&term=",
144
title, "%5Bissn%5D", NULL);
148
str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
149
"/entrez/eutils/esearch.fcgi",
150
"db=nlmcatalog&retmax=200&term=",
151
title, "%5Bmulti%5D+AND+ncbijournals%5Bsb%5D", NULL);
154
if (str == NULL) return FALSE;
156
xop = ParseXmlString (str);
158
if (xop == NULL) return FALSE;
162
VisitXmlNodes (xop, (Pointer) &blk, MUGetStringSetCallback, "Id", NULL, NULL, NULL, 0);
163
VisitXmlNodes (xop, (Pointer) &count, MUGetStringCallback, "Count", "eSearchResult", NULL, NULL, 0);
167
if (StringCmp (count, "0") == 0 || blk.head == NULL) {
170
str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
171
"/entrez/eutils/esearch.fcgi",
172
"db=nlmcatalog&retmax=200&term=",
173
title, "%5Bmulti%5D+AND+ncbijournals%5Bsb%5D", NULL);
174
if (str == NULL) return FALSE;
176
xop = ParseXmlString (str);
178
if (xop == NULL) return FALSE;
182
VisitXmlNodes (xop, (Pointer) &blk, MUGetStringSetCallback, "Id", NULL, NULL, NULL, 0);
183
VisitXmlNodes (xop, (Pointer) &count, MUGetStringCallback, "Count", "eSearchResult", NULL, NULL, 0);
190
if (blk.head == NULL) return FALSE;
192
/* if more than one candidate, bail */
194
if (blk.head->next != NULL) {
195
ValNodeFreeData (blk.head);
199
jids = ValNodeMergeStrsEx (blk.head, ",");
200
ValNodeFreeData (blk.head);
202
if (jids == NULL) return FALSE;
204
str = QUERY_UrlSynchronousQuery ("eutils.ncbi.nlm.nih.gov", 80,
205
"/entrez/eutils/esummary.fcgi",
206
"db=nlmcatalog&retmax=200&version=2.0&id=",
209
if (str == NULL) return FALSE;
211
xop = ParseXmlString (str);
213
if (xop == NULL) return FALSE;
215
VisitXmlNodes (xop, (Pointer) &status, MUGetStringCallback, "CurrentIndexingStatus", NULL, NULL, NULL, 0);
219
if (StringCmp (status, "Y") == 0) {
193
228
/**********************************************************/
194
229
void print_pub(ValNodePtr pub, Boolean found, Boolean auth, Int4 muid)
319
354
"%ld|%s %s|%s|(%d)|%s|%s", (long) muid, last, first,
320
355
s_title, (int) year, vol, page);
357
else if (MUIsJournalIndexed (s_title))
324
ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,
325
"%s %s|%s|(%d)|%s|%s", last, first, s_title,
326
(int) year, vol, page);
360
ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,
361
"%s %s|%s|(%d)|%s|%s", last, first, s_title,
362
(int) year, vol, page);
364
ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,
365
">>%ld<<|%s %s|%s|(%d)|%s|%s", (long) muid, last,
366
first, s_title, (int) year, vol, page);
330
ErrPostEx(SEV_WARNING, ERR_REFERENCE_PmidNotFound,
331
">>%ld<<|%s %s|%s|(%d)|%s|%s", (long) muid, last,
332
first, s_title, (int) year, vol, page);
372
ErrPostEx(SEV_WARNING, ERR_REFERENCE_NoPmidJournalNotInPubMed,
373
"%s %s|%s|(%d)|%s|%s", last, first, s_title,
374
(int) year, vol, page);
376
ErrPostEx(SEV_INFO, ERR_REFERENCE_NoPmidJournalNotInPubMed,
377
">>%ld<<|%s %s|%s|(%d)|%s|%s", (long) muid, last,
378
first, s_title, (int) year, vol, page);