def criteria_covered_by_criteria?(dc)
      @reference_ids.uniq

      base_criteria_defs = %w(patient_characteristic_ethnicity patient_characteristic_gender patient_characteristic_payer patient_characteristic_race)
      to_reject = true
      # don't reject if anything refers directly to this criteria
      to_reject &&= @reference_ids.index(dc.id).nil?
      # don't reject if it is a "base" criteria (no references but must exist)
      to_reject &&= !base_criteria_defs.include?(dc.definition)
      # keep referral occurrence
      to_reject &&= dc.specific_occurrence_const.nil? ||
                    dc.code_list_id != '2.16.840.1.113883.3.464.1003.101.12.1046'
      to_reject && !@data_criteria.detect do |dc2|
        similar_criteria = true
        similar_criteria &&= dc != dc2 # Don't check against itself
        similar_criteria &&= dc.code_list_id == dc2.code_list_id # Ensure code list ids are the same
        similar_criteria && detect_criteria_covered_by_criteria(dc, dc2)
      end.nil? # don't reject unless there is a similar element
    end
def criteria_covered_by_criteria?(dc)
      @reference_ids.uniq

      base_criteria_defs = %w(patient_characteristic_ethnicity patient_characteristic_gender patient_characteristic_payer patient_characteristic_race)
      to_reject = true
      # don't reject if anything refers directly to this criteria
      to_reject &&= @reference_ids.index(dc.id).nil?
      # don't reject if it is a "base" criteria (no references but must exist)
      to_reject &&= !base_criteria_defs.include?(dc.definition)
      # keep referral occurrence
      to_reject &&= dc.specific_occurrence_const.nil? ||
                    dc.code_list_id != '2.16.840.1.113883.3.464.1003.101.12.1046'
      to_reject && !@data_criteria.detect do |dc2|
        similar_criteria = true
        similar_criteria &&= dc != dc2 # Don't check against itself
        similar_criteria &&= dc.code_list_id == dc2.code_list_id # Ensure code list ids are the same
        similar_criteria && detect_criteria_covered_by_criteria(dc, dc2)
      end.nil? # don't reject unless there is a similar element
    end
Checks if one data criteria is covered by another (has all the appropriate elements of)