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 `HealthcareService` 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 details of a healthcare service available at a location.
///
/// FHIR path: `HealthcareService`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct HealthcareService {
    /// `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 identifiers for this item
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether this HealthcareService record is in active use
    pub active: Option<Primitive<bool>>,
    /// `providedBy` (0..1): Organization that provides this service
    pub provided_by: Option<Reference>,
    /// `category` (0..*): Broad category of service being performed or delivered
    pub category: Vec<CodeableConcept>,
    /// `type` (0..*): Type of service that may be delivered or performed
    pub type_: Vec<CodeableConcept>,
    /// `specialty` (0..*): Specialties handled by the HealthcareService
    pub specialty: Vec<CodeableConcept>,
    /// `location` (0..*): Location(s) where service may be provided
    pub location: Vec<Reference>,
    /// `name` (0..1): Description of service as presented to a consumer while searching
    pub name: Option<Primitive<String>>,
    /// `comment` (0..1): Additional description and/or any specific issues not covered elsewhere
    pub comment: Option<Primitive<String>>,
    /// `extraDetails` (0..1): Extra details about the service that can't be placed in the other fields
    pub extra_details: Option<Primitive<String>>,
    /// `photo` (0..1): Facilitates quick identification of the service
    pub photo: Option<Attachment>,
    /// `telecom` (0..*): Contacts related to the healthcare service
    pub telecom: Vec<ContactPoint>,
    /// `coverageArea` (0..*): Location(s) service is intended for/available to
    pub coverage_area: Vec<Reference>,
    /// `serviceProvisionCode` (0..*): Conditions under which service is available/offered
    pub service_provision_code: Vec<CodeableConcept>,
    /// `eligibility` (0..*): Specific eligibility requirements required to use the service
    pub eligibility: Vec<HealthcareServiceEligibility>,
    /// `program` (0..*): Programs that this service is applicable to
    pub program: Vec<CodeableConcept>,
    /// `characteristic` (0..*): Collection of characteristics (attributes)
    pub characteristic: Vec<CodeableConcept>,
    /// `communication` (0..*): The language that this service is offered in
    pub communication: Vec<CodeableConcept>,
    /// `referralMethod` (0..*): Ways that the service accepts referrals
    pub referral_method: Vec<CodeableConcept>,
    /// `appointmentRequired` (0..1): If an appointment is required for access to this service
    pub appointment_required: Option<Primitive<bool>>,
    /// `availableTime` (0..*): Times the Service Site is available
    pub available_time: Vec<HealthcareServiceAvailableTime>,
    /// `notAvailable` (0..*): Not available during this time due to provided reason
    pub not_available: Vec<HealthcareServiceNotAvailable>,
    /// `availabilityExceptions` (0..1): Description of availability exceptions
    pub availability_exceptions: Option<Primitive<String>>,
    /// `endpoint` (0..*): Technical endpoints providing access to electronic services operated for the healthcare service
    pub endpoint: Vec<Reference>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "HealthcareService");
        let r = HealthcareService {
            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),
            provided_by: o.one(d, "providedBy"),
            category: o.list(d, "category"),
            type_: o.list(d, "type"),
            specialty: o.list(d, "specialty"),
            location: o.list(d, "location"),
            name: o.prim(d, "name", Kind::String),
            comment: o.prim(d, "comment", Kind::String),
            extra_details: o.prim(d, "extraDetails", Kind::Markdown),
            photo: o.one(d, "photo"),
            telecom: o.list(d, "telecom"),
            coverage_area: o.list(d, "coverageArea"),
            service_provision_code: o.list(d, "serviceProvisionCode"),
            eligibility: o.list(d, "eligibility"),
            program: o.list(d, "program"),
            characteristic: o.list(d, "characteristic"),
            communication: o.list(d, "communication"),
            referral_method: o.list(d, "referralMethod"),
            appointment_required: o.prim(d, "appointmentRequired", Kind::Boolean),
            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("HealthcareService".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("providedBy", &self.provided_by);
        w.list("category", &self.category);
        w.list("type", &self.type_);
        w.list("specialty", &self.specialty);
        w.list("location", &self.location);
        w.prim("name", &self.name);
        w.prim("comment", &self.comment);
        w.prim("extraDetails", &self.extra_details);
        w.one("photo", &self.photo);
        w.list("telecom", &self.telecom);
        w.list("coverageArea", &self.coverage_area);
        w.list("serviceProvisionCode", &self.service_provision_code);
        w.list("eligibility", &self.eligibility);
        w.list("program", &self.program);
        w.list("characteristic", &self.characteristic);
        w.list("communication", &self.communication);
        w.list("referralMethod", &self.referral_method);
        w.prim("appointmentRequired", &self.appointment_required);
        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()
    }
}

/// Specific eligibility requirements required to use the service
///
/// FHIR path: `HealthcareService.eligibility`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct HealthcareServiceEligibility {
    /// `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>,
    /// `code` (0..1): Coded value for the eligibility
    pub code: Option<CodeableConcept>,
    /// `comment` (0..1): Describes the eligibility conditions for the service
    pub comment: Option<Primitive<String>>,
}

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

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

/// Times the Service Site is available
///
/// FHIR path: `HealthcareService.availableTime`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct HealthcareServiceAvailableTime {
    /// `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 HealthcareServiceAvailableTime {
    const TYPE_NAME: &'static str = "HealthcareServiceAvailableTime";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = HealthcareServiceAvailableTime {
            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: `HealthcareService.notAvailable`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct HealthcareServiceNotAvailable {
    /// `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 HealthcareServiceNotAvailable {
    const TYPE_NAME: &'static str = "HealthcareServiceNotAvailable";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = HealthcareServiceNotAvailable {
            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()
    }
}