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

/// Defines an affiliation/assotiation/relationship between 2 distinct oganizations, that is not a part-of relationship/sub-division relationship.
///
/// FHIR path: `OrganizationAffiliation`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct OrganizationAffiliation {
    /// `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..*): Business identifiers that are specific to this role
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether this organization affiliation record is in active use
    pub active: Option<Primitive<bool>>,
    /// `period` (0..1): The period during which the participatingOrganization is affiliated with the primary organization
    pub period: Option<Period>,
    /// `organization` (0..1): Organization where the role is available
    pub organization: Option<Reference>,
    /// `participatingOrganization` (0..1): Organization that provides/performs the role (e.g. providing services or is a member of)
    pub participating_organization: Option<Reference>,
    /// `network` (0..*): Health insurance provider network in which the participatingOrganization provides the role's services (if defined) at the indicated locations (if defined)
    pub network: Vec<Reference>,
    /// `code` (0..*): Definition of the role the participatingOrganization plays
    pub code: Vec<CodeableConcept>,
    /// `specialty` (0..*): Specific specialty of the participatingOrganization in the context of the role
    pub specialty: Vec<CodeableConcept>,
    /// `location` (0..*): The location(s) at which the role occurs
    pub location: Vec<Reference>,
    /// `healthcareService` (0..*): Healthcare services provided through the role
    pub healthcare_service: Vec<Reference>,
    /// `telecom` (0..*): Contact details at the participatingOrganization relevant to this Affiliation
    pub telecom: Vec<ContactPoint>,
    /// `endpoint` (0..*): Technical endpoints providing access to services operated for this role
    pub endpoint: Vec<Reference>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "OrganizationAffiliation");
        let r = OrganizationAffiliation {
            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),
            period: o.one(d, "period"),
            organization: o.one(d, "organization"),
            participating_organization: o.one(d, "participatingOrganization"),
            network: o.list(d, "network"),
            code: o.list(d, "code"),
            specialty: o.list(d, "specialty"),
            location: o.list(d, "location"),
            healthcare_service: o.list(d, "healthcareService"),
            telecom: o.list(d, "telecom"),
            endpoint: o.list(d, "endpoint"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw(
            "resourceType",
            Json::String("OrganizationAffiliation".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("period", &self.period);
        w.one("organization", &self.organization);
        w.one(
            "participatingOrganization",
            &self.participating_organization,
        );
        w.list("network", &self.network);
        w.list("code", &self.code);
        w.list("specialty", &self.specialty);
        w.list("location", &self.location);
        w.list("healthcareService", &self.healthcare_service);
        w.list("telecom", &self.telecom);
        w.list("endpoint", &self.endpoint);
        w.finish()
    }
}