Class: HealthDataStandards::Import::CCR::ProviderImporter

Inherits:
Object
  • Object
show all
Includes:
ProviderImportUtils, Singleton
Defined in:
lib/health-data-standards/import/ccr/provider_importer.rb

Instance Method Summary collapse

Methods included from ProviderImportUtils

#extract_data, #extract_provider, #find_or_create_provider

Instance Method Details

#create_provider(actor) ⇒ Array

Extract Healthcare Providers from CCR

Parameters:

  • doc (Nokogiri::XML::Document)

    It is expected that the root node of this document will have the “ccr” namespace registered to “urn:astm-org:CCR”

Returns:

  • (Array)

    an array of providers found in the document



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/health-data-standards/import/ccr/provider_importer.rb', line 17

def create_provider(actor)
# Differentiate care providers by content of this field
  provider = {}
  if actor.at_xpath('./ccr:Person/ccr:Name/ccr:CurrentName/ccr:Given')
    provider[:given_name] = extract_data(actor, './ccr:Person/ccr:Name/ccr:CurrentName/ccr:Given')
    provider[:family_name] = extract_data(actor, './ccr:Person/ccr:Name/ccr:CurrentName/ccr:Family')
    provider[:specialty] = extract_data(actor, './ccr:Specialty/ccr:Text')
  end
  
  provider[:specialty] = extract_data(actor, './ccr:Specialty/ccr:Text')

  
  npi_ids = actor.at_xpath("./ccr:IDs[ccr:Type/ccr:Text = \"NPI\"]")
  if npi_ids
    npi_id = npi_ids.at_xpath("./ccr:ID")
    npi = npi_id.content
    provider[:npi] = npi if Provider.valid_npi?(npi)
  end
  
  find_or_create_provider(provider)
end

#extract_providers(doc) ⇒ Object



40
41
42
43
44
45
# File 'lib/health-data-standards/import/ccr/provider_importer.rb', line 40

def extract_providers(doc)

  # Providers are identified as the 'Source' for entries in the CCR.   Sources can also include the patient, relatives, insurance companies, etc
  provider_elements = doc.xpath("//ccr:ContinuityOfCareRecord/ccr:Actors/ccr:Actor[ccr:IDs/ccr:Type/ccr:Text=\"NPI\"]")
  provider_elements.map { |pv| ProviderPerformance.new(provider: create_provider(pv)) }
end