Sha256: 03bfc3500428b1129ce8f2c766ce618ba27806e4ef75b0defefa3209e5fd3e18

Contents?: true

Size: 1.4 KB

Versions: 16

Compression:

Stored size: 1.4 KB

Contents

module HealthDataStandards
  module Export
    class HTML
      def initialize
        template_helper = TemplateHelper.new('html', 'html')
        @rendering_context = RenderingContext.new
        @rendering_context.template_helper = template_helper
        @rendering_context.extensions = [HealthDataStandards::Export::Helper::HTMLViewHelper]
        @code_map = nil
      end

      # For environments where value sets are scoped, say by measure, they can be passed in
      def export(patient, measures=[], scoped_value_sets = nil)
        if scoped_value_sets
          @code_map = self.build_code_map(scoped_value_sets) # Don't cache if value sets are passed in
        else
          @code_map ||= self.build_code_map
        end
        @rendering_context.render(:template => 'show', :locals => {:patient => patient, :code_map => @code_map, :measures => measures})
      end
      
      def build_code_map(scoped_value_sets = nil)
        super_code_map = {}
        val_set_array = (scoped_value_sets || HealthDataStandards::SVS::ValueSet.all).to_a
        val_set_array.each do |valset| 
          valset.concepts.each do |concept|
            super_code_map[concept.code_system_name] ||= {}
            super_code_map[concept.code_system_name][concept.code] = concept.display_name unless super_code_map[concept.code_system_name][concept.code]
          end
        end
        super_code_map
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
health-data-standards-4.3.5 lib/health-data-standards/export/html.rb
health-data-standards-4.3.4 lib/health-data-standards/export/html.rb
health-data-standards-4.3.3 lib/health-data-standards/export/html.rb
health-data-standards-4.3.2 lib/health-data-standards/export/html.rb
health-data-standards-4.3.1 lib/health-data-standards/export/html.rb
health-data-standards-4.3.0 lib/health-data-standards/export/html.rb
health-data-standards-4.2.0 lib/health-data-standards/export/html.rb
health-data-standards-4.1.0 lib/health-data-standards/export/html.rb
health-data-standards-4.0.6 lib/health-data-standards/export/html.rb
health-data-standards-4.0.5 lib/health-data-standards/export/html.rb
health-data-standards-4.0.4 lib/health-data-standards/export/html.rb
health-data-standards-4.0.3 lib/health-data-standards/export/html.rb
health-data-standards-4.0.2 lib/health-data-standards/export/html.rb
health-data-standards-4.0.1 lib/health-data-standards/export/html.rb
health-data-standards-4.0.0 lib/health-data-standards/export/html.rb
health-data-standards-3.7.0 lib/health-data-standards/export/html.rb