Sha256: a6bd1304fefc8b1a8fcfb72e03378684625da131776340241569239d1cc01d27

Contents?: true

Size: 948 Bytes

Versions: 3

Compression:

Stored size: 948 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.15 app/controllers/renalware/api/v1/patients/patients_controller.rb
renalware-core-2.0.14 app/controllers/renalware/api/v1/patients/patients_controller.rb