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 `Organization` 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 formally or informally recognized grouping of people or organizations formed for the purpose of achieving some form of collective action. Includes companies, institutions, corporations, departments, community groups, healthcare practice groups, payer/insurer, etc.
///
/// FHIR path: `Organization`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Organization {
    /// `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..*): Identifies this organization across multiple systems
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether the organization's record is still in active use
    pub active: Option<Primitive<bool>>,
    /// `type` (0..*): Kind of organization
    pub type_: Vec<CodeableConcept>,
    /// `name` (0..1): Name used for the organization
    pub name: Option<Primitive<String>>,
    /// `alias` (0..*): A list of alternate names that the organization is known as, or was known as in the past
    pub alias: Vec<Primitive<String>>,
    /// `telecom` (0..*): A contact detail for the organization
    pub telecom: Vec<ContactPoint>,
    /// `address` (0..*): An address for the organization
    pub address: Vec<Address>,
    /// `partOf` (0..1): The organization of which this organization forms a part
    pub part_of: Option<Reference>,
    /// `contact` (0..*): Contact for the organization for a certain purpose
    pub contact: Vec<OrganizationContact>,
    /// `endpoint` (0..*): Technical endpoints providing access to services operated for the organization
    pub endpoint: Vec<Reference>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Organization");
        let r = Organization {
            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),
            type_: o.list(d, "type"),
            name: o.prim(d, "name", Kind::String),
            alias: o.prim_list(d, "alias", Kind::String),
            telecom: o.list(d, "telecom"),
            address: o.list(d, "address"),
            part_of: o.one(d, "partOf"),
            contact: o.list(d, "contact"),
            endpoint: o.list(d, "endpoint"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Organization".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.list("type", &self.type_);
        w.prim("name", &self.name);
        w.prim_list("alias", &self.alias);
        w.list("telecom", &self.telecom);
        w.list("address", &self.address);
        w.one("partOf", &self.part_of);
        w.list("contact", &self.contact);
        w.list("endpoint", &self.endpoint);
        w.finish()
    }
}

/// Contact for the organization for a certain purpose
///
/// FHIR path: `Organization.contact`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct OrganizationContact {
    /// `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>,
    /// `purpose` (0..1): The type of contact
    pub purpose: Option<CodeableConcept>,
    /// `name` (0..1): A name associated with the contact
    pub name: Option<HumanName>,
    /// `telecom` (0..*): Contact details (telephone, email, etc.) for a contact
    pub telecom: Vec<ContactPoint>,
    /// `address` (0..1): Visiting or postal addresses for the contact
    pub address: Option<Address>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = OrganizationContact {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            purpose: o.one(d, "purpose"),
            name: o.one(d, "name"),
            telecom: o.list(d, "telecom"),
            address: o.one(d, "address"),
        };
        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("purpose", &self.purpose);
        w.one("name", &self.name);
        w.list("telecom", &self.telecom);
        w.one("address", &self.address);
        w.finish()
    }
}