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.0.pre.rc7 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc6 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc5 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc4 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc3 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.rc1 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.0.pre.beta12 app/controllers/renalware/renal/registry_preflight_checks_controller.rb