redox-client 0.1.0 → 0.6.0
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/CHANGELOG.md +43 -1
- data/Gemfile.lock +7 -2
- data/README.md +37 -7
- data/Rakefile +47 -4
- data/lib/redox.rb +29 -3
- data/lib/redox/file_upload.rb +42 -0
- data/lib/redox/flowsheet/new.rb +13 -0
- data/lib/redox/media/new.rb +20 -0
- data/lib/redox/model.rb +1 -1
- data/lib/redox/models/contact.rb +19 -0
- data/lib/redox/models/demographics.rb +3 -0
- data/lib/redox/models/error.rb +12 -0
- data/lib/redox/models/location.rb +12 -0
- data/lib/redox/models/media.rb +23 -0
- data/lib/redox/models/message.rb +1 -0
- data/lib/redox/models/meta.rb +6 -0
- data/lib/redox/models/observation.rb +23 -0
- data/lib/redox/models/observer.rb +12 -0
- data/lib/redox/models/patient.rb +9 -3
- data/lib/redox/models/patient_identifier.rb +7 -3
- data/lib/redox/models/phone_number.rb +11 -0
- data/lib/redox/models/provider.rb +21 -0
- data/lib/redox/models/reference_range.rb +11 -0
- data/lib/redox/models/visit.rb +31 -0
- data/lib/redox/query.rb +4 -1
- data/lib/redox/scheduling/booked.rb +24 -0
- data/lib/redox/source.rb +23 -8
- data/lib/redox/version.rb +1 -1
- data/redox-client.gemspec +2 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb1842a350bb3d66e94a4bb186cbbd321c0fb6ef338e79a6e59746969c7c823
|
4
|
+
data.tar.gz: 0cb76bbd62d9f9cd5971d6e7b85b6a82f7bc756755e400ebaf2ffc94aa4e1c5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc36de5be79b0c6ad0ee7a45529d1d2ab92dfb37771cd21392fd9ef54565c02b8972a16cb741039d3cd07c14249a12b4924796621a8cf31ffdc21254a2db6f2
|
7
|
+
data.tar.gz: cf9ae7791cf26e89e3eaffec71fb8b05376c1a8d67ba0d0677f7f1eea58f14e1a76c3d4aee5bd2dc7797638311ed98041477de7f11e32922cffdd1308c9b78ba
|
data/CHANGELOG.md
CHANGED
@@ -2,14 +2,56 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
### Added
|
5
|
+
- Flowsheet.New data model
|
5
6
|
|
6
7
|
### Changed
|
7
8
|
|
8
9
|
### Removed
|
9
10
|
|
11
|
+
## [0.6.0] - 2020-11-02
|
12
|
+
### Added
|
13
|
+
- Flowsheet.New data model
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
|
19
|
+
## [0.5.0] - 2020-10-29
|
20
|
+
### Added
|
21
|
+
- File Upload
|
22
|
+
- Media.New
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
- fixed: source was re-authenticating every request (DateTime math was incorrect)
|
26
|
+
|
27
|
+
### Removed
|
28
|
+
- remove SchedulingBooked.Query Patient property. It is not present on the corresponding redox model and was never used.
|
29
|
+
|
30
|
+
## [0.4.0] - 2020-09-04
|
31
|
+
### Added
|
32
|
+
- add email and phone to demographics
|
33
|
+
- add patient contacts
|
34
|
+
|
35
|
+
## [0.3.0] - 2020-08-27
|
36
|
+
### Added
|
37
|
+
- _body attribute containing raw response text on query results
|
38
|
+
- SchedulingBooked.Query
|
39
|
+
|
40
|
+
## [0.2.0] - 2020-08-16
|
41
|
+
### Added
|
42
|
+
- improve release process
|
43
|
+
|
44
|
+
### Changed
|
45
|
+
- fixed CHANGELOG url in gemspec
|
46
|
+
|
10
47
|
## [0.1.0] - 2020-08-14
|
11
48
|
### Added
|
12
49
|
- implement PatientSearch.Query
|
13
50
|
|
14
|
-
[Unreleased]: https://github.com/patient-discovery/redox-client/compare/v1.0.0...HEAD
|
15
51
|
[0.1.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.1.0
|
52
|
+
[0.2.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.2.0
|
53
|
+
[0.3.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.3.0
|
54
|
+
[0.4.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.4.0
|
55
|
+
[0.5.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.5.0
|
56
|
+
[0.6.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.6.0
|
57
|
+
[Unreleased]: https://github.com/patient-discovery/redox-client/compare/v0.6.0...HEAD
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
redox-client (0.
|
4
|
+
redox-client (0.6.0)
|
5
5
|
faraday (~> 1.0, >= 1.0.1)
|
6
6
|
hashie (~> 4.1)
|
7
7
|
|
@@ -11,8 +11,9 @@ GEM
|
|
11
11
|
ast (2.4.1)
|
12
12
|
diff-lcs (1.4.4)
|
13
13
|
docile (1.3.2)
|
14
|
-
faraday (1.0
|
14
|
+
faraday (1.1.0)
|
15
15
|
multipart-post (>= 1.2, < 3)
|
16
|
+
ruby2_keywords
|
16
17
|
hashie (4.1.0)
|
17
18
|
multipart-post (2.1.1)
|
18
19
|
parallel (1.19.2)
|
@@ -26,6 +27,8 @@ GEM
|
|
26
27
|
rspec-core (~> 3.9.0)
|
27
28
|
rspec-expectations (~> 3.9.0)
|
28
29
|
rspec-mocks (~> 3.9.0)
|
30
|
+
rspec-collection_matchers (1.2.0)
|
31
|
+
rspec-expectations (>= 2.99.0.beta1)
|
29
32
|
rspec-core (3.9.2)
|
30
33
|
rspec-support (~> 3.9.3)
|
31
34
|
rspec-expectations (3.9.2)
|
@@ -49,6 +52,7 @@ GEM
|
|
49
52
|
rubocop-performance (1.6.1)
|
50
53
|
rubocop (>= 0.71.0)
|
51
54
|
ruby-progressbar (1.10.1)
|
55
|
+
ruby2_keywords (0.0.2)
|
52
56
|
simplecov (0.18.5)
|
53
57
|
docile (~> 1.1)
|
54
58
|
simplecov-html (~> 0.11)
|
@@ -66,6 +70,7 @@ DEPENDENCIES
|
|
66
70
|
rake (~> 12.0)
|
67
71
|
redox-client!
|
68
72
|
rspec (~> 3.9)
|
73
|
+
rspec-collection_matchers (~> 1.2)
|
69
74
|
simplecov (~> 0.18.5)
|
70
75
|
standard (~> 0.4.7)
|
71
76
|
vcr (~> 6.0)
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
[](https://badge.fury.io/rb/redox-client)
|
2
2
|
[](https://github.com/testdouble/standard)
|
3
|
+

|
3
4
|
|
4
5
|
# redox-client - Ruby gem facade for Redox APIs
|
5
6
|
|
@@ -77,6 +78,9 @@ Since `Redox::Source` has shared state, i.e., the access token and its expiratio
|
|
77
78
|
## Supported APIs
|
78
79
|
|
79
80
|
- PatientSearch.Query
|
81
|
+
- Scheduling.Booked
|
82
|
+
- Media.New
|
83
|
+
- File Upload
|
80
84
|
|
81
85
|
## Development
|
82
86
|
***Nota Bene**: This project uses [VCR](https://relishapp.com/vcr/vcr/docs) to record HTTP requests and responses and play them back during tests. Do NOT use Redox production credentials when developing tests.*
|
@@ -87,6 +91,29 @@ After checking out the repo, run `bin/setup` to install gem dependencies and a g
|
|
87
91
|
### Testing
|
88
92
|
This project uses `rspec` and [VCR](https://relishapp.com/vcr/vcr/docs). VCR provides fast deterministic testing of HTTP APIs. It also makes it possible to set up any server response you want to test by authoring the server responses directly. This comes in handy when trying to test edge cases that might occur but are hard to reproduce.
|
89
93
|
|
94
|
+
Some effort has been made to filter credentials from recorded HTTP interactions, but you should always carefully review all your changes before pushing them to avoid credential exposure.
|
95
|
+
|
96
|
+
### Recording and Playing Back Cassettes
|
97
|
+
The `VCR_MODE` environment variable controls whether VCR is recording cassettes or playing them back. When recoding cassettes the following environment variables are used to call Redox APIs:
|
98
|
+
|
99
|
+
- `REDOX_ENDPOINT`: base URL of Redox API endpoint (e.g., https://api.redoxengine.com/)
|
100
|
+
- `REDOX_API_KEY`: Redox `apiKey` used by /auth/authenticate
|
101
|
+
- `REDOX_SECRET`: Redox `secret` used by /auth/authenticate
|
102
|
+
|
103
|
+
Set these to the credentials for the Redox environment you are using for testing.
|
104
|
+
|
105
|
+
When playing back cassettes these environment variables are ignored and no API requests are made to Redox.
|
106
|
+
|
107
|
+
To make a new test with a new recording, set environment variables above then:
|
108
|
+
|
109
|
+
```bash
|
110
|
+
env VCR_MODE=record rspec spec/my_new_spec.rb
|
111
|
+
```
|
112
|
+
|
113
|
+
This will record all API requests made by the test. Be **careful**: if you run all the tests with `VCR_MODE=record` it will re-record all the cassettes.
|
114
|
+
|
115
|
+
The default mode is playback, so to playback cassettes just run `rspec`.
|
116
|
+
|
90
117
|
### Coding Style
|
91
118
|
This project adheres to [StandardRB](https://github.com/testdouble/standard/blob/master/README.md). Additionally
|
92
119
|
[# frozen_string_literal](https://bugs.ruby-lang.org/issues/8976#note-30) is required in Ruby source files, and is enforced by Rubocop.
|
@@ -96,14 +123,17 @@ Run `rake` to run the style checks. Run `rake fix` to fix violations.
|
|
96
123
|
### Useful commands
|
97
124
|
- `rake` - run all tests (lint, Redox cred scan, rspec)
|
98
125
|
- `rake fix` - Fix RuboCop and StandardRB violations
|
99
|
-
- `
|
126
|
+
- `rake vcr:fix` - attempt to replace real looking credentials in VCR cassettes with dummy test values.
|
100
127
|
- `rake -T` - see available rake tasks
|
101
128
|
- `bin/console` - get an interactive prompt for experimenting
|
102
129
|
|
103
130
|
### Release Process
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
131
|
+
This project uses [Semantic Versioning](https://semver.org)
|
132
|
+
|
133
|
+
Prepare release on master branch, then run:
|
134
|
+
|
135
|
+
```
|
136
|
+
rake prepare:release
|
137
|
+
```
|
138
|
+
|
139
|
+
and follow the instructions.
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "date"
|
3
4
|
require "bundler/gem_tasks"
|
4
5
|
require "rspec/core/rake_task"
|
5
6
|
require "standard/rake"
|
@@ -14,15 +15,57 @@ desc "Run all checks and tests"
|
|
14
15
|
task default: :test
|
15
16
|
|
16
17
|
desc "Run all checks and tests"
|
17
|
-
task test: [:rubocop, :standard, :
|
18
|
+
task test: [:rubocop, :standard, :vcr, :spec]
|
18
19
|
|
19
20
|
desc "Fix RuboCop and StandardRB violations"
|
20
21
|
task fix: ["rubocop:auto_correct", "standard:fix"]
|
21
22
|
|
23
|
+
# TODO: Make these a proper lib/rake_tasks.rb task and avoid exec'ing out
|
22
24
|
desc "Check VCR cassettes for Redox credential leak"
|
23
|
-
task
|
24
|
-
|
25
|
-
|
25
|
+
task "vcr" do
|
26
|
+
raise "Possible credential leak, run rake vcr:fix" unless system "bin/check-vcr-cassettes"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Scrub VCR cassettes, replacing suspected real creds with test ones"
|
30
|
+
task "vcr:fix" do
|
31
|
+
system "bin/check-vcr-cassettes --scrub"
|
32
|
+
end
|
33
|
+
|
34
|
+
task "prepare:changelog" do
|
35
|
+
repo = "https://github.com/patient-discovery/redox-client"
|
36
|
+
changelog = IO.readlines("CHANGELOG.md").map(&:chomp)
|
37
|
+
entries = [
|
38
|
+
"## [#{Redox::VERSION}] - #{Date.today}",
|
39
|
+
"[#{Redox::VERSION}]: #{repo}/releases/tag/v#{Redox::VERSION}",
|
40
|
+
"[Unreleased]: #{repo}/compare/v#{Redox::VERSION}...HEAD"
|
41
|
+
]
|
42
|
+
unless entries.all? { |x| changelog.include? x }
|
43
|
+
puts "\nAdd these to CHANGELOG.md:\n\n"
|
44
|
+
puts entries.join("\n")
|
45
|
+
puts "\n\n"
|
46
|
+
abort "ERROR: CHANGELOG version entries needed"
|
47
|
+
end
|
48
|
+
puts "CHANGELOG looks good"
|
49
|
+
end
|
50
|
+
|
51
|
+
task "prepare:version" do
|
52
|
+
if system("git show-ref --tags v#{Redox::VERSION}")
|
53
|
+
abort("ERROR: Tag already exists. Check version.rb")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
task "prepare:tag" do
|
58
|
+
unless system("git tag -m 'Version #{Redox::VERSION}' v#{Redox::VERSION}")
|
59
|
+
abort("ERROR: Unable to tag")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Prepare a gem release"
|
64
|
+
task "prepare:release": [
|
65
|
+
"release:guard_clean", "test", "prepare:version", "prepare:changelog", "prepare:tag"
|
66
|
+
] do
|
67
|
+
puts "Release tagged. To create release run:\n\n"
|
68
|
+
puts "git push --follow-tags"
|
26
69
|
end
|
27
70
|
|
28
71
|
CLEAN.include "coverage"
|
data/lib/redox.rb
CHANGED
@@ -4,18 +4,44 @@ require_relative "redox/version"
|
|
4
4
|
|
5
5
|
require_relative "redox/model"
|
6
6
|
require_relative "redox/models/address"
|
7
|
+
require_relative "redox/models/contact"
|
7
8
|
require_relative "redox/models/demographics"
|
8
9
|
require_relative "redox/models/destination"
|
10
|
+
require_relative "redox/models/error"
|
11
|
+
require_relative "redox/models/location"
|
12
|
+
require_relative "redox/models/media"
|
9
13
|
require_relative "redox/models/message"
|
10
14
|
require_relative "redox/models/meta"
|
11
|
-
require_relative "redox/models/
|
15
|
+
require_relative "redox/models/observation"
|
16
|
+
require_relative "redox/models/observer"
|
12
17
|
require_relative "redox/models/patient_identifier"
|
18
|
+
require_relative "redox/models/patient"
|
19
|
+
require_relative "redox/models/phone_number"
|
20
|
+
require_relative "redox/models/provider"
|
21
|
+
require_relative "redox/models/reference_range"
|
22
|
+
require_relative "redox/models/visit"
|
13
23
|
|
14
|
-
require_relative "redox/query"
|
15
24
|
require_relative "redox/source"
|
25
|
+
require_relative "redox/query"
|
26
|
+
require_relative "redox/file_upload"
|
27
|
+
|
16
28
|
require_relative "redox/patient_search/query.rb"
|
29
|
+
require_relative "redox/scheduling/booked.rb"
|
30
|
+
require_relative "redox/media/new.rb"
|
31
|
+
require_relative "redox/flowsheet/new.rb"
|
17
32
|
|
18
33
|
module Redox
|
19
|
-
class Error < StandardError
|
34
|
+
class Error < StandardError
|
35
|
+
attr_accessor :status
|
36
|
+
attr_accessor :body
|
37
|
+
attr_accessor :message
|
38
|
+
|
39
|
+
def initialize(status: nil, body: nil, message: nil)
|
40
|
+
self.status = status
|
41
|
+
self.body = body
|
42
|
+
self.message = message
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
20
46
|
class AuthenticationError < Error; end
|
21
47
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Redox
|
4
|
+
class FileUpload
|
5
|
+
ENDPOINT = "https://blob.redoxengine.com/upload"
|
6
|
+
|
7
|
+
# Create a multipart file upload.
|
8
|
+
#
|
9
|
+
# @param filename_or_io [String, IO] Either a String filename of a local file
|
10
|
+
# or an open IO object
|
11
|
+
# @param content_type [String] String content type of the file data
|
12
|
+
# @param upload_as_filename [String] (optional) Name to use for uploaded file
|
13
|
+
def initialize(filename_or_io, content_type, upload_as_filename = nil)
|
14
|
+
@file_part = Faraday::FilePart.new(filename_or_io, content_type, upload_as_filename)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Upload the file.
|
18
|
+
#
|
19
|
+
# @param [Redox::Source] source to use for authentication
|
20
|
+
def perform(source)
|
21
|
+
source.ensure_access_token
|
22
|
+
|
23
|
+
connection = Faraday.new { |f|
|
24
|
+
f.authorization :Bearer, source.access_token
|
25
|
+
f.request :multipart
|
26
|
+
f.headers[:accept] = "application/json"
|
27
|
+
}
|
28
|
+
res = connection.post ENDPOINT, {file: @file_part}
|
29
|
+
|
30
|
+
raise Redox::Error.new(status: res.status, body: res.body) unless res.success?
|
31
|
+
|
32
|
+
uri =
|
33
|
+
begin
|
34
|
+
JSON.parse(res.body)["URI"]
|
35
|
+
rescue
|
36
|
+
end
|
37
|
+
raise Redox::Error.new(status: res.status, body: res.body) unless uri
|
38
|
+
|
39
|
+
uri
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "redox"
|
4
|
+
|
5
|
+
module Redox
|
6
|
+
module Flowsheet
|
7
|
+
class New < Models::Message
|
8
|
+
redox_property :Patient, coerce: Models::Patient
|
9
|
+
redox_property :Visit, coerce: Models::Visit
|
10
|
+
redox_property :Observations, coerce: Array[Models::Observation]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "redox"
|
4
|
+
|
5
|
+
module Redox
|
6
|
+
module Media
|
7
|
+
class New < Redox::Query
|
8
|
+
redox_property :Patient, coerce: Models::Patient
|
9
|
+
redox_property :Visit, coerce: Models::Visit
|
10
|
+
redox_property :Media, coerce: Models::Media
|
11
|
+
|
12
|
+
def response_type
|
13
|
+
NewResponse
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class NewResponse < Models::Message
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/redox/model.rb
CHANGED
@@ -55,7 +55,7 @@ class Redox::Model < Hashie::Trash
|
|
55
55
|
# rails `String.underscore` method with the following simplications:
|
56
56
|
#
|
57
57
|
# - any word in all caps is assumed to be an acronym (ZIP -> zip)
|
58
|
-
# - only alphabetic characters
|
58
|
+
# - only alphabetic characters are modified
|
59
59
|
#
|
60
60
|
# Note: this function does not have an inverse. Both "Zip" and "ZIP"
|
61
61
|
# map to "zip".
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "address"
|
4
|
+
require_relative "phone_number"
|
5
|
+
|
6
|
+
module Redox
|
7
|
+
module Models
|
8
|
+
class Contact < Redox::Model
|
9
|
+
redox_property :FirstName
|
10
|
+
redox_property :MiddleName
|
11
|
+
redox_property :LastName
|
12
|
+
redox_property :Address, coerce: Address
|
13
|
+
redox_property :PhoneNumber, coerce: PhoneNumber
|
14
|
+
redox_property :EmailAddresses, coerce: Array[String]
|
15
|
+
redox_property :RelationToPatient
|
16
|
+
redox_property :Roles, coerce: Array[String]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "address"
|
4
|
+
require_relative "phone_number"
|
4
5
|
|
5
6
|
module Redox
|
6
7
|
module Models
|
@@ -12,6 +13,8 @@ module Redox
|
|
12
13
|
redox_property :SSN
|
13
14
|
redox_property :Sex
|
14
15
|
redox_property :Address, coerce: Address
|
16
|
+
redox_property :PhoneNumber, coerce: PhoneNumber
|
17
|
+
redox_property :EmailAddresses, coerce: Array[String]
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "provider"
|
4
|
+
|
5
|
+
module Redox
|
6
|
+
module Models
|
7
|
+
class Media < Redox::Model
|
8
|
+
redox_property :FileType
|
9
|
+
redox_property :FileName
|
10
|
+
redox_property :FileContents
|
11
|
+
redox_property :DocumentType
|
12
|
+
redox_property :DocumentID
|
13
|
+
redox_property :DocumentDescription
|
14
|
+
redox_property :CreationDateTime
|
15
|
+
redox_property :ServiceDateTime
|
16
|
+
redox_property :Provider, coerce: Provider
|
17
|
+
redox_property :Authenticated
|
18
|
+
redox_property :Authenticator, coerce: Provider
|
19
|
+
redox_property :Availability
|
20
|
+
redox_property :Notifications, coerce: Array[Provider]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/redox/models/message.rb
CHANGED
data/lib/redox/models/meta.rb
CHANGED
@@ -4,12 +4,18 @@ require_relative "destination"
|
|
4
4
|
|
5
5
|
module Redox
|
6
6
|
module Models
|
7
|
+
# Redox::Message is already taken: it refers to an entire response
|
8
|
+
class MetaMessage < Redox::Model
|
9
|
+
redox_property :ID
|
10
|
+
end
|
7
11
|
class Meta < Redox::Model
|
8
12
|
redox_property :DataModel
|
9
13
|
redox_property :EventType
|
10
14
|
redox_property :EventDateTime
|
11
15
|
redox_property :Test
|
12
16
|
redox_property :Destinations, coerce: Array[Redox::Models::Destination]
|
17
|
+
redox_property :Message, coerce: MetaMessage
|
18
|
+
redox_property :Errors, coerce: Array[Redox::Models::Error]
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "observer"
|
4
|
+
require_relative "reference_range"
|
5
|
+
|
6
|
+
module Redox
|
7
|
+
module Models
|
8
|
+
class Observation < Redox::Model
|
9
|
+
redox_property :DateTime
|
10
|
+
redox_property :Value
|
11
|
+
redox_property :ValueType
|
12
|
+
redox_property :Units
|
13
|
+
redox_property :Code
|
14
|
+
redox_property :Codeset
|
15
|
+
redox_property :Description
|
16
|
+
redox_property :Status
|
17
|
+
redox_property :Notes, coerce: Array[String]
|
18
|
+
redox_property :Observer, coerce: Observer
|
19
|
+
redox_property :ReferenceRange, coerce: ReferenceRange
|
20
|
+
redox_property :AbnormalFlag
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/redox/models/patient.rb
CHANGED
@@ -2,8 +2,14 @@
|
|
2
2
|
|
3
3
|
require_relative "patient_identifier"
|
4
4
|
require_relative "demographics"
|
5
|
+
require_relative "contact"
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
module Redox
|
8
|
+
module Models
|
9
|
+
class Patient < Redox::Model
|
10
|
+
redox_property :Identifiers, coerce: Array[PatientIdentifier]
|
11
|
+
redox_property :Demographics, coerce: Demographics
|
12
|
+
redox_property :Contacts, coerce: Array[Contact]
|
13
|
+
end
|
14
|
+
end
|
9
15
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Redox
|
4
|
+
module Models
|
5
|
+
class PatientIdentifier < Redox::Model
|
6
|
+
redox_property :IDType
|
7
|
+
redox_property :ID
|
8
|
+
end
|
9
|
+
end
|
6
10
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "address"
|
4
|
+
require_relative "location"
|
5
|
+
require_relative "phone_number"
|
6
|
+
|
7
|
+
module Redox
|
8
|
+
module Models
|
9
|
+
class Provider < Redox::Model
|
10
|
+
redox_property :ID
|
11
|
+
redox_property :IDType
|
12
|
+
redox_property :FirstName
|
13
|
+
redox_property :LastName
|
14
|
+
redox_property :Credentials, coerce: Array[String]
|
15
|
+
redox_property :Address, coerce: Address
|
16
|
+
redox_property :EmailAddresses, coerce: Array[String]
|
17
|
+
redox_property :PhoneNumber, coerce: PhoneNumber
|
18
|
+
redox_property :Location, coerce: Location
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "location"
|
4
|
+
require_relative "patient"
|
5
|
+
require_relative "provider"
|
6
|
+
|
7
|
+
module Redox
|
8
|
+
module Models
|
9
|
+
class Visit < Redox::Model
|
10
|
+
redox_property :VisitNumber
|
11
|
+
redox_property :AccountNumber
|
12
|
+
redox_property :VisitDateTime
|
13
|
+
redox_property :PatientClass
|
14
|
+
redox_property :Status
|
15
|
+
redox_property :Duration
|
16
|
+
redox_property :Reason
|
17
|
+
redox_property :CancelReason
|
18
|
+
redox_property :LastUpdated
|
19
|
+
redox_property :ScheduledDateTime
|
20
|
+
redox_property :CancelDateTime
|
21
|
+
redox_property :Type
|
22
|
+
redox_property :Instructions
|
23
|
+
redox_property :Patient, coerce: Patient
|
24
|
+
redox_property :AttendingProvider, coerce: Provider
|
25
|
+
redox_property :ConsultingProvider, coerce: Provider
|
26
|
+
redox_property :ReferringProvider, coerce: Provider
|
27
|
+
redox_property :VisitProvider, coerce: Provider
|
28
|
+
redox_property :Location, coerce: Location
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/redox/query.rb
CHANGED
@@ -12,7 +12,10 @@ module Redox
|
|
12
12
|
event_date_time: DateTime.now.iso8601,
|
13
13
|
destinations: [Redox::Models::Destination.new(id: destination_id)]
|
14
14
|
}
|
15
|
-
|
15
|
+
result_body = source.execute_query self
|
16
|
+
response = response_type.from_redox_json result_body
|
17
|
+
response._body = result_body
|
18
|
+
response
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "redox"
|
4
|
+
|
5
|
+
module Redox
|
6
|
+
module Scheduling
|
7
|
+
class Booked < Redox::Query
|
8
|
+
redox_property :StartDateTime, coerce: ->(v) {
|
9
|
+
v.respond_to?(:iso8601) ? v.iso8601 : v.to_s
|
10
|
+
}
|
11
|
+
redox_property :EndDateTime, coerce: ->(v) {
|
12
|
+
v.respond_to?(:iso8601) ? v.iso8601 : v.to_s
|
13
|
+
}
|
14
|
+
|
15
|
+
def response_type
|
16
|
+
BookedResponse
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class BookedResponse < Models::Message
|
21
|
+
redox_property :Visits, coerce: Array[Models::Visit]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/redox/source.rb
CHANGED
@@ -7,9 +7,10 @@ require "faraday"
|
|
7
7
|
class Redox::Source
|
8
8
|
include MonitorMixin
|
9
9
|
|
10
|
-
|
10
|
+
SECONDS_PER_DAY = 60 * 60 * 24
|
11
|
+
ACCESS_TOKEN_EXPIRATION_BUFFER = Rational(300, SECONDS_PER_DAY)
|
11
12
|
|
12
|
-
attr_reader :access_token_expires_at
|
13
|
+
attr_reader :endpoint, :api_key, :access_token_expires_at
|
13
14
|
|
14
15
|
def initialize(endpoint:, api_key:, secret:, test_mode: true)
|
15
16
|
super()
|
@@ -20,6 +21,7 @@ class Redox::Source
|
|
20
21
|
content_type: "application/json"
|
21
22
|
}
|
22
23
|
)
|
24
|
+
@endpoint = endpoint
|
23
25
|
@api_key = api_key
|
24
26
|
@secret = secret
|
25
27
|
@test_mode = test_mode
|
@@ -28,8 +30,21 @@ class Redox::Source
|
|
28
30
|
def execute_query(model)
|
29
31
|
ensure_access_token
|
30
32
|
res = @connection.post("/endpoint", model.to_redox_json)
|
31
|
-
|
32
|
-
|
33
|
+
message =
|
34
|
+
begin
|
35
|
+
JSON.parse(res.body)
|
36
|
+
rescue
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
unless res.success?
|
41
|
+
raise Redox::Error.new(
|
42
|
+
status: res.status,
|
43
|
+
body: res.body,
|
44
|
+
message: Redox::Models::Message.from_redox_json(message)
|
45
|
+
)
|
46
|
+
end
|
47
|
+
message
|
33
48
|
end
|
34
49
|
|
35
50
|
def ensure_access_token
|
@@ -50,16 +65,16 @@ class Redox::Source
|
|
50
65
|
end
|
51
66
|
end
|
52
67
|
|
53
|
-
private
|
54
|
-
|
55
68
|
def token_expiring_soon?
|
56
|
-
DateTime.now > @access_token_expires_at -
|
69
|
+
DateTime.now > @access_token_expires_at - ACCESS_TOKEN_EXPIRATION_BUFFER
|
57
70
|
end
|
58
71
|
|
72
|
+
private
|
73
|
+
|
59
74
|
def authenticate
|
60
75
|
self.access_token = nil
|
61
76
|
res = @connection.post("/auth/authenticate", {apiKey: @api_key, secret: @secret}.to_json)
|
62
|
-
raise Redox::AuthenticationError.new
|
77
|
+
raise Redox::AuthenticationError.new status: res.status, body: res.body unless res.success?
|
63
78
|
data = JSON.parse(res.body)
|
64
79
|
self.access_token = data["accessToken"]
|
65
80
|
@access_token_expires_at = DateTime.parse(data["expires"])
|
data/lib/redox/version.rb
CHANGED
data/redox-client.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = "Ruby library for consuming Redox JSON APIs"
|
13
13
|
gem.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
14
14
|
gem.metadata["source_code_uri"] = gem.homepage
|
15
|
-
gem.metadata["changelog_uri"] = "#{gem.homepage}/CHANGELOG.md"
|
15
|
+
gem.metadata["changelog_uri"] = "#{gem.homepage}/blob/master/CHANGELOG.md"
|
16
16
|
|
17
17
|
gem.license = "MIT"
|
18
18
|
gem.files = Dir.chdir(File.expand_path(__dir__)) do
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
|
23
23
|
gem.add_development_dependency "rake", "~> 12.0"
|
24
24
|
gem.add_development_dependency "rspec", "~> 3.9"
|
25
|
+
gem.add_development_dependency "rspec-collection_matchers", "~> 1.2"
|
25
26
|
gem.add_development_dependency "simplecov", "~> 0.18.5"
|
26
27
|
gem.add_development_dependency "standard", "~> 0.4.7"
|
27
28
|
gem.add_development_dependency "vcr", "~> 6.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redox-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Keirnan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-collection_matchers
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: simplecov
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,16 +142,30 @@ files:
|
|
128
142
|
- README.md
|
129
143
|
- Rakefile
|
130
144
|
- lib/redox.rb
|
145
|
+
- lib/redox/file_upload.rb
|
146
|
+
- lib/redox/flowsheet/new.rb
|
147
|
+
- lib/redox/media/new.rb
|
131
148
|
- lib/redox/model.rb
|
132
149
|
- lib/redox/models/address.rb
|
150
|
+
- lib/redox/models/contact.rb
|
133
151
|
- lib/redox/models/demographics.rb
|
134
152
|
- lib/redox/models/destination.rb
|
153
|
+
- lib/redox/models/error.rb
|
154
|
+
- lib/redox/models/location.rb
|
155
|
+
- lib/redox/models/media.rb
|
135
156
|
- lib/redox/models/message.rb
|
136
157
|
- lib/redox/models/meta.rb
|
158
|
+
- lib/redox/models/observation.rb
|
159
|
+
- lib/redox/models/observer.rb
|
137
160
|
- lib/redox/models/patient.rb
|
138
161
|
- lib/redox/models/patient_identifier.rb
|
162
|
+
- lib/redox/models/phone_number.rb
|
163
|
+
- lib/redox/models/provider.rb
|
164
|
+
- lib/redox/models/reference_range.rb
|
165
|
+
- lib/redox/models/visit.rb
|
139
166
|
- lib/redox/patient_search/query.rb
|
140
167
|
- lib/redox/query.rb
|
168
|
+
- lib/redox/scheduling/booked.rb
|
141
169
|
- lib/redox/source.rb
|
142
170
|
- lib/redox/version.rb
|
143
171
|
- redox-client.gemspec
|
@@ -146,7 +174,7 @@ licenses:
|
|
146
174
|
- MIT
|
147
175
|
metadata:
|
148
176
|
source_code_uri: https://github.com/patient-discovery/redox-client
|
149
|
-
changelog_uri: https://github.com/patient-discovery/redox-client/CHANGELOG.md
|
177
|
+
changelog_uri: https://github.com/patient-discovery/redox-client/blob/master/CHANGELOG.md
|
150
178
|
post_install_message:
|
151
179
|
rdoc_options: []
|
152
180
|
require_paths:
|