class QdmPatient
Public Class Methods
new(patient, include_style)
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 8 def initialize(patient, include_style) @include_style = include_style @patient = patient @qdmPatient = patient.qdmPatient @patient_addresses = patient['addresses'] @patient_telecoms = patient['telecoms'] end
Public Instance Methods
code_code_system_string()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 89 def code_code_system_string code_for_element(self) end
code_description(element = self)
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 101 def code_description(element = self) has_descriptions = @patient.respond_to?(:code_description_hash) && !@patient.code_description_hash.empty? # mongo keys cannot contain '.', so replace all '.', key example: '21112-8:2_16_840_1_113883_6_1' return " - #{@patient.code_description_hash["#{element['code']}:#{element['system']}".tr('.', '_')]}" if has_descriptions # no code description available "" end
code_for_element(element)
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 93 def code_for_element(element) "#{element['code']} (#{HQMF::Util::CodeSystemHelper.code_system_for(element['system'])})#{code_description(element)}" end
code_system_name()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 97 def code_system_name HQMF::Util::CodeSystemHelper.code_system_for(self['system']) end
data_elements()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 48 def data_elements de_hash = {} @qdmPatient.dataElements.each do |data_element| data_element['methodCode'] = data_element['method'] if data_element['method'] de_hash[data_element._type] ? de_hash[data_element._type][:element_list] << data_element : de_hash[data_element._type] = { title: data_element._type, element_list: [data_element] } end JSON.parse(de_hash.values.to_json) end
demographic_code_description(code)
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 109 def demographic_code_description(code) # only have code, don't need code system has_descriptions = code && @patient.respond_to?(:code_description_hash) && !@patient.code_description_hash.empty? if has_descriptions key = @patient.code_description_hash.keys.detect { |k| k.starts_with?("#{send(code)}:") } return " - #{@patient.code_description_hash[key]}" end "" end
end_time?()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 130 def end_time? self['high'] && DateTime.parse(self['high']).year < 3000 end
entity_string()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 62 def entity_string if care_partner_entity? "</br> Care Partner: #{identifier_for_element(self['identifier'])} </br> Care Partner Relationship: #{code_for_element(self['relationship'])}" elsif organization_entity? "</br> Organization: #{identifier_for_element(self['identifier'])} </br> Organization Type: #{code_for_element(self['type'])}" elsif patient_entity? "</br> Patient: #{identifier_for_element(self['identifier'])}" elsif practitioner_entity? "</br> Practitioner: #{identifier_for_element(self['identifier'])} </br> Practitioner Role: #{code_for_element(self['role'])}, </br> Practitioner Specialty: #{code_for_element(self['specialty'])}, </br> Practitioner Qualification: #{code_for_element(self['qualification'])}" else "</br> Entity: #{identifier_for_element(self['identifier'])}" end end
identifier_for_element(identifier)
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 85 def identifier_for_element(identifier) "#{identifier['value']} (#{identifier['namingSystem']})" end
identifier_string()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 81 def identifier_string identifier_for_element(self) end
include_style?()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 44 def include_style? @include_style end
nested_code_string()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 126 def nested_code_string code_for_element(self['code']) end
patient_addresses()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 16 def patient_addresses @patient_addresses ||= [CQM::Address.new( use: 'HP', street: ['202 Burlington Rd.'], city: 'Bedford', state: 'MA', zip: '01730', country: 'US' )] address_str = "" @patient_addresses.each do |address| # create formatted address address_str += "<address>" address['street'].each { |street| address_str += "#{street}<br>" } address_str += "#{address['city']}, #{address['state']} #{address['zip']}<br> #{address['country']} </address>" end address_str end
patient_telecoms()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 35 def patient_telecoms @patient_telecoms ||= [CQM::Telecom.new( use: 'HP', value: '555-555-2003' )] # create formatted telecoms @patient_telecoms.map { |telecom| "(#{telecom['use']}) #{telecom['value']}" }.join("<br>") end
result_string()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 119 def result_string return unit_string if self['value'] return code_code_system_string if self['code'] self['result'] end
unit_string()
click to toggle source
# File lib/html-export/qdm-patient/qdm_patient.rb, line 57 def unit_string return "#{self['value']} " if !self['unit'] || self['unit'] == '1' "#{self['value']} #{self['unit']}" end