Skip to content

Instantly share code, notes, and snippets.

@satyatechsavy
Created November 25, 2013 10:33

Revisions

  1. satyatechsavy created this gist Nov 25, 2013.
    29 changes: 29 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    class Api::Foobar
    include HTTParty
    base_uri 'http://demo.foobar.es/vweb/xml'

    GLOBAL_OPTIONS = {edad: 'anciano', farmacovigilancia: false, deportista: false, administrativas: false}

    def initialize(user)
    @user = user
    end

    def perform
    if @user.country=='France'
    contraindications
    else
    medications_by_name(@user.country_name)
    end
    end

    private

    def contraindications
    self.class.get("/ws_patient/alertas", query: GLOBAL_OPTIONS.merge(user_options) )
    end

    def self.medications_by_name(name)
    response = get("/ws_drug/SearchByName", query: {value: name} )
    response['object']['drug_set']['drug']
    end
    end