Class: HealthDataStandards::Import::C32::InsuranceProviderImporter

Inherits:
HealthDataStandards::Import::CDA::SectionImporter show all
Defined in:
lib/health-data-standards/import/c32/insurance_provider_importer.rb

Instance Attribute Summary

Attributes inherited from HealthDataStandards::Import::CDA::SectionImporter

#check_for_usable, #code_xpath, #status_xpath

Instance Method Summary collapse

Methods inherited from HealthDataStandards::Import::CDA::SectionImporter

#create_entries

Methods included from HealthDataStandards::Import::CDA::LocatableImportUtils

#import_address, #import_telecom

Constructor Details

#initialize(entry_finder = CDA::EntryFinder.new("//cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.1.26']")) ⇒ InsuranceProviderImporter

Returns a new instance of InsuranceProviderImporter.



6
7
8
9
10
# File 'lib/health-data-standards/import/c32/insurance_provider_importer.rb', line 6

def initialize(entry_finder=CDA::EntryFinder.new("//cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.1.26']"))
  super(entry_finder)
  @check_for_usable = false # needs to be this way becase InsuranceProvider does not respond
                            # to usable?
end

Instance Method Details

#create_entry(payer_element, nrh = CDA::NarrativeReferenceHandler.new) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/health-data-standards/import/c32/insurance_provider_importer.rb', line 12

def create_entry(payer_element, nrh = CDA::NarrativeReferenceHandler.new)
  ip = InsuranceProvider.new
  type = extract_code(payer_element, "./cda:code")
  ip.type = type['code'] if type
  ip.payer = import_organization(payer_element.at_xpath("./cda:performer/cda:assignedEntity[cda:code[@code='PAYOR']]"))
  ip.guarantors = extract_guarantors(payer_element.xpath("./cda:performer[cda:assignedEntity[cda:code[@code='GUAR']]]"))
  ip.subscriber = import_person(payer_element.at_xpath("./cda:participant[@typeCode='HLD']/cda:participantRole"))
  member_info_element = payer_element.at_xpath("cda:participant[@typeCode='COV']")
  extract_dates(member_info_element, ip, "time")
  name = payer_element.at_xpath("./cda:entryRelationship[@typeCode='REFR']/cda:act[@classCode='ACT' and @moodCode='DEF']/cda:text")
  ip.name = name.try(:text)
  patient_element = member_info_element.at_xpath("./cda:participantRole[@classCode='PAT']")
  if patient_element
    ip.member_id = patient_element.at_xpath("./cda:id")
    ip.relationship = extract_code(patient_element, "./cda:code")
  end
  ip.financial_responsibility_type = extract_code(payer_element, "./cda:performer/cda:assignedEntity/cda:code")
  ip
end

#extract_guarantors(guarantor_elements) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/health-data-standards/import/c32/insurance_provider_importer.rb', line 32

def extract_guarantors(guarantor_elements)
  guarantor_elements.map do |guarantor_element|
    guarantor = Guarantor.new
    extract_dates(guarantor_element, guarantor, "time")
    guarantor_entity = guarantor_element.at_xpath("./cda:assignedEntity")
    guarantor.person = import_person(guarantor_entity.at_xpath("./cda:assignedPerson"))
    guarantor.organization = import_organization(guarantor_entity.at_xpath("./cda:representedOrganization"))
    guarantor
  end
end