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 for the `query` API group: DTOs, per-operation
//! param structs, the `QueryApi` server trait, and the route table.

#![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 `QueryParameters` ITS-REST OAS component schema (a non-object shape, so
/// it is an alias rather than a struct).
pub type QueryParameters = std::collections::BTreeMap<String, serde_json::Value>;

/// The `ResultSetMetadata` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResultSetMetadata {
    /// The `_href` property of `ResultSetMetadata`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _href: Option<String>,
    /// The `_type` property of `ResultSetMetadata`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _type: Option<String>,
    /// The `_schema_version` property of `ResultSetMetadata`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _schema_version: Option<String>,
    /// The `_created` property of `ResultSetMetadata`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _created: Option<String>,
    /// The `_generator` property of `ResultSetMetadata`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _generator: Option<String>,
    /// The `_executed_aql` property of `ResultSetMetadata`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub _executed_aql: Option<String>,
    /// The undeclared (`additionalProperties`) members of `ResultSetMetadata`, which
    /// its ITS-REST OAS component schema declares as an extension point.
    #[serde(flatten)]
    pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
}

/// The `ResultSetColumn` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResultSetColumn {
    /// The `name` property of `ResultSetColumn`.
    pub name: String,
    /// The `path` property of `ResultSetColumn`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
}

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

/// The `ResultSet` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResultSet {
    /// The `meta` property of `ResultSet`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub meta: Option<ResultSetMetadata>,
    /// The `name` property of `ResultSet`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<super::common::QueryName>,
    /// The `q` property of `ResultSet`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub q: Option<super::common::Aql>,
    /// The `columns` property of `ResultSet`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub columns: Option<Vec<ResultSetColumn>>,
    /// The `rows` property of `ResultSet`.
    pub rows: Vec<ResultSetRow>,
}

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

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

/// The `AdhocQueryExecute` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdhocQueryExecute {
    /// The `q` property of `AdhocQueryExecute`.
    pub q: super::common::Aql,
    /// The `offset` property of `AdhocQueryExecute`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub offset: Option<Offset>,
    /// The `fetch` property of `AdhocQueryExecute`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fetch: Option<Fetch>,
    /// The `query_parameters` property of `AdhocQueryExecute`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub query_parameters: Option<QueryParameters>,
}

/// The `Query` transport DTO of this API group (an ITS-REST OAS
/// component schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Query {
    /// The `offset` property of `Query`.
    /// OPTIONAL by the docs text — ITS-REST docs/query/Request.md §Common Headers and Query Parameters — "`offset` … default `0`"
    /// (A required member cannot default; the stored-query execute body must accept `{}` (a parameterless stored query).)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub offset: Option<Offset>,
    /// The `fetch` property of `Query`.
    /// OPTIONAL by the docs text — ITS-REST docs/query/Request.md §Common Headers and Query Parameters — "`fetch` … default depends on the implementation"
    /// (A required member cannot default; the stored-query execute body must accept `{}`.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fetch: Option<Fetch>,
    /// The `query_parameters` property of `Query`.
    /// OPTIONAL by the docs text — ITS-REST docs/query/Request.md §Query parameters — parameters exist "Depending on each query definition"; a parameterless stored query binds none
    /// (A stored query with no $parameters must be executable with an empty body.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub query_parameters: Option<QueryParameters>,
}

/// Parameters for `query_execute_adhoc_query` (path/query/header).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryExecuteAdhocQueryParams {
    /// `q` (query)
    pub q: super::common::Aql,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `ehr_id` (query)
    pub ehr_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `offset` (query)
    pub offset: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `fetch` (query)
    pub fetch: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `query_parameters` (query)
    pub query_parameters: Option<QueryParameters>,
    #[serde(rename = "Accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Accept` (header)
    pub accept: Option<String>,
}

/// Parameters for `query_execute_adhoc_query_body` (path/query/header).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryExecuteAdhocQueryBodyParams {
    #[serde(rename = "Accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Accept` (header)
    pub accept: Option<String>,
    #[serde(rename = "Content-Type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Content-Type` (header)
    pub content_type: Option<String>,
}

/// Parameters for `query_execute_stored_query` (path/query/header).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryExecuteStoredQueryParams {
    /// `qualified_query_name` (path)
    pub qualified_query_name: super::common::QueryName,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `ehr_id` (query)
    pub ehr_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `offset` (query)
    pub offset: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `fetch` (query)
    pub fetch: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `query_parameters` (query)
    pub query_parameters: Option<QueryParameters>,
    #[serde(rename = "Accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Accept` (header)
    pub accept: Option<String>,
}

/// Parameters for `query_execute_stored_query_body` (path/query/header).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryExecuteStoredQueryBodyParams {
    /// `qualified_query_name` (path)
    pub qualified_query_name: super::common::QueryName,
    #[serde(rename = "Accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Accept` (header)
    pub accept: Option<String>,
    #[serde(rename = "Content-Type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Content-Type` (header)
    pub content_type: Option<String>,
}

/// Parameters for `query_execute_stored_query_version` (path/query/header).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryExecuteStoredQueryVersionParams {
    /// `qualified_query_name` (path)
    pub qualified_query_name: super::common::QueryName,
    /// `version` (path)
    pub version: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `ehr_id` (query)
    pub ehr_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `offset` (query)
    pub offset: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `fetch` (query)
    pub fetch: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `query_parameters` (query)
    pub query_parameters: Option<QueryParameters>,
    #[serde(rename = "Accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Accept` (header)
    pub accept: Option<String>,
}

/// Parameters for `query_execute_stored_query_version_body` (path/query/header).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryExecuteStoredQueryVersionBodyParams {
    /// `qualified_query_name` (path)
    pub qualified_query_name: super::common::QueryName,
    /// `version` (path)
    pub version: String,
    #[serde(rename = "Accept")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Accept` (header)
    pub accept: Option<String>,
    #[serde(rename = "Content-Type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    /// `Content-Type` (header)
    pub content_type: Option<String>,
}

/// Server contract for the `query` API group (ITS-REST). Every method
/// defaults to returning `ApiError::NotImplemented`, so an implementor
/// (the application service, or a test stub) overrides only the
/// operations it supports.
#[async_trait::async_trait]
pub trait QueryApi {
    /// `GET /query/aql`
    async fn query_execute_adhoc_query(
        &self,
        params: QueryExecuteAdhocQueryParams,
    ) -> Result<ResultSet, crate::rest::runtime::ApiError> {
        Err(crate::rest::runtime::ApiError::NotImplemented)
    }
    /// `POST /query/aql`
    async fn query_execute_adhoc_query_body(
        &self,
        params: QueryExecuteAdhocQueryBodyParams,
        body: AdhocQueryExecute,
    ) -> Result<ResultSet, crate::rest::runtime::ApiError> {
        Err(crate::rest::runtime::ApiError::NotImplemented)
    }
    /// `GET /query/{qualified_query_name}`
    async fn query_execute_stored_query(
        &self,
        params: QueryExecuteStoredQueryParams,
    ) -> Result<ResultSet, crate::rest::runtime::ApiError> {
        Err(crate::rest::runtime::ApiError::NotImplemented)
    }
    /// `POST /query/{qualified_query_name}`
    async fn query_execute_stored_query_body(
        &self,
        params: QueryExecuteStoredQueryBodyParams,
        body: Query,
    ) -> Result<ResultSet, crate::rest::runtime::ApiError> {
        Err(crate::rest::runtime::ApiError::NotImplemented)
    }
    /// `GET /query/{qualified_query_name}/{version}`
    async fn query_execute_stored_query_version(
        &self,
        params: QueryExecuteStoredQueryVersionParams,
    ) -> Result<ResultSet, crate::rest::runtime::ApiError> {
        Err(crate::rest::runtime::ApiError::NotImplemented)
    }
    /// `POST /query/{qualified_query_name}/{version}`
    async fn query_execute_stored_query_version_body(
        &self,
        params: QueryExecuteStoredQueryVersionBodyParams,
        body: Query,
    ) -> Result<ResultSet, crate::rest::runtime::ApiError> {
        Err(crate::rest::runtime::ApiError::NotImplemented)
    }
}

/// The operations of this group as `(method, path, operation_id)`, for
/// wiring an axum router in `ferroehr-rest`.
pub const ROUTES: &[(&str, &str, &str)] = &[
    ("GET", "/query/aql", "query_execute_adhoc_query"),
    ("POST", "/query/aql", "query_execute_adhoc_query_body"),
    (
        "GET",
        "/query/{qualified_query_name}",
        "query_execute_stored_query",
    ),
    (
        "POST",
        "/query/{qualified_query_name}",
        "query_execute_stored_query_body",
    ),
    (
        "GET",
        "/query/{qualified_query_name}/{version}",
        "query_execute_stored_query_version",
    ),
    (
        "POST",
        "/query/{qualified_query_name}/{version}",
        "query_execute_stored_query_version_body",
    ),
];