Sha256: 3a2d78a27e90ff9ff8023bb64f8d9c663295042c87e527596f5e3c98a9562dac

Contents?: true

Size: 979 Bytes

Versions: 132

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

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

module Renalware
  module API
    module V1
      module Patients
        class PatientsController < TokenAuthenticatedApiController
          include Concerns::Pageable

          def show
            patient = Patient.find_by!(local_patient_id: params[:id])
            render locals: { patient: patient }
          end

          def index
            render locals: { patients: patients }
          end

          private

          def patients
            relation = last_patient_id.blank? ? Patient.none : Patient
            relation
              .where("id > ?", last_patient_id)
              .order(id: :asc)
              .page(page).per(per_page)
          end

          def last_patient_id
            params[:last_patient_id]
          end

          def per_page
            params[:per_page] || 100
          end
        end
      end
    end
  end
end

Version data entries

132 entries across 132 versions & 1 rubygems

Version Path
renalware-core-2.0.116 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.115 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.113 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.112 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.111 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.110 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.109 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.108 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.106 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.105 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.104 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.103 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.102 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.101 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.100 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.99 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.98 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.97 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.96 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.95 app/controllers/renalware/api/v1/patients/patients_controller.rb