Module: HealthDataStandards::CQM::PopulationSelectors
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 34
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
#denominator ⇒ Object
9
10
11
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 9
def denominator
populations.find {|pop| pop.type == 'DENOM'}
end
|
#denominator_exceptions ⇒ Object
13
14
15
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 13
def denominator_exceptions
populations.find {|pop| pop.type == 'DENEXCEP'}
end
|
#denominator_exclusions ⇒ Object
17
18
19
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 17
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.
49
50
51
52
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 49
def multiple_population_types?
population_groups = populations.group_by {|pop| pop.type}
population_groups.values.any? { |pops| pops.size > 1 }
end
|
#numerator ⇒ Object
5
6
7
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 5
def numerator
populations.find {|pop| pop.type == 'NUMER'}
end
|
#population_count(population_type, population_id) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 21
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
30
31
32
|
# File 'lib/health-data-standards/models/cqm/aggregate_objects.rb', line 30
def population_id(population_type)
populations.find {|pop| pop.type == population_type}.id
end
|