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

Feature/add time to medication alerts #1946

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 49 additions & 3 deletions app/helpers/medications_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ def hidden_props(field, value)
def medication_weekly_dosage
{
type: 'checkboxGroup',
checkboxes: days_checkbox,
# checkboxes: days_checkbox,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being commented out?

label: t('common.days'),
info: t('medications.form.weekly_dosage_hint'),
required: true
}.merge(medication_basic_props('weekly_dosage'))
end

def extra_fields
[medication_weekly_dosage, medication_refill, medication_comments]
[medication_refill, medication_comments]
end

def common_fields
Expand All @@ -107,7 +107,7 @@ def common_fields
medication_unit_field('total'),
medication_field('dosage'),
medication_unit_field('dosage')
].concat(extra_fields).concat(reminder_fields)
].concat(daily_reminder).concat(extra_fields).concat(reminder_fields)
end

def medication_comments
Expand Down Expand Up @@ -141,6 +141,51 @@ def medication_name
}.merge(medication_basic_props('name'))
end

def daily_reminder_checkbox(i)
{
id: "medication_weekly_dosage_#{i}",
type: 'checkbox',
label: t(:'date.abbr_day_names')[i],
name: 'medication[weekly_dosage][]',
checked: @medication.weekly_dosage.include?(i),
value: i,
dark: true
}
end

def daily_reminder_input(i)
{
type: 'time',
name: 'medication[weekly_dosage_time]',
}.merge(medication_basic_props('daily_reminder_input'))
end

def daily_reminder
[
medication_weekly_dosage,
daily_reminder_checkbox(0),
daily_reminder_input(0),

daily_reminder_checkbox(1),
daily_reminder_input(1),

daily_reminder_checkbox(2),
daily_reminder_input(2),

daily_reminder_checkbox(3),
daily_reminder_input(3),

daily_reminder_checkbox(4),
daily_reminder_input(4),

daily_reminder_checkbox(5),
daily_reminder_input(5),

daily_reminder_checkbox(6),
daily_reminder_input(6)
]
end

def medication_refill
{
type: 'date',
Expand Down Expand Up @@ -226,5 +271,6 @@ def medication_field(type)
required: true
}.merge(medication_basic_props(type))
end

end
# rubocop:enable Metrics/ModuleLength
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddTimeToMedicationDailyReminders < ActiveRecord::Migration[6.0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to run a migration (rake db:migrate) in order for the database schema to be updated (https://github.com/ifmeorg/ifme/blob/main/db/schema.rb). This why when you run our RSpec tests you get the following error:

ActiveRecord::PendingMigrationError:


  Migrations are pending. To resolve this issue, run:

          rails db:migrate RAILS_ENV=test
# ./spec/spec_helper.rb:24:in `<top (required)>'
No examples found.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes you made to app/helpers/medications_form_helper.rb will result in failing tests that need to be updated. You should run rspec in your dev environment!

def change
add_column :medications, :sunday, :time
add_column :medications, :monday, :time
add_column :medications, :tuesday, :time
add_column :medications, :wednesday, :time
add_column :medications, :thursday, :time
add_column :medications, :friday, :time
add_column :medications, :staurday, :time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a typo, with the word saturday.

end
end