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 `Schedule` 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 container for slots of time that may be available for booking appointments.
///
/// FHIR path: `Schedule`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Schedule {
    /// `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 item
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether this schedule is in active use
    pub active: Option<Primitive<bool>>,
    /// `serviceCategory` (0..*): High-level category
    pub service_category: Vec<CodeableConcept>,
    /// `serviceType` (0..*): Specific service
    pub service_type: Vec<CodeableConcept>,
    /// `specialty` (0..*): Type of specialty needed
    pub specialty: Vec<CodeableConcept>,
    /// `actor` (1..*): Resource(s) that availability information is being provided for
    pub actor: Vec<Reference>,
    /// `planningHorizon` (0..1): Period of time covered by schedule
    pub planning_horizon: Option<Period>,
    /// `comment` (0..1): Comments on availability
    pub comment: Option<Primitive<String>>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Schedule");
        let r = Schedule {
            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),
            service_category: o.list(d, "serviceCategory"),
            service_type: o.list(d, "serviceType"),
            specialty: o.list(d, "specialty"),
            actor: o.list(d, "actor"),
            planning_horizon: o.one(d, "planningHorizon"),
            comment: o.prim(d, "comment", Kind::String),
        };
        required_list(d, "actor", &r.actor, 1);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Schedule".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("serviceCategory", &self.service_category);
        w.list("serviceType", &self.service_type);
        w.list("specialty", &self.specialty);
        w.list("actor", &self.actor);
        w.one("planningHorizon", &self.planning_horizon);
        w.prim("comment", &self.comment);
        w.finish()
    }
}