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

Release 151 #5110

Draft
wants to merge 13 commits into
base: release-150
Choose a base branch
from
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
5 changes: 3 additions & 2 deletions app/controllers/api/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def index
:id,
:ProjectName, # OK to use non-confidentialized name because list is filtered by confidentiality in project_scope
:ProjectType,
:RRHSubType,
o_t[:OrganizationName],
o_t[:id],
ds_t[:short_name],
).each do |id, p_name, type, o_name, o_id, ds_name|
).each do |id, p_name, type, rrh_sub_type, o_name, o_id, ds_name|
o_name_at_ds = "#{o_name} at #{ds_name}"
@data[[o_id, o_name_at_ds]] ||= []

p_name += " (#{HudUtility2024.project_type_brief(type)})" if HudUtility2024.project_type_brief(type).present?
p_name += " (#{HudUtility2024.brief_project_type_with_sub_type(type, rrh_sub_type)})" if HudUtility2024.brief_project_type_with_sub_type(type).present?
@data[[o_id, o_name_at_ds]] << [
p_name,
id,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/anomalies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def flash_interpolation_options
end

protected def title_for_show
"#{@client.name} - Anomalies"
"#{@client.pii_provider(user: current_user).full_name} - Anomalies"
end

private def anomaly_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/audits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def set_client
end

def title_for_show
"#{@client.name} - Audit"
"#{@client.pii_provider(user: current_user).full_name} - Audit"
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/cas_readiness_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def cas_readiness_params
end

def title_for_show
"#{@client.name} - CAS Readiness"
"#{@client.pii_provider(user: current_user).full_name} - CAS Readiness"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/chronic_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def cas_readiness_params
end

def title_for_show
"#{@client.name} - Chronic"
"#{@client.pii_provider(user: current_user).full_name} - Chronic"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def update
end

private def title_for_show
"#{@client.name} - #{Translation.translate('Coordinated Entry Assessment')}"
"#{@client.pii_provider(user: current_user).full_name} - #{Translation.translate('Coordinated Entry Assessment')}"
end

def flash_interpolation_options
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/enrollment_history_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def history_scope
end

def title_for_show
"#{@client.name} - Historical Enrollments"
"#{@client.pii_provider(user: current_user).full_name} - Historical Enrollments"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def file_source
end

protected def title_for_show
"#{@client.name} - Files"
"#{@client.pii_provider(user: current_user).full_name} - Files"
end

def window_visible?(visibility)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/hud_lots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def index
end

private def title_for_show
"#{@client.name} - Client-Level System Use & Length of Time Homeless Report"
"#{@client.pii_provider(user: current_user).full_name} - Client-Level System Use & Length of Time Homeless Report"
end
helper_method :title_for_show

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def destroy
end

private def title_for_show
"#{@client.name} - Notes"
"#{@client.pii_provider(user: current_user).full_name} - Notes"
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/clients/releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def pre_populated

private def render_pdf!
@pdf = true
file_name = "Release of Information for #{@client.name}"
file_name = "Release of Information for #{@client.pii_provider(user: current_user).full_name}"
send_data roi_pdf(file_name), filename: "#{file_name}.pdf", type: 'application/pdf'
end

Expand Down Expand Up @@ -175,7 +175,7 @@ def file_source
end

protected def title_for_show
"#{@client.name} - Release of Information"
"#{@client.pii_provider(user: current_user).full_name} - Release of Information"
end

def window_visible?(_visibility)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def set_user
end

protected def title_for_show
"#{@client.name} - Relationships"
"#{@client.pii_provider(user: current_user).full_name} - Relationships"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/vispdats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def destroy_file
end

private def title_for_show
"#{@client.name} - VI-SPDATs"
"#{@client.pii_provider(user: current_user).full_name} - VI-SPDATs"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/youth/intakes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def remove_all_youth_data
@client.youth_follow_ups.destroy_all
# TODO: This does not remove the client from the Youth DataSource

flash[:notice] = "All Youth information for #{@client.name} has been removed."
flash[:notice] = "All Youth information for #{@client.pii_provider(user: current_user).full_name} has been removed."
redirect_to client_youth_intakes_path(@client)
else
not_authorized!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cohorts/client_notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def cohort_id
end

def flash_interpolation_options
{ resource_name: "Note for #{@note.client.name}" }
{ resource_name: "Note for #{@note.client.pii_provider(user: current_user).full_name}" }
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/cohorts/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def destroy
else
log_removal(@client.cohort_id, @client.id, params.dig(:grda_warehouse_cohort_client, :reason))
if @client.destroy
flash[:notice] = "Removed #{@client.name}"
flash[:notice] = "Removed #{@client.pii_provider(user: current_user).full_name}"
redirect_to cohort_path(@cohort)
else
render :pre_destroy
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cohorts/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def cohort_id
end

def flash_interpolation_options
{ resource_name: "Note for #{@note.client.name}" }
{ resource_name: "Note for #{@note.client.pii_provider(user: current_user).full_name}" }
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/activity_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def log_activity

# override as necessary in the controller
protected def title_for_show
return @client.name if @client.present?
return @client.pii_provider(user: current_user).full_name if @client.present?
return @user.name if @user.present?
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/concerns/cas_client_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ def cas_assessment_collected_at
:additional_homeless_nights_unsheltered,
:calculated_homeless_nights_sheltered,
:calculated_homeless_nights_unsheltered,
:total_homeless_nights_sheltered
:total_homeless_nights_sheltered,
:psh_required
end
end
108 changes: 102 additions & 6 deletions app/models/grda_warehouse/cas_project_client_calculator/boston.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def value_for_cas_project_client(client:, column:)
end
end

def handles_days_homeless?
true
end

def unrelated_columns
[
:vispdat_score,
Expand Down Expand Up @@ -61,7 +65,7 @@ def unrelated_columns
cas_assessment_collected_at: 'Date the assessment was collected', # note this is really just assessment_collected_at
majority_sheltered: 'Most recent current living situation was sheltered',
assessment_score_for_cas: 'Days homeless in the past 3 years for pathways, score for transfer assessments',
tie_breaker_date: 'Date pathways was collected, or Financial Assistance End Date for transfer assessments',
tie_breaker_date: 'Date pathways was collected for Pathways 2023, First Date Homeless for Pathways 2024, or Financial Assistance End Date for Transfer Assessments',
financial_assistance_end_date: 'Latest Date Eligible for Financial Assistance response from the most recent pathways assessment',
assessor_first_name: 'First name of the user who completed the most recent pathways assessment',
assessor_last_name: 'Last name of the user who completed the most recent pathways assessment',
Expand All @@ -73,6 +77,7 @@ def unrelated_columns
days_homeless_for_vispdat_prioritization: 'Unused',
hiv_positive: 'HIV/AIDS response from the most recent pathways assessment',
meth_production_conviction: 'Meth production response from the most recent pathways assessment',
lifetime_sex_offender: 'Registered sex offender (level 1,2,3) - lifetime registration (SORI)',
requires_wheelchair_accessibility: 'Does the client need a wheelchair accessible unit response from the most recent pathways assessment',
income_maximization_assistance_requested: 'Did the client request income maximization services response from the most recent pathways assessment',
sro_ok: 'Is the client ok with an SRO response from the most recent pathways assessment',
Expand All @@ -94,7 +99,6 @@ def unrelated_columns
hiv_positive: 'c_housing_HIV',
income_maximization_assistance_requested: 'c_interest_income_max',
sro_ok: 'c_singleadult_sro',
evicted: 'c_pathways_barrier_eviction',
rrh_desired: 'c_interested_rrh',
housing_barrier: 'c_pathways_barriers_yn',
}.freeze
Expand Down Expand Up @@ -143,6 +147,13 @@ def unrelated_columns
:calculated_homeless_nights_unsheltered,
:total_homeless_nights_sheltered,
:total_homeless_nights_unsheltered,
:date_of_first_service,
:psh_required,
:meth_production_conviction,
:lifetime_sex_offender,
:evicted,
:days_homeless,
:hmis_days_homeless_all_time,
]
end
# memoize :pathways_questions
Expand Down Expand Up @@ -186,6 +197,23 @@ def most_recent_transfer_assessment_for_destination(client)
nil
end

private def lifetime_sex_offender(client)
most_recent_pathways_or_transfer(client).
question_matching_requirement('c_transfer_barrier_SORI', '1').present?
end

private def evicted(client)
evicted = most_recent_pathways_or_transfer(client).question_matching_requirement('c_pathways_barrier_meth', '1').present?
return true if evicted

evicted = most_recent_pathways_or_transfer(client).
question_matching_requirement('c_transfer_barrier_PHAterm', '1').present?
return true if evicted

# Otherwise unknown
nil
end

private def service_need(client)
need = most_recent_pathways_or_transfer(client).question_matching_requirement('c_pathways_service_indicators', '1').present?
return true if need
Expand Down Expand Up @@ -321,6 +349,18 @@ def days_homeless_in_last_three_years_cached(client)
pre_calculated_days
end

# Overrides the usual calculation for first date homeless if available
# If the question doesn't exist on the assessment or is empty, use the usual definition
private def date_of_first_service(client)
field_name = 'c_pathways_first_date_homeless'
answer = most_recent_pathways_or_transfer(client).
question_matching_requirement(field_name)&.AssessmentAnswer

return client.date_of_first_service if answer.blank?

answer.to_date
end

# If a client has more than 548 self-reported days (combination of sheltered and unsheltered)
# and does not have a verification uploaded, count unsheltered days first, then count sheltered days UP TO 548.
# If the self reported days are verified, use the provided amounts.
Expand Down Expand Up @@ -396,12 +436,46 @@ def total_homeless_nights_sheltered(client)
question_matching_requirement('c_pathways_nights_sheltered_warehouse_added_total')&.AssessmentAnswer.to_i || 0
end

# all-time days homeless
def days_homeless(client)
overall_nights_homeless(client)
end

# this seems to be calculated many different ways
def hmis_days_homeless_all_time(client)
overall_nights_homeless(client)
end

private def overall_nights_homeless(client)
most_recent_pathways_or_transfer(client).
question_matching_requirement('c_new_boston_homeless_nights_total')&.AssessmentAnswer.to_i ||
client.days_homeless
end

private def default_shelter_agency_contacts(client)
contact_emails = client.client_contacts.shelter_agency_contacts.where.not(email: nil).pluck(:email)
contact_emails << client.source_assessments.max_by(&:assessment_date)&.user&.user_email
contact_emails.compact.uniq
end

# 0 = No PSH
# 1 = PSH required
# 2 = Either
# Default to either if we don't have an answer
# CAS uses `yes`, `no`, `maybe` strings
private def psh_required(client)
value = most_recent_pathways_or_transfer(client).
question_matching_requirement('c_rrh_transfer_needs_subsidized_housing_resource')&.AssessmentAnswer.to_i || 2
case value
when 0
'no'
when 1
'yes'
else
'maybe'
end
end

private def contact_info_for_rrh_assessment(client)
client.client_contacts.case_managers.map(&:full_address).join("\n\n")
end
Expand All @@ -419,6 +493,7 @@ def total_homeless_nights_sheltered(client)
1 => 'IdentifiedPathwaysVersionThreePathways',
2 => 'IdentifiedPathwaysVersionThreeTransfer',
3 => 'IdentifiedPathwaysVersionFourPathways',
4 => 'IdentifiedPathwaysVersionFourTransfer',
}[value.to_i] || 'IdentifiedClientAssessment'
end

Expand Down Expand Up @@ -447,21 +522,42 @@ def total_homeless_nights_sheltered(client)
question_matching_requirement('c_latest_date_financial_assistance_eligibility_rrh')&.AssessmentAnswer
end

# For 2024/2025 score calculations are:
# Individual Pathways Assessment: days homeless in the past 3 years, prefer Pathways answer clamped to 1,096, use
# days in the past three years from the warehouse if not available.
# Family Pathways Assessment: overall days homeless (all time), prefer Pathways answer, use client.days_homeless if
# not available.
# Transfer Assessment: use assessment score.
private def assessment_score_for_cas(client)
case cas_assessment_name(client)
when 'IdentifiedPathwaysVersionThreePathways', 'IdentifiedPathwaysVersionFourPathways'
days_homeless_in_last_three_years_cached(client)
when 'IdentifiedPathwaysVersionThreeTransfer'
if most_recent_pathways_or_transfer(client).family_pathways_2024?
# Family
overall_days_homeless(client)
else
# Individual
days_homeless_in_last_three_years_cached(client)
end

# all time homeless days (no cap on total, but self-report limited to 548 if no verification)
# Also need a mechanism to identify family Pathways assessments/AssessmentQuestions
when 'IdentifiedPathwaysVersionThreeTransfer', 'IdentifiedPathwaysVersionFourTransfer'
assessment_score(client)
end
end

# Various tie-breaker dates used for prioritization in CAS when all else is equal
# For Pathways V3, use the date the assessment was collected
# For the V3 Transfer assessment, use the financial assistance end date
# For Pathways V4, use the first date of homelessness
private def tie_breaker_date(client)
case cas_assessment_name(client)
when 'IdentifiedPathwaysVersionThreePathways', 'IdentifiedPathwaysVersionFourPathways'
when 'IdentifiedPathwaysVersionThreePathways'
cas_assessment_collected_at(client)
when 'IdentifiedPathwaysVersionThreeTransfer'
when 'IdentifiedPathwaysVersionThreeTransfer', 'IdentifiedPathwaysVersionFourTransfer'
financial_assistance_end_date(client)
when 'IdentifiedPathwaysVersionFourPathways'
date_of_first_service(client)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def value_for_cas_project_client(client:, column:)
client.send(column)
end

# Defer calculation of `days_homeless` to PushClientsToCas
def handles_days_homeless?
false
end

def description_for_column(column)
custom_descriptions[column].presence || GrdaWarehouse::Hud::Client.cas_columns_data.dig(column, :description)
end
Expand Down
Loading