Skip to main content

cima_rs/endpoints/
changes.rs

1use crate::api_client::CimaClient;
2use crate::models::ChangeRecord;
3use anyhow::{Context, Result};
4
5impl CimaClient {
6    /// Get change log from a specific date
7    ///
8    /// Returns a paginated response with medication changes
9    ///
10    /// # Arguments
11    /// * `date` - Date in format "dd/mm/yyyy"
12    /// * `registration_numbers` - Optional list of registration numbers to filter
13    pub async fn get_change_log(
14        &self,
15        date: &str,
16        registration_numbers: Option<&[&str]>,
17    ) -> Result<crate::models::PaginatedResponse<ChangeRecord>> {
18        let mut params = vec![("fecha", date.to_string())];
19
20        if let Some(regs) = registration_numbers {
21            for reg in regs {
22                params.push(("nregistro", reg.to_string()));
23            }
24        }
25
26        self.get_with_params("registroCambios", &params)
27            .await
28            .context("Failed to get change log")
29    }
30}