Artificial-Pancreas / iAPS

MIT License
179 stars 726 forks source link

Extend FPU to pull in external data #165

Open scrappy opened 1 year ago

scrappy commented 1 year ago

Only creating this because it was suggested ... am not sure how to effectively pull this one off, so wasn't going to ask ...

I use an app called myFitnessPal ( there are a few different ones out there ) to calculate my Carb/Fat/Protein values, and right now, manually enter them into iAPS for dosing. mFP has a huge database of foods ( individual foods plus pretty much every restaurant imaginable, and ability for users to add more ), so pretty much anything you can think of can be found ...

Each user has their own sub-database of what they eat ( ie previously looked up ), so I can easily either put together a new meal based on individual components, or store a meal and call that up ( ie. I built up my pizza, from crust through to toppings and just pull that pizza in each time since I alway eat the same pizza ) ...

When you enter food, it does time stamp it / group it, but if you add a food, they only give you 4 categories:

So if I enter a snack in now ( 11:44 ) and another snack later tonight, it shows in Apple Health as one big snack at the same time, not two different snacks ( testing that to double check )

The point being that even though the app writes to Apple Health, not sure how easy it will be to pull the data out due to how it groups the data ... if you pulled in 'the most recent non-iAPS Carb/Fat/Protein values, if I'm correct about how it writes to Apple Health, you could get values later in the day that includes previous values, inflating the numbers.

As I said, am testing to double check ... just added a snack and will add a second one in a few hours ... short term test ( couple of minutes ) appears to validate the 'one big number' theory, but the system may just be seeing the short time between entries as my building my one snack, not as two different ones ... will update ticket in a few hours ...

scrappy commented 1 year ago

Note that I did just find that you can add 2 extra "meals" ( ie. morning, afternoon, evening snacks ) to help break things up a bit instead of one 'big daily snack', which does help

IMG_76BC9D218374-1

scrappy commented 1 year ago

Not sure if this would be useful, but it does have a RESTful API that you can use instead of tapping into Apple Health

https://myfitnesspalapi.com/docs/

But looking at the json results back, it doesn't look at when the entry was made, only the day.

{ "type": "diary_meal", "date": "2014-05-06", "diary_meal": "Lunch", "nutritional_contents": { "energy": { "unit": "calories", "value": 531 }, "fat": 12, "protein": 25, "sugar": 9, "cholesterol": 125, "fiber": 6, "vitamin_a": 35, "vitamin_c": 40 }

But, you could have it setup so that when you go to the Carb Entry page, you could have a list of meal names ( https://myfitnesspalapi.com/docs/appendix-data-structures-diary-preferences/ ) as a drop down box that you choose which meal to use from the app.

So the thought would be that under Settings, you'd maybe have a 'Meal Planning' item, similar to CGM, and under that you can choose which app you are using:

ie. None, myFitnessPal, "Other Apps"

if you choose myFitnessPal, you'd have an api key entry similar to how for Nightscout we have the URL / Access Key ... and then on the carb entry page, if None, its the current setup ... if myFitnessPal, you'd get the drop down for the different meals to pull data, etc

scrappy commented 1 year ago

Just a note, but if something like this does get implemented, having the new 'Note' field auto-filled with:

Source, Diary_Meal

for cross-reference would be cool ... so in the example above, it would be something as simple as:

myFitnessPal, Lunch