Skip to content

Commit

Permalink
refactored some of index lines to new function.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbylight committed Jan 10, 2025
1 parent e5cd7b9 commit 0f76e0a
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class PrescriptionsController < RxController
# (ie: ?sort[]=refill_status&sort[]=-prescription_id)
def index
resource = collection_resource
resource.data = remove_pf_pd(resource.data) # TODO: remove this line when PF and PD are allowed on va.gov
resource.data = group_prescriptions(resource.data) if Flipper.enabled?(:mhv_medications_display_grouping)
resource.data = filter_non_va_meds(resource.data)
resource.data = resource_data_modifications(resource)
filter_count = set_filter_metadata(resource.data)
resource = if params[:filter].present?
if filter_params[:disp_status]&.[](:eq) == 'Active,Expired' # renewal params
Expand Down Expand Up @@ -174,6 +172,12 @@ def collection_resource
end
end

def resource_data_modifications(resource)
resource.data = remove_pf_pd(resource.data) # TODO: remove this line when PF and PD are allowed on va.gov
resource.data = group_prescriptions(resource.data) if Flipper.enabled?(:mhv_medications_display_grouping)
resource.data = filter_non_va_meds(resource.data)
end

def set_filter_metadata(list)
{
filter_count: {
Expand Down Expand Up @@ -206,7 +210,8 @@ def count_non_active_medications(list)

# TODO: remove once pf and pd are allowed on va.gov
def remove_pf_pd(data)
data.reject { |item| item[:prescription_source] == 'PF' || item[:prescription_source] == 'PD' }
sources_to_remove_from_data = ['PF', 'PD']

Check failure on line 213 in modules/my_health/app/controllers/my_health/v1/prescriptions_controller.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Style/WordArray: Use `%w` or `%W` for an array of words.
data.reject { |item| sources_to_remove_from_data.include?(item.prescription_source)}

Check failure on line 214 in modules/my_health/app/controllers/my_health/v1/prescriptions_controller.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/SpaceInsideBlockBraces: Space missing inside }.
end
end
end
Expand Down

0 comments on commit 0f76e0a

Please sign in to comment.