infermedica 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +63 -0
- data/examples/triage.rb +22 -0
- data/infermedica.gemspec +3 -2
- data/lib/infermedica.rb +6 -0
- data/lib/infermedica/diagnosis.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5edc440a2af82943c1d9ff4f3b008bac9ecff99
|
4
|
+
data.tar.gz: 588b22792865559b692ff5d3fda1de5720273bdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f25cad0a7c461ddecd943ca885b29c43dfca08746d4fe474e75a362b5c12252f0856211cc65da4b6b4af3ce673012382196cac1931520cb3d8359f41cabc27f
|
7
|
+
data.tar.gz: 0b3175ca8b2f30f6d7a72dd55053783befbad0b4b1fa1356339fcc34151fc7f148b506a01c4c5a3313ad5316855e09e1cb1cabfded9183fb1445c6d529085784
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# infermedica
|
2
|
+
Ruby interface to the infermedica REST API
|
3
|
+
|
4
|
+
## Description
|
5
|
+
|
6
|
+
This is a Ruby interface to the Infermedica REST API: https://developer.infermedica.com/docs/api
|
7
|
+
|
8
|
+
It is (very) loosely based on the Python library: https://github.com/infermedica/python-api.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
```gem install infermedica```
|
13
|
+
|
14
|
+
## Dependencies
|
15
|
+
|
16
|
+
* json. I have tested with 1.8.x
|
17
|
+
* Ruby 2.x
|
18
|
+
|
19
|
+
## Quick Start
|
20
|
+
|
21
|
+
You will first need to get an API **Id** and *Key* from the **Infermedica** site
|
22
|
+
https://developer.infermedica.com/docs/api
|
23
|
+
|
24
|
+
To start using the API, require the infermedica gem and create an **Infermedica::Api** object,
|
25
|
+
passing the api_id and api_key to the constructor.
|
26
|
+
|
27
|
+
The constructor takes a hash as argument, so you have different options to pass the id and key:
|
28
|
+
|
29
|
+
```
|
30
|
+
require 'infermedica'
|
31
|
+
api = Infermedica::Api.new(api_id: 'xxxxx', api_key: 'xxxxxxxxxxx')
|
32
|
+
```
|
33
|
+
|
34
|
+
Or put the key and id in a .yaml file, read it, and pass the resulting hash to the constructor
|
35
|
+
|
36
|
+
In **config.yaml**
|
37
|
+
```
|
38
|
+
:api_id: xxxxx
|
39
|
+
:api_key: xxxxxxxxxxxxxx
|
40
|
+
:dev_mode: true
|
41
|
+
```
|
42
|
+
|
43
|
+
In **your script**
|
44
|
+
```
|
45
|
+
require 'infermedica'
|
46
|
+
require 'yaml'
|
47
|
+
|
48
|
+
access = YAML.load(File.read('.config.yaml'))
|
49
|
+
api = Infermedica::Api.new(access)
|
50
|
+
```
|
51
|
+
|
52
|
+
## Examples
|
53
|
+
|
54
|
+
The **examples** directory has some examples to get you started. They all assume that you have a **config.yaml**
|
55
|
+
in the same directory. Just create one with your own **api_id** and **api_key** and you should be able to just invoke
|
56
|
+
ruby on each example.
|
57
|
+
|
58
|
+
## Legal
|
59
|
+
|
60
|
+
The Infermedica REST API is copyrighted by [Infermedica](http://infermedica.com).
|
61
|
+
|
62
|
+
The Ruby code itself is released under the [MIT](https://opensource.org/licenses/MIT) license.
|
63
|
+
|
data/examples/triage.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'yaml'
|
3
|
+
require 'infermedica'
|
4
|
+
|
5
|
+
access = YAML.load(File.read('./config.yaml'))
|
6
|
+
api = Infermedica::Api.new(access)
|
7
|
+
|
8
|
+
# Create a diagnosis object with some initial patient info
|
9
|
+
|
10
|
+
diag = Infermedica::Diagnosis.new(sex: 'male', age: '35')
|
11
|
+
|
12
|
+
diag.add_symptom('s_1193', 'present')
|
13
|
+
diag.add_symptom('s_488', 'present')
|
14
|
+
diag.add_symptom('s_418', 'present')
|
15
|
+
|
16
|
+
# Call the triage endpoint
|
17
|
+
|
18
|
+
resp = api.triage(diag)
|
19
|
+
|
20
|
+
# Print the resulting data structure
|
21
|
+
|
22
|
+
pp resp
|
data/infermedica.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'infermedica'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2017-
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.date = '2017-02-27'
|
5
5
|
s.summary = 'Provide a Ruby interface to the Infermedica REST API'
|
6
6
|
s.description = 'A Ruby interface to the Infermedica REST API'
|
7
7
|
s.authors = ['Bruno Melli']
|
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.files = `git ls-files`.split($\)
|
10
10
|
s.require_paths = ['lib']
|
11
11
|
s.license = 'MIT'
|
12
|
+
s.required_ruby_version = '>= 2.0'
|
12
13
|
s.homepage = 'https://github.com/mjskier/infermedica'
|
13
14
|
s.add_runtime_dependency 'json', '~>1.8', '>= 1.8.3'
|
14
15
|
end
|
data/lib/infermedica.rb
CHANGED
@@ -105,6 +105,12 @@ module Infermedica
|
|
105
105
|
response = @connection.post('/diagnosis', diag.to_json)
|
106
106
|
end
|
107
107
|
|
108
|
+
# Submit a diagnosis object to get a triage
|
109
|
+
# See examples/triage.rb for an example
|
110
|
+
def triage(diag)
|
111
|
+
response = @connection.post('/triage', diag.to_json)
|
112
|
+
end
|
113
|
+
|
108
114
|
# Submit a diagnosis object to get an explanation
|
109
115
|
# See examples/explain.rb for an example
|
110
116
|
def explain(req, args = {})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infermedica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Melli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -37,6 +37,7 @@ extensions: []
|
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
39
|
- ".gitignore"
|
40
|
+
- README.md
|
40
41
|
- examples/condition.rb
|
41
42
|
- examples/diagnosis.rb
|
42
43
|
- examples/explain.rb
|
@@ -45,6 +46,7 @@ files:
|
|
45
46
|
- examples/risk_factor.rb
|
46
47
|
- examples/search.rb
|
47
48
|
- examples/symptom.rb
|
49
|
+
- examples/triage.rb
|
48
50
|
- infermedica.gemspec
|
49
51
|
- lib/infermedica.rb
|
50
52
|
- lib/infermedica/conditions.rb
|
@@ -74,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
76
|
requirements:
|
75
77
|
- - ">="
|
76
78
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
79
|
+
version: '2.0'
|
78
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
81
|
requirements:
|
80
82
|
- - ">="
|