def fold_references(mapped_external_entity, references, organization)
      references = format_references(references)
      mapped_external_entity = mapped_external_entity.with_indifferent_access

      # Use both record_references and id_references + the id
      (references.values.flatten + ['id']).each do |reference|
        fold_references_helper(mapped_external_entity, reference.split('/'), organization)
      end

      mapped_external_entity
    end
def fold_references(mapped_external_entity, references, organization)
      references = format_references(references)
      mapped_external_entity = mapped_external_entity.with_indifferent_access

      # Use both record_references and id_references + the id
      (references.values.flatten + ['id']).each do |reference|
        fold_references_helper(mapped_external_entity, reference.split('/'), organization)
      end

      mapped_external_entity
    end
Replaces ids from the external application by arrays containing them