#google-cloud #healthcare #google

google-healthcare1

与Cloud Healthcare(协议v1)交互的完整库

12个稳定版本 (4个主要版本)

5.0.5+20240605 2024年6月27日
5.0.4+20240228 2024年3月5日
5.0.3+20221220 2023年8月23日
5.0.2+20221220 2023年3月16日
1.0.14+20200612 2020年7月10日

#2274 in Web编程


用于 google-healthcare1-cli

MIT 许可证

2.5MB
26K SLoC

google-healthcare1 库允许访问Google Cloud Healthcare服务的所有功能。

本文档是从Cloud Healthcare crate版本5.0.5+20240605生成的,其中20240605mako代码生成器v5.0.5构建的healthcare:v1模式的精确版本。

有关Cloud Healthcare v1 API的其他所有信息,请参阅官方文档网站

功能

从中心 枢纽 轻松处理以下 资源...

本库的结构

API结构如下

  • 枢纽
    • 一个中心对象,用于维护状态和允许访问所有 活动
    • 创建 方法构建器,这些构建器反过来又允许访问单个 调用构建器
  • 资源
    • 可以将其应用于 活动 的主要类型
    • 一组属性和 部分
    • 部分
      • 一组属性
      • 从未直接用于 活动
  • 活动
    • 应用于 资源 的操作

所有 结构 都带有适用的特性,以便进一步分类并简化浏览。

一般来说,您可以像这样调用 活动

let r = hub.resource().activity(...).doit().await

或具体...

let r = hub.projects().locations_datasets_dicom_stores_studies_series_instances_frames_retrieve_frames(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_instances_frames_retrieve_rendered(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_instances_retrieve_instance(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_instances_retrieve_metadata(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_instances_retrieve_rendered(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_retrieve_metadata(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_retrieve_series(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_series_search_for_instances(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_retrieve_metadata(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_retrieve_study(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_search_for_instances(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_search_for_series(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_studies_store_instances(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_search_for_instances(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_search_for_series(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_search_for_studies(...).doit().await
let r = hub.projects().locations_datasets_dicom_stores_store_instances(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir__patient_everything(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir__resource_validate(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_capabilities(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_conditional_patch(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_conditional_update(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_create(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_delete(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_execute_bundle(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_history(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_patch(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_read(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_search(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_search_type(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_update(...).doit().await
let r = hub.projects().locations_datasets_fhir_stores_fhir_vread(...).doit().await

resource()activity(...) 调用创建 构建器。第二个处理 Activities,支持各种配置即将进行的操作的方法(此处未显示)。它被设计成必须立即指定所有必需的参数(即 (...)),而所有可选的参数可以按照所需的任何方式构建。 doit() 方法执行与服务器实际通信并返回相应的结果。

使用方法

设置您的项目

要使用这个库,您需要将以下几行代码添加到您的 Cargo.toml 文件中

[dependencies]
google-healthcare1 = "*"
serde = "^1.0"
serde_json = "^1.0"

一个完整的示例

extern crate hyper;
extern crate hyper_rustls;
extern crate google_healthcare1 as healthcare1;
use healthcare1::{Result, Error};
use std::default::Default;
use healthcare1::{CloudHealthcare, oauth2, hyper, hyper_rustls, chrono, FieldMask};

// Get an ApplicationSecret instance by some means. It contains the `client_id` and 
// `client_secret`, among other things.
let secret: oauth2::ApplicationSecret = Default::default();
// Instantiate the authenticator. It will choose a suitable authentication flow for you, 
// unless you replace  `None` with the desired Flow.
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about 
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
// retrieve them from storage.
let auth = oauth2::InstalledFlowAuthenticator::builder(
        secret,
        oauth2::InstalledFlowReturnMethod::HTTPRedirect,
    ).build().await.unwrap();
let mut hub = CloudHealthcare::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
// You can configure optional parameters by calling the respective setters at will, and
// execute the final call using `doit()`.
// Values shown here are possibly random and not representative !
let result = hub.projects().locations_datasets_fhir_stores_fhir__patient_everything("name")
             .start("magna")
             .end("no")
             ._type("ipsum")
             ._since("voluptua.")
             ._page_token("At")
             ._count(-8)
             .doit().await;

match result {
    Err(e) => match e {
        // The Error enum provides details about what exactly happened.
        // You can also just use its `Debug`, `Display` or `Error` traits
         Error::HttpError(_)
        |Error::Io(_)
        |Error::MissingAPIKey
        |Error::MissingToken(_)
        |Error::Cancelled
        |Error::UploadSizeLimitExceeded(_, _)
        |Error::Failure(_)
        |Error::BadRequest(_)
        |Error::FieldClash(_)
        |Error::JsonDecodeError(_, _) => println!("{}", e),
    },
    Ok(res) => println!("Success: {:?}", res),
}

错误处理

系统产生的所有错误都作为 Result 枚举返回,这些枚举作为 doit() 方法的返回值,或者作为可能的中途结果传递给 Hub DelegateAuthenticator Delegate

当代理处理错误或中间值时,它们可能会有机会指示系统重试。这使得系统对各种错误具有潜在的鲁棒性。

上传和下载

如果某个方法支持下载,您应该读取响应体以获取媒体,响应体是 Result 的一部分。如果这样的方法也支持 Response Result,则默认返回该结果。您可以将它视为实际媒体的元数据。要触发媒体下载,您必须通过以下调用设置构建器:.param("alt", "media")

支持上传的方法可以使用多达 2 种不同的协议进行上传:简单可重试。每种协议的独特性通过定制的 doit(...) 方法表示,这些方法分别命名为 upload(...)upload_resumable(...)

定制和回调

您可以通过在最终调用 doit() 之前向 Method Builder 提供一个 delegate 来改变 doit() 方法被调用的方式。相应的方会调用提供进度信息,以及确定系统在失败时是否应该重试。

delegate trait 默认实现,允许您以最小的努力对其进行定制。

服务器请求中的可选部分

该库提供的所有结构都是通过 json 编码和解码的,以便 encodabledecodable。可选用于表示部分请求或响应是有效的。大多数可选都是 Parts,这些部分可以通过名称识别,将被发送到服务器以指示请求中设置的部件或响应中期望的部件。

构建器参数

通过使用 method builders,您可以通过重复调用其方法来准备一个操作调用。这些方法始终接受单个参数,以下语句是正确的。

参数将始终被复制或克隆到构建器中,以确保它们与其原始生命周期独立。

Cargo 功能

  • utoipa - 添加对 utoipa 的支持,并在所有类型上派生 utoipa::ToSchema。您必须在 #[openapi(schemas(...))] 中导入和注册所需的类型,否则生成的 openapi 规范将是无效的。

许可证

healthcare1 库是由 Sebastian Thiel 生成的,并置于 MIT 许可证之下。您可以在存储库的 许可证文件 中阅读全文。

依赖关系

~12–23MB
~347K SLoC