v0.6.10: Instructor shortcuts on the Actions tab
This commit is contained in:
parent
c366c4f1d7
commit
436299c1e4
7 changed files with 606 additions and 102 deletions
414
patches/SimPaM-v0.6.9-to-v0.6.10.patch
Normal file
414
patches/SimPaM-v0.6.9-to-v0.6.10.patch
Normal file
|
|
@ -0,0 +1,414 @@
|
||||||
|
--- a/Cargo.toml
|
||||||
|
+++ b/Cargo.toml
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "patient-monitor-simulation"
|
||||||
|
-version = "0.6.9"
|
||||||
|
+version = "0.6.10"
|
||||||
|
edition = "2021"
|
||||||
|
license = "MIT"
|
||||||
|
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"
|
||||||
|
--- a/README.md
|
||||||
|
+++ b/README.md
|
||||||
|
@@ -1,10 +1,26 @@
|
||||||
|
-# Patient Monitor Simulation (PaMSim) — v0.6.9
|
||||||
|
+# SimPaM — Patient Monitor Simulation v0.6.10
|
||||||
|
|
||||||
|
A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux.
|
||||||
|
|
||||||
|
> **Synthetic training signals only — not for clinical use.** ECG, arterial pressure,
|
||||||
|
> plethysmography and capnography are schematic mathematical approximations. The
|
||||||
|
> simulation has no clinical validation and is not a medical device.
|
||||||
|
+
|
||||||
|
+## Instructor shortcuts on the Actions tab (v0.6.10)
|
||||||
|
+
|
||||||
|
+The **Actions & Occurrences** tab keeps **Chest compressions** (Start/Stop button
|
||||||
|
+and quality selector: Good, Adequate, Poor, Bad) permanently visible **above**
|
||||||
|
+the scripted action selector. These are the same controls as on Direct Mode,
|
||||||
|
+backed by the same state; changes in either tab are reflected in the other.
|
||||||
|
+Chest compressions therefore no longer needs a redundant entry in the action
|
||||||
|
+dropdown. Its clinical simulation behavior is unchanged.
|
||||||
|
+
|
||||||
|
+A wide **yellow Defibrillation** shortcut with a **red lightning-bolt icon** is
|
||||||
|
+also always available above the scripted actions. One press produces the
|
||||||
|
+**existing transient ECG defibrillation artifact only**. It does not change
|
||||||
|
+rhythm, ART, EtCO₂ or other physiological parameters, and it does not add a
|
||||||
|
+long-running scripted action. For rhythm conversion and hemodynamic targets,
|
||||||
|
+continue to select **Defibrillation + rhythm change** from the dropdown.
|
||||||
|
|
||||||
|
## Actions & Occurrences (v0.6.9)
|
||||||
|
|
||||||
|
@@ -780,3 +796,12 @@
|
||||||
|
an explicit baseline reset. Synthetic defibrillation ECG artifact and scripted
|
||||||
|
invasive pressure/HR/SpO₂/EtCO₂ progressions are independent of NIBP cuff
|
||||||
|
settings. Existing Direct Mode and monitor menus are retained.
|
||||||
|
+
|
||||||
|
+### v0.6.10 — Persistent CPR controls and defibrillation shortcut
|
||||||
|
+
|
||||||
|
+Chest-compression Start/Stop and quality selection are always visible in the
|
||||||
|
+Actions & Occurrences tab above the scripted action dropdown and stay
|
||||||
|
+synchronized with Direct Mode. CPR was removed from the dropdown because the
|
||||||
|
+same controls are now permanently available. A high-contrast yellow one-tap
|
||||||
|
+Defibrillation button with a red lightning symbol triggers only the transient
|
||||||
|
+ECG shock artifact; rhythm conversion remains available as a separate action.
|
||||||
|
--- a/README.de.md
|
||||||
|
+++ b/README.de.md
|
||||||
|
@@ -1,4 +1,20 @@
|
||||||
|
-# Patient Monitor Simulation (PaMSim) — v0.6.9
|
||||||
|
+# SimPaM — Patientenmonitor-Simulation v0.6.10
|
||||||
|
+
|
||||||
|
+## Direktzugriff auf dem Reiter Actions & Occurrences (v0.6.10)
|
||||||
|
+
|
||||||
|
+Die Bedienelemente **Chest compressions** (Start/Stop und Qualität Good,
|
||||||
|
+Adequate, Poor, Bad) sind auf dem Reiter **Actions & Occurrences** dauerhaft
|
||||||
|
+**oberhalb der Aktionsauswahl** sichtbar. Sie steuern denselben Zustand wie
|
||||||
|
+im Reiter **Direct Mode**; Änderungen werden zwischen den Reitern abgeglichen.
|
||||||
|
+Der überflüssige Eintrag „Chest compressions“ entfällt aus der Aktionsauswahl.
|
||||||
|
+Die physiologische Simulation der Thoraxkompressionen bleibt unverändert.
|
||||||
|
+
|
||||||
|
+Zusätzlich steht eine breite **gelbe Defibrillation-Schaltfläche** mit
|
||||||
|
+**rotem Blitzsymbol** bereit. Sie erzeugt auf Tastendruck ausschließlich das
|
||||||
|
+bereits vorhandene, kurzzeitige **Defibrillationsartefakt im EKG**. Herzrhythmus,
|
||||||
|
+arterieller Druck, EtCO₂ und laufende Skripte werden nicht verändert.
|
||||||
|
+Für eine Rhythmuskonversion mit definierten Zielwerten bleibt der Eintrag
|
||||||
|
+**Defibrillation + rhythm change** in der Aktionsauswahl erhalten.
|
||||||
|
|
||||||
|
## Actions & Occurrences – Maßnahmen und Ereignisse (v0.6.9)
|
||||||
|
|
||||||
|
@@ -769,3 +785,12 @@
|
||||||
|
Stop und explizitem Ausgangswert-Reset. Neue EKG-Defibrillationsartefakte,
|
||||||
|
Hypoxie-/Schockverläufe sowie Noradrenalin- und Propofol-Szenarien.
|
||||||
|
Die bisherigen Direct-Mode-Bedienelemente und Monitor-Touch-Menüs bleiben bestehen.
|
||||||
|
+
|
||||||
|
+### v0.6.10 – Dauerhafte CPR-Bedienung und Defibrillations-Schnelltaste
|
||||||
|
+
|
||||||
|
+Start/Stop und Qualität der Thoraxkompressionen sind im Reiter Actions & Occurrences
|
||||||
|
+ständig oberhalb der Aktionsauswahl sichtbar und mit Direct Mode synchronisiert.
|
||||||
|
+Der doppelte CPR-Eintrag wurde aus der Aktionsauswahl entfernt. Eine gut sichtbare
|
||||||
|
+gelbe Defibrillation-Schaltfläche mit rotem Blitz löst nur das kurzzeitige
|
||||||
|
+Defibrillationsartefakt im EKG aus. Die Rhythmuskonversion bleibt eine separate
|
||||||
|
+Maßnahme.
|
||||||
|
--- a/src/ui.rs
|
||||||
|
+++ b/src/ui.rs
|
||||||
|
@@ -17,6 +17,30 @@
|
||||||
|
|
||||||
|
type SharedParams = Rc<RefCell<Parameters>>;
|
||||||
|
type SharedActions = Rc<RefCell<ActionRunner>>;
|
||||||
|
+
|
||||||
|
+// CPR has permanent controls above this menu; do not offer it twice.
|
||||||
|
+// The array also keeps the dropdown and action dispatcher in the same order.
|
||||||
|
+const SCRIPTED_ACTION_CHOICES: [Kind; 7] = [
|
||||||
|
+ Kind::Defibrillation,
|
||||||
|
+ Kind::DefibrillationRhythm,
|
||||||
|
+ Kind::Hypoxia,
|
||||||
|
+ Kind::Shock,
|
||||||
|
+ Kind::Norepinephrine,
|
||||||
|
+ Kind::ExcessivePropofol,
|
||||||
|
+ Kind::LethalPropofol,
|
||||||
|
+];
|
||||||
|
+
|
||||||
|
+fn action_choice(index: u32) -> Kind {
|
||||||
|
+ SCRIPTED_ACTION_CHOICES.get(index as usize)
|
||||||
|
+ .copied().unwrap_or(Kind::Defibrillation)
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+fn sync_cpr_button(button: >k::Button, active: bool) {
|
||||||
|
+ button.set_label(if active { "Stop Chest Compressions" }
|
||||||
|
+ else { "Start Chest Compressions" });
|
||||||
|
+ button.remove_css_class(if active { "cpr-start" } else { "cpr-stop" });
|
||||||
|
+ button.add_css_class(if active { "cpr-stop" } else { "cpr-start" });
|
||||||
|
+}
|
||||||
|
/// Refresh all Admin widgets whenever a monitor touch-menu commits changes.
|
||||||
|
/// The bool indicates whether alarm limits changed (mark preset as Custom).
|
||||||
|
type AdminChanged = Rc<RefCell<Option<Box<dyn Fn(bool)>>>>;
|
||||||
|
@@ -293,7 +317,16 @@
|
||||||
|
let provider = gtk::CssProvider::new();
|
||||||
|
provider.load_from_data(
|
||||||
|
"button.cpr-start { background-image: none; background-color: #158742; color: #ffffff; font-weight: bold; }
|
||||||
|
- button.cpr-stop { background-image: none; background-color: #c53035; color: #ffffff; font-weight: bold; }"
|
||||||
|
+ button.cpr-stop { background-image: none; background-color: #c53035; color: #ffffff; font-weight: bold; }
|
||||||
|
+ button.defib-shortcut {
|
||||||
|
+ background-image: none; background-color: #ffda2b; color: #151515;
|
||||||
|
+ border: 1px solid #b48e14; font-weight: bold; min-height: 44px;
|
||||||
|
+ }
|
||||||
|
+ button.defib-shortcut:hover { background-color: #ffe763; }
|
||||||
|
+ button.defib-shortcut label { color: #151515; }
|
||||||
|
+ button.defib-shortcut label.defib-bolt {
|
||||||
|
+ color: #cb242b; font-size: 22px; font-weight: bold;
|
||||||
|
+ }"
|
||||||
|
);
|
||||||
|
gtk::style_context_add_provider_for_display(
|
||||||
|
&display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
@@ -307,15 +340,7 @@
|
||||||
|
move |button| {
|
||||||
|
let mut p = params.borrow_mut();
|
||||||
|
p.chest_compressions_active = !p.chest_compressions_active;
|
||||||
|
- if p.chest_compressions_active {
|
||||||
|
- button.set_label("Stop Chest Compressions");
|
||||||
|
- button.remove_css_class("cpr-start");
|
||||||
|
- button.add_css_class("cpr-stop");
|
||||||
|
- } else {
|
||||||
|
- button.set_label("Start Chest Compressions");
|
||||||
|
- button.remove_css_class("cpr-stop");
|
||||||
|
- button.add_css_class("cpr-start");
|
||||||
|
- }
|
||||||
|
+ sync_cpr_button(button, p.chest_compressions_active);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cpr.append(&compression_button);
|
||||||
|
@@ -631,8 +656,7 @@
|
||||||
|
tabs.set_hexpand(true);
|
||||||
|
tabs.set_vexpand(true);
|
||||||
|
tabs.append_page(&scroller, Some(>k::Label::new(Some("Direct Mode"))));
|
||||||
|
- let scripted = actions_page(params.clone(), simulator.clone(), actions.clone(),
|
||||||
|
- compression_button.clone(), compression_quality_dropdown.clone());
|
||||||
|
+ let scripted = actions_page(params.clone(), simulator.clone(), actions.clone());
|
||||||
|
tabs.append_page(&scripted, Some(>k::Label::new(Some("Actions & Occurrences"))));
|
||||||
|
main_box.append(&tabs);
|
||||||
|
|
||||||
|
@@ -676,10 +700,7 @@
|
||||||
|
spo2_quality_dropdown.set_selected(snapshot.spo2_quality as u32);
|
||||||
|
}
|
||||||
|
let active = snapshot.chest_compressions_active;
|
||||||
|
- compression_button.set_label(if active { "Stop Chest Compressions" }
|
||||||
|
- else { "Start Chest Compressions" });
|
||||||
|
- compression_button.remove_css_class(if active { "cpr-start" } else { "cpr-stop" });
|
||||||
|
- compression_button.add_css_class(if active { "cpr-stop" } else { "cpr-start" });
|
||||||
|
+ sync_cpr_button(&compression_button, active);
|
||||||
|
let qindex = match snapshot.chest_compression_quality {
|
||||||
|
ChestCompressionQuality::Good => 0,
|
||||||
|
ChestCompressionQuality::Adequate => 1,
|
||||||
|
@@ -1744,8 +1765,7 @@
|
||||||
|
/// Scripted instructor actions are additive to Direct Mode, never a replacement
|
||||||
|
/// for its sliders, ECG rhythms, alarm limits or NIBP scheduling controls.
|
||||||
|
fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
|
- actions: SharedActions, direct_cpr_button: gtk::Button,
|
||||||
|
- direct_cpr_quality: gtk::DropDown) -> gtk::ScrolledWindow {
|
||||||
|
+ actions: SharedActions) -> gtk::ScrolledWindow {
|
||||||
|
let scroller = gtk::ScrolledWindow::new();
|
||||||
|
scroller.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic);
|
||||||
|
let panel = gtk::Box::new(Orientation::Vertical, 14);
|
||||||
|
@@ -1766,12 +1786,84 @@
|
||||||
|
note.set_wrap(true);
|
||||||
|
panel.append(¬e);
|
||||||
|
|
||||||
|
- let selection = gtk::DropDown::from_strings(&[
|
||||||
|
- "Defibrillation (ECG artifact)", "Defibrillation + rhythm change",
|
||||||
|
- "Deterioration: Hypoxia", "Deterioration: Shock",
|
||||||
|
- "Chest compressions", "Norepinephrine bolus",
|
||||||
|
- "Too much propofol", "Lethal propofol",
|
||||||
|
- ]);
|
||||||
|
+ // These resuscitation controls are always accessible, independent of which
|
||||||
|
+ // scripted action is selected. Both Admin tabs edit the same Parameters.
|
||||||
|
+ let cpr_controls = group(&panel, "Chest compressions", None);
|
||||||
|
+ let cpr_button = gtk::Button::with_label("Start Chest Compressions");
|
||||||
|
+ cpr_button.set_hexpand(true);
|
||||||
|
+ cpr_button.add_css_class("cpr-start");
|
||||||
|
+ sync_cpr_button(&cpr_button, params.borrow().chest_compressions_active);
|
||||||
|
+ cpr_controls.append(&cpr_button);
|
||||||
|
+ let initial_cpr_quality = match params.borrow().chest_compression_quality {
|
||||||
|
+ ChestCompressionQuality::Good => 0,
|
||||||
|
+ ChestCompressionQuality::Adequate => 1,
|
||||||
|
+ ChestCompressionQuality::Poor => 2,
|
||||||
|
+ ChestCompressionQuality::Bad => 3,
|
||||||
|
+ };
|
||||||
|
+ let cpr_quality = add_dropdown_at(&cpr_controls, "Compression quality",
|
||||||
|
+ &["Good", "Adequate", "Poor", "Bad"], initial_cpr_quality,
|
||||||
|
+ params.clone(), |p, selected| {
|
||||||
|
+ p.chest_compression_quality = match selected {
|
||||||
|
+ 0 => ChestCompressionQuality::Good,
|
||||||
|
+ 2 => ChestCompressionQuality::Poor,
|
||||||
|
+ 3 => ChestCompressionQuality::Bad,
|
||||||
|
+ _ => ChestCompressionQuality::Adequate,
|
||||||
|
+ };
|
||||||
|
+ });
|
||||||
|
+ cpr_button.connect_clicked({
|
||||||
|
+ let params = params.clone();
|
||||||
|
+ let actions = actions.clone();
|
||||||
|
+ move |button| {
|
||||||
|
+ let mut p = params.borrow_mut();
|
||||||
|
+ actions.borrow_mut().remember_baseline(&p);
|
||||||
|
+ p.chest_compressions_active = !p.chest_compressions_active;
|
||||||
|
+ sync_cpr_button(button, p.chest_compressions_active);
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ // Direct Mode, scripted baseline restoration, and this panel may all
|
||||||
|
+ // change CPR state; update the visible controls without duplicating state.
|
||||||
|
+ glib::timeout_add_local(Duration::from_millis(250), {
|
||||||
|
+ let params = params.clone();
|
||||||
|
+ let cpr_button = cpr_button.clone();
|
||||||
|
+ let cpr_quality = cpr_quality.clone();
|
||||||
|
+ move || {
|
||||||
|
+ let p = params.borrow().clone();
|
||||||
|
+ sync_cpr_button(&cpr_button, p.chest_compressions_active);
|
||||||
|
+ let index = match p.chest_compression_quality {
|
||||||
|
+ ChestCompressionQuality::Good => 0,
|
||||||
|
+ ChestCompressionQuality::Adequate => 1,
|
||||||
|
+ ChestCompressionQuality::Poor => 2,
|
||||||
|
+ ChestCompressionQuality::Bad => 3,
|
||||||
|
+ };
|
||||||
|
+ if cpr_quality.selected() != index { cpr_quality.set_selected(index); }
|
||||||
|
+ glib::ControlFlow::Continue
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+
|
||||||
|
+ // Independent one-tap defibrillation: ECG artifact only. Do not start an
|
||||||
|
+ // Actions timeline and do not change ECG rhythm, blood pressure or EtCO₂.
|
||||||
|
+ let defib_shortcut = gtk::Button::new();
|
||||||
|
+ defib_shortcut.set_hexpand(true);
|
||||||
|
+ defib_shortcut.add_css_class("defib-shortcut");
|
||||||
|
+ defib_shortcut.set_tooltip_text(Some("ECG shock artifact only — no rhythm change"));
|
||||||
|
+ let defib_content = gtk::Box::new(Orientation::Horizontal, 8);
|
||||||
|
+ defib_content.set_halign(gtk::Align::Center);
|
||||||
|
+ let bolt = gtk::Label::new(Some("⚡"));
|
||||||
|
+ bolt.add_css_class("defib-bolt");
|
||||||
|
+ defib_content.append(&bolt);
|
||||||
|
+ defib_content.append(>k::Label::new(Some("Defibrillation")));
|
||||||
|
+ defib_shortcut.set_child(Some(&defib_content));
|
||||||
|
+ defib_shortcut.connect_clicked({
|
||||||
|
+ let simulator = simulator.clone();
|
||||||
|
+ move |_| simulator.borrow_mut().defibrillate()
|
||||||
|
+ });
|
||||||
|
+ panel.append(&defib_shortcut);
|
||||||
|
+
|
||||||
|
+ let actions_title = gtk::Label::new(Some("Scripted actions"));
|
||||||
|
+ actions_title.set_xalign(0.0);
|
||||||
|
+ panel.append(&actions_title);
|
||||||
|
+ let selection = gtk::DropDown::from_strings(
|
||||||
|
+ &SCRIPTED_ACTION_CHOICES.map(Kind::label));
|
||||||
|
selection.set_hexpand(true);
|
||||||
|
panel.append(&selection);
|
||||||
|
|
||||||
|
@@ -1808,66 +1900,6 @@
|
||||||
|
defib_config.set_visible(false);
|
||||||
|
panel.append(&defib_config);
|
||||||
|
|
||||||
|
- let cpr_config = gtk::Box::new(Orientation::Vertical, 8);
|
||||||
|
- let cpr_quality = gtk::DropDown::from_strings(&["Good", "Adequate", "Poor", "Bad"]);
|
||||||
|
- cpr_quality.set_selected(1);
|
||||||
|
- let quality_caption = gtk::Label::new(Some("Chest-compression quality"));
|
||||||
|
- quality_caption.set_xalign(0.0);
|
||||||
|
- cpr_config.append(&quality_caption);
|
||||||
|
- cpr_config.append(&cpr_quality);
|
||||||
|
- let cpr_button = gtk::Button::with_label("Start Chest Compressions");
|
||||||
|
- cpr_button.set_hexpand(true);
|
||||||
|
- cpr_button.add_css_class("cpr-start");
|
||||||
|
- cpr_config.append(&cpr_button);
|
||||||
|
- cpr_config.set_visible(false);
|
||||||
|
- panel.append(&cpr_config);
|
||||||
|
- cpr_quality.connect_selected_notify({
|
||||||
|
- let params = params.clone();
|
||||||
|
- move |widget| {
|
||||||
|
- params.borrow_mut().chest_compression_quality = match widget.selected() {
|
||||||
|
- 0 => ChestCompressionQuality::Good,
|
||||||
|
- 2 => ChestCompressionQuality::Poor,
|
||||||
|
- 3 => ChestCompressionQuality::Bad,
|
||||||
|
- _ => ChestCompressionQuality::Adequate,
|
||||||
|
- };
|
||||||
|
- }
|
||||||
|
- });
|
||||||
|
- cpr_button.connect_clicked({
|
||||||
|
- let params = params.clone();
|
||||||
|
- let actions = actions.clone();
|
||||||
|
- move |_| {
|
||||||
|
- let mut p = params.borrow_mut();
|
||||||
|
- actions.borrow_mut().remember_baseline(&p);
|
||||||
|
- p.chest_compressions_active = !p.chest_compressions_active;
|
||||||
|
- }
|
||||||
|
- });
|
||||||
|
- // Update CPR actions when the instructor also uses Direct Mode.
|
||||||
|
- glib::timeout_add_local(Duration::from_millis(250), {
|
||||||
|
- let params = params.clone();
|
||||||
|
- let cpr_button = cpr_button.clone();
|
||||||
|
- let cpr_quality = cpr_quality.clone();
|
||||||
|
- let direct_cpr_button = direct_cpr_button.clone();
|
||||||
|
- let direct_cpr_quality = direct_cpr_quality.clone();
|
||||||
|
- move || {
|
||||||
|
- let p = params.borrow().clone();
|
||||||
|
- let active = p.chest_compressions_active;
|
||||||
|
- cpr_button.set_label(if active { "Stop Chest Compressions" }
|
||||||
|
- else { "Start Chest Compressions" });
|
||||||
|
- cpr_button.remove_css_class(if active { "cpr-start" } else { "cpr-stop" });
|
||||||
|
- cpr_button.add_css_class(if active { "cpr-stop" } else { "cpr-start" });
|
||||||
|
- // Keep the existing Direct Mode controls as the authoritative UI.
|
||||||
|
- let _ = (&direct_cpr_button, &direct_cpr_quality);
|
||||||
|
- let quality_index = match p.chest_compression_quality {
|
||||||
|
- ChestCompressionQuality::Good => 0,
|
||||||
|
- ChestCompressionQuality::Adequate => 1,
|
||||||
|
- ChestCompressionQuality::Poor => 2,
|
||||||
|
- ChestCompressionQuality::Bad => 3,
|
||||||
|
- };
|
||||||
|
- if cpr_quality.selected() != quality_index { cpr_quality.set_selected(quality_index); }
|
||||||
|
- glib::ControlFlow::Continue
|
||||||
|
- }
|
||||||
|
- });
|
||||||
|
-
|
||||||
|
let info = gtk::Label::new(Some("Instant artifact; does not automatically alter rhythm."));
|
||||||
|
info.set_wrap(true);
|
||||||
|
info.set_xalign(0.0);
|
||||||
|
@@ -1876,15 +1908,10 @@
|
||||||
|
panel.append(&trigger);
|
||||||
|
selection.connect_selected_notify({
|
||||||
|
let defib_config = defib_config.clone();
|
||||||
|
- let cpr_config = cpr_config.clone();
|
||||||
|
- let trigger = trigger.clone();
|
||||||
|
let info = info.clone();
|
||||||
|
move |dropdown| {
|
||||||
|
- let kind = Kind::ALL.get(dropdown.selected() as usize)
|
||||||
|
- .copied().unwrap_or(Kind::Defibrillation);
|
||||||
|
+ let kind = action_choice(dropdown.selected());
|
||||||
|
defib_config.set_visible(kind == Kind::DefibrillationRhythm);
|
||||||
|
- cpr_config.set_visible(kind == Kind::ChestCompressions);
|
||||||
|
- trigger.set_visible(kind != Kind::ChestCompressions);
|
||||||
|
info.set_text(match kind {
|
||||||
|
Kind::Defibrillation => "Brief ECG shock artifact without automatic conversion.",
|
||||||
|
Kind::DefibrillationRhythm => "Instant rhythm change, ART target after 60 s, EtCO₂ after 30 s if cardiac output exists.",
|
||||||
|
@@ -1915,9 +1942,7 @@
|
||||||
|
let action_rows = action_rows.clone();
|
||||||
|
let info = info.clone();
|
||||||
|
move |_| {
|
||||||
|
- let kind = Kind::ALL.get(selection.selected() as usize)
|
||||||
|
- .copied().unwrap_or(Kind::Defibrillation);
|
||||||
|
- if kind == Kind::ChestCompressions { return; }
|
||||||
|
+ let kind = action_choice(selection.selected());
|
||||||
|
let defib = if kind == Kind::DefibrillationRhythm {
|
||||||
|
let rhythm = match defib_rhythm.selected() {
|
||||||
|
1 => EcgRhythm::AtrialFibrillation,
|
||||||
|
@@ -1993,3 +2018,23 @@
|
||||||
|
scroller.set_child(Some(&panel));
|
||||||
|
scroller
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+#[cfg(test)]
|
||||||
|
+mod actions_tab_layout_tests {
|
||||||
|
+ use super::*;
|
||||||
|
+
|
||||||
|
+ #[test]
|
||||||
|
+ fn cpr_is_a_permanent_control_not_a_duplicate_dropdown_action() {
|
||||||
|
+ assert_eq!(SCRIPTED_ACTION_CHOICES.len(), 7);
|
||||||
|
+ assert!(!SCRIPTED_ACTION_CHOICES.contains(&Kind::ChestCompressions));
|
||||||
|
+ assert_eq!(action_choice(0), Kind::Defibrillation);
|
||||||
|
+ assert_eq!(action_choice(1), Kind::DefibrillationRhythm);
|
||||||
|
+ assert_eq!(action_choice(4), Kind::Norepinephrine);
|
||||||
|
+ assert_eq!(action_choice(6), Kind::LethalPropofol);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ #[test]
|
||||||
|
+ fn unknown_action_selection_falls_back_to_artifact_only() {
|
||||||
|
+ assert_eq!(action_choice(u32::MAX), Kind::Defibrillation);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
--- a/src/actions.rs
|
||||||
|
+++ b/src/actions.rs
|
||||||
|
@@ -16,11 +16,6 @@
|
||||||
|
LethalPropofol,
|
||||||
|
}
|
||||||
|
impl Kind {
|
||||||
|
- pub const ALL: [Kind; 8] = [
|
||||||
|
- Self::Defibrillation, Self::DefibrillationRhythm, Self::Hypoxia,
|
||||||
|
- Self::Shock, Self::ChestCompressions, Self::Norepinephrine,
|
||||||
|
- Self::ExcessivePropofol, Self::LethalPropofol,
|
||||||
|
- ];
|
||||||
|
pub fn label(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::Defibrillation => "Defibrillation (ECG artifact)",
|
||||||
2
patient-monitor-simulation/Cargo.lock
generated
2
patient-monitor-simulation/Cargo.lock
generated
|
|
@ -438,7 +438,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "patient-monitor-simulation"
|
name = "patient-monitor-simulation"
|
||||||
version = "0.6.9"
|
version = "0.6.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gtk4",
|
"gtk4",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "patient-monitor-simulation"
|
name = "patient-monitor-simulation"
|
||||||
version = "0.6.9"
|
version = "0.6.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"
|
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,20 @@
|
||||||
# Patient Monitor Simulation (PaMSim) — v0.6.9
|
# SimPaM — Patientenmonitor-Simulation v0.6.10
|
||||||
|
|
||||||
|
## Direktzugriff auf dem Reiter Actions & Occurrences (v0.6.10)
|
||||||
|
|
||||||
|
Die Bedienelemente **Chest compressions** (Start/Stop und Qualität Good,
|
||||||
|
Adequate, Poor, Bad) sind auf dem Reiter **Actions & Occurrences** dauerhaft
|
||||||
|
**oberhalb der Aktionsauswahl** sichtbar. Sie steuern denselben Zustand wie
|
||||||
|
im Reiter **Direct Mode**; Änderungen werden zwischen den Reitern abgeglichen.
|
||||||
|
Der überflüssige Eintrag „Chest compressions“ entfällt aus der Aktionsauswahl.
|
||||||
|
Die physiologische Simulation der Thoraxkompressionen bleibt unverändert.
|
||||||
|
|
||||||
|
Zusätzlich steht eine breite **gelbe Defibrillation-Schaltfläche** mit
|
||||||
|
**rotem Blitzsymbol** bereit. Sie erzeugt auf Tastendruck ausschließlich das
|
||||||
|
bereits vorhandene, kurzzeitige **Defibrillationsartefakt im EKG**. Herzrhythmus,
|
||||||
|
arterieller Druck, EtCO₂ und laufende Skripte werden nicht verändert.
|
||||||
|
Für eine Rhythmuskonversion mit definierten Zielwerten bleibt der Eintrag
|
||||||
|
**Defibrillation + rhythm change** in der Aktionsauswahl erhalten.
|
||||||
|
|
||||||
## Actions & Occurrences – Maßnahmen und Ereignisse (v0.6.9)
|
## Actions & Occurrences – Maßnahmen und Ereignisse (v0.6.9)
|
||||||
|
|
||||||
|
|
@ -769,3 +785,12 @@ Neuer Admin-Reiter für zeitabhängige Ereignisse mit Trigger, Pause/Fortsetzen,
|
||||||
Stop und explizitem Ausgangswert-Reset. Neue EKG-Defibrillationsartefakte,
|
Stop und explizitem Ausgangswert-Reset. Neue EKG-Defibrillationsartefakte,
|
||||||
Hypoxie-/Schockverläufe sowie Noradrenalin- und Propofol-Szenarien.
|
Hypoxie-/Schockverläufe sowie Noradrenalin- und Propofol-Szenarien.
|
||||||
Die bisherigen Direct-Mode-Bedienelemente und Monitor-Touch-Menüs bleiben bestehen.
|
Die bisherigen Direct-Mode-Bedienelemente und Monitor-Touch-Menüs bleiben bestehen.
|
||||||
|
|
||||||
|
### v0.6.10 – Dauerhafte CPR-Bedienung und Defibrillations-Schnelltaste
|
||||||
|
|
||||||
|
Start/Stop und Qualität der Thoraxkompressionen sind im Reiter Actions & Occurrences
|
||||||
|
ständig oberhalb der Aktionsauswahl sichtbar und mit Direct Mode synchronisiert.
|
||||||
|
Der doppelte CPR-Eintrag wurde aus der Aktionsauswahl entfernt. Eine gut sichtbare
|
||||||
|
gelbe Defibrillation-Schaltfläche mit rotem Blitz löst nur das kurzzeitige
|
||||||
|
Defibrillationsartefakt im EKG aus. Die Rhythmuskonversion bleibt eine separate
|
||||||
|
Maßnahme.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Patient Monitor Simulation (PaMSim) — v0.6.9
|
# SimPaM — Patient Monitor Simulation v0.6.10
|
||||||
|
|
||||||
A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux.
|
A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux.
|
||||||
|
|
||||||
|
|
@ -6,6 +6,22 @@ A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedo
|
||||||
> plethysmography and capnography are schematic mathematical approximations. The
|
> plethysmography and capnography are schematic mathematical approximations. The
|
||||||
> simulation has no clinical validation and is not a medical device.
|
> simulation has no clinical validation and is not a medical device.
|
||||||
|
|
||||||
|
## Instructor shortcuts on the Actions tab (v0.6.10)
|
||||||
|
|
||||||
|
The **Actions & Occurrences** tab keeps **Chest compressions** (Start/Stop button
|
||||||
|
and quality selector: Good, Adequate, Poor, Bad) permanently visible **above**
|
||||||
|
the scripted action selector. These are the same controls as on Direct Mode,
|
||||||
|
backed by the same state; changes in either tab are reflected in the other.
|
||||||
|
Chest compressions therefore no longer needs a redundant entry in the action
|
||||||
|
dropdown. Its clinical simulation behavior is unchanged.
|
||||||
|
|
||||||
|
A wide **yellow Defibrillation** shortcut with a **red lightning-bolt icon** is
|
||||||
|
also always available above the scripted actions. One press produces the
|
||||||
|
**existing transient ECG defibrillation artifact only**. It does not change
|
||||||
|
rhythm, ART, EtCO₂ or other physiological parameters, and it does not add a
|
||||||
|
long-running scripted action. For rhythm conversion and hemodynamic targets,
|
||||||
|
continue to select **Defibrillation + rhythm change** from the dropdown.
|
||||||
|
|
||||||
## Actions & Occurrences (v0.6.9)
|
## Actions & Occurrences (v0.6.9)
|
||||||
|
|
||||||
The Admin window now has two tabs: **Direct Mode** (all original controls) and
|
The Admin window now has two tabs: **Direct Mode** (all original controls) and
|
||||||
|
|
@ -780,3 +796,12 @@ manual override of individual parameters, overlapping-action ownership and
|
||||||
an explicit baseline reset. Synthetic defibrillation ECG artifact and scripted
|
an explicit baseline reset. Synthetic defibrillation ECG artifact and scripted
|
||||||
invasive pressure/HR/SpO₂/EtCO₂ progressions are independent of NIBP cuff
|
invasive pressure/HR/SpO₂/EtCO₂ progressions are independent of NIBP cuff
|
||||||
settings. Existing Direct Mode and monitor menus are retained.
|
settings. Existing Direct Mode and monitor menus are retained.
|
||||||
|
|
||||||
|
### v0.6.10 — Persistent CPR controls and defibrillation shortcut
|
||||||
|
|
||||||
|
Chest-compression Start/Stop and quality selection are always visible in the
|
||||||
|
Actions & Occurrences tab above the scripted action dropdown and stay
|
||||||
|
synchronized with Direct Mode. CPR was removed from the dropdown because the
|
||||||
|
same controls are now permanently available. A high-contrast yellow one-tap
|
||||||
|
Defibrillation button with a red lightning symbol triggers only the transient
|
||||||
|
ECG shock artifact; rhythm conversion remains available as a separate action.
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,6 @@ pub enum Kind {
|
||||||
LethalPropofol,
|
LethalPropofol,
|
||||||
}
|
}
|
||||||
impl Kind {
|
impl Kind {
|
||||||
pub const ALL: [Kind; 8] = [
|
|
||||||
Self::Defibrillation, Self::DefibrillationRhythm, Self::Hypoxia,
|
|
||||||
Self::Shock, Self::ChestCompressions, Self::Norepinephrine,
|
|
||||||
Self::ExcessivePropofol, Self::LethalPropofol,
|
|
||||||
];
|
|
||||||
pub fn label(self) -> &'static str {
|
pub fn label(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Self::Defibrillation => "Defibrillation (ECG artifact)",
|
Self::Defibrillation => "Defibrillation (ECG artifact)",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,30 @@ use crate::simulation::Simulator;
|
||||||
|
|
||||||
type SharedParams = Rc<RefCell<Parameters>>;
|
type SharedParams = Rc<RefCell<Parameters>>;
|
||||||
type SharedActions = Rc<RefCell<ActionRunner>>;
|
type SharedActions = Rc<RefCell<ActionRunner>>;
|
||||||
|
|
||||||
|
// CPR has permanent controls above this menu; do not offer it twice.
|
||||||
|
// The array also keeps the dropdown and action dispatcher in the same order.
|
||||||
|
const SCRIPTED_ACTION_CHOICES: [Kind; 7] = [
|
||||||
|
Kind::Defibrillation,
|
||||||
|
Kind::DefibrillationRhythm,
|
||||||
|
Kind::Hypoxia,
|
||||||
|
Kind::Shock,
|
||||||
|
Kind::Norepinephrine,
|
||||||
|
Kind::ExcessivePropofol,
|
||||||
|
Kind::LethalPropofol,
|
||||||
|
];
|
||||||
|
|
||||||
|
fn action_choice(index: u32) -> Kind {
|
||||||
|
SCRIPTED_ACTION_CHOICES.get(index as usize)
|
||||||
|
.copied().unwrap_or(Kind::Defibrillation)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sync_cpr_button(button: >k::Button, active: bool) {
|
||||||
|
button.set_label(if active { "Stop Chest Compressions" }
|
||||||
|
else { "Start Chest Compressions" });
|
||||||
|
button.remove_css_class(if active { "cpr-start" } else { "cpr-stop" });
|
||||||
|
button.add_css_class(if active { "cpr-stop" } else { "cpr-start" });
|
||||||
|
}
|
||||||
/// Refresh all Admin widgets whenever a monitor touch-menu commits changes.
|
/// Refresh all Admin widgets whenever a monitor touch-menu commits changes.
|
||||||
/// The bool indicates whether alarm limits changed (mark preset as Custom).
|
/// The bool indicates whether alarm limits changed (mark preset as Custom).
|
||||||
type AdminChanged = Rc<RefCell<Option<Box<dyn Fn(bool)>>>>;
|
type AdminChanged = Rc<RefCell<Option<Box<dyn Fn(bool)>>>>;
|
||||||
|
|
@ -293,7 +317,16 @@ fn create_admin(app: &Application, params: SharedParams,
|
||||||
let provider = gtk::CssProvider::new();
|
let provider = gtk::CssProvider::new();
|
||||||
provider.load_from_data(
|
provider.load_from_data(
|
||||||
"button.cpr-start { background-image: none; background-color: #158742; color: #ffffff; font-weight: bold; }
|
"button.cpr-start { background-image: none; background-color: #158742; color: #ffffff; font-weight: bold; }
|
||||||
button.cpr-stop { background-image: none; background-color: #c53035; color: #ffffff; font-weight: bold; }"
|
button.cpr-stop { background-image: none; background-color: #c53035; color: #ffffff; font-weight: bold; }
|
||||||
|
button.defib-shortcut {
|
||||||
|
background-image: none; background-color: #ffda2b; color: #151515;
|
||||||
|
border: 1px solid #b48e14; font-weight: bold; min-height: 44px;
|
||||||
|
}
|
||||||
|
button.defib-shortcut:hover { background-color: #ffe763; }
|
||||||
|
button.defib-shortcut label { color: #151515; }
|
||||||
|
button.defib-shortcut label.defib-bolt {
|
||||||
|
color: #cb242b; font-size: 22px; font-weight: bold;
|
||||||
|
}"
|
||||||
);
|
);
|
||||||
gtk::style_context_add_provider_for_display(
|
gtk::style_context_add_provider_for_display(
|
||||||
&display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
|
&display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
@ -307,15 +340,7 @@ fn create_admin(app: &Application, params: SharedParams,
|
||||||
move |button| {
|
move |button| {
|
||||||
let mut p = params.borrow_mut();
|
let mut p = params.borrow_mut();
|
||||||
p.chest_compressions_active = !p.chest_compressions_active;
|
p.chest_compressions_active = !p.chest_compressions_active;
|
||||||
if p.chest_compressions_active {
|
sync_cpr_button(button, p.chest_compressions_active);
|
||||||
button.set_label("Stop Chest Compressions");
|
|
||||||
button.remove_css_class("cpr-start");
|
|
||||||
button.add_css_class("cpr-stop");
|
|
||||||
} else {
|
|
||||||
button.set_label("Start Chest Compressions");
|
|
||||||
button.remove_css_class("cpr-stop");
|
|
||||||
button.add_css_class("cpr-start");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cpr.append(&compression_button);
|
cpr.append(&compression_button);
|
||||||
|
|
@ -631,8 +656,7 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
|
||||||
tabs.set_hexpand(true);
|
tabs.set_hexpand(true);
|
||||||
tabs.set_vexpand(true);
|
tabs.set_vexpand(true);
|
||||||
tabs.append_page(&scroller, Some(>k::Label::new(Some("Direct Mode"))));
|
tabs.append_page(&scroller, Some(>k::Label::new(Some("Direct Mode"))));
|
||||||
let scripted = actions_page(params.clone(), simulator.clone(), actions.clone(),
|
let scripted = actions_page(params.clone(), simulator.clone(), actions.clone());
|
||||||
compression_button.clone(), compression_quality_dropdown.clone());
|
|
||||||
tabs.append_page(&scripted, Some(>k::Label::new(Some("Actions & Occurrences"))));
|
tabs.append_page(&scripted, Some(>k::Label::new(Some("Actions & Occurrences"))));
|
||||||
main_box.append(&tabs);
|
main_box.append(&tabs);
|
||||||
|
|
||||||
|
|
@ -676,10 +700,7 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
|
||||||
spo2_quality_dropdown.set_selected(snapshot.spo2_quality as u32);
|
spo2_quality_dropdown.set_selected(snapshot.spo2_quality as u32);
|
||||||
}
|
}
|
||||||
let active = snapshot.chest_compressions_active;
|
let active = snapshot.chest_compressions_active;
|
||||||
compression_button.set_label(if active { "Stop Chest Compressions" }
|
sync_cpr_button(&compression_button, active);
|
||||||
else { "Start Chest Compressions" });
|
|
||||||
compression_button.remove_css_class(if active { "cpr-start" } else { "cpr-stop" });
|
|
||||||
compression_button.add_css_class(if active { "cpr-stop" } else { "cpr-start" });
|
|
||||||
let qindex = match snapshot.chest_compression_quality {
|
let qindex = match snapshot.chest_compression_quality {
|
||||||
ChestCompressionQuality::Good => 0,
|
ChestCompressionQuality::Good => 0,
|
||||||
ChestCompressionQuality::Adequate => 1,
|
ChestCompressionQuality::Adequate => 1,
|
||||||
|
|
@ -1744,8 +1765,7 @@ fn update_alarm_limits(low_entry: >k::Entry, high_entry: >k::Entry, max: i32
|
||||||
/// Scripted instructor actions are additive to Direct Mode, never a replacement
|
/// Scripted instructor actions are additive to Direct Mode, never a replacement
|
||||||
/// for its sliders, ECG rhythms, alarm limits or NIBP scheduling controls.
|
/// for its sliders, ECG rhythms, alarm limits or NIBP scheduling controls.
|
||||||
fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
actions: SharedActions, direct_cpr_button: gtk::Button,
|
actions: SharedActions) -> gtk::ScrolledWindow {
|
||||||
direct_cpr_quality: gtk::DropDown) -> gtk::ScrolledWindow {
|
|
||||||
let scroller = gtk::ScrolledWindow::new();
|
let scroller = gtk::ScrolledWindow::new();
|
||||||
scroller.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic);
|
scroller.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic);
|
||||||
let panel = gtk::Box::new(Orientation::Vertical, 14);
|
let panel = gtk::Box::new(Orientation::Vertical, 14);
|
||||||
|
|
@ -1766,12 +1786,84 @@ fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
note.set_wrap(true);
|
note.set_wrap(true);
|
||||||
panel.append(¬e);
|
panel.append(¬e);
|
||||||
|
|
||||||
let selection = gtk::DropDown::from_strings(&[
|
// These resuscitation controls are always accessible, independent of which
|
||||||
"Defibrillation (ECG artifact)", "Defibrillation + rhythm change",
|
// scripted action is selected. Both Admin tabs edit the same Parameters.
|
||||||
"Deterioration: Hypoxia", "Deterioration: Shock",
|
let cpr_controls = group(&panel, "Chest compressions", None);
|
||||||
"Chest compressions", "Norepinephrine bolus",
|
let cpr_button = gtk::Button::with_label("Start Chest Compressions");
|
||||||
"Too much propofol", "Lethal propofol",
|
cpr_button.set_hexpand(true);
|
||||||
]);
|
cpr_button.add_css_class("cpr-start");
|
||||||
|
sync_cpr_button(&cpr_button, params.borrow().chest_compressions_active);
|
||||||
|
cpr_controls.append(&cpr_button);
|
||||||
|
let initial_cpr_quality = match params.borrow().chest_compression_quality {
|
||||||
|
ChestCompressionQuality::Good => 0,
|
||||||
|
ChestCompressionQuality::Adequate => 1,
|
||||||
|
ChestCompressionQuality::Poor => 2,
|
||||||
|
ChestCompressionQuality::Bad => 3,
|
||||||
|
};
|
||||||
|
let cpr_quality = add_dropdown_at(&cpr_controls, "Compression quality",
|
||||||
|
&["Good", "Adequate", "Poor", "Bad"], initial_cpr_quality,
|
||||||
|
params.clone(), |p, selected| {
|
||||||
|
p.chest_compression_quality = match selected {
|
||||||
|
0 => ChestCompressionQuality::Good,
|
||||||
|
2 => ChestCompressionQuality::Poor,
|
||||||
|
3 => ChestCompressionQuality::Bad,
|
||||||
|
_ => ChestCompressionQuality::Adequate,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
cpr_button.connect_clicked({
|
||||||
|
let params = params.clone();
|
||||||
|
let actions = actions.clone();
|
||||||
|
move |button| {
|
||||||
|
let mut p = params.borrow_mut();
|
||||||
|
actions.borrow_mut().remember_baseline(&p);
|
||||||
|
p.chest_compressions_active = !p.chest_compressions_active;
|
||||||
|
sync_cpr_button(button, p.chest_compressions_active);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Direct Mode, scripted baseline restoration, and this panel may all
|
||||||
|
// change CPR state; update the visible controls without duplicating state.
|
||||||
|
glib::timeout_add_local(Duration::from_millis(250), {
|
||||||
|
let params = params.clone();
|
||||||
|
let cpr_button = cpr_button.clone();
|
||||||
|
let cpr_quality = cpr_quality.clone();
|
||||||
|
move || {
|
||||||
|
let p = params.borrow().clone();
|
||||||
|
sync_cpr_button(&cpr_button, p.chest_compressions_active);
|
||||||
|
let index = match p.chest_compression_quality {
|
||||||
|
ChestCompressionQuality::Good => 0,
|
||||||
|
ChestCompressionQuality::Adequate => 1,
|
||||||
|
ChestCompressionQuality::Poor => 2,
|
||||||
|
ChestCompressionQuality::Bad => 3,
|
||||||
|
};
|
||||||
|
if cpr_quality.selected() != index { cpr_quality.set_selected(index); }
|
||||||
|
glib::ControlFlow::Continue
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Independent one-tap defibrillation: ECG artifact only. Do not start an
|
||||||
|
// Actions timeline and do not change ECG rhythm, blood pressure or EtCO₂.
|
||||||
|
let defib_shortcut = gtk::Button::new();
|
||||||
|
defib_shortcut.set_hexpand(true);
|
||||||
|
defib_shortcut.add_css_class("defib-shortcut");
|
||||||
|
defib_shortcut.set_tooltip_text(Some("ECG shock artifact only — no rhythm change"));
|
||||||
|
let defib_content = gtk::Box::new(Orientation::Horizontal, 8);
|
||||||
|
defib_content.set_halign(gtk::Align::Center);
|
||||||
|
let bolt = gtk::Label::new(Some("⚡"));
|
||||||
|
bolt.add_css_class("defib-bolt");
|
||||||
|
defib_content.append(&bolt);
|
||||||
|
defib_content.append(>k::Label::new(Some("Defibrillation")));
|
||||||
|
defib_shortcut.set_child(Some(&defib_content));
|
||||||
|
defib_shortcut.connect_clicked({
|
||||||
|
let simulator = simulator.clone();
|
||||||
|
move |_| simulator.borrow_mut().defibrillate()
|
||||||
|
});
|
||||||
|
panel.append(&defib_shortcut);
|
||||||
|
|
||||||
|
let actions_title = gtk::Label::new(Some("Scripted actions"));
|
||||||
|
actions_title.set_xalign(0.0);
|
||||||
|
panel.append(&actions_title);
|
||||||
|
let selection = gtk::DropDown::from_strings(
|
||||||
|
&SCRIPTED_ACTION_CHOICES.map(Kind::label));
|
||||||
selection.set_hexpand(true);
|
selection.set_hexpand(true);
|
||||||
panel.append(&selection);
|
panel.append(&selection);
|
||||||
|
|
||||||
|
|
@ -1808,66 +1900,6 @@ fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
defib_config.set_visible(false);
|
defib_config.set_visible(false);
|
||||||
panel.append(&defib_config);
|
panel.append(&defib_config);
|
||||||
|
|
||||||
let cpr_config = gtk::Box::new(Orientation::Vertical, 8);
|
|
||||||
let cpr_quality = gtk::DropDown::from_strings(&["Good", "Adequate", "Poor", "Bad"]);
|
|
||||||
cpr_quality.set_selected(1);
|
|
||||||
let quality_caption = gtk::Label::new(Some("Chest-compression quality"));
|
|
||||||
quality_caption.set_xalign(0.0);
|
|
||||||
cpr_config.append(&quality_caption);
|
|
||||||
cpr_config.append(&cpr_quality);
|
|
||||||
let cpr_button = gtk::Button::with_label("Start Chest Compressions");
|
|
||||||
cpr_button.set_hexpand(true);
|
|
||||||
cpr_button.add_css_class("cpr-start");
|
|
||||||
cpr_config.append(&cpr_button);
|
|
||||||
cpr_config.set_visible(false);
|
|
||||||
panel.append(&cpr_config);
|
|
||||||
cpr_quality.connect_selected_notify({
|
|
||||||
let params = params.clone();
|
|
||||||
move |widget| {
|
|
||||||
params.borrow_mut().chest_compression_quality = match widget.selected() {
|
|
||||||
0 => ChestCompressionQuality::Good,
|
|
||||||
2 => ChestCompressionQuality::Poor,
|
|
||||||
3 => ChestCompressionQuality::Bad,
|
|
||||||
_ => ChestCompressionQuality::Adequate,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cpr_button.connect_clicked({
|
|
||||||
let params = params.clone();
|
|
||||||
let actions = actions.clone();
|
|
||||||
move |_| {
|
|
||||||
let mut p = params.borrow_mut();
|
|
||||||
actions.borrow_mut().remember_baseline(&p);
|
|
||||||
p.chest_compressions_active = !p.chest_compressions_active;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Update CPR actions when the instructor also uses Direct Mode.
|
|
||||||
glib::timeout_add_local(Duration::from_millis(250), {
|
|
||||||
let params = params.clone();
|
|
||||||
let cpr_button = cpr_button.clone();
|
|
||||||
let cpr_quality = cpr_quality.clone();
|
|
||||||
let direct_cpr_button = direct_cpr_button.clone();
|
|
||||||
let direct_cpr_quality = direct_cpr_quality.clone();
|
|
||||||
move || {
|
|
||||||
let p = params.borrow().clone();
|
|
||||||
let active = p.chest_compressions_active;
|
|
||||||
cpr_button.set_label(if active { "Stop Chest Compressions" }
|
|
||||||
else { "Start Chest Compressions" });
|
|
||||||
cpr_button.remove_css_class(if active { "cpr-start" } else { "cpr-stop" });
|
|
||||||
cpr_button.add_css_class(if active { "cpr-stop" } else { "cpr-start" });
|
|
||||||
// Keep the existing Direct Mode controls as the authoritative UI.
|
|
||||||
let _ = (&direct_cpr_button, &direct_cpr_quality);
|
|
||||||
let quality_index = match p.chest_compression_quality {
|
|
||||||
ChestCompressionQuality::Good => 0,
|
|
||||||
ChestCompressionQuality::Adequate => 1,
|
|
||||||
ChestCompressionQuality::Poor => 2,
|
|
||||||
ChestCompressionQuality::Bad => 3,
|
|
||||||
};
|
|
||||||
if cpr_quality.selected() != quality_index { cpr_quality.set_selected(quality_index); }
|
|
||||||
glib::ControlFlow::Continue
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let info = gtk::Label::new(Some("Instant artifact; does not automatically alter rhythm."));
|
let info = gtk::Label::new(Some("Instant artifact; does not automatically alter rhythm."));
|
||||||
info.set_wrap(true);
|
info.set_wrap(true);
|
||||||
info.set_xalign(0.0);
|
info.set_xalign(0.0);
|
||||||
|
|
@ -1876,15 +1908,10 @@ fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
panel.append(&trigger);
|
panel.append(&trigger);
|
||||||
selection.connect_selected_notify({
|
selection.connect_selected_notify({
|
||||||
let defib_config = defib_config.clone();
|
let defib_config = defib_config.clone();
|
||||||
let cpr_config = cpr_config.clone();
|
|
||||||
let trigger = trigger.clone();
|
|
||||||
let info = info.clone();
|
let info = info.clone();
|
||||||
move |dropdown| {
|
move |dropdown| {
|
||||||
let kind = Kind::ALL.get(dropdown.selected() as usize)
|
let kind = action_choice(dropdown.selected());
|
||||||
.copied().unwrap_or(Kind::Defibrillation);
|
|
||||||
defib_config.set_visible(kind == Kind::DefibrillationRhythm);
|
defib_config.set_visible(kind == Kind::DefibrillationRhythm);
|
||||||
cpr_config.set_visible(kind == Kind::ChestCompressions);
|
|
||||||
trigger.set_visible(kind != Kind::ChestCompressions);
|
|
||||||
info.set_text(match kind {
|
info.set_text(match kind {
|
||||||
Kind::Defibrillation => "Brief ECG shock artifact without automatic conversion.",
|
Kind::Defibrillation => "Brief ECG shock artifact without automatic conversion.",
|
||||||
Kind::DefibrillationRhythm => "Instant rhythm change, ART target after 60 s, EtCO₂ after 30 s if cardiac output exists.",
|
Kind::DefibrillationRhythm => "Instant rhythm change, ART target after 60 s, EtCO₂ after 30 s if cardiac output exists.",
|
||||||
|
|
@ -1915,9 +1942,7 @@ fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
let action_rows = action_rows.clone();
|
let action_rows = action_rows.clone();
|
||||||
let info = info.clone();
|
let info = info.clone();
|
||||||
move |_| {
|
move |_| {
|
||||||
let kind = Kind::ALL.get(selection.selected() as usize)
|
let kind = action_choice(selection.selected());
|
||||||
.copied().unwrap_or(Kind::Defibrillation);
|
|
||||||
if kind == Kind::ChestCompressions { return; }
|
|
||||||
let defib = if kind == Kind::DefibrillationRhythm {
|
let defib = if kind == Kind::DefibrillationRhythm {
|
||||||
let rhythm = match defib_rhythm.selected() {
|
let rhythm = match defib_rhythm.selected() {
|
||||||
1 => EcgRhythm::AtrialFibrillation,
|
1 => EcgRhythm::AtrialFibrillation,
|
||||||
|
|
@ -1993,3 +2018,23 @@ fn actions_page(params: SharedParams, simulator: Rc<RefCell<Simulator>>,
|
||||||
scroller.set_child(Some(&panel));
|
scroller.set_child(Some(&panel));
|
||||||
scroller
|
scroller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod actions_tab_layout_tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cpr_is_a_permanent_control_not_a_duplicate_dropdown_action() {
|
||||||
|
assert_eq!(SCRIPTED_ACTION_CHOICES.len(), 7);
|
||||||
|
assert!(!SCRIPTED_ACTION_CHOICES.contains(&Kind::ChestCompressions));
|
||||||
|
assert_eq!(action_choice(0), Kind::Defibrillation);
|
||||||
|
assert_eq!(action_choice(1), Kind::DefibrillationRhythm);
|
||||||
|
assert_eq!(action_choice(4), Kind::Norepinephrine);
|
||||||
|
assert_eq!(action_choice(6), Kind::LethalPropofol);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unknown_action_selection_falls_back_to_artifact_only() {
|
||||||
|
assert_eq!(action_choice(u32::MAX), Kind::Defibrillation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue