Sha256: 274221b559aacdb601460ef9ad7de7721cfc1026429e1dc03991457e74337557

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

module Renalware
  module Medications
    module DrugTypes
      class PrescriptionsController < BaseController
        include Renalware::Concerns::Pageable

        def index
          authorize Prescription, :index?
          render :index, locals: {
            prescriptions: present_prescriptions,
            search: query.search
          }
        end

        private

        def present_prescriptions
          CollectionPresenter.new(paginated_prescriptions, PrescriptionPresenter)
        end

        def paginated_prescriptions
          query.call.page(page).per(per_page)
        end

        def query
          @query ||= begin
            PrescriptionsByDrugTypeQuery.new(
              drug_type_name: drug_type_name,
              search_params: params[:q]
            )
          end
        end

        def drug_type_name
          params.fetch(:drug_type_name)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta4 app/controllers/renalware/medications/drug_types/prescriptions_controller.rb