Sha256: e22949f070787e5993c8f5fc1487ed63b01bbd2e3389801371af58b306a546f9

Contents?: true

Size: 1.65 KB

Versions: 7

Compression:

Stored size: 1.65 KB

Contents

module HealthDataStandards
  module Import
    module Cat1
      class EncounterPerformedImporter < CDA::EncounterImporter
        def initialize(entry_finder=CDA::EntryFinder.new("./cda:entry/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.23']"))
          super(entry_finder)
          @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation"
        end

        def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
          encounter = super
          extract_admit_time(entry_element, encounter)
          extract_reason(entry_element, encounter, nrh)
          encounter
        end

        private

        def extract_reason(parent_element, encounter, nrh)
          reason_element = parent_element.at_xpath(@reason_xpath)
          if reason_element
            reason = Entry.new
            extract_codes(reason_element, reason)
            extract_reason_description(reason_element, reason, nrh)
            extract_status(reason_element, reason)
            extract_dates(reason_element, reason)
            extract_workaround_codes(reason_element, reason)
            encounter.reason = reason
          end
        end

        def extract_workaround_codes(parent_element, entry)
          value = parent_element.at_xpath("./cda:value")
          entry['code'] = value['code']
          entry['code_system'] = CodeSystemHelper.code_system_for(value['codeSystem'])
          entry['codeSystemName'] = CodeSystemHelper.code_system_for(value['codeSystem'])
        end

        def extract_admit_time(parent_element, encounter)
          encounter.admit_time = encounter.start_time
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
health-data-standards-3.6.1 lib/health-data-standards/import/cat1/encounter_performed_importer.rb
health-data-standards-3.5.3 lib/health-data-standards/import/cat1/encounter_performed_importer.rb
health-data-standards-3.5.2 lib/health-data-standards/import/cat1/encounter_performed_importer.rb
health-data-standards-3.5.1 lib/health-data-standards/import/cat1/encounter_performed_importer.rb
health-data-standards-3.5.0 lib/health-data-standards/import/cat1/encounter_performed_importer.rb
health-data-standards-3.4.6 lib/health-data-standards/import/cat1/encounter_performed_importer.rb
health-data-standards-3.4.5 lib/health-data-standards/import/cat1/encounter_performed_importer.rb