Sha256: 4ae102812a687f1e4f13c8579061da75170bee4ffee78021d0af051e7cf7a779

Contents?: true

Size: 1.6 KB

Versions: 27

Compression:

Stored size: 1.6 KB

Contents

require_dependency("renalware/renal")
require "collection_presenter"

module Renalware
  module Renal
    class RegistryPreflightChecksController < BaseController
      include Renalware::Concerns::Pageable

      class PatientPresenter < SimpleDelegator
        def missing_data
          Registry::PreflightChecks::PatientsQuery.missing_data_for(__getobj__)
        end

        def hd_unit
          if current_modality.description.name == "HD"
            Renalware::HD.cast_patient(__getobj__)&.hd_profile&.hospital_unit&.unit_code
          end
        end
      end

      class DeceasedPatientPresenter < SimpleDelegator
        def missing_data
          Registry::PreflightChecks::DeathsQuery.missing_data_for(__getobj__)
        end

        def hd_unit; end
      end

      def patients
        authorize [:renalware, :renal, :registry_preflight_check], :patients?
        query = Registry::PreflightChecks::PatientsQuery.new(
          query_params: params.fetch(:q, {})
        )
        patients = query.call.page(page).per(per_page)
        patients = CollectionPresenter.new(patients, PatientPresenter)
        render locals: { patients: patients, query: query.search }
      end

      def deaths
        authorize [:renalware, :renal, :registry_preflight_check], :deaths?
        query = Registry::PreflightChecks::DeathsQuery.new(
          query_params: params.fetch(:q, {})
        )
        patients = query.call.page(page).per(per_page)
        patients = CollectionPresenter.new(patients, DeceasedPatientPresenter)
        render locals: { patients: patients, query: query.search }
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.15 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.14 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.13 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.12 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.11 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.9 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.8 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.7 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.5 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.4 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.3 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.2 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.1 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/renal/registry_preflight_checks_controller.rb