summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/diadia/diadia.dtx
blob: 8ad273843e4aeca0d05d3af4e3f697c419371e54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
% \iffalse meta-comment
% !TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*readme>
The diadia package allows you to keep a diabetes diary.
Usually, this means keeping record of certain medical values
like blood sugar, blood pressure, pulse or weight. It might
also include other medical, pharmaceutical or nutritional
data (HbA1c, insulin doses, carbohydrate units). The diadia
package supports all of this plus more - simply by adding
more columns to the data file!
It is able to evaluate the data file and typesets formatted
tables and derived plots. Furthermore, it supports medication
charts and info boxes.

Supported languages: english, german
Feel free to provide other translation files! ;-)

License: LPPL
%</readme>
%<*data>
date        bsl1  bsl2  bsl3  id1 id2 id3 bps bpd weight  cu  pul
2015-02-18  182   197   196   nan nan 10  120 80  102.3   12  64
2015-02-19  190   232   159   12  9   9   130 85  102.1   12  68
2015-02-20  181   217   153   14  9   9   130 85  103.5   12  72
2015-02-21  154   160   146   13  7   9   100 60  102.8   12  60
2015-02-22  186   204   152   14  9   9   120 80  102.4   12  64
2015-02-23  190   170   131   14  8   9   130 85  102.0   12  68
2015-02-24  165   128   97    14  7   6   110 75  101.7   12  64
2015-02-25  160   123   129   11  5   7   130 85  101.3   12  68
2015-02-26  151   115   128   11  nan 7   120 80  100.9   12  64
2015-02-27  141   119   130   11  4   nan 130 85  101.6   12  68
2015-02-28  142   137   143   nan nan nan 120 80  101.2   12  64
2015-03-01  134   151   128   nan nan nan nan nan nan     nan nan
2015-03-02  145   124   116   nan nan nan nan nan nan     nan nan
2015-03-03  133   130   125   nan nan nan nan nan nan     nan nan
2015-03-04  138   153   nan   nan nan nan nan nan nan     nan nan
2015-03-06  122   150   130   nan nan nan nan nan nan     nan nan
2015-03-07  nan   nan   135   nan nan nan nan nan nan     nan nan
2015-03-08  132   146   119   nan nan nan nan nan nan     nan nan
2015-03-11  144   nan   124   nan nan nan nan nan nan     nan nan
2015-03-13  131   116   nan   nan nan nan nan nan nan     nan nan
2015-03-16  119   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-19  109   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-20  107   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-21  103   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-22  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-03-23  111   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-24  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-03-25  109   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-26  115   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-28  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-03-31  90    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-02  101   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-03  105   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-04  116   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-05  118   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-06  124   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-07  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-08  111   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-09  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-10  102   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-11  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-12  104   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-13  105   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-14  105   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-15  125   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-16  102   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-17  102   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-18  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-19  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-20  119   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-21  101   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-22  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-23  93    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-24  108   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-25  114   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-26  95    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-27  110   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-28  114   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-29  104   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-30  99    nan   nan   nan nan nan nan nan nan     nan nan
%</data>
%<*feb15>
date        bsl1  bsl2  bsl3  id1 id2 id3 bps bpd weight  cu  pul
2015-02-18  182   197   196   nan nan 10  120 80  102.3   12  64
2015-02-19  190   232   159   12  9   9   130 85  102.1   12  68
2015-02-20  181   217   153   14  9   9   130 85  103.5   12  72
2015-02-21  154   160   146   13  7   9   100 60  102.8   12  60
2015-02-22  186   204   152   14  9   9   120 80  102.4   12  64
2015-02-23  190   170   131   14  8   9   130 85  102.0   12  68
2015-02-24  165   128   97    14  7   6   110 75  101.7   12  64
2015-02-25  160   123   129   11  5   7   130 85  101.3   12  68
2015-02-26  151   115   128   11  nan 7   120 80  100.9   12  64
2015-02-27  141   119   130   11  4   nan 130 85  101.6   12  68
2015-02-28  142   137   143   nan nan nan 120 80  101.2   12  64
%</feb15>
%<*mar15>
date        bsl1  bsl2  bsl3  id1 id2 id3 bps bpd weight  cu  pul
2015-03-01  134   151   128   nan nan nan nan nan nan     nan nan
2015-03-02  145   124   116   nan nan nan nan nan nan     nan nan
2015-03-03  133   130   125   nan nan nan nan nan nan     nan nan
2015-03-04  138   153   nan   nan nan nan nan nan nan     nan nan
2015-03-06  122   150   130   nan nan nan nan nan nan     nan nan
2015-03-07  nan   nan   135   nan nan nan nan nan nan     nan nan
2015-03-08  132   146   119   nan nan nan nan nan nan     nan nan
2015-03-11  144   nan   124   nan nan nan nan nan nan     nan nan
2015-03-13  131   116   nan   nan nan nan nan nan nan     nan nan
2015-03-16  119   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-19  109   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-20  107   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-21  103   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-22  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-03-23  111   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-24  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-03-25  109   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-26  115   nan   nan   nan nan nan nan nan nan     nan nan
2015-03-28  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-03-31  90    nan   nan   nan nan nan nan nan nan     nan nan
%</mar15>
%<*apr15>
date        bsl1  bsl2  bsl3  id1 id2 id3 bps bpd weight  cu  pul
2015-04-02  101   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-03  105   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-04  116   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-05  118   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-06  124   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-07  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-08  111   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-09  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-10  102   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-11  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-12  104   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-13  105   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-14  105   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-15  125   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-16  102   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-17  102   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-18  97    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-19  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-20  119   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-21  101   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-22  96    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-23  93    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-24  108   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-25  114   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-26  95    nan   nan   nan nan nan nan nan nan     nan nan
2015-04-27  110   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-28  114   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-29  104   nan   nan   nan nan nan nan nan nan     nan nan
2015-04-30  99    nan   nan   nan nan nan nan nan nan     nan nan
%</apr15>
%<*hba1c>
date        hba1c
2015-02-18  10
2015-04-23  6
%</hba1c>
%<*fallback>
\DeclareTranslationFallback{dd-BloodSugar}{Blood Sugar}%
\DeclareTranslationFallback{dd-Insulin}{Insulin}%
\DeclareTranslationFallback{dd-BloodPressure}{Blood Pressure}%
\DeclareTranslationFallback{dd-Weight}{Weight}%
\DeclareTranslationFallback{dd-MedicationChart}{Medication Chart}%
\DeclareTranslationFallback{dd-issued}{issued}%
\DeclareTranslationFallback{dd-Pharmaceutical}{Pharmaceutical}%
\DeclareTranslationFallback{dd-Morning}{Morning}%
\DeclareTranslationFallback{dd-Noon}{Noon}%
\DeclareTranslationFallback{dd-Evening}{Evening}%
\DeclareTranslationFallback{dd-Night}{Night}%
\DeclareTranslationFallback{dd-Note}{Note}%
\DeclareTranslationFallback{dd-Info}{Info}%
\DeclareTranslationFallback{dd-Date}{Date}%
\DeclareTranslationFallback{dd-BSi}{BS(1)}%
\DeclareTranslationFallback{dd-BSii}{BS(2)}%
\DeclareTranslationFallback{dd-BSiii}{BS(3)}%
\DeclareTranslationFallback{dd-IDi}{I(1)}%
\DeclareTranslationFallback{dd-IDii}{I(2)}%
\DeclareTranslationFallback{dd-IDiii}{I(3)}%
\DeclareTranslationFallback{dd-BPs}{BP(s)}%
\DeclareTranslationFallback{dd-BPd}{BP(d)}%
\DeclareTranslationFallback{dd-Weight}{Weight}%
\DeclareTranslationFallback{dd-CU}{CU}%
\DeclareTranslationFallback{dd-Pulse}{Pulse}%
\DeclareTranslationFallback{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}%
%</fallback>
%<*english>
\DeclareTranslation{English}{dd-BloodSugar}{Blood Sugar}%
\DeclareTranslation{English}{dd-Insulin}{Insulin}%
\DeclareTranslation{English}{dd-BloodPressure}{Blood Pressure}%
\DeclareTranslation{English}{dd-Weight}{Weight}%
\DeclareTranslation{English}{dd-MedicationChart}{Medication Chart}%
\DeclareTranslation{English}{dd-issued}{issued}%
\DeclareTranslation{English}{dd-Pharmaceutical}{Pharmaceutical}%
\DeclareTranslation{English}{dd-Morning}{Morning}%
\DeclareTranslation{English}{dd-Noon}{Noon}%
\DeclareTranslation{English}{dd-Evening}{Evening}%
\DeclareTranslation{English}{dd-Night}{Night}%
\DeclareTranslation{English}{dd-Note}{Note}%
\DeclareTranslation{English}{dd-Info}{Info}%
\DeclareTranslation{English}{dd-Date}{Date}%
\DeclareTranslation{English}{dd-BSi}{BS(1)}%
\DeclareTranslation{English}{dd-BSii}{BS(2)}%
\DeclareTranslation{English}{dd-BSiii}{BS(3)}%
\DeclareTranslation{English}{dd-IDi}{I(1)}%
\DeclareTranslation{English}{dd-IDii}{I(2)}%
\DeclareTranslation{English}{dd-IDiii}{I(3)}%
\DeclareTranslation{English}{dd-BPs}{BP(s)}%
\DeclareTranslation{English}{dd-BPd}{BP(d)}%
\DeclareTranslation{English}{dd-Weight}{Weight}%
\DeclareTranslation{English}{dd-CU}{CU}%
\DeclareTranslation{English}{dd-Pulse}{Pulse}%
\DeclareTranslation{English}{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}%
%</english>
%<*german>
\DeclareTranslation{German}{dd-BloodSugar}{Blutzucker}%
\DeclareTranslation{German}{dd-Insulin}{Insulin}%
\DeclareTranslation{German}{dd-BloodPressure}{Blutdruck}%
\DeclareTranslation{German}{dd-Weight}{Gewicht}%
\DeclareTranslation{German}{dd-MedicationChart}{Medikamentenplan}%
\DeclareTranslation{German}{dd-issued}{ausgestellt}%
\DeclareTranslation{German}{dd-Pharmaceutical}{Medikament}%
\DeclareTranslation{German}{dd-Morning}{morgens}%
\DeclareTranslation{German}{dd-Noon}{mittags}%
\DeclareTranslation{German}{dd-Evening}{abends}%
\DeclareTranslation{German}{dd-Night}{nachts}%
\DeclareTranslation{German}{dd-Note}{Bemerkung}%
\DeclareTranslation{German}{dd-Info}{Info}%
\DeclareTranslation{German}{dd-Date}{Datum}%
\DeclareTranslation{German}{dd-BSi}{BZ(1)}%
\DeclareTranslation{German}{dd-BSii}{BZ(2)}%
\DeclareTranslation{German}{dd-BSiii}{BZ(3)}%
\DeclareTranslation{German}{dd-IDi}{I(1)}%
\DeclareTranslation{German}{dd-IDii}{I(2)}%
\DeclareTranslation{German}{dd-IDiii}{I(3)}%
\DeclareTranslation{German}{dd-BPs}{BD(s)}%
\DeclareTranslation{German}{dd-BPd}{BD(d)}%
\DeclareTranslation{German}{dd-Weight}{Gewicht}%
\DeclareTranslation{German}{dd-CU}{BE}%
\DeclareTranslation{German}{dd-Pulse}{Puls}%
\DeclareTranslation{German}{dd-Hbaonec}{$\text{HbA}_{\text{1c}}$}%
%</german>
%<*bibfile>
@misc{bib:pgfplots,
 author               = {Dr. Christian Feuersänger},
 note                 = {\href{http://mirrors.ctan.org/graphics/pgf/contrib/pgfplots/doc/pgfplots.pdf}{http://mirrors.ctan.org/graphics/pgf/contrib/pgfplots/doc/pgfplots.pdf}},
 title                = {{Manual for Package pgfplots}},
 year                 = {2015},
 }

@misc{bib:pgfplotstable,
 author               = {Dr. Christian Feuersänger},
 note                 = {\href{http://mirrors.ctan.org/graphics/pgf/contrib/pgfplots/doc/pgfplotstable.pdf}{http://mirrors.ctan.org/graphics/pgf/contrib/pgfplots/doc/pgfplotstable.pdf}},
 title                = {{Manual for Package pgfplotstable}},
 year                 = {2015},
 }
 
@misc{bib:tcolorbox,
 author               = {Sturm, Thomas F.},
 note                 = {\href{http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf}{http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf}},
 title                = {{The tcolorbox package}},
 year                 = {2015},
 }
 
@misc{bib:multicol,
 author               = {Mittelbach, Frank},
 note                 = {\href{http://mirrors.ctan.org/macros/latex/required/tools/multicol.pdf}{http://mirrors.ctan.org/macros/latex/required/tools/multicol.pdf}},
 title                = {{An environment for multicolumn output}},
 year                 = {2014},
 }

 @misc{bib:longtable,
 author               = {Carlisle, David},
 note                 = {\href{http://mirrors.ctan.org/macros/latex/required/tools/longtable.pdf}{http://mirrors.ctan.org/macros/latex/required/tools/longtable.pdf}},
 title                = {{The \texttt{longtable} package}},
 year                 = {2014},
 }

%</bibfile>
%<*examplefile>
\documentclass[a4paper,DIV=13,parskip]{scrreprt}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[tabcolor=gray!40,tabstyle=advanced]{diadia}
\usepackage{bera}
\usepackage{marvosym}
\usepackage{hyperref}
\begin{document}
\pgfplotstableset{columns/date/.append style={date type={\day.\month.\year}}}
\pgfplotsset{xlabel=2015,
             tick label style={font=\footnotesize}}
\title{My Diabetes Diary}
\author{John Doe}
\maketitle
\centering
\chapter{Long term values}

\begin{diadiasidebyside}
\diadiatab{}{hba1c.dat}

\begin{diadiaplot}[plotstyle=hbaonec]{xmin=2015-02-01,xmax=2015-04-30}
\diadiaaddplot{}{x=date,y=hba1c}{hba1c.dat}
\end{diadiaplot}
\end{diadiasidebyside}

\chapter{February 2015}
\section{Data}
\diadiatab{font=\small}{201502.dat}

\vspace{1cm}
\begin{diadiasidebyside}
\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-02-18,xmax=2015-02-28}
\diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
\diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
\diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
\legend{morning,noon,evening}
\end{diadiaplot}

\begin{diadiaplot}[plotstyle=insulin]{xmin=2015-02-18,xmax=2015-02-27}
\diadiaaddplot{}{x=date,y=id1}{diadia.dat}
\diadiaaddplot{}{x=date,y=id2}{diadia.dat}
\diadiaaddplot{}{x=date,y=id3}{diadia.dat}
\legend{morning,noon,evening}
\end{diadiaplot}

\begin{diadiaplot}[plotstyle=bloodpressure]{xmin=2015-02-18,xmax=2015-02-27}
\diadiaaddplot{}{x=date,y=bps}{diadia.dat}
\diadiaaddplot{}{x=date,y=bpd}{diadia.dat}
\legend{systolic,diastolic}
\end{diadiaplot}

\begin{diadiaplot}[plotstyle=pulse]{xmin=2015-02-18,xmax=2015-02-27}
\diadiaaddplot{}{x=date,y=pul}{diadia.dat}
\end{diadiaplot}
\end{diadiasidebyside}

\vspace{1cm}
\begin{diadiasidebyside}
\begin{diadiaplot}[plotstyle=weight]{xmin=2015-02-18,xmax=2015-02-27}
\diadiaaddplot{ddpweightplot}{x=date,y=weight}{diadia.dat}
\end{diadiaplot}

\begin{diadiaplot}[plotstyle=cu]{xmin=2015-02-18,xmax=2015-02-27,enlargelimits=.08}
\diadiaaddplot{}{x=date,y=cu}{diadia.dat}
\end{diadiaplot}
\end{diadiasidebyside}
\section{Pharmaceuticals}
\begin{medicationchart}{}{16.02.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{1}{1}{1}{0}{}
\mcentry{Insulin}{1}{1}{1}{0}{see data}
\mcentry{Unacid 3g}{1}{0}{1}{1}{infusion 08:00, 16:00, 00:00}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\begin{medicationchart}{}{24.02.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Insulin}{1}{1}{1}{0}{see data}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\begin{medicationchart}{}{28.02.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Metformin}{2}{0}{2}{0}{}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\chapter{March 2015}
\section{Data}
\begin{diadiasidebyside}
\diadiatab{columns={date,bsl1,bsl2,bsl3}}{201503.dat}

\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-03-01,xmax=2015-03-31}
\diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
\diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
\diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
\legend{morning,noon,evening}
\end{diadiaplot}
\end{diadiasidebyside}
\section{Pharmaceuticals}
\begin{medicationchart}{}{03.03.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Januvia 100mg}{1}{0}{0}{0}{replaces Metformin due to op}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\begin{medicationchart}{}{10.03.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Januvia 100mg}{1}{0}{0}{0}{}
\mcentry{Unacid 3g}{1}{0}{1}{1}{infusion 08:00, 16:00, 00:00}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\begin{medicationchart}{}{20.03.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Unacid 3g}{1}{0}{1}{1}{infusion 08:00, 16:00, 00:00}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\begin{medicationchart}{}{30.03.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}
\chapter{April 2015}
\section{Data}
\begin{diadiasidebyside}
\diadiatab{columns={date,bsl1,bsl2,bsl3}}{201504.dat}

\begin{diadiaplot}[plotstyle=bloodsugar]{xmin=2015-04-01,xmax=2015-04-29,enlargelimits=0.25}
\annotation[text width=1.4cm]{2015-04-06}{129}{rise after discharge}
\diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
\legend{morning}
\end{diadiaplot}
\end{diadiasidebyside}

\section{Pharmaceuticals}
\begin{medicationchart}{}{02.04.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe}{0}{0}{1}{0}{}
\end{medicationchart}

\begin{medicationchart}{}{07.04.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe Novartis}{0}{0}{1}{0}{}
\mcentry{Sultamicillin-ratiopharm 375mg}{1}{0}{1}{0}{}
\end{medicationchart}

\begin{medicationchart}{}{16.04.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe Novartis}{0}{0}{1}{0}{}
\mcentry{Amoclav 875mg + 125mg (Amoxicillin, Clavulansäure) Hexal}{1}{0}{1}{0}{}
\end{medicationchart}

\begin{medicationchart}{}{20.04.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{ASS protect 100mg}{0}{1}{0}{0}{}
\mcentry{Amoclav 875mg + 125mg (Amoxicillin, Clavulansäure) Hexal}{1}{0}{1}{0}{}
\end{medicationchart}

\section{Misc.}

\infobox{width=8cm}{22.04.2015}{
Podiatrist appointment:

\bigskip
22.04.2015 11:30

\medskip
\Telefon\ 089/65831933
}
\end{document}
%</examplefile>
%<*manifest>
This work consists of the following files:

diadia.pdf
diadia.dtx
README
makefile

Files packaged in diadia.dtx:

diadia.sty
diadia-example.tex -> diadia-example.pdf
manifest.txt
diadia-fallback.trsl
diadia-english.trsl
diadia-german.trsl
diadia.dat
201502.dat
201503.dat
201504.dat
hba1c.dat
%</manifest>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble

Copyright (C) 2015 by:
Josef Kleber
<josef.kleber@gmx.de>

This file may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3 of this license
or (at your option) any later version.  The latest version of this
license is in:

   http://www.latex-project.org/lppl.txt

and version 1.3 or later is part of all distributions of LaTeX version
2003/12/01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainer of this work is Josef Kleber.

This work consists of all files listed in manifest.txt.

\endpreamble

\usedir{tex/latex/diadia}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\generate{
  \file{\jobname-fallback.trsl}{\from{\jobname.dtx}{fallback}}
}
\generate{
  \file{\jobname-english.trsl}{\from{\jobname.dtx}{english}}
}
\generate{
  \file{\jobname-german.trsl}{\from{\jobname.dtx}{german}}
}
\generate{
  \file{\jobname-example}{\from{\jobname.dtx}{examplefile}}
}
\nopreamble\nopostamble
\usedir{doc/latex/diadia}
\generate{
  \file{\jobname.dat}{\from{\jobname.dtx}{data}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{
  \file{\jobname.dat}{\from{\jobname.dtx}{data}}
}
\generate{
  \file{201502.dat}{\from{\jobname.dtx}{feb15}}
}
\generate{
  \file{201503.dat}{\from{\jobname.dtx}{mar15}}
}
\generate{
  \file{201504.dat}{\from{\jobname.dtx}{apr15}}
}
\generate{
  \file{hba1c.dat}{\from{\jobname.dtx}{hba1c}}
}
\generate{
  \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\generate{
  \file{manifest.txt}{\from{\jobname.dtx}{manifest}}
}
\generate{
  \file{\jobname.bib}{\from{\jobname.dtx}{bibfile}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*driver>
\documentclass[a4paper]{ltxdoc}%
\usepackage[english]{babel}%
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage{textcomp}%
\usepackage{lmodern}%
\usepackage{bera}%
\usepackage{microtype}%
\usepackage{marginnote}%
\usepackage[svgnames,rgb]{xcolor}%
\usepackage{listings}%
\usepackage{makeidx}
\usepackage[numbered]{hypdoc}
\usepackage{ragged2e}%
\usepackage{url}%
\usepackage{diadia}%
\usepackage{alltt}%
\usepackage{marvosym}%
\usepackage[automark,nouppercase]{scrpage2}
\usepackage{tikz}
\usetikzlibrary{calc}%
% turn off idiotic tikz error in doc generation
\makeatletter
\global\let\tikz@ensure@dollar@catcode=\relax
\makeatother
\usepackage{hyperref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\makeatletter
\setlength{\headheight}{1.1\baselineskip}%
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\hypersetup{colorlinks=true,urlcolor=NavyBlue,linkcolor=NavyBlue,citecolor=CornflowerBlue}%
\lstset{literate=%
    {Ö}{{\"O}}1
    {Ä}{{\"A}}1
    {Ü}{{\"U}}1
    {ß}{{\ss}}1
    {ü}{{\"u}}1
    {ä}{{\"a}}1
    {ö}{{\"o}}1
    {~}{{\textasciitilde}}1
}
\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
emph={}}
\renewcommand{\maketitle}%
{%
  \thispagestyle{empty}%
  \pagecolor{Ivory}%
  \begin{titlepage}%
    \begin{tikzpicture}[remember picture,overlay]%
      \node[yshift=-2cm] at (current page.north west)%
      {%
        \begin{tikzpicture}[remember picture, overlay]%
          \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle%
            (\paperwidth,2cm);%
          \draw[anchor=west,yshift=-4cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\RaggedRight\Huge\sffamily\textbf{\@title}}};%
          \draw[anchor=west,yshift=-5.5cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\huge\sffamily\textbf{\@fileversion}}};%
          \draw[anchor=west,yshift=-7.5cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\RaggedRight\huge\sffamily\textbf{\@subtitle}}};%
          \draw[anchor=west,yshift=-13.2cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\usebox\logo};%
          \draw[anchor=west,yshift=-18.5cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\huge\sffamily\textbf{\@date}}};%
          \draw[anchor=west,yshift=-20.5cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\Large\sffamily{\@authorline\\\textbf{\@author}}}};%
        \end{tikzpicture}%
      };%
      \node[yshift=0cm] at (current page.south west)%
      {%
        \begin{tikzpicture}[remember picture, overlay]%
          \draw[fill=NavyBlue,color=NavyBlue,yshift=6cm,xshift=2cm] (0,0) rectangle (0.2cm,19cm);%
          \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
          \draw[anchor=west,yshift=1cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\large\sffamily{\@refline}}};%
        \end{tikzpicture}%
      };%
    \end{tikzpicture}%
  \end{titlepage}%
  \pagecolor{white}%
}%
%
%
\newcommand*{\@tikzhead}[1]%
{%
  \begin{tikzpicture}[remember picture,overlay]%
    \node[yshift=-2cm] at (current page.north west)%
    {%
      \begin{tikzpicture}[remember picture, overlay]%
        \draw[fill=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
        \draw[anchor=west,yshift=1cm,xshift=1.5cm,color=NavyBlue] (0,0) node%
          {\parbox{15cm}{\LARGE\sffamily\textbf{\@title}}};%
        \node[anchor=east,xshift=.9\paperwidth,rectangle,%
              rounded corners=15pt,inner sep=11pt,fill=NavyBlue]%
              {\color{white}\textsc{#1}};%
      \end{tikzpicture}%
    };%
  \end{tikzpicture}%
}%
\clearscrheadings%
\ihead{\@tikzhead{\headmark}}%
\cfoot{\upshape\thepage}%
\pagestyle{scrheadings}%
%
\newcommand*{\Headline}[1]{\@mkboth{#1}{#1}}%
%
\renewcommand{\headfont}{\normalfont\mdseries\scshape}
%
\gdef\@subtitle{}%
\providecommand*{\Subtitle}[1]{\gdef\@subtitle{#1}}%
\gdef\@fileversion{}%
\providecommand*{\Fileversion}[1]{\gdef\@fileversion{#1}}%
\gdef\@author{}%
\providecommand*{\Author}[1]{\gdef\@author{#1}}%
\gdef\@authorline{Package author:}%
\providecommand*{\Authorline}[1]{\gdef\@authorline{#1}}%
\gdef\@refline{}%
\providecommand*{\Refline}[1]{\gdef\@refline{#1}}%
\gdef\and{\unskip{}, }%
\newcommand\doubledash{-\kern0.5pt-}
\def\enoteformat{\rightskip\z@ \leftskip\z@ \parindent=1em\leavevmode\llap{\makeenmark}}
\def\XeLaTeX{Xe\LaTeX}%
%
\newenvironment{optionlist}
{\begin{trivlist}\setlength\leftskip{2em}}
{\end{trivlist}}
\newcommand\optitem[3]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}} \lbrack\textcolor{Crimson}{#2}\rbrack}] #3}
\newcommand\optitemii[2]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}}}] \texttt{\lbrack\textcolor{Crimson}{#2}\rbrack}}
\newcommand\optitempgf[2]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}}}] #2}
\renewcommand\tableofcontents%
{%
  %\section*{\contentsname}%
  \@mkboth{%
  \MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
  \@starttoc{toc}%
}%
%
\newcommand\env[1]{\texttt{#1}\SortIndex{#1}{\string{\string\ttfamily\space#1\string} (environment)}%
                   \SortIndex{environments:>#1}{\string{\string\ttfamily\space#1\string}}}%
\newcommand\stylename[1]{\texttt{#1}\SortIndex{#1}{{\ttfamily #1} (Style file)}%
                     \SortIndex{Style file>#1}{\texttt{#1}}}%
\newcommand\package[1]{\texttt{#1}\SortIndex{#1}{{\ttfamily #1} (Package)}%
                     \SortIndex{Package>#1}{\texttt{#1}}}%
\newcommand*\margcs[1]{\marginnote{\hbadness=10000\RaggedLeft\scriptsize #1}}%
\def\PrintIndex{\clearpage\Headline{Index}\@input@{\jobname.ind}%
                \global\let\PrintIndex\@empty}
                \renewenvironment{theindex}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                \columnsep 35\p@
\def\see##1##2{\textit{See} ##1}%
\def\seealso##1##2{\textit{See also} ##1}%
\long\def\cmd##1{\cs{\expandafter\cmd@to@cs\string##1}}%
\def\@url##1{\url@break\ttt{##1}\endgroup}%
\def\ttt{\begingroup\@sanitize\ttfamily\@ttt}%
\def\@ttt##1{##1\endgroup}%
\mathchardef\save@secnumdepth\c@secnumdepth
\c@secnumdepth\m@ne
                \phantomsection%
                \twocolumn%[\section{\indexname}]%
                \refstepcounter{section}
                \addcontentsline{toc}{section}{\protect\numberline{\thesection}Index}%
\c@secnumdepth\save@secnumdepth
                %\thispagestyle{plain}
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}
\setlength\parindent{0pt}%
\newcommand*\myref[1]{[see: \ref{#1} on page \pageref{#1}]}
\makeatother
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{\jobname.sty}
%
% \hypersetup{pdfauthor={Josef Kleber},pdftitle={A LaTeX package for keeping a diabetes diary},pdfsubject={Documentation for LaTeX package \filename}}%
% \lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
% emph={medicationchart,diadiasidebyside,diadiaplot},emphstyle=\color{Tomato}, 
% emph={[2]columns,column,chol,string,replace,name,ddpuser,font,tabstyle,tabcolor,date,type,bsl1,bsl2,bsl3,plotstyle,xlabel,tick,label,style,xmin,xmax,x,y,
% text,width,very,thick,fill,draw,mark,options},
% emphstyle={[2]\color{OliveDrab}},
% morekeywords={pgfplotsset,pgfplotstableset,diadiatab,diadiaaddplot,legend,annotation,setlimit,mcentry,infobox,Telefon}}
% \DoNotIndex{\,,\\,\begin,\end,\begingroup,\endgroup,\csname,\def,\else,\endcsname,\equal,\expandafter,
% \fi,\gdef,\ifnum,\ifthenelse,\immediate,\MessageBreak,\NeedsTeXFormat,\newcommand,\renewcommand,\NewEnviron,\newenvironment,\newif,
% \PackageInfo,\PackageError,\ProcessOptionsX,\ProvidesPackage,\relax,\RequirePackage,
% \space,\errmessage,\ExecuteOptionsX,}
%
% \setlength\parskip{6pt}%
% \bibliographystyle{plain}
% \title{\filename}%
% \Subtitle{A \LaTeX{} package for keeping a diabetes diary}%
% \author{Josef Kleber}
% \Fileversion{\fileversion}
% \date{\filedate}
% \Refline{\href{mailto:josef.kleber@gmx.de}{\texttt{josef.kleber@gmx.de}}\\\href{https://bitbucket.org/kleberj/diadia/}{\texttt{https://bitbucket.org/kleberj/diadia/}}}
% \newsavebox\logo
% \savebox\logo{%
% \begin{diadiaplot}[plotstyle=bloodsugar]
%                   {
%                     xlabel=2015,
%                     tick label style={font=\footnotesize},
%                     legend style={draw=NavyBlue},
%                     ytick={90,120,150,210,240},
%                     xmin=2015-02-18,
%                     xmax=2015-02-28,
%                     width=9cm,
%                     color=NavyBlue
%                   }
%   \diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
%   \diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
%   \diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
%   \annotation[text width=0.9cm]{2015-02-22}{215}{My first annoation}
%   \setlimit[very thick]{140,180}
%   \legend{morning,noon,evening}
% \end{diadiaplot}
%}
% \maketitle
% \stepcounter{page}
% \tableofcontents
% \clearpage
%
%
%\StopEventually{^^A
% {
% \clearpage
% \raggedright
% \nocite{*}
% \bibliography{\jobname}
% }
% \clearpage
%  \PrintChanges
%  \PrintIndex
%}
%
% \Headline{Abstract}
% \begin{abstract}
% The \package{diadia} package allows you to keep a diabetes diary.
% Usually, this means keeping record of certain medical values
% like blood sugar, blood pressure, pulse or weight. It might
% also include other medical, pharmaceutical or nutritional
% data ($\text{HbA}_{\text{1c}}$, insulin doses, carbohydrate units). The \package{diadia}
% package supports all of this plus more - simply by adding
% more columns to the data file!
%
% It is able to evaluate the data file and typesets formatted
% tables and derived plots. Furthermore, it supports medication
% charts and info boxes.
% \end{abstract}
% \clearpage
% \tableofcontents
% \clearpage
% \Headline{2 Storing data}
%
% \section{Options}
% The following options can be set as package options with global scope,
% as well as command options with local scope:
%
% \begin{optionlist}
%   \optitem{tabstyle}{simple}{sets the style of the tables}
%   \optitem{tabcolor}{none}{sets the color of the table}
%   \optitem{plotstyle}{none}{sets the predefined style of your plot}
%   \optitem{plotclosedcycle}{false}{sets an implicit \cmd\closedcycle\ command inside a filled plot (weight). This is usually controlled by \texttt{plotstyle.}}
%   \optitem{mcnotewidth}{3cm}{sets the width of the note column in medication charts}
%   \optitem{columnsep}{18pt}{sets the distance of columns inside \env{diadiasidebyside} environments}
%   \optitem{columnseprule}{0pt}{sets the width of the separation rule between columns}
%   \optitem{columnseprulecolor}{\cmd\normalcolor}{sets the color of the separation rule. The \package{diadia} package follows the usage of options in the \package{multicol}\cite{bib:multicol} package. Thus, this option must be a color command like \cmd\color\{blue\} -- not just a color name!}
% \end{optionlist}
%
% Furthermore, the design of this package is defined by several Ti\textit{k}z-like styles.
% These can be (re)defined with \cmd\tikzstyle, \cmd\tcbset, \cmd\pgfplotsset\ or \cmd\pgfplotstableset\ with the usual syntax:
%
% \verb|key/.style={}| or\\
% \verb|key/.append style={}|, e.g.:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\pgfplotsset{ddpuser/.style={thin}}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% The \package{pgfplots}\cite{bib:pgfplots}, \package{pgfplotstable}\cite{bib:pgfplotstable} and \package{tcolorbox}\cite{bib:tcolorbox} packages offer
% zillions of options to influence the design!
% \Headline{2 Storing data}
% \section{Storing data}
% The very simple basic structure of the data file is as follows:
%
% \begin{center}
%   \begin{alltt}\input{201502.dat}\end{alltt}
% \end{center}
%
% It is a simple text file with columns seperated by <space> or <tab>.
% Thus, empty cells must be marked either with an empty group (\texttt{\{\}}) or the special marker \texttt{nan} (not a number).
% In plots, empty groups will simply be ignored, where as \texttt{nan} will result in jumps in the plots.
% The data file starts with a header row. Its keys will be used to plot the data or to typeset tables.
%
% \begin{center}
% \begin{tabular}{>{\bfseries}rl}
% \toprule
% \multicolumn{2}{c}{standard keys} \\\midrule
% date & entry date \\
% bsl1-3 & three blood sugar levels (morning, noon, evening) \\
% id1-3 & three insulin doses \\
% bps & blood pressure (systolic) \\
% bpd & blood pressure (diastolic) \\
% weight & weight \\
% cu & carbohydrate units \\
% pul & pulse\\
% hba1c\footnotemark & $\text{HbA}_{\text{1c}}$ \\
% \bottomrule
% \end{tabular}
% \footnotetext{long term values can be stored in a seperate data file}
% \end{center}
%
% You can easily add other columns or delete existing ones. You can even rename these columns, but you would have to redefine a lot of internal commands.
% You must not neither rename the \texttt{date} key nor change its format (YYYY-MM-DD)!
%
% Lets say you want to add a cholesterol column, then you should at least define the following key:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\pgfplotstableset
{
  columns/chol/.style=
  {
    string replace={nan}{},
    column name={Chol.}
  }
}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% This sets the column name in tables and prevents that \texttt{nan} values are printed. For plots you only need the \texttt{chol} key!
%
% \section{Presenting data}
% \subsection{Tables}
%
% The \cmd\diadiatab\margcs{\cmd\diadiatab\oarg{options}\\\marg{pgfplotstable options}\marg{file}} command typesets the data file specified
% by \marg{file} in a table. Now, you can typeset the example data in a formatted table:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\diadiatab{font=\scriptsize}{201502.dat}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
%\diadiatab{font=\scriptsize}{201502.dat}
%
% \bigskip
% You can influence the design with the following options:
%
% \begin{optionlist}
%   \optitem{tabstyle}{\underline{simple}, advanced}{}
%   \optitem{tabcolor}{\underline{none}, color name}{}
% \end{optionlist}
% 
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\diadiatab[tabstyle=advanced,tabcolor=gray!30]
          {font=\scriptsize}{201502.dat}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \diadiatab[tabstyle=advanced,tabcolor=gray!30]{font=\scriptsize}{201502.dat}
%
% \bigskip
% Here's a list of interesting keys for \marg{pgfplotstable options}, but there are of course
% much more in the \package{pgfplotstable}\cite{bib:pgfplotstable} package documentation!
%
% \begin{optionlist}
%   \optitempgf{font}{accepts usual font commads}
%   \optitempgf{columns}{takes a list of columns, which should be typeset}
%   \optitempgf{column name}{sets the column heading (replacement of \texttt{key})}
%   \optitempgf{date type}{sets the date format}
% \end{optionlist}
%  
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\diadiatab[tabstyle=advanced,tabcolor=gray!30]
          {
            font=\small,
            columns={date,bsl1,bsl2,bsl3},
            columns/bsl1/.append style={column name={B1}},
            columns/bsl2/.append style={column name={B2}},
            columns/bsl3/.append style={column name={B3}},
            columns/date/.append style={
              date type={\day.\month.\year}}
          }
          {201502.dat}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \diadiatab[tabstyle=advanced,tabcolor=gray!30]
%           {
%             font=\small,
%             columns={date,bsl1,bsl2,bsl3},
%             columns/bsl1/.append style={column name={B1}},
%             columns/bsl2/.append style={column name={B2}},
%             columns/bsl3/.append style={column name={B3}},
%             columns/date/.append style={
%               date type={\day.\month.\year}}
%           }
%           {201502.dat}
%
% \bigskip
% Note, that the data file was never changed!
%
% Unfortunately, the \package{pgfplotstable} package does not offer a simple method to limit the output
% of the table to certain dates, as the \package{pgfplots} package offers with the \texttt{xmin} and \texttt{xmax} keys.
% Thus, you have to prepare piecewise data files for monthly reports or so. The following simple \texttt{grep} one-liner
% might be helpful:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
grep -e 'date' -e '2015-04' <in.dat >201504.dat
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% Furthermore, \package{diadia} does not support page breaks for tables. The documentation of the \package{pgfplotstable}\cite[p. 21]{bib:pgfplotstable}
% package describes a way out by using a \package{longtable}\cite{bib:longtable} if you need to typeset long tables!
%
% \subsection{Plots}
% The \env{diadiaplot}\margcs{\cmd\begin\{diadiaplot\}\oarg{options}\\\marg{pgfplots options}\\...\\\cmd\end\{diadiaplot\}}
% environment provides a typical plot structure, where you can add elements like plots, annotations or a legend.
% It will typeset the basic frame of the data plot.
%
% \begin{samepage}
% Possible options:
%
% \begin{optionlist}
%   \optitemii{plotstyle}{\underline{none}, bloodsugar, bloodpressure, insulin, weight, cu, pulse, hbaonec}
%   \optitem{plotclosedcycle}{\underline{false}, true}{}
% \end{optionlist}
% \end{samepage}
%
% The \cmd\diadiaaddplot\margcs{\cmd\diadiaaddplot\marg{addplot options}\\\marg{key mappings}\marg{file}} command adds a data plot to the basic frame.
% The keys specified in \marg{addplot options} are added to the predefined plot options.
% By contrast, with the starred version \cmd\diadiaaddplot*\margcs{\cmd\diadiaaddplot*\marg{addplot options}\\\marg{key mappings}\marg{file}},
% the keys specified in \marg{addplot options} will completely replace the predefined plot options.
%
% The \cmd\legend\margcs{\cmd\legend\marg{label list}} command will typeset a legend under the plot.
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{diadiaplot}[plotstyle=bloodsugar]
                  {
                    xlabel=2015,
                    tick label style={font=\footnotesize},
                    xmin=2015-02-18,
                    xmax=2015-02-28
                  }
  \diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
  \diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
  \diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
  \legend{morning,noon,evening}
\end{diadiaplot}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \begin{diadiaplot}[plotstyle=bloodsugar]
%                   {
%                     xlabel=2015,
%                     tick label style={font=\footnotesize},
%                     xmin=2015-02-18,
%                     xmax=2015-02-28
%                   }
%   \diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
%   \diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
%   \diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
%   \legend{morning,noon,evening}
% \end{diadiaplot}
%
% \bigskip
% The \cmd\annotation\margcs{\cmd\annotation\oarg{Ti\textit{k}z options}\\\marg{x}\marg{y}\marg{annotation}} command allows you to annotate
% your plot values. The x and y coordinates must be declared in the context of the plot. That is usually a date and a plot value.
%
% With the \cmd\setlimit\margcs{\cmd\setlimit\oarg{Ti\textit{k}z options}\\\marg{limit list}} command, you can set general and/or individual
% limits agreed with your doctor.
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{diadiaplot}[plotstyle=bloodsugar]
                  {
                    xlabel=2015,
                    tick label style={font=\footnotesize},
                    xmin=2015-02-18,
                    xmax=2015-02-28
                  }
  \diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
  \diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
  \diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
  \annotation[text width=0.9cm]{2015-02-22}{215}
             {My first annoation}
  \setlimit[very thick]{140,180}
  \legend{morning,noon,evening}
\end{diadiaplot}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \begin{diadiaplot}[plotstyle=bloodsugar]
%                   {
%                     xlabel=2015,
%                     tick label style={font=\footnotesize},
%                     xmin=2015-02-18,
%                     xmax=2015-02-28
%                   }
%   \diadiaaddplot{}{x=date,y=bsl1}{diadia.dat}
%   \diadiaaddplot{}{x=date,y=bsl2}{diadia.dat}
%   \diadiaaddplot{}{x=date,y=bsl3}{diadia.dat}
%   \annotation[text width=0.9cm]{2015-02-22}{215}{My first annoation}
%   \setlimit[very thick]{140,180}
%   \legend{morning,noon,evening}
% \end{diadiaplot}
%
% \bigskip
% Here's a list of interesting keys for \marg{pgfplots options}, but there are of course
% much more in the \package{pgfplots}\cite{bib:pgfplots} package documentation!
%
% \begin{optionlist}
%   \optitempgf{width}{sets the width of the data plot. Furthermore, there are the special \texttt{normalsize}, \texttt{small}, \texttt{footnotesize} and \texttt{tiny} keys}
%   \optitempgf{height}{usually, a 1:1 aspect ratio is used}
%   \optitempgf{xlabel}{sets a label under the plot, usually the year}
%   \optitempgf{ylabel}{sets a label left to the plot, usually controlled by \texttt{plotstyle}}
%   \optitempgf{xmin}{sets the start date of the plot}
%   \optitempgf{xmax}{sets the end date of the plot}
%   \optitempgf{tick label style}{sets the style of tick labels, usually the font size (see examples)}
%   \optitempgf{ytick}{takes a list of values for y ticks, if you are not happy with the standard choice}
% \end{optionlist}
%  
% \subsection{Medication charts}
%
% The \env{medicationchart}\margcs{\cmd\begin\{medicationchart\}\oarg{options}\\\marg{tcolorbox options}\marg{date}\\...\\\cmd\end\{medicationchart\}} 
% environment allows you to typeset a medication chart. That is, a list of your pharmaceuticals and how to take them. 	Internally, you must use
% the standard systax of a 6 column tabular. Or you simply use the \cmd\mcentry\margcs{\cmd\mcentry\marg{pharmaceutical}\marg{morning}\\\marg{noon}\marg{evening}\marg{night}\marg{note}} command.
%
% Possible options:
%
% \begin{optionlist}
%   \optitem{mcnotewidth}{\underline{3cm}}{}
% \end{optionlist}
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{medicationchart}{}{07.04.2015}
\mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
\mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
\mcentry{Mono-Embolex 3000 I.E. Prophylaxe Novartis}{0}{0}{1}{0}{}
\mcentry{Sultamicillin-ratiopharm 375mg}{1}{0}{1}{0}{}
\end{medicationchart}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \begin{medicationchart}{}{07.04.2015}
%   \mcentry{Oxycodon-HCI STADA 10mg Retardtabletten}{0}{0}{1}{0}{}
%   \mcentry{Novaminsulfon Lichtenstein 500 mg}{1}{1}{1}{1}{}
%   \mcentry{Mono-Embolex 3000 I.E. Prophylaxe Novartis}{0}{0}{1}{0}{}
%   \mcentry{Sultamicillin-ratiopharm 375mg}{1}{0}{1}{0}{}
% \end{medicationchart}
%
% \subsection{Info boxes}
%
% The \cmd\infobox\margcs{\cmd\infobox\marg{tcolorbox options}\\\marg{date}\marg{information}} 
% environment allows you to typeset info boxes.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\infobox{width=8cm}{22.04.2015}{%
Podiatrist appointment:

\bigskip
22.04.2015 11:30

\medskip
\Telefon\ 089/65831933
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \infobox{width=8cm}{22.04.2015}{%
% Podiatrist appointment:
%
% \bigskip
% 22.04.2015 11:30
%
% \medskip
% \Telefon\ 089/65831933
% }%
%
% \subsection{Misc.}
%
% The \env{diadiasidebyside}\margcs{\cmd\begin\{diadiasidebyside\}\oarg{options}\\...\\\cmd\end\{diadiasidebyside\}} 
% environment is a wrappper for the \env{multicol}\cite{bib:multicol} environment with a two column layout and offers the following options:
%
% \begin{optionlist}
%   \optitem{columnsep}{\underline{18pt}}{}
%   \optitem{columnseprule}{\underline{0pt}}{}
%   \optitem{columnseprulecolor}{\underline{\cmd\normalcolor}}{}
% \end{optionlist}
%
% For plots it sets the width to \cmd\columnwidth, so there's no need to adjust the width!
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{diadiasidebyside}
\pgfplotsset{xlabel=2015,tick label style={font=\footnotesize}}
\begin{diadiaplot}[plotstyle=bloodpressure]
                  {
                    xmin=2015-02-18,
                    xmax=2015-02-27
                  }
\diadiaaddplot{}{x=date,y=bps}{diadia.dat}
\diadiaaddplot{}{x=date,y=bpd}{diadia.dat}
\legend{systolic,diastolic}
\end{diadiaplot}

\begin{diadiaplot}[plotstyle=weight]
                  {
                    xmin=2015-02-18,
                    xmax=2015-02-27
                  }
\diadiaaddplot{lime,mark options={fill=lime!50!black},
               mark=otimes*,draw=lime!75!black}
              {x=date,y=weight}{diadia.dat}
\end{diadiaplot}
\end{diadiasidebyside}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \vspace{1cm}
% \begin{diadiasidebyside}
% \pgfplotsset{xlabel=2015,tick label style={font=\footnotesize}}
% \begin{diadiaplot}[plotstyle=bloodpressure]
%                   {
%                     xmin=2015-02-18,
%                     xmax=2015-02-27
%                   }
% \diadiaaddplot{}{x=date,y=bps}{diadia.dat}
% \diadiaaddplot{}{x=date,y=bpd}{diadia.dat}
% \legend{systolic,diastolic}
% \end{diadiaplot}
%
% \begin{diadiaplot}[plotstyle=weight]
%                   {
%                     xmin=2015-02-18,
%                     xmax=2015-02-27
%                   }
% \diadiaaddplot{lime,mark options={fill=lime!50!black},
%                mark=otimes*,draw=lime!75!black}
%               {x=date,y=weight}{diadia.dat}
% \end{diadiaplot}
% \end{diadiasidebyside}
%
% \clearpage
% \section{Implementation}
% \changes{v1.0}{2015/05/11}{CTAN upload}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% First, we provide the \LaTeX\ package \package{diadia}.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{diadia}[2015/05/11 v1.0 diadia.sty - Josef Kleber (C) 2015]%
%    \end{macrocode}
% We load the \texttt{xkeyval} package and define a helper macro to define the (global) options.
%    \begin{macrocode}
\RequirePackage{xkeyval}%
%
\newcommand*\DD@JK@define@key[4]%
{%
  \expandafter\gdef\csname#1@#3\endcsname{#4}%
  \define@key{#2.sty}{#3}[#4]%
  {%
    \expandafter\gdef\csname#1@#3\endcsname{##1}%
  }%
  \define@key{#2}{#3}%
  {%
    \expandafter\def\csname#1@#3\endcsname{##1}%
  }%
}%
%    \end{macrocode}
% Now, we can define the options and execute them with defaults. 
%    \begin{macrocode}
\DD@JK@define@key{DD@JK}{diadia}{tabstyle}{simple}%
\DD@JK@define@key{DD@JK}{diadia}{tabcolor}{none}%
\DD@JK@define@key{DD@JK}{diadia}{plotstyle}{none}%
\DD@JK@define@key{DD@JK}{diadia}{plotclosedcycle}{false}%
\DD@JK@define@key{DD@JK}{diadia}{mcnotewidth}{3cm}%
\DD@JK@define@key{DD@JK}{diadia}{columnsep}{18pt}%
\DD@JK@define@key{DD@JK}{diadia}{columnseprule}{0pt}%
\DD@JK@define@key{DD@JK}{diadia}{columnseprulecolor}{\normalcolor}%
%
\ExecuteOptionsX{tabstyle,tabcolor,plotstyle,plotclosedcycle,mcnotewidth,%
                 columnsep,columnseprule,columnseprulecolor}%
\ProcessOptionsX*\relax%
%    \end{macrocode}
% We load the needed packages and libraries!
%    \begin{macrocode}
\RequirePackage{pgfplots}%
\RequirePackage{pgfplotstable}%
\RequirePackage{pgfcalendar}%
\RequirePackage{tabularx}%
\RequirePackage{booktabs}%
\RequirePackage{colortbl}%
\RequirePackage{ifthen}%
\RequirePackage{calc}%
\RequirePackage{translations}%
\RequirePackage{amsmath}%
\RequirePackage[many]{tcolorbox}%
\RequirePackage{environ}%
\RequirePackage{multicol}%
%
\usepgfplotslibrary{dateplot}%
%
\def\DD@JK@closedcycle{}%
\def\DD@JK@addplotdefault{}%
%    \end{macrocode}
% We load the translation files for supported languages and map the translations of the active language to macros!
%    \begin{macrocode}
\input{diadia-fallback.trsl}%
\input{diadia-english.trsl}%
\input{diadia-german.trsl}%
%
\def\DD@JK@trans@BloodSugar{\GetTranslation{dd-BloodSugar}}%
\def\DD@JK@trans@Insulin{\GetTranslation{dd-Insulin}}%
\def\DD@JK@trans@BloodPressure{\GetTranslation{dd-BloodPressure}}%
\def\DD@JK@trans@Weight{\GetTranslation{dd-Weight}}%
\def\DD@JK@trans@MedicationChart{\GetTranslation{dd-MedicationChart}}%
\def\DD@JK@trans@issued{\GetTranslation{dd-issued}}%
\def\DD@JK@trans@Pharmaceutical{\GetTranslation{dd-Pharmaceutical}}%
\def\DD@JK@trans@Morning{\GetTranslation{dd-Morning}}%
\def\DD@JK@trans@Noon{\GetTranslation{dd-Noon}}%
\def\DD@JK@trans@Evening{\GetTranslation{dd-Evening}}%
\def\DD@JK@trans@Night{\GetTranslation{dd-Night}}%
\def\DD@JK@trans@Note{\GetTranslation{dd-Note}}%
\def\DD@JK@trans@Info{\GetTranslation{dd-Info}}%
\def\DD@JK@trans@Date{\GetTranslation{dd-Date}}%
\def\DD@JK@trans@BSi{\GetTranslation{dd-BSi}}%
\def\DD@JK@trans@BSii{\GetTranslation{dd-BSii}}%
\def\DD@JK@trans@BSiii{\GetTranslation{dd-BSiii}}%
\def\DD@JK@trans@IDi{\GetTranslation{dd-IDi}}%
\def\DD@JK@trans@IDii{\GetTranslation{dd-IDii}}%
\def\DD@JK@trans@IDiii{\GetTranslation{dd-IDiii}}%
\def\DD@JK@trans@BPs{\GetTranslation{dd-BPs}}%
\def\DD@JK@trans@BPd{\GetTranslation{dd-BPd}}%
\def\DD@JK@trans@Weight{\GetTranslation{dd-Weight}}%
\def\DD@JK@trans@CU{\GetTranslation{dd-CU}}%
\def\DD@JK@trans@Pulse{\GetTranslation{dd-Pulse}}%
\def\DD@JK@trans@Hbaonec{\GetTranslation{dd-Hbaonec}}%
%    \end{macrocode}
% We define two new tabular types Z (ragged right X type) and Y (ragged right p with \texttt{mcnotewidth} width).
%    \begin{macrocode}
\newcolumntype{Z}{>{\raggedright\let\newline\\\arraybackslash}X}%
\newcolumntype{Y}{>{\raggedright\let\newline\\\arraybackslash}p{\DD@JK@mcnotewidth}}%
%    \end{macrocode}
% We set \texttt{pgfplot} compat mode to 1.12 and the \texttt{date ZERO} key to \texttt{2015-01-01}.
% Sometimes, values are plotted at the wrong date. Then you should adjust the \texttt{date ZERO} key
% to the start date of your data to avoid rounding errors in date calculation.
%    \begin{macrocode}
\pgfplotsset{%
  compat=1.12,%
  date ZERO=2015-01-01%
}%
%    \end{macrocode}
% We define some \texttt{pgfplots} styles with priority order: \texttt{ddpdefault} $\rightarrow$ \texttt{ddpuser} $\rightarrow$
% \{\texttt{ddpbloodsugar}\textbar\texttt{insulin}\textbar\texttt{bloodpressure}\textbar\texttt{weight}\textbar\texttt{cu}\textbar\texttt{pulse}\textbar\texttt{hbaonec}\}
%
% Thus, you can redefine \texttt{ddpuser} to adjust the general design set by \texttt{ddpdefault}. Furthermore, we define
% a \texttt{ddpweightplot} to use our standard design also in weight plots, as area style plots use their own color cycle list.
%    \begin{macrocode}
\pgfplotsset{%
  ddpuser/.style=%
  {},%
  ddpdefault/.style=%
  {%
    thick,%
    date coordinates in=x,%
    xticklabel={\day.\month.},%
    legend style={at={(0.5,-0.25)},%
      font=\footnotesize,%
      anchor=north,%
      legend columns=-1},%
    ddpuser%
  },%
  ddpweight/.style=%
  {%
    smooth,%
    area style,%
    ylabel=\DD@JK@trans@Weight%
  },%
  ddpweightplot/.style=%
  {%
    teal,%
    fill=teal!50,%
    mark=halfcircle*,%
    every mark/.append style={solid,fill=.!80!black}%
  },%
  ddpbloodpressure/.style=%
  {%
    cycle list name=diadiacyclelist,%
    unbounded coords=jump,%
    ylabel=\DD@JK@trans@BloodPressure%
  },%
  ddpinsulin/.style=%
  {%
    cycle list name=diadiacyclelist,%
    unbounded coords=jump,%
    ylabel=\DD@JK@trans@Insulin%
  },%
  ddpbloodsugar/.style=%
  {%
    smooth,%
    cycle list name=diadiacyclelist,%
    unbounded coords=jump,%
    ylabel=\DD@JK@trans@BloodSugar%
  },%
  ddppulse/.style=%
  {%
    smooth,%
    cycle list name=diadiacyclelist,%
    unbounded coords=jump,%
    ylabel=\DD@JK@trans@Pulse%
  },%
  ddpcu/.style=%
  {%
    ybar,%
    tick align=inside,%
    cycle list name=diadiacyclelist,%
    unbounded coords=jump,%
    ylabel=\DD@JK@trans@CU%
  },%
  ddphbaonec/.style=%
  {%
    ybar,%
    tick align=inside,%
    cycle list name=diadiacyclelist,%
    unbounded coords=jump,%
    ylabel=\DD@JK@trans@Hbaonec%
  }%
}%
%    \end{macrocode}
% We set some sensible defaults for \cmd\diadiatab
%
% \begin{itemize}
% \item replace \texttt{nan} with empty string
% \item replace empty cells with --
% \item define \texttt{date} column as \texttt{date type}
% \item define \texttt{weight} and \texttt{hba1c} columns as \texttt{fixed,fixed zerofill,precision=1}
% \end{itemize}
%
%    \begin{macrocode}
\pgfplotstableset%
{%
  empty cells with={--},%
  columns/date/.style={date type},%
  columns/bsl1/.style={string replace={nan}{}},%
  columns/bsl2/.style={string replace={nan}{}},%
  columns/bsl3/.style={string replace={nan}{}},%
  columns/id1/.style={string replace={nan}{}},%
  columns/id2/.style={string replace={nan}{}},%
  columns/id3/.style={string replace={nan}{}},%
  columns/bps/.style={string replace={nan}{}},%
  columns/bpd/.style={string replace={nan}{}},%
  columns/weight/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}},%
  columns/cu/.style={string replace={nan}{}},%
  columns/pul/.style={string replace={nan}{}},%
  columns/hba1c/.style={fixed,fixed zerofill,precision=1,string replace={nan}{}}%
}%
%    \end{macrocode}
% Now, we append the language dependent column headers to the column style!
%    \begin{macrocode}
\pgfplotstableset%
{%
  columns/date/.append style={column name={\DD@JK@trans@Date}},%
  columns/bsl1/.append style={column name={\DD@JK@trans@BSi}},%
  columns/bsl2/.append style={column name={\DD@JK@trans@BSii}},%
  columns/bsl3/.append style={column name={\DD@JK@trans@BSiii}},%
  columns/id1/.append style={column name={\DD@JK@trans@IDi}},%
  columns/id2/.append style={column name={\DD@JK@trans@IDii}},%
  columns/id3/.append style={column name={\DD@JK@trans@IDiii}},%
  columns/bps/.append style={column name={\DD@JK@trans@BPs}},%
  columns/bpd/.append style={column name={\DD@JK@trans@BPd}},%
  columns/weight/.append style={column name={\DD@JK@trans@Weight}},%
  columns/cu/.append style={column name={\DD@JK@trans@CU}},%
  columns/pul/.append style={column name={\DD@JK@trans@Pulse}},%
  columns/hba1c/.append style={column name={\DD@JK@trans@Hbaonec}}%
}%
%    \end{macrocode}
% We define the \texttt{diadiacyclelist} color cycle list used in plots. You may adjust it to your needs.
%    \begin{macrocode}
\pgfplotscreateplotcyclelist{diadiacyclelist}%
{%
  {teal,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black}},%
  {orange,mark=halfcircle*,every mark/.append style={solid,fill=.!80!black,rotate=180}},%
  {cyan,mark=o,every mark/.append style={solid,fill=.!80!black}},%
  {yellow,mark=star,every mark/.append style={solid,fill=.!80!black}}%
}%
%    \end{macrocode}
% We define the Ti\textit{k}z styles for annotations and limits.
%    \begin{macrocode}
\tikzset%
{%
  ddpannotation/.style=%
  {%
    fill=yellow!50!white,%
    rectangle,%
    rounded corners=3pt,%
    font=\tiny%
  },%
  setlimit/.style=%
  {%
    red,%
    thick%
  },%
  ddaddplotfill/.style=%
  {%
    fill=teal!50,%
  },%
}%
%    \end{macrocode}
% Finally, we define the \texttt{medicationchart} and \texttt{infobox} \texttt{tcolorbox} styles based on \texttt{ddboxdefault}!
%    \begin{macrocode}
\tcbset%
{%
  ddboxdefault/.style=%
  {%
    enhanced,%
    fonttitle=\bfseries\large,%
    coltitle=black,%
    center title,%
    titlerule=.75mm,%
    toprule=1mm,%
    bottomrule=1mm,%
    toptitle=2mm,%
    bottomtitle=2mm%
  },%
  medicationchart/.style=%
  {%
    ddboxdefault,%
    fontupper=\footnotesize,%
    colback=yellow!10!white,%
    colframe=yellow!60!black,%
    colbacktitle=yellow!20!white,%
    left=0mm,%
    right=0mm,%
    top=0mm,%
    bottom=0mm,%
    boxsep=0mm,%
  },%
  infobox/.style=%
  {%
    ddboxdefault,%
    width=\linewidth-10.888pt,%
    colback=orange!10!white,%
    colframe=orange!60!black,%
    colbacktitle=orange!20!white%
  },%
}%
%    \end{macrocode}
% \begin{macro}{\annotation}
% With this command you can annotate your plots. You must use x/y coordinates in the context of your plot. Thus the x coordinate is usually a date.
%
% \cs{annotation}\oarg{Ti\textit{k}z options}\marg{x}\marg{y}\marg{annotation}
%    \begin{macrocode}
\newcommand*{\annotation}[4][]%
{%
  \node[ddpannotation,#1] at (#2,#3) {#4};%
}%
%    \end{macrocode}
%  \end{macro}
% \begin{macro}{\diadiatab}
% The \cmd\diadiatab\ command allows you to typeset your data in a formatted table.
%
% \cs{diadiatab}\oarg{options}\marg{pgfplotstable options}\marg{file}
%    \begin{macrocode}
\newcommand*{\diadiatab}[3][]%
{%
  \begingroup%
  %    \end{macrocode}
% Initially, we evaluate the options and set \texttt{pgfplotstable} options accordingly.
%    \begin{macrocode}
    \setkeys{diadia}{#1}%
    \ifthenelse{\equal{\DD@JK@tabstyle}{simple}}%
    {}%
    {%
      \ifthenelse{\equal{\DD@JK@tabstyle}{advanced}}%
      {%
        \pgfplotstableset%
        {%
          every head row/.style={before row=\toprule,after row=\midrule},%
          every last row/.style={after row=\bottomrule}%
        }%
      }%
      {}%
    }%
    \ifthenelse{\equal{\DD@JK@tabcolor}{none}}%
    {}%
    {%
      \pgfplotstableset%
      {%
        every even row/.style={before row={\rowcolor{\DD@JK@tabcolor}}}%
      }%
    }%
%    \end{macrocode}
% Finally, we typeset the table.
%    \begin{macrocode}
    \pgfplotstabletypeset[#2]{#3}%
  \endgroup%
}%
%    \end{macrocode}
%  \end{macro}
% \begin{macro}{\diadiaaddplot}
% The \cmd\diadiaddplot\ command adds a data plot. First of all, it checks for a * and calls
% \cmd\@@diadiaaddplot or \cmd\@@diadiaaddplot!
%
% \cs{diadiaaddplot}\marg{pgfplots options}\marg{key mapping}\marg{file}
%    \begin{macrocode}
\newcommand*\diadiaaddplot{\@ifstar\@@diadiaaddplot\@diadiaaddplot}%
%    \end{macrocode}
%  \end{macro}
%    \begin{macrocode}
\newcommand*\@diadiaaddplot[4][]%
{%
  \addplot+[\DD@JK@addplotdefault,#2] table[#3] {#4}\DD@JK@closedcycle;%
}%
%
\newcommand*\@@diadiaaddplot[4][]%
{%
  \addplot[#2] table[#3] {#4}\DD@JK@closedcycle;%
}%
%    \end{macrocode}
% \begin{environment}{diadiaplot}
% The \env{diadiaplot} environment is a wrapper for the \env{tikzpicture} and \env{axis} environments!
%
%    \begin{macrocode}
\newenvironment{diadiaplot}[2][]%
{%
%    \end{macrocode}
% We use the \texttt{baseline} option to have all plots on the same baseline. Important for sidebyside
% plots with different legends!
%    \begin{macrocode}
  \begin{tikzpicture}[baseline]%
%    \end{macrocode}
% We evalute the options and set the \cmd\DD@JK@closedcycle\ and \cmd\DD@JK@ddpmode\ macros accordingly.
%    \begin{macrocode}
    \setkeys{diadia}{#1}%
    \ifthenelse{\equal{\DD@JK@plotclosedcycle}{true}}%
    {\def\DD@JK@closedcycle{\closedcycle}}%
    {\def\DD@JK@closedcycle{}}%
    \def\DD@JK@ddpmode{}%
    \ifthenelse{\equal{\DD@JK@plotstyle}{none}}%
    {%
      \def\DD@JK@ddpmode{}%
    }%
    {%
      \ifthenelse{\equal{\DD@JK@plotstyle}{weight}}%
      {%
        \def\DD@JK@ddpmode{ddpweight}%
        \def\DD@JK@closedcycle{\closedcycle}%
      }%
      {%
        \ifthenelse{\equal{\DD@JK@plotstyle}{bloodpressure}}%
        {%
          \def\DD@JK@ddpmode{ddpbloodpressure}%
        }%
        {%
          \ifthenelse{\equal{\DD@JK@plotstyle}{insulin}}%
          {%
            \def\DD@JK@ddpmode{ddpinsulin}%
          }%
          {%
            \ifthenelse{\equal{\DD@JK@plotstyle}{bloodsugar}}%
            {%
              \def\DD@JK@ddpmode{ddpbloodsugar}%
            }%
            {%
              \ifthenelse{\equal{\DD@JK@plotstyle}{pulse}}%
              {%
                \def\DD@JK@ddpmode{ddppulse}%
              }%
              {%
                \ifthenelse{\equal{\DD@JK@plotstyle}{cu}}%
                {%
                  \def\DD@JK@ddpmode{ddpcu}%
                  \def\DD@JK@addplotdefault{ddaddplotfill}%
                }%
                {%
                  \ifthenelse{\equal{\DD@JK@plotstyle}{hbaonec}}%
                  {%
                    \def\DD@JK@ddpmode{ddphbaonec}%
                    \def\DD@JK@addplotdefault{ddaddplotfill}%
                  }%
                  {}%
                }%
              }%
            }%
          }%
        }%
      }%
    }%
%    \end{macrocode}
% We start the \texttt{axis} environment with the right plot style.
%    \begin{macrocode}
    \begin{axis}[ddpdefault,%
                 \DD@JK@ddpmode,%
                 #2%
                ]%
}%
{%
    \end{axis}%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{environment}
% \begin{macro}{\mcentry}
% The \cmd\mcentry\ command provides a simple interface for a six column tabular entry needed inside a \env{medicationchart} environment.
%
% \cs{mcentry}\marg{pharmaceutical}\marg{morning}\marg{noon}\marg{evening}\marg{night}\marg{note}
%    \begin{macrocode}
\newcommand*{\mcentry}[6]%
{%
  #1 & #2 & #3 & #4 & #5 & #6 \\%
}%
%    \end{macrocode}
%  \end{macro}
% \begin{environment}{medicationchart}
% The \env{medicationchart} environment allows you to typeset a medication chart. It uses the \package{environ} package to collect
% the environment body in the \cmd\Body\ macro. It is later used in a \texttt{medicationchart} style \texttt{tcolorbox} box.
%
%    \begin{macrocode}
\NewEnviron{medicationchart}[3][]%
{%
  \begingroup%
    \setkeys{diadia}{#1}%
    \tcbox[medicationchart,%
           title={\DD@JK@trans@MedicationChart\space (\DD@JK@trans@issued: #3)},#2]%
    {%
      \renewcommand{\arraystretch}{1.2}%
      \begin{tabularx}{\textwidth-13.64pt}{Z||r|r|r|r||Y}%
        \DD@JK@trans@Pharmaceutical & \DD@JK@trans@Morning & \DD@JK@trans@Noon &%
        \DD@JK@trans@Evening & \DD@JK@trans@Night & \DD@JK@trans@Note\\\hline\hline%
        \BODY%
      \end{tabularx}%
    }%
  \endgroup%
}%
%    \end{macrocode}
% \end{environment}
% \begin{macro}{\infobox}
% The \cmd\infobox\ allows you to typeset arbitrary material into a \texttt{infobox} style \texttt{tcolorbox} box.
%
% \cs{infobox}\marg{tcolorbox options}\marg{date}\marg{info}
%    \begin{macrocode}
\newcommand{\infobox}[3]%
{%
  \begin{tcolorbox}[infobox,title={\DD@JK@trans@Info\space (#2)},#1]%
    #3%
  \end{tcolorbox}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{diadiasidebyside}
% The \env{diadiasidebyside} environment allows you to typeset (narrow) tables and plots sidebyside.
% It supports the \texttt{columnsep}, \texttt{columnseprule} and \texttt{columnseprulecolor} options of the \package{multicol} package.
%
%    \begin{macrocode}
\newenvironment{diadiasidebyside}[1][]%
{%
  \setkeys{diadia}{#1}%
  \setlength{\columnsep}{\DD@JK@columnsep}%
  \setlength{\columnseprule}{\DD@JK@columnseprule}%
  \def\columnseprulecolor{\DD@JK@columnseprulecolor}%
  \pgfplotsset{width=\columnwidth}%
  \begin{multicols}{2}%
}%
{%
  \end{multicols}%
}%
%    \end{macrocode}
% \end{environment}
% \begin{macro}{\setlimit}
% The \cmd\setlimit\ command allows you to add limits to your plot!
%
% \cs{setlimit}\oarg{Tikz options}\marg{limit list}
%    \begin{macrocode}
\newcommand*{\setlimit}[2][]%
{%
  \pgfplotsset{%
                extra y ticks={#2},%
                extra tick style={grid=major, major grid style={setlimit, #1}}%
              }%
}%
%    \end{macrocode}
%  \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale