Sha256: 3dc4985b8f6d1be9b6e2501c633a4a659fe95928f64f6cf57bebe65c461f39c6

Contents?: true

Size: 968 Bytes

Versions: 132

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/patients"
require_dependency "renalware/api"

module Renalware
  module API
    module V1
      module Medications
        class PrescriptionsController < TokenAuthenticatedApiController
          def index
            render locals: {
              patient: patient,
              prescriptions: current_prescriptions_presenter
            }
          end

          private

          def current_prescriptions_presenter
            CollectionPresenter.new(
              current_prescriptions,
              Renalware::Medications::PrescriptionPresenter
            )
          end

          def current_prescriptions
            Renalware::Medications::PrescriptionsQuery.new(
              relation: patient.prescriptions.current
            ).call
          end

          def patient
            Patient.find_by!(secure_id: params[:patient_id])
          end
        end
      end
    end
  end
end

Version data entries

132 entries across 132 versions & 1 rubygems

Version Path
renalware-core-2.0.159 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.158 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.157 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.156 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.155 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.153 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.152 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.151 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.149 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.148 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.147 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.146 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.145 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.144 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.143 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.142 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.141 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.140 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.139 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.138 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb