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 `Appointment` 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 booking of a healthcare event among patient(s), practitioner(s), related person(s) and/or device(s) for a specific date/time. This may result in one or more Encounter(s).
///
/// FHIR path: `Appointment`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Appointment {
    /// `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>,
    /// `status` (1..1): proposed | pending | booked | arrived | fulfilled | cancelled | noshow | entered-in-error | checked-in | waitlist
    pub status: Option<Primitive<String>>,
    /// `cancelationReason` (0..1): The coded reason for the appointment being cancelled
    pub cancelation_reason: Option<CodeableConcept>,
    /// `serviceCategory` (0..*): A broad categorization of the service that is to be performed during this appointment
    pub service_category: Vec<CodeableConcept>,
    /// `serviceType` (0..*): The specific service that is to be performed during this appointment
    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 has been booked in the slot (not service type)
    pub appointment_type: Option<CodeableConcept>,
    /// `reasonCode` (0..*): Coded reason this appointment is scheduled
    pub reason_code: Vec<CodeableConcept>,
    /// `reasonReference` (0..*): Reason the appointment is to take place (resource)
    pub reason_reference: Vec<Reference>,
    /// `priority` (0..1): Used to make informed decisions if needing to re-prioritize
    pub priority: Option<Primitive<i32>>,
    /// `description` (0..1): Shown on a subject line in a meeting request, or appointment list
    pub description: Option<Primitive<String>>,
    /// `supportingInformation` (0..*): Additional information to support the appointment
    pub supporting_information: Vec<Reference>,
    /// `start` (0..1): When appointment is to take place
    pub start: Option<Primitive<String>>,
    /// `end` (0..1): When appointment is to conclude
    pub end: Option<Primitive<String>>,
    /// `minutesDuration` (0..1): Can be less than start/end (e.g. estimate)
    pub minutes_duration: Option<Primitive<i32>>,
    /// `slot` (0..*): The slots that this appointment is filling
    pub slot: Vec<Reference>,
    /// `created` (0..1): The date that this appointment was initially created
    pub created: Option<Primitive<String>>,
    /// `comment` (0..1): Additional comments
    pub comment: Option<Primitive<String>>,
    /// `patientInstruction` (0..1): Detailed information and instructions for the patient
    pub patient_instruction: Option<Primitive<String>>,
    /// `basedOn` (0..*): The service request this appointment is allocated to assess
    pub based_on: Vec<Reference>,
    /// `participant` (1..*): Participants involved in appointment
    pub participant: Vec<AppointmentParticipant>,
    /// `requestedPeriod` (0..*): Potential date/time interval(s) requested to allocate the appointment within
    pub requested_period: Vec<Period>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Appointment");
        let r = Appointment {
            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),
            cancelation_reason: o.one(d, "cancelationReason"),
            service_category: o.list(d, "serviceCategory"),
            service_type: o.list(d, "serviceType"),
            specialty: o.list(d, "specialty"),
            appointment_type: o.one(d, "appointmentType"),
            reason_code: o.list(d, "reasonCode"),
            reason_reference: o.list(d, "reasonReference"),
            priority: o.prim(d, "priority", Kind::UnsignedInt),
            description: o.prim(d, "description", Kind::String),
            supporting_information: o.list(d, "supportingInformation"),
            start: o.prim(d, "start", Kind::Instant),
            end: o.prim(d, "end", Kind::Instant),
            minutes_duration: o.prim(d, "minutesDuration", Kind::PositiveInt),
            slot: o.list(d, "slot"),
            created: o.prim(d, "created", Kind::DateTime),
            comment: o.prim(d, "comment", Kind::String),
            patient_instruction: o.prim(d, "patientInstruction", Kind::String),
            based_on: o.list(d, "basedOn"),
            participant: o.list(d, "participant"),
            requested_period: o.list(d, "requestedPeriod"),
        };
        required(d, "status", &r.status);
        required_list(d, "participant", &r.participant, 1);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Appointment".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.one("cancelationReason", &self.cancelation_reason);
        w.list("serviceCategory", &self.service_category);
        w.list("serviceType", &self.service_type);
        w.list("specialty", &self.specialty);
        w.one("appointmentType", &self.appointment_type);
        w.list("reasonCode", &self.reason_code);
        w.list("reasonReference", &self.reason_reference);
        w.prim("priority", &self.priority);
        w.prim("description", &self.description);
        w.list("supportingInformation", &self.supporting_information);
        w.prim("start", &self.start);
        w.prim("end", &self.end);
        w.prim("minutesDuration", &self.minutes_duration);
        w.list("slot", &self.slot);
        w.prim("created", &self.created);
        w.prim("comment", &self.comment);
        w.prim("patientInstruction", &self.patient_instruction);
        w.list("basedOn", &self.based_on);
        w.list("participant", &self.participant);
        w.list("requestedPeriod", &self.requested_period);
        w.finish()
    }
}

/// Participants involved in appointment
///
/// FHIR path: `Appointment.participant`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct AppointmentParticipant {
    /// `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>,
    /// `type` (0..*): Role of participant in the appointment
    pub type_: Vec<CodeableConcept>,
    /// `actor` (0..1): Person, Location/HealthcareService or Device
    pub actor: Option<Reference>,
    /// `required` (0..1): required | optional | information-only
    pub required: Option<Primitive<String>>,
    /// `status` (1..1): accepted | declined | tentative | needs-action
    pub status: Option<Primitive<String>>,
    /// `period` (0..1): Participation period of the actor
    pub period: Option<Period>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = AppointmentParticipant {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            type_: o.list(d, "type"),
            actor: o.one(d, "actor"),
            required: o.prim(d, "required", Kind::Code),
            status: o.prim(d, "status", Kind::Code),
            period: o.one(d, "period"),
        };
        required(d, "status", &r.status);
        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("type", &self.type_);
        w.one("actor", &self.actor);
        w.prim("required", &self.required);
        w.prim("status", &self.status);
        w.one("period", &self.period);
        w.finish()
    }
}