Sha256: e7537ee25f6c482f9863ce2012b93abda366518489a85bdd5735071d30c90759

Contents?: true

Size: 674 Bytes

Versions: 4

Compression:

Stored size: 674 Bytes

Contents

module ProviderImportUtils
  
  def extract_provider(performer)
    provider_data = extract_provider_data(performer, false)
    find_or_create_provider(provider_data)
  end
  
  def find_or_create_provider(provider_hash)
    provider = Provider.first(conditions: {npi: provider_hash[:npi]}) if provider_hash[:npi] && !provider_hash[:npi].empty?
    provider ||= Provider.create(provider_hash)
  end

  # Returns nil if result is an empty string, block allows text munging of result if there is one
  def extract_data(subject, query)
    result = subject.at_xpath(query)
    if result.nil? || result.content.empty?
      nil
    else
      result.content
    end
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
health-data-standards-1.0.1 lib/health-data-standards/import/provider_import_utils.rb
health-data-standards-1.0.0 lib/health-data-standards/import/provider_import_utils.rb
health-data-standards-0.8.1 lib/health-data-standards/import/provider_import_utils.rb
health-data-standards-0.8.0 lib/health-data-standards/import/provider_import_utils.rb