ResourceTrait

Trait ResourceTrait 

Source
pub trait ResourceTrait: Clone {
    // Required methods
    fn resource_name(&self) -> &str;
    fn to_fhir_resource(&self) -> FhirResource;
    fn get_last_updated(&self) -> Option<DateTime<Utc>>;
}
Expand description

Trait for abstracting Resource across FHIR versions.

This trait provides version-agnostic access to FHIR resource functionality, enabling the core processing logic to work with resources from any supported FHIR version. Resources are the primary data objects processed by ViewDefinitions.

§Key Functionality

  • Type Identification: Determine the resource type (Patient, Observation, etc.)
  • Version Wrapping: Convert to version-agnostic containers for FHIRPath evaluation

§Examples

use helios_sof::traits::ResourceTrait;
use helios_fhir::FhirResource;

fn process_resource<R: ResourceTrait>(resource: &R) {
    println!("Processing {} resource", resource.resource_name());
     
    // Convert to FhirResource for FHIRPath evaluation
    let fhir_resource = resource.to_fhir_resource();
     
    // Now can be used with FHIRPath evaluation context
    // let context = EvaluationContext::new(vec![fhir_resource]);
}

Required Methods§

Source

fn resource_name(&self) -> &str

Returns the FHIR resource type name (e.g., “Patient”, “Observation”)

Source

fn to_fhir_resource(&self) -> FhirResource

Converts this resource to a version-agnostic FhirResource for FHIRPath evaluation

Source

fn get_last_updated(&self) -> Option<DateTime<Utc>>

Returns the lastUpdated timestamp from the resource’s metadata if available

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ResourceTrait for Resource

Implementors§