Sha256: 2a7270c5e1d0ef01a5225182c24d5461fcb07d1397eb8f47ca7295fa7b15343d

Contents?: true

Size: 1.87 KB

Versions: 38

Compression:

Stored size: 1.87 KB

Contents

require "date"
# require "date/delta"

module HealthDataStandards
  module Import
    module CCR
      class ProviderImporter
        include Singleton
        include ProviderImportUtils

        # Extract Healthcare Providers from CCR
        #
        # @param [Nokogiri::XML::Document] doc It is expected that the root node of this document
        #        will have the "ccr" namespace registered to "urn:astm-org:CCR"
        # @return [Array] an array of providers found in the document
        
        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
        
        
        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
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
health-data-standards-3.5.3 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.5.2 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.5.1 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.5.0 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.6 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.5 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.4 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.3 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.2 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.1 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.4.0 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.12 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.3.0 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.11 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.10 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.8 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.7 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.6 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.5 lib/health-data-standards/import/ccr/provider_importer.rb
health-data-standards-3.2.4 lib/health-data-standards/import/ccr/provider_importer.rb