Class: Medivo::Lab
- Inherits:
-
LabResource
- Object
- ActiveResource::Base
- LabResource
- Medivo::Lab
- Defined in:
- app/models/medivo/lab.rb
Constant Summary collapse
- LAB_CORP_ID =
129
- QUEST_ID =
119
- LAB_CORP_NAME =
:lab_corp
- QUEST_NAME =
:quest
- LAB_ID_TO_NAME =
{LAB_CORP_ID => LAB_CORP_NAME, QUEST_ID => QUEST_NAME}
- LAB_ID_TO_SHORT_NAME =
{LAB_CORP_ID => 'LC', QUEST_ID => 'QD'}
- LAB_ID_TO_PRETTY_NAME =
{LAB_CORP_ID => 'Lab Corp', QUEST_ID => 'Quest Diagnostics'}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.data_for_zip(zip = '') ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/models/medivo/lab.rb', line 19 def self.data_for_zip(zip='') zip = zip.to_s.match(/(\d{5})/) ? $1 : nil return {} unless zip labs = findLabs(zip) zip_info = Geocoder.coordinates(zip) rescue nil zip_location = { title: zip, lat: zip_info[0], lng: zip_info[1] } if zip_info {labs: labs, zip_location: zip_location} end |
.findLabs(zip_code, radius = 15) ⇒ Object
15 16 17 |
# File 'app/models/medivo/lab.rb', line 15 def self.findLabs(zip_code, radius = 15) find(:all, from: "/find_psc/#{zip_code}", params: { radius: radius}).sort_by(&:distance) end |
Instance Method Details
#as_json(options = {}) ⇒ Object
32 33 34 |
# File 'app/models/medivo/lab.rb', line 32 def as_json(={}) attributes.merge(:lab_name => self.lab_name) end |
#lab_name ⇒ Object
28 29 30 |
# File 'app/models/medivo/lab.rb', line 28 def lab_name LAB_ID_TO_PRETTY_NAME[lab_id] end |