/*
* Orthanc API
*
* This is the full documentation of the [REST API](https://orthanc.uclouvain.be/book/users/rest.html) of Orthanc.<p>This reference is automatically generated from the source code of Orthanc. A [shorter cheat sheet](https://orthanc.uclouvain.be/book/users/rest-cheatsheet.html) is part of the Orthanc Book.<p>An earlier, manually crafted version from August 2019, is [still available](2019-08-orthanc-openapi.html), but is not up-to-date anymore ([source](https://groups.google.com/g/orthanc-users/c/NUiJTEICSl8/m/xKeqMrbqAAAJ)).
*
* The version of the OpenAPI document: 1.12.8
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`patients_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_anonymize_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAnonymizePostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_archive_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdArchiveGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_archive_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdArchivePostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_compress_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameCompressPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_compressed_data_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameCompressedDataGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_compressed_md5_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameCompressedMd5GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_compressed_size_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameCompressedSizeGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_data_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameDataGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_info_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameInfoGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_is_compressed_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameIsCompressedGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_md5_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameMd5GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNamePutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_size_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameSizeGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_uncompress_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameUncompressPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_attachments_name_verify_md5_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdAttachmentsNameVerifyMd5PostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_instances_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdInstancesGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_instances_tags_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdInstancesTagsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_labels_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdLabelsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_labels_label_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdLabelsLabelDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_labels_label_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdLabelsLabelGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_labels_label_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdLabelsLabelPutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_media_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdMediaGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_media_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdMediaPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_metadata_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdMetadataGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_metadata_name_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdMetadataNameDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_metadata_name_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdMetadataNameGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_metadata_name_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdMetadataNamePutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_modify_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdModifyPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_module_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdModuleGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_protected_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdProtectedGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_protected_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdProtectedPutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_reconstruct_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdReconstructPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_series_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdSeriesGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_shared_tags_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdSharedTagsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_statistics_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdStatisticsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patients_id_studies_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatientsIdStudiesGetError {
UnknownValue(serde_json::Value),
}
/// List the Orthanc identifiers of all the available DICOM patients
pub async fn patients_get(configuration: &configuration::Configuration, expand: Option<&str>, full: Option<bool>, limit: Option<f64>, requested_tags: Option<&str>, response_content: Option<&str>, short: Option<bool>, since: Option<f64>) -> Result<serde_json::Value, Error<PatientsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_expand = expand;
let p_full = full;
let p_limit = limit;
let p_requested_tags = requested_tags;
let p_response_content = response_content;
let p_short = short;
let p_since = since;
let uri_str = format!("{}/patients", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_response_content {
req_builder = req_builder.query(&[("response-content", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_since {
req_builder = req_builder.query(&[("since", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Start a job that will anonymize all the DICOM instances within the patient whose identifier is provided in the URL. The modified DICOM instances will be stored into a brand new patient, whose Orthanc identifiers will be returned by the job. <https://orthanc.uclouvain.be/book/users/anonymization.html>#anonymization-of-patients-studies-or-series
pub async fn patients_id_anonymize_post(configuration: &configuration::Configuration, id: &str, patients_id_anonymize_post_request: Option<models::PatientsIdAnonymizePostRequest>) -> Result<models::ModalitiesIdGetPost200Response, Error<PatientsIdAnonymizePostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_patients_id_anonymize_post_request = patients_id_anonymize_post_request;
let uri_str = format!("{}/patients/{id}/anonymize", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_patients_id_anonymize_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModalitiesIdGetPost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModalitiesIdGetPost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAnonymizePostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Synchronously create a ZIP archive containing the DICOM patient whose Orthanc identifier is provided in the URL. This flavor is synchronous, which might *not* be desirable to archive large amount of data, as it might lead to network timeouts. Prefer the asynchronous version using `POST` method.
pub async fn patients_id_archive_get(configuration: &configuration::Configuration, id: &str, filename: Option<&str>, lossy_quality: Option<f64>, transcode: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdArchiveGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_filename = filename;
let p_lossy_quality = lossy_quality;
let p_transcode = transcode;
let uri_str = format!("{}/patients/{id}/archive", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_lossy_quality {
req_builder = req_builder.query(&[("lossy-quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_transcode {
req_builder = req_builder.query(&[("transcode", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdArchiveGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a ZIP archive containing the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_archive_post(configuration: &configuration::Configuration, id: &str, patients_id_archive_post_request: Option<models::PatientsIdArchivePostRequest>) -> Result<models::PatientsIdArchivePost200Response, Error<PatientsIdArchivePostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_patients_id_archive_post_request = patients_id_archive_post_request;
let uri_str = format!("{}/patients/{id}/archive", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_patients_id_archive_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PatientsIdArchivePost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PatientsIdArchivePost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdArchivePostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the list of attachments that are associated with the given patient
pub async fn patients_id_attachments_get(configuration: &configuration::Configuration, id: &str, full: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let uri_str = format!("{}/patients/{id}/attachments", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Change the compression scheme that is used to store an attachment.
pub async fn patients_id_attachments_name_compress_post(configuration: &configuration::Configuration, id: &str, name: &str) -> Result<(), Error<PatientsIdAttachmentsNameCompressPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let uri_str = format!("{}/patients/{id}/attachments/{name}/compress", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameCompressPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the (binary) content of one attachment associated with the given patient. The attachment will not be decompressed if `StorageCompression` is `true`.
pub async fn patients_id_attachments_name_compressed_data_get(configuration: &configuration::Configuration, id: &str, name: &str, filename: Option<&str>, content_range: Option<&str>, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameCompressedDataGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_filename = filename;
let p_content_range = content_range;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/compressed-data", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_content_range {
req_builder = req_builder.header("Content-Range", param_value.to_string());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameCompressedDataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the MD5 hash of one attachment associated with the given patient, as stored on the disk. This is different from `.../md5` iff `EnableStorage` is `true`.
pub async fn patients_id_attachments_name_compressed_md5_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameCompressedMd5GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/compressed-md5", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameCompressedMd5GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the size of one attachment associated with the given patient, as stored on the disk. This is different from `.../size` iff `EnableStorage` is `true`.
pub async fn patients_id_attachments_name_compressed_size_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameCompressedSizeGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/compressed-size", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameCompressedSizeGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the (binary) content of one attachment associated with the given patient
pub async fn patients_id_attachments_name_data_get(configuration: &configuration::Configuration, id: &str, name: &str, filename: Option<&str>, content_range: Option<&str>, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameDataGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_filename = filename;
let p_content_range = content_range;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/data", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_content_range {
req_builder = req_builder.header("Content-Range", param_value.to_string());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameDataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete an attachment associated with the given DICOM patient. This call will fail if trying to delete a system attachment (i.e. whose index is < 1024).
pub async fn patients_id_attachments_name_delete(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>) -> Result<(), Error<PatientsIdAttachmentsNameDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get all the information about the attachment associated with the given patient
pub async fn patients_id_attachments_name_info_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameInfoGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/info", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameInfoGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Test whether the attachment has been stored as a compressed file on the disk.
pub async fn patients_id_attachments_name_is_compressed_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameIsCompressedGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/is-compressed", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameIsCompressedGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the MD5 hash of one attachment associated with the given patient
pub async fn patients_id_attachments_name_md5_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameMd5GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/md5", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameMd5GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Attach a file to the given DICOM patient. This call will fail if trying to modify a system attachment (i.e. whose index is < 1024).
pub async fn patients_id_attachments_name_put(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNamePutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let p_body = body;
let uri_str = format!("{}/patients/{id}/attachments/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNamePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the size of one attachment associated with the given patient
pub async fn patients_id_attachments_name_size_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameSizeGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/attachments/{name}/size", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameSizeGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Change the compression scheme that is used to store an attachment.
pub async fn patients_id_attachments_name_uncompress_post(configuration: &configuration::Configuration, id: &str, name: &str) -> Result<(), Error<PatientsIdAttachmentsNameUncompressPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let uri_str = format!("{}/patients/{id}/attachments/{name}/uncompress", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameUncompressPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Verify that the attachment is not corrupted, by validating its MD5 hash
pub async fn patients_id_attachments_name_verify_md5_post(configuration: &configuration::Configuration, id: &str, name: &str) -> Result<serde_json::Value, Error<PatientsIdAttachmentsNameVerifyMd5PostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let uri_str = format!("{}/patients/{id}/attachments/{name}/verify-md5", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdAttachmentsNameVerifyMd5PostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_delete(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<PatientsIdDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/patients/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_get(configuration: &configuration::Configuration, id: &str, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/patients/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the child instances of the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_instances_get(configuration: &configuration::Configuration, id: &str, expand: Option<&str>, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdInstancesGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_expand = expand;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/patients/{id}/instances", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdInstancesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the tags of all the child instances of the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_instances_tags_get(configuration: &configuration::Configuration, id: &str, ignore_length: Option<Vec<String>>, short: Option<bool>, simplify: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdInstancesTagsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_ignore_length = ignore_length;
let p_short = short;
let p_simplify = simplify;
let uri_str = format!("{}/patients/{id}/instances-tags", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_ignore_length {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ignore-length".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("ignore-length", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_simplify {
req_builder = req_builder.query(&[("simplify", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdInstancesTagsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the labels that are associated with the given patient (new in Orthanc 1.12.0)
pub async fn patients_id_labels_get(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<PatientsIdLabelsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/patients/{id}/labels", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdLabelsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Remove a label associated with a patient
pub async fn patients_id_labels_label_delete(configuration: &configuration::Configuration, id: &str, label: &str) -> Result<(), Error<PatientsIdLabelsLabelDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_label = label;
let uri_str = format!("{}/patients/{id}/labels/{label}", configuration.base_path, id=crate::apis::urlencode(p_id), label=crate::apis::urlencode(p_label));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdLabelsLabelDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Test whether the patient is associated with the given label
pub async fn patients_id_labels_label_get(configuration: &configuration::Configuration, id: &str, label: &str) -> Result<serde_json::Value, Error<PatientsIdLabelsLabelGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_label = label;
let uri_str = format!("{}/patients/{id}/labels/{label}", configuration.base_path, id=crate::apis::urlencode(p_id), label=crate::apis::urlencode(p_label));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdLabelsLabelGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Associate a label with a patient
pub async fn patients_id_labels_label_put(configuration: &configuration::Configuration, id: &str, label: &str) -> Result<(), Error<PatientsIdLabelsLabelPutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_label = label;
let uri_str = format!("{}/patients/{id}/labels/{label}", configuration.base_path, id=crate::apis::urlencode(p_id), label=crate::apis::urlencode(p_label));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdLabelsLabelPutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Synchronously create a DICOMDIR media containing the DICOM patient whose Orthanc identifier is provided in the URL. This flavor is synchronous, which might *not* be desirable to archive large amount of data, as it might lead to network timeouts. Prefer the asynchronous version using `POST` method.
pub async fn patients_id_media_get(configuration: &configuration::Configuration, id: &str, extended: Option<&str>, filename: Option<&str>, lossy_quality: Option<f64>, transcode: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdMediaGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_extended = extended;
let p_filename = filename;
let p_lossy_quality = lossy_quality;
let p_transcode = transcode;
let uri_str = format!("{}/patients/{id}/media", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_extended {
req_builder = req_builder.query(&[("extended", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_lossy_quality {
req_builder = req_builder.query(&[("lossy-quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_transcode {
req_builder = req_builder.query(&[("transcode", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdMediaGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a DICOMDIR media containing the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_media_post(configuration: &configuration::Configuration, id: &str, patients_id_media_post_request: Option<models::PatientsIdMediaPostRequest>) -> Result<models::PatientsIdArchivePost200Response, Error<PatientsIdMediaPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_patients_id_media_post_request = patients_id_media_post_request;
let uri_str = format!("{}/patients/{id}/media", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_patients_id_media_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PatientsIdArchivePost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PatientsIdArchivePost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdMediaPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the list of metadata that are associated with the given patient
pub async fn patients_id_metadata_get(configuration: &configuration::Configuration, id: &str, expand: Option<&str>, numeric: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdMetadataGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_expand = expand;
let p_numeric = numeric;
let uri_str = format!("{}/patients/{id}/metadata", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_numeric {
req_builder = req_builder.query(&[("numeric", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdMetadataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete some metadata associated with the given DICOM patient. This call will fail if trying to delete a system metadata (i.e. whose index is < 1024).
pub async fn patients_id_metadata_name_delete(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>) -> Result<(), Error<PatientsIdMetadataNameDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let uri_str = format!("{}/patients/{id}/metadata/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdMetadataNameDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the value of a metadata that is associated with the given patient
pub async fn patients_id_metadata_name_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<PatientsIdMetadataNameGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/patients/{id}/metadata/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdMetadataNameGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Set the value of some metadata in the given DICOM patient. This call will fail if trying to modify a system metadata (i.e. whose index is < 1024).
pub async fn patients_id_metadata_name_put(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>, body: Option<serde_json::Value>) -> Result<(), Error<PatientsIdMetadataNamePutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let p_body = body;
let uri_str = format!("{}/patients/{id}/metadata/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdMetadataNamePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Start a job that will modify all the DICOM instances within the patient whose identifier is provided in the URL. The modified DICOM instances will be stored into a brand new patient, whose Orthanc identifiers will be returned by the job. <https://orthanc.uclouvain.be/book/users/anonymization.html>#modification-of-studies-or-series
pub async fn patients_id_modify_post(configuration: &configuration::Configuration, id: &str, patients_id_modify_post_request: Option<models::PatientsIdModifyPostRequest>) -> Result<models::ModalitiesIdGetPost200Response, Error<PatientsIdModifyPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_patients_id_modify_post_request = patients_id_modify_post_request;
let uri_str = format!("{}/patients/{id}/modify", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_patients_id_modify_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModalitiesIdGetPost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModalitiesIdGetPost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdModifyPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the patient module of the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_module_get(configuration: &configuration::Configuration, id: &str, ignore_length: Option<Vec<String>>, short: Option<bool>, simplify: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdModuleGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_ignore_length = ignore_length;
let p_short = short;
let p_simplify = simplify;
let uri_str = format!("{}/patients/{id}/module", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_ignore_length {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ignore-length".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("ignore-length", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_simplify {
req_builder = req_builder.query(&[("simplify", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdModuleGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Is the patient protected against recycling?
pub async fn patients_id_protected_get(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<PatientsIdProtectedGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/patients/{id}/protected", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdProtectedGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Protects a patient by sending `1` or `true` in the payload request. Unprotects a patient by sending `0` or `false` in the payload requests. More info: <https://orthanc.uclouvain.be/book/faq/features.html>#recycling-protection
pub async fn patients_id_protected_put(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<PatientsIdProtectedPutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/patients/{id}/protected", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdProtectedPutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reconstruct the main DICOM tags in DB of the patient whose Orthanc identifier is provided in the URL. This is useful if child studies/series/instances have inconsistent values for higher-level tags, in order to force Orthanc to use the value from the resource of interest. Beware that this is a time-consuming operation, as all the children DICOM instances will be parsed again, and the Orthanc index will be updated accordingly.
pub async fn patients_id_reconstruct_post(configuration: &configuration::Configuration, id: &str, instances_id_reconstruct_post_request: Option<models::InstancesIdReconstructPostRequest>) -> Result<(), Error<PatientsIdReconstructPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_instances_id_reconstruct_post_request = instances_id_reconstruct_post_request;
let uri_str = format!("{}/patients/{id}/reconstruct", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_instances_id_reconstruct_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdReconstructPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the child series of the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_series_get(configuration: &configuration::Configuration, id: &str, expand: Option<&str>, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdSeriesGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_expand = expand;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/patients/{id}/series", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdSeriesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Extract the DICOM tags whose value is constant across all the child instances of the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_shared_tags_get(configuration: &configuration::Configuration, id: &str, short: Option<bool>, simplify: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdSharedTagsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_short = short;
let p_simplify = simplify;
let uri_str = format!("{}/patients/{id}/shared-tags", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_simplify {
req_builder = req_builder.query(&[("simplify", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdSharedTagsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get statistics about the given patient
pub async fn patients_id_statistics_get(configuration: &configuration::Configuration, id: &str) -> Result<models::PatientsIdStatisticsGet200Response, Error<PatientsIdStatisticsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/patients/{id}/statistics", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PatientsIdStatisticsGet200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PatientsIdStatisticsGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdStatisticsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the child studies of the DICOM patient whose Orthanc identifier is provided in the URL
pub async fn patients_id_studies_get(configuration: &configuration::Configuration, id: &str, expand: Option<&str>, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<PatientsIdStudiesGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_expand = expand;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/patients/{id}/studies", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatientsIdStudiesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}