Medication Reminder (again)

You could use the AfterTimeSet event for that, calculate the correct alarm time there and store it in TinyDB...

Anorher thing to consider...
You are storing several alarm times in TinyDB...

But in the Clock Timer event currently you compare the last picked alarm time and the current time...

What is missing is to detect the next alarm time and do the comparison for that in the Clock Timer event

Also when there was an alarm, then again detect the next alarm time

Taifun

I can send you the .aia soo you can check out...
HealthMate_versao4.aia (120.5 KB)

And how exactly would I do that?

Do it step by step, try something and if you got stuck, post a screenshot of your relevant blocks

Taifun

I tried something, I don't know if it works or no...
This just feels wrong

To find out if you store the correct alarm time, what about doing a test?

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

The blocks don't look too bad...

However remember, you use the alarm time as tag... but now additionally you store it again as 4th item in the list. Can you explain why you are doing that?

Also you have chosen to ignore the date and store only the time... does this make sense?

Taifun

I've tried the "Do it" feature, but I'm still having trouble understanding the blocks. I can't tell if the blocks are correct or not.

I added it as the fourth item in the list because I wanted it to appear when selected in the list view. However, now that I think about it, this approach doesn't make much sense.

I also ignored the date initially because it didn't look good in the list view, but I plan to put it back.

Update: I tested the app by building it, but the problem still persists.

Thank you. I am not a Spanish speaker so this is difficult to find where the problem with respect to Description is located Dose seems to work sometimes.


but not always. I do not know why. Sorry.

It's fine, by the way, it's portuguese not spanish but it's very close... Anyways, can you help me with this other problem?

Additionally, there's another issue. On the screen where you add medication, if someone sets the alarm for a time that refers to the next day (like 4 AM when it's currently 4 PM), the alarm will go off immediately because 4 AM is earlier than 4 PM.

yes of course the problem still persists, because it occurs in the Clock Timer event... up to now you did not update it...

here is your to do list again

So to fix your problem all you have to do is to detect the next alarm time from the list TinyDB.GetTags and use that time in the Clock Timer event instead of the latest picked time as you are doing it currently
unknown

Taifun

And how exactly do I do the "detect the next alarm" part?


Is it just this? Am I missing something?
And what about that whole "If the alarm time is lower than the current time then add a day"?

Well, you are again putting blocks randomly together... is TinyDB.GetTags an instant? And if you do not know the answer, then what about using Do it to find it out?

Screenshot_20240706_060904_DuckDuckGo

To be able to find the smallest item in a list it is helpful to have a list in a format, which is easy to sort...

In your case you have alarm times as items
The alarm time could be stored for example as millis (milliseconds) or in a format like yyyy-MM-dd HH:mm example: 2024-07-06 06:21 ( current time here in Costa Rica)

For the available patterns see here SimpleDateFormat (Java Platform SE 7 )

Then just use the sort list in ascending order block from the list drawer to sort the list

http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/blocks/lists.html#sort

The first item in the list is the next alarm time you are looking for

You could write a procedure for that
http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/blocks/procedures.html

You do that before storing an alarm time in TinyDB

Taifun

This is overwhelming for me. I'm giving it my all, but I don't feel capable of handling everything at once. I'm struggling to figure it all out.

What shoud I put on the comparison? How do I sort the list in ascending order with the blocks in the guide? And should the procedure do? I'm soo confused...

So which format did you choose?
Show us a screenshot of a TinyDB.GetTags block together with a Do it result

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Taifun is recommending you redo a major part of your Project to achieve a new feature you want You probably don't have enough time to do that and submit your Project on the 9th; so don't add the feature. Instead get all the other parts of your app to work.

I doubt I could do all he is recommending in the time available. :thinking: and am not sure I could implement his advice.

Do what you can. And provide a screenshot of a TinyDB.GetTags block together with a Do it result as Taifun requests. After you do it perhaps he will provide some Blocks to help you. Provide a screenshot oof the GetTags, not the format you provided.

The format is: dd-MM-yyyy HH:mm(that's the one we use here in portugal)
And the Do It printscreen is of the get tags in the listview screen, right?

That format is not useful to sort...
You have to differentiate 2 things, 1) to store the data and 2) to display the data
And you always can convert data from a format as it is stored to a better readable fornat to display it

It does not matter from where

Actually I'm not doing that
And for the record, this was my suggestion already a few days ago

To get the smallest item from the list you put 3 blocks together like this

  1. Select list item (to select the first item)
  2. sort list in ascending order
  3. TinyDB.GetTags

Taifun

image
Here is the result of the get tags

Ok, very good... you have stored currently one alarm time...
Now as already said..

What about storing millis in the database? This would make it very easy to sort... and to display it in the listview, you convert it into readable format

Taifun