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 optional practical_support_waiver field to patient behind a Config #3259

Merged
merged 11 commits into from
Sep 8, 2024
2 changes: 1 addition & 1 deletion app/controllers/patients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def respond_to_update_for_json_format
: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, :practical_support_waiver].freeze

def patient_params
permitted_params = [].concat(
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/locales.json
Original file line number Diff line number Diff line change
Expand Up @@ -5745,6 +5745,7 @@
"pledge_generated_by_id": "Pledge generated by",
"pledge_sent": "Pledge sent",
"pledge_sent_at": "Pledge sent at",
"practical_support_waiver": "Practical support waiver",
"primary_phone": "Primary phone",
"procedure_cost": "Procedure cost",
"procedure_date": "Procedure date",
Expand Down Expand Up @@ -6906,6 +6907,7 @@
"delete_confirm": "Are you sure you want to delete this practical support entry?",
"guidance_link": "%{fund} practical support guidance",
"new": "Record new practical support info:",
"practical_support_waiver": "Has signed a practical support waiver",
"title": "Practical support"
},
"shared": {
Expand Down Expand Up @@ -10153,6 +10155,7 @@
"pledge_generated_by_id": "Promesa generada por",
"pledge_sent": "Promeso enviada",
"pledge_sent_at": "Promesa enviada en",
"practical_support_waiver": "Exención de soporte práctico",
"primary_phone": "Número de teléfono principal",
"procedure_cost": "Costo del procedimiento",
"procedure_date": "Fecha de procedimiento",
Expand Down Expand Up @@ -11243,6 +11246,7 @@
"delete_confirm": "¿Está seguro de que desea eliminar esta entrada de soporte práctico?",
"guidance_link": "Orientacíon de soporte práctico de %{fund}",
"new": "Grabar nueva información de soporte práctico:",
"practical_support_waiver": "Aa firmado una renuncia de soporte práctico",
"title": "Apoyo practico"
},
"shared": {
Expand Down
1 change: 1 addition & 0 deletions app/models/archived_patient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def self.convert_patient(patient)
initial_call_date: patient.initial_call_date,
appointment_date: patient.appointment_date,
multiday_appointment: patient.multiday_appointment,
practical_support_waiver: patient.practical_support_waiver,

shared_flag: patient.shared_flag,
referred_by: patient.referred_by,
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/exportable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module Exportable
"Solidarity pledge" => :solidarity,
"Solidarity lead" => :solidarity_lead,
"Multi-day appointment" => :multiday_appointment,
"Practical Support Waiver" => :practical_support_waiver,

# Call related
"Timestamp of first call" => :first_call_timestamp,
Expand Down
8 changes: 8 additions & 0 deletions app/models/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Config < ApplicationRecord
"are added here. Please separate with commas.",
show_patient_identifier: 'Enter "yes" to show the patient\' Daria Identifier on the patient information tab.',
display_practical_support_attachment_url: 'CAUTION: Whether or not to allow people to enter attachment URLs for practical support entries; for example, a link to a file in Google Drive. Please ensure that any system storing these is properly secured by your fund!',
display_practical_support_waiver: 'For funds that use waivers for practical support recipients. Enables the display of a checkbox for indicating if a patient has signed a practical support waiver. '
}.freeze

# Whether a config should show a current options dropdown to the right
Expand Down Expand Up @@ -67,6 +68,7 @@ class Config < ApplicationRecord
procedure_type: 21,
show_patient_identifier: 22,
display_practical_support_attachment_url: 23,
display_practical_support_waiver: 24,
}

# which fields are URLs (run special validation only on those)
Expand Down Expand Up @@ -107,6 +109,8 @@ class Config < ApplicationRecord
[:validate_singleton, :validate_yes_or_no],
display_practical_support_attachment_url:
[:validate_singleton, :validate_yes_or_no],
display_practical_support_waiver:
[:validate_singleton, :validate_yes_or_no],

budget_bar_max:
[:validate_singleton, :validate_number],
Expand Down Expand Up @@ -228,6 +232,10 @@ def self.display_practical_support_attachment_url?
config_to_bool('display_practical_support_attachment_url')
end

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

private
### Generic Functions

Expand Down
12 changes: 12 additions & 0 deletions app/views/patients/_practical_support.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
<h2 class="mt-5"><%= t 'patient.practical_support.title' %></h2>
<p class="mb-5"><%= practical_support_guidance_link %></p>

<% if Config.display_practical_support_waiver? %>
<%= bootstrap_form_with model: patient,
html: { id: 'practical-support-patient-form' },
local: false,
method: 'patch',
class: 'edit_patient' do |f| %>
<%= f.form_group :practical_support_waiver do %>
<%= f.check_box :practical_support_waiver, label: t('patient.practical_support.practical_support_waiver') %>
<% end %>
<% end %>
<% end %>

<div id="practical-support-entries">
<%= render 'practical_supports/entries',
patient: patient %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ en:
pledge_generated_by_id: Pledge generated by
pledge_sent: Pledge sent
pledge_sent_at: Pledge sent at
practical_support_waiver: Practical support waiver
primary_phone: Primary phone
procedure_cost: Procedure cost
procedure_date: Procedure date
Expand Down Expand Up @@ -596,6 +597,7 @@ en:
delete_confirm: Are you sure you want to delete this practical support entry?
guidance_link: "%{fund} practical support guidance"
new: 'Record new practical support info:'
practical_support_waiver: Has signed a practical support waiver
title: Practical support
shared:
appt_date: Appointment date
Expand Down
2 changes: 2 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ es:
pledge_generated_by_id: Promesa generada por
pledge_sent: Promeso enviada
pledge_sent_at: Promesa enviada en
practical_support_waiver: Exención de soporte práctico
primary_phone: Número de teléfono principal
procedure_cost: Costo del procedimiento
procedure_date: Fecha de procedimiento
Expand Down Expand Up @@ -596,6 +597,7 @@ es:
delete_confirm: "¿Está seguro de que desea eliminar esta entrada de soporte práctico?"
guidance_link: Orientacíon de soporte práctico de %{fund}
new: 'Grabar nueva información de soporte práctico:'
practical_support_waiver: Aa firmado una renuncia de soporte práctico
title: Apoyo practico
shared:
appt_date: Día de la cita
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20240818162657_add_waiver_to_patient.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddWaiverToPatient < ActiveRecord::Migration[7.1]
def change
add_column :patients, :practical_support_waiver, :boolean, comment: 'Optional practical support services waiver, for funds that use them'
add_column :archived_patients, :practical_support_waiver, :boolean, comment: 'Optional practical support services waiver, for funds that use them'
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_08_13_034235) do
ActiveRecord::Schema[7.1].define(version: 2024_08_18_162657) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -60,6 +60,7 @@
t.string "procedure_type"
t.integer "ultrasound_cost"
t.boolean "multiday_appointment"
t.boolean "practical_support_waiver", comment: "Optional practical support services waiver, for funds that use them"
t.index ["clinic_id"], name: "index_archived_patients_on_clinic_id"
t.index ["fund_id"], name: "index_archived_patients_on_fund_id"
t.index ["line_id"], name: "index_archived_patients_on_line_id"
Expand Down Expand Up @@ -314,6 +315,7 @@
t.time "appointment_time", comment: "A patient's appointment time"
t.integer "ultrasound_cost"
t.boolean "multiday_appointment"
t.boolean "practical_support_waiver", comment: "Optional practical support services waiver, for funds that use them"
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"
Expand Down
1 change: 1 addition & 0 deletions docs/DATA_DICTIONARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Field | Description | Exportable? | Reported by | Input Type
**When was pledge generated** | Date autogenerated from the DARIA system when a pledge is generated. | Exportable | Autogenerated | Autogenerated
**Pledge sent at** | Date autogenerated from the DARIA system when a pledge is sent. | Exportable | Autogenerated | Autogenerated
**Fund pledged at** | Date autogenerated from the DARIA system when a pledge amount changes. | Exportable | Autogenerated | Autogenerated
**Practical Support Waiver** | Whether or not a patient has signed a waiver for practical support services, in funds where this is used. | Exportable | CM Reported | Checkbox
**Notes** | These are multiple, large text fields used by case managers to record details of the case which could impact case management or funding. Each note is paired with a date/time stamp and attributed to a CM.| Not Exportable | Patient Reported | Large text fields
**Notes Count** | How many notes were recorded with this patient.| Exportable | Patient Reported | Integer
**Calls Count** | How many calls were done with this patient.| Exportable | Patient Reported | Integer
Expand Down
8 changes: 7 additions & 1 deletion test/models/archived_patient_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class ArchivedPatientTest < ActiveSupport::TestCase
city: 'Washington',
race_ethnicity: 'Asian',
initial_call_date: 16.days.ago,
appointment_date: 6.days.ago
appointment_date: 6.days.ago,
multiday_appointment: true,
practical_support_waiver: true
@patient.calls.create status: :couldnt_reach_patient
@patient.external_pledges.create source: 'Friendship Abortion Fund',
amount: 100
Expand Down Expand Up @@ -75,6 +77,10 @@ class ArchivedPatientTest < ActiveSupport::TestCase
assert_equal @archived_patient.race_ethnicity, @patient.race_ethnicity
assert_equal @archived_patient.appointment_date,
@patient.appointment_date
assert_equal @archived_patient.multiday_appointment,
@patient.multiday_appointment
assert_equal @archived_patient.practical_support_waiver,
@patient.practical_support_waiver
end

it 'should have a shared clinic for Patient and Archive Patient' do
Expand Down
20 changes: 20 additions & 0 deletions test/models/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,26 @@ class ConfigTest < ActiveSupport::TestCase
end
end

describe '#display_practical_support_waiver?' do
it 'can return true' do
c = Config.find_or_create_by(config_key: 'display_practical_support_waiver')
c.config_value = { options: ["Yes"] }
c.save!
assert(Config.display_practical_support_waiver? == true)
end

it 'can return false' do
c = Config.find_or_create_by(config_key: 'display_practical_support_waiver')
c.config_value = { options: ["No"] }
c.save!
assert(Config.display_practical_support_waiver? == false)
end

it "returns false by default" do
assert(Config.display_practical_support_waiver? == false)
end
end

describe '#start_day' do
it 'should return the day of week as a symbol' do
assert_equal :monday, Config.start_day
Expand Down
16 changes: 16 additions & 0 deletions test/system/practical_support_behaviors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ class PracticalSupportBehaviorsTest < ApplicationSystemTestCase
@user = create :user
@patient = create :patient, line: @line
create_display_practical_support_attachment_url_config
create_display_practical_support_waiver_config
end

describe 'marking patient level data' do
it 'should hide if no config' do
Config.find_by(config_key: 'display_practical_support_waiver').update config_value: { options: ['no'] }
go_to_practical_support_tab
refute has_text? 'practical support waiver'
end

it 'should be there and save if config' do
go_to_practical_support_tab
check 'Has signed a practical support waiver'
reload_page_and_click_link 'Practical Support'
assert has_checked_field? 'Has signed a practical support waiver'
end
end

describe 'creating a new practical support entry' do
Expand Down
6 changes: 6 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def create_display_practical_support_attachment_url_config(on: true)
c.save!
end

def create_display_practical_support_waiver_config(on: true)
c = Config.find_or_create_by(config_key: 'display_practical_support_waiver')
c.config_value = { options: [on ? 'yes' : 'no']}
c.save!
end

def with_versioning(user = nil)
was_enabled = PaperTrail.enabled?
was_enabled_for_request = PaperTrail.request.enabled?
Expand Down
Loading