diff --git a/rustmodels/src/medrecord/querying/attributes.rs b/rustmodels/src/medrecord/querying/attributes.rs index 0c109c61..b6132101 100644 --- a/rustmodels/src/medrecord/querying/attributes.rs +++ b/rustmodels/src/medrecord/querying/attributes.rs @@ -1,4 +1,6 @@ -use medmodels_core::medrecord::{AttributesTreeOperand, Wrapper}; +use medmodels_core::medrecord::{ + AttributesTreeOperand, MultipleAttributesOperand, SingleAttributeOperand, Wrapper, +}; use pyo3::pyclass; #[pyclass] @@ -16,3 +18,35 @@ impl From for Wrapper { operand.0 } } + +#[pyclass] +#[repr(transparent)] +pub struct PyMultipleAttributesOperand(Wrapper); + +impl From> for PyMultipleAttributesOperand { + fn from(operand: Wrapper) -> Self { + Self(operand) + } +} + +impl From for Wrapper { + fn from(operand: PyMultipleAttributesOperand) -> Self { + operand.0 + } +} + +#[pyclass] +#[repr(transparent)] +pub struct PySingleAttributeOperand(Wrapper); + +impl From> for PySingleAttributeOperand { + fn from(operand: Wrapper) -> Self { + Self(operand) + } +} + +impl From for Wrapper { + fn from(operand: PySingleAttributeOperand) -> Self { + operand.0 + } +} diff --git a/rustmodels/src/medrecord/querying/nodes.rs b/rustmodels/src/medrecord/querying/nodes.rs index e03e108c..1f31391f 100644 --- a/rustmodels/src/medrecord/querying/nodes.rs +++ b/rustmodels/src/medrecord/querying/nodes.rs @@ -3,7 +3,9 @@ use super::{ PyGroupCardinalityWrapper, PyMedRecordAttributeCardinalityWrapper, }; use crate::medrecord::attribute::PyMedRecordAttribute; -use medmodels_core::medrecord::{EdgeDirection, NodeIndicesOperand, NodeOperand, Wrapper}; +use medmodels_core::medrecord::{ + EdgeDirection, NodeIndexOperand, NodeIndicesOperand, NodeOperand, Wrapper, +}; use pyo3::{ pyclass, pymethods, types::{PyAnyMethods, PyFunction}, @@ -118,3 +120,46 @@ impl From for Wrapper { operand.0 } } + +#[pymethods] +impl PyNodeIndicesOperand { + pub fn max(&mut self) -> PyNodeIndexOperand { + self.0.max().into() + } + + pub fn min(&mut self) -> PyNodeIndexOperand { + self.0.min().into() + } + + pub fn count(&mut self) -> PyNodeIndexOperand { + self.0.count().into() + } + + pub fn sum(&mut self) -> PyNodeIndexOperand { + self.0.sum().into() + } + + pub fn first(&mut self) -> PyNodeIndexOperand { + self.0.first().into() + } + + pub fn last(&mut self) -> PyNodeIndexOperand { + self.0.last().into() + } +} + +#[pyclass] +#[repr(transparent)] +pub struct PyNodeIndexOperand(Wrapper); + +impl From> for PyNodeIndexOperand { + fn from(operand: Wrapper) -> Self { + Self(operand) + } +} + +impl From for Wrapper { + fn from(operand: PyNodeIndexOperand) -> Self { + operand.0 + } +} diff --git a/rustmodels/src/medrecord/querying/values.rs b/rustmodels/src/medrecord/querying/values.rs index 5a7f0032..9960e1b0 100644 --- a/rustmodels/src/medrecord/querying/values.rs +++ b/rustmodels/src/medrecord/querying/values.rs @@ -1,4 +1,4 @@ -use medmodels_core::medrecord::{MultipleValuesOperand, Wrapper}; +use medmodels_core::medrecord::{MultipleValuesOperand, SingleValueOperand, Wrapper}; use pyo3::pyclass; #[pyclass] @@ -16,3 +16,19 @@ impl From for Wrapper { operand.0 } } + +#[pyclass] +#[repr(transparent)] +pub struct PySingleValueOperand(Wrapper); + +impl From> for PySingleValueOperand { + fn from(operand: Wrapper) -> Self { + Self(operand) + } +} + +impl From for Wrapper { + fn from(operand: PySingleValueOperand) -> Self { + operand.0 + } +}