v0.4.2: add PVT
This commit is contained in:
parent
5b6fbb8766
commit
5e397019fc
8 changed files with 727 additions and 51 deletions
|
|
@ -5,15 +5,40 @@ pub enum EcgRhythm {
|
|||
Sinus,
|
||||
AtrialFibrillation,
|
||||
VentricularTachycardia,
|
||||
PulselessVentricularTachycardia,
|
||||
VentricularFibrillation,
|
||||
Asystole,
|
||||
}
|
||||
|
||||
impl EcgRhythm {
|
||||
/// VF and asystole have no organized QRS to trigger a mechanical pulse.
|
||||
/// Organized electrical QRS complexes. PVT still has electrical QRS complexes.
|
||||
pub fn has_qrs(self) -> bool {
|
||||
!matches!(self, Self::VentricularFibrillation | Self::Asystole)
|
||||
}
|
||||
|
||||
/// Whether a QRS can trigger a mechanical pulse, depending on capture.
|
||||
/// Perfusing VT is distinct from PVT. VF and asystole have no QRS.
|
||||
pub fn can_generate_pulse(self) -> bool {
|
||||
self.has_qrs() && self != Self::PulselessVentricularTachycardia
|
||||
}
|
||||
|
||||
/// Rhythm alarms are independent of instructor-defined HR thresholds.
|
||||
pub fn rhythm_alarm(self) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::VentricularTachycardia | Self::PulselessVentricularTachycardia
|
||||
| Self::VentricularFibrillation => Some("ARRHYTHMIA"),
|
||||
Self::Asystole => Some("ASYSTOLE"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pulse-oximeter availability and technical alarms. Sensor loss takes precedence.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Spo2Status {
|
||||
Available,
|
||||
NoSensor,
|
||||
NoReading,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
|
|
@ -195,6 +220,24 @@ pub struct Parameters {
|
|||
pub show_nibp: bool,
|
||||
}
|
||||
|
||||
impl Parameters {
|
||||
/// 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 {
|
||||
if !self.spo2_sensor_attached {
|
||||
Spo2Status::NoSensor
|
||||
} else if self.spo2_quality == Spo2Quality::None || pulse_rate.is_none()
|
||||
|| !self.ecg_rhythm.can_generate_pulse()
|
||||
|| self.pulse_conduction == PulseConduction::None
|
||||
|| self.heart_rate <= 0
|
||||
{
|
||||
Spo2Status::NoReading
|
||||
} else {
|
||||
Spo2Status::Available
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Parameters {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
@ -308,6 +351,41 @@ mod tests {
|
|||
assert!(!p.alarms.pr.enabled());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vt_stays_perfusing_and_pvt_is_electrically_organized_but_pulseless() {
|
||||
use EcgRhythm::*;
|
||||
assert!(VentricularTachycardia.has_qrs());
|
||||
assert!(VentricularTachycardia.can_generate_pulse());
|
||||
assert!(PulselessVentricularTachycardia.has_qrs());
|
||||
assert!(!PulselessVentricularTachycardia.can_generate_pulse());
|
||||
assert!(!VentricularFibrillation.can_generate_pulse());
|
||||
assert!(!Asystole.can_generate_pulse());
|
||||
for rhythm in [VentricularTachycardia, PulselessVentricularTachycardia, VentricularFibrillation] {
|
||||
assert_eq!(rhythm.rhythm_alarm(), Some("ARRHYTHMIA"));
|
||||
}
|
||||
assert_eq!(Asystole.rhythm_alarm(), Some("ASYSTOLE"));
|
||||
assert_eq!(Sinus.rhythm_alarm(), None);
|
||||
assert_eq!(AtrialFibrillation.rhythm_alarm(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sensor_and_no_reading_alarms_override_spo2_thresholds() {
|
||||
let mut p = Parameters::default();
|
||||
assert_eq!(p.spo2_status(Some(80)), Spo2Status::Available);
|
||||
assert_eq!(p.spo2_status(None), Spo2Status::NoReading);
|
||||
p.spo2_quality = Spo2Quality::None;
|
||||
assert_eq!(p.spo2_status(Some(80)), Spo2Status::NoReading);
|
||||
p.spo2_sensor_attached = false;
|
||||
assert_eq!(p.spo2_status(Some(80)), Spo2Status::NoSensor);
|
||||
p.spo2_sensor_attached = true;
|
||||
p.spo2_quality = Spo2Quality::Good;
|
||||
p.ecg_rhythm = EcgRhythm::PulselessVentricularTachycardia;
|
||||
assert_eq!(p.spo2_status(Some(80)), Spo2Status::NoReading);
|
||||
p.ecg_rhythm = EcgRhythm::Sinus;
|
||||
p.pulse_conduction = PulseConduction::None;
|
||||
assert_eq!(p.spo2_status(Some(80)), Spo2Status::NoReading);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grouped_mechanical_capture_follows_requested_patterns() {
|
||||
assert_eq!((1..=8).filter(|&b| PulseConduction::TwoToOne.conducts(b)).collect::<Vec<_>>(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue