Index: sources/storage/TreatmentLog.h =================================================================== diff -u -r7b34653589ba6e4f4705fb4026fcd9319c41c352 -r3b323bd6a1a03429c2321a889049de1c3b11302f --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 7b34653589ba6e4f4705fb4026fcd9319c41c352) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 3b323bd6a1a03429c2321a889049de1c3b11302f) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * copyright + * Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. + * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file TreatmentLog.h * \author (last) Behrouz NematiPour - * \date (last) 4/30/2021 + * \date (last) 13-Mar-2024 * \author (original) Behrouz NematiPour - * \date (original) 4/30/2021 + * \date (original) 04-May-2021 * */ #pragma once @@ -40,8 +40,18 @@ { Q_OBJECT + const int _interval = 1000; // 1s + const int _pendingInterval= 60 ; // 1m + int _pendingCounter = 0 ; // + + const QString _sep = ","; + QString _treatmentLogPath; + const char* _treatmentLogExtUploaded = "txr"; + const char* _treatmentLogExtPending = "txr.p"; + const char* _txCodeKey = "Tx Code"; + QFutureWatcher _saveWatcher; QFutureWatcher _exportWatcher; @@ -53,24 +63,46 @@ QString _unitTextFlowRate = tr("mL/min" ); QString _unitTextDurationHour = tr("hour" ); QString _unitTextDurationMin = tr("min" ); - QString _unitTextConcentration = tr("mEg/L" ); - QString _unitTextTemperature = tr("°C" ); + QString _unitTextConcentration = tr("mEq/L" ); + QString _unitTextTemperature = tr("C" ); QString _unitTextVolume = tr("L" ); QString _unitTextFluid = tr("mL" ); QString _unitTextHeparinConcentration = tr("IU/mL" ); - QString _unitTextDispencingRate = tr("mL/hr" ); + QString _unitTextDispensingRate = tr("mL/hr" ); QString _unitTextBloodPressure = tr("mmHg" ); + struct TxInfo { + void clear() { + mStatus = false; + mDateTime = ""; + mDeviceID = ""; + mPatientID = ""; + mFileName = ""; + } + bool mStatus = false; + QString mDateTime = ""; + QString mDeviceID = ""; + QString mPatientID = ""; + QString mFileName = ""; + } + _lastTxInfo; + QString _deviceID = "unknown"; + QString _pendingTxr = ""; + QString _emptyPatinetID = "NoPatientIDEntered"; // No translation + + MEMBER( QString , gTxCode, ""); // content of this value is generated by VPreTreatment. + MEMBER( QString , rTxCode, ""); // content of this value be received from CloudSync App. + enum Role { - eValue, eTitle, - eUnit + eValue, + eUnit , + eCount }; enum TreatmentLogIndex { ePatientID , - eDeviceID , eBloodFlowRate , eDialysateFlowRate , eTreatmentDuration , @@ -93,23 +125,18 @@ eTreatmentEndDateTime , eWaterSampleTestResult , eDialysateVolumeUsed , + eOriginUFVolume , eTargetUFVolume , eActualUFVolume , + eOriginUFRate , eTargetUFRate , eActualUFRate , eSalineBolusVolume , - eAverageBloodFlow , - eAverageDialysateFlow , - eAverageDialysateTemp , - eAverageArterialPressure , - eAverageVenousPressure , - - eTreatmentLogIndexCount + eTreatmentLogIndexCount , }; const QStringList _titles { tr("Patient ID" ), // ePatientID - tr("Device ID" ), // eDeviceID tr("Blood Flow Rate" ), // eBloodFlowRate tr("Dialysate Flow Rate" ), // eDialysateFlowRate tr("Treatment Duration" ), // eTreatmentDuration @@ -132,21 +159,17 @@ tr("Treatment End DateTime" ), // eTreatmentEndDateTime tr("Water Sample Test Result" ), // eWaterSampleTestResult tr("Dialysate Volume Used" ), // eDialysateVolumeUsed + tr("Prescribed UF Volume" ), // eOriginUFVolume tr("Target UF Volume" ), // eTargetUFVolume tr("Actual UF Volume" ), // eActualUFVolume + tr("Prescribed UF Rate" ), // eOriginUFRate tr("Target UF Rate" ), // eTargetUFRate tr("Actual UF Rate" ), // eActualUFRate tr("Saline Bolus Volume" ), // eSalineBolusVolume - tr("Average Blood Flow" ), // eAverageBloodFlow - tr("Average Dialysate Flow" ), // eAverageDialysateFlow - tr("Average Dialysate Temp" ), // eAverageDialysateTemp - tr("Average Arterial Pressure" ), // eAverageArterialPressure - tr("Average Venous Pressure" ), // eAverageVenousPressure }; const QStringList _units { "" , // ePatientID - "" , // eDeviceID _unitTextFlowRate , // eBloodFlowRate _unitTextFlowRate , // eDialysateFlowRate _unitTextDurationMin , // eTreatmentDuration @@ -162,77 +185,103 @@ "" , // eHeparinType _unitTextHeparinConcentration , // eHeparinConcentration _unitTextFluid , // eHeparinBolusVolume - _unitTextDispencingRate , // eHeparinDispenseRate + _unitTextDispensingRate , // eHeparinDispenseRate _unitTextDurationMin , // eHeparinStop _unitTextFluid , // eHeparinDeliveredVolume "" , // eTreatmentStartDateTime "" , // eTreatmentEndDateTime "" , // eWaterSampleTestResult _unitTextVolume , // eDialysateVolumeUsed + _unitTextVolume , // eOriginUFVolume _unitTextVolume , // eTargetUFVolume _unitTextVolume , // eActualUFVolume + _unitTextFlowRate , // eOriginUFRate _unitTextFlowRate , // eTargetUFRate _unitTextFlowRate , // eActualUFRate _unitTextFluid , // eSalineBolusVolume - _unitTextFlowRate , // eAverageBloodFlow - _unitTextFlowRate , // eAverageDialysateFlow - _unitTextTemperature , // eAverageDialysateTemp - _unitTextBloodPressure , // eAverageArterialPressure - _unitTextBloodPressure , // eAverageVenousPressure }; - QString title(quint8 vIndex) const { - if (vIndex < _titles.count()) return _titles[vIndex]; - return ""; + QString string(quint8 vIndex , const QStringList &vStringList) const { + QString str = ""; + if (vIndex < vStringList.count()) { + str = vStringList[vIndex]; + str.remove(_sep); + } + return str; } - QString value(quint8 vIndex) const { - if (vIndex < _values.count()) return _values[vIndex]; - return ""; - } - QString unit(quint8 vIndex) const { - if (vIndex < _units.count()) return _units[vIndex]; - return ""; - } + QString title(quint8 vIndex) const { return string(vIndex, _titles );} + QString value(quint8 vIndex) const { return string(vIndex, _values );} + QString unit (quint8 vIndex) const { return string(vIndex, _units );} + // Lists QStringList _values; + QList _treatmentLogAvrgeData; QList _treatmentLogAlarmData; QList _treatmentLogEventData; + QMap _treatmentLogAlarmTitles; + QMap _treatmentLogEventTitles; + + void readAlarmTitles ( ); + void readEventTitles ( ); + QString alarmTitle (quint32 vID); + QString eventTitle (quint32 vID); + void initConnections(); - void logPath (Logger::LogType vLogType = Logger::eLogTrtmt, QString vLogPath = ""); + void logPath (Logger::LogType vLogType, QString vLogPath); bool saveLog (); void saveLogConcurrent (); bool exportLog (); void exportLogConcurrent(); + bool checkTxCode(); + bool findTxCode (); + void sendPending(); + // Pending Tx Report + void testPendingTxReports (); // eMessageID_TxReport + NOTIFIER(isIdle) SINGLETON(TreatmentLog) +protected: + void timerEvent(QTimerEvent *) override; + public: - void initModel(const AdjustTreatmentLogResponseData &vData, const QString &vPatientID); + void initModel(const AdjustTreatmentLogResponseData &vData, const QString &vPatientID, bool vHeparinBolusVolumeOff, bool vHeparinDispensingRateOff); + void clearModel() { + _values.clear(); + for (int i = 0; i < eTreatmentLogIndexCount; i++) _values << ""; + } - const QStringList titles() const { return _titles; } - const QStringList units () const { return _units ; } - const QStringList values() const { return _values; } + const QStringList titles () const { return _titles ; } + const QStringList units () const { return _units ; } + const QStringList values () const { return _values ; } void append(const TreatmentLogAvrgeData &vData); void append(const TreatmentLogAlarmData &vData); void append(const TreatmentLogEventData &vData); + QString logPath () const { return _treatmentLogPath; } + private slots: void onLogPathSet(Logger::LogType vLogType, const QString &vLogPath); void onSave (); void onExport (); + void onTxCodeReceive (const QString &vTxCode); + void onCloudSyncStatus ( bool vReady ); public slots: void doSave (); void doExport (); signals: + void didPendingTxr ( const QString &vFileName ); + void didTxCodeReceive ( const QString &vTxCode ); + void didNotification ( const QString &vNotification ); }; }