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 `Practitioner` 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 person who is directly or indirectly involved in the provisioning of healthcare.
///
/// FHIR path: `Practitioner`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Practitioner {
    /// `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..*): An identifier for the person as this agent
    pub identifier: Vec<Identifier>,
    /// `active` (0..1): Whether this practitioner's record is in active use
    pub active: Option<Primitive<bool>>,
    /// `name` (0..*): The name(s) associated with the practitioner
    pub name: Vec<HumanName>,
    /// `telecom` (0..*): A contact detail for the practitioner (that apply to all roles)
    pub telecom: Vec<ContactPoint>,
    /// `address` (0..*): Address(es) of the practitioner that are not role specific (typically home address)
    pub address: Vec<Address>,
    /// `gender` (0..1): male | female | other | unknown
    pub gender: Option<Primitive<String>>,
    /// `birthDate` (0..1): The date on which the practitioner was born
    pub birth_date: Option<Primitive<String>>,
    /// `photo` (0..*): Image of the person
    pub photo: Vec<Attachment>,
    /// `qualification` (0..*): Certification, licenses, or training pertaining to the provision of care
    pub qualification: Vec<PractitionerQualification>,
    /// `communication` (0..*): A language the practitioner can use in patient communication
    pub communication: Vec<CodeableConcept>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Practitioner");
        let r = Practitioner {
            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),
            name: o.list(d, "name"),
            telecom: o.list(d, "telecom"),
            address: o.list(d, "address"),
            gender: o.prim(d, "gender", Kind::Code),
            birth_date: o.prim(d, "birthDate", Kind::Date),
            photo: o.list(d, "photo"),
            qualification: o.list(d, "qualification"),
            communication: o.list(d, "communication"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Practitioner".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("name", &self.name);
        w.list("telecom", &self.telecom);
        w.list("address", &self.address);
        w.prim("gender", &self.gender);
        w.prim("birthDate", &self.birth_date);
        w.list("photo", &self.photo);
        w.list("qualification", &self.qualification);
        w.list("communication", &self.communication);
        w.finish()
    }
}

/// Certification, licenses, or training pertaining to the provision of care
///
/// FHIR path: `Practitioner.qualification`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct PractitionerQualification {
    /// `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>,
    /// `identifier` (0..*): An identifier for this qualification for the practitioner
    pub identifier: Vec<Identifier>,
    /// `code` (1..1): Coded representation of the qualification
    pub code: Option<CodeableConcept>,
    /// `period` (0..1): Period during which the qualification is valid
    pub period: Option<Period>,
    /// `issuer` (0..1): Organization that regulates and issues the qualification
    pub issuer: Option<Reference>,
}

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

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