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

/// The Care Team includes all the people and organizations who plan to participate in the coordination and delivery of care for a patient.
///
/// FHIR path: `CareTeam`.
#[cfg(feature = "clinical")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct CareTeam {
    /// `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..*): External Ids for this team
    pub identifier: Vec<Identifier>,
    /// `status` (0..1): proposed | active | suspended | inactive | entered-in-error
    pub status: Option<Primitive<String>>,
    /// `category` (0..*): Type of team
    pub category: Vec<CodeableConcept>,
    /// `name` (0..1): Name of the team, such as crisis assessment team
    pub name: Option<Primitive<String>>,
    /// `subject` (0..1): Who care team is for
    pub subject: Option<Reference>,
    /// `encounter` (0..1): Encounter created as part of
    pub encounter: Option<Reference>,
    /// `period` (0..1): Time period team covers
    pub period: Option<Period>,
    /// `participant` (0..*): Members of the team
    pub participant: Vec<CareTeamParticipant>,
    /// `reasonCode` (0..*): Why the care team exists
    pub reason_code: Vec<CodeableConcept>,
    /// `reasonReference` (0..*): Why the care team exists
    pub reason_reference: Vec<Reference>,
    /// `managingOrganization` (0..*): Organization responsible for the care team
    pub managing_organization: Vec<Reference>,
    /// `telecom` (0..*): A contact detail for the care team (that applies to all members)
    pub telecom: Vec<ContactPoint>,
    /// `note` (0..*): Comments made about the CareTeam
    pub note: Vec<Annotation>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "CareTeam");
        let r = CareTeam {
            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"),
            status: o.prim(d, "status", Kind::Code),
            category: o.list(d, "category"),
            name: o.prim(d, "name", Kind::String),
            subject: o.one(d, "subject"),
            encounter: o.one(d, "encounter"),
            period: o.one(d, "period"),
            participant: o.list(d, "participant"),
            reason_code: o.list(d, "reasonCode"),
            reason_reference: o.list(d, "reasonReference"),
            managing_organization: o.list(d, "managingOrganization"),
            telecom: o.list(d, "telecom"),
            note: o.list(d, "note"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("CareTeam".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("status", &self.status);
        w.list("category", &self.category);
        w.prim("name", &self.name);
        w.one("subject", &self.subject);
        w.one("encounter", &self.encounter);
        w.one("period", &self.period);
        w.list("participant", &self.participant);
        w.list("reasonCode", &self.reason_code);
        w.list("reasonReference", &self.reason_reference);
        w.list("managingOrganization", &self.managing_organization);
        w.list("telecom", &self.telecom);
        w.list("note", &self.note);
        w.finish()
    }
}

/// Members of the team
///
/// FHIR path: `CareTeam.participant`.
#[cfg(feature = "clinical")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct CareTeamParticipant {
    /// `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>,
    /// `role` (0..*): Type of involvement
    pub role: Vec<CodeableConcept>,
    /// `member` (0..1): Who is involved
    pub member: Option<Reference>,
    /// `onBehalfOf` (0..1): Organization of the practitioner
    pub on_behalf_of: Option<Reference>,
    /// `period` (0..1): Time period of participant
    pub period: Option<Period>,
}

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

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