lib/models/cql_measure.rb in bonnie_bundler-2.2.0 vs lib/models/cql_measure.rb in bonnie_bundler-2.2.1

- old
+ new

@@ -70,9 +70,25 @@ options[:user_id] = user.id if user? @value_sets ||= HealthDataStandards::SVS::ValueSet.in(options) @value_sets end + def value_sets_by_oid + @value_sets_by_oid = {} + value_sets.each do |vs| + if @value_sets_by_oid[vs.oid] + # If there are multiple value sets with the same oid for the user, then keep the one with + # the version corresponding to this measure. + if vs.version.include?(hqmf_set_id) + @value_sets_by_oid[vs.oid] = { vs.version => vs } + end + else + @value_sets_by_oid[vs.oid] = { vs.version => vs } + end + end + @value_sets_by_oid + end + # Returns the hqmf-parser's ruby implementation of an HQMF document. # Rebuild from population_criteria, data_criteria, and measure_period JSON def as_hqmf_model json = { "id" => self.measure_id,