11'use strict' ;
22
3+ var consts = require ( '../constants' ) ;
4+
35var dailystats = {
46 name : 'dailystats'
57 , label : 'Daily Stats'
@@ -62,6 +64,8 @@ dailystats.report = function report_dailystats (datastorage, sorteddaystoshow, o
6264 $ ( '<th>' + translate ( '25%' ) + '</th>' ) . appendTo ( thead ) ;
6365 $ ( '<th>' + translate ( 'Median' ) + '</th>' ) . appendTo ( thead ) ;
6466 $ ( '<th>' + translate ( '75%' ) + '</th>' ) . appendTo ( thead ) ;
67+ $ ( '<th>' + translate ( 'A1c est* %<sub>DCCT</sub>' ) + '</th>' ) . appendTo ( thead ) ;
68+ $ ( '<th>' + translate ( 'A1c est* <sub>IFCC</sub>' ) + '</th>' ) . appendTo ( thead ) ;
6569 thead . appendTo ( table ) ;
6670
6771 sorteddaystoshow . forEach ( function ( day ) {
@@ -104,6 +108,8 @@ dailystats.report = function report_dailystats (datastorage, sorteddaystoshow, o
104108 , highs : 0
105109 } ) ;
106110 var average = sum / daysRecords . length ;
111+ var averageA1cDCCT = ( average * consts . MMOL_TO_MGDL + 46.7 ) / 28.7 ;
112+ var averageA1cIFCC = ( ( average * consts . MMOL_TO_MGDL + 46.7 ) / 28.7 - 2.15 ) * 10.929 ;
107113
108114 var bgValues = daysRecords . map ( function ( r ) { return r . sgv ; } ) ;
109115 $ ( '<td><div id="dailystat-chart-' + day . toString ( ) + '" class="inlinepiechart"></div></td>' ) . appendTo ( tr ) ;
@@ -120,6 +126,8 @@ dailystats.report = function report_dailystats (datastorage, sorteddaystoshow, o
120126 $ ( '<td class="tdborder">' + ss . quantile ( bgValues , 0.25 ) . toFixed ( 1 ) + '</td>' ) . appendTo ( tr ) ;
121127 $ ( '<td class="tdborder">' + ss . quantile ( bgValues , 0.5 ) . toFixed ( 1 ) + '</td>' ) . appendTo ( tr ) ;
122128 $ ( '<td class="tdborder">' + ss . quantile ( bgValues , 0.75 ) . toFixed ( 1 ) + '</td>' ) . appendTo ( tr ) ;
129+ $ ( '<td class="tdborder">' + averageA1cDCCT . toFixed ( 1 ) + '%</td>' ) . appendTo ( tr ) ;
130+ $ ( '<td class="tdborder">' + averageA1cIFCC . toFixed ( 0 ) + '</td>' ) . appendTo ( tr ) ;
123131
124132 table . append ( tr ) ;
125133 var inrange = [
0 commit comments