v0.4.3: Debug and optimize alarms and rhythms
This commit is contained in:
parent
5e397019fc
commit
d4162c49e8
8 changed files with 995 additions and 54 deletions
|
|
@ -221,12 +221,29 @@ pub struct Parameters {
|
|||
}
|
||||
|
||||
impl Parameters {
|
||||
/// Selecting a ventricular tachycardia starts at the teaching default of
|
||||
/// 160 bpm. The instructor can subsequently adjust the heart rate.
|
||||
pub fn select_ecg_rhythm(&mut self, rhythm: EcgRhythm) {
|
||||
self.ecg_rhythm = rhythm;
|
||||
if matches!(rhythm, EcgRhythm::VentricularTachycardia
|
||||
| EcgRhythm::PulselessVentricularTachycardia) {
|
||||
self.heart_rate = 160;
|
||||
}
|
||||
}
|
||||
|
||||
/// No saturation without an attached sensor, usable signal quality and
|
||||
/// two observed mechanical pulse events. Thresholds do not control this alarm.
|
||||
pub fn spo2_status(&self, pulse_rate: Option<i32>) -> Spo2Status {
|
||||
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 {
|
||||
if !self.spo2_sensor_attached {
|
||||
Spo2Status::NoSensor
|
||||
} else if self.spo2_quality == Spo2Quality::None || pulse_rate.is_none()
|
||||
} else if (signal_lost && self.spo2_quality == Spo2Quality::Poor)
|
||||
|| self.spo2_quality == Spo2Quality::None || pulse_rate.is_none()
|
||||
|| !self.ecg_rhythm.can_generate_pulse()
|
||||
|| self.pulse_conduction == PulseConduction::None
|
||||
|| self.heart_rate <= 0
|
||||
|
|
@ -368,6 +385,34 @@ mod tests {
|
|||
assert_eq!(AtrialFibrillation.rhythm_alarm(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tachycardia_selection_sets_160_bpm_but_other_rhythms_do_not() {
|
||||
let mut p = Parameters::default();
|
||||
p.select_ecg_rhythm(EcgRhythm::VentricularTachycardia);
|
||||
assert_eq!(p.heart_rate, 160);
|
||||
p.heart_rate = 185; // a subsequent instructor override remains possible
|
||||
p.select_ecg_rhythm(EcgRhythm::Sinus);
|
||||
assert_eq!(p.heart_rate, 185);
|
||||
p.select_ecg_rhythm(EcgRhythm::PulselessVentricularTachycardia);
|
||||
assert_eq!(p.heart_rate, 160);
|
||||
assert!(!p.ecg_rhythm.can_generate_pulse());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transient_poor_signal_loss_preserves_sensor_precedence() {
|
||||
let mut p = Parameters::default();
|
||||
p.spo2_quality = Spo2Quality::Poor;
|
||||
assert_eq!(p.spo2_status_during(Some(80), false), Spo2Status::Available);
|
||||
assert_eq!(p.spo2_status_during(Some(80), true), Spo2Status::NoReading);
|
||||
p.spo2_sensor_attached = false;
|
||||
assert_eq!(p.spo2_status_during(Some(80), true), Spo2Status::NoSensor);
|
||||
p.spo2_sensor_attached = true;
|
||||
p.spo2_quality = Spo2Quality::Good;
|
||||
assert_eq!(p.spo2_status_during(Some(80), false), Spo2Status::Available);
|
||||
assert_eq!(p.spo2_status_during(Some(80), true), Spo2Status::Available);
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sensor_and_no_reading_alarms_override_spo2_thresholds() {
|
||||
let mut p = Parameters::default();
|
||||
|
|
|
|||
Loading…
Reference in a new issue