v0.5.0: tweak NIBP

This commit is contained in:
GABRIEL Sebastian 2026-11-12 14:07:59 +01:00
commit ef269099bd
12 changed files with 2900 additions and 109 deletions

View file

@ -94,6 +94,10 @@ pub enum Spo2Quality {
}
impl Spo2Quality {
pub fn min(self, other: Self) -> Self {
if (self as u8) <= (other as u8) { self } else { other }
}
pub fn stars(self) -> &'static str {
match self {
Self::None => "",
@ -207,8 +211,12 @@ pub struct Parameters {
pub art_diastolic: i32, // mmHg
pub arterial_shape: ArterialShape,
pub pulse_pressure_variation: i32, // PPV %, 0 disables respiratory variation
pub nibp_systolic: i32, // mmHg, historical/static simulated cuff value
pub nibp_diastolic: i32, // mmHg
pub nibp_systolic: i32, // mmHg, initial measured NIBP result
pub nibp_diastolic: i32, // mmHg, initial measured NIBP result
pub nibp_interval_minutes: i32, // 1 / 3 / 5 / 10 / 20 / 30 / 60
pub nibp_no_reading: bool, // force unsuccessful cuff measurement
pub nibp_cuff_on_spo2: bool, // simulated probe on cuff extremity
pub nibp_cuff_on_art: bool, // simulated arterial catheter on cuff extremity
pub etco2: i32, // mmHg
pub respiratory_rate: i32, // breaths/min
pub capno_shape: CapnoShape,
@ -237,13 +245,14 @@ impl Parameters {
self.spo2_status_during(pulse_rate, false)
}
/// Poor-quality signal interruptions are generated by the simulator and
/// override the normal reading, but not a physically disconnected sensor.
pub fn spo2_status_during(&self, pulse_rate: Option<i32>, signal_lost: bool) -> Spo2Status {
/// Effective quality can be temporarily reduced by an NIBP cuff on the
/// same extremity. A detached probe still has highest priority.
pub fn spo2_status_at_quality(&self, pulse_rate: Option<i32>, signal_lost: bool,
effective_quality: Spo2Quality) -> Spo2Status {
if !self.spo2_sensor_attached {
Spo2Status::NoSensor
} else if (signal_lost && self.spo2_quality == Spo2Quality::Poor)
|| self.spo2_quality == Spo2Quality::None || pulse_rate.is_none()
|| effective_quality == Spo2Quality::None || pulse_rate.is_none()
|| !self.ecg_rhythm.can_generate_pulse()
|| self.pulse_conduction == PulseConduction::None
|| self.heart_rate <= 0
@ -253,6 +262,12 @@ impl Parameters {
Spo2Status::Available
}
}
/// Quality without cuff interference; retained for regression tests.
#[cfg(test)]
pub fn spo2_status_during(&self, pulse_rate: Option<i32>, signal_lost: bool) -> Spo2Status {
self.spo2_status_at_quality(pulse_rate, signal_lost, self.spo2_quality)
}
}
impl Default for Parameters {
@ -272,6 +287,10 @@ impl Default for Parameters {
pulse_pressure_variation: 0,
nibp_systolic: 118,
nibp_diastolic: 74,
nibp_interval_minutes: 5,
nibp_no_reading: false,
nibp_cuff_on_spo2: false,
nibp_cuff_on_art: false,
etco2: 38,
respiratory_rate: 14,
capno_shape: CapnoShape::Normal,