Module config

Source
Expand description

Core runtime configuration.

This module defines configuration that should be resolved once at process startup and then passed into core services. The intent is to avoid reading process-wide environment variables during request handling, which can lead to inconsistent behaviour in multi-threaded runtimes and test harnesses.

§Configuration Sources

Configuration is typically resolved from environment variables at startup:

  • PATIENT_DATA_DIR: Base directory for patient data storage
  • RM_SYSTEM_VERSION: OpenEHR Reference Model version (optional)
  • VPR_NAMESPACE: Namespace identifier for this VPR instance

§Directory Structure

The configuration establishes the following directory layout:

patient_data_dir/
├── clinical/          # Clinical records (Git repos per patient)
└── demographics/      # Demographic data (JSON files per patient)

§Safety and Validation

Configuration values are validated at construction time:

  • Directory paths must exist and be accessible
  • Namespace cannot be empty
  • RM version must be supported

§Usage Pattern

// In main.rs or startup code
let config = CoreConfig::new(
    patient_data_dir,
    rm_version,
    namespace,
)?;

// Pass to services
let clinical_service = ClinicalService::new(Arc::new(config.clone()));
let demographics_service = DemographicsService::new(Arc::new(config));

Structs§

CoreConfig
Core configuration resolved at startup.

Functions§

rm_system_version_from_env_value
Parse the RM system version from an optional string value.