Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module V1
- class RedoxController < Grape::API
- include V1::Default
- include V1::RedoxHelper
- before do
- authenticate_redox_token!
- authenticate_redox_source!
- end
- desc "Verify Redox Token"
- get "/redox/verify" do
- Rails.configuration.VERIFICATION_TOKEN == params["verification-token"] ? params[:challenge] : error!({ success: false}, 400)
- end
- desc "Get patient captured info from redox by email"
- params do
- requires :patient_email, type: String, documentation: { param_type: 'url'}
- optional :info_type, type: String, documentation: { param_type: 'url'}
- optional :Token, type: String, documentation: { param_type: 'header'}
- end
- get "/redox/captured_data_by_email" do
- patient = User.find_by(email: params[:patient_email])
- if patient
- authorize! :redox_captured_data, patient
- case params[:info_type]
- when 'appointment'
- { success: true, data: patient.appointment_json}
- when 'surgery'
- { success: true, data: patient.surgery_json}
- when 'demographic'
- { success: true, data: patient.update_patient_json}
- when 'all'
- { success: true, data: patient.patient_redox_json}
- end
- else
- error!({ success: false, data: { message: "Patient not found" }}, 404)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment