ncbi 0.2.0-beta

Rust data structures for NCBI APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
//! Bibliographic data elements
//! Adapted from ["biblio.asn"](https://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/biblio/biblio.asn)

use crate::general::{Date, DbTag, PersonId};
use crate::parsing::{read_vec_node, read_node, read_string, UnexpectedTags};
use crate::parsing::{XmlNode, XmlVecNode};
use quick_xml::events::{BytesStart, Event};
use quick_xml::Reader;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
/// represents multiple ways to id an article
pub enum ArticleId {
    PubMed(PubMedId),
    Medline(MedlineUID),
    DOI(DOI),
    PmcId(PmcID),
    PmPid(PmPid),

    /// generic catch all
    Other(DbTag),
}

/// id from the PubMed database at NCBI
pub type PubMedId = u64;

/// id from MEDLINE
pub type MedlineUID = u64;

/// Document Object Identifier
pub type DOI = String;

/// Controlled Publisher Identifier
pub type PII = String;

/// PubMed Central Id
pub type PmcID = u64;

/// Publisher Id supplied to PubMed Central
pub type PmcPid = String;

/// Publisher Id supplied to PubMed
pub type PmPid = String;

pub type ArticleIdSet = Vec<ArticleId>;

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
/// points of publication
///
/// # Notes
///
/// Originally implement as `INTEGER`. Therefore, it is assumed that serialized
/// representation is an 8-bit integer.
pub enum PubStatus {
    /// date manuscript received for review
    Received = 1,

    /// accepted for publication
    Accepted,

    /// published electronically by publisher
    EPublish,

    /// published in print by publisher
    PPublish,

    /// article revised by publisher/author
    Revised,

    /// article first appeared in PubMed Central
    PMC,

    /// article revision in PubMed Central
    PMCR,

    /// article first citation appeared in PubMed
    PubMed,

    /// article citation revision in PubMed
    PubMedR,

    /// epublish, but will be followed by print
    AheadOfPrint,

    /// date into PreMedline status
    PreMedline,

    /// date made a MEDLINE record
    Medline,

    Other = 255,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
/// done as a struct so fields can be added
pub struct PubStatusDate {
    pub pubstatus: PubStatus,
    /// time may be added later
    pub date: Date,
}

pub type PubStatusDateSet = Vec<PubStatusDate>;

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
/// journal or book
pub enum CitArtFrom {
    Journal(CitJour),
    Book(CitBook),
    Proc(CitProc),
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
/// Article in journal or book
pub struct CitArt {
    /// title or paper (ANSI requires)
    pub title: Option<Title>,

    /// authors (ANSI requires)
    pub authors: Option<AuthList>,

    /// journal or book
    pub from: CitArtFrom,

    pub ids: Option<ArticleIdSet>,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
/// journal citation
pub struct CitJour {
    /// title of journal
    pub title: Title,
    pub imp: Imprint,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
/// book citation
pub struct CitBook {
    /// title of book
    pub title: Title,

    /// part of a collection
    pub coll: Option<Title>,

    /// authors
    pub authors: AuthList,

    pub imp: Imprint,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
/// meeting proceedings
pub struct CitProc {
    /// citation to meeting
    pub book: CitBook,
    /// time and location of meeting
    pub meet: Meeting,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
/// Patent citation
pub struct CitPat {
    pub title: String,

    /// author/inventor
    pub authors: AuthList,

    /// patent document country
    pub country: String,

    /// patent document type
    pub doc_type: String,

    /// patent document number
    pub number: Option<String>,

    /// patent issue/pub date
    pub date_issue: Option<Date>,

    /// patent doc class code
    pub class: Option<Vec<String>>,

    /// patent doc application number
    pub app_number: Option<String>,

    /// patent application file date
    pub app_date: Option<Date>,

    /// applicants
    pub applicants: Option<AuthList>,

    /// assignees
    pub assignees: Option<AuthList>,

    /// priorities
    pub priority: Option<Vec<PatentPriority>>,

    #[serde(rename = "abstract")]
    /// abstract of patent
    pub r#abstract: Option<String>,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct PatentPriority {
    /// patent country code
    pub country: String,

    /// number assigned in that country
    pub number: String,

    /// date of application
    pub date: Date,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum IdPatChoice {
    /// patent document number
    Number(String),

    /// patent doc application number
    AppNumber(String),
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
/// identifies a patent
pub struct IdPat {
    /// patent document country
    pub country: String,

    pub id: IdPatChoice,

    ///patent doc type
    pub doc_type: Option<String>,
}

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
/// # Note
///
/// Original implementation lists this as `ENUMERATED`, therefore it is assumed that
/// serialized representation is an integer
pub enum CitLetType {
    Manuscript = 1,
    Letter,
    Thesis,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
/// cite a letter, thesis, or manuscript
pub struct CitLet {
    /// same fields as a book
    pub cit: CitBook,

    /// manuscript identifier
    pub man_id: Option<String>,

    #[serde(rename = "type")]
    pub r#type: CitLetType,
}

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
/// Internal representation for medium of submission for `medium` in [`CitSub`]
///
/// # Note
///
/// Original implementation lists this as `ENUMERATED`, therefore it is assumed that
/// serialized representation is an integer
pub enum CitSubMedium {
    #[default]
    Paper = 1,
    Tape,
    Floppy,
    Email,
    Other = 255,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
/// Cite a direct data submission
///
/// # Original Comment
///     See "NCBI-Submit" for the form of a direct sequence submission
pub struct CitSub {
    /// not necessarily authors of the paper
    pub authors: AuthList,

    /// only used to get date.
    ///
    /// Might be deprecated soon.
    pub imp: Option<Imprint>,

    /// medium of submission
    pub medium: CitSubMedium,

    /// replaces imp, will become required
    pub date: Option<Date>,

    /// description of changes for public view
    pub descr: Option<String>,
}

impl CitSub {
    pub fn new(authors: AuthList) -> Self {
        Self {
            authors,
            imp: None,
            medium: Default::default(),
            date: None,
            descr: None,
        }
    }
}

impl XmlNode for CitSub {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Cit-sub")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        let authors_element = BytesStart::new("Cit-sub_authors");
        let date_element = BytesStart::new("Cit-sub_date");

        let mut cit = CitSub::new(AuthList {
            names: AuthListNames::Std(vec![]),
            affil: None,
        });

        let forbidden = UnexpectedTags(&[]);

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == authors_element.name() {
                        cit.authors = read_node(reader).unwrap();
                    } else if name == date_element.name() {
                        cit.date = read_node(reader);
                    } else if name != Self::start_bytes().name() {
                        forbidden.check(&name);
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        break;
                    }
                }
                _ => (),
            }
        }

        cit.into()
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
#[serde(rename_all = "kebab-case")]
/// NOT from ANSI, this is a catchall
pub struct CitGen {
    /// anything, not parsable
    pub cit: Option<String>,

    pub authors: Option<AuthList>,

    /// medline uid
    pub muid: Option<u64>,

    pub journal: Option<Title>,
    pub volume: Option<String>,
    pub issue: Option<String>,
    pub pages: Option<String>,
    pub date: Option<Date>,

    /// for GenBank style references
    pub serial_number: Option<u64>,

    /// eg. cit="unpublished",title="title"
    pub title: Option<String>,

    /// PubMed Id
    pub pmid: Option<PubMedId>,
}

impl XmlNode for CitGen {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Cit-gen")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        let mut gen = CitGen::default();

        // elements
        let cit_element = BytesStart::new("Cit-gen_cit");
        let authors_element = BytesStart::new("Cit-gen_authors");
        let title_element = BytesStart::new("Cit-gen_title");

        let forbidden = UnexpectedTags(&[]);

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == cit_element.name() {
                        gen.cit = read_string(reader);
                    } else if name == title_element.name() {
                        gen.title = read_string(reader);
                    } else if name == authors_element.name() {
                        gen.authors = read_node(reader);
                    } else if name != Self::start_bytes().name() {
                        forbidden.check(&name)
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        return gen.into();
                    }
                }
                _ => (),
            }
        }
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum AuthListNames {
    /// full citations
    Std(Vec<Author>),

    /// MEDLINE, semi-structured
    Ml(Vec<String>),

    /// free-for-all
    Str(Vec<String>),
}

/// Explicit definition instead of using derive
///
/// This default is not in original NCBI spec,
/// therefore, it is subject to change
impl Default for AuthListNames {
    fn default() -> Self {
        Self::Str(vec![])
    }
}

impl XmlNode for AuthListNames {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Auth-list_names")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        // variants
        let std_element = BytesStart::new("Auth-list_names_std");

        let forbidden = UnexpectedTags(&[]);

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == std_element.name() {
                        return Self::Std(read_vec_node(reader, std_element.to_end())).into();
                    } else if name == Self::start_bytes().name() {
                        forbidden.check(&name);
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        return None;
                    }
                }
                _ => (),
            }
        }
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
/// authorship group
pub struct AuthList {
    pub names: AuthListNames,

    /// author affiliation
    pub affil: Option<Affil>,
}

impl XmlNode for AuthList {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Auth-list")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        let mut list = AuthList::default();

        let names_element = BytesStart::new("Auth-list_names");
        let affil_element = BytesStart::new("Auth-list_affil");

        let forbidden = UnexpectedTags(&[]);

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == names_element.name() {
                        list.names = read_node(reader).unwrap();
                    } else if name == affil_element.name() {
                        list.affil = read_node(reader);
                    } else if name != Self::start_bytes().name() {
                        forbidden.check(&name);
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        return list.into();
                    }
                }
                _ => (),
            }
        }
    }
}

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
/// # Note
///
/// Original implementation lists this as `ENUMERATED`, therefore it is assumed that
/// serialized representation is an integer
pub enum AuthorLevel {
    Primary = 1,
    Secondary,
}

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
/// # Note
///
/// Original implementation lists this as `ENUMERATED`, therefore it is assumed that
/// serialized representation is an integer
pub enum AuthorRole {
    Compiler = 1,
    Editor,
    PatentAssignee,
    Translator,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Author {
    /// author, primary, or secondary
    pub name: PersonId,
    pub level: Option<AuthorLevel>,

    /// author role indicator
    pub role: Option<AuthorRole>,

    pub affil: Option<Affil>,

    /// true if [corresponding author](https://scientific-publishing.webshop.elsevier.com/publication-recognition/what-corresponding-author/)
    pub is_corr: Option<bool>,
}

impl Author {
    pub fn new(name: PersonId) -> Self {
        Self {
            name,
            level: None,
            role: None,
            affil: None,
            is_corr: None,
        }
    }
}

impl XmlNode for Author {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Author")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        let mut author = Author::new(PersonId::default());

        let name_element = BytesStart::new("Author_name");

        let forbidden = UnexpectedTags(&[]);

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == name_element.name() {
                        author.name = read_node(reader).unwrap();
                    } else {
                        forbidden.check(&name);
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        return author.into();
                    }
                }
                _ => (),
            }
        }
    }
}
impl XmlVecNode for Author {}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
#[serde(rename_all = "kebab-case")]
/// std representation for affiliations
pub struct AffilStd {
    /// Author Affiliation, Name
    pub affil: Option<String>,

    /// Author Affiliation, Division
    pub div: Option<String>,

    /// Author Affiliation, City
    pub city: Option<String>,

    /// Author Affiliation, County Sub
    pub sub: Option<String>,

    /// Author Affiliation, Country
    pub country: Option<String>,

    /// street address, not ANSI
    pub street: Option<String>,

    pub email: Option<String>,
    pub fax: Option<String>,
    pub phone: Option<String>,
    pub postal_code: Option<String>,
}

impl XmlNode for AffilStd {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Affil_std")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        let mut affil = AffilStd::default();

        // elements
        let affil_element = BytesStart::new("Affil_std_affil");
        let div_element = BytesStart::new("Affil_std_div");
        let city_element = BytesStart::new("Affil_std_city");
        let sub_element = BytesStart::new("Affil_std_sub");
        let country_element = BytesStart::new("Affil_std_country");
        let street_element = BytesStart::new("Affil_std_street");
        let postal_code_element = BytesStart::new("Affil_std_postal-code");

        let forbidden = UnexpectedTags(&[]);

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == affil_element.name() {
                        affil.affil = read_string(reader);
                    } else if name == div_element.name() {
                        affil.div = read_string(reader);
                    } else if name == city_element.name() {
                        affil.city = read_string(reader);
                    } else if name == sub_element.name() {
                        affil.sub = read_string(reader);
                    } else if name == country_element.name() {
                        affil.country = read_string(reader);
                    } else if name == street_element.name() {
                        affil.street = read_string(reader);
                    } else if name == postal_code_element.name() {
                        affil.postal_code = read_string(reader);
                    } else if name != Self::start_bytes().name() {
                        forbidden.check(&name);
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        return affil.into();
                    }
                }
                _ => (),
            }
        }
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum Affil {
    /// unparsed string
    Str(String),

    /// std representation
    Std(AffilStd),
}

impl XmlNode for Affil {
    fn start_bytes() -> BytesStart<'static> {
        BytesStart::new("Affil")
    }

    fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
    where
        Self: Sized,
    {
        // variants
        let str_element = BytesStart::new("Affil_str");
        let std_element = BytesStart::new("Affil_std");

        loop {
            match reader.read_event().unwrap() {
                Event::Start(e) => {
                    let name = e.name();

                    if name == std_element.name() {
                        return Self::Std(read_node(reader).unwrap()).into();
                    }
                    if name == str_element.name() {
                        return Self::Str(read_string(reader).unwrap()).into();
                    }
                }
                Event::End(e) => {
                    if Self::is_end(&e) {
                        return None;
                    }
                }
                _ => (),
            }
        }
    }
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
/// title group
///
/// # Variants
///
/// Only certain variants are valid for certain types:
/// Valid for = A = Analytic [`CitArt`]
///             J = Journals [`CitJour`]
///             B = Book [`CitBook`]
pub enum TitleItem {
    /// Title, Anal,Coll,Mono
    /// Valid: AJB
    Name(String),

    /// Title, Subordinate
    /// Valid: A B
    TSub(String),

    /// Title, Translated
    /// Valid: AJB
    Trans(String),

    /// Title, Abbreviated
    /// Valid:  J
    Jta(String),

    #[serde(rename = "iso-jta")]
    /// Title, MEDLINE jta
    /// Valid:  J
    IsoJta(String),

    /// specifically ISO jta
    /// Valid:  J
    MlJta(String),

    /// a coden
    /// Valid:  J
    Coden(String),

    /// ISSN
    /// Valid:  J
    ISSN(String),

    /// Title, Abbreviated
    /// Valid:  B
    Abr(String),

    /// ISBN
    /// Valid:  B
    ISBN(String),
}

pub type Title = Vec<TitleItem>;

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
/// For pre-publication citations
///
/// # Note
///
/// Original implementation lists this as `ENUMERATED`, therefore it is assumed that
/// serialized representation is an integer
pub enum ImprintPrePub {
    /// submitted, not accepted
    Submitted = 1,

    /// accepted, not published
    InPress,

    Other = 255,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Imprint {
    /// date of publication
    pub date: Date,

    pub volume: Option<String>,
    pub issue: Option<String>,
    pub pages: Option<String>,
    pub section: Option<String>,

    #[serde(rename = "pub")]
    /// publisher, required for book
    pub r#pub: Option<Affil>,

    /// copyright date, required for book
    pub cprt: Option<Date>,

    /// part/sup of volume
    pub part_sup: Option<String>,

    /// put here for simplicity
    // TODO: default "ENG"
    pub language: Option<String>,

    /// for pre-publication citations
    pub prepub: Option<ImprintPrePub>,

    /// part/sup on issue
    pub part_supi: Option<String>,

    /// retraction info
    pub retract: Option<CitRetract>,

    /// current status of this publication
    pub pubstatus: Option<PubStatus>,

    /// dates for this record
    pub history: Option<PubStatusDateSet>,
}

#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
/// represents type of entry retraction
///
/// # Note
///
/// Original implementation lists this as `ENUMERATED`, therefore it is assumed that
/// serialized representation is an integer
pub enum CitRetractType {
    /// this citation is retracted
    Retracted = 1,

    /// this citation is a retraction notice
    Notice,

    /// an erratum was published about this
    InError,

    /// citation and/or explanation
    Erratum,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct CitRetract {
    #[serde(rename = "type")]
    /// retraction of an entry
    pub r#type: CitRetractType,

    /// citation and/or explanation
    pub exp: Option<String>,
}

#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct Meeting {
    pub number: String,
    pub date: Date,
    pub place: Option<Affil>,
}