Topic: Track your blood sugar !

Hello everyone,
I've updated one of my old projects for tracking blood sugar levels (type 2 diabetes) with data entry and graphing.
It does the basic job; the table is incremented via an Add button.
But I'd like to improve it further.
Essentially, I want to be able to separate the table (sqlite.db) into various elements
by year. This allows the user to view their data entries according to the year of their choice, and the graph is updated accordingly. I found an excellent Sparrow program on the forum that did what I'd like to achieve: split the general sqlite.db file into as many files as there are years, which would result in something like: (2023 -> sqlite.db), (2024 -> sqlite.db), and so on, i.e., assign a given year an sqlite.db file containing only the data specific to that year.
Unfortunately, I'm unable to find his project, and especially his method for
splitting the general sqlite.db into as many small sqlite.db files specific to each year (perhaps with SQLStudio?).
I would be very grateful to anyone who could help me make this improvement.
I've already entered the data by year (.csv format, perhaps not the most appropriate?).
Note: I'm freely making this project available to anyone who, like me, would like to track their own blood sugar. You can modify it, add new features, and do anything you can to improve it. In exchange for feedback on your own improvements.

Thanks in advance
JB

Post's attachments

Attachment icon DIAB_YANN.ZIP 775.15 kb, 208 downloads since 2025-08-25 

2 (edited by sparrow 2025-08-25 17:46:58)

Re: Track your blood sugar !

Hi Jean.


You asked about this example ?
I don't know if this is the right way to split the database.

Post's attachments

Attachment icon switch between SQLite base.zip 30.64 kb, 198 downloads since 2025-08-25 

Re: Track your blood sugar !

Maybe it will be easier this way?

Post's attachments

Attachment icon DIAB_YANN m.zip 433.3 kb, 213 downloads since 2025-08-25 

Re: Track your blood sugar !

Be sure to create a backup copy in case something goes wrong!!!
As for creating databases by year, take your common database. Create a copy. Load the copy into SQLStudio. Delete all data by year except 2013.

DELETE FROM DIABETE WHERE strftime('%Y', Date_Prise) <> '2013'

Use the VACUUM command. Exit the program. Save the created database in the 2013 folder.
Create a new copy. Load it into SQLStudio. Delete all data by year except 2014.

DELETE FROM DIABETE WHERE strftime('%Y', Date_Prise) <> '2014'

Use the VACUUM command. Exit the program. Save the created database in the 2014 folder.


Repeat as many times as necessary.

Re: Track your blood sugar !

Hello Sparrow,
Thank you for your quick response.
Your solution works perfectly.
As I had anticipated, you do indeed need to use SQLStudio to achieve this.
For my part, to avoid requiring my project's user to use SQLStudio to achieve this (this superb program is obviously not easy to use), I'm currently testing my own system. Namely:
1 - In the grid, I placed a checkbox for each row.
2 - I made a backup of the original table (let's cover our backs!!!)
3 - I check the rows to be deleted and applied this snippet of code to them:

Procedure Form1_Button10_OnClick (Sender: TObject; var Cancel: boolean); // Mass deletion of grid rows using CheckBoxes
var i,c : integer;
begin
c := Form1.TableGrid1.RowCount - 1; // Count the records in the table
for i :=0 to c do
if Form1.TableGrid1.Cell[0,i].AsBoolean then // If a record is selected
SQLExecute('DELETE FROM Diabetes WHERE id = ' + IntToStr(Form1.TableGrid1.dbIndexToID(i) ));
Form1.TableGrid1.dbUpdate; // Update the table
end;

4 - I save the remaining data, which becomes the current table, and transfer it to a unique folder for each (2007, 2008, etc.) using the code you provided.
5 - From a ComboBox, I display the year I'm looking for, which shows the data specific to that year.
6 - The graph refreshes automatically, and that's it!
7 - Since computers are for lazy people, I'm even going to create a piece of code that allows me to delete
the years to be throw away all at once. No need to click each checkbox individually.

Thanks again for your help, as it makes things much easier for me.

Note: Oddly enough, my program throws an error with version 6.6.1 of MVD (the ChartLine keyword is causing problems).
So, I upgraded to version 6.3 and it works fine. Strange!

JB

6 (edited by sparrow 2025-08-26 18:21:12)

Re: Track your blood sugar !

Jean, you really want a more complicated way ))).


Jean, look at my example at the end of the script, there is a note "Moved to the bottom section.".
Part of the code has been moved to the "begin end." section.
This will fix the error in newer versions. In 6.5, no error.

Re: Track your blood sugar !

Hello Sparrow
You're right, Sparrow.
I was too hasty! I read your instructions carefully, but I didn't follow them.
After doing so, everything went back to normal and works perfectly.
Thanks again,
JB.

Re: Track your blood sugar !

Hi Jean, I found your project interesting! I adapted it to my needs (the most widely used language and metric for diabetes in Brazil). I've included a few modifications...

Post's attachments

Attachment icon GLICONTROL.zip 672.2 kb, 202 downloads since 2025-08-27 

Roberto Alencar

Re: Track your blood sugar !

jrga wrote:

Hi Jean, I found your project interesting! I adapted it to my needs (the most widely used language and metric for diabetes in Brazil). I've included a few modifications...


Hi Roberto


This will fix the display in the year filter (cbo_ano)

procedure Form1_cbo_ano_OnEnter (Sender: TObject);
begin
    form1.cbo_ano.dbSQL := 'select distinct strftime("%Y", Date_Prise) id, strftime("%Y", Date_Prise) from diabete order by date_prise';
    form1.cbo_ano.dbUpdate;
end;

Re: Track your blood sugar !

sparrow wrote:
jrga wrote:

Hi Jean, I found your project interesting! I adapted it to my needs (the most widely used language and metric for diabetes in Brazil). I've included a few modifications...


Hi Roberto


This will fix the display in the year filter (cbo_ano)

procedure Form1_cbo_ano_OnEnter (Sender: TObject);
begin
    form1.cbo_ano.dbSQL := 'select distinct strftime("%Y", Date_Prise) id, strftime("%Y", Date_Prise) from diabete order by date_prise';
    form1.cbo_ano.dbUpdate;
end;

Thank you Sparrow!

Roberto Alencar

Re: Track your blood sugar !

Hello jrga
Thank you for your quick involvement in my blood sugar monitoring project.
There are many new interesting features or modifications you've made:
- Added the day to the measurement date format (useful when taking multiple measurements in one day)
- I hadn't coded the complete redisplay all  the table after clearing the filters. It's now done.
- You added additional filters to the sorts (useful in the case of different types of diabetes).
- I noticed that the help you added mentions Absolute Database. Perhaps it was coded in a previous program made with Delphi?
Because the proposed help deals exclusively with types of diabetes and their characteristics. Useful for anyone who wants to access this information directly from the program. - I didn't initially include a Status column in the grid because my blood glucose values are entered in mmL/L, but I'm going to provide an option allowing the user to choose between one or the other calculation modes.

Thank you very much for your feedback on my program and your improvements.
Kind regards,
JB

12 (edited by jrga 2025-08-28 13:34:36)

Re: Track your blood sugar !

Hi Jean, I added a button to delete the contents of the DIABETE table, allowing a new user to start their measurement history. I also added a question at the end, "if a backup is made," if any changes were made to the database. I created the Help.chm with the MyNotesKeeper application.


Dear Sparrow, the SQLite statement you suggested for updating cbo_ano was already contained in the script... thanks anyway!

Post's attachments

Attachment icon GLICONTROL 2.zip 675.16 kb, 184 downloads since 2025-08-28 

Roberto Alencar

Re: Track your blood sugar !

Hi Jean, Roberto

Ok. )
In order for the program to work and not stop by error in version 6.5 (what I checked), some changes need to be made.

1. Change in the "Form1_OnShow" procedure. The diagram initialization must occur before accessing them in the checkboxes. Otherwise, an error.
2. When selecting the year filter (cbo_ano), the year value disappears after updating the tables and graphs. That is why a small correction to the query was suggested above.

I am posting the corrected version so that users of new versions of MVD can launch and work with the program.


Best regards, sparrow.

Post's attachments

Attachment icon GLICONTROL 2 m.rar 334.98 kb, 222 downloads since 2025-08-28 

Re: Track your blood sugar !

sparrow wrote:

Hi Jean, Roberto

Ok. )
In order for the program to work and not stop by error in version 6.5 (what I checked), some changes need to be made.

1. Change in the "Form1_OnShow" procedure. The diagram initialization must occur before accessing them in the checkboxes. Otherwise, an error.
2. When selecting the year filter (cbo_ano), the year value disappears after updating the tables and graphs. That is why a small correction to the query was suggested above.

I am posting the corrected version so that users of new versions of MVD can launch and work with the program.


Best regards, sparrow.

Now I understand, thank you!

Roberto Alencar

Re: Track your blood sugar !

Hello Sparrow, jrga
Sparrow,Thank you for all your improvments
JB

16 (edited by Destiny 2025-08-29 05:17:27)

Re: Track your blood sugar !

This is a great program that will be useful to many people. I've translated it into French for those who are interested.
Congratulations and thank you to the users.
-----------------------------------
C'est un super programme qui sera utile a beaucoup de personnes, je l'ai traduit en Français pour ceux que ça interresse.
Bravo et merçi pour les utilisateurs.

Post's attachments

Attachment icon GLICONTROL FR (diabète).zip 663.85 kb, 212 downloads since 2025-08-29 

Destiny

Re: Track your blood sugar !

Finally, I thought it was important to include the ability to print the table grid's content (filtered or not) using the "print" button. This will make it easier if the user needs to show a report of the measurements they took to their doctor.

Post's attachments

Attachment icon GLICONTROL 3.zip 678.29 kb, 231 downloads since 2025-08-28 

Roberto Alencar

Re: Track your blood sugar !

Hello jrga
Well seen with a Print Button.
I see that my original program is moving in the right direction.
Thank you all!
JB

Re: Track your blood sugar !

Hello All,
Seeing as we all seem to be looking after our health(!), attached is a program that I've used over the years to monitor blood pressure and pulse rate.
Select a month / year to see an overview of readings and to keep it simple, data is entered on the same screen using an editable tablegrid.
If anyone finds it useful, please feel free to use / improve (the sample data has been randomised - otherwise it would not be looking good for me sad).
Regards,
Derek.

Post's attachments

Attachment icon blood pressure.zip 759.62 kb, 216 downloads since 2025-08-29 

Re: Track your blood sugar !

Hello Derek,
I've been looking forward to your talk.
With all the stakeholders in the health field, we'll be able to
create a startup to write softwares for our well-being!
Regards,
JB