Sha256: 69616c1fde910b4000feea4ede90c2af3eb95bf6c16cc691563c532707381a77

Contents?: true

Size: 1.11 KB

Versions: 21

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/medications"

module Renalware
  module Medications
    module HomeDelivery
      class PrescriptionsController < BaseController
        include Pagy::Backend

        def index
          form = SearchForm.new(search_params)
          query = Medications::Delivery::PrescriptionsDueForDeliveryQuery.new(
            drug_type_code: params[:named_filter],
            modality_description_id: form.modality_description_id,
            query: params[:q]
          )
          pagy, prescriptions = pagy(query.call)
          authorize prescriptions
          render :index, locals: {
            prescriptions: prescriptions,
            pagy: pagy,
            query: query.search,
            form: form
          }
        end

        class SearchForm
          include ActiveModel::Model
          include Virtus::Model

          attribute :modality_description_id, Integer
        end

        def search_params
          return {} unless params.key?(:search)

          params.require(:search).permit(:modality_description_id)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.1.0 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.167 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.166 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.165 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.164 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.163 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.162 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.161 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.160 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.159 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.158 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.157 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.156 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.155 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.153 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.152 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.151 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.149 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb
renalware-core-2.0.148 app/controllers/renalware/medications/home_delivery/prescriptions_controller.rb