def build_population_criteria(criteria_def, criteria_id, population)
      criteria = PopulationCriteria.new(criteria_def, @document, @id_generator)

      # check to see if we have an identical population criteria.
      # this can happen since the hqmf 2.0 will export a DENOM, NUMER, etc for each population, even if identical.
      # if we have identical, just re-use it rather than creating DENOM_1, NUMER_1, etc.
      identical = @population_criteria.select { |pc| pc.to_model.hqmf_id == criteria.to_model.hqmf_id }

      @reference_ids.concat(criteria.to_model.referenced_data_criteria)

      if identical.empty?
        # this section constructs a human readable id.  The first IPP will be IPP, the second will be IPP_1, etc.
        # This allows the populations to be more readable.  The alternative would be to have the hqmf ids in the
        # populations, which would work, but is difficult to read the populations.
        if @ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"]
          criteria.create_human_readable_id(@ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"])
        else
          criteria.create_human_readable_id(population_id_with_counter(criteria_id))
          @ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"] = criteria.id
        end

        @population_criteria << criteria
        population[criteria_id] = criteria.id
      else
        population[criteria_id] = identical.first.id
      end
    end
def build_population_criteria(criteria_def, criteria_id, population)
      criteria = PopulationCriteria.new(criteria_def, @document, @id_generator)

      # check to see if we have an identical population criteria.
      # this can happen since the hqmf 2.0 will export a DENOM, NUMER, etc for each population, even if identical.
      # if we have identical, just re-use it rather than creating DENOM_1, NUMER_1, etc.
      identical = @population_criteria.select { |pc| pc.to_model.hqmf_id == criteria.to_model.hqmf_id }

      @reference_ids.concat(criteria.to_model.referenced_data_criteria)

      if identical.empty?
        # this section constructs a human readable id.  The first IPP will be IPP, the second will be IPP_1, etc.
        # This allows the populations to be more readable.  The alternative would be to have the hqmf ids in the
        # populations, which would work, but is difficult to read the populations.
        if @ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"]
          criteria.create_human_readable_id(@ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"])
        else
          criteria.create_human_readable_id(population_id_with_counter(criteria_id))
          @ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"] = criteria.id
        end

        @population_criteria << criteria
        population[criteria_id] = criteria.id
      else
        population[criteria_id] = identical.first.id
      end
    end
Method to generate the criteria defining a population