Sha256: 86b403db7686e02df066d84e28254bf6e1709b89c1fb11c45966eedf836b448e

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module HealthDataStandards
  module Import
    module GreenC32
      class EncounterImporter < SectionImporter
        include Singleton
        
        def initialize
          super
        end
        
        def import(encounter_xml)
          encounter = Encounter.new
          encounter_xml.root.add_namespace_definition('gc32', "urn:hl7-org:greencda:c32")
          encounter_element = encounter_xml.xpath("/gc32:encounter")
          extract_entry(encounter_element, encounter)
          extract_code(encounter_element, encounter, "./gc32:dischargeDisposition", :discharge_disposition)
          extract_code(encounter_element, encounter, "./gc32:admissionType", :admit_type)
          extract_code(encounter_element, encounter, "./gc32:reasonForVisit", :reason)
          extract_code(encounter_element, encounter)
          extract_facility(encounter_element, encounter)
          
          free_text = encounter_element.xpath("./gc32:freeText").first

          if free_text
            encounter.free_text = free_text.content
          end
          
          encounter
        end
        
        def extract_facility(encounter_element, encounter)
          facility_element = encounter_element.xpath("./gc32:facility").first
          if facility_element
            organization = extract_organization(facility_element)
            encounter.facility = organization
          end
        end
        
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
health-data-standards-0.8.1 lib/health-data-standards/import/green_c32/encounter_importer.rb
health-data-standards-0.8.0 lib/health-data-standards/import/green_c32/encounter_importer.rb