fhirkit 0.1.0

FHIR R4 for Rust: typed models for every resource and datatype generated from the official specification, lossless JSON with path-precise validation, typed search queries, FHIRPath
Documentation
// @generated by fhirkit-gen from hl7.fhir.r4.core 4.0.1. Do not edit.
//! The FHIR R4 `SubstanceNucleicAcid` resource.

#![allow(
    unused_imports,
    clippy::large_enum_variant,
    clippy::too_many_lines,
    clippy::doc_markdown
)]

use crate::decode::{
    choice_key, required, required_list, resource_type, Choice, Decoder, FhirJson, Obj, ObjWriter,
};
use crate::json::Json;
use crate::primitive::{Decimal, Kind, Primitive};
use crate::r4::*;

/// Nucleic acids are defined by three distinct elements: the base, sugar and linkage. Individual substance/moiety IDs will be created for each of these elements. The nucleotide sequence will be always entered in the 5’-3’ direction.
///
/// FHIR path: `SubstanceNucleicAcid`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct SubstanceNucleicAcid {
    /// `id` (0..1): Logical id of this artifact
    pub id: Option<String>,
    /// `meta` (0..1): Metadata about the resource
    pub meta: Option<Meta>,
    /// `implicitRules` (0..1): A set of rules under which this content was created
    pub implicit_rules: Option<Primitive<String>>,
    /// `language` (0..1): Language of the resource content
    pub language: Option<Primitive<String>>,
    /// `text` (0..1): Text summary of the resource, for human interpretation
    pub text: Option<Narrative>,
    /// `contained` (0..*): Contained, inline Resources
    pub contained: Vec<Resource>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored
    pub modifier_extension: Vec<Extension>,
    /// `sequenceType` (0..1): The type of the sequence shall be specified based on a controlled vocabulary
    pub sequence_type: Option<CodeableConcept>,
    /// `numberOfSubunits` (0..1): The number of linear sequences of nucleotides linked through phosphodiester bonds shall be described. Subunits would be strands of nucleic acids that are tightly associated typically through Watson-Crick base pairing. NOTE: If not specified in the reference source, the assumption is that there is 1 subunit
    pub number_of_subunits: Option<Primitive<i32>>,
    /// `areaOfHybridisation` (0..1): The area of hybridisation shall be described if applicable for double stranded RNA or DNA. The number associated with the subunit followed by the number associated to the residue shall be specified in increasing order. The underscore “” shall be used as separator as follows: “Subunitnumber Residue”
    pub area_of_hybridisation: Option<Primitive<String>>,
    /// `oligoNucleotideType` (0..1): (TBC)
    pub oligo_nucleotide_type: Option<CodeableConcept>,
    /// `subunit` (0..*): Subunits are listed in order of decreasing length; sequences of the same length will be ordered by molecular weight; subunits that have identical sequences will be repeated multiple times
    pub subunit: Vec<SubstanceNucleicAcidSubunit>,
}

#[cfg(feature = "specialized")]
impl FhirJson for SubstanceNucleicAcid {
    const TYPE_NAME: &'static str = "SubstanceNucleicAcid";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "SubstanceNucleicAcid");
        let r = SubstanceNucleicAcid {
            id: o.string(d, "id"),
            meta: o.one(d, "meta"),
            implicit_rules: o.prim(d, "implicitRules", Kind::Uri),
            language: o.prim(d, "language", Kind::Code),
            text: o.one(d, "text"),
            contained: o.list(d, "contained"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            sequence_type: o.one(d, "sequenceType"),
            number_of_subunits: o.prim(d, "numberOfSubunits", Kind::Integer),
            area_of_hybridisation: o.prim(d, "areaOfHybridisation", Kind::String),
            oligo_nucleotide_type: o.one(d, "oligoNucleotideType"),
            subunit: o.list(d, "subunit"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("SubstanceNucleicAcid".into()));
        w.string("id", &self.id);
        w.one("meta", &self.meta);
        w.prim("implicitRules", &self.implicit_rules);
        w.prim("language", &self.language);
        w.one("text", &self.text);
        w.list("contained", &self.contained);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.one("sequenceType", &self.sequence_type);
        w.prim("numberOfSubunits", &self.number_of_subunits);
        w.prim("areaOfHybridisation", &self.area_of_hybridisation);
        w.one("oligoNucleotideType", &self.oligo_nucleotide_type);
        w.list("subunit", &self.subunit);
        w.finish()
    }
}

/// Subunits are listed in order of decreasing length; sequences of the same length will be ordered by molecular weight; subunits that have identical sequences will be repeated multiple times
///
/// FHIR path: `SubstanceNucleicAcid.subunit`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct SubstanceNucleicAcidSubunit {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `subunit` (0..1): Index of linear sequences of nucleic acids in order of decreasing length. Sequences of the same length will be ordered by molecular weight. Subunits that have identical sequences will be repeated and have sequential subscripts
    pub subunit: Option<Primitive<i32>>,
    /// `sequence` (0..1): Actual nucleotide sequence notation from 5' to 3' end using standard single letter codes. In addition to the base sequence, sugar and type of phosphate or non-phosphate linkage should also be captured
    pub sequence: Option<Primitive<String>>,
    /// `length` (0..1): The length of the sequence shall be captured
    pub length: Option<Primitive<i32>>,
    /// `sequenceAttachment` (0..1): (TBC)
    pub sequence_attachment: Option<Attachment>,
    /// `fivePrime` (0..1): The nucleotide present at the 5’ terminal shall be specified based on a controlled vocabulary. Since the sequence is represented from the 5' to the 3' end, the 5’ prime nucleotide is the letter at the first position in the sequence. A separate representation would be redundant
    pub five_prime: Option<CodeableConcept>,
    /// `threePrime` (0..1): The nucleotide present at the 3’ terminal shall be specified based on a controlled vocabulary. Since the sequence is represented from the 5' to the 3' end, the 5’ prime nucleotide is the letter at the last position in the sequence. A separate representation would be redundant
    pub three_prime: Option<CodeableConcept>,
    /// `linkage` (0..*): The linkages between sugar residues will also be captured
    pub linkage: Vec<SubstanceNucleicAcidSubunitLinkage>,
    /// `sugar` (0..*): 5.3.6.8.1 Sugar ID (Mandatory)
    pub sugar: Vec<SubstanceNucleicAcidSubunitSugar>,
}

#[cfg(feature = "specialized")]
impl FhirJson for SubstanceNucleicAcidSubunit {
    const TYPE_NAME: &'static str = "SubstanceNucleicAcidSubunit";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = SubstanceNucleicAcidSubunit {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            subunit: o.prim(d, "subunit", Kind::Integer),
            sequence: o.prim(d, "sequence", Kind::String),
            length: o.prim(d, "length", Kind::Integer),
            sequence_attachment: o.one(d, "sequenceAttachment"),
            five_prime: o.one(d, "fivePrime"),
            three_prime: o.one(d, "threePrime"),
            linkage: o.list(d, "linkage"),
            sugar: o.list(d, "sugar"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.prim("subunit", &self.subunit);
        w.prim("sequence", &self.sequence);
        w.prim("length", &self.length);
        w.one("sequenceAttachment", &self.sequence_attachment);
        w.one("fivePrime", &self.five_prime);
        w.one("threePrime", &self.three_prime);
        w.list("linkage", &self.linkage);
        w.list("sugar", &self.sugar);
        w.finish()
    }
}

/// The linkages between sugar residues will also be captured
///
/// FHIR path: `SubstanceNucleicAcid.subunit.linkage`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct SubstanceNucleicAcidSubunitLinkage {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `connectivity` (0..1): The entity that links the sugar residues together should also be captured for nearly all naturally occurring nucleic acid the linkage is a phosphate group. For many synthetic oligonucleotides phosphorothioate linkages are often seen. Linkage connectivity is assumed to be 3’-5’. If the linkage is either 3’-3’ or 5’-5’ this should be specified
    pub connectivity: Option<Primitive<String>>,
    /// `identifier` (0..1): Each linkage will be registered as a fragment and have an ID
    pub identifier: Option<Identifier>,
    /// `name` (0..1): Each linkage will be registered as a fragment and have at least one name. A single name shall be assigned to each linkage
    pub name: Option<Primitive<String>>,
    /// `residueSite` (0..1): Residues shall be captured as described in 5.3.6.8.3
    pub residue_site: Option<Primitive<String>>,
}

#[cfg(feature = "specialized")]
impl FhirJson for SubstanceNucleicAcidSubunitLinkage {
    const TYPE_NAME: &'static str = "SubstanceNucleicAcidSubunitLinkage";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = SubstanceNucleicAcidSubunitLinkage {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            connectivity: o.prim(d, "connectivity", Kind::String),
            identifier: o.one(d, "identifier"),
            name: o.prim(d, "name", Kind::String),
            residue_site: o.prim(d, "residueSite", Kind::String),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.prim("connectivity", &self.connectivity);
        w.one("identifier", &self.identifier);
        w.prim("name", &self.name);
        w.prim("residueSite", &self.residue_site);
        w.finish()
    }
}

/// 5.3.6.8.1 Sugar ID (Mandatory)
///
/// FHIR path: `SubstanceNucleicAcid.subunit.sugar`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct SubstanceNucleicAcidSubunitSugar {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `identifier` (0..1): The Substance ID of the sugar or sugar-like component that make up the nucleotide
    pub identifier: Option<Identifier>,
    /// `name` (0..1): The name of the sugar or sugar-like component that make up the nucleotide
    pub name: Option<Primitive<String>>,
    /// `residueSite` (0..1): The residues that contain a given sugar will be captured. The order of given residues will be captured in the 5‘-3‘direction consistent with the base sequences listed above
    pub residue_site: Option<Primitive<String>>,
}

#[cfg(feature = "specialized")]
impl FhirJson for SubstanceNucleicAcidSubunitSugar {
    const TYPE_NAME: &'static str = "SubstanceNucleicAcidSubunitSugar";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = SubstanceNucleicAcidSubunitSugar {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            identifier: o.one(d, "identifier"),
            name: o.prim(d, "name", Kind::String),
            residue_site: o.prim(d, "residueSite", Kind::String),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.one("identifier", &self.identifier);
        w.prim("name", &self.name);
        w.prim("residueSite", &self.residue_site);
        w.finish()
    }
}