Sha256: 571551358878c1ff9c2d5b64001472c802de93fdc1dc776c0277fe16c7039951

Contents?: true

Size: 1.78 KB

Versions: 47

Compression:

Stored size: 1.78 KB

Contents

module HealthDataStandards
  module Import
    module C32
      class ConditionImporter < CDA::ConditionImporter
        
        def initialize
          super
          @death_xpath = "./cda:entryRelationship[@typeCode='CAUS']/cda:observation"
          @cod_xpath = "#{@death_xpath}/cda:code[@code='419620001']"
          @time_of_death_xpath = "#{@death_xpath}/cda:effectiveTime/@value"
        end
        
        def create_entry(entry_element, nrh = CDA::NarrativeReferenceHandler.new)
          condition = super
          extract_cause_of_death(entry_element, condition)
          extract_type(entry_element, condition)
          condition
        end

        private

        def extract_cause_of_death(entry_element, condition)
          cod = entry_element.at_xpath(@cod_xpath)
          condition.cause_of_death = cod.present?
          time_of_death = entry_element.at_xpath(@time_of_death_xpath)
          condition.time_of_death = HL7Helper.timestamp_to_integer(time_of_death.text) if time_of_death
        end

        def extract_type(entry_element, condition)
          code_element = entry_element.at_xpath('./cda:code')
          if code_element
            condition.type = case code_element['code']
                               when '404684003'  then 'Finding'
                               when '418799008'  then 'Symptom'
                               when '55607006'   then 'Problem'
                               when '409586006'  then 'Complaint'
                               when '64572001'   then 'Condition'
                               when '282291009'  then 'Diagnosis'
                               when '248536006'  then 'Functional limitation'
                               else nil
                             end
          end
        end

      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
health-data-standards-4.3.5 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.3.4 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.3.3 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.3.2 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.3.1 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.3.0 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.2.0 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.1.0 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.6 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.5 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.4 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.3 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.2 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.1 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-4.0.0 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-3.7.0 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-3.6.1 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-3.5.3 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-3.5.2 lib/health-data-standards/import/c32/condition_importer.rb
health-data-standards-3.5.1 lib/health-data-standards/import/c32/condition_importer.rb