Sha256: 7c09538a72cccc1fd4fe9c12a958621f6ebdd7cd9cf5d242cdd377a2dd29f7dc

Contents?: true

Size: 1.63 KB

Versions: 19

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

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

19 entries across 19 versions & 1 rubygems

Version Path
renalware-core-2.0.37 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.36 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.35 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.34 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.33 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.32 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.31 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.30 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.28 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.27 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.26 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.25 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.24 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.23 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.22 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.21 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.20 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.18 app/controllers/renalware/renal/registry_preflight_checks_controller.rb
renalware-core-2.0.17 app/controllers/renalware/renal/registry_preflight_checks_controller.rb