Module: HealthDataStandards::CQM::PopulationSelectors

Included in:
PopulationGroup
Defined in:
lib/health-data-standards/models/cqm/aggregate_objects.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 33

def method_missing(method, *args, &block)
  match_data = method.to_s.match(/^(.+)_count$/)
  if match_data
    population = self.send(match_data[1])
    if population
      population.value
    else
      0
    end
  else
    super
  end
end

Instance Method Details

#denominatorObject



8
9
10
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 8

def denominator
  populations.find {|pop| pop.type == 'DENOM'}
end

#denominator_exceptionsObject



12
13
14
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 12

def denominator_exceptions
  populations.find {|pop| pop.type == 'DENEXCEP'}
end

#denominator_exclusionsObject



16
17
18
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 16

def denominator_exclusions
  populations.find {|pop| pop.type == 'DENEX'}
end

#multiple_population_types?Boolean

Returns true if there is more than one IPP or DENOM, etc.

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 48

def multiple_population_types?
  population_groups = populations.group_by {|pop| pop.type}
  population_groups.values.any? { |pops| pops.size > 1 }
end

#numeratorObject



4
5
6
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 4

def numerator
  populations.find {|pop| pop.type == 'NUMER'}
end

#population_count(population_type, population_id) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 20

def population_count(population_type, population_id)
  population = populations.find {|pop| pop.type == population_type && pop.id == population_id}
  if population
    population.value
  else
    0
  end
end

#population_id(population_type) ⇒ Object



29
30
31
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 29

def population_id(population_type)
  populations.find {|pop| pop.type == population_type}.id
end