Skip to main content

Crate helios_fhir

Crate helios_fhir 

Source
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

§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.340

Re-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§

DecimalElement
Specialized element container for FHIR decimal values with precision preservation.
Element
Generic element container supporting FHIR’s extension mechanism.
PreciseDecimal
High-precision decimal type that preserves original string representation.
PrecisionDate
Precision-aware FHIR Date type.
PrecisionDateTime
Precision-aware FHIR DateTime type.
PrecisionInstant
A FHIR instant value that preserves the original string representation and precision.
PrecisionTime
Precision-aware FHIR Time type.

Enums§

DatePrecision
Precision levels for FHIR Date values.
DateTimePrecision
Precision levels for FHIR DateTime values.
FhirVersion
Enumeration of supported FHIR specification versions.
TimePrecision
Precision levels for FHIR Time values.

Traits§

FhirComplexTypeProvider
Trait for providing FHIR complex type information
FhirPrimitiveTypeProvider
Trait for providing FHIR primitive type information
FhirResourceTypeProvider
Trait for providing FHIR resource type information

Functions§

compartment_params
Returns the search-parameter NAMES that link resource_type to 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_name appears anywhere in the per-version FIELD_TYPES table. 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_TYPES slice 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, prefer get_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_TYPES table. Returns (field_type, is_collection) when the (parent_type, field_name) pair is known, or None when the version variant isn’t compiled in (e.g. a downstream crate enabled helios-fhir features that this build doesn’t have).
is_primitive_type
Returns true when name is 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, so integer64 (added in R5) and xhtml are 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 marks isSummary: true on resource_type, for the specified FHIR version: the set _summary=true keeps. An unknown resource type gets the generated lookup’s minimal resourceType, id, meta set.