Index: firmware/App/Services/TxParams.h =================================================================== diff -u -rda59fa4a98dbc11c37677e92a66aa940d251678f -r52787cd53986cfd0abb7e674bf096898e5070f9a --- firmware/App/Services/TxParams.h (.../TxParams.h) (revision da59fa4a98dbc11c37677e92a66aa940d251678f) +++ firmware/App/Services/TxParams.h (.../TxParams.h) (revision 52787cd53986cfd0abb7e674bf096898e5070f9a) @@ -7,8 +7,8 @@ * * @file TxParams.h * -* @author (last) Raghu Kallala -* @date (last) 01-May-2026 +* @author (last) Vijay Pamula +* @date (last) 07-Jul-2026 * * @author (original) Varshini Nagabooshanam * @date (original) 02-Dec-2025 @@ -37,6 +37,8 @@ #define MAX_UF_RATE_ML_MIN ( 2000.01F / (F32)MIN_PER_HOUR ) ///< Maximum ultrafiltration rate (in mL/min). Added small decimal to prevent float round off issues. #define MIN_UF_RATE_ML_MIN ( 0.0F ) ///< Minimum ultrafiltration rate (in mL/min). #define MAX_UF_VOLUME_ML ( 8 * ML_PER_LITER ) ///< Maximum ultrafiltration volume (in mL). +#define MIN_ISOLATED_UF_DURATION_MIN ( 30 ) ///< Minimum isolated UF session duration (in min). +#define MIN_ISOLATED_UF_VOLUME_ML ( 0.1F * (F32)ML_PER_LITER ) ///< Minimum isolated UF volume (in mL). /// Record structure for a treatment parameters payload from UI. typedef struct @@ -104,17 +106,187 @@ F32 uFVolume_L; ///< Current ultrafiltration volume (in L). } CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T; -/// Payload record structure for treatment parameter range broadcast messages. +#pragma pack(push, 1) + +/// Payload record structure for requesting an isolated UF duration change. typedef struct { - U32 minTreatmentTime; ///< Minimum treatment duration (in minutes) - U32 maxTreatmentTime; ///< Maximum treatment duration (in minutes) - F32 minUFVolume; ///< Minimum ultrafiltration volume (in mL) - F32 maxUFVolume; ///< Maximum ultrafiltration volume (in mL) - U32 minDialRate; ///< Minimum dialysate flow rate (in mL/min) - U32 maxDialRate; ///< Maximum dialysate flow rate (in mL/min) -} TREATMENT_PARAM_RANGE_BROADCAST_PAYLOAD_T; + U32 mDuration; ///< Requested isolated UF duration in minutes. +} ISOLATED_UF_DURATION_CHANGE_REQUEST_PAYLOAD_T; +/// Payload record structure for requesting an isolated UF volume goal change. +typedef struct +{ + U32 mDuration; ///< Requested isolated UF duration in minutes. + U32 mVolume; ///< Requested isolated UF volume goal in mL. +} ISOLATED_UF_VOLUME_GOAL_CHANGE_REQUEST_PAYLOAD_T; + +/// Payload record structure for confirming an isolated UF settings change. +typedef struct +{ + U32 mConfirmed; ///< TRUE if user confirms the staged isolated UF settings. +} ISOLATED_UF_CONFIRM_REQUEST_PAYLOAD_T; + +/// Payload record structure for isolated UF duration change responses. +typedef struct +{ + U32 mAccepted; ///< Accepted/Rejected. + U32 mReason; ///< Rejection reason if not accepted. + U32 mVolumeMax; ///< Maximum isolated UF volume in mL for the requested duration. +} ISOLATED_UF_DURATION_CHANGE_RESPONSE_PAYLOAD_T; + +/// Payload record structure for isolated UF volume goal change responses. +typedef struct +{ + U32 mAccepted; ///< Accepted/Rejected. + U32 mReason; ///< Rejection reason if not accepted. + U32 mVolume; ///< Isolated UF volume goal in mL. + U32 mDuration; ///< Isolated UF duration in minutes. + U32 mRate; ///< Isolated UF rate in mL/min. +} ISOLATED_UF_VOLUME_GOAL_CHANGE_RESPONSE_PAYLOAD_T; + +/// Payload record structure for isolated UF confirmation responses. +typedef struct +{ + U32 mAccepted; ///< Accepted/Rejected. + U32 mReason; ///< Rejection reason if not accepted. +} ISOLATED_UF_CONFIRM_RESPONSE_PAYLOAD_T; + +#pragma pack(pop) + +/// Payload record structure for treatment duration validate request. +typedef struct +{ + U32 duration; ///< Requested treatment duration in minutes. +} TREATMENT_DURATION_VALIDATE_REQUEST_PAYLOAD_T; + +/// Payload record structure for treatment duration confirm request. +typedef struct +{ + U32 duration; ///< Confirmed treatment duration in minutes. + U32 heparinDuration; ///< Confirmed heparin delivery duration in minutes. + F32 ufRate; ///< Confirmed UF rate in L/hr. +} TREATMENT_DURATION_CONFIRM_REQUEST_PAYLOAD_T; + +/// Payload record structure for treatment duration validate response. +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected. + U32 rejectionReason; ///< Rejection reason if not accepted. + U32 duration; ///< Treatment duration in minutes. + U32 heparinDuration; ///< Heparin delivery duration in minutes. + F32 ufVolumeGoal; ///< UF volume goal in L. + F32 ufRate; ///< UF rate in L/hr. +} TREATMENT_DURATION_VALIDATE_RESPONSE_PAYLOAD_T; + +/// Payload record structure for bolus volume change request. +typedef struct +{ + U32 bolusVolume; ///< Requested bolus volume (in mL). +} BOLUS_VOLUME_CHANGE_REQUEST_PAYLOAD_T; + +/// Payload record structure for vitals settings change request. +typedef struct +{ + U32 systolicBpLowAlarmLimit; ///< Requested systolic BP low alarm limit in mmHg. + U32 systolicBpHighAlarmLimit; ///< Requested systolic BP high alarm limit in mmHg. + U32 heartRateLowAlarmLimit; ///< Requested heart rate low alarm limit in BPM. + U32 heartRateHighAlarmLimit; ///< Requested heart rate high alarm limit in BPM. + U32 vitalsMeasurementInterval_min; ///< Requested vitals measurement interval in minutes. +} VITALS_ADJUSTMENT_REQUEST_PAYLOAD_T; + +/// Payload record structure for vitals settings change response. +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected. + U32 systolicBpLowAlarmLimitRejectionReason; ///< Rejection reason for systolic BP low alarm limit. + U32 systolicBpHighAlarmLimitRejectionReason; ///< Rejection reason for systolic BP high alarm limit. + U32 heartRateLowAlarmLimitRejectionReason; ///< Rejection reason for heart rate low alarm limit. + U32 heartRateHighAlarmLimitRejectionReason; ///< Rejection reason for heart rate high alarm limit. + U32 vitalsMeasurementIntervalRejectionReason; ///< Rejection reason for vitals measurement interval. +} VITALS_ADJUSTMENT_RESPONSE_PAYLOAD_T; + +/// Payload record structure for pressure limit change request. +typedef struct +{ + U32 arterialPressureLimitWindowMMHG; ///< Arterial pressure limit window in mmHg. + U32 venousHighPressureLimitWindowMMHG; ///< Venous high pressure limit window in mmHg. + U32 venousLowPressureLimitWindowMMHG; ///< Venous low pressure limit window in mmHg. + U32 tmpPressureLimitWindowMMHG; ///< TMP pressure limit window in mmHg. +} PRESSURE_LIMIT_CHANGE_REQUEST_T; + +/// Payload record structure for in-treatment pressure limit change response. +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected. + U32 arterialPressureLimitWindowRejectionReason; ///< Rejection reason for arterial pressure limit window. + U32 venousPressureLimitWindowRejectionReason; ///< Rejection reason for venous pressure limit window. + U32 venousAsymmetricPressureLimitWindowRejectionReason; ///< Rejection reason for venous asymmetric pressure limit window. + U32 tmpPressureLimitWindowRejectionReason; ///< Rejection reason for TMP pressure limit window. +} PRESSURE_LIMITS_CHANGE_RESPONSE_PAYLOAD_T; + +/// Payload record structure for UF volume validate request. +typedef struct +{ + F32 ufVolume; ///< Requested UF volume in L. +} UF_VOLUME_VALIDATE_REQUEST_PAYLOAD_T; + +/// Payload record structure for UF volume confirm request. +typedef struct +{ + F32 ufVolume; ///< Confirmed UF volume in L. + F32 ufRate; ///< Confirmed UF rate in L/hr. +} UF_VOLUME_CONFIRM_REQUEST_PAYLOAD_T; + +/// Payload record structure for UF change response. +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected. + U32 rejectionReason; ///< Rejection reason if not accepted. + F32 ufVolumeGoal; ///< UF Volume in L. + F32 ufRate; ///< new UF rate in L/hr. +} UF_VOLUME_RESPONSE_PAYLOAD_T; + +/// Payload record structure for blood flow rate change request. +typedef struct +{ + U32 flowRate; ///< Blood flow rate in mL/min. +} BLOOD_FLOW_RATE_CHANGE_REQUEST_PAYLOAD_T; + +/// Payload record structure for dialysate flow rate change request. +typedef struct +{ + U32 flowRate; ///< Dialysate flow rate in mL/min. +} DIALYSATE_FLOW_RATE_CHANGE_REQUEST_PAYLOAD_T; + +/// Payload record structure for dialysate temperature change request. +typedef struct +{ + F32 temperature; ///< Dialysate temperature in degrees Celsius. +} DIALYSATE_TEMPERATURE_CHANGE_REQUEST_PAYLOAD_T; + +/// Payload record structure for prescription settings change request. +typedef struct +{ + U32 bloodFlowRate; ///< Blood flow rate. + U32 dialysateFlowRate; ///< Dialysate flow rate. + F32 dialysateTemperature; ///< Dialysate temperature. + U32 acidConcentrate; ///< Acid concentrate. + F32 acidConcentrateConversionFactor; ///< Acid concentrate conversion factor. + U32 bicarbonateConcentrate; ///< Dry bicarbonate cartridge size. + U32 treatmentModality; ///< Treatment modality. + U32 hepatitis; ///< Hepatitis status. + U32 sodium; ///< Sodium concentration. + U32 bicarbonate; ///< Bicarbonate concentration (mEq/L). +} TREATMENT_PRESCRIPTION_SETTINGS_EDIT_REQUEST_T; + +/// Payload record structure for prescription settings change response. +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected. + U32 rejectionReason[ NUM_OF_TREATMENT_SETPOINT_PARAMS ]; ///< Rejection reason for each prescription setting. +} TREATMENT_PRESCRIPTION_SETTINGS_EDIT_RESPONSE_T; + // ********** public function prototypes **************** BOOL setTreatmentParameterU32( TREATMENT_PARAM_T param, U32 value ); // Set a specified unsigned integer treatment parameter value @@ -123,11 +295,27 @@ F32 getTreatmentParameterF32( TREATMENT_PARAM_T param ); // Get a specified floating point treatment parameter BOOL validateAndSetTreatmentParameters( MESSAGE_T *message ); // User provided treatment params to be set and validated -//BOOL validateAndSetUFVolume( MESSAGE_T *message ); // User provided ultrafiltration volume to be set and validated +//BOOL validateAndSetUFVolume( MESSAGE_T *message ); // User provided ultrafiltration volume to be set and validated +F32 calculateIsolatedUFRateMlMin( U32 durationMin, F32 volumeGoalMl ); // Calculate isolated UF rate (mL/min) from duration and volume goal +BOOL handleIsolatedUFDurationChangeRequest( MESSAGE_T *message ); // User requested isolated UF duration change +BOOL handleIsolatedUFVolumeGoalChangeRequest( MESSAGE_T *message ); // User requested isolated UF volume goal change +BOOL handleIsolatedUFConfirmRequest( MESSAGE_T *message ); // User confirmed/rejected isolated UF settings change -void resetTreatmentParameters( void ); // Reset all parameters to defaults -//BOOL signalUserConfirmationOfTreatmentParameters( MESSAGE_T *message ); // Process UI confirm/reject Treatment parameters +// Edit Treatment parameter handlers +BOOL validateAndSetTreatmentDuration( MESSAGE_T *message ); // User provided treatment duration to be set and validated +BOOL validateAndSetBolusVolume( MESSAGE_T *message ); // User provided bolus volume to be set and validated +BOOL vitalsAdjustmentHandleChangeRequest( MESSAGE_T *message ); // User provided vitals settings to be validated and applied +BOOL pressureLimitHandleChangeRequest( MESSAGE_T *message ); // User provided pressure limit window values to be validated and applied +BOOL validateAndSetUFVolume( MESSAGE_T *message ); // User provided ultrafiltration volume to be set and validated +BOOL validateAndSetTreatmentSetPoints( MESSAGE_T *message ); // User provided prescription setting values to be validated and applied +BOOL validateAndSetBloodFlowRate( MESSAGE_T *message ); // Validates and applies blood flow rate change from UI button request +BOOL validateAndSetDialysateFlowRate( MESSAGE_T *message ); // Validates and applies dialysate flow rate change from UI button request +BOOL validateAndSetDialysateTemperature( MESSAGE_T *message ); // Validates and applies temperature change from UI button request +BOOL signalUserConfirmationOfTreatmentDuration( MESSAGE_T *message ); // Process UI confirm/reject treatment duration +BOOL signalUserConfirmationOfUFVolume( MESSAGE_T *message ); // Process UI confirm/reject ultrafiltration volume change +void initTreatmentParameters( void ); // Initialize treatment parameters and session state + BOOL getValidTreatParamsReceived( void ); // Determine whether valid Treatment Parameters exist BOOL getTreatParamsConfirmed( void ); // Determine whether user confirmed the parameters @@ -145,6 +333,7 @@ U32 getU32DefaultSysConfigTreatmentParamEdge( SYS_CONFIG_TREATMENT_PARAM_T param, BOOL isMin ); // Get default min/max edge for unsigned integer system configured treatment parameter U32 getSysConfigTreatmentParameterU32( SYS_CONFIG_TREATMENT_PARAM_T param ); // Get a specified unsigned integer system configured treatment parameter U32 getSysConfigTreatmentParameterU32DefaultValue( SYS_CONFIG_TREATMENT_PARAM_T param ); // Get the default value for a specified unsigned integer system configured treatment parameter +BOOL setSysConfigTreatmentParameterU32( SYS_CONFIG_TREATMENT_PARAM_T param, U32 value ); // Set a specified unsigned integer system configured treatment parameter U32 getDialyzerBloodVolume( DIALYZER_TYPE_T dialyzer ); // Get the blood side volume for a given dialyzer type U32 getDialyzerDialysateVolume( DIALYZER_TYPE_T dialyzer ); // Get the dialysate side volume for a given dialyzer type