Creating wait time function

What I’m trying to do:

We are a group of students working on a project and we are trying to create a website that replaces a waiting room for a doctors office. We’re trying to make it so each user has a certain wait time till their scheduled appointment time. Is it possible to make a timer that will count down from the selected date to zero? If it isn’t possible to create a timer function, is there any other way we could create something similar?

What I’ve tried and what’s not working:

We’ve tried using the timer component provided in the toolbox on Anvil, but we’re not sure how we could use it for our specific purpose.

Clone link:
https://anvil.works/build#clone:GZGYW477SAT7JU7V=EJD52TKTBN2KS5OZKSXAQVTG

admin username: admin@admin.com
password: 12345

patient username: rebecca.bae@quinnipiac.edu
patient password: 12345

Anvil’s built-in Timer component, by itself, might not work for such long durations. I had some difficulties with that in the past. Use it for relatively short durations (a few hours at most), and handle the rest with some other code.

my answer would be to use the timer function - but not in the way you think.

I would use it to update the running counter to display the comparison of the time of ‘now’ to the stored future time you are waiting for for the patients waiting in the waiting room.

In other-words, the timer function would:

  1. check to see first if it had a stored future time (the appointment) to display.

  2. if not, grab the appointment info.

  3. compare the appointment info by subtracting the ‘now’ time object from the future datetime object (an appointment) to get a timedelta object (an object representing the amount of time between ‘now’ and ‘a future time’)

  4. Use the timedelta object to update a countdown on the screen (days, weeks, minutes, hours, seconds is up to you)

This could update every 5 minutes, 5 seconds, 1 seconds, or whatever you wish.

You could store future patient appointment time in the data tables, as long as this is really a test environment and the patient info is fake in the USA. See: HIPAA - Health Insurance Portability and Accountability Act

Otherwise I would use anvil uplink from inside a secure network - to a function in the server module in anvil - then to the client page - and provide only the exact info requested in a python object for that individual person.
The server module function could also check again that the user should be able to access the data before providing it to the browser.

2 Likes