Version 1 of Basic_RS V2 in TCL as partial Basic language interpreter

Updated 2020-09-17 20:08:02 by gold

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


Title: Demo for TCL table format V2

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:


  • 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>.





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
        }
        table_format_out 90
        comma_delimit_format 90
        

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