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
- #mood_for_id ⇒ 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
120 121 122 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 120 def self['authorDatetime'] || self['dispenserId'] end |
#code_and_codesystem ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 47 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
34 35 36 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 34 def self['qdmCategory'] == 'medication' && self['qdmStatus'] == 'dispensed' end |
#display_author_prescriber_id? ⇒ Boolean
38 39 40 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 38 def self['qdmCategory'] == 'medication' && self['qdmStatus'] == 'order' end |
#dose_quantity_value ⇒ Object
79 80 81 82 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 79 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
42 43 44 45 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 42 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
110 111 112 113 114 115 116 117 118 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 110 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 |
#mood_for_id ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 5 def mood_for_id = self['relatedTo']&.first # If there isn't a relatedTo id, return a default mood code return 'EVN' if .blank? # Find the qdmStatus for the dataElement for the relatedTo id status = @qdmPatient.dataElements.find { |de| de._id.to_s == }&.qdmStatus # Find a corresponding mood code for the qdmStatus. Default to EVN if none found { 'active' => 'EVN', 'administered' => 'EVN', 'dispensed' => 'EVN', 'expired' => 'EVN', 'intolerance' => 'EVN', 'payer' => 'EVN', 'performed' => 'EVN', 'discharge' => 'RQO', 'order' => 'RQO', 'recommended' => 'INT' }.fetch(status, 'EVN') end |
#multiple_codes? ⇒ Boolean
30 31 32 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 30 def multiple_codes? self[:dataElementCodes].size > 1 end |
#negated ⇒ Object
26 27 28 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 26 def negated self[:negationRationale].nil? ? false : true end |
#negation_ind ⇒ Object
22 23 24 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 22 def negation_ind self[:negationRationale].nil? ? "" : "negationInd=\"true\"" end |
#primary_code_and_codesystem ⇒ Object
56 57 58 59 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 56 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
75 76 77 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 75 def refills_as_repeat_number self['refills'] + 1 end |
#result_value ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 84 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.iso8601 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
103 104 105 106 107 108 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 103 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
61 62 63 64 65 66 67 68 69 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 61 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
71 72 73 |
# File 'lib/qrda-export/helper/cat1_view_helper.rb', line 71 def value_as_float self['value'].to_f end |