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 `SubstanceProtein` 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::*;

/// A SubstanceProtein is defined as a single unit of a linear amino acid sequence, or a combination of subunits that are either covalently linked or have a defined invariant stoichiometric relationship. This includes all synthetic, recombinant and purified SubstanceProteins of defined sequence, whether the use is therapeutic or prophylactic. This set of elements will be used to describe albumins, coagulation factors, cytokines, growth factors, peptide/SubstanceProtein hormones, enzymes, toxins, toxoids, recombinant vaccines, and immunomodulators.
///
/// FHIR path: `SubstanceProtein`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct SubstanceProtein {
    /// `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 SubstanceProtein descriptive elements will only be used when a complete or partial amino acid sequence is available or derivable from a nucleic acid sequence
    pub sequence_type: Option<CodeableConcept>,
    /// `numberOfSubunits` (0..1): Number of linear sequences of amino acids linked through peptide bonds. The number of subunits constituting the SubstanceProtein shall be described. It is possible that the number of subunits can be variable
    pub number_of_subunits: Option<Primitive<i32>>,
    /// `disulfideLinkage` (0..*): The disulphide bond between two cysteine residues either on the same subunit or on two different subunits shall be described. The position of the disulfide bonds in the SubstanceProtein shall be listed in increasing order of subunit number and position within subunit followed by the abbreviation of the amino acids involved. The disulfide linkage positions shall actually contain the amino acid Cysteine at the respective positions
    pub disulfide_linkage: Vec<Primitive<String>>,
    /// `subunit` (0..*): This subclause refers to the description of each subunit constituting the SubstanceProtein. A subunit is a linear sequence of amino acids linked through peptide bonds. The Subunit information shall be provided when the finished SubstanceProtein is a complex of multiple sequences; subunits are not used to delineate domains within a single sequence. Subunits are listed in order of decreasing length; sequences of the same length will be ordered by decreasing molecular weight; subunits that have identical sequences will be repeated multiple times
    pub subunit: Vec<SubstanceProteinSubunit>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "SubstanceProtein");
        let r = SubstanceProtein {
            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),
            disulfide_linkage: o.prim_list(d, "disulfideLinkage", Kind::String),
            subunit: o.list(d, "subunit"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("SubstanceProtein".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_list("disulfideLinkage", &self.disulfide_linkage);
        w.list("subunit", &self.subunit);
        w.finish()
    }
}

/// This subclause refers to the description of each subunit constituting the SubstanceProtein. A subunit is a linear sequence of amino acids linked through peptide bonds. The Subunit information shall be provided when the finished SubstanceProtein is a complex of multiple sequences; subunits are not used to delineate domains within a single sequence. Subunits are listed in order of decreasing length; sequences of the same length will be ordered by decreasing molecular weight; subunits that have identical sequences will be repeated multiple times
///
/// FHIR path: `SubstanceProtein.subunit`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct SubstanceProteinSubunit {
    /// `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 primary sequences of amino acids linked through peptide bonds 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): The sequence information shall be provided enumerating the amino acids from N- to C-terminal end using standard single-letter amino acid codes. Uppercase shall be used for L-amino acids and lowercase for D-amino acids. Transcribed SubstanceProteins will always be described using the translated sequence; for synthetic peptide containing amino acids that are not represented with a single letter code an X should be used within the sequence. The modified amino acids will be distinguished by their position in the sequence
    pub sequence: Option<Primitive<String>>,
    /// `length` (0..1): Length of linear sequences of amino acids contained in the subunit
    pub length: Option<Primitive<i32>>,
    /// `sequenceAttachment` (0..1): The sequence information shall be provided enumerating the amino acids from N- to C-terminal end using standard single-letter amino acid codes. Uppercase shall be used for L-amino acids and lowercase for D-amino acids. Transcribed SubstanceProteins will always be described using the translated sequence; for synthetic peptide containing amino acids that are not represented with a single letter code an X should be used within the sequence. The modified amino acids will be distinguished by their position in the sequence
    pub sequence_attachment: Option<Attachment>,
    /// `nTerminalModificationId` (0..1): Unique identifier for molecular fragment modification based on the ISO 11238 Substance ID
    pub n_terminal_modification_id: Option<Identifier>,
    /// `nTerminalModification` (0..1): The name of the fragment modified at the N-terminal of the SubstanceProtein shall be specified
    pub n_terminal_modification: Option<Primitive<String>>,
    /// `cTerminalModificationId` (0..1): Unique identifier for molecular fragment modification based on the ISO 11238 Substance ID
    pub c_terminal_modification_id: Option<Identifier>,
    /// `cTerminalModification` (0..1): The modification at the C-terminal shall be specified
    pub c_terminal_modification: Option<Primitive<String>>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = SubstanceProteinSubunit {
            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"),
            n_terminal_modification_id: o.one(d, "nTerminalModificationId"),
            n_terminal_modification: o.prim(d, "nTerminalModification", Kind::String),
            c_terminal_modification_id: o.one(d, "cTerminalModificationId"),
            c_terminal_modification: o.prim(d, "cTerminalModification", 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("subunit", &self.subunit);
        w.prim("sequence", &self.sequence);
        w.prim("length", &self.length);
        w.one("sequenceAttachment", &self.sequence_attachment);
        w.one("nTerminalModificationId", &self.n_terminal_modification_id);
        w.prim("nTerminalModification", &self.n_terminal_modification);
        w.one("cTerminalModificationId", &self.c_terminal_modification_id);
        w.prim("cTerminalModification", &self.c_terminal_modification);
        w.finish()
    }
}