Expand description
§FHIR Model Infrastructure
This module provides the foundational types and infrastructure that support the generated FHIR specification implementations. It contains hand-coded types that enable the generated code to handle FHIR’s complex requirements for precision, extensions, and cross-version compatibility.
§Architecture
The FHIR crate is organized as follows:
- Generated modules (
r4.rs,r4b.rs,r5.rs,r6.rs): Complete FHIR type implementations - Infrastructure module (
lib.rs): Foundational types used by generated code - Test modules: Validation against official FHIR examples
§Key Infrastructure Types
PreciseDecimal- High-precision decimal arithmetic preserving original string formatElement<T, Extension>- Base container for FHIR elements with extension supportDecimalElement<Extension>- Specialized element for decimal valuesFhirVersion- Version enumeration for multi-version support
§Usage Example
use helios_fhir::r4::{Patient, HumanName};
use helios_fhir::PreciseDecimal;
use rust_decimal::Decimal;
// Create a patient with precise decimal handling
let patient = Patient {
name: Some(vec![HumanName {
family: Some("Doe".to_string().into()),
given: Some(vec!["John".to_string().into()]),
..Default::default()
}]),
..Default::default()
};
// Work with precise decimals
let precise = PreciseDecimal::from(Decimal::new(12340, 3)); // 12.340Re-exports§
pub use parameters::ParameterValueAccessor;pub use parameters::VersionIndependentParameters;
Modules§
- compartment
- FHIR CompartmentDefinition spec data.
- compartment_
expressions - Compartment search-param FHIRPath expression tables for each FHIR version.
- implied_
code_ systems - Implied code systems of
code-typed token search parameters (#1395). - parameters
- Version-independent FHIR Parameters resource wrapper
- r4
- FHIR R4 (4.0.1) - generated type definitions
- r5
- FHIR R5 (5.0.0) - generated type definitions
- r6
- FHIR R6 (current) - generated type definitions
- r4b
- FHIR R4B (4.3.0) - generated type definitions
- search
- FHIR SearchParameter spec data.
Structs§
- Decimal
Element - Specialized element container for FHIR decimal values with precision preservation.
- Element
- Generic element container supporting FHIR’s extension mechanism.
- Precise
Decimal - High-precision decimal type that preserves original string representation.
- Precision
Date - Precision-aware FHIR Date type.
- Precision
Date Time - Precision-aware FHIR DateTime type.
- Precision
Instant - A FHIR instant value that preserves the original string representation and precision.
- Precision
Time - Precision-aware FHIR Time type.
Enums§
- Date
Precision - Precision levels for FHIR Date values.
- Date
Time Precision - Precision levels for FHIR DateTime values.
- Fhir
Version - Enumeration of supported FHIR specification versions.
- Time
Precision - Precision levels for FHIR Time values.
Traits§
- Fhir
Complex Type Provider - Trait for providing FHIR complex type information
- Fhir
Primitive Type Provider - Trait for providing FHIR primitive type information
- Fhir
Resource Type Provider - Trait for providing FHIR resource type information
Functions§
- compartment_
params - Returns the search-parameter NAMES that link
resource_typeto the named compartment (e.g."Patient","Group","Encounter","Practitioner","RelatedPerson","Device"), for the specified FHIR version. - deserialize_
forgiving_ option - Custom deserializer that is more forgiving of null values in JSON.
- field_
exists_ anywhere - Returns true when
field_nameappears anywhere in the per-versionFIELD_TYPEStable. Used as a parent-context-free fallback for detecting polymorphic typed variants (valueQuantity,deceasedBoolean, …) when the parent FHIR type isn’t statically known. - field_
types - Returns the per-version
FIELD_TYPESslice when the version’s feature is compiled in. Each entry is(parent_type, field_name, field_type, is_collection). Use this when you need to enumerate all fields of a parent type — for a single-field lookup, preferget_field_type. - get_
compartment_ params - Returns the compartment search parameters for a given FHIR version.
- get_
field_ type - Dispatches a field-type lookup to the per-version generated
FIELD_TYPEStable. Returns(field_type, is_collection)when the(parent_type, field_name)pair is known, orNonewhen the version variant isn’t compiled in (e.g. a downstream crate enabledhelios-fhirfeatures that this build doesn’t have). - is_
primitive_ type - Returns true when
nameis the type code of a FHIR primitive datatype (case-sensitive, lowercase as in the FHIR spec —boolean,integer,dateTime, …). The set is the union across FHIR versions, sointeger64(added in R5) andxhtmlare included regardless of which version feature is enabled. - summary_
elements - Returns the JSON element names (camelCase —
billablePeriod,type,use) of every element the FHIR specification marksisSummary: trueonresource_type, for the specified FHIR version: the set_summary=truekeeps. An unknown resource type gets the generated lookup’s minimalresourceType,id,metaset.