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 `PractitionerRole` 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 specific set of Roles/Locations/specialties/services that a practitioner may perform at an organization for a period of time.
///
/// FHIR path: `PractitionerRole`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct PractitionerRole {
    /// `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 a role/location
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether this practitioner role record is in active use
    pub active: Option<Primitive<bool>>,
    /// `period` (0..1): The period during which the practitioner is authorized to perform in these role(s)
    pub period: Option<Period>,
    /// `practitioner` (0..1): Practitioner that is able to provide the defined services for the organization
    pub practitioner: Option<Reference>,
    /// `organization` (0..1): Organization where the roles are available
    pub organization: Option<Reference>,
    /// `code` (0..*): Roles which this practitioner may perform
    pub code: Vec<CodeableConcept>,
    /// `specialty` (0..*): Specific specialty of the practitioner
    pub specialty: Vec<CodeableConcept>,
    /// `location` (0..*): The location(s) at which this practitioner provides care
    pub location: Vec<Reference>,
    /// `healthcareService` (0..*): The list of healthcare services that this worker provides for this role's Organization/Location(s)
    pub healthcare_service: Vec<Reference>,
    /// `telecom` (0..*): Contact details that are specific to the role/location/service
    pub telecom: Vec<ContactPoint>,
    /// `availableTime` (0..*): Times the Service Site is available
    pub available_time: Vec<PractitionerRoleAvailableTime>,
    /// `notAvailable` (0..*): Not available during this time due to provided reason
    pub not_available: Vec<PractitionerRoleNotAvailable>,
    /// `availabilityExceptions` (0..1): Description of availability exceptions
    pub availability_exceptions: Option<Primitive<String>>,
    /// `endpoint` (0..*): Technical endpoints providing access to services operated for the practitioner with this role
    pub endpoint: Vec<Reference>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "PractitionerRole");
        let r = PractitionerRole {
            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"),
            practitioner: o.one(d, "practitioner"),
            organization: o.one(d, "organization"),
            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"),
            available_time: o.list(d, "availableTime"),
            not_available: o.list(d, "notAvailable"),
            availability_exceptions: o.prim(d, "availabilityExceptions", Kind::String),
            endpoint: o.list(d, "endpoint"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("PractitionerRole".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("practitioner", &self.practitioner);
        w.one("organization", &self.organization);
        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("availableTime", &self.available_time);
        w.list("notAvailable", &self.not_available);
        w.prim("availabilityExceptions", &self.availability_exceptions);
        w.list("endpoint", &self.endpoint);
        w.finish()
    }
}

/// Times the Service Site is available
///
/// FHIR path: `PractitionerRole.availableTime`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct PractitionerRoleAvailableTime {
    /// `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>,
    /// `daysOfWeek` (0..*): mon | tue | wed | thu | fri | sat | sun
    pub days_of_week: Vec<Primitive<String>>,
    /// `allDay` (0..1): Always available? e.g. 24 hour service
    pub all_day: Option<Primitive<bool>>,
    /// `availableStartTime` (0..1): Opening time of day (ignored if allDay = true)
    pub available_start_time: Option<Primitive<String>>,
    /// `availableEndTime` (0..1): Closing time of day (ignored if allDay = true)
    pub available_end_time: Option<Primitive<String>>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = PractitionerRoleAvailableTime {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            days_of_week: o.prim_list(d, "daysOfWeek", Kind::Code),
            all_day: o.prim(d, "allDay", Kind::Boolean),
            available_start_time: o.prim(d, "availableStartTime", Kind::Time),
            available_end_time: o.prim(d, "availableEndTime", Kind::Time),
        };
        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.prim_list("daysOfWeek", &self.days_of_week);
        w.prim("allDay", &self.all_day);
        w.prim("availableStartTime", &self.available_start_time);
        w.prim("availableEndTime", &self.available_end_time);
        w.finish()
    }
}

/// Not available during this time due to provided reason
///
/// FHIR path: `PractitionerRole.notAvailable`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct PractitionerRoleNotAvailable {
    /// `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>,
    /// `description` (1..1): Reason presented to the user explaining why time not available
    pub description: Option<Primitive<String>>,
    /// `during` (0..1): Service not available from this date
    pub during: Option<Period>,
}

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

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