Sha256: d2bac345893a359ccbd588b8f3a417695eed114fd56efb3c394deb160345ff64

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

module HealthDataStandards
  module Export
    module ViewHelper
      def code_display(entry, tag_name='code', extra_content=nil)
        if entry.single_code_value?
          code = entry.codes.first[1].first
          code_system_oid = QME::Importer::CodeSystemHelper.oid_for_code_system(entry.codes.first[0])
          "<#{tag_name} code=\"#{code}\" codeSystem=\"#{code_system_oid}\" #{extra_content}><originalText>#{ERB::Util.html_escape entry.description}</originalText></#{tag_name}>"
        else
          all_codes = []
          entry.codes.each_pair {|key, values| values.each {|v| all_codes << {:set => key, :value => v}}}
          first_code = all_codes.first
          code_string = "<#{tag_name} code=\"#{first_code[:value]}\" codeSystem=\"#{QME::Importer::CodeSystemHelper.oid_for_code_system(first_code[:set])}\">\n"
          code_string += "<originalText>#{ERB::Util.html_escape entry.description}</originalText>\n"
          all_codes[1..-1].each do |cv|
            code_string += "<translation code=\"#{cv[:value]}\" codeSystem=\"#{QME::Importer::CodeSystemHelper.oid_for_code_system(cv[:set])}\"/>\n"
          end
          code_string += "</#{tag_name}>"
          code_string
        end
      end
      
      def status_code_for(entry)
        case entry.status.to_s
        when 'active'
          '55561003'
        when 'inactive'
          '73425007'
        when 'resolved'
          '413322009'
        end
      end      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
health-data-standards-0.3.0 lib/health-data-standards/export/view_helper.rb
health-data-standards-0.2.0 lib/health-data-standards/export/view_helper.rb
health-data-standards-0.1.0 lib/health-data-standards/export/view_helper.rb