Module: Qrda::Export::Helper::Cat1ViewHelper
- Included in:
- Qrda1R5
- Defined in:
- lib/qrda-export/helper/cat1_view_helper.rb
Instance Method Summary collapse
- #authordatetime_or_dispenserid? ⇒ Boolean
- #code_and_codesystem ⇒ Object
- #display_author_dispenser_id? ⇒ Boolean
- #display_author_prescriber_id? ⇒ Boolean
- #dose_quantity_value ⇒ Object
- #id_or_null_flavor ⇒ Object
- #integer_or_pq(number, unit = nil) ⇒ Object
- #multiple_codes? ⇒ Boolean
- #negated ⇒ Object
- #negation_ind ⇒ Object
- #primary_code_and_codesystem ⇒ Object
- #refills_as_repeat_number ⇒ Object
- #result_value ⇒ Object
- #result_value_as_string(result) ⇒ Object
- #translation_codes_and_codesystem_list ⇒ Object
- #value_as_float ⇒ Object
Instance Method Details
#authordatetime_or_dispenserid? ⇒ Boolean
103 104 105 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 103 def self['authorDatetime'] || self['dispenserId'] end |
#code_and_codesystem ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 30 def code_and_codesystem oid = self['system'] || self['codeSystem'] if oid == '1.2.3.4.5.6.7.8.9.10' "nullFlavor=\"NA\" sdtc:valueSet=\"#{self['code']}\"" else "code=\"#{self['code']}\" codeSystem=\"#{oid}\" codeSystemName=\"#{HQMF::Util::CodeSystemHelper.code_system_for(oid)}\"" end end |
#display_author_dispenser_id? ⇒ Boolean
17 18 19 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 17 def self['qdmCategory'] == 'medication' && self['qdmStatus'] == 'dispensed' end |
#display_author_prescriber_id? ⇒ Boolean
21 22 23 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 21 def self['qdmCategory'] == 'medication' && self['qdmStatus'] == 'order' end |
#dose_quantity_value ⇒ Object
62 63 64 65 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 62 def dose_quantity_value return "<doseQuantity value=\"#{value_as_float}\" unit=\"#{self['unit']}\"/>" if self['unit'] && self['unit'] != '' "<doseQuantity value=\"#{value_as_float}\" />" end |
#id_or_null_flavor ⇒ Object
25 26 27 28 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 25 def id_or_null_flavor return "<id root=\"#{self['namingSystem']}\" extension=\"#{self['value']}\"/>" if self['namingSystem'] && self['value'] "<id nullFlavor=\"NA\"/>" end |
#integer_or_pq(number, unit = nil) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 93 def integer_or_pq(number, unit = nil) i = number.to_i f = number.to_f if i == f unit ? "<value xsi:type=\"PQ\" value=\"#{i}\" unit=\"#{unit}\"/>" : "<value xsi:type=\"INT\" value=\"#{i}\"/>" else unit ? "<value xsi:type=\"PQ\" value=\"#{f}\" unit=\"#{unit}\"/>" : "<value xsi:type=\"REAL\" value=\"#{f}\"/>" end end |
#multiple_codes? ⇒ Boolean
13 14 15 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 13 def multiple_codes? self[:dataElementCodes].size > 1 end |
#negated ⇒ Object
9 10 11 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 9 def negated self[:negationRationale].nil? ? false : true end |
#negation_ind ⇒ Object
5 6 7 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 5 def negation_ind self[:negationRationale].nil? ? "" : "negationInd=\"true\"" end |
#primary_code_and_codesystem ⇒ Object
39 40 41 42 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 39 def primary_code_and_codesystem oid = self[:dataElementCodes][0]['system'] || self[:dataElementCodes][0]['codeSystem'] "code=\"#{self[:dataElementCodes][0]['code']}\" codeSystem=\"#{oid}\" codeSystemName=\"#{HQMF::Util::CodeSystemHelper.code_system_for(oid)}\"" end |
#refills_as_repeat_number ⇒ Object
58 59 60 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 58 def refills_as_repeat_number self['refills'] + 1 end |
#result_value ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 67 def result_value return "<value xsi:type=\"CD\" nullFlavor=\"UNK\"/>" unless self['result'] result_string = if self['result'].is_a? Array result_value_as_string(self['result'][0]) elsif self['result'].is_a? Hash result_value_as_string(self['result']) elsif self['result'].is_a? String begin DateTime.parse self['result'] "<value xsi:type=\"TS\" #{value_or_null_flavor(self['result'])}/>" rescue StandardError "<value xsi:type=\"ST\">#{self['result']}</value>" end elsif !self['result'].nil? integer_or_pq(self['result']) end result_string end |
#result_value_as_string(result) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 86 def result_value_as_string(result) return "<value xsi:type=\"CD\" nullFlavor=\"UNK\"/>" unless result oid = result['system'] || result['codeSystem'] return "<value xsi:type=\"CD\" code=\"#{result['code']}\" codeSystem=\"#{oid}\" codeSystemName=\"#{HQMF::Util::CodeSystemHelper.code_system_for(oid)}\"/>" if result['code'] return integer_or_pq(result['value'], result['unit']) if result['unit'] && result['unit'] != '' end |
#translation_codes_and_codesystem_list ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 44 def translation_codes_and_codesystem_list translation_list = "" self[:dataElementCodes].each_with_index do |_dec, index| next if index.zero? oid = self[:dataElementCodes][index]['system'] || self[:dataElementCodes][index]['codeSystem'] translation_list += "<translation code=\"#{self[:dataElementCodes][index]['code']}\" codeSystem=\"#{oid}\" codeSystemName=\"#{HQMF::Util::CodeSystemHelper.code_system_for(oid)}\"/>" end translation_list end |
#value_as_float ⇒ Object
54 55 56 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 54 def value_as_float self['value'].to_f end |