~ubuntu-branches/ubuntu/oneiric/ncbi-tools6/oneiric

« back to all changes in this revision

Viewing changes to desktop/pubdesc.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-07-14 19:43:15 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080714194315-ed44u9ek7txva2rz
Tags: 6.1.20080302-3
tools/readdb.c: enable madvise()-based code on all glibc (hence all
Debian) systems, not just Linux.  (Closes: #490437.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   7/28/95
31
31
*
32
 
* $Revision: 6.49 $
 
32
* $Revision: 6.66 $
33
33
*
34
34
* File Description:
35
35
*
38
38
* Date     Name        Description of modification
39
39
* -------  ----------  -----------------------------------------------------
40
40
*
41
 
* $Log: pubdesc.c,v $
42
 
* Revision 6.49  2005/10/18 19:09:40  kans
43
 
* shorten locale dialog box
44
 
*
45
 
* Revision 6.48  2005/08/18 14:41:30  kans
46
 
* include toasn3.h for ExtendGeneFeatIfOnMRNA prototype
47
 
*
48
 
* Revision 6.47  2005/07/11 16:35:48  bollin
49
 
* when creating temporary empty sets as containers for descriptors, set
50
 
* the _class member to BioseqseqSet_class_empty_set to prevent the BioseqSet
51
 
* from being removed by the DeleteMarkedSeqEntry function in api/gather.c
52
 
*
53
 
* Revision 6.46  2005/07/05 14:23:15  bollin
54
 
* "Lookup Relaxed" button should only be available for internal Sequin,
55
 
* per Linda Yankie's request.
56
 
*
57
 
* Revision 6.45  2005/06/03 13:24:36  bollin
58
 
* unregister dialogs for ObjMgr messages when the form is being removed
59
 
*
60
 
* Revision 6.44  2005/05/23 15:58:33  bollin
61
 
* improved appearance of publications listed in PublicationListDialog -
62
 
* don't include the word "citation" at the front of the string, use semicolons
63
 
* instead of carriage returns.
64
 
*
65
 
* Revision 6.43  2005/05/23 15:47:56  bollin
66
 
* added external method for invoking the editor for a publication listed by the
67
 
* PublicationListDialog
68
 
*
69
 
* Revision 6.42  2005/05/20 19:12:11  bollin
70
 
* user can now edit publications from the publication list dialog
71
 
*
72
 
* Revision 6.41  2005/05/20 14:34:30  bollin
73
 
* fixed bug in SeqDescrListCopy
74
 
*
75
 
* Revision 6.40  2005/05/19 20:24:37  bollin
76
 
* created a new dialog for editing a list of publications.  Will be used by
77
 
* the new Submission Template File Editor dialog.  Still needs some work.
78
 
*
79
 
* Revision 6.39  2005/04/20 19:46:02  kans
80
 
* fixed ReplaceAllCallback
81
 
*
82
 
* Revision 6.38  2005/03/03 21:44:05  kans
83
 
* PubEquivLookupProc takes extra BoolPtr parameter to signal success or failure
84
 
*
85
 
* Revision 6.37  2004/08/13 16:07:54  kans
86
 
* warn if changing pub_reftype to sites or lost
87
 
*
88
 
* Revision 6.36  2004/08/13 15:32:37  kans
89
 
* restored reftype gui controls on initial publication window
90
 
*
91
 
* Revision 6.35  2004/08/11 18:50:14  kans
92
 
* PubdescPtrToPubdescPage looks at imp history, changes pubstatus from electronic to print if hard copy has been published
93
 
*
94
 
* Revision 6.34  2004/08/09 16:15:13  kans
95
 
* more informative popup item values for pubstatus
96
 
*
97
 
* Revision 6.33  2004/07/20 16:04:05  kans
98
 
* added pubstatus control
99
 
*
100
 
* Revision 6.32  2004/04/29 13:17:22  bollin
101
 
* removed scope control (unused) from pub descriptor and pub feature dialogs.
102
 
*
103
 
* Revision 6.31  2004/04/26 18:48:39  bollin
104
 
* prevent user from changing from submission to non-submission pub descriptor
105
 
*
106
 
* Revision 6.30  2004/04/26 18:25:28  kans
107
 
* always allow Submission to be added, even by non-indexers
108
 
*
109
 
* Revision 6.29  2003/02/24 14:14:10  kans
110
 
* removed unnecessary prototypes
111
 
*
112
 
* Revision 6.28  2002/11/03 21:10:12  kans
113
 
* do not put standard remark popup in online pub dialog
114
 
*
115
 
* Revision 6.27  2002/11/03 20:53:11  kans
116
 
* added support for online publication
117
 
*
118
 
* Revision 6.26  2002/10/30 18:21:33  kans
119
 
* strAuthor does not take author_popups, and calls to CreateAuthorDialog now use spacing of 2 instead of -1 to make suffix popup look better
120
 
*
121
 
* Revision 6.25  2002/08/01 19:47:10  kans
122
 
* AddConsortiumToAuthList in CitSub
123
 
*
124
 
* Revision 6.24  2002/07/23 21:31:19  kans
125
 
* support for consortium
126
 
*
127
 
* Revision 6.23  2001/11/12 19:54:53  kans
128
 
* do not allocate year, protect against buffer overflow by -1 value
129
 
*
130
 
* Revision 6.22  2001/11/08 14:26:38  kans
131
 
* some protection in relaxed lookup, but server is not handling maxuid parameter in EntrezCreateBooleanRequest
132
 
*
133
 
* Revision 6.21  2001/10/23 18:57:38  kans
134
 
* EntrezAddToBooleanRequest has new key parameter
135
 
*
136
 
* Revision 6.20  2001/09/28 15:55:17  kans
137
 
* for docsum, extract first author, separate year from month
138
 
*
139
 
* Revision 6.19  2001/09/10 19:20:06  kans
140
 
* fixed for new entrez2 spec
141
 
*
142
 
* Revision 6.18  2001/08/03 23:01:50  kans
143
 
* import/export primary author dialog
144
 
*
145
 
* Revision 6.17  2001/05/30 15:10:53  kans
146
 
* removed medarch and medutil includes
147
 
*
148
 
* Revision 6.16  2001/05/29 16:31:11  kans
149
 
* added LaunchRelaxedQuery, written by Hanzhen Sun
150
 
*
151
 
* Revision 6.15  1999/05/10 23:13:26  kans
152
 
* separate lookup by muid and pmid in case both are present
153
 
*
154
 
* Revision 6.14  1999/05/06 19:00:58  kans
155
 
* enable lookup by pmid button
156
 
*
157
 
* Revision 6.13  1998/12/14 22:36:21  kans
158
 
* trim spaces around muid string
159
 
*
160
 
* Revision 6.12  1998/11/30 17:31:13  kans
161
 
* kludge to save authors if lookup by article
162
 
*
163
 
* Revision 6.11  1998/10/20 15:33:59  kans
164
 
* citsub now allows affil phone, fax, e-mail to be set
165
 
*
166
 
* Revision 6.10  1998/06/12 00:24:52  kans
167
 
* fixed problems detected by unix compiler
168
 
*
169
 
* Revision 6.9  1998/06/02 17:51:02  kans
170
 
* StdVibrantEditorMsgFunc responds to OM_MSG_DEL
171
 
*
172
 
* Revision 6.8  1998/04/13 21:07:22  kans
173
 
* PubdescAcceptFormButtonProc tries to copy ASN.1, on failure aborts attempted save
174
 
*
175
 
* Revision 6.7  1997/12/01 15:05:03  kuzio
176
 
* continuing bug fixes for proceedings citation
177
 
*
178
 
* Revision 6.6  1997/11/26 20:40:11  kuzio
179
 
* typo
180
 
*
181
 
* Revision 6.5  1997/11/26 15:49:25  kuzio
182
 
* 1st fix of proceedings entry bugs
183
 
*
184
 
* Revision 6.4  1997/11/13 21:33:50  kans
185
 
* implemented proceedings, proceedings chapter (Kuzio)
186
 
*
187
 
* Revision 6.3  1997/11/11 23:24:46  kans
188
 
* Import clears ppp->flagPubDelta
189
 
*
190
 
* Revision 6.2  1997/10/21 23:02:12  kans
191
 
* standard remark text popup for indexers
192
 
*
193
 
* Revision 6.1  1997/09/15 19:05:53  kans
194
 
* editors call ObjMgrAddUserData to support ItemAlreadyHasEditor
195
 
*
196
 
* Revision 6.0  1997/08/25 18:22:59  madden
197
 
* Revision changed to 6.0
198
 
*
199
 
* Revision 5.23  1997/08/01 15:07:20  kans
200
 
* ExtendGeneFeatIfOnMRNA only called by indexer version
201
 
*
202
 
* Revision 5.22  1997/07/30 20:27:31  kans
203
 
* use of ExtendGeneFeatIfOnMRNA
204
 
*
205
 
* Revision 5.21  1997/07/22 21:51:15  kans
206
 
* citbookptr was not being objtained properly from citartptr
207
 
*
208
 
* Revision 5.20  1997/07/14 13:17:51  kans
209
 
* CreateIntervalEditorDialogEx takes callback to synchronize feature partial checkbox to 5prime and 3prime partial boxes
210
 
*
211
 
* Revision 5.19  1997/05/05 15:51:35  kans
212
 
* no replace authors on new pub
213
 
*
214
 
 * Revision 5.18  1997/05/05  02:07:26  kans
215
 
 * replace authors button in initial form
216
 
 *
217
 
 * Revision 5.17  1997/05/02  21:27:32  kans
218
 
 * replace authors implemented
219
 
 *
220
 
 * Revision 5.16  1997/05/02  19:18:33  kans
221
 
 * calls SetClosestParentIfDuplicating
222
 
 *
223
 
 * Revision 5.15  1997/04/02  22:48:56  kans
224
 
 * changed title_rank to be iso-jta, ml-jta, jta, coden, issn, name, trans
225
 
 *
226
 
 * Revision 5.14  1997/04/02  21:19:43  kans
227
 
 * title_old set to 0 at beginning, so cit-art with lower ranked titles
228
 
 * coming after cit-gen with higher ranked titles don't override
229
 
 *
230
 
 * Revision 5.13  1997/01/29  19:33:43  kans
231
 
 * changed to StringNCpy_0
232
 
 *
233
 
 * Revision 5.12  1996/12/31  21:24:06  kans
234
 
 * calls GetRidOfEmptyFeatsDescStrings
235
 
 *
236
 
 * Revision 5.11  1996/12/12  21:20:19  kans
237
 
 * unpublished citations don't force current date if none set
238
 
 *
239
 
 * Revision 5.10  1996/12/04  18:17:05  kans
240
 
 * internal indexer version start up on journal page
241
 
 *
242
 
 * Revision 5.9  1996/11/01  20:56:00  kans
243
 
 * create dummy date in pub_sub
244
 
 *
245
 
 * Revision 5.8  1996/10/25  18:31:42  kans
246
 
 * one more place to make fake imp->date
247
 
 *
248
 
 * Revision 5.7  1996/09/12  13:25:43  kans
249
 
 * added cast to memset
250
 
 *
251
 
 * Revision 5.6  1996/09/05  16:23:50  kans
252
 
 * cit-sub date initialized to current date
253
 
 *
254
 
 * Revision 5.5  1996/07/18  19:46:11  kans
255
 
 * activate slot now in forms structure in vibforms.h
256
 
 *
257
 
 * Revision 5.4  1996/07/17  21:52:31  kans
258
 
 * SaveStringFromTextAndStripNewlines for saving from most scroll text boxes
259
 
 *
260
 
 * Revision 5.3  1996/07/17  20:53:58  kans
261
 
 * multiple citgen would miss "unpublished" indication
262
 
 *
263
 
 * Revision 5.2  1996/06/21  18:38:12  kans
264
 
 * allows switching of reftype in existing pub if descriptor
265
 
 *
266
 
 * Revision 5.1  1996/06/13  18:22:32  kans
267
 
 * GetATSub needed to check for csp->imp not NULL before double dereferencing
268
 
 *
269
 
 * Revision 5.0  1996/05/28  13:39:11  ostell
270
 
 * Set to revision 5.0
271
 
 *
272
 
 * Revision 1.47  1996/05/22  21:50:59  kans
273
 
 * changed OM_MSG_RET_OK to OM_MSG_RET_DONE
274
 
 *
275
 
 * Revision 1.46  1996/05/21  20:18:23  kans
276
 
 * don't read or write reftype on import/export
277
 
 *
278
 
 * Revision 1.45  1996/05/21  20:05:34  kans
279
 
 * implement import/export of pubdesc, seqloc
280
 
 *
281
 
 * Revision 1.44  1996/05/21  18:50:57  kans
282
 
 * put title page(s) before author page, preparation for import/export
283
 
 *
284
 
 * Revision 1.43  1996/04/24  19:23:27  kans
285
 
 * internal sequin always shows serial number control
286
 
 *
287
 
 * Revision 1.42  1996/04/09  21:37:10  kans
288
 
 * fixed thesis (Kuzio)
289
 
 *
290
 
 * Revision 1.41  1996/04/09  16:33:20  kans
291
 
 * added help scrolling, and new pub has accept button instead of replace
292
 
 *
293
 
 * Revision 1.40  1996/04/08  14:40:22  kans
294
 
 * added initial support for PubMed IDs (Kuzio)
295
 
 *
296
 
 * Revision 1.39  1996/03/21  16:06:18  kans
297
 
 * SetNewFeatureDefaultInterval now used
298
 
 *
299
 
 * Revision 1.38  1996/03/12  00:39:39  kans
300
 
 * added support for CitRetract in journal imprint
301
 
 *
302
 
 * Revision 1.37  1996/02/29  17:47:28  kans
303
 
 * internal sequin allows new submission citation to be added
304
 
 *
305
 
 * Revision 1.36  1996/02/15  23:03:43  kans
306
 
 * remove contact sub-dialog
307
 
 *
308
 
 * Revision 1.35  1996/02/14  18:15:48  kans
309
 
 * publication features don't have citations on feature requirement
310
 
 *
311
 
 * Revision 1.34  1996/02/07  16:15:20  kans
312
 
 * new pub disables buttons that would allow unimplemented feat/desc switch
313
 
 *
314
 
 * Revision 1.33  1996/01/24  22:11:46  kans
315
 
 * if no imp->date, it creates a dummy one to pass the object loader
316
 
 *
317
 
 * Revision 1.32  1996/01/24  21:46:30  kans
318
 
 * convert cap to cgp truncated and corrupted title
319
 
 *
320
 
 * Revision 1.31  1996/01/02  21:35:24  kans
321
 
 * changed Process to Proceed for initial form button title
322
 
 *
323
 
 * Revision 1.30  1996/01/02  19:48:35  kans
324
 
 * uses fallback message callback
325
 
 *
326
 
 * Revision 1.29  1996/01/02  17:15:31  kans
327
 
 * replaceThis is in the app property structure, newfeat reftype set properly
328
 
 *
329
 
 * Revision 1.28  1995/12/31  02:55:36  kans
330
 
 * REPLACE_THIS needed for separate replace all and replace this buttons
331
 
 *
332
 
 * Revision 1.27  1995/12/30  19:50:01  kans
333
 
 * message handler now uses switch statement
334
 
 *
335
 
 * Revision 1.26  1995/12/30  04:05:48  kans
336
 
 * editors handle cut/copy/paste/delete etc. messages from menu items
337
 
 *
338
 
 * Revision 1.25  1995/12/30  00:51:49  kans
339
 
 * init, enter, reset, redraw dialog/form uses message function
340
 
 *
341
 
 * Revision 1.24  1995/12/26  14:57:21  kans
342
 
 * added NULL clearProc parameter to CreateStdEditorFormMenus
343
 
 *
344
 
 * Revision 1.23  1995/12/25  21:48:12  kans
345
 
 * calls CreateStdEditorFormMenus
346
 
 *
347
 
 * Revision 1.22  1995/12/24  15:58:54  kans
348
 
 * SetSerialNumber was testing cgp->serial_number instead of serial_number
349
 
 *
350
 
 * Revision 1.21  1995/12/23  21:18:11  kans
351
 
 * moved MedArch pre- and post-processing into pubdesc
352
 
 *
353
 
 * Revision 1.20  1995/12/21  20:40:39  kans
354
 
 * accept buttons now update minimal cits on feats
355
 
 *
356
 
 * Revision 1.19  1995/12/20  22:22:37  kans
357
 
 * code center cleanup (Kuzio)
358
 
 *
359
 
 * Revision 1.18  1995/12/20  21:01:53  kans
360
 
 * support for remote MedArch services
361
 
 *
362
 
 * Revision 1.17  1995/12/20  20:22:08  kans
363
 
 * implements most of replace all function (except minimal cits on feats)
364
 
 *
365
 
 * Revision 1.16  1995/12/20  16:04:10  kans
366
 
 * Update called when switching folder tabs
367
 
 *
368
 
 * Revision 1.15  1995/12/19  22:16:57  kans
369
 
 * *** empty log message ***
370
 
 *
371
 
 * Revision 1.14  1995/12/15  00:51:53  kans
372
 
 * all author pages now use subfolders for names, affil, and contact
373
 
 *
374
 
 * Revision 1.13  1995/12/12  23:34:22  kans
375
 
 * uses extra folder tab appearance parameters
376
 
 *
377
 
 * Revision 1.12  1995/12/12  22:36:32  kans
378
 
 * cannot change feat/desc type of existing pubdesc (Kuzio)
379
 
 *
380
 
 * Revision 1.11  1995/12/09  01:55:16  kans
381
 
 * changes to cit-sub and cit-pat (the other JAK)
382
 
 *
383
 
 * Revision 1.10  1995/12/08  03:22:26  kans
384
 
 * second round of cosmetic changes
385
 
 *
386
 
 * Revision 1.9  1995/12/08  01:48:08  kans
387
 
 * first round of cosmetic changes
388
 
 *
389
 
 * Revision 1.8  1995/12/07  22:51:39  kans
390
 
 * maximum folder tab per line now set for all publication types
391
 
 *
392
 
 * Revision 1.7  1995/12/07  01:00:33  kans
393
 
 * new parameters to CreateFolderTabs
394
 
 *
395
 
 * Revision 1.6  1995/12/05  22:55:05  kans
396
 
 * major internal simplification (Kuzio)
397
 
 *
398
 
 * Revision 1.5  1995/12/02  23:36:38  kans
399
 
 * functional on existing features and descriptors
400
 
 *
401
 
 * Revision 1.4  1995/12/01  23:38:35  kans
402
 
 * *** empty log message ***
403
 
 *
404
 
 * Revision 1.3  1995/11/08  23:37:52  kans
405
 
 * edit block moved out of vibrant
406
 
 *
407
 
 * Revision 1.2  1995/09/25  21:13:26  kans
408
 
 * *** empty log message ***
409
 
 *
410
 
 * Revision 1.1  1995/07/28  18:01:31  kans
411
 
 * Initial revision
412
 
 *
413
 
*
414
41
* ==========================================================================
415
42
*/
416
43
 
419
46
#include <utilpub.h>
420
47
#include <explore.h>
421
48
#include <toasn3.h>
 
49
#include <mla2api.h>
 
50
#include <dlogutil.h>
422
51
 
423
52
#define FIRST_PAGE      0
424
53
 
456
85
  GrouP         pub_status;
457
86
  GrouP         pub_choice;
458
87
  GrouP         pub_reftype;
 
88
  ButtoN        patent_btn;
459
89
  Int2          pub_ref_value;
460
90
  Int2          pub_choice_init;
461
91
  Uint1         reftype;
485
115
  TexT          title_box;
486
116
  DialoG        author_list;
487
117
  DialoG        author_affil;
488
 
  TexT          consortium;
 
118
  DialoG        consortium;
 
119
  ButtoN        cons_btn;
489
120
  AuthListPtr   originalAuthList;
490
121
 
491
122
  TexT          journal;
677
308
  return pubgennode;
678
309
}
679
310
 
680
 
static AuthListPtr AddConsortiumToAuthList (AuthListPtr alp, TexT consortium)
 
311
static void ShowConsortium (ButtoN b)
 
312
 
 
313
{
 
314
  PubdescPagePtr  ppp;
 
315
 
 
316
  ppp = (PubdescPagePtr) GetObjectExtra (b);
 
317
  if (ppp == NULL) return;
 
318
 
 
319
  SafeHide (ppp->cons_btn);
 
320
  SafeShow (ppp->consortium);
 
321
  Update ();
 
322
}
 
323
 
 
324
static AuthListPtr AddConsortiumToAuthList (AuthListPtr alp, DialoG consortium)
681
325
 
682
326
{
683
327
  AuthorPtr    ap;
 
328
  ValNodePtr   head, vnp;
684
329
  ValNodePtr   names;
685
330
  PersonIdPtr  pid;
 
331
  CharPtr      str;
686
332
 
687
 
  if (TextHasNoText (consortium)) return alp;
 
333
  head = DialogToPointer (consortium);
 
334
  if (head == NULL) return alp;
688
335
  if (alp == NULL) {
689
336
    alp = AuthListNew ();
690
337
    alp->choice = 1;
691
338
  }
692
 
  pid = PersonIdNew ();
693
 
  if (pid == NULL) return NULL;
694
 
  pid->choice = 5;
695
 
  pid->data = SaveStringFromText (consortium);
696
 
  ap = AuthorNew ();
697
 
  if (ap == NULL) return NULL;
698
 
  ap->name = pid;
699
 
  names = ValNodeAdd (&(alp->names));
700
 
  names->choice = 1;
701
 
  names->data.ptrvalue = ap;
 
339
  for (vnp = head; vnp != NULL; vnp = vnp->next) {
 
340
    str = (CharPtr) vnp->data.ptrvalue;
 
341
    if (StringHasNoText (str)) continue;
 
342
    pid = PersonIdNew ();
 
343
    if (pid == NULL) continue;
 
344
    pid->choice = 5;
 
345
    pid->data = StringSave (str);
 
346
    ap = AuthorNew ();
 
347
    if (ap == NULL) continue;
 
348
    ap->name = pid;
 
349
    names = ValNodeAdd (&(alp->names));
 
350
    names->choice = 1;
 
351
    names->data.ptrvalue = ap;
 
352
  }
702
353
  return alp;
703
354
}
704
355
 
705
 
static void AuthListToConsortium (AuthListPtr alp, TexT consortium)
 
356
static void AuthListToConsortium (AuthListPtr alp, DialoG consortium, ButtoN cons_btn)
706
357
 
707
358
{
708
359
  AuthorPtr    ap;
 
360
  ValNodePtr   head = NULL;
709
361
  ValNodePtr   names;
710
362
  PersonIdPtr  pid;
711
363
  CharPtr      str;
718
370
    pid = ap->name;
719
371
    if (pid == NULL || pid->choice != 5) continue;
720
372
    str = (CharPtr) pid->data;
721
 
    SafeSetTitle (consortium, str);
722
 
  }
 
373
    ValNodeCopyStr (&head, 0, str);
 
374
  }
 
375
  PointerToDialog (consortium, head);
 
376
  if (head != NULL) {
 
377
    SafeHide (cons_btn);
 
378
    SafeShow (consortium);
 
379
    Update ();
 
380
  }
 
381
  ValNodeFreeData (head);
723
382
}
724
383
 
725
384
static CitPatPtr PutATPat (PubdescPagePtr ppp)
971
630
  return cap;
972
631
}
973
632
 
 
633
static void TestPubdescArt (ValNodePtr PNTR err_list, PubdescPagePtr ppp)
 
634
{
 
635
  if (err_list == NULL || ppp == NULL) return;
 
636
  
 
637
  if (TextHasNoText (ppp->title_box)) {
 
638
    ValNodeAddPointer (err_list, 0, StringSave ("Missing required field Article Title"));
 
639
  }
 
640
}
 
641
 
 
642
 
 
643
static ValNodePtr TestPubdescDialog (DialoG d)
 
644
{
 
645
  PubdescPagePtr        ppp;
 
646
  ValNodePtr            err_list = NULL;
 
647
  AuthListPtr           alp;
 
648
 
 
649
  ppp = (PubdescPagePtr) GetObjectExtra (d);
 
650
  if (ppp != NULL) {
 
651
    switch (ppp->pub_choice)
 
652
    {
 
653
      case PUB_UNPUB:
 
654
      case PUB_ONLINE:
 
655
        /* all fields are optional in a Cit-gen */
 
656
        break;
 
657
      case PUB_PATENT:
 
658
        if (TextHasNoText (ppp->pat_country)) {
 
659
          ValNodeAddPointer (&err_list, 0, StringSave ("Missing required field Patent Country"));
 
660
        }
 
661
        if (TextHasNoText (ppp->pat_doc_type)) {
 
662
          ValNodeAddPointer (&err_list, 0, StringSave ("Missing required field Patent Document Type"));
 
663
        }
 
664
        if (TextHasNoText (ppp->title_box)) {
 
665
          ValNodeAddPointer (&err_list, 0, StringSave ("Missing required field Title"));
 
666
        }
 
667
          
 
668
        alp = (AuthListPtr) DialogToPointer (ppp->author_list);
 
669
        alp = AddConsortiumToAuthList (alp, ppp->consortium);
 
670
        if (alp == NULL) {
 
671
          ValNodeAddPointer (&err_list, 0, StringSave ("Missing required Author names"));
 
672
        } else {
 
673
          alp = AuthListFree (alp);
 
674
        }
 
675
        break;
 
676
      case PUB_JOURNAL:
 
677
        if (TextHasNoText (ppp->journal)) {
 
678
          ValNodeAddPointer (&err_list, 0, StringSave ("Missing required field Journal Title"));
 
679
        }
 
680
        TestPubdescArt (&err_list, ppp);
 
681
        break;
 
682
      case PUB_SUB:
 
683
        alp = (AuthListPtr) DialogToPointer (ppp->author_list);
 
684
        alp = AddConsortiumToAuthList (alp, ppp->consortium);
 
685
        if (alp == NULL) {
 
686
          ValNodeAddPointer (&err_list, 0, StringSave ("Missing required Author names"));
 
687
        } else {
 
688
          alp = AuthListFree (alp);
 
689
        }
 
690
        break;
 
691
      default:
 
692
        break;
 
693
    }
 
694
  }
 
695
  return err_list;
 
696
}
 
697
 
 
698
 
974
699
static Pointer PubdescPageToPubdescPtr (DialoG d)
975
700
{
976
701
  DatePtr               dp;
991
716
  Int2                  val;
992
717
  CitRetractPtr         crp;
993
718
  UIEnum                uieval;
 
719
  /* for fixing special characters */
 
720
  SeqDescrPtr           sdp_tmp;
 
721
  Boolean               fixed_chars = FALSE;
994
722
 
995
723
  pdp = NULL;
996
724
  ppp = (PubdescPagePtr) GetObjectExtra (d);
1236
964
      }
1237
965
    }
1238
966
  }
 
967
 
 
968
  /* fix special characters before returning */
 
969
  sdp_tmp = SeqDescrNew(NULL);
 
970
  sdp_tmp->choice = Seq_descr_pub;
 
971
  sdp_tmp->data.ptrvalue = pdp;
 
972
  FixSpecialCharactersForObject (OBJ_SEQDESC, sdp_tmp, "You may not include special characters in publication text.\nIf you do not choose replacement characters, these special characters will be replaced with '#'.", TRUE, &fixed_chars);
 
973
  sdp_tmp->data.ptrvalue = NULL;
 
974
  sdp_tmp = SeqDescrFree (sdp_tmp);
 
975
  if (fixed_chars)
 
976
  {
 
977
    PointerToDialog (d, pdp);
 
978
  }
 
979
 
1239
980
  return (Pointer) pdp;
1240
981
}
1241
982
 
1253
994
    if (alp != NULL)
1254
995
    {
1255
996
      PointerToDialog (ppp->author_list, (Pointer) alp);
1256
 
      AuthListToConsortium (alp, ppp->consortium);
 
997
      AuthListToConsortium (alp, ppp->consortium, ppp->cons_btn);
1257
998
      ppp->originalAuthList = AuthListFree (ppp->originalAuthList);
1258
999
      ppp->originalAuthList = AsnIoMemCopy (alp,
1259
1000
                                            (AsnReadFunc) AuthListAsnRead,
1284
1025
    if (alp != NULL)
1285
1026
    {
1286
1027
      PointerToDialog (ppp->author_list, (Pointer) alp);
1287
 
      AuthListToConsortium (alp, ppp->consortium);
 
1028
      AuthListToConsortium (alp, ppp->consortium, ppp->cons_btn);
1288
1029
      ppp->originalAuthList = AuthListFree (ppp->originalAuthList);
1289
1030
      ppp->originalAuthList = AsnIoMemCopy (alp,
1290
1031
                                            (AsnReadFunc) AuthListAsnRead,
1330
1071
      else
1331
1072
      {
1332
1073
        PointerToDialog (ppp->author_list, (Pointer) alp);
1333
 
        AuthListToConsortium (alp, ppp->consortium);
 
1074
        AuthListToConsortium (alp, ppp->consortium, ppp->cons_btn);
1334
1075
        ppp->originalAuthList = AuthListFree (ppp->originalAuthList);
1335
1076
        ppp->originalAuthList = AsnIoMemCopy (alp,
1336
1077
                                              (AsnReadFunc) AuthListAsnRead,
1436
1177
    if (alp != NULL)
1437
1178
    {
1438
1179
      PointerToDialog (ppp->author_list, (Pointer) alp);
1439
 
      AuthListToConsortium (alp, ppp->consortium);
 
1180
      AuthListToConsortium (alp, ppp->consortium, ppp->cons_btn);
1440
1181
      ppp->originalAuthList = AuthListFree (ppp->originalAuthList);
1441
1182
      ppp->originalAuthList = AsnIoMemCopy (alp,
1442
1183
                                            (AsnReadFunc) AuthListAsnRead,
1522
1263
                if (alp != NULL)
1523
1264
                {
1524
1265
                  PointerToDialog (ppp->author_list, (Pointer) alp);
1525
 
                  AuthListToConsortium (alp, ppp->consortium);
 
1266
                  AuthListToConsortium (alp, ppp->consortium, ppp->cons_btn);
1526
1267
                  ppp->originalAuthList = AuthListFree (ppp->originalAuthList);
1527
1268
                  ppp->originalAuthList = AsnIoMemCopy (alp,
1528
1269
                                            (AsnReadFunc) AuthListAsnRead,
1989
1730
  return cgp;
1990
1731
}
1991
1732
 
 
1733
static void FixEPubOnlyJournal (PubdescPagePtr ppp, Boolean only_if_ahead_of_print)
 
1734
 
 
1735
{
 
1736
  Char    str [256];
 
1737
  Int2    starting_year;
 
1738
  UIEnum  val;
 
1739
  Int2    year = 0;
 
1740
 
 
1741
  if (ppp == NULL) return;
 
1742
 
 
1743
  GetTitle (ppp->year, str, sizeof (str));
 
1744
  if (StringDoesHaveText (str)) {
 
1745
    StrToInt (str, &year);
 
1746
    if (year < 1900) {
 
1747
      year = 0;
 
1748
    }
 
1749
  }
 
1750
 
 
1751
  GetTitle (ppp->journal, str, sizeof (str) - 1);
 
1752
  if (StringHasNoText (str)) return;
 
1753
 
 
1754
  if (! Mla2IsEPubOnlyJournal (str, &starting_year)) return;
 
1755
 
 
1756
  if (starting_year > 0) {
 
1757
    if (year < starting_year) return;
 
1758
  }
 
1759
 
 
1760
  if (only_if_ahead_of_print) {
 
1761
    if (GetEnumPopup (ppp->pubstatus, pubstatus_alist, &val) && val > 0) {
 
1762
      if ((Uint1) val != PUBSTATUS_aheadofprint) return;
 
1763
    }
 
1764
  }
 
1765
 
 
1766
  SetEnumPopup (ppp->pubstatus, pubstatus_alist, (UIEnum) PUBSTATUS_epublish);
 
1767
}
1992
1768
 
1993
1769
static ValNodePtr LookupAnArticle (PubEquivLookupProc lookup, ValNodePtr oldpep, Boolean byMuid)
1994
1770
 
2148
1924
        PointerToDialog (ppp->dialog, (Pointer) pdp);
2149
1925
      }
2150
1926
      PubdescFree (pdp);
 
1927
      FixEPubOnlyJournal (ppp, FALSE);
2151
1928
      Select (ParentWindow (b));
2152
1929
      Update ();
2153
1930
    }
2190
1967
  PubdescFree (pdp);
2191
1968
}
2192
1969
 
 
1970
static Boolean ChooseFromMultipleJournals (CharPtr rsult, size_t max, ValNodePtr allTitles)
 
1971
{
 
1972
  WindoW                 w;
 
1973
  GrouP                  h, c, q;
 
1974
  ButtoN                 b;
 
1975
  PrompT                 p;
 
1976
  CharPtr                str;
 
1977
  Int2                   j;
 
1978
  ValNodePtr             vnp;
 
1979
  PopuP                  x;
 
1980
  ModalAcceptCancelData  acd;
 
1981
 
 
1982
  if (allTitles == NULL) return FALSE;
 
1983
  acd.accepted = FALSE;
 
1984
  acd.cancelled = FALSE;
 
1985
 
 
1986
  w = ModalWindow (-20, -13, -10, -10, NULL);
 
1987
  h = HiddenGroup (w, -1, 0, NULL);
 
1988
  SetGroupSpacing (h, 10, 10);
 
1989
 
 
1990
  p = StaticPrompt (h, "Select the desired journal from the following popup menu", 0, 0, programFont, 'c');
 
1991
 
 
1992
  q = HiddenGroup (h, 3, 0, NULL);
 
1993
  StaticPrompt (q, "Journal", 0, popupMenuHeight, programFont, 'l');
 
1994
  x = PopupList (q, TRUE, NULL);
 
1995
  PopupItem (x, " ");
 
1996
  for (vnp = allTitles; vnp != NULL; vnp = vnp->next) {
 
1997
    str = (CharPtr) vnp->data.ptrvalue;
 
1998
    if (StringHasNoText (str)) continue;
 
1999
    PopupItem (x, str);
 
2000
  }
 
2001
  SetValue (x, 1);
 
2002
 
 
2003
  c = HiddenGroup (h, 3, 0, NULL);
 
2004
  b = PushButton (c, "Yes", ModalAcceptButton);
 
2005
  SetObjectExtra (b, &acd, NULL);
 
2006
  b = PushButton (c, "No", ModalCancelButton);
 
2007
  SetObjectExtra (b, &acd, NULL);
 
2008
  AlignObjects (ALIGN_CENTER, (HANDLE) p, (HANDLE) q, (HANDLE) c, NULL);
 
2009
 
 
2010
  Show (w); 
 
2011
  Select (w);
 
2012
  while (! acd.accepted && ! acd.cancelled) {
 
2013
    ProcessExternalEvent ();
 
2014
    Update ();
 
2015
  }
 
2016
  ProcessAnEvent ();
 
2017
  Remove (w);
 
2018
  if (acd.accepted) {
 
2019
    j = GetValue (x);
 
2020
    if (j > 1) {
 
2021
      j -= 2;
 
2022
      vnp = allTitles;
 
2023
      while (j > 0) {
 
2024
        vnp = vnp->next;
 
2025
        j--;
 
2026
      }
 
2027
      if (vnp != NULL) {
 
2028
        str = (CharPtr) vnp->data.ptrvalue;
 
2029
        if (StringDoesHaveText (str)) {
 
2030
          StringNCpy_0 (rsult, str, max);
 
2031
          return TRUE;
 
2032
        }
 
2033
      }
 
2034
    }
 
2035
  }
 
2036
  return FALSE;
 
2037
}
 
2038
 
2193
2039
static void LookupISOJournalProc (ButtoN b)
2194
2040
 
2195
2041
{
 
2042
  ValNodePtr      allTitles = NULL;
2196
2043
  Int1            jtaType;
 
2044
  Int4            len;
2197
2045
  PubdescPagePtr  ppp;
2198
2046
  Char            str [256];
2199
2047
 
2201
2049
  if (ppp != NULL && ppp->lookupJournal != NULL) {
2202
2050
    GetTitle (ppp->journal, str, sizeof (str) - 1);
2203
2051
    if (! StringHasNoText (str)) {
2204
 
      if ((ppp->lookupJournal) (str, sizeof (str) - 1, &jtaType)) {
2205
 
        SetTitle (ppp->journal, str);
 
2052
      if ((ppp->lookupJournal) (str, sizeof (str) - 1, &jtaType, &allTitles)) {
 
2053
        len = ValNodeLen (allTitles);
 
2054
        if (len > 1) {
 
2055
          if (ChooseFromMultipleJournals (str, sizeof (str) - 1, allTitles)) {
 
2056
            SetTitle (ppp->journal, str);
 
2057
            FixEPubOnlyJournal (ppp, FALSE);
 
2058
          } else {
 
2059
            Message (MSG_OK, "Unable to match journal");
 
2060
          }
 
2061
        } else if (len == 1 && StringDoesHaveText (allTitles->data.ptrvalue) &&
 
2062
                   allTitles->choice == Cit_title_iso_jta) {
 
2063
          SetTitle (ppp->journal, allTitles->data.ptrvalue);
 
2064
          FixEPubOnlyJournal (ppp, FALSE);
 
2065
        } else {
 
2066
          Message (MSG_OK, "Unable to match journal");
 
2067
        }
2206
2068
        Update ();
2207
2069
      }
2208
2070
    }
2292
2154
  ButtoN                lkp;
2293
2155
  GrouP                 m, m1, m2, m3, m4, m5, m6, m7, m8, m9;
2294
2156
  GrouP                 n1, n2, n3, n4;
2295
 
  GrouP                 p, q;
2296
 
  PrompT                p2, p3, p4, p5;
 
2157
  GrouP                 p, q, z;
 
2158
  PrompT                p2, p3, p4, p5, p6;
2297
2159
  PopuP                 pp;
2298
2160
  PubdescPagePtr        ppp;
2299
2161
  GrouP                 s;
2315
2177
    ppp->dialog = (DialoG) p;
2316
2178
    ppp->todialog = PubdescPtrToPubdescPage;
2317
2179
    ppp->fromdialog = PubdescPageToPubdescPtr;
2318
 
    ppp->testdialog = NULL;
 
2180
    ppp->testdialog = TestPubdescDialog;
2319
2181
 
2320
2182
/* copy a bunch of flags and defaults got from the init form */
2321
2183
    ppp->reftype = reftype;
2426
2288
      ppp->AuthGroup[0] = m2;
2427
2289
      ppp->author_list = CreateAuthorDialog (m2, 3, 2);
2428
2290
      pfp->Author_Page = thispage;
 
2291
      /*
2429
2292
      q = HiddenGroup (m2, 2, 0, NULL);
2430
2293
      StaticPrompt (q, "Consortium", 0, stdLineHeight, programFont, 'l');
2431
2294
      ppp->consortium = DialogText (q, "", 16, NULL);
 
2295
      */
 
2296
      q = HiddenGroup (m2, 0, 2, NULL);
 
2297
      p6 = StaticPrompt (q, "Consortium", 0, stdLineHeight, programFont, 'c');
 
2298
      z = HiddenGroup (q, 0, 0, NULL);
 
2299
      ppp->cons_btn = PushButton (z, "Press To Show Consortium Editor", ShowConsortium);
 
2300
      SetObjectExtra (ppp->cons_btn, ppp, NULL);
 
2301
      ppp->consortium = CreateVisibleStringDialog (z, 3, -1, 16);
 
2302
      Hide (ppp->consortium);
 
2303
      AlignObjects (ALIGN_CENTER, (HANDLE) p6, (HANDLE) ppp->cons_btn, (HANDLE) ppp->consortium, NULL);
2432
2304
      AlignObjects (ALIGN_CENTER, (HANDLE) ppp->author_list, (HANDLE) q, NULL);
2433
2305
    }
2434
2306
    else
2887
2759
  ErrSev          oldErrSev;
2888
2760
  PubdescPtr      pdp;
2889
2761
  PubdescFormPtr  pfp;
 
2762
  ValNodePtr      err_list;
2890
2763
 
2891
2764
  pfp = (PubdescFormPtr) GetObjectExtra (b);
2892
2765
  if (pfp == NULL) return;
2893
2766
  ErrClear ();
2894
2767
  oldErrSev = ErrSetMessageLevel (SEV_ERROR);
 
2768
  err_list = TestDialog (pfp->data);
 
2769
  if (err_list != NULL) {
 
2770
    DisplayErrorMessages ("Missing Required Fields", err_list);
 
2771
    err_list = ValNodeFreeData (err_list);
 
2772
    return;
 
2773
  }
2895
2774
  pdp = (PubdescPtr) DialogToPointer (pfp->data);
 
2775
 
2896
2776
  copy = AsnIoMemCopy ((Pointer) pdp,
2897
2777
                       (AsnReadFunc) PubdescAsnRead,
2898
2778
                       (AsnWriteFunc) PubdescAsnWrite); 
3529
3409
      if (PubEquivMatch (pdp->pub, radp->deleteThis->pub) == 0) {
3530
3410
        serial_number = GetSerialNumber (pdp->pub);
3531
3411
        pdp->pub = PubEquivFree (pdp->pub);
 
3412
 
3532
3413
        pdp->pub = AsnIoMemCopy (radp->replaceWith->pub, (AsnReadFunc) PubEquivAsnRead,
3533
3414
                                 (AsnWriteFunc) PubEquivAsnWrite);
3534
3415
        SetSerialNumber (pdp->pub, serial_number);
3665
3546
      }
3666
3547
      rf_value = pifp->reftype;
3667
3548
      st_value = (Uint1) GetValue (pifp->pub_status);
 
3549
      pb_value = GetValue (pifp->pub_choice);
 
3550
      if (st_value > 1 && pb_value == 0) {
 
3551
        Message (MSG_ERROR, "Must choose class");
 
3552
        ArrowCursor();
 
3553
        Update();
 
3554
        return;
 
3555
      }
3668
3556
      if (st_value > 2)
3669
3557
        st_value = 0;
3670
 
      pb_value = GetValue (pifp->pub_choice);
3671
3558
      if (descfeat != 2)
3672
3559
      {
3673
3560
        w = (WindoW) CreatePubdescDescForm (-50, -33, "Citation Information",
3747
3634
      {
3748
3635
        SetValue (pifp->pub_choice, 1);
3749
3636
      }
 
3637
      if (pubstat == 2) {
 
3638
        if (GetStatus (pifp->patent_btn)) {
 
3639
          SetValue (pifp->pub_choice, 0);
 
3640
        }
 
3641
        Disable (pifp->patent_btn);        
 
3642
      } else {
 
3643
        Enable (pifp->patent_btn);
 
3644
      }
3750
3645
    }
3751
3646
  }
3752
3647
}
4260
4155
    RadioButton (g5, "Thesis/Monograph");
4261
4156
    RadioButton (g5, "Proceedings Chapter");
4262
4157
    RadioButton (g5, "Proceedings");
4263
 
    RadioButton (g5, "Patent");
 
4158
    pifp->patent_btn = RadioButton (g5, "Patent");
4264
4159
    RadioButton (g5, "Online Publication");
4265
4160
    if (pdp != NULL)
4266
4161
    {
4518
4413
 
4519
4414
typedef struct citart_inpress_struct {
4520
4415
 
4521
 
  FILE *logfile;        
4522
4416
  Boolean error;        
4523
4417
      
4524
 
  CharPtr   f_last_name, f_first_name, l_last_name, l_first_name; 
 
4418
  CharPtr   f_last_name, l_last_name; 
4525
4419
  CharPtr  jour_title, jour_volume,  jour_page, art_title;
4526
4420
 
4527
4421
  Int2 year;
4528
 
  Int1 rank;
4529
4422
 
4530
4423
  ByteStorePtr uids_bs;  /*pmids*/
4531
4424
 
4558
4451
  ButtoN          Extra_Term;
4559
4452
  TexT            extra_term_text;
4560
4453
 
 
4454
  ButtoN          expand_year;
 
4455
 
4561
4456
  PopuP           new_query;
4562
4457
  DoC             rdoc;          
4563
4458
  ButtoN          action;           
4692
4587
  CharPtr count_str, sumStr = NULL;
4693
4588
 
4694
4589
  Entrez2DocsumPtr      dsp;
4695
 
  Entrez2DocsumListPtr  e2dl;
 
4590
  Entrez2DocsumListPtr  e2dl = NULL;
4696
4591
  Entrez2RequestPtr     e2rp;
4697
4592
  Entrez2ReplyPtr       e2ry;
4698
4593
  Entrez2DocsumDataPtr  e2ddp;
4704
4599
          pages="No Page Available",
4705
4600
          year_str="No Year Available",
4706
4601
          tmp = NULL;
4707
 
  Int2 size = 0, year = -1;
 
4602
  Int2 size = 0;
4708
4603
 
4709
4604
  /* no citation hit returned */
4710
4605
  if  (uids_bs == NULL) {
4842
4737
  EntrezAddToBooleanRequest (e2rp, NULL, 0, "PAGE",term, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
4843
4738
}
4844
4739
 
4845
 
static  void AddYear(Entrez2RequestPtr e2rp, CharPtr term, Boolean is_1st)
 
4740
static  void AddYear(Entrez2RequestPtr e2rp, CharPtr term, Boolean is_1st, Boolean expand)
4846
4741
{
 
4742
  Int4 year;
 
4743
  Char year_buf[10];
4847
4744
  if (StringHasNoText (term)) return;
4848
4745
  if (!is_1st) {
4849
4746
    EntrezAddToBooleanRequest (e2rp, NULL, ENTREZ_OP_AND, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);  
4850
4747
  }
4851
 
  EntrezAddToBooleanRequest (e2rp, NULL, 0, "DP", term, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4748
  if (expand) {
 
4749
    year = atoi (term);
 
4750
    if (year > 0) {
 
4751
      EntrezAddToBooleanRequest (e2rp, NULL, ENTREZ_OP_LEFT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE); 
 
4752
      sprintf (year_buf, "%d", year - 1);
 
4753
      EntrezAddToBooleanRequest (e2rp, NULL, 0, "EDAT", year_buf, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4754
      EntrezAddToBooleanRequest (e2rp, NULL, ENTREZ_OP_OR, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE); 
 
4755
      sprintf (year_buf, "%d", year);
 
4756
      EntrezAddToBooleanRequest (e2rp, NULL, 0, "EDAT", year_buf, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4757
      EntrezAddToBooleanRequest (e2rp, NULL, ENTREZ_OP_OR, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE); 
 
4758
      sprintf (year_buf, "%d", year + 1);
 
4759
      EntrezAddToBooleanRequest (e2rp, NULL, 0, "EDAT", year_buf, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4760
      EntrezAddToBooleanRequest (e2rp, NULL, ENTREZ_OP_RIGHT_PAREN, NULL, NULL, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4761
    } else {
 
4762
      EntrezAddToBooleanRequest (e2rp, NULL, 0, "EDAT", term, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4763
    }
 
4764
  } else {
 
4765
    EntrezAddToBooleanRequest (e2rp, NULL, 0, "EDAT", term, NULL, 0, 0, NULL, NULL, FALSE, FALSE);
 
4766
  }
4852
4767
}
4853
4768
 
4854
4769
static  void AddAll(Entrez2RequestPtr e2rp, CharPtr term, Boolean is_1st)
4861
4776
}
4862
4777
 
4863
4778
 
4864
 
 
4865
 
 
4866
 
/*****************************************************************************
4867
 
*
4868
 
*  Function:   FormDefaultQuery
4869
 
*              constructs entrez2 query from information passed in, execute
4870
 
*              the query, and get back the uids from entrezReplyPtr. 
4871
 
********************************pass uids back as bs of caipp. returns void.
4872
 
*  Argument:   CitArtInPressPtr
4873
 
*
4874
 
*  Returns:    void
4875
 
*
4876
 
*****************************************************************************/
4877
 
static void FormDefaultQuery (Entrez2RequestPtr e2rp, CitArtInPressPtr caipp) {
4878
 
 
4879
 
  Char  year [16];
4880
 
 
4881
 
  if (caipp->year != -1) {
4882
 
    sprintf(year, "%d", (int) caipp->year); 
4883
 
  }
4884
 
 
4885
 
  /* add all available fields as indicated by rank*/
4886
 
  if (caipp->rank == 10) {      /* add title, page, vol */
4887
 
 
4888
 
    AddJournal(e2rp,  caipp->jour_title, TRUE);  /* add first term*/
4889
 
    AddVolume(e2rp,  caipp->jour_volume, FALSE);  
4890
 
    AddPage(e2rp,  caipp->jour_page, FALSE); 
4891
 
  }
4892
 
  
4893
 
  else {    
4894
 
    
4895
 
    if (caipp->rank > 4) {    /* add author in all cases*/
4896
 
 
4897
 
      /***** term  can be capital letter or lower case,  (ENTREZ_OP_NONE is 0)  */
4898
 
      AddAuthor(e2rp,  caipp->f_last_name, TRUE);  /* add first term */
4899
 
 
4900
 
      if(StringCmp(caipp->l_last_name, "null") && StringCmp(caipp->l_last_name, caipp->f_last_name)) {
4901
 
      AddAuthor(e2rp,  caipp->l_last_name, FALSE); 
4902
 
      }
4903
 
    }
4904
 
    
4905
 
    if (caipp->rank == 6) {  /* add year, takes StringSave(year-1900)?? */   
4906
 
      AddYear(e2rp,  year, FALSE);        
4907
 
    }     
4908
 
 
4909
 
    if (caipp->rank > 6) {  /* add jour_title */
4910
 
      AddJournal(e2rp,  caipp->jour_title, FALSE);  /* NOT first term*/
4911
 
    }
4912
 
    
4913
 
    if (caipp->rank == 9) {       /* add vol and year */
4914
 
      AddVolume(e2rp,  caipp->jour_volume, FALSE);  
4915
 
      AddYear(e2rp,  year, FALSE); 
4916
 
    }
4917
 
 
4918
 
    if (caipp->rank == 8) {  /* add year or volume */
4919
 
      
4920
 
      if (caipp->year != -1) {
4921
 
        AddYear(e2rp,  year, FALSE);    
4922
 
      }
4923
 
      else {
4924
 
        AddVolume(e2rp,  caipp->jour_volume, FALSE);
4925
 
      }                
4926
 
    }   /* end rank 8*/                      
4927
 
  }  
4928
 
}       
4929
 
 
 
4779
static Entrez2RequestPtr QueryFromForm (CitationUpdateFormPtr cufp, Boolean use_all)
 
4780
{
 
4781
  Entrez2RequestPtr e2rp = NULL;
 
4782
  Boolean is_first_term = TRUE;
 
4783
  Char    val_str[256];
 
4784
 
 
4785
  if (cufp == NULL) return NULL;
 
4786
 
 
4787
  /* for new term in query, add to [all], then automatically go through Term mapping*/
 
4788
  /* add exta term (user supplied) as ALL, no specific field */
 
4789
  /* debug:  assuming this is a well-formed query string, let the add func. parse it*/
 
4790
  if ( !TextHasNoText (cufp->extra_term_text) && (use_all || GetStatus (cufp->Extra_Term))) {
 
4791
    GetTitle (cufp->extra_term_text, val_str, sizeof (val_str));
 
4792
    e2rp = EntrezCreateBooleanRequest (TRUE, FALSE, "PubMed", val_str, 0, 0, NULL, 20, 0); 
 
4793
    is_first_term = FALSE;
 
4794
  } else {
 
4795
    e2rp = EntrezCreateBooleanRequest (TRUE, FALSE, "PubMed", NULL, 0, 0, NULL, 20, 0);
 
4796
  }
 
4797
 
 
4798
  if ( ! TextHasNoText (cufp->f_auth_text) && (use_all || GetStatus (cufp->First_Author))) {
 
4799
    GetTitle (cufp->f_auth_text, val_str, sizeof (val_str));
 
4800
    AddAuthor(e2rp, val_str, is_first_term);
 
4801
    is_first_term = FALSE;
 
4802
  }
 
4803
 
 
4804
  if ( !TextHasNoText (cufp->l_auth_text) && (use_all || GetStatus (cufp->Last_Author))) {
 
4805
    GetTitle (cufp->l_auth_text, val_str, sizeof (val_str));
 
4806
    AddAuthor(e2rp, val_str, is_first_term);    
 
4807
    is_first_term = FALSE;
 
4808
  }
 
4809
 
 
4810
  if ( !TextHasNoText (cufp->journal_text) && (use_all || GetStatus (cufp->Journal))) {
 
4811
    GetTitle (cufp->journal_text, val_str, sizeof (val_str));
 
4812
    AddJournal(e2rp, val_str, is_first_term);
 
4813
    is_first_term = FALSE;
 
4814
  }
 
4815
 
 
4816
  if ( !TextHasNoText (cufp->volume_text) && (use_all || GetStatus (cufp->Volume))) {
 
4817
    GetTitle (cufp->volume_text, val_str, sizeof (val_str));
 
4818
    AddVolume(e2rp, val_str, is_first_term);
 
4819
    is_first_term = FALSE;
 
4820
  }
 
4821
 
 
4822
  if ( !TextHasNoText (cufp->page_text) && (use_all || GetStatus (cufp->Page))) {
 
4823
    GetTitle (cufp->page_text, val_str, sizeof (val_str));
 
4824
    AddPage(e2rp, val_str, is_first_term);
 
4825
    is_first_term = FALSE;
 
4826
  }
 
4827
 
 
4828
  if ( !TextHasNoText (cufp->year_text) && (use_all || GetStatus (cufp->Year))) {
 
4829
    GetTitle (cufp->year_text, val_str, sizeof (val_str));
 
4830
    AddYear(e2rp, val_str, is_first_term, GetStatus (cufp->expand_year));
 
4831
    is_first_term = FALSE;
 
4832
  }
 
4833
  return e2rp;  
 
4834
}
4930
4835
 
4931
4836
 
4932
4837
/*****************************************************************************
4948
4853
  CitationUpdateFormPtr  cufp;
4949
4854
  CitArtInPressPtr caipp;        /* local caipp, make deref coding easier*/
4950
4855
 
4951
 
  Entrez2RequestPtr  e2rp;
4952
 
 
4953
 
 
4954
 
  Char               f_auth [64];
4955
 
  Char               l_auth [64];
4956
 
  Char               journal [64];
4957
 
  Char               volume [64];
4958
 
  Char               page [64];
4959
 
  Char               year [64];
4960
 
  Char               new_term [256];
4961
 
 
4962
 
  Boolean            is_first_term = TRUE;
 
4856
  Entrez2RequestPtr  e2rp = NULL;
4963
4857
 
4964
4858
 
4965
4859
  cufp = (CitationUpdateFormPtr) GetObjectExtra (b);
4976
4870
  /*** trick:  must make sure to add Op : AND, after the first term, can't
4977
4871
   add one before!! */
4978
4872
 
4979
 
  if (choice == 1) {               /* precess default query*/
4980
 
 
4981
 
    e2rp = EntrezCreateBooleanRequest (TRUE, FALSE, "PubMed", NULL, 0, 0, NULL, 20, 0);
4982
 
 
4983
 
    FormDefaultQuery (e2rp,  caipp);
4984
 
    
4985
 
 
4986
 
    /* add exta term (user supplied) as ALL, no specific field */
4987
 
    if ( GetStatus (cufp->Extra_Term) ) {
4988
 
      GetTitle (cufp->extra_term_text, new_term, sizeof (f_auth));
4989
 
      AddAll(e2rp, new_term, FALSE);
4990
 
      is_first_term = FALSE;
4991
 
    }
4992
 
  }
4993
 
     
4994
 
  if (choice == 2) {        /*user specify query*/
4995
 
 
4996
 
    /* for new term in query, add to [all], then automatically go through Term mapping*/
4997
 
    /* add exta term (user supplied) as ALL, no specific field */
4998
 
    /* debug:  assuming this is a well-formed query string, let the add func. parse it*/
4999
 
    if ( GetStatus (cufp->Extra_Term) ) {
5000
 
      GetTitle (cufp->extra_term_text, new_term, sizeof (f_auth));
5001
 
      e2rp = EntrezCreateBooleanRequest (TRUE, FALSE, "PubMed", new_term, 0, 0, NULL, 20, 0); 
5002
 
      is_first_term = FALSE;
5003
 
    }
5004
 
    else{
5005
 
      e2rp = EntrezCreateBooleanRequest (TRUE, FALSE, "PubMed", NULL, 0, 0, NULL, 20, 0);
5006
 
    }
5007
 
 
5008
 
    if ( GetStatus (cufp->First_Author) ) {
5009
 
      GetTitle (cufp->f_auth_text, f_auth, sizeof (f_auth));
5010
 
      AddAuthor(e2rp, f_auth, is_first_term);
5011
 
      is_first_term = FALSE;
5012
 
    }
5013
 
 
5014
 
    if ( GetStatus (cufp->Last_Author) ) {
5015
 
      GetTitle (cufp->l_auth_text, l_auth, sizeof (l_auth));
5016
 
      AddAuthor(e2rp, l_auth, is_first_term);    
5017
 
      is_first_term = FALSE;
5018
 
    }
5019
 
 
5020
 
    if ( GetStatus (cufp->Journal) ) {
5021
 
      GetTitle (cufp->journal_text, journal, sizeof (journal));
5022
 
      AddJournal(e2rp, journal, is_first_term);
5023
 
      is_first_term = FALSE;
5024
 
    }
5025
 
 
5026
 
    if ( GetStatus (cufp->Volume) ) {
5027
 
      GetTitle (cufp->volume_text, volume, sizeof (volume));
5028
 
      AddVolume(e2rp, volume, is_first_term);
5029
 
      is_first_term = FALSE;
5030
 
    }
5031
 
 
5032
 
    if ( GetStatus (cufp->Page) ) {
5033
 
      GetTitle (cufp->page_text, volume, sizeof (page));
5034
 
      AddPage(e2rp, page, is_first_term);
5035
 
      is_first_term = FALSE;
5036
 
    }
5037
 
 
5038
 
    if ( GetStatus (cufp->Year) ) {
5039
 
      GetTitle (cufp->year_text, year, sizeof (year));
5040
 
      AddYear(e2rp, year, is_first_term);
5041
 
      is_first_term = FALSE;
5042
 
    }      
5043
 
  }
5044
 
 
5045
 
  SetValue (cufp->new_query, 2); /* reset the popup list to display customize item*/
5046
 
 
 
4873
  e2rp = QueryFromForm (cufp, choice == 1);
5047
4874
 
5048
4875
  /* process query, get Uids, populate the caipp field*/
5049
4876
  GetUidListFromE2Request (caipp, e2rp, cufp->rdoc);
5192
5019
}
5193
5020
 
5194
5021
 
 
5022
static void SetRequestType (ButtoN b)
 
5023
{
 
5024
  CitationUpdateFormPtr  cufp;
 
5025
 
 
5026
  cufp = (CitationUpdateFormPtr) GetObjectExtra (b);
 
5027
  if (cufp == NULL) return;
 
5028
 
 
5029
  if (GetStatus (cufp->First_Author)
 
5030
      || GetStatus (cufp->Last_Author)
 
5031
      || GetStatus (cufp->Journal)
 
5032
      || GetStatus (cufp->Volume)
 
5033
      || GetStatus (cufp->Page)
 
5034
      || GetStatus (cufp->Year)
 
5035
      || GetStatus (cufp->Extra_Term)) {
 
5036
    SetValue (cufp->new_query, 2);
 
5037
  } else {
 
5038
    SetValue (cufp->new_query, 1);
 
5039
  }  
 
5040
}
 
5041
 
5195
5042
 
5196
5043
/*****************************************************************************
5197
5044
*  Function:     CreateCitationUpdateWindow_detail
5252
5099
  authors = HiddenGroup (cit_fields, 4, 0, NULL);
5253
5100
  SetGroupSpacing (authors, 5, 3);
5254
5101
 
5255
 
  cufp->First_Author  = CheckBox (authors, "First Author", NULL);
 
5102
  cufp->First_Author  = CheckBox (authors, "First Author", SetRequestType);
 
5103
  SetObjectExtra (cufp->First_Author, cufp, NULL);
5256
5104
  cufp->f_auth_text = DialogText (authors,  "", 12, NULL);
5257
5105
 
5258
 
  cufp->Last_Author = CheckBox (authors, "Last Author", NULL);
 
5106
  cufp->Last_Author = CheckBox (authors, "Last Author", SetRequestType);
 
5107
  SetObjectExtra (cufp->Last_Author, cufp, NULL);
5259
5108
  cufp->l_auth_text = DialogText (authors,  "", 12, NULL);
5260
5109
 
5261
5110
  journal = HiddenGroup (cit_fields, 2, 0, NULL);
5262
5111
  SetGroupSpacing (journal, 5, 3);
5263
5112
 
5264
 
  cufp->Journal = CheckBox (journal, "Journal", NULL);
 
5113
  cufp->Journal = CheckBox (journal, "Journal", SetRequestType);
 
5114
  SetObjectExtra (cufp->Journal, cufp, NULL);
5265
5115
  cufp->journal_text = DialogText (journal,  "", 30, NULL);
5266
5116
 
5267
 
  imprint = HiddenGroup (cit_fields, 6, 0, NULL);
 
5117
  imprint = HiddenGroup (cit_fields, 7, 0, NULL);
5268
5118
  SetGroupSpacing (imprint, 5, 3);
5269
5119
 
5270
 
  cufp->Year = CheckBox (imprint, "Year", NULL);
 
5120
  cufp->Year = CheckBox (imprint, "Year", SetRequestType);
 
5121
  SetObjectExtra (cufp->Year, cufp, NULL);
5271
5122
  cufp->year_text = DialogText (imprint, "", 6, NULL);
5272
 
  cufp->Volume = CheckBox (imprint, "Volume", NULL);
 
5123
  cufp->expand_year = CheckBox (imprint, "+/- 1 Year", NULL);
 
5124
  SetStatus (cufp->expand_year, TRUE);
 
5125
  cufp->Volume = CheckBox (imprint, "Volume", SetRequestType);
 
5126
  SetObjectExtra (cufp->Volume, cufp, NULL);
5273
5127
  cufp->volume_text  = DialogText (imprint, "", 6, NULL);
5274
 
  cufp->Page = CheckBox (imprint, "Page", NULL);
 
5128
  cufp->Page = CheckBox (imprint, "Page", SetRequestType);
 
5129
  SetObjectExtra (cufp->Page, cufp, NULL);
5275
5130
  cufp->page_text = DialogText (imprint, "", 6, NULL);
5276
5131
 
5277
5132
 
5279
5134
  SetGroupSpacing (title, 5, 3);
5280
5135
 
5281
5136
  StaticPrompt (title, "Article Title:", 0, dialogTextHeight, systemFont, 'l');
5282
 
  cufp->art_title_text = ScrollText (title, 30, 1, systemFont, TRUE, NULL);
 
5137
  cufp->art_title_text = ScrollText (title, 30, 2, systemFont, TRUE, NULL);
5283
5138
  SafeSetTitle (cufp->art_title_text, "");
5284
5139
 
5285
5140
  i = HiddenGroup (h, 2, 0, NULL);     /*3rd vertical item in h*/
5289
5144
  StaticPrompt (i, " ", 0, popupMenuHeight, programFont, 'l');
5290
5145
  StaticPrompt (i, " ", 0, popupMenuHeight, programFont, 'l');
5291
5146
 
5292
 
  cufp->Extra_Term = CheckBox (i, "Add these terms to new query", NULL);
 
5147
  cufp->Extra_Term = CheckBox (i, "Add these terms to new query", SetRequestType);
 
5148
  SetObjectExtra (cufp->Extra_Term, cufp, NULL);
5293
5149
  cufp->extra_term_text = DialogText (i, "", 25, NULL);
5294
5150
 
5295
5151
 
5363
5219
  return w;
5364
5220
}
5365
5221
 
 
5222
 
 
5223
static CharPtr GetLastNameFromPersonId (PersonIdPtr pid)
 
5224
{
 
5225
  NameStdPtr nsp;
 
5226
  CharPtr lname = NULL;
 
5227
 
 
5228
  if (pid != NULL && pid->choice == 2) {                     
 
5229
                nsp = (NameStdPtr) pid->data;  
 
5230
                if (nsp->names != NULL) {               
 
5231
      lname = nsp->names[0];
 
5232
    }
 
5233
  }
 
5234
  return lname;
 
5235
}
 
5236
 
 
5237
 
5366
5238
/*****************************************************************************
5367
5239
*  Function:     PopulateWindow
5368
5240
*  Description:  use pdp to populate a caipp structure. No default query!!
5387
5259
  CitJourPtr cjp;
5388
5260
  ImprintPtr ImpPtr;
5389
5261
  AuthListPtr alp;  
5390
 
  AuthorPtr f_author_p, l_author_p;  /* first and last authors*/
5391
 
  PersonIdPtr pid_p;
5392
 
  NameStdPtr nsp;
 
5262
  AuthorPtr f_author_p = NULL, l_author_p = NULL, ap;  /* first and last authors*/
 
5263
  PersonIdPtr pid;
5393
5264
 
5394
5265
  ValNodePtr title_vnp, auth_vnp, art_title_vnp;
5395
5266
 
5396
 
  /*could get rid of full names*/
5397
 
  CharPtr f_first_name, f_last_name, l_first_name, l_last_name;
5398
 
  CharPtr jour_title, jour_volume, jour_page, art_title;
 
5267
  CharPtr f_last_name = NULL, l_last_name = NULL;
 
5268
  CharPtr jour_title = NULL, jour_volume = NULL, jour_page = NULL, art_title = NULL;
5399
5269
  
5400
 
  Int2 year;
5401
 
  Int1 rank;
 
5270
  Int2 year = -1;
5402
5271
 
5403
 
  Boolean has_author, has_title, has_volume, has_page, has_year, is_article;
5404
 
  has_author =  has_title = has_volume = has_page = has_year = is_article = FALSE;
 
5272
  Boolean is_article = FALSE;;
5405
5273
 
5406
5274
  cufp = (CitationUpdateFormPtr) GetObjectExtra (w);
5407
5275
  if (cufp == NULL) return;
5408
5276
 
5409
5277
 
5410
 
  if ( (caipp = MemNew(sizeof(CitArtInPress))) == NULL) {
5411
 
    return;
5412
 
  }
5413
 
 
5414
5278
  pubdesc = pdp;      /* don't really need this could use pubdesc*/   
5415
5279
  if(pubdesc == NULL) return;
5416
5280
 
5419
5283
 
5420
5284
  for (pub=pubdesc->pub, cap=NULL; pub; pub=pub->next) {
5421
5285
    if (pub->choice == PUB_Article) {
5422
 
 
5423
5286
      is_article = TRUE;
5424
5287
      cap = (CitArtPtr) pub->data.ptrvalue;
5425
5288
      if (cap == NULL) return; 
5426
5289
      
5427
5290
      /* look for cit-art from journals only*/
5428
 
      if (cap->from ==1) {
5429
 
        
5430
 
        cjp = (CitJourPtr) cap->fromptr;
5431
 
        if (cjp == NULL) return; 
5432
 
        
5433
 
        ImpPtr =(ImprintPtr) cjp->imp;        
5434
 
        if(ImpPtr == NULL) return; 
 
5291
      if (cap->from ==1) {      
 
5292
              cjp = (CitJourPtr) cap->fromptr;
 
5293
              if (cjp == NULL) return; 
 
5294
        
 
5295
              ImpPtr =(ImprintPtr) cjp->imp;          
 
5296
              if(ImpPtr == NULL) return; 
5435
5297
              
5436
 
 
5437
 
          /* get article title */
5438
 
          if( !cap->title ) { art_title = StringSave("No title was available"); }
5439
 
          for (art_title_vnp=cap->title; art_title_vnp; art_title_vnp=art_title_vnp->next) {
5440
 
            /*could combine the four*/
5441
 
            if((art_title_vnp->choice == Cit_title_name) || (art_title_vnp->choice == Cit_title_tsub)|| (art_title_vnp->choice == Cit_title_trans)) {
5442
 
              art_title = art_title_vnp->data.ptrvalue;             
5443
 
            }
5444
 
          }      
5445
 
 
5446
 
          /* get journal title */
5447
 
          if( !cjp->title ) { jour_title = StringSave("null"); }
5448
 
          for (title_vnp=cjp->title; title_vnp; title_vnp=title_vnp->next) {
5449
 
            /*could combine the four*/
5450
 
            if (title_vnp->choice == Cit_title_iso_jta) {
5451
 
              jour_title = title_vnp->data.ptrvalue;                
5452
 
            }
5453
 
            else if (title_vnp->choice == Cit_title_ml_jta) {
5454
 
              jour_title = title_vnp->data.ptrvalue;
5455
 
            }
5456
 
            else if (title_vnp->choice == Cit_title_jta) {
5457
 
              jour_title = title_vnp->data.ptrvalue;
5458
 
            }
5459
 
            else if (title_vnp->choice == Cit_title_name) {
5460
 
              jour_title = title_vnp->data.ptrvalue;
5461
 
              /* break;            don't need break ??? */
5462
 
            }
5463
 
            else { 
5464
 
              jour_title = StringSave("this journal got a WEIRD title");
5465
 
            }
5466
 
            has_title = TRUE;  
5467
 
          }
5468
 
          
5469
 
          
5470
 
          if (ImpPtr->volume) {
5471
 
            jour_volume =  ImpPtr->volume;
5472
 
            has_volume = TRUE;  
5473
 
          }
5474
 
          else {  jour_volume = StringSave("null"); }    
5475
 
          
5476
 
          if (ImpPtr->pages) { 
5477
 
            jour_page =  ImpPtr->pages;
5478
 
            has_page = TRUE;  
5479
 
          }
5480
 
          else {  jour_page = StringSave("null"); }
5481
 
        
5482
 
          
5483
 
          /* not ideal behavior, although date is required in imp*/
5484
 
          if ((DatePtr)ImpPtr->date == NULL) { return; }
5485
 
          
5486
 
                year = -1;
5487
 
                DateRead (ImpPtr->date, &year, NULL, NULL, NULL);
5488
 
                if (year != -1) { has_year = TRUE; }                            
5489
 
                
5490
 
                alp = (AuthListPtr) cap->authors; 
5491
 
                if (alp == NULL) {
5492
 
                  
5493
 
                  if (caipp->logfile) {                   
5494
 
 
5495
 
                    fprintf(caipp->logfile,"|this in-press cit-art has no author| %s | %s| %s | %d\n", jour_title, jour_volume, jour_page, year);
5496
 
                  }
5497
 
                   return;
5498
 
                }               
5499
 
                                                        
5500
 
                /*get ptr to both 1st and last author*/  
5501
 
                auth_vnp = (ValNodePtr) alp->names; /*get the first node */ 
5502
 
                
5503
 
                f_author_p = (AuthorPtr)auth_vnp->data.ptrvalue;
5504
 
                
5505
 
                /* get the node for the last author*/
5506
 
                while (auth_vnp->next) {
5507
 
                  auth_vnp = auth_vnp->next;
5508
 
                }
5509
 
                l_author_p =(AuthorPtr)auth_vnp->data.ptrvalue;
5510
 
                
5511
 
                /* should be analyzing the value of alp->choice,  not alp->names->choice*/
5512
 
                if (alp->choice == 1) {   
5513
 
                  /*could make this (getting name from author_p) a function */             
5514
 
                   pid_p = (PersonIdPtr) f_author_p->name;
5515
 
                   
5516
 
                   if (pid_p->choice ==2) {                      
5517
 
                     
5518
 
                     nsp = (NameStdPtr) pid_p -> data;  
5519
 
                     
5520
 
                     /* why didnot this work?? *                         
5521
 
                        if (!( nsp->names[0])) */                   
5522
 
                     
5523
 
                     if (nsp->names[0] != NULL ) {
5524
 
                       
5525
 
                       f_last_name =  nsp->names[0];    
5526
 
                       has_author = TRUE;                      
5527
 
                       
5528
 
                       if (nsp->names[1]!= NULL) {
5529
 
                         f_first_name =  nsp->names[1]; 
5530
 
                       }
5531
 
                       else { f_first_name = StringSave("null"); }                      
5532
 
                       
5533
 
                     }
5534
 
                     /* set to null!! */
5535
 
                     else {  f_last_name = StringSave("null"); 
5536
 
                     f_first_name = StringSave("null");                      
5537
 
                     }
5538
 
                   }
5539
 
                   
5540
 
                   
5541
 
                   /*now do the last author */
5542
 
                   
5543
 
                   if (l_author_p->name == f_author_p->name) {  /*single author*/
5544
 
                     l_first_name = f_first_name;
5545
 
                     l_last_name =f_last_name;
5546
 
                   }
5547
 
                   else {
5548
 
                     
5549
 
                     pid_p = (PersonIdPtr) l_author_p->name;
5550
 
                     if (pid_p->choice ==2) {                    
5551
 
                       nsp = (NameStdPtr) pid_p -> data;  
5552
 
                       
5553
 
                       if (nsp->names[0] != NULL ) {
5554
 
                         
5555
 
                         l_last_name =  nsp->names[0];  
5556
 
                         if (nsp->names[1]!= NULL) {
5557
 
                           l_first_name =  nsp->names[1];       
5558
 
                         }
5559
 
                         else { l_first_name = StringSave("null"); }
5560
 
                       }                      
5561
 
                       else {  l_last_name = StringSave("null"); 
5562
 
                       l_first_name = StringSave("null");       
5563
 
                       }
5564
 
                     }
5565
 
                   } /*end of last author */
5566
 
                 }  /* end alp-> choice is std */
5567
 
                 
5568
 
                 
5569
 
                 /* here, if author list is not std names */                          
5570
 
                 else if (alp->choice == 2) {  
5571
 
                   
5572
 
                   /* full name as last name*/         
5573
 
                   f_last_name = (CharPtr)f_author_p;
5574
 
                   f_first_name = StringSave ("null");
5575
 
                   has_author = TRUE;   
5576
 
 
5577
 
                   l_last_name = (CharPtr)l_author_p;
5578
 
                   l_first_name = StringSave ("null");
5579
 
                 }
5580
 
                 else {  
5581
 
                   /* full name as last name*/         
5582
 
                   f_last_name = (CharPtr)f_author_p;
5583
 
                   f_first_name = StringSave ("null");
5584
 
                   has_author = TRUE;   
5585
 
 
5586
 
                   l_last_name = (CharPtr)l_author_p;
5587
 
                   l_first_name = StringSave ("null");
5588
 
                 }                                         
5589
 
                
5590
 
 
5591
 
 
5592
 
                rank = 0;
5593
 
                 /*caculate rank*/
5594
 
        
5595
 
                if (has_page && has_volume && has_title) {
5596
 
                   rank = 10;
5597
 
                }
5598
 
                else if (has_author) {
5599
 
                  if (has_title) {
5600
 
                    if(has_year && has_volume) { rank = 9; }
5601
 
                    else if (has_year || has_volume) { rank = 8; }
5602
 
                     else { rank = 7; }                /* auth + journal_title only*/
5603
 
                  }
5604
 
                  else if (has_year) { rank = 6; }   /* auth + year only*/
5605
 
                  else { rank = 5; } /* author  but no journal_title case */
5606
 
                }                
5607
 
                else { rank = 0; }  /*ignore all other combo*/       
5608
 
 
5609
 
 
5610
 
                rank = 0;
5611
 
                 /*caculate rank*/
5612
 
                /*   better set flags as key individual fields are collected!! 
5613
 
                 *    avoid many calls to StringCmp */
5614
 
                /* must have first author, or (journal_title, volume and page)*/
5615
 
                
5616
 
                if (has_page && has_volume && has_title) {
5617
 
                   rank = 10;
5618
 
                }
5619
 
                else if (has_author) {
5620
 
                  if (has_title) {
5621
 
                    if(has_year && has_volume) { rank = 9; }
5622
 
                    else if (has_year || has_volume) { rank = 8; }
5623
 
                     else { rank = 7; }                /* auth + journal_title only*/
5624
 
                  }
5625
 
                  else if (has_year) { rank = 6; }   /* auth + year only*/
5626
 
                  else { rank = 5; } /* author  but no journal_title case */
5627
 
                }                
5628
 
                else { rank = 0; }  /*ignore all other combo*/       
5629
 
 
5630
 
 
5631
 
                  /*  safe practice to save a new copy if the struct my go away. */     
5632
 
                  caipp->jour_title =  StringSave(jour_title);
5633
 
                  caipp->f_last_name = StringSave(f_last_name);
5634
 
                  caipp->f_first_name =StringSave(f_first_name);
5635
 
                  caipp->l_last_name = StringSave(l_last_name);
5636
 
                  caipp->l_first_name = StringSave(l_first_name);
5637
 
                  caipp->jour_volume = StringSave(jour_volume);
5638
 
                  caipp->jour_page = StringSave(jour_page);
5639
 
                  caipp->year = year;
5640
 
                  caipp->art_title = StringSave(art_title);
5641
 
                  caipp->rank = rank;
5642
 
                        
5643
 
        /*}       end if prepub*/       
 
5298
              /* get article title */
 
5299
              for (art_title_vnp=cap->title; art_title_vnp; art_title_vnp=art_title_vnp->next) {
 
5300
                /*could combine the four*/
 
5301
                if((art_title_vnp->choice == Cit_title_name) || (art_title_vnp->choice == Cit_title_tsub)|| (art_title_vnp->choice == Cit_title_trans)) {
 
5302
                  art_title = art_title_vnp->data.ptrvalue;                 
 
5303
                }
 
5304
              }
 
5305
 
 
5306
              /* get journal title */
 
5307
              for (title_vnp=cjp->title; title_vnp; title_vnp=title_vnp->next) {
 
5308
                /*could combine the four*/
 
5309
                if (title_vnp->choice == Cit_title_iso_jta) {
 
5310
                  jour_title = title_vnp->data.ptrvalue;                    
 
5311
                }
 
5312
                else if (title_vnp->choice == Cit_title_ml_jta) {
 
5313
                  jour_title = title_vnp->data.ptrvalue;
 
5314
                }
 
5315
                else if (title_vnp->choice == Cit_title_jta) {
 
5316
                  jour_title = title_vnp->data.ptrvalue;
 
5317
                }
 
5318
                else if (title_vnp->choice == Cit_title_name) {
 
5319
                  jour_title = title_vnp->data.ptrvalue;
 
5320
                  /* break;            don't need break ??? */
 
5321
                }
 
5322
                else { 
 
5323
                  jour_title = "this journal got a WEIRD title";
 
5324
                }
 
5325
              }
 
5326
          
 
5327
          
 
5328
              if (ImpPtr->volume) {
 
5329
                jour_volume =  ImpPtr->volume;
 
5330
              }
 
5331
          
 
5332
              if (ImpPtr->pages) { 
 
5333
                jour_page =  ImpPtr->pages;
 
5334
              }
 
5335
        
 
5336
          
 
5337
              /* not ideal behavior, although date is required in imp*/
 
5338
              if ((DatePtr)ImpPtr->date != NULL) {        
 
5339
                      DateRead (ImpPtr->date, &year, NULL, NULL, NULL);
 
5340
                    }
 
5341
 
 
5342
                    alp = (AuthListPtr) cap->authors; 
 
5343
                    if (alp != NULL) {                                                                  
 
5344
                      /*get ptr to both 1st and last author*/    
 
5345
                      auth_vnp = (ValNodePtr) alp->names; /*get the first node */ 
 
5346
                
 
5347
                      f_author_p = (AuthorPtr)auth_vnp->data.ptrvalue;
 
5348
                      l_author_p =(AuthorPtr)auth_vnp->data.ptrvalue;
 
5349
                
 
5350
                      /* get the node for the last author, but ignore consortium */
 
5351
                      while (auth_vnp->next) {
 
5352
                        auth_vnp = auth_vnp->next;
 
5353
                        ap = (AuthorPtr) auth_vnp->data.ptrvalue;
 
5354
                        if (ap != NULL) {
 
5355
                          pid = (PersonIdPtr) ap->name;
 
5356
                          if (pid != NULL) {
 
5357
                            if (pid->choice == 2) {
 
5358
                              l_author_p =(AuthorPtr)auth_vnp->data.ptrvalue;
 
5359
                            }
 
5360
                          }
 
5361
                        }
 
5362
                      }
 
5363
                
 
5364
                      /* should be analyzing the value of alp->choice,  not alp->names->choice*/
 
5365
                      if (alp->choice == 1) {
 
5366
            /* std */   
 
5367
            f_last_name = GetLastNameFromPersonId (f_author_p->name);
 
5368
                        l_last_name = GetLastNameFromPersonId (l_author_p->name);
 
5369
                      } else if (alp->choice == 2) {               
 
5370
            /* full name as last name*/        
 
5371
                        f_last_name = (CharPtr)f_author_p;
 
5372
                        l_last_name = (CharPtr)l_author_p;
 
5373
                      } else {  
 
5374
                        /* full name as last name*/            
 
5375
                        f_last_name = (CharPtr)f_author_p;
 
5376
                        l_last_name = (CharPtr)l_author_p;
 
5377
                      }                                    
 
5378
                    }                   
5644
5379
      }        /*end if cit-art*/      
5645
5380
    }          /*end if Pub_article*/    
5646
5381
  }  /* end for, looped through all valnodes of pub*/
5652
5387
    ArrowCursor ();
5653
5388
    Update ();
5654
5389
 
5655
 
    MemFree(caipp);
5656
 
    return;
5657
 
  }
 
5390
    return;
 
5391
  }
 
5392
 
 
5393
  if ( (caipp = MemNew(sizeof(CitArtInPress))) == NULL) {
 
5394
    return;
 
5395
  }
 
5396
 
 
5397
        caipp->jour_title =  StringSave(jour_title);
 
5398
        caipp->f_last_name = StringSave(f_last_name);
 
5399
        caipp->l_last_name = StringSave(l_last_name);
 
5400
        caipp->jour_volume = StringSave(jour_volume);
 
5401
        caipp->jour_page = StringSave(jour_page);
 
5402
        caipp->year = year;
 
5403
        caipp->art_title = StringSave(art_title);
5658
5404
  
5659
5405
  cufp->caipp = caipp;
5660
5406
 
5686
5432
 
5687
5433
  if (caipp == NULL) return;
5688
5434
 
5689
 
  year = MemNew(5);
5690
 
  sprintf(year, "%d", caipp->year); 
5691
 
 
5692
 
  SafeSetTitle (cufp->f_auth_text,caipp->f_last_name);
5693
 
  SafeSetTitle (cufp->l_auth_text,caipp->l_last_name);
5694
 
  SafeSetTitle (cufp->journal_text,caipp->jour_title);
5695
 
  SafeSetTitle (cufp->year_text, year);
5696
 
  SafeSetTitle (cufp->volume_text,caipp->jour_volume);
5697
 
  SafeSetTitle (cufp->page_text,caipp->jour_page);
5698
 
 
5699
 
  SafeSetTitle (cufp->art_title_text, caipp->art_title);
 
5435
  if (caipp->year > -1) {
 
5436
    year = MemNew(5);
 
5437
    sprintf(year, "%d", caipp->year); 
 
5438
    SafeSetTitle (cufp->year_text, year);
 
5439
  } else {
 
5440
    SetTitle (cufp->year_text, "");
 
5441
  }
 
5442
 
 
5443
  if (caipp->f_last_name == NULL) {
 
5444
    SetTitle (cufp->f_auth_text, "");
 
5445
  } else {
 
5446
    SafeSetTitle (cufp->f_auth_text, caipp->f_last_name);
 
5447
  }
 
5448
  if (caipp->l_last_name == NULL) {
 
5449
    SetTitle (cufp->l_auth_text, "");
 
5450
  } else {
 
5451
    SafeSetTitle (cufp->l_auth_text,caipp->l_last_name);
 
5452
  }
 
5453
  if (caipp->jour_title == NULL) {
 
5454
    SetTitle (cufp->journal_text, "");
 
5455
  } else {
 
5456
    SafeSetTitle (cufp->journal_text,caipp->jour_title);
 
5457
  }
 
5458
  if (caipp->jour_volume == NULL) {
 
5459
    SetTitle (cufp->volume_text, "");
 
5460
  } else {
 
5461
    SafeSetTitle (cufp->volume_text,caipp->jour_volume);
 
5462
  }
 
5463
  if (caipp->jour_page== NULL) {
 
5464
    SetTitle (cufp->page_text, "");
 
5465
  } else {
 
5466
    SafeSetTitle (cufp->page_text,caipp->jour_page);
 
5467
  }
 
5468
 
 
5469
  if (caipp->art_title == NULL) {
 
5470
    SetTitle (cufp->art_title_text, "");
 
5471
  } else {
 
5472
    SafeSetTitle (cufp->art_title_text, caipp->art_title);
 
5473
  }
5700
5474
  SafeSetTitle (cufp->extra_term_text, "");
5701
5475
 
5702
5476
  SetValue (cufp->new_query, 1); /* reset the popup to default query after an update*/