Skip to content

Commit

Permalink
GUI/Main/Pharma/Vitals - Blood Pressure and HandleUnitVitals fixes (K…
Browse files Browse the repository at this point in the history
…AT-Advanced-Medical#618)

**When merged this pull request will:**
- Fixes blood pressure values to be more stable and to only come from
one source
- Implements HandleUnitVitals changes to simple vitals

### 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}`.
  • Loading branch information
mazinskihenry authored Oct 11, 2024
1 parent 7cb7b09 commit d082614
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 47 deletions.
48 changes: 24 additions & 24 deletions addons/circulation/Blood_Medical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,122 @@ class BloodIV;
class BloodIV_O: BloodIV {
displayName = CSTRING(Action_BloodIV_O);
items[] = {"kat_bloodIV_O"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_O_N: BloodIV {
displayName = CSTRING(Action_BloodIV_O_N);
items[] = {"kat_bloodIV_O_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_A: BloodIV {
displayName = CSTRING(Action_BloodIV_A);
items[] = {"kat_bloodIV_A"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_A_N: BloodIV {
displayName = CSTRING(Action_BloodIV_A_N);
items[] = {"kat_bloodIV_A_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_B: BloodIV {
displayName = CSTRING(Action_BloodIV_B);
items[] = {"kat_bloodIV_B"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_B_N: BloodIV {
displayName = CSTRING(Action_BloodIV_B_N);
items[] = {"kat_bloodIV_B_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_AB: BloodIV {
displayName = CSTRING(Action_BloodIV_AB);
items[] = {"kat_bloodIV_AB"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_AB_N: BloodIV {
displayName = CSTRING(Action_BloodIV_AB_N);
items[] = {"kat_bloodIV_AB_N"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 800, 12]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -800, 12]] call CBA_fnc_localEvent;";
};
class BloodIV_500;
class BloodIV_O_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_O);
items[] = {"kat_bloodIV_O_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_O_N_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_O_N);
items[] = {"kat_bloodIV_O_N_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_A_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_A);
items[] = {"kat_bloodIV_A_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_A_N_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_A_N);
items[] = {"kat_bloodIV_A_N_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_B_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_B);
items[] = {"kat_bloodIV_B_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_B_N_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_B_N);
items[] = {"kat_bloodIV_B_N_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_AB_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_AB);
items[] = {"kat_bloodIV_AB_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_AB_N_500: BloodIV_500 {
displayName = CSTRING(Action_500_BloodIV_AB_N);
items[] = {"kat_bloodIV_AB_N_500"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 400, 8]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -400, 8]] call CBA_fnc_localEvent;";
};
class BloodIV_250;
class BloodIV_O_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_O);
items[] = {"kat_bloodIV_O_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_O_N_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_O_N);
items[] = {"kat_bloodIV_O_N_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_A_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_A);
items[] = {"kat_bloodIV_A_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_A_N_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_A_N);
items[] = {"kat_bloodIV_A_N_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_B_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_B);
items[] = {"kat_bloodIV_B_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_B_N_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_B_N);
items[] = {"kat_bloodIV_B_N_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_AB_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_AB);
items[] = {"kat_bloodIV_AB_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
class BloodIV_AB_N_250: BloodIV_250 {
displayName = CSTRING(Action_250_BloodIV_AB_N);
items[] = {"kat_bloodIV_AB_N_250"};
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, 200, 4]] call CBA_fnc_localEvent;";
callbackSuccess = "[_medic, _patient, _bodyPart, _className, _usedItem] call kat_circulation_fnc_handleTreatment; ['kat_fluid', [_patient, -200, 4]] call CBA_fnc_localEvent;";
};
2 changes: 0 additions & 2 deletions addons/gui/functions/fnc_updateABGStatus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ private _bloodGasTest = _target getVariable [QEGVAR(circulation,testedBloodGas),
private _activeBlood = 0;
private _ABGmenuShow = _target getVariable [QEGVAR(pharma,ABGmenuShow), false];

diag_log _ABGmenuShow;

if (_ABGmenuShow) then {
ctrlShow [IDC_ABG_TITLE, true];
ctrlShow [IDC_ABG_BACKGROUND, true];
Expand Down
3 changes: 2 additions & 1 deletion addons/pharma/functions/fnc_getBloodVolumeChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ if (!isNil {_unit getVariable [QACEGVAR(medical,ivBags),[]]}) then {
// Movement and recovery of interstital fluid
private _shiftValue = 0;
switch (true) do {
case ((_ECB + _ECP) > (_ISP * 0.6)): {
case (((_ECB + _ECP) > (_ISP * 0.6)) && ((_ECB + _ECP) > 4500)): {
// Negative shifts only happen above 4500ml of blood volume, to prevent issues with falling back into arrest/unconsciousness
_shiftValue = (2 min ((_ECP + _ECB) - (_ISP * 0.6)));
_ECP = _ECP - _shiftValue;
_ISP = _ISP + _shiftValue;
Expand Down
13 changes: 9 additions & 4 deletions addons/vitals/functions/fnc_handleOxygenFunction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ private _paco2 = if ((_demandVentilation / _actualVentilation) == 1) then { _pre
// 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));

// Extenal pH impacts from saline is included
private _externalPh = _unit getVariable [QEGVAR(pharma,externalPh), 0];
private _externalPh = 0;
private _pH = 7.4;

// pH is from the Henderson-Hasselbalch equation
private _pH = (6.1 + log(24 / ((0.03 - 0.001 * (_temperature - DEFAULT_TEMPERATURE)) * _paco2))) - ((_externalPh max 1) / 2000);
if (EGVAR(pharma,kidneyAction)) then {
// Extenal pH impacts from saline is included
_externalPh = _unit getVariable [QEGVAR(pharma,externalPh), 0];

// pH is from the Henderson-Hasselbalch equation
_pH = (6.1 + log(24 / ((0.03 - 0.001 * (_temperature - DEFAULT_TEMPERATURE)) * _paco2))) - ((_externalPh max 1) / 2000);
};

// Fractional Oxygen when breathing normal air is 0.21, 1 when breathing 100% Oxygen, and 0 when no air is being brought into the lungs
private _fio2 = switch (true) do {
Expand Down
7 changes: 3 additions & 4 deletions addons/vitals/functions/fnc_handleSimpleVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@ if !(_adjustments isEqualTo []) then {
private _heartRate = [_unit, _hrTargetAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updateHeartRate); //Rename
[_unit, _painSupressAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updatePainSuppress); //Leave alone

// Remeber to change getBloodPressure macro ----------------------------------------------------------

private _bloodPressure = [120,80];
_unit setVariable [VAR_BLOOD_PRESS, _bloodPressure, _syncValues];

_bloodPressure params ["_bloodPressureL", "_bloodPressureH"];

// Statements are ordered by most lethal first.
switch (true) do {
case (IN_CRDC_ARRST(_unit)): {}; // if in cardiac arrest just break now to avoid throwing unneeded events
Expand Down Expand Up @@ -119,4 +115,7 @@ if (!isPlayer _unit) then {

END_COUNTER(Vitals);

//placed outside the counter as 3rd-party code may be called from this event
[QACEGVAR(medical,handleUnitVitals), [_unit, _deltaT]] call CBA_fnc_localEvent;

true
15 changes: 3 additions & 12 deletions addons/vitals/functions/fnc_handleUnitVitals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,13 @@ if (EGVAR(breathing,enable)) then {
_spo2 = [_unit, _heartRate, _anerobicPressure, _bloodGas, _temperature, _baroPressure, _opioidDepression, _deltaT, _syncValues] call FUNC(handleOxygenFunction);
};

// Systolic Blood Pressure from Blood Volume with postive Heart Rate impacts capped by Blood Volume, Diastolic Blood Pressure from Vasoconstriction and Systolic BP
private _vasoconstriction = GET_VASOCONSTRICTION(_unit);

private _bloodPressureSystolic = (_bloodVolume * 20) * ((_unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES]) / 100) + ((-0.005 * _heartRate^2) + (1.6 * _heartRate) - 96);
_bloodPressureSystolic = 250 / (1 + exp((-0.04) * (_bloodPressureSystolic - 122)));

private _bloodPressureDiastolic = ((_bloodVolume * 13.33) * ((_unit getVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES]) / 100) + ((_vasoconstriction - 1) * 40)) min (_bloodPressureSystolic - 5);
_bloodPressureDiastolic = 250 / (1 + exp((-0.04) * (_bloodPressureDiastolic - 100)));

private _woundBloodLoss = GET_WOUND_BLEEDING(_unit);

// Vasoconstriction from Wound Blood Loss and Alpha Adjustment
_vasoconstriction = 1 + (0.5 * _woundBloodLoss) + _alphaFactorAdjustment;
_unit setVariable [VAR_VASOCONSTRICTION, (1.8 min (0.2 max _vasoconstriction)), _syncValues];

private _bloodPressure = [round(_bloodPressureDiastolic), round(_bloodPressureSystolic)];
private _woundBloodLoss = GET_WOUND_BLEEDING(_unit);

private _bloodPressure = [_unit] call EFUNC(circulation,getBloodPressure);
_unit setVariable [VAR_BLOOD_PRESS, _bloodPressure, _syncValues];

_bloodPressure params ["_bloodPressureL", "_bloodPressureH"];
Expand Down

0 comments on commit d082614

Please sign in to comment.