Class: OpenFdaApi::Drugs

Inherits:
Endpoint show all
Defined in:
lib/open_fda_api/drugs.rb

Overview

Interact with the Drugs API Endpoint:

- Adverse Events
- Product Labeling
- NDC Directory
- Recall Enforcement Reports
- Drugs@FDA)

Instance Attribute Summary

Attributes inherited from Endpoint

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#build_inputs, #build_query, #initialize, #make_request

Constructor Details

This class inherits a constructor from OpenFdaApi::Endpoint

Class Method Details

.valid_adverse_events_fieldsObject



78
79
80
# File 'lib/open_fda_api/drugs.rb', line 78

def self.valid_adverse_events_fields
  @valid_adverse_events_fields ||= ::YAML.load_file("#{__dir__}/adverse_events_fields.yml")
end

Instance Method Details

#adverse_events(search: [], sort: [], count: [], skip: 0, limit: 1) ⇒ Object

Returns Response from the API parsed as JSON.

Parameters:

Returns:

  • Response from the API parsed as JSON



19
20
21
22
23
24
# File 'lib/open_fda_api/drugs.rb', line 19

def adverse_events(search: [], sort: [], count: [], skip: 0, limit: 1)
  endpoint = "event.json"
  inputs   = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
  query    = build_query(inputs, self.class.valid_adverse_events_fields)
  make_request(endpoint, query)
end

#drugs_at_fda(search: [], sort: [], count: [], skip: 0, limit: 1) ⇒ Object

Returns Response from the API parsed as JSON.

Parameters:

Returns:

  • Response from the API parsed as JSON



71
72
73
74
75
76
# File 'lib/open_fda_api/drugs.rb', line 71

def drugs_at_fda(search: [], sort: [], count: [], skip: 0, limit: 1)
  endpoint = "drugsfda.json"
  inputs   = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
  query    = build_query(inputs, {}) # TODO: Upload valid fields
  make_request(endpoint, query)
end

#ndc_directory(search: [], sort: [], count: [], skip: 0, limit: 1) ⇒ Object

Returns Response from the API parsed as JSON.

Parameters:

Returns:

  • Response from the API parsed as JSON



45
46
47
48
49
50
# File 'lib/open_fda_api/drugs.rb', line 45

def ndc_directory(search: [], sort: [], count: [], skip: 0, limit: 1)
  endpoint = "ndc.json"
  inputs   = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
  query    = build_query(inputs, {}) # TODO: Upload valid fields
  make_request(endpoint, query)
end

#product_labeling(search: [], sort: [], count: [], skip: 0, limit: 1) ⇒ Object

Returns Response from the API parsed as JSON.

Parameters:

Returns:

  • Response from the API parsed as JSON



32
33
34
35
36
37
# File 'lib/open_fda_api/drugs.rb', line 32

def product_labeling(search: [], sort: [], count: [], skip: 0, limit: 1)
  endpoint = "label.json"
  inputs   = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
  query    = build_query(inputs, {}) # TODO: Upload valid fields
  make_request(endpoint, query)
end

#recall_enforcement_reports(search: [], sort: [], count: [], skip: 0, limit: 1) ⇒ Object

Returns Response from the API parsed as JSON.

Parameters:

Returns:

  • Response from the API parsed as JSON



58
59
60
61
62
63
# File 'lib/open_fda_api/drugs.rb', line 58

def recall_enforcement_reports(search: [], sort: [], count: [], skip: 0, limit: 1)
  endpoint = "enforcement.json"
  inputs   = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
  query    = build_query(inputs, {}) # TODO: Upload valid fields
  make_request(endpoint, query)
end