Skip to content

Commit

Permalink
Additional overall calculations for days homeless; preload source cli…
Browse files Browse the repository at this point in the history
…ent data source; don't try to get phone numbers from HMIS if no HMIS exists
  • Loading branch information
eanders committed Feb 5, 2025
1 parent 6feef88 commit 0c4d5d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def unrelated_columns
:lifetime_sex_offender,
:evicted,
:days_homeless,
:hmis_days_homeless_all_time,
]
end
# memoize :pathways_questions
Expand Down Expand Up @@ -440,6 +441,11 @@ 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 ||
Expand Down
8 changes: 4 additions & 4 deletions app/models/grda_warehouse/hud/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ def email
return source_clients.map(&:email).reject(&:blank?).first if destination?

# Look for value from OP HMIS
value = most_recent_email_hmis if HmisEnforcement.hmis_enabled?
value = most_recent_email_hmis if HmisEnforcement.hmis_enabled? && data_source&.hmis?
# Look for value from other HMIS integrations
value ||= hmis_client_response['Email'] if hmis_client_response.present?
value ||= hmis_client.processed_fields['email'] if hmis_client&.processed_fields
Expand All @@ -1368,7 +1368,7 @@ def home_phone
# Fetch the data from the source clients if we are a destination client
return source_clients.map(&:home_phone).reject(&:blank?).first if destination?

value = most_recent_home_phone_hmis if HmisEnforcement.hmis_enabled?
value = most_recent_home_phone_hmis if HmisEnforcement.hmis_enabled? && data_source&.hmis?
value ||= hmis_client_response['HomePhone'] if hmis_client_response.present?
value
end
Expand All @@ -1377,7 +1377,7 @@ def cell_phone
# Fetch the data from the source clients if we are a destination client
return source_clients.map(&:cell_phone).reject(&:blank?).first if destination?

value = most_recent_cell_or_other_phone_hmis if HmisEnforcement.hmis_enabled?
value = most_recent_cell_or_other_phone_hmis if HmisEnforcement.hmis_enabled? && data_source&.hmis?
value ||= hmis_client_response['CellPhone'] if hmis_client_response.present?
value ||= hmis_client.processed_fields['phone'] if hmis_client&.processed_fields
value
Expand All @@ -1387,7 +1387,7 @@ def work_phone
# Fetch the data from the source clients if we are a destination client
return source_clients.map(&:work_phone).reject(&:blank?).first if destination?

value = most_recent_work_or_school_phone_hmis if HmisEnforcement.hmis_enabled?
value = most_recent_work_or_school_phone_hmis if HmisEnforcement.hmis_enabled? && data_source&.hmis?
return value if value
return unless hmis_client_response.present?

Expand Down
5 changes: 3 additions & 2 deletions app/models/grda_warehouse/tasks/push_clients_to_cas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def sync!
source_clients: [
:most_recent_current_living_situation,
:most_recent_tc_hat,
:data_source,
{
most_recent_pathways_or_rrh_assessment: [
:assessment_questions,
Expand Down Expand Up @@ -112,8 +113,8 @@ def sync!
project_client.needs_update = true
to_update << project_client
end
to_insert = to_update.select { |c| c.id.blank? }
to_upsert = to_update.select { |c| c.id.present? }
to_insert = to_update.select { |c| c.id.blank? }.uniq
to_upsert = to_update.select { |c| c.id.present? }.uniq

CasAccess::ProjectClient.import!(to_upsert, on_duplicate_key_update: update_columns) if to_upsert.present?
CasAccess::ProjectClient.import!(update_columns, to_insert) if to_insert.present?
Expand Down

0 comments on commit 0c4d5d7

Please sign in to comment.