Sha256: f31d8570bf5ba090961b62de6ce9c66eaf76a73b6d0d888a7a3756a3d92e063c

Contents?: true

Size: 968 Bytes

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.1.0 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.167 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.166 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.165 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.164 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.163 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.162 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.161 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb
renalware-core-2.0.160 app/controllers/renalware/api/v1/medications/prescriptions_controller.rb