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.111 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.110 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.109 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.108 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.106 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.105 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.104 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.103 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.102 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.101 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.100 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.99 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.98 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.97 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.96 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.95 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.94 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.93 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.92 app/controllers/renalware/hd/mdm_patients_controller.rb
renalware-core-2.0.91 app/controllers/renalware/hd/mdm_patients_controller.rb