NCBI C++ ToolKit
PubmedBookArticle.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: PubmedBookArticle.cpp 98428 2022-11-14 14:16:14Z grichenk $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'efetch.xsd'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
40 
41 
42 // generated includes
44 
45 // generated classes
46 
47 BEGIN_eutils_SCOPE // namespace eutils::
48 
52 
53 // destructor
55 {
56 }
57 
58 
60 
61 static CRef<CAuth_list> s_GetAuthorList(const CBookDocument::TAuthorList& list_author_list, bool empty_ok)
62 {
63  CRef<CAuth_list> auth_list;
64  if (!empty_ok && list_author_list.empty()) return auth_list;
65  if (!empty_ok && all_of(list_author_list.begin(), list_author_list.end(),
66  [](const CRef<CAuthorList>& author_list_element) -> bool {
67  return author_list_element->GetAuthor().empty(); })) return auth_list;
68 
69  bool std_format = any_of(list_author_list.begin(), list_author_list.end(),
70  [](const CRef<CAuthorList>& author_list_element) -> bool {
71  auto list_author = author_list_element->GetAuthor();
72  bool attr_editors = author_list_element->GetAttlist().IsSetType() &&
73  author_list_element->GetAttlist().GetType() == CAuthorList::C_Attlist::eAttlist_Type_editors;
74  return attr_editors || any_of( list_author.begin(), list_author.end(),
75  [](const CRef<CAuthor>& author_element) -> bool { return author_element->GetLC().IsCollectiveName(); } );
76  });
78  if (!std_format) auth_names->SetMl();
79  for (const auto& author_list_element : list_author_list) {
80  for (const auto& author_element : author_list_element->GetAuthor() ) {
81  CRef<CPerson_id> person(new CPerson_id());
82  if (author_element->GetLC().IsCollectiveName()) {
83  person->SetConsortium(s_CleanupText(
84  s_TextListToString(author_element->GetLC().GetCollectiveName().Get())));
85  CRef<objects::CAuthor> auth(new objects::CAuthor());
86  auth->SetName(*person);
87  if (author_list_element->GetAttlist().GetType() == CAuthorList::C_Attlist::eAttlist_Type_editors)
88  auth->SetRole(objects::CAuthor::eRole_editor);
89  auth_names->SetStd().push_back(auth);
90  }
91  else {
92  string medline_name = s_CleanupText(s_GetAuthorMedlineName(*author_element));
93  if (std_format) {
94  person->SetMl(medline_name);
95  CRef<objects::CAuthor> auth(new objects::CAuthor());
96  auth->SetName(*person);
97  if (author_list_element->GetAttlist().GetType() == CAuthorList::C_Attlist::eAttlist_Type_editors)
98  auth->SetRole(objects::CAuthor::eRole_editor);
99  auth_names->SetStd().push_back(auth);
100  }
101  else {
102  auth_names->SetMl().push_back(medline_name);
103  }
104  }
105  }
106  }
107  auth_list.Reset(new CAuth_list());
108  auth_list->SetNames(*auth_names);
109  return auth_list;
110 }
111 
112 
113 static CRef<CTitle> s_GetBookTitle(const CPubmedBookArticle& pubmed_article)
114 {
115  CRef<CTitle> title(new CTitle());
116  const auto& book = pubmed_article.GetBookDocument().GetBook();
117  string title_str = s_TextListToString(book.GetBookTitle().GetBookTitle());
118  CRef<CTitle::C_E> name(new CTitle::C_E());
119  name->SetName(s_CleanupText(title_str));
120  title->Set().push_back(name);
121  if (book.IsSetIsbn()) {
122  for (const auto& isbn_element : book.GetIsbn()) {
123  CRef<CTitle::C_E> name(new CTitle::C_E());
124  name->SetIsbn(s_CleanupText(isbn_element->Get()));
125  title->Set().push_back(name);
126  }
127  }
128  return title;
129 }
130 
131 
133 {
134  switch (status) {
136  return ePubStatus_received;
138  return ePubStatus_accepted;
140  return ePubStatus_epublish;
142  return ePubStatus_ppublish;
144  return ePubStatus_revised;
148  return ePubStatus_pmc;
150  return ePubStatus_pmcr;
152  return ePubStatus_pubmed;
154  return ePubStatus_pubmedr;
156  return ePubStatus_premedline;
158  return ePubStatus_medline;
159  default:
160  return ePubStatus_other;
161  }
162 }
163 
164 
165 static CRef<CImprint> s_GetImprint(const CPubmedBookArticle& pubmed_article)
166 {
167  const auto& book_document = pubmed_article.GetBookDocument();
168  const auto& book = book_document.GetBook();
169  const auto& book_data = pubmed_article.GetPubmedBookData();
170  CRef<CImprint> imprint(new CImprint());
171  imprint->SetDate(*s_GetDateFromPubDate(book.GetPubDate()));
172  if (book.IsSetVolume()) {
173  imprint->SetVolume(s_CleanupText(book.GetVolume()));
174  }
175  if (book_document.IsSetPagination()) {
176  imprint->SetPages(s_GetPagination(book_document.GetPagination()));
177  }
178  const auto& list_language = book_document.GetLanguage();
179  if (!list_language.empty()) {
180  string langiages = accumulate(next(list_language.begin()), list_language.end(), (*list_language.begin())->Get(),
181  [](const string& x, const CRef<CLanguage>& e) -> string { return x + "," + e->Get(); } );
182  imprint->SetLanguage(langiages);
183  }
184  imprint->SetPubstatus(s_GetPublicationStatusId(book_data.GetPublicationStatus().Get()));
185  if (book_data.IsSetHistory()) {
187  for (const auto& pub_date : book_data.GetHistory().GetPubMedPubDate()) {
188  CRef<CPubStatusDate> pub_stat_date(new CPubStatusDate());
189  pub_stat_date->SetPubstatus(s_GetPubStatus(pub_date->GetAttlist().GetPubStatus()));
190  pub_stat_date->SetDate(*s_GetDateFromPubMedPubDate(*pub_date));
191  date_set->Set().push_back(pub_stat_date);
192  }
193  imprint->SetHistory(*date_set);
194  }
195  return imprint;
196 }
197 
198 
199 static CRef<CCit_book> s_GetBook(const CPubmedBookArticle& pubmed_article)
200 {
201  CRef<CCit_book> cit_book(new CCit_book());
202  cit_book->SetTitle(*s_GetBookTitle(pubmed_article));
203  if (pubmed_article.GetBookDocument().GetBook().IsSetCollectionTitle()) {
204  CRef<CTitle::C_E> name(new CTitle::C_E());
205  name->SetName(s_CleanupText(
207  CRef<CTitle> title(new CTitle());
208  title->Set().push_back(name);
209  cit_book->SetColl(*title);
210  }
211  auto auth_list = s_GetAuthorList(pubmed_article.GetBookDocument().GetBook().GetAuthorList(), true );
212  if (auth_list) {
213  cit_book->SetAuthors(*auth_list);
214  }
215  cit_book->SetImp(*s_GetImprint(pubmed_article));
216  return cit_book;
217 }
218 
219 
220 static CRef<CCit_art> s_GetCitation(const CPubmedBookArticle& pubmed_article)
221 {
222  CRef<CCit_art> cit_article(new CCit_art());
223  auto title = s_GetTitle(pubmed_article.GetBookDocument());
224  if (title) {
225  cit_article->SetTitle(*title);
226  }
227  auto author_list = s_GetAuthorList(pubmed_article.GetBookDocument().GetAuthorList(), false);
228  if (author_list) {
229  cit_article->SetAuthors(*author_list);
230  }
232  from->SetBook(*s_GetBook(pubmed_article));
233  cit_article->SetFrom(*from);
234  cit_article->SetIds(*s_GetArticleIdSet(pubmed_article.GetPubmedBookData().GetArticleIdList(), nullptr));
235  return cit_article;
236 }
237 
238 
240 {
241  CRef<CMedline_entry> medline_entry(new CMedline_entry());
242  if (pubmed_article.GetPubmedBookData().IsSetHistory()) {
243  const auto& dates = pubmed_article.GetPubmedBookData().GetHistory().GetPubMedPubDate();
244  auto created_date_element = find_if(dates.begin(), dates.end(),
245  [](const CRef<CPubMedPubDate>& date_element) -> bool {
246  return date_element->GetAttlist().GetPubStatus() == CPubMedPubDate::C_Attlist::eAttlist_PubStatus_entrez; });
247  if (created_date_element != dates.end())
248  medline_entry->SetEm(*s_GetDateFromPubMedPubDate(**created_date_element));
249  }
250  else {
251  medline_entry->SetEm(*s_GetDateFromPubDate(pubmed_article.GetBookDocument().GetBook().GetPubDate()));
252  }
253  medline_entry->SetCit(*s_GetCitation(pubmed_article));
254  if (pubmed_article.GetBookDocument().IsSetAbstract()) {
255  string abstract_text = s_CleanupText(s_GetAbstractText(pubmed_article.GetBookDocument().GetAbstract()));
256  medline_entry->SetAbstract(abstract_text);
257  }
258  if (pubmed_article.GetBookDocument().IsSetGrantList()) {
259  s_FillGrants(medline_entry->SetIdnum(), pubmed_article.GetBookDocument().GetGrantList());
260  }
261  try {
262  medline_entry->SetPmid(CPubMedId(
263  NStr::StringToNumeric<TEntrezId>(pubmed_article.GetBookDocument().GetPMID().GetPMID())));
264  }
265  catch (...) {}
266  medline_entry->SetStatus(medline_entry->eStatus_publisher);
267  return medline_entry;
268 }
269 
270 
272 
273 
275 {
276  CRef<CPubmed_entry> pubmed_entry(new CPubmed_entry());
277  try {
278  pubmed_entry->SetPmid(CPubMedId(
279  NStr::StringToNumeric<TEntrezId>(GetBookDocument().GetPMID().GetPMID())));
280  }
281  catch (...) {}
282  pubmed_entry->SetMedent(*s_GetMedlineEntry(*this));
283  return pubmed_entry;
284 }
285 
286 
287 END_eutils_SCOPE // namespace eutils::
288 
289 /* Original file checksum: lines: 53, chars: 1708, CRC32: d8a53f84 */
#define BEGIN_eutils_SCOPE
Definition: Abstract_.hpp:51
#define END_eutils_SCOPE
Definition: Abstract_.hpp:52
static string s_GetAbstractText(const CAbstract &abstr)
static EPubStatus s_GetPublicationStatusId(const string &publication_status)
User-defined methods of the data storage class.
ncbi::CRef< ncbi::objects::CArticleIdSet > s_GetArticleIdSet(const CArticleIdList &article_id_list, const CArticle *article)
void s_FillGrants(std::list< std::string > &id_nums, const CGrantList &grant_list)
std::string s_GetPagination(const CPagination &pagination)
ncbi::CRef< ncbi::objects::CDate > s_GetDateFromPubDate(const CPubDate &pub_date)
ncbi::CRef< ncbi::objects::CDate > s_GetDateFromPubMedPubDate(const CPubMedPubDate &pdate)
std::string s_TextListToString(const std::list< ncbi::CRef< TE >> &text_list)
ncbi::CRef< ncbi::objects::CTitle > s_GetTitle(const D &doc)
std::string s_CleanupText(std::string str)
std::string s_GetAuthorMedlineName(const CAuthor &author)
USING_SCOPE(objects)
static int s_GetPubStatus(CPubMedPubDate::C_Attlist::EAttlist_PubStatus status)
static CRef< CMedline_entry > s_GetMedlineEntry(const CPubmedBookArticle &pubmed_article)
BEGIN_LOCAL_NAMESPACE
static CRef< CTitle > s_GetBookTitle(const CPubmedBookArticle &pubmed_article)
static CRef< CImprint > s_GetImprint(const CPubmedBookArticle &pubmed_article)
static CRef< CCit_art > s_GetCitation(const CPubmedBookArticle &pubmed_article)
END_LOCAL_NAMESPACE
static CRef< CAuth_list > s_GetAuthorList(const CBookDocument::TAuthorList &list_author_list, bool empty_ok)
static CRef< CCit_book > s_GetBook(const CPubmedBookArticle &pubmed_article)
USING_NCBI_SCOPE
BEGIN_eutils_SCOPE NCBI_USING_NAMESPACE_STD
User-defined methods of the data storage class.
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
journal or book
Definition: Cit_art_.hpp:98
CImprint –.
Definition: Imprint.hpp:66
CPubStatusDateSet –.
CPubStatusDate –.
ncbi::CRef< ncbi::objects::CPubmed_entry > ToPubmed_entry(void) const
CPubmed_entry –.
C_E –.
Definition: Title_.hpp:96
Definition: Title.hpp:51
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:56
void SetPages(const TPages &value)
Assign a value to Pages data member.
Definition: Imprint_.hpp:861
void SetIds(TIds &value)
Assign a value to Ids data member.
Definition: Cit_art_.cpp:258
void SetTitle(TTitle &value)
Assign a value to Title data member.
Definition: Cit_art_.cpp:210
void SetTitle(TTitle &value)
Assign a value to Title data member.
Definition: Cit_book_.cpp:62
void SetFrom(TFrom &value)
Assign a value to From data member.
Definition: Cit_art_.cpp:248
void SetLanguage(const TLanguage &value)
Assign a value to Language data member.
Definition: Imprint_.hpp:1054
void SetAuthors(TAuthors &value)
Assign a value to Authors data member.
Definition: Cit_art_.cpp:227
void SetColl(TColl &value)
Assign a value to Coll data member.
Definition: Cit_book_.cpp:72
void SetImp(TImp &value)
Assign a value to Imp data member.
Definition: Cit_book_.cpp:107
void SetVolume(const TVolume &value)
Assign a value to Volume data member.
Definition: Imprint_.hpp:767
void SetAuthors(TAuthors &value)
Assign a value to Authors data member.
Definition: Cit_book_.cpp:93
void SetDate(TDate &value)
Assign a value to Date data member.
Definition: Imprint_.cpp:73
void SetHistory(THistory &value)
Assign a value to History data member.
Definition: Imprint_.cpp:170
void SetPubstatus(TPubstatus value)
Assign a value to Pubstatus data member.
Definition: Imprint_.hpp:1223
Tdata & Set(void)
Assign a value to data member.
Tdata & Set(void)
Assign a value to data member.
Definition: Title_.hpp:787
@ ePubStatus_pubmed
article citation first appeared in PubMed
Definition: PubStatus_.hpp:73
@ ePubStatus_accepted
accepted for publication
Definition: PubStatus_.hpp:67
@ ePubStatus_ppublish
published in print by publisher
Definition: PubStatus_.hpp:69
@ ePubStatus_premedline
date into PreMedline status
Definition: PubStatus_.hpp:76
@ ePubStatus_revised
article revised by publisher/author
Definition: PubStatus_.hpp:70
@ ePubStatus_received
date manuscript received for review
Definition: PubStatus_.hpp:66
@ ePubStatus_other
Definition: PubStatus_.hpp:78
@ ePubStatus_pubmedr
article citation revision in PubMed
Definition: PubStatus_.hpp:74
@ ePubStatus_aheadofprint
epublish, but will be followed by print
Definition: PubStatus_.hpp:75
@ ePubStatus_medline
date made a MEDLINE record
Definition: PubStatus_.hpp:77
@ ePubStatus_epublish
published electronically by publisher
Definition: PubStatus_.hpp:68
@ ePubStatus_pmc
article first appeared in PubMed Central
Definition: PubStatus_.hpp:71
@ ePubStatus_pmcr
article revision in PubMed Central
Definition: PubStatus_.hpp:72
void SetEm(TEm &value)
Assign a value to Em data member.
TIdnum & SetIdnum(void)
Assign a value to Idnum data member.
void SetStatus(TStatus value)
Assign a value to Status data member.
void SetCit(TCit &value)
Assign a value to Cit data member.
void SetAbstract(const TAbstract &value)
Assign a value to Abstract data member.
void SetPmid(const TPmid &value)
Assign a value to Pmid data member.
@ eStatus_publisher
record as supplied by publisher
const TAuthorList & GetAuthorList(void) const
Get the AuthorList member data.
Definition: Book_.hpp:860
const TCollectionTitle & GetCollectionTitle(void) const
Get the CollectionTitle member data.
const TBook & GetBook(void) const
Get the Book member data.
bool IsSetHistory(void) const
Check if a value has been assigned to History data member.
const TPMID & GetPMID(void) const
Get the PMID member data.
const TPMID & GetPMID(void) const
Get the PMID member data.
Definition: PMID_.hpp:367
const TPubDate & GetPubDate(void) const
Get the PubDate member data.
Definition: Book_.hpp:788
const TGrantList & GetGrantList(void) const
Get the GrantList member data.
bool IsSetGrantList(void) const
Check if a value has been assigned to GrantList data member.
const TAuthorList & GetAuthorList(void) const
Get the AuthorList member data.
const TPubmedBookData & GetPubmedBookData(void) const
Get the PubmedBookData member data.
const TPubMedPubDate & GetPubMedPubDate(void) const
Get the PubMedPubDate member data.
Definition: History_.hpp:167
const THistory & GetHistory(void) const
Get the History member data.
bool IsSetAbstract(void) const
Check if a value has been assigned to Abstract data member.
NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< CAuthorList > > TAuthorList
const TCollectionTitle & GetCollectionTitle(void) const
Get the CollectionTitle member data.
Definition: Book_.hpp:969
const TArticleIdList & GetArticleIdList(void) const
Get the ArticleIdList member data.
const TAbstract & GetAbstract(void) const
Get the Abstract member data.
bool IsSetCollectionTitle(void) const
Check if a value has been assigned to CollectionTitle data member.
Definition: Book_.hpp:957
const TBookDocument & GetBookDocument(void) const
Get the BookDocument member data.
Modified on Fri Sep 20 14:58:06 2024 by modify_doxy.py rev. 669887