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 `Endpoint` 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 technical details of an endpoint that can be used for electronic services, such as for web services providing XDS.b or a REST endpoint for another FHIR server. This may include any security context information.
///
/// FHIR path: `Endpoint`.
#[cfg(feature = "base")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Endpoint {
    /// `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..*): Identifies this endpoint across multiple systems
    pub identifier: Vec<Identifier>,
    /// `status` (1..1): active | suspended | error | off | entered-in-error | test
    pub status: Option<Primitive<String>>,
    /// `connectionType` (1..1): Protocol/Profile/Standard to be used with this endpoint connection
    pub connection_type: Option<Coding>,
    /// `name` (0..1): A name that this endpoint can be identified by
    pub name: Option<Primitive<String>>,
    /// `managingOrganization` (0..1): Organization that manages this endpoint (might not be the organization that exposes the endpoint)
    pub managing_organization: Option<Reference>,
    /// `contact` (0..*): Contact details for source (e.g. troubleshooting)
    pub contact: Vec<ContactPoint>,
    /// `period` (0..1): Interval the endpoint is expected to be operational
    pub period: Option<Period>,
    /// `payloadType` (1..*): The type of content that may be used at this endpoint (e.g. XDS Discharge summaries)
    pub payload_type: Vec<CodeableConcept>,
    /// `payloadMimeType` (0..*): Mimetype to send. If not specified, the content could be anything (including no payload, if the connectionType defined this)
    pub payload_mime_type: Vec<Primitive<String>>,
    /// `address` (1..1): The technical base address for connecting to this endpoint
    pub address: Option<Primitive<String>>,
    /// `header` (0..*): Usage depends on the channel type
    pub header: Vec<Primitive<String>>,
}

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

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "Endpoint");
        let r = Endpoint {
            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"),
            status: o.prim(d, "status", Kind::Code),
            connection_type: o.one(d, "connectionType"),
            name: o.prim(d, "name", Kind::String),
            managing_organization: o.one(d, "managingOrganization"),
            contact: o.list(d, "contact"),
            period: o.one(d, "period"),
            payload_type: o.list(d, "payloadType"),
            payload_mime_type: o.prim_list(d, "payloadMimeType", Kind::Code),
            address: o.prim(d, "address", Kind::Url),
            header: o.prim_list(d, "header", Kind::String),
        };
        required(d, "status", &r.status);
        required(d, "connectionType", &r.connection_type);
        required_list(d, "payloadType", &r.payload_type, 1);
        required(d, "address", &r.address);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("Endpoint".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("status", &self.status);
        w.one("connectionType", &self.connection_type);
        w.prim("name", &self.name);
        w.one("managingOrganization", &self.managing_organization);
        w.list("contact", &self.contact);
        w.one("period", &self.period);
        w.list("payloadType", &self.payload_type);
        w.prim_list("payloadMimeType", &self.payload_mime_type);
        w.prim("address", &self.address);
        w.prim_list("header", &self.header);
        w.finish()
    }
}