diff --git a/app/controllers/patients_controller.rb b/app/controllers/patients_controller.rb index 7df41aa25..77785ef05 100644 --- a/app/controllers/patients_controller.rb +++ b/app/controllers/patients_controller.rb @@ -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? @@ -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( diff --git a/app/helpers/pledges_helper.rb b/app/helpers/pledges_helper.rb index f374342fa..09a115978 100644 --- a/app/helpers/pledges_helper.rb +++ b/app/helpers/pledges_helper.rb @@ -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 + def clinic_pledge_email(patient) email = patient.clinic&.email_for_pledges return unless email diff --git a/app/models/concerns/statusable.rb b/app/models/concerns/statusable.rb index ab1bc9b91..b4ba34d79 100644 --- a/app/models/concerns/statusable.rb +++ b/app/models/concerns/statusable.rb @@ -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') }, }.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 @@ -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? diff --git a/app/models/config.rb b/app/models/config.rb index f8ba9b85d..581b8a60c 100644 --- a/app/models/config.rb +++ b/app/models/config.rb @@ -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.' }.freeze enum config_key: { @@ -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 = { @@ -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], @@ -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 @@ -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 @@ -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 end ### Patient archive @@ -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 end diff --git a/app/views/dashboards/index.html.erb b/app/views/dashboards/index.html.erb index 191e1f290..054ff5c6b 100644 --- a/app/views/dashboards/index.html.erb +++ b/app/views/dashboards/index.html.erb @@ -1,6 +1,6 @@
- <% 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' %> diff --git a/app/views/patients/_complete.html.erb b/app/views/patients/_complete.html.erb new file mode 100644 index 000000000..e277d0b95 --- /dev/null +++ b/app/views/patients/_complete.html.erb @@ -0,0 +1,55 @@ +<% if not patient.marked_complete %> + + + + + +<% else %> + + + + + +<% end %> diff --git a/app/views/patients/_menu.html.erb b/app/views/patients/_menu.html.erb index 5ecca7d35..9976b024c 100644 --- a/app/views/patients/_menu.html.erb +++ b/app/views/patients/_menu.html.erb @@ -1,14 +1,14 @@ diff --git a/app/views/patients/_menu_pledge_button.html.erb b/app/views/patients/_menu_pledge_button.html.erb index 4712e3247..c17d86ff3 100644 --- a/app/views/patients/_menu_pledge_button.html.erb +++ b/app/views/patients/_menu_pledge_button.html.erb @@ -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 %> - <%= 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 %> \ No newline at end of file diff --git a/app/views/patients/complete.js.erb b/app/views/patients/complete.js.erb new file mode 100644 index 000000000..c8e472bcb --- /dev/null +++ b/app/views/patients/complete.js.erb @@ -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 (!@patient.marked_complete) %> + + $('#pledge-modal').modalSteps(); + +<% else %> + $('#cancel-pledge-form').on('submit', function() { + $('.modal').modal('hide'); + }) +<% end %> diff --git a/app/views/patients/edit.html.erb b/app/views/patients/edit.html.erb index 897546c4c..beb2ca023 100644 --- a/app/views/patients/edit.html.erb +++ b/app/views/patients/edit.html.erb @@ -14,9 +14,11 @@ <%= render 'patients/patient_information', patient: @patient %>
+ <% unless Config.practical_support_mode? %>
<%= render 'patients/abortion_information', patient: @patient, new_external_pledge: @external_pledge %>
+ <% end %>
<%= render 'patients/change_log', patient: @patient %> @@ -32,15 +34,15 @@ <% unless Config.hide_practical_support? %> -
- <%= render 'patients/practical_support', patient: @patient, note: @note %> -
+
+ <%= render 'patients/practical_support', patient: @patient, note: @note %> +
+ +
+ <% if current_user.allowed_data_access? && @patient.pledge_sent? %> + <%= render 'patients/fulfillment', patient: @patient %> + <% end %> +
<% end %> - -
- <% if current_user.allowed_data_access? && @patient.pledge_sent? %> - <%= render 'patients/fulfillment', patient: @patient %> - <% end %> -
diff --git a/app/views/patients/update.js.erb b/app/views/patients/update.js.erb index e235e9f2d..8d918cafa 100644 --- a/app/views/patients/update.js.erb +++ b/app/views/patients/update.js.erb @@ -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() diff --git a/config/locales/en.yml b/config/locales/en.yml index 53bda42d6..512214ab2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}' @@ -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 @@ -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. @@ -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 diff --git a/config/locales/es.yml b/config/locales/es.yml index 836480754..8b9a67e13 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -397,6 +397,12 @@ es: change: Cambiar (de -> a) modified_date: Fecha modificada title: Historia del paciente + complete: + body: "¿Este paciente está completo?" + cancel: + confirm: "¿Estás seguro de que deseas marcar a este paciente como incompleto?" + title: Marcar incompleto + title: Confirmar finalización dashboard: approx_gestation: 'Aprox la gestación en la cita: %{weeks} semanas %{days} días' called_on: 'Llamado en: %{date}' @@ -502,6 +508,8 @@ es: call_log: Registro de Llamadas cancel_pledge: Cancelar Promesa change_log: Registro de Cambios + mark_complete: Marcar completo + mark_incomplete: Marcar incompleto notes: Notas patient_information: Información del Paciente pledge_fulfillment: Cumplimiento de la Promesa @@ -585,6 +593,7 @@ es: status: Estatus status: help: + completed: El paciente ha sido marcado como completado para recibir apoyo práctico. dropoff: Paciente no ha sido escuchado en 120+ días. fulfilled: El paciente ha sido marcado cumplido. fundraising: El paciente tiene una cita y está trabajando para recaudar fondos. @@ -595,6 +604,7 @@ es: pledge_unfulfilled: El paciente tenía una promesa enviada hace 150+ días, pero no la ha cobrado. resolved: El paciente ha decidido no involucrar al fondo en sus planes. key: + completed: Apoyo Completado dropoff: Probable Abandono fulfilled: Promesa Cumplida fundraising: Recaudación de fondos diff --git a/config/routes.rb b/config/routes.rb index 8997e7952..d76982012 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,6 +47,7 @@ end get 'patients/:patient_id/submit_pledge', to: 'patients#pledge', as: 'submit_pledge' + get 'patients/:patient_id/mark_complete', to: 'patients#complete', as: 'mark_complete' get 'data_entry', to: 'patients#data_entry', as: 'data_entry' # temporary post 'data_entry', to: 'patients#data_entry_create', as: 'data_entry_create' # temporary diff --git a/db/migrate/20230712194816_add_marked_complete_to_patient.rb b/db/migrate/20230712194816_add_marked_complete_to_patient.rb new file mode 100644 index 000000000..2f31b340f --- /dev/null +++ b/db/migrate/20230712194816_add_marked_complete_to_patient.rb @@ -0,0 +1,5 @@ +class AddMarkedCompleteToPatient < ActiveRecord::Migration[7.0] + def change + add_column :patients, :marked_complete, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index bcde832a8..44a0d670a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_27_181226) do +ActiveRecord::Schema[7.0].define(version: 2023_07_12_194816) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -304,6 +304,7 @@ t.bigint "line_id", null: false t.boolean "solidarity" t.string "solidarity_lead" + t.boolean "marked_complete" t.index ["clinic_id"], name: "index_patients_on_clinic_id" t.index ["fund_id"], name: "index_patients_on_fund_id" t.index ["identifier"], name: "index_patients_on_identifier"