app/controllers/medivo/labs_controller.rb in medivo-0.1.23 vs app/controllers/medivo/labs_controller.rb in medivo-0.1.24
- old
+ new
@@ -1,18 +1,22 @@
module Medivo
class LabsController < ActionController::Base
+ layout false
+
def lab_data
lab_data = Medivo::Lab.data_for_zip(params[:zip_code])
- render :json=> lab_data, :layout => nil
+ render :json=> lab_data
end
def appointment_data
- data = Medivo::Appointment.find(params[:lab_code], params[:appointment_date])
- render :json=> data, :layout => nil
- rescue => e
- render :json=> {:status=>'Error', :message=>"Problem getting data: #{e.message}"},
- :status=> 500,
- :layout => nil
+ data = Medivo::Appointment.find(params[:lab_code], params[:appointment_date], params[:am_pm])
+ render :json=> data
+ rescue RestClient::RequestTimeout, RestClient::InternalServerError => te
+ render :status=> te.http_code, :json=> {:message=>"Could be lab_code is wrong, or labcorp server is down"}
+ rescue RestClient::Exception => br
+ render :status=> br.http_code, :json=> {:message=>br.response}
+ rescue Exception => e
+ render :status=> 500, :json=> {:message=>e.message}
end
end
end