Sha256: e38834919971ebac9d321b9a3639400f5792bec86160ee92a25c90f7395875ef

Contents?: true

Size: 1.67 KB

Versions: 43

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/hd"

module Renalware
  module HD
    class MDMPatientsController < Renalware::MDMPatientsController
      def index
        render_index(filter_form: filter_form,
                     query: query,
                     page_title: t(".page_title"),
                     view_proc: ->(patient) { patient_hd_mdm_path(patient) },
                     patient_presenter_class: HD::PatientPresenter)
      end

      private

      def query
        @query ||= begin
          MDMPatientsQuery.new(
            params: filter_form.ransacked_parameters.merge(query_params).with_indifferent_access,
            named_filter: named_filter
          )
        end
      end

      # Pass in the current path to the filter form so it can render the correct URI in form and
      # reset links.
      def filter_form
        @filter_form ||= form_object_class.new(filter_form_params.merge(url: request.path))
      end

      # Permit all attributes on the filter form object. Slightly messy
      def filter_form_params
        params.fetch(:filter, {}).permit(form_object_class.permittable_attributes)
      end

      def form_object_class
        Renalware::HD::MDMPatientsForm
      end

      # Ransack params use for column sorting
      def query_params
        params.fetch(:q, {}).permit(:s)
      end

      def named_filter
        params[:named_filter]
      end

      def render_index(filter_form:, **args)
        presenter = build_presenter(params: params, **args)
        authorize presenter.patients
        render(
          :index,
          locals: { presenter: presenter, filter_form: filter_form }
        )
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
renalware-core-2.0.90 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.89 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.88 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.87 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.86 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.85 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.84 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.83 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.82 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.81 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.80 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.79 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.78 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.77 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.76 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.75 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.74 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.73 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.72 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.71 app/controllers/renalware/hd/mdm_patients_controller.rb