openehr-its 0.0.128

openEHR ITS (Implementation Technology Specifications): canonical JSON + canonical XML serialization of the RM, the generated ITS-REST 1.1.0 API contract, and the OPT 1.4 and AOM2 archetype XML codecs
Documentation
// @generated by openehr-codegen (emit-rest) — DO NOT EDIT.
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-FileCopyrightText: openEHR Foundation
// SPDX-License-Identifier: Apache-2.0
//! 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"
)]
#![expect(
    clippy::disallowed_types,
    reason = "adjudicated free-form JSON slots: serde_json::Value is workspace-banned (#1694); a generated carrier exists only where the spec leaves the slot open, and each adjudicated field's NOTE names its citation"
)]
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`.
    /// DEFAULT when absent — ITS-REST `responses/400.yaml`: "The response body MAY contain error details" — the released text makes the whole error body optional and binds no client's reading of one; no openEHR spec governs a client's tolerance of a partial `Error` — our own design
    /// (A service that answers `{"message": …}` alone still sends its diagnostics; an empty list reads them, a decode refusal loses them.)
    #[serde(rename = "validationErrors")]
    #[serde(default)]
    pub validation_errors: Vec<String>,
    /// The undeclared (`additionalProperties`) members of `Error`, which
    /// its ITS-REST OAS component schema leaves open (no `additionalProperties`, which defaults to `true`).
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
}

/// 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::v1_2::composition::content::entry::action::Action),
    /// `_type: "ADMIN_ENTRY"`
    AdminEntry(openehr_rm::v1_2::composition::content::entry::admin_entry::AdminEntry),
    /// `_type: "CARE_ENTRY"`
    CareEntry(openehr_rm::v1_2::composition::content::entry::care_entry::CareEntry),
    /// `_type: "EVALUATION"`
    Evaluation(openehr_rm::v1_2::composition::content::entry::evaluation::Evaluation),
    /// `_type: "INSTRUCTION"`
    Instruction(openehr_rm::v1_2::composition::content::entry::instruction::Instruction),
    /// `_type: "OBSERVATION"`
    Observation(openehr_rm::v1_2::composition::content::entry::observation::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::v1_2::demographic::party_identity::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::v1_2::demographic::contact::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::v1_2::demographic::party_relationship::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::v1_2::demographic::capability::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 undeclared (`additionalProperties`) members of `Identifier`, which
    /// its ITS-REST OAS component schema leaves open (no `additionalProperties`, which defaults to `true`).
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
}

/// 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::v1_2::data_types::text::dv_coded_text::DvCodedText,
    /// The `description` property of `UpdateAudit`.
    /// `_type` REQUIRED by `UDvText`: ITS-REST `schemas/common/UpdateAudit.yaml` types `description` as `UDvText.yaml`, whose members `UMDvText.yaml` and `UMDvCodedText.yaml` both list `_type` under `required`
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default, deserialize_with = "crate::rest::tagged::optional")]
    pub description: Option<openehr_rm::v1_2::data_types::text::dv_text::DvText>,
    /// The `committer` property of `UpdateAudit`.
    pub committer: openehr_rm::v1_2::common::generic::party_proxy::PartyProxy,
    /// The undeclared (`additionalProperties`) members of `UpdateAudit`, which
    /// its ITS-REST OAS component schema leaves open (no `additionalProperties`, which defaults to `true`).
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
}

/// 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", "AUDIT_DETAILS"];
        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)?,
                            )),
                            "AUDIT_DETAILS" => {
                                ::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::v1_2::data_types::text::dv_coded_text::DvCodedText,
    /// The `description` property of `UpdateAttestation`.
    /// `_type` REQUIRED by `UDvText`: ITS-REST `schemas/common/UpdateAttestation.yaml` inherits `description` from `UpdateAudit.yaml` (`UDvText.yaml`; `UMDvText.yaml` and `UMDvCodedText.yaml` require `_type`)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default, deserialize_with = "crate::rest::tagged::optional")]
    pub description: Option<openehr_rm::v1_2::data_types::text::dv_text::DvText>,
    /// The `committer` property of `UpdateAttestation`.
    pub committer: openehr_rm::v1_2::common::generic::party_proxy::PartyProxy,
    /// The `attested_view` property of `UpdateAttestation`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attested_view:
        Option<openehr_rm::v1_2::data_types::encapsulated::dv_multimedia::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::v1_2::data_types::uri::dv_ehr_uri::DvEhrUri>>,
    /// The `reason` property of `UpdateAttestation`.
    /// `_type` REQUIRED by `UDvText`: ITS-REST `schemas/common/UpdateAttestation.yaml` types `reason` as `UDvText.yaml`, whose members `UMDvText.yaml` and `UMDvCodedText.yaml` both list `_type` under `required`
    #[serde(deserialize_with = "crate::rest::tagged::required")]
    pub reason: openehr_rm::v1_2::data_types::text::dv_text::DvText,
    /// The `is_pending` property of `UpdateAttestation`.
    pub is_pending: bool,
    /// The undeclared (`additionalProperties`) members of `UpdateAttestation`, which
    /// its ITS-REST OAS component schema leaves open (no `additionalProperties`, which defaults to `true`).
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
}

/// 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::v1_3::base_types::identification::object_version_id::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::v1_2::data_types::text::dv_coded_text::DvCodedText,
    /// The `attestations` property of `UpdateVersion`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub attestations: Option<Vec<UpdateAttestation>>,
    /// The `data` property of `UpdateVersion`.
    /// OPTIONAL by the docs text — RM common original_version.adoc §Attributes — `data` is `0..1`; RM common master06-change_control_package.adoc §Logical Deletion — "delete its `_data_`" and "set the `_lifecycle_state_` value to the code for `deleted`"
    /// (A logical-deletion member carries no data; the released OAS lists `data` as required, which makes the RM's own deletion procedure unrepresentable.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<T>,
    /// The `commit_audit` property of `UpdateVersion`.
    pub commit_audit: UpdateAudit,
    /// The undeclared (`additionalProperties`) members of `UpdateVersion`, which
    /// its ITS-REST OAS component schema leaves open (no `additionalProperties`, which defaults to `true`).
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
}