Sha256: 2b45aab2b1500ffeca79383ba3eead5f034d908480d9de14b833298bce0ead0d
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require_relative 'lab_resource' module Medivo class Lab < LabResource unless defined? LAB_CORP_ID 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'} end def self.findLabs(zip_code, radius = 15) find(:all, from: "/find_psc/#{zip_code}", params: { radius: radius}).sort_by(&:distance) end 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 def lab_name LAB_ID_TO_PRETTY_NAME[lab_id] end def as_json(options={}) attributes.merge(:lab_name => self.lab_name) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
medivo-0.2.24 | app/models/medivo/lab.rb |