openehr-its 0.0.2

openEHR ITS (Implementation Technology Specifications): canonical JSON + XML serialization, ITS-REST OpenAPI contract, ITS-BMM. Mirrors the specifications-ITS-{JSON,XML,REST,BMM} repos.
Documentation
// @generated by openehr-codegen (emit-rest) — DO NOT EDIT.
//! ITS-REST contract, shared component schemas: DTOs that appear in more
//! than one API group's OAS bundle with identical definitions, hoisted so
//! one Rust type serves every group (the per-group bundles duplicate
//! shared schemas verbatim).

#![allow(
    clippy::all,
    clippy::pedantic,
    clippy::nursery,
    dead_code,
    unused_variables,
    reason = "mechanically generated contract text: the OAS is emitted in full (every DTO, param struct and route, whether or not this workspace consumes it yet), so style and dead-code lints do not apply — the hand-written runtime and the implementing adapter carry the lint bar"
)]
use serde::{Deserialize, Serialize};

/// The `Error` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Error {
    /// The `message` property of `Error`.
    pub message: String,
    /// The `validationErrors` property of `Error`.
    #[serde(rename = "validationErrors")]
    pub validation_errors: Vec<String>,
}

/// The `AbstractEntry` ITS-REST OAS component schema: `_type`-discriminated
/// polymorphism over its OAS `discriminator.mapping` targets.
#[derive(Debug, Clone)]
pub enum AbstractEntry {
    /// `_type: "ACTION"`
    Action(openehr_rm::prelude::Action),
    /// `_type: "ADMIN_ENTRY"`
    AdminEntry(openehr_rm::prelude::AdminEntry),
    /// `_type: "CARE_ENTRY"`
    CareEntry(openehr_rm::prelude::CareEntry),
    /// `_type: "EVALUATION"`
    Evaluation(openehr_rm::prelude::Evaluation),
    /// `_type: "INSTRUCTION"`
    Instruction(openehr_rm::prelude::Instruction),
    /// `_type: "OBSERVATION"`
    Observation(openehr_rm::prelude::Observation),
}

impl ::serde::Serialize for AbstractEntry {
    fn serialize<__S: ::serde::Serializer>(
        &self,
        __serializer: __S,
    ) -> ::core::result::Result<__S::Ok, __S::Error> {
        match self {
            Self::Action(__x) => ::serde::Serialize::serialize(__x, __serializer),
            Self::AdminEntry(__x) => ::serde::Serialize::serialize(__x, __serializer),
            Self::CareEntry(__x) => ::serde::Serialize::serialize(__x, __serializer),
            Self::Evaluation(__x) => ::serde::Serialize::serialize(__x, __serializer),
            Self::Instruction(__x) => ::serde::Serialize::serialize(__x, __serializer),
            Self::Observation(__x) => ::serde::Serialize::serialize(__x, __serializer),
        }
    }
}

impl<'de> ::serde::Deserialize<'de> for AbstractEntry {
    fn deserialize<__D: ::serde::Deserializer<'de>>(
        __deserializer: __D,
    ) -> ::core::result::Result<Self, __D::Error> {
        const __TAGS: &[&str] = &[
            "ACTION",
            "ADMIN_ENTRY",
            "CARE_ENTRY",
            "EVALUATION",
            "INSTRUCTION",
            "OBSERVATION",
        ];
        struct __Visitor;
        impl<'de> ::serde::de::Visitor<'de> for __Visitor {
            type Value = AbstractEntry;
            fn expecting(&self, __f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
                __f.write_str("an ITS-REST `AbstractEntry` object")
            }
            fn visit_map<__A: ::serde::de::MapAccess<'de>>(
                self,
                mut __map: __A,
            ) -> ::core::result::Result<Self::Value, __A::Error> {
                let (__tag, __buffered) =
                    ::openehr_base::serde_support::read_slot_tag(&mut __map, __TAGS)?;
                match __tag {
                    Some(::openehr_base::serde_support::TagMatch::Known(__t)) => {
                        let __rest = ::openehr_base::serde_support::TaggedRest::new(
                            Some(__t),
                            __buffered,
                            __map,
                        );
                        match __t {
                            "ACTION" => ::core::result::Result::Ok(AbstractEntry::Action(
                                ::serde::Deserialize::deserialize(__rest)?,
                            )),
                            "ADMIN_ENTRY" => ::core::result::Result::Ok(AbstractEntry::AdminEntry(
                                ::serde::Deserialize::deserialize(__rest)?,
                            )),
                            "CARE_ENTRY" => ::core::result::Result::Ok(AbstractEntry::CareEntry(
                                ::serde::Deserialize::deserialize(__rest)?,
                            )),
                            "EVALUATION" => ::core::result::Result::Ok(AbstractEntry::Evaluation(
                                ::serde::Deserialize::deserialize(__rest)?,
                            )),
                            "INSTRUCTION" => {
                                ::core::result::Result::Ok(AbstractEntry::Instruction(
                                    ::serde::Deserialize::deserialize(__rest)?,
                                ))
                            }
                            "OBSERVATION" => {
                                ::core::result::Result::Ok(AbstractEntry::Observation(
                                    ::serde::Deserialize::deserialize(__rest)?,
                                ))
                            }
                            __other => ::core::result::Result::Err(
                                ::openehr_base::serde_support::unexpected_type(
                                    "AbstractEntry",
                                    __other,
                                    "ACTION, ADMIN_ENTRY, CARE_ENTRY, EVALUATION, INSTRUCTION, OBSERVATION",
                                ),
                            ),
                        }
                    }
                    Some(::openehr_base::serde_support::TagMatch::Unknown(__other)) => {
                        ::core::result::Result::Err(::openehr_base::serde_support::unexpected_type(
                            "AbstractEntry",
                            &__other,
                            "ACTION, ADMIN_ENTRY, CARE_ENTRY, EVALUATION, INSTRUCTION, OBSERVATION",
                        ))
                    }
                    None => {
                        ::core::result::Result::Err(::openehr_base::serde_support::missing_type(
                            "AbstractEntry",
                            "ACTION, ADMIN_ENTRY, CARE_ENTRY, EVALUATION, INSTRUCTION, OBSERVATION",
                        ))
                    }
                }
            }
        }
        ::serde::Deserializer::deserialize_map(__deserializer, __Visitor)
    }
}

/// The `ListOfPartyIdentity` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type ListOfPartyIdentity = Vec<openehr_rm::prelude::PartyIdentity>;

/// The `ListOfContact` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type ListOfContact = Vec<openehr_rm::prelude::Contact>;

/// The `ListOfPartyRelationship` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type ListOfPartyRelationship = Vec<openehr_rm::prelude::PartyRelationship>;

/// The `ListOfCapability` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type ListOfCapability = Vec<openehr_rm::prelude::Capability>;

/// The `QueryName` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type QueryName = String;

/// The `AQL` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type Aql = String;

/// The `UpdateItemTag` transport DTO of this API group (an ITS-REST OAS
/// component schema).
///
/// The OAS declares this schema `additionalProperties: false`, so an
/// undeclared member is refused rather than silently ignored.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct UpdateItemTag {
    /// The `key` property of `UpdateItemTag`.
    pub key: String,
    /// The `value` property of `UpdateItemTag`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
    /// The `target_path` property of `UpdateItemTag`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub target_path: Option<String>,
}

/// The `Identifier` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Identifier {
    /// The `uid` property of `Identifier`.
    pub uid: String,
}

/// The `UpdateAudit` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateAuditData {
    /// The `_type` property of `UpdateAudit`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _type: Option<String>,
    /// The `system_id` property of `UpdateAudit`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_id: Option<String>,
    /// The `change_type` property of `UpdateAudit`.
    pub change_type: openehr_rm::prelude::DvCodedText,
    /// The `description` property of `UpdateAudit`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<openehr_rm::prelude::DvText>,
    /// The `committer` property of `UpdateAudit`.
    pub committer: openehr_rm::prelude::PartyProxy,
}

/// The `UpdateAudit` ITS-REST OAS component schema: `_type`-discriminated
/// polymorphism over its OAS `discriminator.mapping` targets.
#[derive(Debug, Clone)]
pub enum UpdateAudit {
    /// `_type: "UPDATE_ATTESTATION"`
    UpdateAttestation(UpdateAttestation),
    /// `_type: "UPDATE_AUDIT"`
    UpdateAudit(UpdateAuditData),
}

impl ::serde::Serialize for UpdateAudit {
    fn serialize<__S: ::serde::Serializer>(
        &self,
        __serializer: __S,
    ) -> ::core::result::Result<__S::Ok, __S::Error> {
        match self {
            Self::UpdateAttestation(__x) => ::serde::Serialize::serialize(__x, __serializer),
            Self::UpdateAudit(__x) => ::serde::Serialize::serialize(__x, __serializer),
        }
    }
}

impl<'de> ::serde::Deserialize<'de> for UpdateAudit {
    fn deserialize<__D: ::serde::Deserializer<'de>>(
        __deserializer: __D,
    ) -> ::core::result::Result<Self, __D::Error> {
        const __TAGS: &[&str] = &["UPDATE_ATTESTATION", "UPDATE_AUDIT"];
        struct __Visitor;
        impl<'de> ::serde::de::Visitor<'de> for __Visitor {
            type Value = UpdateAudit;
            fn expecting(&self, __f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
                __f.write_str("an ITS-REST `UpdateAudit` object")
            }
            fn visit_map<__A: ::serde::de::MapAccess<'de>>(
                self,
                mut __map: __A,
            ) -> ::core::result::Result<Self::Value, __A::Error> {
                let (__tag, __buffered) =
                    ::openehr_base::serde_support::read_slot_tag(&mut __map, __TAGS)?;
                match __tag {
                    Some(::openehr_base::serde_support::TagMatch::Known(__t)) => {
                        let __rest = ::openehr_base::serde_support::TaggedRest::new(
                            Some(__t),
                            __buffered,
                            __map,
                        );
                        match __t {
                            "UPDATE_ATTESTATION" => {
                                ::core::result::Result::Ok(UpdateAudit::UpdateAttestation(
                                    ::serde::Deserialize::deserialize(__rest)?,
                                ))
                            }
                            "UPDATE_AUDIT" => ::core::result::Result::Ok(UpdateAudit::UpdateAudit(
                                ::serde::Deserialize::deserialize(__rest)?,
                            )),
                            __other => ::core::result::Result::Err(
                                ::openehr_base::serde_support::unexpected_type(
                                    "UpdateAudit",
                                    __other,
                                    "UPDATE_ATTESTATION, UPDATE_AUDIT",
                                ),
                            ),
                        }
                    }
                    Some(::openehr_base::serde_support::TagMatch::Unknown(__other)) => {
                        ::core::result::Result::Err(::openehr_base::serde_support::unexpected_type(
                            "UpdateAudit",
                            &__other,
                            "UPDATE_ATTESTATION, UPDATE_AUDIT",
                        ))
                    }
                    None => {
                        let __rest =
                            ::openehr_base::serde_support::TaggedRest::new(None, __buffered, __map);
                        ::core::result::Result::Ok(UpdateAudit::UpdateAudit(
                            ::serde::Deserialize::deserialize(__rest)?,
                        ))
                    }
                }
            }
        }
        ::serde::Deserializer::deserialize_map(__deserializer, __Visitor)
    }
}

/// The `UpdateAttestation` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateAttestation {
    /// The `_type` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _type: Option<String>,
    /// The `system_id` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_id: Option<String>,
    /// The `change_type` property of `UpdateAttestation`.
    pub change_type: openehr_rm::prelude::DvCodedText,
    /// The `description` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<openehr_rm::prelude::DvText>,
    /// The `committer` property of `UpdateAttestation`.
    pub committer: openehr_rm::prelude::PartyProxy,
    /// The `attested_view` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attested_view: Option<openehr_rm::prelude::DvMultimedia>,
    /// The `proof` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proof: Option<String>,
    /// The `items` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items: Option<Vec<openehr_rm::prelude::DvEhrUri>>,
    /// The `reason` property of `UpdateAttestation`.
    pub reason: openehr_rm::prelude::DvText,
    /// The `is_pending` property of `UpdateAttestation`.
    pub is_pending: bool,
}

/// The `UpdateVersion` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateVersion<T> {
    /// The `preceding_version_uid` property of `UpdateVersion`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub preceding_version_uid: Option<openehr_base::prelude::ObjectVersionId>,
    /// The `signature` property of `UpdateVersion`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signature: Option<String>,
    /// The `lifecycle_state` property of `UpdateVersion`.
    pub lifecycle_state: openehr_rm::prelude::DvCodedText,
    /// The `attestations` property of `UpdateVersion`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attestations: Option<Vec<UpdateAttestation>>,
    /// The `data` property of `UpdateVersion`.
    pub data: T,
    /// The `commit_audit` property of `UpdateVersion`.
    pub commit_audit: UpdateAudit,
}