Class: QdmPatient
Instance Method Summary
collapse
#care_partner_entity?, #location_entity?, #organization_entity?, #patient_entity?, #practitioner_entity?
#birthdate, #ethnic_group, #expiration, #gender, #given_name, #mrn, #onc_gender_code?, #patient, #payer, #provider, #provider_ccn, #provider_npi, #provider_street, #provider_tin, #provider_type_code, #race
Constructor Details
#initialize(patient, include_style) ⇒ QdmPatient
Returns a new instance of QdmPatient.
9
10
11
12
13
14
15
16
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 9
def initialize(patient, include_style)
@include_style = include_style
@patient = patient
@qdmPatient = patient.qdmPatient
@patient_addresses = patient['addresses']
@patient_email = patient['email']
@patient_telecoms = patient['telecoms']
end
|
Instance Method Details
#code_code_system_string ⇒ Object
98
99
100
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 98
def code_code_system_string
code_for_element(self)
end
|
#code_description(element = self) ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 110
def code_description(element = self)
has_descriptions = @patient.respond_to?(:code_description_hash) && !@patient.code_description_hash.empty?
return " - #{@patient.code_description_hash["#{element['code']}:#{element['system']}".tr('.', '_')]}" if has_descriptions
""
end
|
#code_for_element(element) ⇒ Object
102
103
104
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 102
def code_for_element(element)
element ? "#{element['code']} (#{HQMF::Util::CodeSystemHelper.code_system_for(element['system'])})#{code_description(element)}" : ''
end
|
#code_system_name ⇒ Object
106
107
108
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 106
def code_system_name
HQMF::Util::CodeSystemHelper.code_system_for(self['system'])
end
|
#convert_iso_timestamp_to_human_readable(iso) ⇒ Object
164
165
166
167
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 164
def convert_iso_timestamp_to_human_readable(iso)
t = Time.parse(iso).in_time_zone
t.strftime('%B %e, %Y %l:%M%P')
end
|
#data_elements ⇒ Object
48
49
50
51
52
53
54
55
|
# 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) ⇒ Object
118
119
120
121
122
123
124
125
126
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 118
def demographic_code_description(code)
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
|
#diagnosis_string ⇒ Object
145
146
147
148
149
150
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 145
def diagnosis_string
dx_string = ''
dx_string += "</br> rank: #{self['rank']}" if self['rank']
dx_string += "</br> presentOnAdmissionIndicator: #{self['presentOnAdmissionIndicator']['code']}" if self['presentOnAdmissionIndicator']
dx_string
end
|
#end_time? ⇒ Boolean
152
153
154
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 152
def end_time?
self['high'] && DateTime.parse(self['high']).year < 3000
end
|
#entity_string ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 68
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['organizationType'])}"
elsif location_entity?
"</br> Location: #{identifier_for_element(self['identifier'])}
</br> Location Type: #{code_for_element(self['locationType'])}"
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
|
156
157
158
159
160
161
162
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 156
def format_time
str = render('{{.}}').to_s.strip
return "" if str.empty? || str == "null"
convert_iso_timestamp_to_human_readable(str)
rescue ArgumentError, TypeError => _e
str
end
|
#identifier_for_element(identifier) ⇒ Object
94
95
96
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 94
def identifier_for_element(identifier)
identifier ? "#{identifier['value']} (#{identifier['namingSystem']})" : ''
end
|
#identifier_string ⇒ Object
90
91
92
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 90
def identifier_string
identifier_for_element(self)
end
|
#include_style? ⇒ Boolean
44
45
46
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 44
def include_style?
@include_style
end
|
#nested_code_string ⇒ Object
141
142
143
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 141
def nested_code_string
code_for_element(self['code'])
end
|
#patient_addresses ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 18
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|
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 ⇒ Object
37
38
39
40
41
42
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 37
def patient_telecoms
@patient_telecoms ||= [CQM::Telecom.new(use: 'HP', value: '555-555-2003')]
@patient_telecoms << CQM::Telecom.new(use: 'HP', value: @patient_email) if @patient_email
@patient_telecoms.map { |telecom| "(#{telecom['use']}) #{telecom['value']}" }.join("<br>")
end
|
#result_string ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 128
def result_string
return unit_string if self['value']
return code_code_system_string if self['code']
begin
DateTime.parse(self['result'])
rescue ArgumentError, TypeError
self['result'].is_a?(Numeric) ? trimed_value(self['result']) : self['result']
end
end
|
#trimed_value(number) ⇒ Object
62
63
64
65
66
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 62
def trimed_value(number)
i = number.to_i
f = number.to_f
i == f ? i : f
end
|
#unit_string ⇒ Object
57
58
59
60
|
# File 'lib/html-export/qdm-patient/qdm_patient.rb', line 57
def unit_string
return trimed_value(self['value']).to_s if !self['unit'] || self['unit'] == '1'
"#{trimed_value(self['value'])} #{self['unit']}"
end
|