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 `Parameters` 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::*;

/// This resource is a non-persisted resource used to pass information into and back from an [operation](operations.html). It has no other use, and there is no RESTful endpoint associated with it.
///
/// FHIR path: `Parameters`.
#[cfg(feature = "foundation")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Parameters {
    /// `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>>,
    /// `parameter` (0..*): Operation Parameter
    pub parameter: Vec<ParametersParameter>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Parameters");
        let r = Parameters {
            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),
            parameter: o.list(d, "parameter"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Parameters".into()));
        w.string("id", &self.id);
        w.one("meta", &self.meta);
        w.prim("implicitRules", &self.implicit_rules);
        w.prim("language", &self.language);
        w.list("parameter", &self.parameter);
        w.finish()
    }
}

/// Operation Parameter
///
/// FHIR path: `Parameters.parameter`.
#[cfg(feature = "foundation")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ParametersParameter {
    /// `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>,
    /// `name` (1..1): Name from the definition
    pub name: Option<Primitive<String>>,
    /// `value[x]` (0..1): If parameter is a data type
    pub value: Option<ParametersParameterValue>,
    /// `resource` (0..1): If parameter is a whole resource
    pub resource: Option<Resource>,
    /// `part` (0..*): Named part of a multi-part parameter
    pub part: Vec<ParametersParameter>,
}

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

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

/// The types `Parameters.parameter.value[x]` allows.
#[cfg(feature = "foundation")]
#[derive(Debug, Clone, PartialEq)]
pub enum ParametersParameterValue {
    /// `base64Binary`
    Base64Binary(Primitive<String>),
    /// `boolean`
    Boolean(Primitive<bool>),
    /// `canonical`
    Canonical(Primitive<String>),
    /// `code`
    Code(Primitive<String>),
    /// `date`
    Date(Primitive<String>),
    /// `dateTime`
    DateTime(Primitive<String>),
    /// `decimal`
    Decimal(Primitive<Decimal>),
    /// `id`
    Id(Primitive<String>),
    /// `instant`
    Instant(Primitive<String>),
    /// `integer`
    Integer(Primitive<i32>),
    /// `markdown`
    Markdown(Primitive<String>),
    /// `oid`
    Oid(Primitive<String>),
    /// `positiveInt`
    PositiveInt(Primitive<i32>),
    /// `string`
    String(Primitive<String>),
    /// `time`
    Time(Primitive<String>),
    /// `unsignedInt`
    UnsignedInt(Primitive<i32>),
    /// `uri`
    Uri(Primitive<String>),
    /// `url`
    Url(Primitive<String>),
    /// `uuid`
    Uuid(Primitive<String>),
    /// `Address`
    Address(Address),
    /// `Age`
    Age(Age),
    /// `Annotation`
    Annotation(Annotation),
    /// `Attachment`
    Attachment(Attachment),
    /// `CodeableConcept`
    CodeableConcept(CodeableConcept),
    /// `Coding`
    Coding(Coding),
    /// `ContactPoint`
    ContactPoint(ContactPoint),
    /// `Count`
    Count(Count),
    /// `Distance`
    Distance(Distance),
    /// `Duration`
    Duration(Duration),
    /// `HumanName`
    HumanName(HumanName),
    /// `Identifier`
    Identifier(Identifier),
    /// `Money`
    Money(Money),
    /// `Period`
    Period(Period),
    /// `Quantity`
    Quantity(Quantity),
    /// `Range`
    Range(Range),
    /// `Ratio`
    Ratio(Ratio),
    /// `Reference`
    Reference(Reference),
    /// `SampledData`
    SampledData(SampledData),
    /// `Signature`
    Signature(Signature),
    /// `Timing`
    Timing(Timing),
    /// `ContactDetail`
    ContactDetail(ContactDetail),
    /// `Contributor`
    Contributor(Contributor),
    /// `DataRequirement`
    DataRequirement(DataRequirement),
    /// `Expression`
    Expression(Expression),
    /// `ParameterDefinition`
    ParameterDefinition(ParameterDefinition),
    /// `RelatedArtifact`
    RelatedArtifact(RelatedArtifact),
    /// `TriggerDefinition`
    TriggerDefinition(TriggerDefinition),
    /// `UsageContext`
    UsageContext(UsageContext),
    /// `Dosage`
    Dosage(Dosage),
    /// `Meta`
    Meta(Meta),
}

#[cfg(feature = "foundation")]
impl Choice for ParametersParameterValue {
    const TYPES: &'static [&'static str] = &[
        "base64Binary",
        "boolean",
        "canonical",
        "code",
        "date",
        "dateTime",
        "decimal",
        "id",
        "instant",
        "integer",
        "markdown",
        "oid",
        "positiveInt",
        "string",
        "time",
        "unsignedInt",
        "uri",
        "url",
        "uuid",
        "Address",
        "Age",
        "Annotation",
        "Attachment",
        "CodeableConcept",
        "Coding",
        "ContactPoint",
        "Count",
        "Distance",
        "Duration",
        "HumanName",
        "Identifier",
        "Money",
        "Period",
        "Quantity",
        "Range",
        "Ratio",
        "Reference",
        "SampledData",
        "Signature",
        "Timing",
        "ContactDetail",
        "Contributor",
        "DataRequirement",
        "Expression",
        "ParameterDefinition",
        "RelatedArtifact",
        "TriggerDefinition",
        "UsageContext",
        "Dosage",
        "Meta",
    ];

    fn decode_as(code: &str, key: &str, o: &mut Obj<'_>, d: &mut Decoder) -> Option<Self> {
        match code {
            "base64Binary" => o.prim(d, key, Kind::Base64Binary).map(Self::Base64Binary),
            "boolean" => o.prim(d, key, Kind::Boolean).map(Self::Boolean),
            "canonical" => o.prim(d, key, Kind::Canonical).map(Self::Canonical),
            "code" => o.prim(d, key, Kind::Code).map(Self::Code),
            "date" => o.prim(d, key, Kind::Date).map(Self::Date),
            "dateTime" => o.prim(d, key, Kind::DateTime).map(Self::DateTime),
            "decimal" => o.prim(d, key, Kind::Decimal).map(Self::Decimal),
            "id" => o.prim(d, key, Kind::Id).map(Self::Id),
            "instant" => o.prim(d, key, Kind::Instant).map(Self::Instant),
            "integer" => o.prim(d, key, Kind::Integer).map(Self::Integer),
            "markdown" => o.prim(d, key, Kind::Markdown).map(Self::Markdown),
            "oid" => o.prim(d, key, Kind::Oid).map(Self::Oid),
            "positiveInt" => o.prim(d, key, Kind::PositiveInt).map(Self::PositiveInt),
            "string" => o.prim(d, key, Kind::String).map(Self::String),
            "time" => o.prim(d, key, Kind::Time).map(Self::Time),
            "unsignedInt" => o.prim(d, key, Kind::UnsignedInt).map(Self::UnsignedInt),
            "uri" => o.prim(d, key, Kind::Uri).map(Self::Uri),
            "url" => o.prim(d, key, Kind::Url).map(Self::Url),
            "uuid" => o.prim(d, key, Kind::Uuid).map(Self::Uuid),
            "Address" => o.one(d, key).map(Self::Address),
            "Age" => o.one(d, key).map(Self::Age),
            "Annotation" => o.one(d, key).map(Self::Annotation),
            "Attachment" => o.one(d, key).map(Self::Attachment),
            "CodeableConcept" => o.one(d, key).map(Self::CodeableConcept),
            "Coding" => o.one(d, key).map(Self::Coding),
            "ContactPoint" => o.one(d, key).map(Self::ContactPoint),
            "Count" => o.one(d, key).map(Self::Count),
            "Distance" => o.one(d, key).map(Self::Distance),
            "Duration" => o.one(d, key).map(Self::Duration),
            "HumanName" => o.one(d, key).map(Self::HumanName),
            "Identifier" => o.one(d, key).map(Self::Identifier),
            "Money" => o.one(d, key).map(Self::Money),
            "Period" => o.one(d, key).map(Self::Period),
            "Quantity" => o.one(d, key).map(Self::Quantity),
            "Range" => o.one(d, key).map(Self::Range),
            "Ratio" => o.one(d, key).map(Self::Ratio),
            "Reference" => o.one(d, key).map(Self::Reference),
            "SampledData" => o.one(d, key).map(Self::SampledData),
            "Signature" => o.one(d, key).map(Self::Signature),
            "Timing" => o.one(d, key).map(Self::Timing),
            "ContactDetail" => o.one(d, key).map(Self::ContactDetail),
            "Contributor" => o.one(d, key).map(Self::Contributor),
            "DataRequirement" => o.one(d, key).map(Self::DataRequirement),
            "Expression" => o.one(d, key).map(Self::Expression),
            "ParameterDefinition" => o.one(d, key).map(Self::ParameterDefinition),
            "RelatedArtifact" => o.one(d, key).map(Self::RelatedArtifact),
            "TriggerDefinition" => o.one(d, key).map(Self::TriggerDefinition),
            "UsageContext" => o.one(d, key).map(Self::UsageContext),
            "Dosage" => o.one(d, key).map(Self::Dosage),
            "Meta" => o.one(d, key).map(Self::Meta),
            _ => None,
        }
    }

    fn encode_into(&self, base: &str, w: &mut ObjWriter) {
        match self {
            Self::Base64Binary(v) => w.prim_value(&choice_key(base, "base64Binary"), v),
            Self::Boolean(v) => w.prim_value(&choice_key(base, "boolean"), v),
            Self::Canonical(v) => w.prim_value(&choice_key(base, "canonical"), v),
            Self::Code(v) => w.prim_value(&choice_key(base, "code"), v),
            Self::Date(v) => w.prim_value(&choice_key(base, "date"), v),
            Self::DateTime(v) => w.prim_value(&choice_key(base, "dateTime"), v),
            Self::Decimal(v) => w.prim_value(&choice_key(base, "decimal"), v),
            Self::Id(v) => w.prim_value(&choice_key(base, "id"), v),
            Self::Instant(v) => w.prim_value(&choice_key(base, "instant"), v),
            Self::Integer(v) => w.prim_value(&choice_key(base, "integer"), v),
            Self::Markdown(v) => w.prim_value(&choice_key(base, "markdown"), v),
            Self::Oid(v) => w.prim_value(&choice_key(base, "oid"), v),
            Self::PositiveInt(v) => w.prim_value(&choice_key(base, "positiveInt"), v),
            Self::String(v) => w.prim_value(&choice_key(base, "string"), v),
            Self::Time(v) => w.prim_value(&choice_key(base, "time"), v),
            Self::UnsignedInt(v) => w.prim_value(&choice_key(base, "unsignedInt"), v),
            Self::Uri(v) => w.prim_value(&choice_key(base, "uri"), v),
            Self::Url(v) => w.prim_value(&choice_key(base, "url"), v),
            Self::Uuid(v) => w.prim_value(&choice_key(base, "uuid"), v),
            Self::Address(v) => w.value(&choice_key(base, "Address"), v),
            Self::Age(v) => w.value(&choice_key(base, "Age"), v),
            Self::Annotation(v) => w.value(&choice_key(base, "Annotation"), v),
            Self::Attachment(v) => w.value(&choice_key(base, "Attachment"), v),
            Self::CodeableConcept(v) => w.value(&choice_key(base, "CodeableConcept"), v),
            Self::Coding(v) => w.value(&choice_key(base, "Coding"), v),
            Self::ContactPoint(v) => w.value(&choice_key(base, "ContactPoint"), v),
            Self::Count(v) => w.value(&choice_key(base, "Count"), v),
            Self::Distance(v) => w.value(&choice_key(base, "Distance"), v),
            Self::Duration(v) => w.value(&choice_key(base, "Duration"), v),
            Self::HumanName(v) => w.value(&choice_key(base, "HumanName"), v),
            Self::Identifier(v) => w.value(&choice_key(base, "Identifier"), v),
            Self::Money(v) => w.value(&choice_key(base, "Money"), v),
            Self::Period(v) => w.value(&choice_key(base, "Period"), v),
            Self::Quantity(v) => w.value(&choice_key(base, "Quantity"), v),
            Self::Range(v) => w.value(&choice_key(base, "Range"), v),
            Self::Ratio(v) => w.value(&choice_key(base, "Ratio"), v),
            Self::Reference(v) => w.value(&choice_key(base, "Reference"), v),
            Self::SampledData(v) => w.value(&choice_key(base, "SampledData"), v),
            Self::Signature(v) => w.value(&choice_key(base, "Signature"), v),
            Self::Timing(v) => w.value(&choice_key(base, "Timing"), v),
            Self::ContactDetail(v) => w.value(&choice_key(base, "ContactDetail"), v),
            Self::Contributor(v) => w.value(&choice_key(base, "Contributor"), v),
            Self::DataRequirement(v) => w.value(&choice_key(base, "DataRequirement"), v),
            Self::Expression(v) => w.value(&choice_key(base, "Expression"), v),
            Self::ParameterDefinition(v) => w.value(&choice_key(base, "ParameterDefinition"), v),
            Self::RelatedArtifact(v) => w.value(&choice_key(base, "RelatedArtifact"), v),
            Self::TriggerDefinition(v) => w.value(&choice_key(base, "TriggerDefinition"), v),
            Self::UsageContext(v) => w.value(&choice_key(base, "UsageContext"), v),
            Self::Dosage(v) => w.value(&choice_key(base, "Dosage"), v),
            Self::Meta(v) => w.value(&choice_key(base, "Meta"), v),
        }
    }
}