open_fda_api 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78be5ea8edd340db43aa24fd7d5901db436b0704e9717f8468f48d6a33dea58e
4
- data.tar.gz: 83d48159b751f9629b6aa4f6aed50da430ba620c995529552d5fc69d8d05b4f2
3
+ metadata.gz: 10a12a605aa07fbd3dfa75f7fdb9e909fc9eaa7b18f2add3449db666110c7d3f
4
+ data.tar.gz: 79207bf839e4a82f2a6a1f374645cc4e2a25cfa2923d4726aaf856d779b667dd
5
5
  SHA512:
6
- metadata.gz: f5ec2d359100d3680297789a28f450eb0515f0e845b2fabbc9bd60075bf4d572e5754e5fb8e980eb4a02e432858fbf8f6ecb3aba6cdc8c57b2c4a83c7021e088
7
- data.tar.gz: 506f6f0708ef3a0c179ac1a0d8c1de10e397d4c83ba8196488ca625a2e263722333a9f2dac5e9bbc1c5090a8d6af35aadfb45b2e0d9027b28c85aa014467462c
6
+ metadata.gz: 1a172a5bd14024af9dff624f3bf0c5cd22d09cb43cd7b5901b43d7b328e88d6cfbbabc8097be14ec456fe64b4e6ff661334687c24cb7141f217be52b4808ccfd
7
+ data.tar.gz: 375be0de9fbf21279fd5b0d00ebd16375455d99a3d1e672bfc6cdf3373aa04c3cc2c824b7deddb6104c8b39856365b2a54c8ef5ae04243682d830a72782f04f3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.2] - 2022-01-19
4
+ - Update version again because CHANGELOG wasn't updated along with the 0.0.2 release.
5
+
6
+ ## [0.0.2] - 2022-01-19
7
+
8
+ - Add `OpenFdaApi::Client#drugs` to interact with the FDA Drug endpoints.
9
+ - The `adverse_events` endpoint has been implemented in a very limited capacity.
10
+
3
11
  ## [0.0.1] - 2022-01-17
4
12
 
5
- - Add OpenFdaApi::Client.new(api_key:) to create a client which does nothing right now
13
+ - Add `OpenFdaApi::Client.new(api_key:)` to create a client which does nothing right now.
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # OpenFdaApi
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/open_fda_api`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A simple Ruby wrapper for the [openFDA API](https://open.fda.gov/apis/).
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
@@ -13,26 +12,53 @@ gem 'open_fda_api'
13
12
  ```
14
13
 
15
14
  And then execute:
15
+ ```shell
16
+ bundle install
17
+ ```
18
+
19
+ ## Documentation
20
+
21
+ There are 5 main category of endpoints that openFDA API provides: Drug, Device, Food, Other, and Tobacco.
22
+
23
+ Each category has further subcategories. Everything is accessible from the `OpenFdaApi.client`.
24
+
25
+
26
+ ### Drug
16
27
 
17
- $ bundle install
28
+ The Drug API has the following endpoints: Adverse Events, Product Labeling, NDC Directory, Recall Enforcement Reports, and Drugs@FDA.
18
29
 
19
- Or install it yourself as:
30
+ Here's how you interact with each:
31
+
32
+ #### Adverse Events
33
+ ```ruby
34
+ require 'open_fda_api'
35
+
36
+ client = OpenFdaApi.client
37
+ drugs_api = client.drugs
38
+
39
+ arguments = [{"patient.reaction.reactionmeddrapt"=>"fatigue"}, {"occurcountry"=>"ca"}]
40
+ drugs_api.adverse_events(search_arguments: arguments) # => {"meta" => {...}, "results" => [...]}
41
+ ```
20
42
 
21
- $ gem install open_fda_api
43
+ ### Device (Not Implemented Yet)
44
+ ### Food (Not Implemented Yet)
45
+ ### Other (Not Implemented Yet)
46
+ ### Tobacco (Not Implemented Yet)
22
47
 
23
- ## Usage
24
48
 
25
- TODO: Write usage instructions here
26
49
 
27
50
  ## Development
28
51
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+ After checking out the repo, run `bin/setup` to install dependencies.
53
+ Then, run `rake spec` to run the tests.
54
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
55
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
57
 
33
58
  ## Contributing
34
59
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/open_fda_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/open_fda_api/blob/master/CODE_OF_CONDUCT.md).
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hebron-george/open_fda_api .
61
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/open_fda_api/blob/master/CODE_OF_CONDUCT.md).
36
62
 
37
63
  ## License
38
64
 
@@ -0,0 +1,893 @@
1
+ type: object
2
+ properties:
3
+ authoritynumb:
4
+ format:
5
+ is_exact: true
6
+ type: string
7
+ pattern:
8
+ description: "Populated with the Regulatory Authority’s case report number, when available."
9
+ possible_values:
10
+ companynumb:
11
+ format:
12
+ is_exact: true
13
+ type: string
14
+ pattern:
15
+ description: "Identifier for the company providing the report. This is self-assigned."
16
+ possible_values:
17
+ duplicate:
18
+ format:
19
+ is_exact: false
20
+ type: string
21
+ pattern:
22
+ description: "This value is `1` if earlier versions of this report were submitted to FDA. openFDA only shows the most recent version."
23
+ possible_values:
24
+ fulfillexpeditecriteria:
25
+ format: int32
26
+ is_exact: false
27
+ type: string
28
+ pattern:
29
+ description: "Identifies expedited reports (those that were processed within 15 days)."
30
+ possible_values:
31
+ type: one_of
32
+ value:
33
+ '1': Yes
34
+ '2': No
35
+ occurcountry:
36
+ format:
37
+ is_exact: true
38
+ type: string
39
+ pattern: ^[A-Z]{2}$
40
+ description: "The name of the country where the event occurred."
41
+ possible_values:
42
+ type: reference
43
+ value:
44
+ name: "Country codes"
45
+ link: "http://data.okfn.org/data/core/country-list"
46
+ patient:
47
+ type: object
48
+ properties:
49
+ drug:
50
+ type: array
51
+ items:
52
+ properties:
53
+ actiondrug:
54
+ format: int64
55
+ is_exact: false
56
+ type: string
57
+ pattern:
58
+ description: "Actions taken with the drug."
59
+ possible_values:
60
+ type: one_of
61
+ value:
62
+ '1': "Drug withdrawn"
63
+ '2': "Dose reduced"
64
+ '3': "Dose increased"
65
+ '4': "Dose not changed"
66
+ '5': "Unknown"
67
+ '6': "Not applicable"
68
+ activesubstance:
69
+ type: object
70
+ properties:
71
+ activesubstancename:
72
+ format:
73
+ is_exact: true
74
+ type: string
75
+ pattern:
76
+ description: "Product active ingredient, which may be different than other drug identifiers (when provided)."
77
+ possible_values:
78
+ drugadditional:
79
+ format: int64
80
+ is_exact: false
81
+ type: string
82
+ pattern:
83
+ description: "Dechallenge outcome information—whether the event abated after product use stopped or the dose was reduced. Only present when this was attempted and the data was provided."
84
+ possible_values:
85
+ type: one_of
86
+ value:
87
+ '1': 'Yes'
88
+ '2': 'No'
89
+ '3': 'Does not apply'
90
+ drugadministrationroute:
91
+ format:
92
+ is_exact: true
93
+ type: string
94
+ pattern:
95
+ description: "The drug’s route of administration."
96
+ possible_values:
97
+ type: one_of
98
+ value:
99
+ '001': "Auricular (otic)"
100
+ '002': "Buccal"
101
+ '003': "Cutaneous"
102
+ '004': "Dental"
103
+ '005': "Endocervical"
104
+ '006': "Endosinusial"
105
+ '007': "Endotracheal"
106
+ '008': "Epidural"
107
+ '009': "Extra-amniotic"
108
+ '010': "Hemodialysis"
109
+ '011': "Intra corpus cavernosum"
110
+ '012': "Intra-amniotic"
111
+ '013': "Intra-arterial"
112
+ '014': "Intra-articular"
113
+ '015': "Intra-uterine"
114
+ '016': "Intracardiac"
115
+ '017': "Intracavernous"
116
+ '018': "Intracerebral"
117
+ '019': "Intracervical"
118
+ '020': "Intracisternal"
119
+ '021': "Intracorneal"
120
+ '022': "Intracoronary"
121
+ '023': "Intradermal"
122
+ '024': "Intradiscal (intraspinal)"
123
+ '025': "Intrahepatic"
124
+ '026': "Intralesional"
125
+ '027': "Intralymphatic"
126
+ '028': "Intramedullar (bone marrow)"
127
+ '029': "Intrameningeal"
128
+ '030': "Intramuscular"
129
+ '031': "Intraocular"
130
+ '032': "Intrapericardial"
131
+ '033': "Intraperitoneal"
132
+ '034': "Intrapleural"
133
+ '035': "Intrasynovial"
134
+ '036': "Intratumor"
135
+ '037': "Intrathecal"
136
+ '038': "Intrathoracic"
137
+ '039': "Intratracheal"
138
+ '040': "Intravenous bolus"
139
+ '041': "Intravenous drip"
140
+ '042': "Intravenous (not otherwise specified)"
141
+ '043': "Intravesical"
142
+ '044': "Iontophoresis"
143
+ '045': "Nasal"
144
+ '046': "Occlusive dressing technique"
145
+ '047': "Ophthalmic"
146
+ '048': "Oral"
147
+ '049': "Oropharingeal"
148
+ '050': "Other"
149
+ '051': "Parenteral"
150
+ '052': "Periarticular"
151
+ '053': "Perineural"
152
+ '054': "Rectal"
153
+ '055': "Respiratory (inhalation)"
154
+ '056': "Retrobulbar"
155
+ '057': "Sunconjunctival"
156
+ '058': "Subcutaneous"
157
+ '059': "Subdermal"
158
+ '060': "Sublingual"
159
+ '061': "Topical"
160
+ '062': "Transdermal"
161
+ '063': "Transmammary"
162
+ '064': "Transplacental"
163
+ '065': "Unknown"
164
+ '066': "Urethral"
165
+ '067': "Vaginal"
166
+ drugauthorizationnumb:
167
+ format:
168
+ is_exact: true
169
+ type: string
170
+ pattern: ^[0-9]{6}$
171
+ description: "Drug authorization or application number (NDA or ANDA), if provided."
172
+ possible_values:
173
+ drugbatchnumb:
174
+ format:
175
+ is_exact: true
176
+ type: string
177
+ pattern:
178
+ description: "Drug product lot number, if provided."
179
+ possible_values:
180
+ drugcharacterization:
181
+ format: int32
182
+ is_exact: false
183
+ type: string
184
+ pattern:
185
+ description: "Reported role of the drug in the adverse event report. These values are not validated by FDA."
186
+ possible_values:
187
+ type: one_of
188
+ value:
189
+ '1': "Suspect (the drug was considered by the reporter to be the cause)"
190
+ '2': "Concomitant (the drug was reported as being taken along with the suspect drug)"
191
+ '3': "Interacting (the drug was considered by the reporter to have interacted with the suspect drug)"
192
+ drugcumulativedosagenumb:
193
+ format: float
194
+ is_exact: false
195
+ type: string
196
+ pattern:
197
+ description: "The cumulative dose taken until the first reaction was experienced, if provided."
198
+ possible_values:
199
+ drugcumulativedosageunit:
200
+ format:
201
+ is_exact: false
202
+ type: string
203
+ pattern:
204
+ description: "The unit for `drugcumulativedosagenumb`."
205
+ possible_values:
206
+ type: one_of
207
+ value:
208
+ "001": "kg (kilograms)"
209
+ "002": "g (grams)"
210
+ "003": "mg (milligrams)"
211
+ "004": "µg (micrograms)"
212
+ drugdosageform:
213
+ format:
214
+ is_exact: true
215
+ type: string
216
+ pattern:
217
+ description: "The drug’s dosage form. There is no standard, but values may include terms like `tablet` or `solution for injection`."
218
+ possible_values:
219
+ drugdosagetext:
220
+ format:
221
+ is_exact: true
222
+ type: string
223
+ pattern:
224
+ description: "Additional detail about the dosage taken. Frequently unknown, but occasionally including information like a brief textual description of the schedule of administration."
225
+ possible_values:
226
+ drugenddate:
227
+ format: date
228
+ is_exact: false
229
+ type: string
230
+ pattern:
231
+ description: "Date the patient stopped taking the drug."
232
+ possible_values:
233
+ drugenddateformat:
234
+ format:
235
+ is_exact: false
236
+ type: string
237
+ pattern:
238
+ description: "Encoding format of the field `drugenddateformat`. Always set to `102` (YYYYMMDD)."
239
+ possible_values:
240
+ drugindication:
241
+ format:
242
+ is_exact: true
243
+ type: string
244
+ pattern:
245
+ description: "Indication for the drug’s use."
246
+ possible_values:
247
+ drugintervaldosagedefinition:
248
+ format: int32
249
+ is_exact: false
250
+ type: string
251
+ pattern:
252
+ description: "The unit for the interval in the field `drugintervaldosageunitnumb.`"
253
+ possible_values:
254
+ type: one_of
255
+ value:
256
+ '801': "Year"
257
+ '802': "Month"
258
+ '803': "Week"
259
+ '804': "Day"
260
+ '805': "Hour"
261
+ '806': "Minute"
262
+ '807': "Trimester"
263
+ '810': "Cyclical"
264
+ '811': "Trimester"
265
+ '812': "As necessary"
266
+ '813': "Total"
267
+ drugintervaldosageunitnumb:
268
+ format: int32
269
+ is_exact: false
270
+ type: string
271
+ pattern:
272
+ description: "Number of units in the field `drugintervaldosagedefinition`."
273
+ possible_values:
274
+ drugrecurreadministration:
275
+ format: int32
276
+ is_exact: false
277
+ type: string
278
+ pattern:
279
+ description: "Whether the reaction occured after readministration of the drug."
280
+ possible_values:
281
+ type: one_of
282
+ value:
283
+ '1': "Yes"
284
+ '2': "No"
285
+ '3': "Unknown"
286
+ drugrecurrence:
287
+ properties:
288
+ drugrecuraction:
289
+ format:
290
+ is_exact: true
291
+ type: string
292
+ pattern:
293
+ description: "Populated with the Reaction/Event information if/when `drugrecurreadministration` equals `1`."
294
+ possible_values:
295
+ drugseparatedosagenumb:
296
+ format: int32
297
+ is_exact: false
298
+ type: string
299
+ pattern:
300
+ description: "The number of separate doses that were administered."
301
+ possible_values:
302
+ drugstartdate:
303
+ format: date
304
+ is_exact: false
305
+ type: string
306
+ pattern:
307
+ description: "Date the patient began taking the drug."
308
+ possible_values:
309
+ drugstartdateformat:
310
+ format:
311
+ is_exact: false
312
+ type: string
313
+ pattern:
314
+ description: "Encoding format of the field `drugstartdate`. Always set to `102` (YYYYMMDD)."
315
+ possible_values:
316
+ drugstructuredosagenumb:
317
+ format:
318
+ is_exact: true
319
+ type: string
320
+ pattern:
321
+ description: "The number portion of a dosage; when combined with `drugstructuredosageunit` the complete dosage information is represented. For example, *300* in `300 mg`."
322
+ possible_values:
323
+ drugstructuredosageunit:
324
+ format:
325
+ is_exact: false
326
+ type: string
327
+ pattern:
328
+ description: "The unit for the field `drugstructuredosagenumb`. For example, *mg* in `300 mg`."
329
+ possible_values:
330
+ type: one_of
331
+ value:
332
+ '001': "kg (kilograms)"
333
+ '002': "g (grams)"
334
+ '003': "mg (milligrams)"
335
+ '004': "µg (micrograms)"
336
+ drugtreatmentduration:
337
+ format:
338
+ is_exact: true
339
+ type: string
340
+ pattern:
341
+ description: "The interval of the field `drugtreatmentdurationunit` for which the patient was taking the drug."
342
+ possible_values:
343
+ drugtreatmentdurationunit:
344
+ format:
345
+ is_exact: false
346
+ type: string
347
+ pattern:
348
+ description:
349
+ possible_values:
350
+ type: one_of
351
+ value:
352
+ '801': "Year"
353
+ '802': "Month"
354
+ '803': "Week"
355
+ '804': "Day"
356
+ '805': "Hour"
357
+ '806': "Minute"
358
+ medicinalproduct:
359
+ format:
360
+ type: string
361
+ pattern:
362
+ is_exact: true
363
+ description: "Drug name. This may be the valid trade name of the product (such as `ADVIL` or `ALEVE`) or the generic name (such as `IBUPROFEN`). This field is not systematically normalized. It may contain misspellings or idiosyncratic descriptions of drugs, such as combination products such as those used for birth control."
364
+ possible_values:
365
+ openfda:
366
+ type: object
367
+ properties:
368
+ application_number:
369
+ type: array
370
+ items:
371
+ format:
372
+ is_exact: true
373
+ type: string
374
+ pattern: ^[BLA|ANDA|NDA]{3,4}[0-9]{6}$
375
+ description: "This corresponds to the NDA, ANDA, or BLA number reported by the labeler for products which have the corresponding Marketing Category designated. If the designated Marketing Category is OTC Monograph Final or OTC Monograph Not Final, then the application number will be the CFR citation corresponding to the appropriate Monograph (e.g. “part 341”). For unapproved drugs, this field will be null."
376
+ possible_values:
377
+ brand_name:
378
+ type: array
379
+ items:
380
+ format:
381
+ is_exact: true
382
+ type: string
383
+ pattern:
384
+ description: "Brand or trade name of the drug product."
385
+ possible_values:
386
+ generic_name:
387
+ type: array
388
+ items:
389
+ format:
390
+ is_exact: true
391
+ type: string
392
+ pattern:
393
+ description: "Generic name(s) of the drug product."
394
+ possible_values:
395
+ manufacturer_name:
396
+ type: array
397
+ items:
398
+ format:
399
+ is_exact: true
400
+ type: string
401
+ pattern:
402
+ description: "Name of manufacturer or company that makes this drug product, corresponding to the labeler code segment of the NDC."
403
+ possible_values:
404
+ nui:
405
+ type: array
406
+ items:
407
+ format:
408
+ is_exact: true
409
+ type: string
410
+ pattern: ^[N][0-9]{10}$
411
+ description: "Unique identifier applied to a drug concept within the National Drug File Reference Terminology (NDF-RT)."
412
+ possible_values:
413
+ type: reference
414
+ value:
415
+ name: "NDF-RT"
416
+ link: "https://www.nlm.nih.gov/research/umls/sourcereleasedocs/current/NDFRT/"
417
+ package_ndc:
418
+ type: array
419
+ items:
420
+ format:
421
+ is_exact: true
422
+ type: string
423
+ pattern: ^[0-9]{5,4}-[0-9]{4,3}-[0-9]{1,2}$
424
+ description: "This number, known as the NDC, identifies the labeler, product, and trade package size. The first segment, the labeler code, is assigned by the FDA. A labeler is any firm that manufactures (including repackers or relabelers), or distributes (under its own name) the drug."
425
+ possible_values:
426
+ pharm_class_cs:
427
+ type: array
428
+ items:
429
+ format:
430
+ is_exact: true
431
+ type: string
432
+ pattern:
433
+ description: "Chemical structure classification of the drug product’s pharmacologic class. Takes the form of the classification, followed by `[Chemical/Ingredient]` (such as `Thiazides [Chemical/Ingredient]` or `Antibodies, Monoclonal [Chemical/Ingredient]."
434
+ possible_values:
435
+ pharm_class_epc:
436
+ type: array
437
+ items:
438
+ format:
439
+ is_exact: true
440
+ type: string
441
+ pattern:
442
+ description: "Established pharmacologic class associated with an approved indication of an active moiety (generic drug) that the FDA has determined to be scientifically valid and clinically meaningful. Takes the form of the pharmacologic class, followed by `[EPC]` (such as `Thiazide Diuretic [EPC]` or `Tumor Necrosis Factor Blocker [EPC]`."
443
+ possible_values:
444
+ pharm_class_pe:
445
+ type: array
446
+ items:
447
+ format:
448
+ is_exact: true
449
+ type: string
450
+ pattern:
451
+ description: "Physiologic effect or pharmacodynamic effect—tissue, organ, or organ system level functional activity—of the drug’s established pharmacologic class. Takes the form of the effect, followed by `[PE]` (such as `Increased Diuresis [PE]` or `Decreased Cytokine Activity [PE]`."
452
+ possible_values:
453
+ pharm_class_moa:
454
+ type: array
455
+ items:
456
+ format:
457
+ is_exact: true
458
+ type: string
459
+ pattern:
460
+ description: "Mechanism of action of the drug—molecular, subcellular, or cellular functional activity—of the drug’s established pharmacologic class. Takes the form of the mechanism of action, followed by `[MoA]` (such as `Calcium Channel Antagonists [MoA]` or `Tumor Necrosis Factor Receptor Blocking Activity [MoA]`."
461
+ possible_values:
462
+ product_ndc:
463
+ type: array
464
+ items:
465
+ format:
466
+ is_exact: true
467
+ type: string
468
+ pattern: ^[0-9]{5,4}-[0-9]{4,3}$
469
+ description: "The labeler manufacturer code and product code segments of the NDC number, separated by a hyphen."
470
+ possible_values:
471
+ product_type:
472
+ type: array
473
+ items:
474
+ format:
475
+ is_exact: true
476
+ type: string
477
+ pattern:
478
+ description:
479
+ possible_values:
480
+ type: reference
481
+ value:
482
+ name: "Type of drug product"
483
+ link: http://www.fda.gov/ForIndustry/DataStandards/StructuredProductLabeling/ucm162063.htm
484
+ route:
485
+ type: array
486
+ items:
487
+ format:
488
+ is_exact: true
489
+ type: string
490
+ pattern:
491
+ description: "The route of administation of the drug product."
492
+ possible_values:
493
+ type: reference
494
+ value:
495
+ name: "Route of administration"
496
+ link: http://www.fda.gov/ForIndustry/DataStandards/StructuredProductLabeling/ucm162034.htm
497
+ rxcui:
498
+ type: array
499
+ items:
500
+ format:
501
+ is_exact: true
502
+ type: string
503
+ pattern: ^[0-9]{6}$
504
+ description: "The RxNorm Concept Unique Identifier. RxCUI is a unique number that describes a semantic concept about the drug product, including its ingredients, strength, and dose forms."
505
+ possible_values:
506
+ type: reference
507
+ value:
508
+ name: "RxNorm and RxCUI documentation"
509
+ link: "https://www.nlm.nih.gov/research/umls/rxnorm/docs/2012/rxnorm_doco_full_2012-3.html"
510
+ spl_id:
511
+ type: array
512
+ items:
513
+ format:
514
+ is_exact: true
515
+ type: string
516
+ pattern: ^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$
517
+ description: "Unique identifier for a particular version of a Structured Product Label for a product. Also referred to as the document ID."
518
+ possible_values:
519
+ spl_set_id:
520
+ type: array
521
+ items:
522
+ format:
523
+ is_exact: true
524
+ type: string
525
+ pattern: ^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$
526
+ description: "Unique identifier for the Structured Product Label for a product, which is stable across versions of the label. Also referred to as the set ID."
527
+ possible_values:
528
+ substance_name:
529
+ type: array
530
+ items:
531
+ format:
532
+ is_exact: true
533
+ type: string
534
+ pattern:
535
+ description: "The list of active ingredients of a drug product."
536
+ possible_values:
537
+ unii:
538
+ type: array
539
+ items:
540
+ format:
541
+ is_exact: true
542
+ type: string
543
+ pattern: ^[A-Z0-9]{10}$
544
+ description: "Unique Ingredient Identifier, which is a non-proprietary, free, unique, unambiguous, non-semantic, alphanumeric identifier based on a substance’s molecular structure and/or descriptive information."
545
+ possible_values:
546
+ type: reference
547
+ value:
548
+ name: "Unique Ingredient Identifiers"
549
+ link: "http://fdasis.nlm.nih.gov/srs/srs.jsp"
550
+ patientagegroup:
551
+ format: int32
552
+ is_exact: false
553
+ type: string
554
+ pattern:
555
+ description: "Populated with Patient Age Group code."
556
+ possible_values:
557
+ type: one_of
558
+ value:
559
+ '1': "Neonate"
560
+ '2': "Infant"
561
+ '3': "Child"
562
+ '4': "Adolescent"
563
+ '5': "Adult"
564
+ '6': "Elderly"
565
+ patientdeath:
566
+ type: object
567
+ properties:
568
+ patientdeathdate:
569
+ format: date
570
+ is_exact: false
571
+ type: string
572
+ pattern:
573
+ description: "If the patient died, the date that the patient died."
574
+ possible_values:
575
+ patientdeathdateformat:
576
+ format:
577
+ is_exact: false
578
+ type: string
579
+ pattern:
580
+ description: "Encoding format of the field `patientdeathdate`. Always set to `102` (YYYYMMDD)."
581
+ possible_values:
582
+ patientonsetage:
583
+ format: float
584
+ is_exact: false
585
+ type: string
586
+ pattern:
587
+ description: "Age of the patient when the event first occured."
588
+ possible_values:
589
+ patientonsetageunit:
590
+ format:
591
+ is_exact: false
592
+ type: string
593
+ pattern:
594
+ description: "The unit for the interval in the field `patientonsetage.`"
595
+ possible_values:
596
+ type: one_of
597
+ value:
598
+ '800': "Decade"
599
+ '801': "Year"
600
+ '802': "Month"
601
+ '803': "Week"
602
+ '804': "Day"
603
+ '805': "Hour"
604
+ patientsex:
605
+ format: int32
606
+ is_exact: false
607
+ type: string
608
+ pattern:
609
+ description: "The sex of the patient."
610
+ possible_values:
611
+ type: one_of
612
+ value:
613
+ '0': "Unknown"
614
+ '1': "Male"
615
+ '2': "Female"
616
+ patientweight:
617
+ format: float
618
+ is_exact: false
619
+ type: string
620
+ pattern:
621
+ description: "The patient weight, in kg (kilograms)."
622
+ possible_values:
623
+ reaction:
624
+ type: array
625
+ items:
626
+ type: object
627
+ properties:
628
+ reactionmeddrapt:
629
+ format:
630
+ is_exact: true
631
+ type: string
632
+ pattern:
633
+ description: "Patient reaction, as a MedDRA term. Note that these terms are encoded in British English. For instance, diarrhea is spelled `diarrohea`. MedDRA is a standardized medical terminology."
634
+ possible_values:
635
+ type: reference
636
+ value:
637
+ name: "MedDRA"
638
+ link: "http://www.fda.gov/ForIndustry/DataStandards/StructuredProductLabeling/ucm162038.htm"
639
+ reactionmeddraversionpt:
640
+ format:
641
+ is_exact: false
642
+ type: string
643
+ pattern:
644
+ description: "The version of MedDRA from which the term in `reactionmeddrapt` is drawn."
645
+ possible_values:
646
+ reactionoutcome:
647
+ format: int32
648
+ is_exact: false
649
+ type: string
650
+ pattern:
651
+ description: "Outcome of the reaction in `reactionmeddrapt` at the time of last observation."
652
+ possible_values:
653
+ type: one_of
654
+ value:
655
+ '1': "Recovered/resolved"
656
+ '2': "Recovering/resolving"
657
+ '3': "Not recovered/not resolved"
658
+ '4': "Recovered/resolved with sequelae (consequent health issues)"
659
+ '5': "Fatal"
660
+ '6': "Unknown"
661
+ summary:
662
+ type: object
663
+ properties:
664
+ narrativeincludeclinical:
665
+ format:
666
+ is_exact: false
667
+ type: string
668
+ pattern:
669
+ description: "Populated with Case Event Date, when available; does `NOT` include Case Narrative."
670
+ possible_values:
671
+ primarysource:
672
+ type: object
673
+ properties:
674
+ literaturereference:
675
+ format:
676
+ is_exact: false
677
+ type: string
678
+ pattern:
679
+ description: "Populated with the Literature Reference information, when available."
680
+ possible_values:
681
+ qualification:
682
+ format:
683
+ is_exact: false
684
+ type: string
685
+ pattern:
686
+ description: "Category of individual who submitted the report."
687
+ possible_values:
688
+ type: one_of
689
+ value:
690
+ '1': "Physician"
691
+ '2': "Pharmacist"
692
+ '3': "Other health professional"
693
+ '4': "Lawyer"
694
+ '5': "Consumer or non-health professional"
695
+ reportercountry:
696
+ format:
697
+ is_exact: true
698
+ type: string
699
+ pattern:
700
+ description: "Country from which the report was submitted."
701
+ possible_values:
702
+ primarysourcecountry:
703
+ format:
704
+ is_exact: true
705
+ type: string
706
+ pattern:
707
+ description: "Country of the reporter of the event."
708
+ possible_values:
709
+ type: reference
710
+ value:
711
+ name: "Country codes"
712
+ link: "http://data.okfn.org/data/core/country-list"
713
+ receiptdate:
714
+ format: date
715
+ is_exact: false
716
+ type: string
717
+ pattern:
718
+ description: "Date that the _most recent_ information in the report was received by FDA."
719
+ possible_values:
720
+ receiptdateformat:
721
+ format:
722
+ is_exact: false
723
+ type: string
724
+ pattern:
725
+ description: "Encoding format of the `transmissiondate` field. Always set to 102 (YYYYMMDD)."
726
+ possible_values:
727
+ receivedate:
728
+ format: date
729
+ is_exact: false
730
+ type: string
731
+ pattern:
732
+ description: "Date that the report was _first_ received by FDA. If this report has multiple versions, this will be the date the first version was received by FDA."
733
+ possible_values:
734
+ receivedateformat:
735
+ format:
736
+ is_exact: false
737
+ type: string
738
+ pattern:
739
+ description: "Encoding format of the `transmissiondate` field. Always set to 102 (YYYYMMDD)."
740
+ possible_values:
741
+ receiver:
742
+ type: object
743
+ description: "Information on the organization receiving the report."
744
+ properties:
745
+ receiverorganization:
746
+ format:
747
+ is_exact: true
748
+ type: string
749
+ pattern:
750
+ description: "Name of the organization receiving the report. Because FDA received the report, the value is always `FDA`."
751
+ possible_values:
752
+ receivertype:
753
+ format: int32
754
+ is_exact: false
755
+ type: string
756
+ pattern:
757
+ description: "The type of organization receiving the report. The value,`6`, is only specified if it is `other`, otherwise it is left blank."
758
+ possible_values:
759
+ type: one_of
760
+ value:
761
+ '6': "Other"
762
+ reportduplicate:
763
+ type: object
764
+ description: "If a report is a duplicate or more recent version than a previously submitted report, this field will provide additional details on source provider."
765
+ properties:
766
+ duplicatenumb:
767
+ format:
768
+ is_exact: true
769
+ type: string
770
+ pattern:
771
+ description: "The case identifier for the duplicate."
772
+ possible_values:
773
+ duplicatesource:
774
+ format:
775
+ is_exact: true
776
+ type: string
777
+ pattern:
778
+ description: "The name of the organization providing the duplicate."
779
+ possible_values:
780
+ reporttype:
781
+ format: int32
782
+ is_exact: false
783
+ type: string
784
+ pattern:
785
+ description: "Code indicating the circumstances under which the report was generated."
786
+ possible_values:
787
+ type: one_of
788
+ value:
789
+ '1': "Spontaneous"
790
+ '2': "Report from study"
791
+ '3': "Other"
792
+ '4': "Not available to sender (unknown)"
793
+ safetyreportid:
794
+ format:
795
+ is_exact: true
796
+ type: string
797
+ pattern: ^[0-9]{7}-[0-9]{1,2}$
798
+ description: "The 8-digit Safety Report ID number, also known as the case report number or case ID. The first 7 digits (before the hyphen) identify an individual report and the last digit (after the hyphen) is a checksum. This field can be used to identify or find a specific adverse event report."
799
+ possible_values:
800
+ safetyreportversion:
801
+ format: int32
802
+ is_exact: false
803
+ type: string
804
+ pattern:
805
+ description: "The version number of the `safetyreportid`. Multiple versions of the same report may exist, it is generally best to only count the latest report and disregard others. openFDA will only return the latest version of a report."
806
+ possible_values:
807
+ sender:
808
+ type: object
809
+ properties:
810
+ senderorganization:
811
+ format:
812
+ is_exact: true
813
+ type: string
814
+ pattern:
815
+ description: "Name of the organization sending the report. Because FDA is providing these reports to you, the value is always `FDA-Public Use.`"
816
+ possible_values:
817
+ sendertype:
818
+ format: int32
819
+ is_exact: false
820
+ type: string
821
+ pattern:
822
+ description: "The name of the organization sending the report. Because FDA is providing these reports to you, the value is always `2`."
823
+ possible_values:
824
+ type: one_of
825
+ value:
826
+ '2': "Regulatory authority"
827
+ serious:
828
+ format: int32
829
+ is_exact: false
830
+ type: string
831
+ pattern:
832
+ description: "Seriousness of the adverse event."
833
+ possible_values:
834
+ type: one_of
835
+ value:
836
+ '1': "The adverse event resulted in death, a life threatening condition, hospitalization, disability, congenital anomaly, or other serious condition"
837
+ '2': "The adverse event did not result in any of the above"
838
+ seriousnesscongenitalanomali:
839
+ format: int32
840
+ is_exact: false
841
+ type: string
842
+ pattern:
843
+ description: "This value is `1` if the adverse event resulted in a congenital anomaly, and absent otherwise."
844
+ possible_values:
845
+ seriousnessdeath:
846
+ format: int32
847
+ is_exact: false
848
+ type: string
849
+ pattern:
850
+ description: "This value is `1` if the adverse event resulted in death, and absent otherwise."
851
+ possible_values:
852
+ seriousnessdisabling:
853
+ format: int32
854
+ is_exact: false
855
+ type: string
856
+ pattern:
857
+ description: "This value is `1` if the adverse event resulted in disability, and absent otherwise."
858
+ possible_values:
859
+ seriousnesshospitalization:
860
+ format: int32
861
+ is_exact: false
862
+ type: string
863
+ pattern:
864
+ description: "This value is `1` if the adverse event resulted in a hospitalization, and absent otherwise."
865
+ possible_values:
866
+ seriousnesslifethreatening:
867
+ format: int32
868
+ is_exact: false
869
+ type: string
870
+ pattern:
871
+ description: "This value is `1` if the adverse event resulted in a life threatening condition, and absent otherwise."
872
+ possible_values:
873
+ seriousnessother:
874
+ format: int32
875
+ is_exact: false
876
+ type: string
877
+ pattern:
878
+ description: "This value is `1` if the adverse event resulted in some other serious condition, and absent otherwise."
879
+ possible_values:
880
+ transmissiondate:
881
+ format: date
882
+ is_exact: false
883
+ type: string
884
+ pattern:
885
+ description: "Date that the record was created. This may be earlier than the date the record was received by the FDA."
886
+ possible_values:
887
+ transmissiondateformat:
888
+ format: int32
889
+ is_exact: false
890
+ type: string
891
+ pattern:
892
+ description: "Encoding format of the `transmissiondate` field. Always set to 102 (YYYYMMDD)."
893
+ possible_values:
@@ -1,12 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "./drugs"
4
+
3
5
  module OpenFdaApi
4
6
  # Gives you access to the main nouns in the openFDA API
5
7
  class Client
6
8
  attr_reader :api_key
7
9
 
8
- def initialize(api_key:)
10
+ def initialize(api_key: nil)
9
11
  @api_key = api_key
10
12
  end
13
+
14
+ def drugs
15
+ OpenFdaApi::Drugs.new
16
+ end
11
17
  end
12
18
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "open_fda_api/query_builder"
6
+
7
+ module OpenFdaApi
8
+ # Interact with the Drugs API Endpoint:
9
+ # - Adverse Events
10
+ # - Product Labeling
11
+ # - NDC Directory
12
+ # - Recall Enforcement Reports
13
+ # - Drugs@FDA)
14
+ class Drugs
15
+ def initialize
16
+ @host = "api.fda.gov"
17
+ @path_base = "/drug"
18
+ end
19
+
20
+ # The openFDA drug adverse event API returns data that has been collected from the
21
+ # FDA Adverse Event Reporting System (FAERS), a database that contains information on
22
+ # adverse event and medication error reports submitted to FDA.
23
+ #
24
+ # @param search_arguments [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
25
+ # @return Response from the API parsed as JSON
26
+ def adverse_events(search_arguments: [])
27
+ endpoint = "/event.json"
28
+ query = build_query(search_arguments)
29
+ url = build_url(endpoint, query)
30
+ make_request(url)
31
+ end
32
+
33
+ private
34
+
35
+ def build_url(endpoint, query)
36
+ URI::HTTPS.build(host: @host, path: @path_base + endpoint, query: query)
37
+ end
38
+
39
+ def build_query(search_arguments)
40
+ QueryBuilder.new(search: search_arguments).build_query
41
+ end
42
+
43
+ def make_request(url)
44
+ JSON.parse(Net::HTTP.get(url))
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenFdaApi
4
+ # A helper to build queries against the openFDA API
5
+ #
6
+ # The API supports five query parameters. The basic building block of queries is the search parameter.
7
+ # Use it to "filter" requests to the API by looking in specific fields for matches.
8
+ # Each endpoint has its own unique fields that can be searched.
9
+ #
10
+ # search:
11
+ # What to search for, in which fields. If you don't specify a field to search, the API will search in every field.
12
+ # sort:
13
+ # Sort the results of the search by the specified field in ascending or descending order by using the
14
+ # :asc or :desc modifier.
15
+ # count:
16
+ # Count the number of unique values of a certain field, for all the records that matched the search parameter.
17
+ # By default, the API returns the 1000 most frequent values.
18
+ # limit:
19
+ # Return up to this number of records that match the search parameter. Currently, the largest allowed value for the
20
+ # limit parameter is 1000.
21
+ # skip:
22
+ # Skip this number of records that match the search parameter, then return the matching records that follow.
23
+ # Use in combination with limit to paginate results. Currently, the largest allowed value for the skip parameter
24
+ # is 25000. See Paging if you require paging through larger result sets.
25
+ class QueryBuilder
26
+ # @param [Array<Hash>] search
27
+ def initialize(search: [])
28
+ @search = build_search_string(search)
29
+ end
30
+
31
+ # @return [String] the query string portion of a request
32
+ def build_query
33
+ # TODO: We currently just build a very basic search string for simple examples like "search=a:b+AND+c:d",
34
+ # but it is possible to construct more complex queries and we will need to support that. Sorting, counting,
35
+ # setting limits, skipping records, pagination, converting spaces, phrase matching, grouping, and using dates and
36
+ # ranges are examples of more complex queries that can be built.
37
+ @search
38
+ end
39
+
40
+ private
41
+
42
+ def build_search_string(search)
43
+ return "" if search.empty?
44
+
45
+ value = if search.count == 1 # AND case
46
+ # Turns [{a: b, c: d}] into "a:b+AND+c:d"
47
+ search.first.map { |k, v| "#{k}:#{v}" }.join("+AND+")
48
+ else # OR case
49
+ # Turns [{a: b}, {c: d}] into "a:b+c:d"
50
+ search.map { |h| "#{h.keys.first}:#{h.values.first}" }.join("+")
51
+ end
52
+
53
+ "search=#{value}"
54
+ end
55
+ end
56
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenFdaApi
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_fda_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hebron George
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-01-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -31,7 +31,10 @@ files:
31
31
  - bin/console
32
32
  - bin/setup
33
33
  - lib/open_fda_api.rb
34
+ - lib/open_fda_api/adverse_events_fields.yml
34
35
  - lib/open_fda_api/client.rb
36
+ - lib/open_fda_api/drugs.rb
37
+ - lib/open_fda_api/query_builder.rb
35
38
  - lib/open_fda_api/version.rb
36
39
  - open_fda_api.gemspec
37
40
  homepage: https://github.com/hebron-george/open_fda_api