dgc/
vaccination.rs

1use crate::lookup_value;
2use serde::{Deserialize, Serialize};
3use std::borrow::Cow;
4
5/// A vaccination entry.
6///
7/// It provides all the necessary detail regarding a vaccination record.
8#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
9pub struct Vaccination {
10    /// Targeted Disease or agent
11    #[serde(rename = "tg")]
12    pub targeted_disease: Cow<'static, str>,
13    /// Vaccine or prophylaxis
14    #[serde(rename = "vp")]
15    pub vaccine_prophylaxis: Cow<'static, str>,
16    /// Vaccine medicinal product
17    #[serde(rename = "mp")]
18    pub medicinal_product: Cow<'static, str>,
19    /// Marketing Authorization Holder - if no MAH present, then manufacturer
20    #[serde(rename = "ma")]
21    pub manufacturer: Cow<'static, str>,
22    /// Dose Number
23    #[serde(rename = "dn")]
24    pub dose_number: usize,
25    /// Total Series of Doses
26    #[serde(rename = "sd")]
27    pub total_doses: usize,
28    /// ISO8601 complete date: Date of Vaccination
29    #[serde(rename = "dt")]
30    pub date: String,
31    /// Country of Vaccination
32    #[serde(rename = "co")]
33    pub country: Cow<'static, str>,
34    /// Certificate Issuer
35    #[serde(rename = "is")]
36    pub issuer: String,
37    /// Unique Certificate Identifier: UVCI
38    #[serde(rename = "ci")]
39    pub id: String,
40}
41
42impl Vaccination {
43    /// Updates all the ids in the vaccination entry with their descriptive counterparts using
44    /// the official valueset.
45    pub fn expand_values(&mut self) {
46        self.targeted_disease = lookup_value(&self.targeted_disease);
47        self.vaccine_prophylaxis = lookup_value(&self.vaccine_prophylaxis);
48        self.medicinal_product = lookup_value(&self.medicinal_product);
49        self.manufacturer = lookup_value(&self.manufacturer);
50        self.country = lookup_value(&self.country);
51    }
52}