Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitals - Improve oxygen function to handle respiratory depression #643

Open
wants to merge 4 commits into
base: dev-Tomcat
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion addons/breathing/functions/fnc_checkBreathing.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ private _breathing = LLSTRING(breathing_isNormal);
private _breathing_log = localize ACELSTRING(medical_treatment,Check_Pulse_Normal);
private _breath = "";

if (_patient getVariable [QGVAR(pneumothorax), 0] > 0) then {
private _respiratoryDepth = _patient getVariable [QEGVAR(vitals,respiratoryDepth), 10];
if ((10 > _respiratoryDepth) && (_respiratoryDepth >= 7)) 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 @@ -2323,6 +2323,12 @@
<Russian>Дыхание поверхностное</Russian>
<Dutch>Oppervlakkig</Dutch>
</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
17 changes: 12 additions & 5 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 @@ -42,19 +44,24 @@ 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;
_respiratoryRate = 0;
_respiratoryDepression = 1;
_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]);
// Respiratory Depth is supressed by Opioids and pneumothorax
private _respiratoryDepth = (DEFAULT_RESPIRATORY_DEPTH - ((_unit getVariable [QEGVAR(breathing,pneumothorax), 0]) / 2));
_respiratoryDepression = [((_respiratoryDepth - (_opioidDepression * 5)) max MINIMUM_DEPTH), 10] select (_unit getVariable [QEGVAR(breathing,BVMInUse), false]);

// 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};

_actualVentilation = _tidalVolume * _respiratoryRate;
_actualVentilation = _tidalVolume * _respiratoryRate * (_respiratoryDepression / 10);
};

private _paco2 = 40;
Expand All @@ -65,7 +72,7 @@ if (EGVAR(breathing,paco2Active)) then {
};

// Generated ETCO2 quadratic. Ensures ETCO2 moves with Respiratory Rate and is constantly below PaCO2
private _etco2 = [((_paco2 - 3) - ((-0.0416667 * (_respiratoryRate^2)) + (3.09167 * (_respiratoryRate)) - DEFAULT_ETCO2) max 10), 0] select (IN_CRDC_ARRST(_unit));
private _etco2 = [((((_paco2 - 3) - ((-0.0416667 * (_respiratoryRate^2)) + (3.09167 * (_respiratoryRate))) *(_respiratoryDepression / 10)) - DEFAULT_ETCO2) max 10), 0] select (IN_CRDC_ARRST(_unit));

private _externalPh = 0;
private _pH = 7.4;
Expand Down Expand Up @@ -102,5 +109,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), (_respiratoryDepression max 0), _syncValues];
_o2Sat * 100
Loading