LXGLUC.WK1 version 1.1 

Lotus 1-2-3 worksheet for 
Diabetes Data Management

(c) 2002 by Daniel Hertrich http://www.daniel-hertrich.de/lxgluc

................................................................

CONTENTS:
~~~~~~~~~

HISTORY

DISCLAIMER

WHAT THIS WORKSHEET DOES

STRUCTURE OF THE WORKSHEET

USAGE GUIDE
   Import data from LXGLUC.wk1 v1.0 (Alt-I) (NEW!)
   Installation:
   Open the worksheet and first setup
   Diary data entry
   Save changes and quit (Alt-Q)
   Manual timestamp for Diary (Alt-T and Alt-P)
   Erase diary and start new one (Alt-X)
   Longterm part data entry (Alt-T and Alt-L)
   Enter the basal insulin rate (Alt-B)
   Analyze data (ALt-A) 
   Show graphs (Alt-G)
   Usage of the statistical data (NEW!)

THE MACROS
   ALT-T:
   ALT-Q:
   ALT-S:
   ALT-B:
   ALT-A:
   ALT-G:
   ALT-F:
   ALT-X:
   ALT-I: (NEW!)
   ALT-O: (NEW!)

TROUBLESHOOTING
   Worksheet Ranges:
   Different Language versions:
   A cell shows ****** or data in an unusual format:
   A graph looks stange, totally wrong scaling, **** as a label...
   Any other problems or bugs?

TODO

................................................................

HISTORY:
~~~~~~~~

v1.0 released 05/19/02:
     First release, some functions not yet implemented,
     
v1.1 released 05/30/02 
     * Much improved Standard Day graph (now 24 bars, each for one hour
       of the day, instead of 4 ranges, additionally amount of
       measurements (which the value is calculated from) on top of the
       bars!
     * Improved Standard week graph (amount of measurements on top of
       bar)
     * Analysis macro now writes the date of its execution into
       cell Q4 and graphs use that date in the title, so it is now
       obvious how recent the data is from which a graph is created.
     * Basal Rate graph now uses Basal Rate date in title
     * Usage guide (LXGLUC.TXT) partially rewritten. Please read it!
       (Especially advice added how to use data analysis to improve
       the therapy)
     * macro \I added to import old v1.0 data.
     * macro \O added to sort the diary
     * minor macro enhancements
       
................................................................

DISCLAIMER:
~~~~~~~~~~~
I have written this worksheet mainly for my own usage, but I decided to
release it to the public domain, because I think it could be of use for
other people.
The goal of LXGLUC is to improve the Diabetes therapy to avoid too high
and too low blood sugars and thus to avoid dangerous situations and
long-termed damages of your nerves.
Of course it depends entirely on YOU how effective LXGLUC can help you.
I don't guarantee any success, nor am I responsible to any healthy or
whatever problems which can appear as a result of using LXGLUC.
LXGLUC.wk1 may contain errors, I don't guarantee that it is error-free.

................................................................


WHAT THIS WORKSHEET DOES:
~~~~~~~~~~~~~~~~~~~~~~~~~
This worksheet lets you track your diabetes data, such as measured 
blood sugar, HbA1(c) values and so on and creates graphs from that data.

It also analyzes the data in several ways and creates graphs for 
sugar averages over a day and over a week, so you have an overview 
over when your sugar is usually too low / too high and can use this
overview to adapt your therapy.

You can use it for different forms of diabetes therapy, maybe all; I
don't know too much about therapy with tablets, so I don't know if this
worksheet is useful for that form of therapy. Maybe you can simply
replace the Insulin dosis values with tablets dosis values?

This worksheet has been tested on Lotus 1-2-3 2.4 English version, on a
Hewlett Packard 200LX palmtop with Double Speed upgrade.
It should at least work as well on English versions of Lotus 1-2-3
which are built into the ROM of the HP 100/200LX palmtops, and on other
English Lotus 1-2-3 versions. However, if you want to use a version
which supports a different language, you have to adapt all macros. See
section "Troubleshooting".
I have also tested it a bit on an English HP 95LX, and it seems to
work, albeit slow, and the graphics look really ugly.


................................................................


STRUCTURE OF THE WORKSHEET:
~~~~~~~~~~~~~~~~~~~~~~~~~~~

This worksheet consists of six parts:
                                                    
A          H       O         T         Z        AL        AQ
+----------+-------+---------+---------+--------+----------+
|DIARY     |LONG-  |ANALYSIS |MACROS   |CONTROL |INSULIN-  |
|          |TERM   |         |         |        |PUMP      |
|          |       |         |         |        |          |
|          |       |         |         |        |          |
|          |       |         |         |        |          |
|          |       |         |         |        |          |
|          |       +---------+---------+        +----------+
|          |       |                   |        |          
|          |       |                   +--------+          
|          +-------+
|          |
|          |
|          |
+----------+


1. The DIARY part (Columns A..G)
   Here you can enter all the daily stuff like blood sugar,
   carbohydrates, insulin and notes about special events.
   Delete the contents every now and then (if you visiteded the 
   doctor, for example), and begin a new diary (see Macro \X).
   
2. The LONG-TERM part (Columns I..N)
   This is for data which is collected over years: Your weight, the
   HbA1 and HbA1c values and the blood pressure. 

3. The ANALYSIS part (Columns P..S)
   Here you see the values calculated from the diary and long-term part
   which represent averages of certain values. 

4. The MACROS part (Columns U..Y)
   Here the macros are stored. Column U contains the pacros, and column
   V contains a short description for each macro.
   First, the macros are listed which are directly accesable via
   Alt-[Character] key combination.
   Further down, the macros which are called by menus are listed. You
   won't have to call them manually.

5. The CONTROL part (Columns AA..AK)
   Here all control data is stored, for example annalyze criteria,
   menus and some global user-defineable settings.

6. The INSULIN PUMP part (Columns AM..AP)
   The basal rate of an insulin pump can be stored here.
   If you don't use an insulin pump, but use two different insulins,
   you can use this area for the slow (basal) insulin, then just only
   fill some of the hour cells and leave the others blank.

Parts 1 and 2 are those you will regulary enter data into.
The contents of section 3 are created automatically, so you will only
have to read here, don't write anything into it. 
And parts 4 and 5 are only inportant for the functionality of the
worksheet, you don't have to deal with anything in these parts at all,
except you have good reasons for it (an exception are the SETTINGS
fields in the CONTROL part, details follow).

................................................................


USAGE GUIDE:
~~~~~~~~~~~~

* Import data from LXGLUC.wk1 v1.0 (Alt-I) 

(Skip this section if you haven't used a previous version of LXGLUC!)

If you want to use data which you have entered into an LXGLUC.wk1 v1.0
worksheet, you can easily import that old data into the new v1.1
worksheet using the new macro \I.
First, rename the old worksheet to "lxgluc10.wk1", for example using
the REN command in DOS:
REN LXGLUC.WK1 LXGLUC10.WK1
(no other file name allowed!).
Then install the new v1.1 LXGLUC.WK1 in your working directory and load
it into Lotus 1-2-3.
Delete the time stamp, if it has been created, then execute macro \I by
pressing Alt-I. All data should be imported automatically.
The macro \I will then destroy itself (by deleting the range name \I),
so you cannot execute it anymore by accident.
Then do a data analysis to update all statistics (Alt-A) and save the
worksheet (Alt-S or Alt-Q).
Then continue with section "Open the worksheet and first setup".

* Installation:

Please copy the file LXGLUC.wk1 into your preferred Lotus 1-2-3 working
directory.
For most convenient use, I recommend to turn the "automatic macro
execution" feature of 1-2-3 on, this can be done via 
/Worksheet Global Defaults. Save the new configuration.

* Open the worksheet and first setup

Now open LXGLUC.wk1 (/File Retrieve). Or, if you use a stand-alone
version of 1-2-3, not the HP palmtop built-in version, you can start
1-2-3 that way to load the worksheet automatically:
123.exe -wLXGLUC.wk1
If you have the automatic macro execution turned on, a time stamp will
be created. For now, please delete the time stamp again. We don't need
it now. Delete both time and date.

Now execute the Formatting script (Alt-F) and choose whether you will
use mmol/l or mg/dl as your blood glucose unit. The macro will then
format all cells accordingly.
You are automatically taken to the SETTINGS range now, please adapt all
settings to your needs. Especially, adapt the blood sugar ranges. They
are predefined for mg/dl, if you use mmol/l or if you want to define
different ranges, you will have to enter other values here.
The hour ranges for the standard day analysis can be kept as they are
for now.

Now save and exit (use macro Alt-Q for that, if you want), and restart
1-2-3 with LXGLUC.wk1. 

This setup procedure has only to be done once, 


* Diary data entry

Macro \0, which is exectued automatically on startup, will create a new
time stamp and take you to the "Gluc" field, where you can enter your 
current blood sugar value.
Jumping into cells E, F and G, you can enter more data: If you injected
insulin (Bolus), enter the amount, if you eat something, enter the amount 
of carbohydrates, if something special happened (sports, a disease,
whatever can influence the blood sugar), enter it as a note in col. G.
The diary part can be filled down to row 1000, below row 1000, no
formatting of the cells is done and no analysis or graphs will work.


* Save changes and quit (Alt-Q)

Now you can save the changes and quit 1-2-3. For this purpose the macro
\Q exists. Press Alt-Q and LXGLUC.wk1 is saved and 1-2-3- is terminated.
Alt-Q additionally recalculates column A, which shows exclamation marks
in rows where you have entered a blood sugar which is not in the goal
range, so they catch your attention.

This was the usual diary data entry cycle, you see, it needs only very
few keystrokes.


* Manual timestamp for Diary (Alt-T and Alt-P)

Now start 1-2-3 again loading the worksheet. A new time stamp is
created. Say, you don't want to use the timestamp. No problem. Simply
delete the two new cell contents.

Say, you want to enter a value from one hour ago, when you didn't have
your computer at hand. Press Alt-T. This invokes Macro \T, which creates
a time stamp. A menu is shown, where you can choose, if you want to use
the current time for the time stamp or a custom time and if you want
the time stamp to be used for the Diary or the Longterm part.
If you chose "DIARY NOW", a time stamp would be created with the 
current time. But choose "DIARY OTHER". This takes you to a worksheet area, 
where you can conveniently enter your own time values, the current 
time is set there as default, so you only have to change values which 
are different. So, go to the hour value and enter the number which 
represents one hour ago. Leave everthing else as it is and follow the 
instructions: Press Alt-P. This creates the time stamp in the diary with 
your new values. Now enter the sugar value of that time and maybe other 
data.

Alt-Q saves and exits.
You can instead use Alt-S, which does the same as Alt-Q, except that it
doesn't quit 1-2-3.


* Erase diary and start new one (Alt-X)

You may want to start a new diary either if the old one gets too long
(max. data entry down to row 1000 is allowed!) or if you begin a new
range of time to observe your blood sugar, e.g. after visiting the
doctor and having presented him the old diary analysis.

To do so, press Alt-X.
This will export the current diary to another file (only the diary, not
all thhe other parts of the worksheet!). Choose a file name of a file
which doesn't exist yet. If you accidentally enter a file name which
exists already, the original file is backed up (with extension .bak),
but you won't be notified of that! So take care!
Then you will be asked to confirm the deletion of the current diary.


* Longterm part data entry (Alt-T and Alt-L)

For longterm data like your weight, the HbA1 and HbA1c (Hemoglobin
values, also called long-term blood sugar) and your blood pressure, 
use the second part of the worksheet, columns I..N.
Here also time stamps are used, To create one, press ALt-T again. 
In the menu choose either LONGTERM TODAY or LONGTERM OTHER, dependant 
on when the data has been measured which you want to enter. 
If you use LONGTERM TODAY, a time stamp with today's date is created 
immediately. If you choose LONGTERM OTHER, you are again taken to 
another work sheet area for easy data entry and asked to press 
Alt-L (not Alt-P this time!) to insert the modified time stamp.
The cursor is then moved right and you can enter your weight,
HbA1(c) and blood pressure data of that date.

The Long-term part can only be filled down to row 300. That should be
sufficient for many years of values.


* Enter the basal insulin rate (Alt-B)

If you use any kind of basal insulin, either a slow insulin which you
inject once or twice per day or if you have an insulin pump, you can
enter your basal insulin rate into the INSULIN PUMP basal rate field.
Press Alt-B and choose "NEW" from the menu. You will be taken to the
Basal Rate field, if there was an old basal rate, it is copied one
column to the right for later reference, you can now enter your current
basal rate hour by hour. If you use a slow insulin and not a pump,
enter only the amounts of slow insulin for the hours you really inject
it. Set all other values to zero.
If you are finished, Press Alt-B once more, and choose "RECALC".
This recalculates the sum of the current basal rate as well as column
AO, which shows the differences between the old and the new basal rate. 
By the way: If you enter a new basal rate, consider starting a new
diary (Alt-X), because if you use the "Standard Day" analysis (see 
below) to regulary adapt your basal rate to the blood sugar course, 
you probably don't want any sugar value to have effect on the standard 
day analysis, which are taken before the basal rate modification.


* Analyze data (ALt-A)

There are several statistical values created from the data in the diary
and long-term parts. They are not created automatically on every data
entry, because that would be too slow and thus very inconvenient.
Instead, to create the statistics, press Alt-A. You can do that whenever
you want, but note that it can take several minutes, depending on the
machine you run 1-2-3 on! On my double-speed 200LX, it takes for an
almost empty worksheet about 1 minute.

Once the analyzing macro is finished, you will be taken to part
ANALYSIS, where you can find the results of the data analysis.
"Last run" is filled with the current date, so you always see when you
which holds the
recalculated the analysis the last time. This date is also shown in
the titles of the graphs which are created from the results of the data
analysis.

For an explanation of the data you find there, please reat section
"Usage of the statistical data"!



* Show graphs (Alt-G)

These statistical values as well as the diary, long-term and
basal rate data can be viewed as graphs. To choose a graph for viewing, 
press Alt-G. A menu with all avaiable predefined graphs will be shown. 
Select one and press enter. The graph will be shown.
You can get back to spreadsheet mode by pressing any key.
Alt-G lets you then choose a new graph.

Don't forget to analyze the data *before* you view a graph which uses
values from the "Data analysis" part. Press Alt-A for that purpose,
then Alt-G to choose the graph.
The GLUCOSE, WEIGHT, HBA1, BLOODPRESSURE and BASALRATE graphs can be 
viewed without a new data analysis, since they are simply created 
from the entered data in the diary and long-term parts.

For further processing of the graphs you have several options:

You can export a graph using /Graph Save. This will produce a Lotus
PIC file, which can be converted (even on the palmtop) to 
PostScript using the little program LPIC2PS, which is available on
http://www.palmtop.net/cgi-bin/search.pl?Query=lpic2ps
You can then send the PS file to a PostScript capable printer to print
the graph.

Or you can use the PGraph (PrintGraph) component of Lotus 1-2-3, 
which is delivered with 1-2-3 version 2.4 (not included into the
palmtop ROM). This lets you even print several graphs on one sheet of
paper. Works well on the palmtop, too, but printing graphics over the
serial port is slow.

Another way may be to use the PrtScr key directly from the graph screen
in Lotus 1-2-3, for this purpose the TSR graphics.com must be loaded,
which is part of MS-DOS, but also not included into the palmtop ROM.

Or you can use a screen capture program like CAPLX
http://www.palmtop.net/cgi-bin/search.pl?Query=caplx
to capture the screen when it displays a graph. THe resulting picture
is saved as PCX and can then be firther processed, printed, whatever.

Another option my be to use the freely available MS Word 5.5 for DOS, 
which also works on the palmtop, to import the Lotus PIC files and 
arrange them in a Word document for later printing:
http://www.palmtop.net/cgi-bin/search.pl?Query=word55



* Usage of the statistical data

This section gives you a few ideas about how you can use the statistics
to improve your therapy.

The mentioned statistical values can be found in the ANALYSIS part of
the worksheet (see section "Data analysis") and some of them as
graphs (see section "Show graphs").

Gluc Avg: 
Average blood sugar from the whole diary.
This value is hopefully in the normal range! 

Avg Bol:Carb ratio: 
Ratio of bolus insulin units to carbohydrate units; average calculated 
from the whole diary. Represented as X:1.
This is not yet implemented (NYI). If you know how that can be 
calculated, please let me know!

Test per day:
Average amount of glucose tests per day. The higher, the better.
Also NYI.

Bolus insulin per day:
Average amount of units of bolus insulin per day. Also NYI.

Basal insulin per day:
The sum of the daily Basal rate (see section "Enter the basal 
insulin rate").

Total insulin per day:
Sum of Bolus and Basal insulin per day. Not yet correct, because Bolus
per day is missing. 

Weight, HbA1, HbA1c Averages, 
calculated from the longterm part.


Standard Day (graph STANDARDDAY):
These are probably the most important statistics.
The "standard day are glucose averages for each hour of the day.
They are calculated from the diary by building the average of 
all blood sugar values which are measured within the respective hour,
independent of the day.
How many values are used to calculate one value is shown on the right
in the column "Measurem.p.val" (=measurements per value).
The more measurements per value, the more reliable is the average
value.
In the graph you see the amount of the "measurem.p.val" directly above
each blood sugar bar.
The standard day gives you an overview over your average blood sugar 
course during the day. You can use this to easily adapt your basal 
rate for example. And you can easily see in the graph at which times
of the day you should increase your measurements frequency to get
more detailed insight into the daily blood sugar course.
Your goal should be a course as flat as possible and in the normal
blood sugar range.


Standard Week (graph STANDARDWEEK):
One average value for every day is calculated here. E.g. for the Monday
value, all gluc values from the diary which are entered on any Monday
are used. That way you can detect e.g. if you take care of your
diabetes during the busy week as well as on the weekend, when you have
more time to measure blood sugar.
Here you also see the amount of measurements per value directly above
the respective bars. Same as for the standard day: Try to reach a flat
course in the normal range!


Regarding the other graphs (weight, HbA1 etc.) I'm sure you know what
they are saying. 


NOTE that if one or more of the statistical values show "ERR" instead
of a value, there is not enough source data to calculate the
value. For example, if you don't have any blood sugar value in your
diary entered on a Sunday, the Standard week Sundey value will show
"ERR".


................................................................


THE MACROS:
~~~~~~~~~~~

Although all macros have been described above, I'll give you a short
overview over the macros here for reference.
Only the macros which are for direct calling are mentioned here, not
all the macros which are only automatically called by menus or other
macros.

* ALT-T:

Add a time stamp, either to the end of the diary or to the end of the
long-term part. You canchoose if you want to use the current time/date
or another one.

* ALT-Q:

Quit LXGLUC.wk1. The macro does a recalculation of column A, then saves
the worksheet and exits.

* ALT-S:

Same as ALT-Q, but doesn't quit.

* ALT-B:

Basal rate operations. You can create a new basal rate, copying the
current one into the "old basal rate" area, and you can recalculate the
basal rate sum and differences.

* ALT-A:

Analyze data. This does a total recalculation of the worksheet. Can
take a long time, several minutes, dependant on the machine you run
1-2-3 on. At the end you will hear a beep and you will be taken to the
ANALYSIS part of the worksheet.
The date which is current while Alt-A runs is written into the first
line in the ANALYSIS part, so you see when Alt-A has been executed for
the last time.

* ALT-G:

Lets you choose a graph for viewing

* ALT-F:

Starts reformatting of the worksheet. You can choose if you use mmol/l
or mg/dl as the unit for blood glucose, then all cells holding values
are reformatted automatically.

* ALT-X:

Exports current diary into another file (take care to use a file name
which is not in use yet, otherwise you will overwrite the original file
with that name, however, the original file will be backed up as .bak,
but wou won't be notified!) and erases current diary to let you start a
new one.


* ALT-I:

Imports data from a v1.0 worksheet and the destroys itself by deleting
the range name "\I". See section "Importing data..."


* ALT-O:

Sorts the diary.
Note that this only works if the diary doesn't contain any empty line!
The diary data MUST reach from B5..Gsomething, otherwise only a part of
the diary will be sorted.
This sorting algorithm may become important in future versions.
In this version it actually isn't important to sort the data.

................................................................


TROUBLESHOOTING:
~~~~~~~~~~~~~~~~

* Worksheet Ranges:

The worksheet is prepared to take data down to row 1000 in the diary and
down to row 300 in the long-term part, if you need to enter more data, 
you will have to format all date / time columns further below row 1000 
and you will need to redefine the ranges for the graphs and the macros.
This may be a lot of work, so rather consider deleting some data or
start a new LXGLUC.wk1 worksheet.
Same goes for the long-term part below row 300.

* Different Language versions:

If you have a non-English version of Lotus 1-2-3, you will need to
adapt the macros to your language. Note that the functions don't 
have to be adapted, but the function names in the macros and
the menu item selections in the macros have to be adapted. Otherwise
the macros won't work.
Note: You have to unprotect the worksheet or at least the cells which 
you want to modify. 

* A cell shows ****** or data in an unusual format:

You have probably destroyed the formatting information for that cell.
To reformat all diary and longterm cells, use macro \F. Press Alt-F and
LXGLUC.wk1 will restore the proper formatting. However, if you have
modified some formatting for any reason, that modification will be
lost.

* A graph looks stange, totally wrong scaling, **** as a label...

You have probably entered wrong data. Please look into the respective
part of the worksheet if you accidentally entered some non-relevant
data, such as a character somewhere in the time stamps columns or so.

* Any other problems or bugs?

Please notify me: http://www.daniel-hertrich.de/contact

................................................................


TODO:
~~~~~

* implement NYI (not yet implemented) functions

* Convenient graph printing feature (conversion necessary, maybe via 
batch file...)

* Diary List exporting and printing feature (maybe using "WRITE" 
macro command, thus exporting to a text file)

* Anything else? Please write suggestions to me, my email address can
be found here: http://www.daniel-hertrich.de/contact
Recent info about LXGLUC.wk1:
http://www.daniel-hertrich.de/lxgluc
