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 `Slot` 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 slot of time on a schedule that may be available for booking appointments.
///
/// FHIR path: `Slot`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Slot {
    /// `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>,
    /// `serviceCategory` (0..*): A broad categorization of the service that is to be performed during this appointment
    pub service_category: Vec<CodeableConcept>,
    /// `serviceType` (0..*): The type of appointments that can be booked into this slot (ideally this would be an identifiable service - which is at a location, rather than the location itself). If provided then this overrides the value provided on the availability resource
    pub service_type: Vec<CodeableConcept>,
    /// `specialty` (0..*): The specialty of a practitioner that would be required to perform the service requested in this appointment
    pub specialty: Vec<CodeableConcept>,
    /// `appointmentType` (0..1): The style of appointment or patient that may be booked in the slot (not service type)
    pub appointment_type: Option<CodeableConcept>,
    /// `schedule` (1..1): The schedule resource that this slot defines an interval of status information
    pub schedule: Option<Reference>,
    /// `status` (1..1): busy | free | busy-unavailable | busy-tentative | entered-in-error
    pub status: Option<Primitive<String>>,
    /// `start` (1..1): Date/Time that the slot is to begin
    pub start: Option<Primitive<String>>,
    /// `end` (1..1): Date/Time that the slot is to conclude
    pub end: Option<Primitive<String>>,
    /// `overbooked` (0..1): This slot has already been overbooked, appointments are unlikely to be accepted for this time
    pub overbooked: Option<Primitive<bool>>,
    /// `comment` (0..1): Comments on the slot to describe any extended information. Such as custom constraints on the slot
    pub comment: Option<Primitive<String>>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Slot");
        let r = Slot {
            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"),
            service_category: o.list(d, "serviceCategory"),
            service_type: o.list(d, "serviceType"),
            specialty: o.list(d, "specialty"),
            appointment_type: o.one(d, "appointmentType"),
            schedule: o.one(d, "schedule"),
            status: o.prim(d, "status", Kind::Code),
            start: o.prim(d, "start", Kind::Instant),
            end: o.prim(d, "end", Kind::Instant),
            overbooked: o.prim(d, "overbooked", Kind::Boolean),
            comment: o.prim(d, "comment", Kind::String),
        };
        required(d, "schedule", &r.schedule);
        required(d, "status", &r.status);
        required(d, "start", &r.start);
        required(d, "end", &r.end);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Slot".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.list("serviceCategory", &self.service_category);
        w.list("serviceType", &self.service_type);
        w.list("specialty", &self.specialty);
        w.one("appointmentType", &self.appointment_type);
        w.one("schedule", &self.schedule);
        w.prim("status", &self.status);
        w.prim("start", &self.start);
        w.prim("end", &self.end);
        w.prim("overbooked", &self.overbooked);
        w.prim("comment", &self.comment);
        w.finish()
    }
}