Skip to main content

ConditionalStorage

Trait ConditionalStorage 

Source
pub trait ConditionalStorage: ResourceStorage {
    // Required methods
    fn conditional_create<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
        resource_type: &'life2 str,
        resource: Value,
        search_params: &'life3 str,
        fhir_version: FhirVersion,
    ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalCreateResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn conditional_update<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
        resource_type: &'life2 str,
        resource: Value,
        search_params: &'life3 str,
        upsert: bool,
        fhir_version: FhirVersion,
    ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalUpdateResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn conditional_delete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
        resource_type: &'life2 str,
        search_params: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalDeleteResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided method
    fn conditional_patch<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        tenant: &'life1 TenantContext,
        resource_type: &'life2 str,
        search_params: &'life3 str,
        patch: &'life4 PatchFormat,
    ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalPatchResult>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait { ... }
}
Expand description

Extension trait for conditional operations based on search criteria.

Required Methods§

Source

fn conditional_create<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, resource_type: &'life2 str, resource: Value, search_params: &'life3 str, fhir_version: FhirVersion, ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalCreateResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Creates a resource only if no matching resource exists.

§Arguments
  • tenant - The tenant context
  • resource_type - The FHIR resource type
  • resource - The resource to create
  • search_params - Search parameters to check for existing match
  • fhir_version - The FHIR specification version for this resource
§Returns
  • Created - If no match was found and resource was created
  • Exists - If exactly one matching resource was found
  • MultipleMatches - If multiple matching resources were found (error)
Source

fn conditional_update<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, resource_type: &'life2 str, resource: Value, search_params: &'life3 str, upsert: bool, fhir_version: FhirVersion, ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalUpdateResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Updates a resource based on search criteria.

§Arguments
  • tenant - The tenant context
  • resource_type - The FHIR resource type
  • resource - The new resource content
  • search_params - Search parameters to find the resource
  • upsert - If true, create if no match found
  • fhir_version - The FHIR specification version for this resource (used if creating)
§Returns
  • Updated - If exactly one match was found and updated
  • Created - If no match was found and upsert is true
  • NoMatch - If no match was found and upsert is false
  • MultipleMatches - If multiple matches were found (error)
Source

fn conditional_delete<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, resource_type: &'life2 str, search_params: &'life3 str, ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalDeleteResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Deletes a resource based on search criteria.

§Arguments
  • tenant - The tenant context
  • resource_type - The FHIR resource type
  • search_params - Search parameters to find the resource
§Returns
  • Deleted - If exactly one match was found and deleted
  • NoMatch - If no match was found
  • MultipleMatches - If multiple matches were found (error)

Provided Methods§

Source

fn conditional_patch<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, tenant: &'life1 TenantContext, resource_type: &'life2 str, search_params: &'life3 str, patch: &'life4 PatchFormat, ) -> Pin<Box<dyn Future<Output = StorageResult<ConditionalPatchResult>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Patches a resource based on search criteria.

This implements conditional patch as defined in FHIR: PATCH [base]/[type]?[search-params]

§Arguments
  • tenant - The tenant context
  • resource_type - The FHIR resource type
  • search_params - Search parameters to find the resource
  • patch - The patch to apply (JSON Patch, FHIRPath Patch, or Merge Patch)
§Returns
  • Patched - If exactly one match was found and patched
  • NoMatch - If no match was found
  • MultipleMatches - If multiple matches were found (error)
§Errors
  • StorageError::Validation - If the patch is invalid or would create invalid resource
  • StorageError::Backend(NotSupported) - If conditional patch is not supported

Implementors§