Skip to content

Commit

Permalink
Vitals - Improve oxygen function to handle respiratory depression (#643)
Browse files Browse the repository at this point in the history
**When merged this pull request will:**
- Adds respiratory depression to the vitals loop
- Adds pneumothorax's to the oxygen calculation to affect multiple areas

### IMPORTANT

- [Development Guidelines](https://ace3.acemod.org/wiki/development/)
are read, understood and applied.
- Title of this PR uses our standard template `Component -
Add|Fix|Improve|Change|Make|Remove {changes}`.

---------

Co-authored-by: mazinskihenry <[email protected]>
  • Loading branch information
Cplhardcore and mazinskihenry authored Jan 31, 2025
1 parent 4dc0e7e commit bd700f4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
8 changes: 7 additions & 1 deletion addons/breathing/functions/fnc_checkBreathing.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ private _breathing_log = localize ACELSTRING(medical_treatment,Check_Pulse_Norma
private _breath = "";
private _breathRate = "RR: ";

if ((_patient getVariable [QGVAR(pneumothorax), 0] > 0) || (_patient getVariable [QEGVAR(chemical,airPoisoning), false])) then {
private _respiratoryDepth = _patient getVariable [QEGVAR(vitals,respiratoryDepth), 10];
if (((10 > _respiratoryDepth) && (_respiratoryDepth >= 7)) || (_patient getVariable [QEGVAR(chemical,airPoisoning), false])) then {
_breathing = LLSTRING(breathing_isShallow);
_breathing_log = LLSTRING(breathing_shallow);
};

if (_respiratoryDepth < 7) then {
_breathing = LLSTRING(breathing_isVeryShallow);
_breathing_log = LLSTRING(breathing_Veryshallow);
};

if (_ph < 7.2) then {
_breath = LLSTRING(breath_mild);

Expand Down
6 changes: 6 additions & 0 deletions addons/breathing/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,12 @@
<Japanese>呼吸速度: 正常</Japanese>
<French>RR : Normal</French>
</Key>
<Key ID="STR_KAT_Breathing_breathing_isVeryShallow">
<English>Patient's breathing is very shallow</English>
</Key>
<Key ID="STR_KAT_Breathing_breathing_Veryshallow">
<English>Very Shallow</English>
</Key>
<Key ID="STR_KAT_Breathing_breathing_none">
<English>Patient is not breathing</English>
<Japanese>患者は呼吸していない</Japanese>
Expand Down
4 changes: 4 additions & 0 deletions addons/main/script_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
#define DEFAULT_PH 7.4
#define DEFAULT_ETCO2 37
#define DEFAULT_BLOOD_GAS [DEFAULT_PACO2, DEFAULT_PAO2, DEFAULT_O2SAT, DEFAULT_HCO3, DEFAULT_PH, DEFAULT_ETCO2]
#define DEFAULT_RESPIRATORY_DEPTH 10

#define DEFAULT_ANEROBIC_EXCHANGE 0.8
#define DEFAULT_TEMPERATURE 37
Expand All @@ -302,6 +303,9 @@
#define VAR_SURFACE_AREA 400
#define GET_KAT_SURFACE_AREA(unit) (VAR_SURFACE_AREA - (((unit getVariable [QEGVAR(breathing,pneumothorax), 0]) * 75)))

#define VAR_RESPIRATORY_DEPTH QEGVAR(vitals,respiratoryDepth)
#define GET_KAT_RESPIRATORY_DEPTH(unit) (unit getVariable [QEGVAR(vitals,respiratoryDepth), 10])

#define VAR_BLOOD_GAS QEGVAR(circulation,bloodGas)
#define VAR_BREATHING_RATE QEGVAR(breathing,breathRate)

Expand Down
1 change: 1 addition & 0 deletions addons/vitals/functions/fnc_fullHealLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
params ["_patient"];

_patient setVariable [QGVAR(simpleMedical), false, true];
_patient setVariable [QGVAR(respiratoryDepth), DEFAULT_RESPIRATORY_DEPTH, true];

if (GVAR(enableSimpleMedical)) then {
_patient setVariable [QGVAR(simpleMedical), true, true];
Expand Down
15 changes: 11 additions & 4 deletions addons/vitals/functions/fnc_handleOxygenFunction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ params ["_unit", "_actualHeartRate", "_anerobicPressure", "_bloodGas", "_tempera
#define PACO2_MAX_CHANGE 0.05
#define PAO2_MAX_CHANGE 0.1
#define DEFAULT_FIO2 0.21
#define MINIMUM_DEPTH 0.2

private _respiratoryRate = 0;
private _respiratoryDepression = 0;
private _demandVentilation = 0;
private _actualVentilation = 0;
private _previousCyclePaco2 = (_bloodGas select 0);
Expand All @@ -41,15 +43,20 @@ private _previousCyclePao2 = (_bloodGas select 1);
if (IN_CRDC_ARRST(_unit)) then {
// When in arrest, there should be no effecive breaths but still a minimum O2 demand. Zero O2 demand would mean a dead patient. Actual ventilation is 1 to prevent issues in the gas tension functions
_demandVentilation = MINIMUM_VENTILATION;
_respiratoryDepression = 1;
_respiratoryRate = [0, 20] select (_unit getVariable [QEGVAR(breathing,BVMInUse), false]);
_actualVentilation = 1;
} else {
// Ventilatory Demand comes from Heart Rate with increase demand from PaCO2 levels
_demandVentilation = ((((_actualHeartRate * HEART_RATE_CO2_MULTIPLIER) / _anerobicPressure) + ((_previousCyclePaco2 - DEFAULT_PACO2) * 200)) max MINIMUM_VENTILATION);
private _tidalVolume = GET_KAT_SURFACE_AREA(_unit);

// Respiratory Rate is supressed by Opioids
_respiratoryRate = [((_demandVentilation / _tidalVolume) - (_opioidDepression * 5)) min MAXIMUM_RR, 20] select (_unit getVariable [QEGVAR(breathing,BVMInUse), false]);
// Tidal Volume is modified by respiratory depth which can be supressed by opioids and pneumothroax
private _respiratoryDepth = [((DEFAULT_RESPIRATORY_DEPTH / 10) - (_opioidDepression / 1.5)), 10] select (_unit getVariable [QEGVAR(breathing,BVMInUse), false]);
private _tidalVolume = GET_KAT_SURFACE_AREA(_unit) * (_respiratoryDepth / 1);

// Respiratory Rate Calculation
_respiratoryRate = [((_demandVentilation / _tidalVolume)) min MAXIMUM_RR, 20] select (_unit getVariable [QEGVAR(breathing,BVMInUse), false]);

// If respiratory rate is low due to PaCO2, it starts increasing faster to compensate
if (_previousCyclePaco2 > 50) then { _respiratoryRate = (_respiratoryRate + ((_previousCyclePaco2 - 50) * 0.2)) min MAXIMUM_RR};
Expand All @@ -76,7 +83,7 @@ if (IN_CRDC_ARRST(_unit)) then {
};
} else {
// Generated ETCO2 quadratic. Ensures ETCO2 moves with Respiratory Rate and is constantly below PaCO2
_etco2 = ((_paco2 - 3) - ((-0.0416667 * (_respiratoryRate^2)) + (3.09167 * (_respiratoryRate)) - DEFAULT_ETCO2) max 5);
_etco2 = (((_paco2 - 3) - ((-0.0416667 * (_respiratoryRate^2)) + (3.09167 * (_respiratoryRate))) * (_respiratoryDepth)) - DEFAULT_ETCO2) max 5;
};

private _externalPh = 0;
Expand Down Expand Up @@ -123,5 +130,5 @@ private _o2Sat = ((_pao2 max 1)^2.7 / ((25 - (((_pH / DEFAULT_PH) - 1) * 150))^2

_unit setVariable [VAR_BREATHING_RATE, (_respiratoryRate max 0), _syncValues];
_unit setVariable [VAR_BLOOD_GAS, [_paco2, _pao2, _o2Sat, 24, _pH, _etco2], _syncValues];

_unit setVariable [QGVAR(respiratoryDepth), (_respiratoryDepth max 0), _syncValues];
_o2Sat * 100

0 comments on commit bd700f4

Please sign in to comment.