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

/// Record details about an anatomical structure. This resource may be used when a coded concept does not provide the necessary detail needed for the use case.
///
/// FHIR path: `BodyStructure`.
#[cfg(feature = "clinical")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct BodyStructure {
    /// `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>,
    /// `identifier` (0..*): Bodystructure identifier
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether this record is in active use
    pub active: Option<Primitive<bool>>,
    /// `morphology` (0..1): Kind of Structure
    pub morphology: Option<CodeableConcept>,
    /// `location` (0..1): Body site
    pub location: Option<CodeableConcept>,
    /// `locationQualifier` (0..*): Body site modifier
    pub location_qualifier: Vec<CodeableConcept>,
    /// `description` (0..1): Text description
    pub description: Option<Primitive<String>>,
    /// `image` (0..*): Attached images
    pub image: Vec<Attachment>,
    /// `patient` (1..1): Who this is about
    pub patient: Option<Reference>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "BodyStructure");
        let r = BodyStructure {
            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"),
            identifier: o.list(d, "identifier"),
            active: o.prim(d, "active", Kind::Boolean),
            morphology: o.one(d, "morphology"),
            location: o.one(d, "location"),
            location_qualifier: o.list(d, "locationQualifier"),
            description: o.prim(d, "description", Kind::String),
            image: o.list(d, "image"),
            patient: o.one(d, "patient"),
        };
        required(d, "patient", &r.patient);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("BodyStructure".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.list("identifier", &self.identifier);
        w.prim("active", &self.active);
        w.one("morphology", &self.morphology);
        w.one("location", &self.location);
        w.list("locationQualifier", &self.location_qualifier);
        w.prim("description", &self.description);
        w.list("image", &self.image);
        w.one("patient", &self.patient);
        w.finish()
    }
}