Skip to content
Draft
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
9 changes: 8 additions & 1 deletion app/controllers/patients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def pledge
end
end

def complete
@patient = Patient.find params[:patient_id]
respond_to do |format|
format.js
end
end

# download a filled out pledge form based on patient record
def download
if params[:case_manager_name].blank?
Expand Down Expand Up @@ -189,7 +196,7 @@ def find_patient_minimal
:fund_payout, :check_number, :date_of_check, :audited]
].freeze

OTHER_PARAMS = [:shared_flag, :initial_call_date, :pledge_sent].freeze
OTHER_PARAMS = [:shared_flag, :initial_call_date, :pledge_sent, :marked_complete].freeze

def patient_params
permitted_params = [].concat(
Expand Down
16 changes: 16 additions & 0 deletions app/helpers/pledges_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ def cancel_pledge_button
end
end

def mark_complete_button
content_tag :span, class: 'btn btn-primary btn-lg submit-btn btn-block',
aria: { hidden: true },
id: 'submit-pledge-button' do
t('patient.menu.mark_complete')
end
end

def mark_incomplete_button
content_tag :span, class: 'btn btn-warning btn-lg cancel-btn btn-block',
aria: { hidden: true },
id: 'submit-pledge-button' do
t('patient.menu.mark_incomplete')
end
end

Comment on lines +19 to +34
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two functions look extremely similar to the submit pledge button pair (above). Thoughts on condensing, or fine to keep separate?

Copy link
Member

Choose a reason for hiding this comment

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

I'd say keep separate - reasonable for them to diverge a bit here

def clinic_pledge_email(patient)
email = patient.clinic&.email_for_pledges
return unless email
Expand Down
9 changes: 8 additions & 1 deletion app/models/concerns/statusable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ module Statusable
dropoff: { key: I18n.t('patient.status.key.dropoff'),
help_text: I18n.t('patient.status.help.dropoff')},
resolved: { key: I18n.t('patient.status.key.resolved', fund: ActsAsTenant.current_tenant&.name),
help_text: I18n.t('patient.status.help.resolved')}
help_text: I18n.t('patient.status.help.resolved')},
completed: { key: I18n.t('patient.status.key.completed'),
help_text: I18n.t('patient.status.help.completed') },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do we use help_text for? I wasn't able to find a reference

Copy link
Member

Choose a reason for hiding this comment

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

These show up in the Status tooltip on patient records!

image

}.freeze

def status
return STATUSES[:completed][:key] if practical_support_completed?
return STATUSES[:fulfilled][:key] if fulfillment.fulfilled?
return STATUSES[:resolved][:key] if resolved_without_fund?
return STATUSES[:pledge_unfulfilled][:key] if days_since_pledge_sent > 150
Expand All @@ -36,6 +39,10 @@ def status

private

def practical_support_completed?
Config.practical_support_mode? && marked_complete?
end

def contact_made?
calls.each do |call|
return true if call.reached_patient?
Expand Down
33 changes: 23 additions & 10 deletions app/models/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Config < ApplicationRecord
hide_budget_bar: 'Enter "yes" to hide the budget bar display.',
aggregate_statistics: 'Enter "yes" to show aggregate statistics on the budget bar.',
hide_standard_dropdown_values: 'Enter "yes" to hide standard dropdown values. Only custom options (specified on this page) will be used.',
time_zone: "Time zone to use for displaying dates. Default is Eastern. Valid options are Eastern, Central, Mountain, Pacific, Alaska, Hawaii, Arizona, Indiana (East), or Puerto Rico."
time_zone: "Time zone to use for displaying dates. Default is Eastern. Valid options are Eastern, Central, Mountain, Pacific, Alaska, Hawaii, Arizona, Indiana (East), or Puerto Rico.",
practical_support_mode: 'Enter "yes" to enable practical-support-only mode. Pledges will be disabled.'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
practical_support_mode: 'Enter "yes" to enable practical-support-only mode. Pledges will be disabled.'
practical_support_mode: 'Enter "yes" to enable practical-support-only mode. Pledges will be disabled, in in favor of marking people complete/incomplete.'

}.freeze

enum config_key: {
Expand All @@ -46,18 +47,18 @@ class Config < ApplicationRecord
aggregate_statistics: 17,
hide_standard_dropdown_values: 18,
county: 19,
time_zone: 20
time_zone: 20,
practical_support_mode: 21,
}

# which fields are URLs (run special validation only on those)

# symbols are required here because functions are not objects in rails :)
CLEAN_PRE_VALIDATION = {
start_of_week: [:fix_capitalization],
hide_practical_support: [:fix_capitalization],
language: [:fix_capitalization],
county: [:fix_capitalization],
time_zone: [:titleize_capitalization]
time_zone: [:titleize_capitalization],
practical_support_mode: [:fix_capitalization],
}.freeze

VALIDATIONS = {
Expand All @@ -82,7 +83,7 @@ class Config < ApplicationRecord
[:validate_singleton, :validate_time_zone],

hide_practical_support:
[:validate_singleton, :validate_yes_or_no],
[:validate_yes_or_no, :validate_only_one_practical_support],

budget_bar_max:
[:validate_singleton, :validate_number],
Expand All @@ -102,11 +103,13 @@ class Config < ApplicationRecord
[:validate_singleton, :validate_shared_reset],

hide_budget_bar:
[:validate_singleton, :validate_yes_or_no],
[:validate_yes_or_no],
aggregate_statistics:
[:validate_singleton, :validate_yes_or_no],
[:validate_yes_or_no],
hide_standard_dropdown_values:
[:validate_singleton, :validate_yes_or_no],
[:validate_yes_or_no],
practical_support_mode:
[:validate_yes_or_no, :validate_only_one_practical_support],
}.freeze

before_validation :clean_config_value
Expand Down Expand Up @@ -194,6 +197,10 @@ def self.hide_standard_dropdown?
config_to_bool('hide_standard_dropdown_values')
end

def self.practical_support_mode?
config_to_bool('practical_support_mode')
end

private
### Generic Functions

Expand Down Expand Up @@ -308,7 +315,7 @@ def validate_time_zone

def validate_yes_or_no
# allow yes or no, to be nice (technically only yes is considered)
options.last =~ /\A(yes|no)\z/i
validate_singleton and options.last =~ /\A(yes|no)\z/i
Copy link
Member

Choose a reason for hiding this comment

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

great rails

end

### Patient archive
Expand All @@ -335,4 +342,10 @@ def validate_length
end
true
end

def validate_only_one_practical_support
# TODO - Should not be able to use both practical support configs at the
# same time.
true
end
Comment on lines +345 to +350
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After this is done, I'm thinking about opening a separate issue to combine "practical support mode" and "hide practical supports" into a single option — practical supports only, on, off. in the interim, should we have some validation? Weird things will happen if we turn on both options.

How would that best work? We can't compare the actual saved values because on validation, the submitted value has not yet been committed. We could have a conditional check based on the option key?

Copy link
Member

Choose a reason for hiding this comment

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

Let me say a bit more about the thinking here, and let's see if that makes sense with how you're thinking about it. I think there are three possible states:

  • fund is not doing practical support at all (in which case we'd want to hide these options) - unusual but it happens
  • fund is doing pledges AND practical support - most of our clientele
  • fund is doing zero pledges, ONLY practical support - unusual but it happens

So I think you're def right that 'hide practical support on' and 'practical support only on' doesn't make sense, but I think the other cases (hide off, practical only on; hide on, practical only off; hide off, practical only off) are cases I think we'd like to support. Does that match your understanding?

end
2 changes: 1 addition & 1 deletion app/views/dashboards/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row">
<div class="col-sm-12">
<% unless Config.hide_budget_bar? %>
<% unless Config.hide_budget_bar? or Config.practical_support_mode? %>
<%= render partial: 'dashboards/overview' %>
<% end %>
<%= render partial: 'dashboards/search_form' %>
Expand Down
55 changes: 55 additions & 0 deletions app/views/patients/_complete.html.erb
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you think about this modal? i don't know if we need any confirmation steps, so maybe we don't even need the modal - just the button?

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 yes to the modal -- an extra UX step to signify 'this is a significant action' is helpful (and helps prevent problems from misclicks)

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<% if not patient.marked_complete %>
<div class="modal-header">
<h4 class="modal-title"><%= t('patient.complete.title') %></h4>
</div>

<div class="modal-body">
<div class="row">
<%= t('patient.complete.body') %>
</div>
</div>

<div class="modal-footer">
<div class="col">
<button type="button" class="btn btn-outline-secondary js-btn-step float-left" style="color:red;" data-dismiss="modal"><%= t('common.no') %></button>
</div>

<div class="col">
<%= bootstrap_form_with model: @patient,
html: { id: 'submit-pledge-form' },
local: false,
method: 'patch',
class: 'edit_patient' do |f| %>
<%= f.hidden_field :marked_complete, value: true %>
<%= f.submit t('common.yes'), class: "btn btn-success js-btn-step float-right", id: 'submit-pledge-submit'%>
<% end %>
</div>
</div>
<% else %>
<div class="modal-header">
<h4 class="modal-title"><%= t('patient.complete.cancel.title') %></h4>
</div>

<div class="modal-body">
<div class="row">
<p><%= t('patient.complete.cancel.confirm') %></p>
</div>
</div>

<div class="modal-footer">
<div class="col">
<button type="button" class="btn btn-outline-secondary js-btn-step float-left" style="color:red;" data-dismiss="modal"><%= t('common.no') %></button>
</div>

<div class="col">
<%= bootstrap_form_with model: @patient,
html: { id: 'cancel-pledge-form' },
local: false,
method: 'patch',
class: 'edit_patient' do |f| %>
<%= f.hidden_field :marked_complete, value: false %>
<%= f.submit t('common.yes'), class: "btn btn-success js-btn-step float-right", id: 'cancel-pledge-submit'%>
<% end %>
</div>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/patients/_menu.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div id='menu-content' class="row mt-5">
<div class="nav nav-pills flex-column abortion-left-menu" id='menu-list' role='tablist' aria-orientation="vertical">
<%= render 'menu_item', link_for: 'patient_information', active: true %>
<%= render 'menu_item', link_for: 'abortion_information', active: false %>
<%= render 'menu_item', link_for: 'abortion_information', active: false unless Config.practical_support_mode? %>
<%= render 'menu_item', link_for: 'practical_support', active: false unless Config.hide_practical_support? %>
<%= render 'menu_item', link_for: 'notes', active: false %>
<%= render 'menu_item', link_for: 'change_log', active: false %>
<%= render 'menu_item', link_for: 'call_log', active: false %>

<% if current_user.allowed_data_access? && patient.pledge_sent? %>
<%= render 'menu_item', link_for: 'pledge_fulfillment', active: false %>
<%= render 'menu_item', link_for: 'pledge_fulfillment', active: false unless Config.practical_support_mode? %>
<% end %>
</div>
</div>
Expand Down
40 changes: 28 additions & 12 deletions app/views/patients/_menu_pledge_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<% if not patient.pledge_sent? %>
<%= link_to submit_pledge_button,
submit_pledge_path(patient),
class: 'submit-pledge-button',
aria: { label: t('patient.menu.submit_pledge') },
remote: true %>
<% if Config.practical_support_mode? %>
<% if not patient.marked_complete? %>
<%= link_to mark_complete_button,
mark_complete_path(patient),
class: 'submit-pledge-button', # reuse classes from submit pledge button
aria: { label: t('patient.menu.mark_complete') },
remote: true %>
<% else %>
<%= link_to mark_incomplete_button,
mark_complete_path(patient),
class: 'submit-pledge-button',
aria: { label: t('patient.menu.mark_incomplete') },
remote: true %>
<% end %>
<% else %>
Comment on lines +1 to 15
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same question here as with the button controller function - very similar code between in/complete and submit/cancel.

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 reasonable to collapse this one if you like. Up to you!

<%= link_to cancel_pledge_button,
submit_pledge_path(patient),
class: 'submit-pledge-button',
aria: { label: t('patient.menu.cancel_pledge') },
remote: true %>
<% end %>
<% if not patient.pledge_sent? %>
<%= link_to submit_pledge_button,
submit_pledge_path(patient),
class: 'submit-pledge-button',
aria: { label: t('patient.menu.submit_pledge') },
remote: true %>
<% else %>
<%= link_to cancel_pledge_button,
submit_pledge_path(patient),
class: 'submit-pledge-button',
aria: { label: t('patient.menu.cancel_pledge') },
remote: true %>
<% end %>
<% end %>
17 changes: 17 additions & 0 deletions app/views/patients/complete.js.erb
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ergh i hate this but is it ok?

Copy link
Member

Choose a reason for hiding this comment

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

this reads as ok to me, what's the issue?

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$('.modal-content').html('')
$('.modal').attr('id', 'pledge-modal')
$('.modal-content').append(
'<%= escape_javascript(render partial: "patients/complete", locals: { patient: @patient, disable_next: disable_continue?(@patient) })%>'
);

$('.modal').modal('toggle');

<% if ([email protected]_complete) %>

$('#pledge-modal').modalSteps();

<% else %>
$('#cancel-pledge-form').on('submit', function() {
$('.modal').modal('hide');
})
<% end %>
20 changes: 11 additions & 9 deletions app/views/patients/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
<%= render 'patients/patient_information', patient: @patient %>
</div>

<% unless Config.practical_support_mode? %>
<div id="abortion_information" class="abortion-info tab-pane">
<%= render 'patients/abortion_information', patient: @patient, new_external_pledge: @external_pledge %>
</div>
<% end %>

<div id="change_log" class="change-log tab-pane">
<%= render 'patients/change_log', patient: @patient %>
Expand All @@ -32,15 +34,15 @@


<% unless Config.hide_practical_support? %>
<div id="practical_support" class="practical_support tab-pane">
<%= render 'patients/practical_support', patient: @patient, note: @note %>
</div>
<div id="practical_support" class="practical_support tab-pane">
<%= render 'patients/practical_support', patient: @patient, note: @note %>
</div>

<div id="pledge_fulfillment" class="pledge-fulfillment-info tab-pane">
<% if current_user.allowed_data_access? && @patient.pledge_sent? %>
<%= render 'patients/fulfillment', patient: @patient %>
<% end %>
</div>
<% end %>

<div id="pledge_fulfillment" class="pledge-fulfillment-info tab-pane">
<% if current_user.allowed_data_access? && @patient.pledge_sent? %>
<%= render 'patients/fulfillment', patient: @patient %>
<% end %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/patients/update.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $('#change_log').html(
$('#patient_shared_flag').prop('checked', <%= @patient.shared_flag? %>);

// if pledge is sent, re-rack fulfillment info
<% if current_user.allowed_data_access? && @patient.pledge_sent? %>
<% if current_user.allowed_data_access? && !Config.practical_support_mode && @patient.pledge_sent? %>
// populate the fulfillment form if it's supposed to be there and not there already
if ($('#pledge_fulfillment-menu-item').length == 0) {
$('#pledge_fulfillment').empty()
Expand Down
10 changes: 10 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@ en:
change: Change (from -> to)
modified_date: Modified Date
title: Patient history
complete:
body: Is this patient completed?
cancel:
confirm: Are you sure you want to mark this patient incomplete?
title: Mark Incomplete
title: Confirm Completion
dashboard:
approx_gestation: 'Approx gestation at appt: %{weeks} weeks %{days} days'
called_on: 'Called on: %{date}'
Expand Down Expand Up @@ -502,6 +508,8 @@ en:
call_log: Call Log
cancel_pledge: Cancel pledge
change_log: Change Log
mark_complete: Mark Complete
mark_incomplete: Mark Incomplete
notes: Notes
patient_information: Patient Information
pledge_fulfillment: Pledge Fulfillment
Expand Down Expand Up @@ -585,6 +593,7 @@ en:
status: Status
status:
help:
completed: Patient has been marked completed for practical support.
dropoff: Patient has not been heard from in 120+ days.
fulfilled: Patient has been marked fulfilled.
fundraising: The patient has an appointment date, and is working on raising funds.
Expand All @@ -595,6 +604,7 @@ en:
pledge_unfulfilled: Patient had a pledge sent 150+ days ago but has not cashed it.
resolved: Patient has decided to not involve the fund in their plans.
key:
completed: Support Completed
dropoff: Probable Dropoff
fulfilled: Pledge Fulfilled
fundraising: Fundraising
Expand Down
Loading