Struct Client

Source
pub struct Client<Version = DefaultVersion>(/* private fields */);
Expand description

FHIR REST Client.

Implementations§

Source§

impl<V: FhirVersion> Client<V>

Source

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.

Source

pub async fn read<R: AnyResource<V> + DeserializeOwned>( &self, id: &str, ) -> Result<Option<R>, Error>

Read the current version of a specific FHIR resource.

Source

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.

Source

pub async fn read_referenced( &self, reference: &V::Reference, ) -> Result<V::Resource, Error>

Read the resource that is targeted in the reference.

Source

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.

Source

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.

Source

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.

Source

pub async fn delete( &self, resource_type: V::ResourceType, id: &str, ) -> Result<(), Error>

Delete a FHIR resource on the server.

Source

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.

Source

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.

Source

pub async fn search_custom<R, F>( &self, make_request: F, ) -> Result<Page<V, R>, Error>
where R: TryFrom<V::Resource> + Send + Sync + 'static, for<'a> &'a R: TryFrom<&'a V::Resource>, F: FnOnce(&Client) -> RequestBuilder + Send,

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]).

Source

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.

Source

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.

Source

pub fn batch(&self) -> BatchTransaction<V>

Start building a new batch request.

Source

pub fn transaction(&self) -> BatchTransaction<V>

Start building a new transaction request.

Source§

impl Client<FhirR5>

Source

pub async fn operation_encounter_everything( &self, id: &str, ) -> Result<Bundle, Error>

Operation $everything on Encounter, returning a Bundle with all resources for an Encounter record.

Source§

impl Client<FhirR5>

Source

pub async fn operation_patient_everything( &self, id: &str, ) -> Result<Bundle, Error>

Operation $everything on Patient, returning a Bundle with all resources for an Patient record.

Source§

impl Client<FhirR5>

Source

pub async fn operation_patient_match( &self, patient: Patient, only_certain: bool, count: i32, ) -> Result<Bundle, Error>

Operation $match on Patient, returning matches for Patient records based on a given incomplete Patient resource.

Source§

impl Client<FhirR5>

Source

pub async fn operation_subscription_status( &self, id: &str, ) -> Result<SubscriptionStatus, Error>

Operation $status on Subscription, returning the SubcriptionStatus.

Source§

impl Client<FhirR5>

Source

pub async fn operation_subscription_events( &self, id: &str, events_since: Option<i64>, events_until: Option<i64>, content: Option<SubscriptionPayloadContent>, ) -> Result<Bundle, Error>

Operation $events on Subscription, returning the previous notifications that were triggered by a topic.

Source§

impl<V: FhirVersion> Client<V>

Source

pub fn builder() -> ClientBuilder<V>

Start building a new client with custom settings.

Source

pub fn new(base_url: Url) -> Result<Self, Error>

Create a new client with default settings.

Source

pub fn base_url(&self) -> &Url

Get the configured base URL.

Source

pub fn request_settings(&self) -> RequestSettings

Get the request settings configured in this client.

Source

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).

Source

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.

Source

pub fn stu3(self) -> Client<FhirStu3>

Switch the client to STU3 mode.

Source

pub fn r4b(self) -> Client<FhirR4B>

Switch the client to R4B mode.

Source

pub fn r5(self) -> Client<FhirR5>

Switch the client to R5 mode.

Source

pub async fn send_custom_request<F>( &self, make_request: F, ) -> Result<Response, Error>
where F: FnOnce(&Client) -> RequestBuilder + Send,

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).

Trait Implementations§

Source§

impl<V> Clone for Client<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V> Debug for Client<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Version> Freeze for Client<Version>

§

impl<Version = FhirR5> !RefUnwindSafe for Client<Version>

§

impl<Version> Send for Client<Version>
where Version: Send,

§

impl<Version> Sync for Client<Version>
where Version: Sync,

§

impl<Version> Unpin for Client<Version>
where Version: Unpin,

§

impl<Version = FhirR5> !UnwindSafe for Client<Version>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,