Class: Measures::CqlLoader
- Inherits:
-
Object
- Object
- Measures::CqlLoader
- Defined in:
- lib/measure-loader/cql_loader.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#extract_measures ⇒ Object
Returns an array of measures, will contain a single measure if it is a non-composite measure.
-
#initialize(measure_zip, measure_details, value_set_loader = nil) ⇒ CqlLoader
constructor
A new instance of CqlLoader.
Constructor Details
#initialize(measure_zip, measure_details, value_set_loader = nil) ⇒ CqlLoader
Returns a new instance of CqlLoader.
4 5 6 7 8 9 10 |
# File 'lib/measure-loader/cql_loader.rb', line 4 def initialize(measure_zip, measure_details, value_set_loader = nil) @measure_zip = measure_zip @measure_details = measure_details.deep_symbolize_keys @vs_model_cache = {} @value_set_loader = value_set_loader @value_set_loader.vs_model_cache = @vs_model_cache if @value_set_loader.present? end |
Class Method Details
.update_population_set_and_strat_titles(measure, population_titles) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/measure-loader/cql_loader.rb', line 30 def self.update_population_set_and_strat_titles(measure, population_titles) # Sample population_titles: [pop set 1 title, pop set 2 title, pop set 1 strat 1 title, # pop set 1 strat 2 title, pop set 2 strat 1 title, pop set 2 strat 2 title] # Note RE composite measures: components and composite must have same population sets and strats return if population_titles.nil? || population_titles.empty? title_idx = 0 measure.population_sets.each do |population_set| population_set.title = population_titles[title_idx] if population_titles[title_idx].present? title_idx += 1 break if title_idx >= population_titles.size end return if title_idx >= population_titles.size measure.population_sets.flat_map(&:stratifications).each do |strat| strat.title = population_titles[title_idx] if population_titles[title_idx].present? title_idx += 1 break if title_idx >= population_titles.size end end |
Instance Method Details
#extract_measures ⇒ Object
Returns an array of measures, will contain a single measure if it is a non-composite measure
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/measure-loader/cql_loader.rb', line 13 def extract_measures measure_files = MATMeasureFiles.create_from_zip_file(@measure_zip) measures = [] if measure_files.components.present? measure, component_measures = create_measure_and_components(measure_files) measures.push(*component_measures) else measure = create_measure(measure_files) end measure.package = CQM::MeasurePackage.new(file: BSON::Binary.new(@measure_zip.read)) measures << measure measures.each { |m| CqlLoader.update_population_set_and_strat_titles(m, @measure_details[:population_titles]) } return measures end |