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§
Sourcefn resource_name(&self) -> &str
fn resource_name(&self) -> &str
Returns the FHIR resource type name (e.g., “Patient”, “Observation”)
Sourcefn to_fhir_resource(&self) -> FhirResource
fn to_fhir_resource(&self) -> FhirResource
Converts this resource to a version-agnostic FhirResource for FHIRPath evaluation
Sourcefn get_last_updated(&self) -> Option<DateTime<Utc>>
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.