Index: sources/storage/TreatmentLog.h =================================================================== diff -u -r928a1ed5d70358fc00c49df45725f989d16c370e -r3b323bd6a1a03429c2321a889049de1c3b11302f --- sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 928a1ed5d70358fc00c49df45725f989d16c370e) +++ sources/storage/TreatmentLog.h (.../TreatmentLog.h) (revision 3b323bd6a1a03429c2321a889049de1c3b11302f) @@ -1,13 +1,13 @@ /*! * - * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. + * 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) 27-Jun-2022 + * \date (last) 13-Mar-2024 * \author (original) Behrouz NematiPour * \date (original) 04-May-2021 * @@ -40,9 +40,18 @@ { Q_OBJECT + const int _interval = 1000; // 1s + const int _pendingInterval= 60 ; // 1m + int _pendingCounter = 0 ; // + + const QString _sep = ","; + QString _treatmentLogPath; - QString _treatmentLogPath_Pending; + const char* _treatmentLogExtUploaded = "txr"; + const char* _treatmentLogExtPending = "txr.p"; + const char* _txCodeKey = "Tx Code"; + QFutureWatcher _saveWatcher; QFutureWatcher _exportWatcher; @@ -54,7 +63,7 @@ QString _unitTextFlowRate = tr("mL/min" ); QString _unitTextDurationHour = tr("hour" ); QString _unitTextDurationMin = tr("min" ); - QString _unitTextConcentration = tr("mEg/L" ); + QString _unitTextConcentration = tr("mEq/L" ); QString _unitTextTemperature = tr("C" ); QString _unitTextVolume = tr("L" ); QString _unitTextFluid = tr("mL" ); @@ -76,16 +85,20 @@ QString mPatientID = ""; QString mFileName = ""; } - _lastTxInfo; + _lastTxInfo; + QString _deviceID = "unknown"; + QString _pendingTxr = ""; + QString _emptyPatinetID = "NoPatientIDEntered"; // No translation - QString _deviceID = ""; - QString _txCode = ""; // content of this value comes from CloudSync App. + 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 { @@ -188,68 +201,87 @@ _unitTextFluid , // eSalineBolusVolume }; - 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 addTxCode(); + 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 () { return _treatmentLogPath ;} - QString logPathPending () { return _treatmentLogPath_Pending ;} + 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 onTxCodeReceive (const QString &vTxCode); + void onCloudSyncStatus ( bool vReady ); public slots: void doSave (); void doExport (); signals: - void didTreatmentLogSave( const QString &vDeviceID , - const QString &vPatientID , - const QString &vFileName ); - void didTxCodeReceive ( const QString &vTxCode ); + void didPendingTxr ( const QString &vFileName ); + void didTxCodeReceive ( const QString &vTxCode ); - void didNotification ( const QString &vNotification); + void didNotification ( const QString &vNotification ); }; }