Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add time support for Medications #1601

Open
julianguyen opened this issue Nov 5, 2019 · 17 comments
Open

Add time support for Medications #1601

julianguyen opened this issue Nov 5, 2019 · 17 comments

Comments

@julianguyen
Copy link
Member

Description

Currently, users can specify the days they want to be notified of Medication reminders. This notification is sent at 12:00 am, at the beginning of each day. We want to add ability to specify the time for each day of the week.

Screenshots

Currently:

image


Please assign yourself (via the Assignees dropdown), if you do want to work on this issue. Can't find yourself? You need to join our organization.

Check out our Picking Up Issues guide if you haven't already!

@anGie44
Copy link

anGie44 commented Nov 12, 2019

@julianguyen is there a specific uicomponent in mind for listing out the times of day? dropdown or checkboxes for example

@julianguyen
Copy link
Member Author

@anGie44 Yes, good question! You should be able to use the <Input /> component and pass in type="time". We should add examples for this and type="date" in our Storybook but here's a link to <Input type="text" /> to get you started: http://design.if-me.org/?path=/story/input--text

@SonuToor
Copy link
Contributor

Hi @anGie44,

I was wondering if you're still working on this issue? It's been a while since I contributed to if-me and I was looking for something to work on. If you'd like help or if you're not working on this issue anymore let me know!

@SonuToor
Copy link
Contributor

SonuToor commented Jan 8, 2020

Hi @julianguyen,

It's been a while since I contributed and I was looking for something to do. I reached out to @anGie44 to see if she was still active on this issue, I don't think she is.

Should I wait a bit longer or do you think it's safe to take this issue on?

@julianguyen
Copy link
Member Author

Go ahead and assign it to yourself @SonuToor. Thanks for reaching out! :D

@SonuToor SonuToor self-assigned this Jan 9, 2020
@SonuToor
Copy link
Contributor

Hi @julianguyen ,

Just have a couple of questions to clarify the nature of the new feature.

When a user sets a time, is that time for every single day? Or should a user be able to set a separate time for every single day?

@julianguyen
Copy link
Member Author

julianguyen commented Jan 13, 2020

Or should a user be able to set a separate time for every single day?

This is what we want! Good question @SonuToor :)

We could add a checkbox for setting the same time daily, but we should give users the ability to fine-tune time for each day.

@SonuToor
Copy link
Contributor

SonuToor commented Jan 13, 2020

@julianguyen so the time input that I am creating is for the reminder to take the medication not the refill reminder correct?

So maybe below the checkboxes for the days of the week have a checkbox that is by default checked that sets it to same time daily. Then if the user unchecks this checkbox, we then display each day that is currently checked, with a corresponding component of type time, whereby they can set a separate time for every selected day?

@julianguyen
Copy link
Member Author

@SonuToor Correct that it's a reminder for when to take the medication!

That sounds like a good experience to me! Thanks!

@SonuToor
Copy link
Contributor

SonuToor commented Jan 16, 2020

Hey @julianguyen,

So I played around with the code. I get the checkbox that toggles whether the medication is taken at the same time daily to render. Now unfortunately my skills on the backend (and Ruby) aren't fully there yet to handle the next steps.

So I want the checking and unchecking of the checkbox to be stored in postgres and then depending on whether the value is checked (true) or unchecked (false) I want to conditionally render inputs that allow the user to input times for each day they take the medication.

Now I'd have no problem creating the inputs in React or adapting existing input components to fit the need, but the back end code to make it happen I need some help on.

I am going to start a thread in the #dev channel and ask for some help, but if you have some pointers you could give me it would be super helpful as well.

*edit I have a new branch on my fork for this issue the link is:
https://github.com/SonuToor/ifme/tree/1601

@julianguyen
Copy link
Member Author

Hey @SonuToor! You're correct about storing the checkbox data in Postgres!

So you'll want to create a DB migration to add columns to the Medications table. You should the rails generate migration command to generate migration files, you can read more about it here.

The table you'll want to modify is Medication. Currently, we use the weekly_dosage column to store the days of the week (with numbers).

Possible Solutions

(1) Keep weekly_dosage

If we want to preserve weekly_dosage, then I recommend adding new columns for each day of the week to indicate time. Something like: monday_time, tuesday_time, etc.

Pros

  • We don't have to run a separate migration to copy over existing weekly_dosage data in the production database.

Cons

  • We need to make sure we are only updating the new time values if the corresponding weekly_dosage values exist.

(2) Get rid of weekly_dosage

If we want to get rid of weekly_dosage, then I recommend storing the data as follows:

monday: time OR nil
tuesday: time OR nil
etc.

Pros

  • We just have to update one column for each day of the week.

Cons

  • We have to run a separate migration to copy over existing weekly_dosage data in the production database. We have to make a decision about what time to set for days of the week the user has selected. We can either set a time ourselves OR prompt the user to do so in the app.

Recommended Solution

So I actually recommend doing both. (1) will work for existing users who have weekly_dosage set and (2) will work for users afterwards. At a later time, we can run a migration to get rid of data from (1) so that (2) becomes the only solution.

@SonuToor
Copy link
Contributor

Thanks for such a detailed response @julianguyen !

As I mentioned in the slack chat I agree with your solution, it is pragmatic, a bit more work is required but worth it imo.

So, I think it would be best to tackle it in order. So implement solution 1, then implement solution 2.

As far as I can tell in either path we would have the checkbox that sets the time uniformly for each day? That would also be stored in the Medications table? Then after that go to add the columns for monday_time, tuesday_time etc. After that I could go on to add the UI components that allow the user to input medication times?

I'm going to read the link you provided about db migrations, as it's something I've not done before. I'll need some guidance on modifying the table as well, would that be found under ruby docs?

Let me know what you think about my plan and of course any guidance or tips would be appreciated!

@developer22-university
Copy link
Contributor

@julianguyen i want to join slack channel , i have also mailed you, want to talk with you please contact me

@rutger-t
Copy link

Hi @SonuToor

I was wondering if you are still working on this issue.
Let me know if you are, then I will grab another issue!

@SonuToor
Copy link
Contributor

@rutger-t I've been quite busy, so you can take it up!

The conversation between me and Julia above will be quite helpful!

@marthaerm
Copy link

Hi! @julianguyen I was looking at this issue and I would like to know if there is someone working on this? I would like to give it a try :)

@rutger-t
Copy link

Hi! @julianguyen I was looking at this issue and I would like to know if there is someone working on this? I would like to give it a try :)

Hi Marthaerm,

I got a bit busy so please go ahead and take it

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants