Sha256: ca81a1233347f9ebf364660f154b4d54d67b46465f32702b88151185ef093704

Contents?: true

Size: 1.22 KB

Versions: 64

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/renal"

module Renalware
  module Renal
    module Registry
      module PreflightChecks
        class DeathsQuery
          include ModalityScopes
          MODALITY_NAMES = %w(Death).freeze

          attr_reader :relation, :query_params

          def initialize(relation: nil, query_params: {})
            @relation = relation || default_relation
            @query_params = query_params
            @query_params[:s] = "modality_descriptions_name ASC" if @query_params[:s].blank?
          end

          def default_relation
            Renalware::Renal::Patient.left_outer_joins(:profile)
          end

          def call
            search
              .result
              .extending(ModalityScopes)
              .preload(current_modality: [:description])
              .with_current_modality_matching(MODALITY_NAMES)
              .where("patients.first_cause_id is NULL AND renal_profiles.esrf_on IS NOT NULL")
          end

          def search
            @search ||= relation.ransack(query_params)
          end

          def self.missing_data_for(_patient)
            [
              :cause_of_death
            ]
          end
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
renalware-core-2.0.105 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.104 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.103 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.102 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.101 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.100 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.99 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.98 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.97 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.96 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.95 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.94 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.93 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.92 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.91 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.90 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.89 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.88 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.87 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb
renalware-core-2.0.86 app/models/renalware/renal/registry/preflight_checks/deaths_query.rb