Module: AthenaHealth::Endpoints::Patients

Included in:
Client
Defined in:
lib/athena_health/endpoints/patients.rb

Instance Method Summary collapse

Instance Method Details

#add_patient_medication(practice_id:, department_id:, patient_id:, medication_id:, params: {}) ⇒ Object



273
274
275
276
277
278
279
# File 'lib/athena_health/endpoints/patients.rb', line 273

def add_patient_medication(practice_id:, department_id:, patient_id:, medication_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/medications",
    method: :post,
    body: params.merge!(departmentid: department_id, medicationid: medication_id)
  )
end

#add_patient_preferred_pharmacy(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



199
200
201
202
203
204
205
# File 'lib/athena_health/endpoints/patients.rb', line 199

def add_patient_preferred_pharmacy(practice_id:, department_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/pharmacies/preferred",
    method: :put,
    params: params.merge!(departmentid: department_id)
  )
end

#all_patients(practice_id:, department_id:, params: {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/athena_health/endpoints/patients.rb', line 4

def all_patients(practice_id:, department_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  PatientCollection.new(response)
end

#create_patient(practice_id:, department_id:, params: {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/athena_health/endpoints/patients.rb', line 34

def create_patient(practice_id:, department_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients",
    method: :post,
    body: params.merge!(departmentid: department_id)
  )
end

#create_patient_case(practice_id:, patient_id:, params: {}) ⇒ Object



378
379
380
381
382
383
384
# File 'lib/athena_health/endpoints/patients.rb', line 378

def create_patient_case(practice_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/documents/patientcase",
    method: :post,
    body: params
  )
end

#create_patient_document(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



163
164
165
166
167
168
169
# File 'lib/athena_health/endpoints/patients.rb', line 163

def create_patient_document(practice_id:, department_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/documents",
    method: :post,
    body: params.merge!(departmentid: department_id.to_s)
  )
end

#create_patient_insurance(practice_id:, patient_id:, insurance_package_id:, sequence_number:, params: {}) ⇒ Object



315
316
317
318
319
320
321
322
# File 'lib/athena_health/endpoints/patients.rb', line 315

def create_patient_insurance(practice_id:, patient_id:, insurance_package_id:, sequence_number:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/insurances",
    method: :post,
    body: params.merge!(insurancepackageid: insurance_package_id, sequencenumber: sequence_number)
  )
  Insurance.new(response[0])
end

#create_patient_problem(practice_id:, department_id:, patient_id:, snomed_code:, params: {}) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/athena_health/endpoints/patients.rb', line 58

def create_patient_problem(practice_id:, department_id:, patient_id:, snomed_code:, params: {})
  @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/problems",
    method: :post,
    body: params.merge!(departmentid: department_id, snomedcode: snomed_code)
  )
end

#delete_patient(practice_id:, patient_id:) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/athena_health/endpoints/patients.rb', line 50

def delete_patient(practice_id:, patient_id:)
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}",
    method: :put,
    params: { status: 'deleted' }
  )
end

#delete_patient_insurance(practice_id:, patient_id:, sequence_number:, params: {}) ⇒ Object



332
333
334
335
336
337
338
# File 'lib/athena_health/endpoints/patients.rb', line 332

def delete_patient_insurance(practice_id:, patient_id:, sequence_number:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/insurances",
    method: :delete,
    params: params.merge!(sequencenumber: sequence_number)
  )
end

#find_bestmatch_patients(practice_id:, date_of_birth:, first_name:, last_name:, params: {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/athena_health/endpoints/patients.rb', line 24

def find_bestmatch_patients(practice_id:, date_of_birth:, first_name:, last_name:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients/enhancedbestmatch",
    method: :get,
    params: params.merge!(firstname: first_name, lastname: last_name, dob: date_of_birth)
  )

  response.map{ |patient| Patient.new(patient) }
end

#find_patient(practice_id:, patient_id:, params: {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/athena_health/endpoints/patients.rb', line 14

def find_patient(practice_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}",
    method: :get,
    params: params
  )

  Patient.new(response.first)
end

#find_patient_problems(practice_id:, department_id:, patient_id:) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/athena_health/endpoints/patients.rb', line 66

def find_patient_problems(practice_id:, department_id:, patient_id:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/problems",
    method: :get,
    params: { departmentid: department_id }
  )

  PatientProblemCollection.new(response)
end

#patient_allergies(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



289
290
291
292
293
294
295
296
297
# File 'lib/athena_health/endpoints/patients.rb', line 289

def patient_allergies(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/allergies",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  UserAllergyCollection.new(response)
end

#patient_analytes(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



133
134
135
136
137
138
139
140
141
# File 'lib/athena_health/endpoints/patients.rb', line 133

def patient_analytes(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/analytes",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  AnalyteCollection.new(response)
end

#patient_appointments(practice_id:, patient_id:, params: {}) ⇒ Object



143
144
145
146
147
148
149
150
151
# File 'lib/athena_health/endpoints/patients.rb', line 143

def patient_appointments(practice_id:, patient_id:, params: {})
    response = @api.call(
      endpoint: "#{practice_id}/patients/#{patient_id}/appointments",
      method: :get,
      params: params
    )

    AppointmentCollection.new(response)
end

#patient_default_laboratory(practice_id:, department_id:, patient_id:) ⇒ Object



207
208
209
210
211
212
213
214
215
# File 'lib/athena_health/endpoints/patients.rb', line 207

def patient_default_laboratory(practice_id:, department_id:, patient_id:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/labs/default",
    method: :get,
    params: { departmentid: department_id }
  )

  Laboratory.new(response)
end

#patient_default_pharmacy(practice_id:, department_id:, patient_id:) ⇒ Object



171
172
173
174
175
176
177
178
179
# File 'lib/athena_health/endpoints/patients.rb', line 171

def patient_default_pharmacy(practice_id:, department_id:, patient_id:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/pharmacies/default",
    method: :get,
    params: { departmentid: department_id }
  )

  Pharmacy.new(response)
end

#patient_documents(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



153
154
155
156
157
158
159
160
161
# File 'lib/athena_health/endpoints/patients.rb', line 153

def patient_documents(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/documents",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  DocumentCollection.new(response)
end

#patient_encounters(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/athena_health/endpoints/patients.rb', line 76

def patient_encounters(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/encounters",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  EncounterCollection.new(response)
end

#patient_insurances(practice_id:, patient_id:, params: {}) ⇒ Object



360
361
362
363
364
365
366
367
368
# File 'lib/athena_health/endpoints/patients.rb', line 360

def patient_insurances(practice_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/insurances",
    method: :get,
    params: params
  )

  InsuranceCollection.new(response)
end

#patient_lab_result_document(practice_id:, patient_id:, lab_result_id:) ⇒ Object



96
97
98
99
100
101
102
103
# File 'lib/athena_health/endpoints/patients.rb', line 96

def patient_lab_result_document(practice_id:, patient_id:, lab_result_id:)
  response = @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/documents/labresult/#{lab_result_id}",
    method: :get
  ).first

  Document.new(response)
end

#patient_lab_results(practice_id:, department_id:, patient_id:) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/athena_health/endpoints/patients.rb', line 86

def patient_lab_results(practice_id:, department_id:, patient_id:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/labresults",
    method: :get,
    params: { departmentid: department_id }
  )

  LabResultCollection.new(response)
end

#patient_medical_history(practice_id:, department_id:, patient_id:) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/athena_health/endpoints/patients.rb', line 105

def patient_medical_history(practice_id:, department_id:, patient_id:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/medicalhistory",
    method: :get,
    params: { departmentid: department_id }
  )

  QuestionCollection.new(response)
end

#patient_medications(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
# File 'lib/athena_health/endpoints/patients.rb', line 261

def patient_medications(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/medications",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  response['medications'] = response['medications'].flatten

  UserMedicationCollection.new(response)
end

#patient_preferred_pharmacies(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



189
190
191
192
193
194
195
196
197
# File 'lib/athena_health/endpoints/patients.rb', line 189

def patient_preferred_pharmacies(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/pharmacies/preferred",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  PharmacyCollection.new(response)
end

#patient_prescriptions(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



123
124
125
126
127
128
129
130
131
# File 'lib/athena_health/endpoints/patients.rb', line 123

def patient_prescriptions(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/documents/prescription",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  PrescriptionCollection.new(response)
end

#patient_social_history(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



251
252
253
254
255
256
257
258
259
# File 'lib/athena_health/endpoints/patients.rb', line 251

def patient_social_history(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/socialhistory",
    method: :get,
    params: params.merge!(departmentid: department_id)
  )

  SocialHistory.new(response)
end

#patient_social_history_templates(practice_id:, department_id:, patient_id:) ⇒ Object



225
226
227
228
229
230
231
232
233
# File 'lib/athena_health/endpoints/patients.rb', line 225

def patient_social_history_templates(practice_id:, department_id:, patient_id:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/socialhistory/templates",
    method: :get,
    params: { departmentid: department_id }
  )

  response.map {|template| AthenaHealth::Template.new(template) }
end

#record_payment(practice_id:, department_id:, patient_id:, payment_method:, amount:, params: {}) ⇒ Object



348
349
350
351
352
353
354
355
356
357
358
# File 'lib/athena_health/endpoints/patients.rb', line 348

def record_payment(practice_id:, department_id:, patient_id:, payment_method:, amount:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/recordpayment",
    method: :post,
    body: params.merge!(
      departmentid: department_id.to_s,
      paymentmethod: payment_method,
      copayamount: amount
    )
  )
end

#set_patient_default_laboratory(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



217
218
219
220
221
222
223
# File 'lib/athena_health/endpoints/patients.rb', line 217

def set_patient_default_laboratory(practice_id:, department_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/labs/default",
    method: :put,
    params: params.merge!(departmentid: department_id)
  )
end

#set_patient_default_pharmacy(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



181
182
183
184
185
186
187
# File 'lib/athena_health/endpoints/patients.rb', line 181

def set_patient_default_pharmacy(practice_id:, department_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/pharmacies/default",
    method: :put,
    params: params.merge!(departmentid: department_id)
  )
end

#set_patient_social_history_templates(practice_id:, department_id:, patient_id:, template_ids: []) ⇒ Object



235
236
237
238
239
240
241
# File 'lib/athena_health/endpoints/patients.rb', line 235

def set_patient_social_history_templates(practice_id:, department_id:, patient_id:, template_ids: [])
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/socialhistory/templates",
    method: :put,
    params: { departmentid: department_id, templateids: template_ids.join(', ') }
  )
end

#update_patient(practice_id:, patient_id:, params: {}) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/athena_health/endpoints/patients.rb', line 42

def update_patient(practice_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}",
    method: :put,
    params: params
  )
end

#update_patient_allergies(practice_id:, department_id:, patient_id:, allergies:, params: {}) ⇒ Object



299
300
301
302
303
304
305
# File 'lib/athena_health/endpoints/patients.rb', line 299

def update_patient_allergies(practice_id:, department_id:, patient_id:, allergies:, params: {})
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/allergies",
    method: :put,
    params: params.merge!(departmentid: department_id, allergies: allergies.to_json)
  )
end

#update_patient_insurance(practice_id:, patient_id:, sequence_number:, params: {}) ⇒ Object



324
325
326
327
328
329
330
# File 'lib/athena_health/endpoints/patients.rb', line 324

def update_patient_insurance(practice_id:, patient_id:, sequence_number:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/insurances",
    method: :put,
    params: params.merge!(sequencenumber: sequence_number)
  )
end

#update_patient_insurance_card_image(practice_id:, patient_id:, insurance_id:, image:, params: {}) ⇒ Object



340
341
342
343
344
345
346
# File 'lib/athena_health/endpoints/patients.rb', line 340

def update_patient_insurance_card_image(practice_id:, patient_id:, insurance_id:, image:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/insurances/#{insurance_id}/image", 
    method: :put,
    body: {image: image}
  )
end

#update_patient_medical_history(practice_id:, department_id:, patient_id:, questions:) ⇒ Object



115
116
117
118
119
120
121
# File 'lib/athena_health/endpoints/patients.rb', line 115

def update_patient_medical_history(practice_id:, department_id:, patient_id:, questions:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/medicalhistory",
    method: :put,
    params: { departmentid: department_id, questions: questions.to_json }
  )
end

#update_patient_medications(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



281
282
283
284
285
286
287
# File 'lib/athena_health/endpoints/patients.rb', line 281

def update_patient_medications(practice_id:, department_id:, patient_id:, params: {})
  response = @api.call(
      endpoint: "#{practice_id}/chart/#{patient_id}/medications",
      method: :put,
      body: params.merge!(departmentid: department_id)
  )
end

#update_patient_photo(practice_id:, patient_id:, image:, params: {}) ⇒ Object



370
371
372
373
374
375
376
# File 'lib/athena_health/endpoints/patients.rb', line 370

def update_patient_photo(practice_id:, patient_id:, image:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/photo",
    method: :post,
    body: params.merge!(image: image)
  )
end

#update_patient_social_history(practice_id:, department_id:, patient_id:, questions:) ⇒ Object



243
244
245
246
247
248
249
# File 'lib/athena_health/endpoints/patients.rb', line 243

def update_patient_social_history(practice_id:, department_id:, patient_id:, questions:)
  response = @api.call(
    endpoint: "#{practice_id}/chart/#{patient_id}/socialhistory",
    method: :put,
    params: { departmentid: department_id, questions: questions.to_json }
  )
end

#verify_patient_privacy_information(practice_id:, department_id:, patient_id:, params: {}) ⇒ Object



307
308
309
310
311
312
313
# File 'lib/athena_health/endpoints/patients.rb', line 307

def verify_patient_privacy_information(practice_id:, department_id:, patient_id:, params: {})
  @api.call(
    endpoint: "#{practice_id}/patients/#{patient_id}/privacyinformationverified",
    method: :post,
    body: params.merge!(departmentid: department_id.to_s)
  )
end