pub struct Client<Version = DefaultVersion>(/* private fields */);
Expand description
FHIR REST Client.
Implementations§
Source§impl<V: FhirVersion> Client<V>
impl<V: FhirVersion> Client<V>
Sourcepub async fn capabilities(&self) -> Result<V::CapabilityStatement, Error>
pub async fn capabilities(&self) -> Result<V::CapabilityStatement, Error>
Get the server’s capabilities. Fails if the respective FHIR version is not supported at all.
Sourcepub async fn read<R: AnyResource<V> + DeserializeOwned>(
&self,
id: &str,
) -> Result<Option<R>, Error>
pub async fn read<R: AnyResource<V> + DeserializeOwned>( &self, id: &str, ) -> Result<Option<R>, Error>
Read the current version of a specific FHIR resource.
Sourcepub async fn read_version<R: AnyResource<V> + DeserializeOwned>(
&self,
id: &str,
version_id: &str,
) -> Result<Option<R>, Error>
pub async fn read_version<R: AnyResource<V> + DeserializeOwned>( &self, id: &str, version_id: &str, ) -> Result<Option<R>, Error>
Read a specific version of a specific FHIR resource.
Sourcepub async fn read_referenced(
&self,
reference: &V::Reference,
) -> Result<V::Resource, Error>
pub async fn read_referenced( &self, reference: &V::Reference, ) -> Result<V::Resource, Error>
Read the resource that is targeted in the reference.
Sourcepub async fn history<R>(&self, id: Option<&str>) -> Result<Page<V, R>, Error>where
R: AnyResource<V> + TryFrom<V::Resource, Error = WrongResourceType> + 'static,
for<'a> &'a R: TryFrom<&'a V::Resource>,
pub async fn history<R>(&self, id: Option<&str>) -> Result<Page<V, R>, Error>where
R: AnyResource<V> + TryFrom<V::Resource, Error = WrongResourceType> + 'static,
for<'a> &'a R: TryFrom<&'a V::Resource>,
Retrieve the history of the specified resource type or a specific resource.
Sourcepub async fn create<R: AnyResource<V> + Serialize + Send + Sync>(
&self,
resource: &R,
) -> Result<(String, Option<String>), Error>
pub async fn create<R: AnyResource<V> + Serialize + Send + Sync>( &self, resource: &R, ) -> Result<(String, Option<String>), Error>
Create a new FHIR resource on the FHIR server. Returns the resource ID and version ID.
Sourcepub async fn update<R: AnyResource<V> + Serialize + Send + Sync>(
&self,
resource: &R,
conditional: bool,
) -> Result<(bool, String), Error>
pub async fn update<R: AnyResource<V> + Serialize + Send + Sync>( &self, resource: &R, conditional: bool, ) -> Result<(bool, String), Error>
Update a FHIR resource (or create it if it did not exist). If conditional update is selected, the resource is only updated if the version ID matches the expectations.
Sourcepub async fn delete(
&self,
resource_type: V::ResourceType,
id: &str,
) -> Result<(), Error>
pub async fn delete( &self, resource_type: V::ResourceType, id: &str, ) -> Result<(), Error>
Delete a FHIR resource on the server.
Sourcepub async fn search_all(
&self,
queries: SearchParameters,
) -> Result<Page<V, V::Resource>, Error>
pub async fn search_all( &self, queries: SearchParameters, ) -> Result<Page<V, V::Resource>, Error>
Search for FHIR resources of any type given the query parameters.
Sourcepub async fn search<R>(
&self,
queries: SearchParameters,
) -> Result<Page<V, R>, Error>where
R: AnyResource<V> + TryFrom<V::Resource, Error = WrongResourceType> + 'static,
for<'a> &'a R: TryFrom<&'a V::Resource>,
pub async fn search<R>(
&self,
queries: SearchParameters,
) -> Result<Page<V, R>, Error>where
R: AnyResource<V> + TryFrom<V::Resource, Error = WrongResourceType> + 'static,
for<'a> &'a R: TryFrom<&'a V::Resource>,
Search for FHIR resources of a given type given the query parameters.
Sourcepub async fn search_custom<R, F>(
&self,
make_request: F,
) -> Result<Page<V, R>, Error>
pub async fn search_custom<R, F>( &self, make_request: F, ) -> Result<Page<V, R>, Error>
Search for FHIR resources via a custom request. This allows sending POST requests instead of GET when necessary. You can construct the request yourself to any URL and send any data. The endpoint is expected to send a FHIR-conform bundle.
You can specify the expected search entry type via the type parameter. This can be either the generic resource or a specific resource.
Keep in mind that mismatching origins to the base URL are rejected if not explicitly allowed via the flag in the builder ([ClientBuilder::allow_origin_mismatch]). Similarly, if the server responds with a different major FHIR version than the client is configured for, the response is rejected if not explicitly allowed via the flag in the builder ([ClientBuilder::allow_version_mismatch]).
Sourcepub fn patch_via_fhir<'a>(
&self,
resource_type: V::ResourceType,
id: &'a str,
) -> PatchViaFhir<'a, V>
pub fn patch_via_fhir<'a>( &self, resource_type: V::ResourceType, id: &'a str, ) -> PatchViaFhir<'a, V>
Begin building a patch request for a FHIR resource on the server via the
FHIRPath Patch
method.
Sourcepub fn patch_via_json<'a>(
&self,
resource_type: V::ResourceType,
id: &'a str,
) -> PatchViaJson<'a, V>
pub fn patch_via_json<'a>( &self, resource_type: V::ResourceType, id: &'a str, ) -> PatchViaJson<'a, V>
Begin building a patch request for a FHIR resource on the server via the
JSON Patch
method.
Sourcepub fn transaction(&self) -> BatchTransaction<V>
pub fn transaction(&self) -> BatchTransaction<V>
Start building a new transaction request.
Source§impl Client<FhirR5>
impl Client<FhirR5>
Sourcepub async fn operation_subscription_status(
&self,
id: &str,
) -> Result<SubscriptionStatus, Error>
pub async fn operation_subscription_status( &self, id: &str, ) -> Result<SubscriptionStatus, Error>
Operation $status
on Subscription
, returning the
SubcriptionStatus
.
Source§impl<V: FhirVersion> Client<V>
impl<V: FhirVersion> Client<V>
Sourcepub fn builder() -> ClientBuilder<V>
pub fn builder() -> ClientBuilder<V>
Start building a new client with custom settings.
Sourcepub fn request_settings(&self) -> RequestSettings
pub fn request_settings(&self) -> RequestSettings
Get the request settings configured in this client.
Sourcepub fn set_request_settings(&self, settings: RequestSettings)
pub fn set_request_settings(&self, settings: RequestSettings)
Set the request settings for this client. Be warned that this can be
subject to race conditions. Prefer to use
Self::patch_request_settings. Basically same as
client.patch_request_settings(|_| new_settings)
.
Sourcepub fn patch_request_settings<F>(&self, mutator: F)
pub fn patch_request_settings<F>(&self, mutator: F)
Patch the request settings atomically. Blocks all requests until the change to request settings is finished.
Sourcepub async fn send_custom_request<F>(
&self,
make_request: F,
) -> Result<Response, Error>
pub async fn send_custom_request<F>( &self, make_request: F, ) -> Result<Response, Error>
Send a custom HTTP request anywhere you want, but using this client’s
internal HTTP machinery. The machinery includes automatic authentication
if configured (auth_callback
) and automatic retrying of requests on
connection problems (as per request_settings
).
Keep in mind that mismatching origins to the base URL are rejected if not explicitly allowed via the flag in the builder (ClientBuilder::allow_origin_mismatch). Similarly, if the server responds with a different major FHIR version than the client is configured for, the response is rejected if not explicitly allowed via the flag in the builder (ClientBuilder::allow_version_mismatch).