HgA1c Approximates Average Blood Glucose in Console Example Demo for TCL table format V2

HbA1c Approximates Average Blood Glucose in Console Example Demo for TCL table format V2

This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, gold 20Aug2020


Preface

gold 20aug2020 Here are some calculations for converting HbA1c measurement to average blood glucose mg/dl over a 3 month period. Console program outputs data as table in TCL table format and comma delimited spreadsheet.


Introduction

Here are TCL calculations on the equation converting HbA1c to Average Blood Glucose mg/dl. Console program example demo was written on Windows 10, working under TCL version 8.6 20aug2020. Each HbA1c reading usually from limits of 4.0 to 11 has an equivalent average blood glucose over a 3 month period. ADA formula from Diabetes Care, 2012. As peg point, 5 HbA1c units converts to 100 mg/dl abbreviation for milligrams per deciliter. Note. This Diabetes Care field is rapidly changing, one needs to check in at ADA professional.diabetes.org for the latest up to date info.



References:


  • Wikipedia search engine < diabetes >
  • Wikipedia search engine < Richard K. Bernstein >
  • Wikipedia search engine < Programming Examples >
  • Google search engine < vaporware >
  • Google search engine < Blood Glucose >
  • Book >> The Diabetes Code: Prevent and Reverse Type 2 Diabetes Naturally
  • One Liners Programs Pie in the Sky
  • One Liners
  • One Liners Programs Compendium [L1 ]
  • WIKI BOOKS, Programming_Examples pdf
  • WIKI BOOKS, Tcl_Programming_Introduction pdf
  • google search engine < HgA1c to Average Blood Glucose>
  • How Do You Calculate Your A1c? diabetestalk.net
  • BLOOD SUGAR HOW DO YOU CALCULATE YOUR A1C? DEC 5, 2017
  • table
  • The Diabetes Code: Prevent and Reverse Type 2 Diabetes Naturally
  • 2018 · 4.88 MB by Dr Jason Fung
  • Dr. Bernstein's Diabetes Solution: The Complete Guide to Achieving Normal Blood Sugars
  • 2007 by Richard K. Bernstein
  • care.diabetesjournals.org 2012
  • Measurement of Hemoglobin A1c , Diabetes Care
  • Measurement of Hemoglobin A1c
  • A new twist on the path to harmony
  • David B. Sacks, December 2012, full pdf available from ADA
  • Translating the A1C Assay pdf, Richard Kahn and Vivian Fonseca, Diabetes Care, 2008
  • see ADA professional.diabetes.org diapro glucose_calc for up to date
  • see ADA professional.diabetes.org for up to date

ADA Quotes. Therefore, to change glucose from mg/dL to mmol/L, one divides by 18.016 (usually rounded off to 18), and values are multiplied by 18 to switch from mmol/L to mg/dL. For example, 126 mg/dL is equivalent to 7.0 mmol/L, and 40 mg/dL is 2.2 mmol/L.


  • Developing an HbA1c-Based Equation to Estimate Blood Glucose in Maintenance Hemodialysis Patients
  • Junichi Hoshino, MD, MPH1,2,3, Miklos Z. Molnar, MD, PHD1,
  • September 2020

ADA Quotes. Developing an HbA1c-Based Equation to Estimate Blood Glucose in Maintenance Hemodialysis Patients,2013. Some equations showing a good correlation between HbA1c and average BG (AG) levels.The Diabetes Control and Complications Trial DCCT formula is Average Blood Glucose = expr { 35.6 * HbA1c − 77.3} < in milligrams per deciliter>.



Screenshots Section


figure 1. Screenshot, HgA1c_Average_Blood_Glucose





HgA1c_Average_Blood_Glucose



Appendix TCL programs and scripts

* Pretty Print Version


        ;# pretty print from autoindent and ased editor
        ;# Convert HbA1c to Average Blood Glucose mg/dl V2
        ;# Console program example demo
        ;# written on Windows 10 on  TCL
        ;# working under TCL version 8.6
        ;# gold on TCL Club , 20aug2020
        ;# Each HbA1c reading usually from
        ;# limits of 4.0 to 11
        ;# has an equivalent average blood glucose
        ;# over a 3 month period.
        ;# formula from Diabetes Care, 2012.
        ;# Roughly 5 HbA1c converts to 100
        ;# mg/dl abbrev. for milligrams per deciliter
        ;# mmol/L abbrev. for milligrams per Liter
        package require Tk
        package require math::numtheory
        package require math::constants
        package require math::trig
        package require math
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
        set tclprecision 17
        console show
        ;# following dresses up console output to easy eye
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        set tclprecision 17
        ;# hbA1c_convert_to_average_blood_glucose mg/dl  HbA1c
        proc a1c hbA1c {  expr { 35.6*$hbA1c -77.3} }
        ;# convert mg/dl to mmol/L average blood glucose
        ;# some papers round off 18.016 to mgdl/18.
        proc mgdl_to_mmoll mgdl {  expr { $mgdl/18.0 } }
        ;# convert  mmol/L to mg/dl average blood glucose
        proc mmoll_to_mgdl mmoll {  expr { $mmoll*18.0 } }
        ;# proc precisionx used to round off floating point numbers
        proc precisionx {precision float}  {
            ;#  tcl:wiki:Floating-point formatting, <AM>
            ;# select numbers only, not used on every number.
            set x [ expr {round( 10 ** $precision * $float) / (10.0 ** $precision)} ]
            ;#  rounded or clipped to nearest 5ird significant figure
            set x [ format "%#.5g" $x ]
            return $x
        }
        proc table_format_out  n {
            set sum 0
            ;# initial hbA1c level
            set count 4.0
            puts "%| table|  | printed in|TCL format |% "
            puts "%| HbA1c units | mg/dl units |conv. mmol/L units  |comment, if any|% "
            ;# adapted proc from <RS>
            ;# printout in TCL WIKI format table
            for { set i 1 } { $i <= $n } { incr i } {
                set count [+ $count .1]
                set mgdl5 [ precisionx 3 [ a1c $count ]]
                set mmoll  [ precisionx 3 [mgdl_to_mmoll [ a1c $count ]]]
                puts "&| [ precisionx 3  $count ] | $mgdl5  | $mmoll | |&"
                incr sum $i
            }
            return $sum
        }
        proc comma_delimit_format n {
            set sum 0
            ;# initial hbA1c level
            set count 4.0
            puts "table, ,  printed in,  TCL format  "
            puts "HbA1c units , mg/dl units , conv. mmol/L units, comment, if any "
            ;# adapted proc from <RS>
            ;# printout in TCL  comma delimited format
            for { set i 1 } { $i <= $n } { incr i } {
                set count [+ $count .1]
                set mgdl5 [ precisionx 3 [ a1c $count ]]
                set mmoll  [ precisionx 3 [mgdl_to_mmoll [ a1c $count ]]]
                puts "[ precisionx 3  $count ] , $mgdl5, $mmoll ,  ,"
                incr sum $i
            }
            return $sum
        }
        puts "  Console wrapper for solution proc"
        puts "  ***************************"
        puts "  ***************************"   
        table_format_out 90
        comma_delimit_format 90
        ;# end of working deck
        ;# add cosmetics below to bottom of file 
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        console eval {wm title . " Report for Homa_IR_2  "}
        console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}       

Conversion unit formulas in one line TCL procs


    ;# conversion unit formulas in one line TCL procs
    ;# HOMA-IR standing for Homeostatic Model Assessment of Insulin Resistance 
    ;# HOMA_IR = expr { $insulin * $glucose * $scale_factor}
    ;# fasting blood insulin in units  uIU/mL
    ;# fasting blood glucose in units mg/dL
    proc HOMA_IR2 { insulin  glucose }  {
            set scale_factor [ expr { 1. / 405. } ]
            return [expr { $insulin * $glucose * $scale_factor}]}
    ;# HOMA-IR calculations here requires U.S. standard units.
    ;# European SI units as best understood. 
    ;# To convert component terms of  HOMA-IR ( $insulin & $glucose)
    ;# from international S.I. units:
    ;# Insulin: pmol/L to uIU/mL, divide by (÷) 6
    ;# Glucose: mmol/L to mg/dL, multiply by (x) 18
    ;# hbA1c_convert_to_average_blood_glucose mg/dl  HbA1c
    ;# HbA1c test is a simple blood test that measures your 
    ;# average blood sugar levels over the past 3 months.
    ;# As a peg point, 5 HbA1c units converts to 100 mg/dl,
    ;# mg/dl is abbreviation for milligrams per deciliter.
    proc a1c hbA1c {  expr { 35.6*$hbA1c -77.3} }
    ;# convert mg/dl to mmol/L average blood glucose
    ;#  European SI units conversion on blood glucose
    ;# some papers round off 18.016 to mgdl/18.
    proc mgdl_to_mmoll mgdl {  expr { $mgdl/18.0 } }
    ;# convert  mmol/L to mg/dl average blood glucose
    proc mmoll_to_mgdl mmoll {  expr { $mmoll*18.0 } }
    ;# formula QUICKI_index insulin resistance = 1/(log(insulin) + log(glucose)), decimal logs 
    proc QUICKI_INDEX_IR { insulin  glucose } { return [ expr { 1./(log10($insulin) + log10($glucose))} ] }
    ;# Usage set answer [  QUICKI_INDEX_IR 4. 100. ] ;# eval 0.38


Hidden Comments Section

Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Thanks, gold 12Aug2020

x