Skip to content

Instantly share code, notes, and snippets.

@barek2k2
Created March 23, 2017 18:06
Show Gist options
  • Save barek2k2/2d022406a6f28ed688c1a31f54a0c549 to your computer and use it in GitHub Desktop.
Save barek2k2/2d022406a6f28ed688c1a31f54a0c549 to your computer and use it in GitHub Desktop.
def gen_url
patient = Patient.find_by(:id => params[:patient_id])
doctor = patient.user
client = Savon.client(wsdl: 'https://test.mdtoolboxrx.net/rxws/rx.asmx?wsdl')
hash = patient.hash_for_mdtoolbox
hook_url = CGI::escape("#{ENV['BACKEND_SERVER']}api/eprescriptions/capture.json?patient_id=#{patient.id}")
r = client.call(:update_data_for_screens, hash)
r = r.body
code = r[:update_data_for_screens_response][:update_data_for_screens_result]
url = "https://test.mdtoolboxrx.net/rxtest/access1.aspx?code=#{code}&aid=5182&sid=#{doctor.practice.id}&user=#{doctor.email}&theme=blue&did=#{doctor.id}&page=rx&pid=#{patient.id}&post=#{hook_url}"
render :json => {:url => url, :r => r}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment