Guest User

Untitled

a guest
Jan 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. module V1
  2. class RedoxController < Grape::API
  3. include V1::Default
  4. include V1::RedoxHelper
  5.  
  6. before do
  7. authenticate_redox_token!
  8. authenticate_redox_source!
  9. end
  10.  
  11. desc "Verify Redox Token"
  12. get "/redox/verify" do
  13. Rails.configuration.VERIFICATION_TOKEN == params["verification-token"] ? params[:challenge] : error!({ success: false}, 400)
  14. end
  15.  
  16. desc "Get patient captured info from redox by email"
  17.  
  18. params do
  19. requires :patient_email, type: String, documentation: { param_type: 'url'}
  20. optional :info_type, type: String, documentation: { param_type: 'url'}
  21. optional :Token, type: String, documentation: { param_type: 'header'}
  22. end
  23.  
  24. get "/redox/captured_data_by_email" do
  25. patient = User.find_by(email: params[:patient_email])
  26. if patient
  27. authorize! :redox_captured_data, patient
  28. case params[:info_type]
  29. when 'appointment'
  30. { success: true, data: patient.appointment_json}
  31. when 'surgery'
  32. { success: true, data: patient.surgery_json}
  33. when 'demographic'
  34. { success: true, data: patient.update_patient_json}
  35. when 'all'
  36. { success: true, data: patient.patient_redox_json}
  37. end
  38. else
  39. error!({ success: false, data: { message: "Patient not found" }}, 404)
  40. end
  41. end
  42. end
  43. end
Add Comment
Please, Sign In to add comment