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 `ChargeItemDefinition` 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 ChargeItemDefinition resource provides the properties that apply to the (billing) codes necessary to calculate costs and prices. The properties may differ largely depending on type and realm, therefore this resource gives only a rough structure and requires profiling for each type of billing code system.
///
/// FHIR path: `ChargeItemDefinition`.
#[cfg(feature = "financial")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ChargeItemDefinition {
    /// `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>,
    /// `url` (1..1): Canonical identifier for this charge item definition, represented as a URI (globally unique)
    pub url: Option<Primitive<String>>,
    /// `identifier` (0..*): Additional identifier for the charge item definition
    pub identifier: Vec<Identifier>,
    /// `version` (0..1): Business version of the charge item definition
    pub version: Option<Primitive<String>>,
    /// `title` (0..1): Name for this charge item definition (human friendly)
    pub title: Option<Primitive<String>>,
    /// `derivedFromUri` (0..*): Underlying externally-defined charge item definition
    pub derived_from_uri: Vec<Primitive<String>>,
    /// `partOf` (0..*): A larger definition of which this particular definition is a component or step
    pub part_of: Vec<Primitive<String>>,
    /// `replaces` (0..*): Completed or terminated request(s) whose function is taken by this new request
    pub replaces: Vec<Primitive<String>>,
    /// `status` (1..1): draft | active | retired | unknown
    pub status: Option<Primitive<String>>,
    /// `experimental` (0..1): For testing purposes, not real usage
    pub experimental: Option<Primitive<bool>>,
    /// `date` (0..1): Date last changed
    pub date: Option<Primitive<String>>,
    /// `publisher` (0..1): Name of the publisher (organization or individual)
    pub publisher: Option<Primitive<String>>,
    /// `contact` (0..*): Contact details for the publisher
    pub contact: Vec<ContactDetail>,
    /// `description` (0..1): Natural language description of the charge item definition
    pub description: Option<Primitive<String>>,
    /// `useContext` (0..*): The context that the content is intended to support
    pub use_context: Vec<UsageContext>,
    /// `jurisdiction` (0..*): Intended jurisdiction for charge item definition (if applicable)
    pub jurisdiction: Vec<CodeableConcept>,
    /// `copyright` (0..1): Use and/or publishing restrictions
    pub copyright: Option<Primitive<String>>,
    /// `approvalDate` (0..1): When the charge item definition was approved by publisher
    pub approval_date: Option<Primitive<String>>,
    /// `lastReviewDate` (0..1): When the charge item definition was last reviewed
    pub last_review_date: Option<Primitive<String>>,
    /// `effectivePeriod` (0..1): When the charge item definition is expected to be used
    pub effective_period: Option<Period>,
    /// `code` (0..1): Billing codes or product types this definition applies to
    pub code: Option<CodeableConcept>,
    /// `instance` (0..*): Instances this definition applies to
    pub instance: Vec<Reference>,
    /// `applicability` (0..*): Whether or not the billing code is applicable
    pub applicability: Vec<ChargeItemDefinitionApplicability>,
    /// `propertyGroup` (0..*): Group of properties which are applicable under the same conditions
    pub property_group: Vec<ChargeItemDefinitionPropertyGroup>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "ChargeItemDefinition");
        let r = ChargeItemDefinition {
            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"),
            url: o.prim(d, "url", Kind::Uri),
            identifier: o.list(d, "identifier"),
            version: o.prim(d, "version", Kind::String),
            title: o.prim(d, "title", Kind::String),
            derived_from_uri: o.prim_list(d, "derivedFromUri", Kind::Uri),
            part_of: o.prim_list(d, "partOf", Kind::Canonical),
            replaces: o.prim_list(d, "replaces", Kind::Canonical),
            status: o.prim(d, "status", Kind::Code),
            experimental: o.prim(d, "experimental", Kind::Boolean),
            date: o.prim(d, "date", Kind::DateTime),
            publisher: o.prim(d, "publisher", Kind::String),
            contact: o.list(d, "contact"),
            description: o.prim(d, "description", Kind::Markdown),
            use_context: o.list(d, "useContext"),
            jurisdiction: o.list(d, "jurisdiction"),
            copyright: o.prim(d, "copyright", Kind::Markdown),
            approval_date: o.prim(d, "approvalDate", Kind::Date),
            last_review_date: o.prim(d, "lastReviewDate", Kind::Date),
            effective_period: o.one(d, "effectivePeriod"),
            code: o.one(d, "code"),
            instance: o.list(d, "instance"),
            applicability: o.list(d, "applicability"),
            property_group: o.list(d, "propertyGroup"),
        };
        required(d, "url", &r.url);
        required(d, "status", &r.status);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("ChargeItemDefinition".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.prim("url", &self.url);
        w.list("identifier", &self.identifier);
        w.prim("version", &self.version);
        w.prim("title", &self.title);
        w.prim_list("derivedFromUri", &self.derived_from_uri);
        w.prim_list("partOf", &self.part_of);
        w.prim_list("replaces", &self.replaces);
        w.prim("status", &self.status);
        w.prim("experimental", &self.experimental);
        w.prim("date", &self.date);
        w.prim("publisher", &self.publisher);
        w.list("contact", &self.contact);
        w.prim("description", &self.description);
        w.list("useContext", &self.use_context);
        w.list("jurisdiction", &self.jurisdiction);
        w.prim("copyright", &self.copyright);
        w.prim("approvalDate", &self.approval_date);
        w.prim("lastReviewDate", &self.last_review_date);
        w.one("effectivePeriod", &self.effective_period);
        w.one("code", &self.code);
        w.list("instance", &self.instance);
        w.list("applicability", &self.applicability);
        w.list("propertyGroup", &self.property_group);
        w.finish()
    }
}

/// Whether or not the billing code is applicable
///
/// FHIR path: `ChargeItemDefinition.applicability`.
#[cfg(feature = "financial")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ChargeItemDefinitionApplicability {
    /// `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` (0..1): Natural language description of the condition
    pub description: Option<Primitive<String>>,
    /// `language` (0..1): Language of the expression
    pub language: Option<Primitive<String>>,
    /// `expression` (0..1): Boolean-valued expression
    pub expression: Option<Primitive<String>>,
}

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

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

/// Group of properties which are applicable under the same conditions
///
/// FHIR path: `ChargeItemDefinition.propertyGroup`.
#[cfg(feature = "financial")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ChargeItemDefinitionPropertyGroup {
    /// `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>,
    /// `applicability` (0..*): Conditions under which the priceComponent is applicable
    pub applicability: Vec<ChargeItemDefinitionApplicability>,
    /// `priceComponent` (0..*): Components of total line item price
    pub price_component: Vec<ChargeItemDefinitionPropertyGroupPriceComponent>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = ChargeItemDefinitionPropertyGroup {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            applicability: o.list(d, "applicability"),
            price_component: o.list(d, "priceComponent"),
        };
        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("applicability", &self.applicability);
        w.list("priceComponent", &self.price_component);
        w.finish()
    }
}

/// Components of total line item price
///
/// FHIR path: `ChargeItemDefinition.propertyGroup.priceComponent`.
#[cfg(feature = "financial")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ChargeItemDefinitionPropertyGroupPriceComponent {
    /// `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` (1..1): base | surcharge | deduction | discount | tax | informational
    pub type_: Option<Primitive<String>>,
    /// `code` (0..1): Code identifying the specific component
    pub code: Option<CodeableConcept>,
    /// `factor` (0..1): Factor used for calculating this component
    pub factor: Option<Primitive<Decimal>>,
    /// `amount` (0..1): Monetary amount associated with this component
    pub amount: Option<Money>,
}

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

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