Class: QDM::Patient

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/qdm/patient.rb

Overview

app/models/qdm/patient.rb

Instance Method Summary collapse

Instance Method Details

#adverse_eventsObject

Helper method; returns adverse_event data element types on this patient.



56
57
58
# File 'app/models/qdm/patient.rb', line 56

def adverse_events
  get_data_elements('adverse_event')
end

#allergiesObject

Helper method; returns allergy data element types on this patient.



61
62
63
# File 'app/models/qdm/patient.rb', line 61

def allergies
  get_data_elements('allergy')
end

#assessmentsObject

Helper method; returns assessment data element types on this patient.



66
67
68
# File 'app/models/qdm/patient.rb', line 66

def assessments
  get_data_elements('assessment')
end

#care_experiencesObject

Helper method; returns care_experience data element types on this patient.



71
72
73
# File 'app/models/qdm/patient.rb', line 71

def care_experiences
  get_data_elements('care_experience')
end

#care_goalsObject

Helper method; returns care_goal data element types on this patient.



76
77
78
# File 'app/models/qdm/patient.rb', line 76

def care_goals
  get_data_elements('care_goal')
end

#communicationsObject

Helper method; returns communication data element types on this patient.



81
82
83
# File 'app/models/qdm/patient.rb', line 81

def communications
  get_data_elements('communication')
end

#conditionsObject

Helper method; returns condition data element types on this patient.



86
87
88
# File 'app/models/qdm/patient.rb', line 86

def conditions
  get_data_elements('condition')
end

#devicesObject

Helper method; returns device data element types on this patient.



91
92
93
# File 'app/models/qdm/patient.rb', line 91

def devices
  get_data_elements('device')
end

#diagnostic_studiesObject

Helper method; returns diagnostic_study data element types on this patient.



96
97
98
# File 'app/models/qdm/patient.rb', line 96

def diagnostic_studies
  get_data_elements('diagnostic_study')
end

#encountersObject

Helper method; returns encounter data element types on this patient.



101
102
103
# File 'app/models/qdm/patient.rb', line 101

def encounters
  get_data_elements('encounter')
end

#family_historyObject

Helper method; returns family_history data element types on this patient.



106
107
108
# File 'app/models/qdm/patient.rb', line 106

def family_history
  get_data_elements('family_history')
end

#functional_statusesObject

Helper method; returns functional_status data element types on this patient.



111
112
113
# File 'app/models/qdm/patient.rb', line 111

def functional_statuses
  get_data_elements('functional_status')
end

#get_by_hqmf_oid(hqmf_oid) ⇒ Object

Returns an array of elements that exist on this patient, that match the given HQMF data criteria OID.



20
21
22
# File 'app/models/qdm/patient.rb', line 20

def get_by_hqmf_oid(hqmf_oid)
  dataElements.where(hqmfOid: hqmf_oid) || []
end

#get_by_qrda_oid(qrda_oid) ⇒ Object

Returns an array of elements that exist on this patient, that match the given QRDA data criteria OID.



26
27
28
# File 'app/models/qdm/patient.rb', line 26

def get_by_qrda_oid(qrda_oid)
  dataElements.where(qrdaOid: qrda_oid) || []
end

#get_data_elements(category = nil, status = nil) ⇒ Object

Returns an array of elements that exist on this patient. Optionally takes a category and/or, which returns all elements of that QDM category. Example: patient.get_data_elements(‘encounters’) will return all Encounter QDM data types active on the patient.



45
46
47
48
49
50
51
52
53
# File 'app/models/qdm/patient.rb', line 45

def get_data_elements(category = nil, status = nil)
  if category && status
    dataElements.where(qdmCategory: category, qdmStatus: status) || []
  elsif category
    dataElements.where(qdmCategory: category) || []
  else
    dataElements || []
  end
end

#idObject

Return the Mongo id.



206
207
208
# File 'app/models/qdm/patient.rb', line 206

def id
  _id
end

#immunizationsObject

Helper method; returns immunization data element types on this patient.



116
117
118
# File 'app/models/qdm/patient.rb', line 116

def immunizations
  get_data_elements('immunization')
end

#interventionsObject

Helper method; returns intervention data element types on this patient.



121
122
123
# File 'app/models/qdm/patient.rb', line 121

def interventions
  get_data_elements('intervention')
end

#laboratory_testsObject

Helper method; returns laboratory_test data element types on this patient.



126
127
128
# File 'app/models/qdm/patient.rb', line 126

def laboratory_tests
  get_data_elements('laboratory_test')
end

#medical_equipmentObject

Helper method; returns medical_equipment data element types on this patient.



131
132
133
# File 'app/models/qdm/patient.rb', line 131

def medical_equipment
  get_data_elements('medical_equipment')
end

#medicationsObject

Helper method; returns medication data element types on this patient.



136
137
138
# File 'app/models/qdm/patient.rb', line 136

def medications
  get_data_elements('medication')
end

#patient_characteristicsObject

Helper method; returns patient_characteristic data element types on this patient.



141
142
143
# File 'app/models/qdm/patient.rb', line 141

def patient_characteristics
  get_data_elements('patient_characteristic')
end

#physical_examsObject

Helper method; returns physical_exam data element types on this patient.



146
147
148
# File 'app/models/qdm/patient.rb', line 146

def physical_exams
  get_data_elements('physical_exam')
end

#preferencesObject

Helper method; returns preference data element types on this patient.



151
152
153
# File 'app/models/qdm/patient.rb', line 151

def preferences
  get_data_elements('preference')
end

#proceduresObject

Helper method; returns procedure data element types on this patient.



161
162
163
# File 'app/models/qdm/patient.rb', line 161

def procedures
  get_data_elements('procedure')
end

#provider_characteristicsObject

Helper method; returns provider_characteristic data element types on this patient.



156
157
158
# File 'app/models/qdm/patient.rb', line 156

def provider_characteristics
  get_data_elements('provider_characteristic')
end

#resultsObject

Helper method; returns result data element types on this patient.



166
167
168
# File 'app/models/qdm/patient.rb', line 166

def results
  get_data_elements('result')
end

#risk_category_assessmentsObject

Helper method; returns risk_category_assessment data element types on this patient.



171
172
173
# File 'app/models/qdm/patient.rb', line 171

def risk_category_assessments
  get_data_elements('risk_category_assessment')
end

#shift_dates(seconds) ⇒ Object

Shift all data element fields that deal with dates by the given value. Given value should be in seconds. Positive values shift forward, negative values shift backwards.

Note: This will shift dates of the birthdate and dates on the data elements that exist on the patient.



36
37
38
39
# File 'app/models/qdm/patient.rb', line 36

def shift_dates(seconds)
  self.birthDatetime = (birthDatetime.utc.to_time + seconds.seconds).to_datetime
  dataElements.each { |element| element.shift_dates(seconds) }
end

#social_historyObject

Helper method; returns social_history data element types on this patient.



176
177
178
# File 'app/models/qdm/patient.rb', line 176

def social_history
  get_data_elements('social_history')
end

#substancesObject

Helper method; returns substance data element types on this patient.



181
182
183
# File 'app/models/qdm/patient.rb', line 181

def substances
  get_data_elements('substance')
end

#symptomsObject

Helper method; returns symptom data element types on this patient.



186
187
188
# File 'app/models/qdm/patient.rb', line 186

def symptoms
  get_data_elements('symptom')
end

#system_characteristicsObject

Helper method; returns system_characteristic data element types on this patient.



191
192
193
# File 'app/models/qdm/patient.rb', line 191

def system_characteristics
  get_data_elements('system_characteristic')
end

#to_json(options = nil) ⇒ Object

Include ‘_type’ in any JSON output. This is necessary for deserialization.



211
212
213
# File 'app/models/qdm/patient.rb', line 211

def to_json(options = nil)
  serializable_hash(methods: :_type, include: :_type).to_json(options)
end

#transfersObject

Helper method; returns transfer data element types on this patient.



196
197
198
# File 'app/models/qdm/patient.rb', line 196

def transfers
  get_data_elements('transfer')
end

#vital_signsObject

Helper method; returns vital_sign data element types on this patient.



201
202
203
# File 'app/models/qdm/patient.rb', line 201

def vital_signs
  get_data_elements('vital_sign')
end