Sha256: 159b57aef34456a9e3313d25d553fba152d694489116a1c8ad457bc569792880
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
module HealthDataStandards module Export module ViewHelper def code_display(entry, options={}) options['tag_name'] ||= 'code' options['attribute'] ||= :codes code_string = nil preferred_code = entry.preferred_code(options['preferred_code_sets'], options['attribute']) if preferred_code code_system_oid = HealthDataStandards::Util::CodeSystemHelper.oid_for_code_system(preferred_code['code_set']) code_string = "<#{options['tag_name']} code=\"#{preferred_code['code']}\" codeSystem=\"#{code_system_oid}\" #{options['extra_content']}>" else code_string = "<#{options['tag_name']} nullFlavor=\"UNK\" #{options['extra_content']}>" end code_string += "<originalText>#{ERB::Util.html_escape entry.description}</originalText>" if entry.respond_to?(:description) if entry.respond_to?(:translation_codes) entry.translation_codes(options['preferred_code_sets']).each do |translation| code_string += "<translation code=\"#{translation['code']}\" codeSystem=\"#{HealthDataStandards::Util::CodeSystemHelper.oid_for_code_system(translation['code_set'])}\"/>\n" end end code_string += "</#{options['tag_name']}>" code_string end def status_code_for(entry) case entry.status.to_s.downcase when 'active' '55561003' when 'inactive' '73425007' when 'resolved' '413322009' end end def value_or_null_flavor(time) if time return "value='#{Time.at(time).utc.to_formatted_s(:number)}'" else return "nullFlavor='UNK'" end end def quantity_display(value, tag_name="value") return unless value "<#{tag_name} value=\"#{value['value']}\" units=\"#{value['unit']}\" />" end def time_if_not_nil(*args) args.compact.map {|t| Time.at(t)}.first 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/export/view_helper.rb |
health-data-standards-0.8.0 | lib/health-data-standards/export/view_helper.rb |