mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 11:10:44 +00:00
Fix Statistics: corrected calculation of 'Used Days < 4 hrs/day'
This commit is contained in:
parent
2c1a79ca0a
commit
4768a02272
@ -708,14 +708,14 @@ Statistics::Statistics(QObject *parent) :
|
|||||||
rows.push_back(StatisticsRow("", SC_COLUMNHEADERS, MT_CPAP));
|
rows.push_back(StatisticsRow("", SC_COLUMNHEADERS, MT_CPAP));
|
||||||
rows.push_back(StatisticsRow(tr("CPAP Usage"), SC_SUBHEADING, MT_CPAP));
|
rows.push_back(StatisticsRow(tr("CPAP Usage"), SC_SUBHEADING, MT_CPAP));
|
||||||
|
|
||||||
rows.push_back(StatisticsRow(tr("Total Days"), SC_SELECTED_DAYS , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Total Days"), SC_TOTAL_DAYS , MT_CPAP));
|
||||||
rows.push_back(StatisticsRow(tr("Used Days"), SC_DAYS_W_DATA , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Used Days"), SC_DAYS_W_DATA , MT_CPAP));
|
||||||
rows.push_back(StatisticsRow(tr("Used Days %1%2 hrs/day"), SC_COMPLIANCE_DAYS , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Used Days %1%2 hrs/day"), SC_DAYS_GE_COMPLIANCE_HOURS , MT_CPAP));
|
||||||
|
|
||||||
rows.push_back(StatisticsRow(tr("Percent Total Days %1%2 hrs/day"), SC_COMPLIANCE , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Percent Total Days %1%2 hrs/day"), SC_TOTAL_DAYS_PERCENT , MT_CPAP));
|
||||||
rows.push_back(StatisticsRow(tr("Percent Used Days %1%2 hrs/day"), SC_USED_DAY_COMPLIANCE_PERCENT , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Percent Used Days %1%2 hrs/day"), SC_USED_DAY_PERCENT , MT_CPAP));
|
||||||
|
|
||||||
rows.push_back(StatisticsRow(tr("Used Days %1%2 hrs/day"), SC_NON_COMPLIANCE_DAYS , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Used Days %1%2 hrs/day"), SC_DAYS_LT_COMPLAINCE_HOURS , MT_CPAP));
|
||||||
rows.push_back(StatisticsRow(tr("Days Not Used"), SC_DAYS_WO_DATA , MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Days Not Used"), SC_DAYS_WO_DATA , MT_CPAP));
|
||||||
|
|
||||||
rows.push_back(StatisticsRow(tr("Average Hours per Night"), SC_HOURS, MT_CPAP));
|
rows.push_back(StatisticsRow(tr("Average Hours per Night"), SC_HOURS, MT_CPAP));
|
||||||
@ -1332,8 +1332,8 @@ QString Statistics::GenerateCPAPUsage()
|
|||||||
html += "<font size='+0'>";
|
html += "<font size='+0'>";
|
||||||
|
|
||||||
// Find first and last days with valid CPAP data
|
// Find first and last days with valid CPAP data
|
||||||
QDate lastcpap = p_profile->LastGoodDay(MT_CPAP);
|
QDate lastcpap = p_profile->LastDay();
|
||||||
QDate firstcpap = p_profile->FirstGoodDay(MT_CPAP);
|
QDate firstcpap = p_profile->FirstDay();
|
||||||
adjustRange(firstcpap,lastcpap);
|
adjustRange(firstcpap,lastcpap);
|
||||||
|
|
||||||
QString ahitxt = getRDIorAHIText();
|
QString ahitxt = getRDIorAHIText();
|
||||||
@ -1455,15 +1455,15 @@ QString Statistics::GenerateCPAPUsage()
|
|||||||
name = row.src;
|
name = row.src;
|
||||||
} else if (row.calc == SC_DAYS_W_DATA) {
|
} else if (row.calc == SC_DAYS_W_DATA) {
|
||||||
name = row.src;
|
name = row.src;
|
||||||
} else if (row.calc == SC_SELECTED_DAYS) {
|
} else if (row.calc == SC_TOTAL_DAYS) {
|
||||||
name = row.src;
|
name = row.src;
|
||||||
} else if (row.calc == SC_NON_COMPLIANCE_DAYS) {
|
} else if (row.calc == SC_DAYS_LT_COMPLAINCE_HOURS) {
|
||||||
name = QString(row.src).arg("< ").arg(p_profile->cpap->m_complianceHours);
|
name = QString(row.src).arg("< ").arg(p_profile->cpap->m_complianceHours);
|
||||||
} else if (row.calc == SC_USED_DAY_COMPLIANCE_PERCENT) {
|
} else if (row.calc == SC_USED_DAY_PERCENT) {
|
||||||
name = QString(row.src).arg(">= ").arg(p_profile->cpap->m_complianceHours);
|
name = QString(row.src).arg(">= ").arg(p_profile->cpap->m_complianceHours);
|
||||||
} else if (row.calc == SC_COMPLIANCE_DAYS) {
|
} else if (row.calc == SC_DAYS_GE_COMPLIANCE_HOURS) {
|
||||||
name = QString(row.src).arg(">= ").arg(p_profile->cpap->m_complianceHours);
|
name = QString(row.src).arg(">= ").arg(p_profile->cpap->m_complianceHours);
|
||||||
} else if (row.calc == SC_COMPLIANCE) {
|
} else if (row.calc == SC_TOTAL_DAYS_PERCENT) {
|
||||||
name = QString(row.src).arg(">= " ).arg(p_profile->cpap->m_complianceHours);
|
name = QString(row.src).arg(">= " ).arg(p_profile->cpap->m_complianceHours);
|
||||||
} else if (row.calc == SC_COLUMNHEADERS) {
|
} else if (row.calc == SC_COLUMNHEADERS) {
|
||||||
html += QString("<tr><td><b>%1</b></td>").arg(tr("Details"));
|
html += QString("<tr><td><b>%1</b></td>").arg(tr("Details"));
|
||||||
@ -1473,8 +1473,8 @@ QString Statistics::GenerateCPAPUsage()
|
|||||||
html += "</tr>";
|
html += "</tr>";
|
||||||
continue;
|
continue;
|
||||||
} else if (row.calc == SC_DAYS) {
|
} else if (row.calc == SC_DAYS) {
|
||||||
QDate first=p_profile->FirstGoodDay(row.type);
|
QDate first=p_profile->FirstDay(row.type);
|
||||||
QDate last=p_profile->LastGoodDay(row.type);
|
QDate last=p_profile->LastDay(row.type);
|
||||||
// there no relationship to reports date. It just specifies the number of days used for a cetain range of dates.
|
// there no relationship to reports date. It just specifies the number of days used for a cetain range of dates.
|
||||||
QString & machine = machinenames[row.type];
|
QString & machine = machinenames[row.type];
|
||||||
int value=p_profile->countDays(row.type, first, last );
|
int value=p_profile->countDays(row.type, first, last );
|
||||||
@ -1654,8 +1654,8 @@ QString Statistics::UpdateRecordsBox()
|
|||||||
|
|
||||||
Machine * cpap = p_profile->GetMachine(MT_CPAP);
|
Machine * cpap = p_profile->GetMachine(MT_CPAP);
|
||||||
if (cpap) {
|
if (cpap) {
|
||||||
QDate first = p_profile->FirstGoodDay(MT_CPAP);
|
QDate first = p_profile->FirstDay(MT_CPAP);
|
||||||
QDate last = p_profile->LastGoodDay(MT_CPAP);
|
QDate last = p_profile->LastDay(MT_CPAP);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Compliance and usage information
|
/// Compliance and usage information
|
||||||
@ -1932,15 +1932,10 @@ QString Statistics::UpdateRecordsBox()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
html += "</body></html>";
|
html += "</body></html>";
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString StatisticsRow::value(QDate start, QDate end)
|
QString StatisticsRow::value(QDate start, QDate end)
|
||||||
{
|
{
|
||||||
if (noDaysInPeriod.contains(start) ) return "-";
|
if (noDaysInPeriod.contains(start) ) return "-";
|
||||||
@ -1968,14 +1963,14 @@ QString StatisticsRow::value(QDate start, QDate end)
|
|||||||
}
|
}
|
||||||
} else if (calc == SC_DAYS_WO_DATA) {
|
} else if (calc == SC_DAYS_WO_DATA) {
|
||||||
value = QString::number((1+start.daysTo(end)) - p_profile->countDays(type, start, end ));
|
value = QString::number((1+start.daysTo(end)) - p_profile->countDays(type, start, end ));
|
||||||
} else if (calc == SC_USED_DAY_COMPLIANCE_PERCENT) {
|
} else if (calc == SC_USED_DAY_PERCENT) {
|
||||||
int days = p_profile->countDays(type, start, end );
|
int days = p_profile->countDays(type, start, end );
|
||||||
if (days) {
|
if (days) {
|
||||||
value = QString("%1%").arg( ( (
|
value = QString("%1%").arg( ( (
|
||||||
((100.0*(EventDataType)p_profile->countCompliantDays(type, start, end )) / (EventDataType)days) )
|
((100.0*(EventDataType)p_profile->countCompliantDays(type, start, end )) / (EventDataType)days) )
|
||||||
), 0, 'f', decimals);
|
), 0, 'f', decimals);
|
||||||
} else {
|
} else {
|
||||||
value = 0.0 ;
|
value = QString("-");
|
||||||
}
|
}
|
||||||
} else if (calc == SC_DAYS_W_DATA) {
|
} else if (calc == SC_DAYS_W_DATA) {
|
||||||
int daysUsed = p_profile->countDays(type, start, end);
|
int daysUsed = p_profile->countDays(type, start, end);
|
||||||
@ -1984,23 +1979,28 @@ QString StatisticsRow::value(QDate start, QDate end)
|
|||||||
noDaysInPeriod.insert(start);
|
noDaysInPeriod.insert(start);
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
} else if (calc == SC_SELECTED_DAYS) {
|
} else if (calc == SC_TOTAL_DAYS) {
|
||||||
value = QString::number(1+start.daysTo(end));
|
value = QString::number(1+start.daysTo(end));
|
||||||
} else if (calc == SC_NON_COMPLIANCE_DAYS) {
|
} else if (calc == SC_DAYS_LT_COMPLAINCE_HOURS) {
|
||||||
int value1 = ( (1+start.daysTo(end)) - p_profile->countCompliantDays(type, start, end ) );
|
int daysUsed = p_profile->countDays(type, start, end);
|
||||||
|
int value1 = ( daysUsed - p_profile->countCompliantDays(type, start, end ) );
|
||||||
|
if (value1<0) value1 =0;
|
||||||
value = QString("%1 ").arg(value1);
|
value = QString("%1 ").arg(value1);
|
||||||
//value += QString(" / %1").arg(double(100*value1)/double(1+start.daysTo(end)));
|
//value += QString(" / %1").arg(double(100*value1)/double(1+start.daysTo(end)));
|
||||||
} else if (calc == SC_HOURS) {
|
} else if (calc == SC_HOURS) {
|
||||||
if (days==0) { value = QString("0"); } else {
|
if (days==0) { value = QString("0"); } else {
|
||||||
value = QString("%1").arg(formatTime(p_profile->calcHours(type, start, end) / days));
|
value = QString("%1").arg(formatTime(p_profile->calcHours(type, start, end) / days));
|
||||||
}
|
}
|
||||||
} else if (calc == SC_COMPLIANCE) {
|
} else if (calc == SC_TOTAL_DAYS_PERCENT) {
|
||||||
float c = p_profile->countCompliantDays(type, start, end );
|
float c = p_profile->countCompliantDays(type, start, end );
|
||||||
// float p = (100.0 / days) * c;
|
int days = 1+start.daysTo(end);
|
||||||
float realDays = qAbs(start.daysTo(end)) + 1;
|
if (days) {
|
||||||
float p = (100.0 *c / realDays) ;
|
float p = (100.0 *c / (float)days) ;
|
||||||
value = QString("%1%").arg(p, 0, 'f', 2);
|
value = QString("%1%").arg(p, 0, 'f', 2);
|
||||||
} else if (calc == SC_COMPLIANCE_DAYS) {
|
} else {
|
||||||
|
value = QString("-");
|
||||||
|
}
|
||||||
|
} else if (calc == SC_DAYS_GE_COMPLIANCE_HOURS) {
|
||||||
int value1 = p_profile->countCompliantDays(type, start, end );
|
int value1 = p_profile->countCompliantDays(type, start, end );
|
||||||
value = QString("%1 ").arg(value1);
|
value = QString("%1 ").arg(value1);
|
||||||
} else if (calc == SC_DAYS) {
|
} else if (calc == SC_DAYS) {
|
||||||
@ -2058,7 +2058,7 @@ QString StatisticsRow::value(QDate start, QDate end)
|
|||||||
value = fmt.arg(val, 0, 'f', decimals);
|
value = fmt.arg(val, 0, 'f', decimals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (value.contains("nan",Qt::CaseInsensitive) ) value='-';
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ public:
|
|||||||
|
|
||||||
//! \brief Type of calculation on one statistics row
|
//! \brief Type of calculation on one statistics row
|
||||||
enum StatCalcType {
|
enum StatCalcType {
|
||||||
SC_UNDEFINED=0, SC_COLUMNHEADERS, SC_HEADING, SC_SUBHEADING, SC_MEDIAN, SC_AVG, SC_WAVG, SC_90P, SC_MIN, SC_MAX, SC_CPH, SC_SPH, SC_AHI_RDI , SC_HOURS, SC_COMPLIANCE, SC_DAYS, SC_ABOVE, SC_BELOW , SC_WARNING , SC_MESSAGE ,
|
SC_UNDEFINED=0, SC_COLUMNHEADERS, SC_HEADING, SC_SUBHEADING, SC_MEDIAN, SC_AVG, SC_WAVG, SC_90P, SC_MIN, SC_MAX, SC_CPH, SC_SPH, SC_AHI_RDI , SC_HOURS, SC_TOTAL_DAYS_PERCENT, SC_DAYS, SC_ABOVE, SC_BELOW , SC_WARNING , SC_MESSAGE ,
|
||||||
SC_SELECTED_DAYS , SC_DAYS_W_DATA , SC_DAYS_WO_DATA , SC_COMPLIANCE_DAYS , SC_USED_DAY_COMPLIANCE_PERCENT , SC_NON_COMPLIANCE_DAYS , SC_MEDIAN_HOURS , SC_MEDIAN_AHI , SC_AHI_ONLY
|
SC_TOTAL_DAYS , SC_DAYS_W_DATA , SC_DAYS_WO_DATA , SC_DAYS_GE_COMPLIANCE_HOURS , SC_USED_DAY_PERCENT , SC_DAYS_LT_COMPLAINCE_HOURS , SC_MEDIAN_HOURS , SC_MEDIAN_AHI , SC_AHI_ONLY
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \struct StatisticsRow
|
/*! \struct StatisticsRow
|
||||||
@ -118,7 +118,7 @@ struct StatisticsRow {
|
|||||||
} else if (calc.compare("hours", Qt::CaseInsensitive)==0) {
|
} else if (calc.compare("hours", Qt::CaseInsensitive)==0) {
|
||||||
return SC_HOURS;
|
return SC_HOURS;
|
||||||
} else if (calc.compare("compliance", Qt::CaseInsensitive)==0) {
|
} else if (calc.compare("compliance", Qt::CaseInsensitive)==0) {
|
||||||
return SC_COMPLIANCE;
|
return SC_TOTAL_DAYS_PERCENT;
|
||||||
} else if (calc.compare("days", Qt::CaseInsensitive)==0) {
|
} else if (calc.compare("days", Qt::CaseInsensitive)==0) {
|
||||||
return SC_DAYS;
|
return SC_DAYS;
|
||||||
} else if (calc.compare("heading", Qt::CaseInsensitive)==0) {
|
} else if (calc.compare("heading", Qt::CaseInsensitive)==0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user