def extract_populations_and_criteria
      has_observation = extract_observations
      document_populations = @doc.xpath('cda:QualityMeasureDocument/cda:component/cda:populationCriteriaSection',
                                        HQMF2::Document::NAMESPACES)
      # Sort the populations based on the id/extension, since the populations may be out of order; there doesn't seem to
      # be any other way that order is indicated in the HQMF
      document_populations = document_populations.sort_by do |pop|
        pop.at_xpath('cda:id/@extension', HQMF2::Document::NAMESPACES).try(:value)
      end
      number_of_populations = document_populations.length
      document_populations.each_with_index do |population_def, population_index|
        population = {}
        handle_base_populations(population_def, population)

        id_def = population_def.at_xpath('cda:id/@extension', HQMF2::Document::NAMESPACES)
        population['id'] = id_def ? id_def.value : "Population#{population_index}"
        title_def = population_def.at_xpath('cda:title/@value', HQMF2::Document::NAMESPACES)
        population['title'] = title_def ? title_def.value : "Population #{population_index}"

        population['OBSERV'] = 'OBSERV' if has_observation
        @populations << population

        handle_stratifications(population_def, number_of_populations, population, id_def, population_index)
      end

      # Push in the stratification populations after the unstratified populations
      @populations.concat(@stratifications)
      [@populations, @population_criteria]
    end
def extract_populations_and_criteria
      has_observation = extract_observations
      document_populations = @doc.xpath('cda:QualityMeasureDocument/cda:component/cda:populationCriteriaSection',
                                        HQMF2::Document::NAMESPACES)
      # Sort the populations based on the id/extension, since the populations may be out of order; there doesn't seem to
      # be any other way that order is indicated in the HQMF
      document_populations = document_populations.sort_by do |pop|
        pop.at_xpath('cda:id/@extension', HQMF2::Document::NAMESPACES).try(:value)
      end
      number_of_populations = document_populations.length
      document_populations.each_with_index do |population_def, population_index|
        population = {}
        handle_base_populations(population_def, population)

        id_def = population_def.at_xpath('cda:id/@extension', HQMF2::Document::NAMESPACES)
        population['id'] = id_def ? id_def.value : "Population#{population_index}"
        title_def = population_def.at_xpath('cda:title/@value', HQMF2::Document::NAMESPACES)
        population['title'] = title_def ? title_def.value : "Population #{population_index}"

        population['OBSERV'] = 'OBSERV' if has_observation
        @populations << population

        handle_stratifications(population_def, number_of_populations, population, id_def, population_index)
      end

      # Push in the stratification populations after the unstratified populations
      @populations.concat(@stratifications)
      [@populations, @population_criteria]
    end
Returns the population descriptions and criteria found in this document