redox-client 0.2.0 → 0.7.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 +14 -2
- data/README.md +29 -2
- data/Rakefile +10 -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 +32 -0
- data/lib/redox/query.rb +4 -1
- data/lib/redox/scheduling/booked.rb +25 -0
- data/lib/redox/source.rb +23 -8
- data/lib/redox/version.rb +1 -1
- data/redox-client.gemspec +4 -1
- metadata +59 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61496cd6d9179e9bdaf751c4c07552c10c1cae5fa4dc55e86135fb377253fe93
|
4
|
+
data.tar.gz: ea8b48866244c15ce1daa183274faf72bbce6b5f9b6ccfba9676a30792b9f234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec8bc7f4e6def7b10f472dbb270c0ed94928aaeae8f51226929c9a44368d6e1519f7a23596a7167139660b1ee28b22846f520a2ba293c3cb9e3491ae2156485
|
7
|
+
data.tar.gz: 05607f97e183226a51b012594578d145273462b34d618a3f8bfeb5d49da16f0fa05dafcb02526fd0c7f293b78a297338f180fde141e287d0194a36406e9c97aa
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,44 @@
|
|
7
7
|
|
8
8
|
### Removed
|
9
9
|
|
10
|
+
## [0.7.0] - 2021-02-15
|
11
|
+
[0.7.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.7.0
|
12
|
+
### Added
|
13
|
+
- Scheduling.Booked query can optionally restrict results to specific patients.
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
- VisitNumber now appears to be a string in redox (previously it was an integer). This doesn't affect this library as strings, numbers, and booleans are passed through as-is after parsing the JSON. The update was to the test recordings and specs to assert the correct type.
|
17
|
+
|
18
|
+
### Removed
|
19
|
+
## [0.6.0] - 2020-11-02
|
20
|
+
### Added
|
21
|
+
- Flowsheet.New data model
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
### Removed
|
26
|
+
|
27
|
+
## [0.5.0] - 2020-10-29
|
28
|
+
### Added
|
29
|
+
- File Upload
|
30
|
+
- Media.New
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
- fixed: source was re-authenticating every request (DateTime math was incorrect)
|
34
|
+
|
35
|
+
### Removed
|
36
|
+
- remove SchedulingBooked.Query Patient property. It is not present on the corresponding redox model and was never used.
|
37
|
+
|
38
|
+
## [0.4.0] - 2020-09-04
|
39
|
+
### Added
|
40
|
+
- add email and phone to demographics
|
41
|
+
- add patient contacts
|
42
|
+
|
43
|
+
## [0.3.0] - 2020-08-27
|
44
|
+
### Added
|
45
|
+
- _body attribute containing raw response text on query results
|
46
|
+
- SchedulingBooked.Query
|
47
|
+
|
10
48
|
## [0.2.0] - 2020-08-16
|
11
49
|
### Added
|
12
50
|
- improve release process
|
@@ -20,4 +58,8 @@
|
|
20
58
|
|
21
59
|
[0.1.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.1.0
|
22
60
|
[0.2.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.2.0
|
23
|
-
[
|
61
|
+
[0.3.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.3.0
|
62
|
+
[0.4.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.4.0
|
63
|
+
[0.5.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.5.0
|
64
|
+
[0.6.0]: https://github.com/patient-discovery/redox-client/releases/tag/v0.6.0
|
65
|
+
[Unreleased]: https://github.com/patient-discovery/redox-client/compare/v0.7.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.7.0)
|
5
5
|
faraday (~> 1.0, >= 1.0.1)
|
6
6
|
hashie (~> 4.1)
|
7
7
|
|
@@ -9,10 +9,14 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ast (2.4.1)
|
12
|
+
debase (0.2.4.1)
|
13
|
+
debase-ruby_core_source (>= 0.10.2)
|
14
|
+
debase-ruby_core_source (0.10.12)
|
12
15
|
diff-lcs (1.4.4)
|
13
16
|
docile (1.3.2)
|
14
|
-
faraday (1.0
|
17
|
+
faraday (1.1.0)
|
15
18
|
multipart-post (>= 1.2, < 3)
|
19
|
+
ruby2_keywords
|
16
20
|
hashie (4.1.0)
|
17
21
|
multipart-post (2.1.1)
|
18
22
|
parallel (1.19.2)
|
@@ -26,6 +30,8 @@ GEM
|
|
26
30
|
rspec-core (~> 3.9.0)
|
27
31
|
rspec-expectations (~> 3.9.0)
|
28
32
|
rspec-mocks (~> 3.9.0)
|
33
|
+
rspec-collection_matchers (1.2.0)
|
34
|
+
rspec-expectations (>= 2.99.0.beta1)
|
29
35
|
rspec-core (3.9.2)
|
30
36
|
rspec-support (~> 3.9.3)
|
31
37
|
rspec-expectations (3.9.2)
|
@@ -48,7 +54,10 @@ GEM
|
|
48
54
|
parser (>= 2.7.1.4)
|
49
55
|
rubocop-performance (1.6.1)
|
50
56
|
rubocop (>= 0.71.0)
|
57
|
+
ruby-debug-ide (0.7.2)
|
58
|
+
rake (>= 0.8.1)
|
51
59
|
ruby-progressbar (1.10.1)
|
60
|
+
ruby2_keywords (0.0.2)
|
52
61
|
simplecov (0.18.5)
|
53
62
|
docile (~> 1.1)
|
54
63
|
simplecov-html (~> 0.11)
|
@@ -63,9 +72,12 @@ PLATFORMS
|
|
63
72
|
ruby
|
64
73
|
|
65
74
|
DEPENDENCIES
|
75
|
+
debase (~> 0.2.4.1)
|
66
76
|
rake (~> 12.0)
|
67
77
|
redox-client!
|
68
78
|
rspec (~> 3.9)
|
79
|
+
rspec-collection_matchers (~> 1.2)
|
80
|
+
ruby-debug-ide (~> 0.7.2)
|
69
81
|
simplecov (~> 0.18.5)
|
70
82
|
standard (~> 0.4.7)
|
71
83
|
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,14 @@ 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
131
|
This project uses [Semantic Versioning](https://semver.org)
|
105
132
|
|
106
|
-
Prepare release on
|
133
|
+
Prepare release on main branch, then run:
|
107
134
|
|
108
135
|
```
|
109
136
|
rake prepare:release
|
data/Rakefile
CHANGED
@@ -15,15 +15,20 @@ desc "Run all checks and tests"
|
|
15
15
|
task default: :test
|
16
16
|
|
17
17
|
desc "Run all checks and tests"
|
18
|
-
task test: [:rubocop, :standard, :
|
18
|
+
task test: [:rubocop, :standard, :vcr, :spec]
|
19
19
|
|
20
20
|
desc "Fix RuboCop and StandardRB violations"
|
21
21
|
task fix: ["rubocop:auto_correct", "standard:fix"]
|
22
22
|
|
23
|
+
# TODO: Make these a proper lib/rake_tasks.rb task and avoid exec'ing out
|
23
24
|
desc "Check VCR cassettes for Redox credential leak"
|
24
|
-
task
|
25
|
-
|
26
|
-
|
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"
|
27
32
|
end
|
28
33
|
|
29
34
|
task "prepare:changelog" do
|
@@ -55,6 +60,7 @@ task "prepare:tag" do
|
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
63
|
+
desc "Prepare a gem release"
|
58
64
|
task "prepare:release": [
|
59
65
|
"release:guard_clean", "test", "prepare:version", "prepare:changelog", "prepare:tag"
|
60
66
|
] do
|
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,32 @@
|
|
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 :Patients, coerce: Array[Patient]
|
25
|
+
redox_property :AttendingProvider, coerce: Provider
|
26
|
+
redox_property :ConsultingProvider, coerce: Provider
|
27
|
+
redox_property :ReferringProvider, coerce: Provider
|
28
|
+
redox_property :VisitProvider, coerce: Provider
|
29
|
+
redox_property :Location, coerce: Location
|
30
|
+
end
|
31
|
+
end
|
32
|
+
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,25 @@
|
|
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
|
+
redox_property :Visit, coerce: Models::Visit
|
15
|
+
|
16
|
+
def response_type
|
17
|
+
BookedResponse
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class BookedResponse < Models::Message
|
22
|
+
redox_property :Visits, coerce: Array[Models::Visit]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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}/blob/
|
15
|
+
gem.metadata["changelog_uri"] = "#{gem.homepage}/blob/main/CHANGELOG.md"
|
16
16
|
|
17
17
|
gem.license = "MIT"
|
18
18
|
gem.files = Dir.chdir(File.expand_path(__dir__)) do
|
@@ -20,8 +20,11 @@ Gem::Specification.new do |gem|
|
|
20
20
|
end
|
21
21
|
gem.require_paths = ["lib"]
|
22
22
|
|
23
|
+
gem.add_development_dependency "debase", "~> 0.2.4.1"
|
23
24
|
gem.add_development_dependency "rake", "~> 12.0"
|
25
|
+
gem.add_development_dependency "ruby-debug-ide", "~> 0.7.2"
|
24
26
|
gem.add_development_dependency "rspec", "~> 3.9"
|
27
|
+
gem.add_development_dependency "rspec-collection_matchers", "~> 1.2"
|
25
28
|
gem.add_development_dependency "simplecov", "~> 0.18.5"
|
26
29
|
gem.add_development_dependency "standard", "~> 0.4.7"
|
27
30
|
gem.add_development_dependency "vcr", "~> 6.0"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redox-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2021-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: debase
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.4.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.4.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '12.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-debug-ide
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.2
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rspec
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +66,20 @@ dependencies:
|
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '3.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-collection_matchers
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
84
|
name: simplecov
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,16 +170,30 @@ files:
|
|
128
170
|
- README.md
|
129
171
|
- Rakefile
|
130
172
|
- lib/redox.rb
|
173
|
+
- lib/redox/file_upload.rb
|
174
|
+
- lib/redox/flowsheet/new.rb
|
175
|
+
- lib/redox/media/new.rb
|
131
176
|
- lib/redox/model.rb
|
132
177
|
- lib/redox/models/address.rb
|
178
|
+
- lib/redox/models/contact.rb
|
133
179
|
- lib/redox/models/demographics.rb
|
134
180
|
- lib/redox/models/destination.rb
|
181
|
+
- lib/redox/models/error.rb
|
182
|
+
- lib/redox/models/location.rb
|
183
|
+
- lib/redox/models/media.rb
|
135
184
|
- lib/redox/models/message.rb
|
136
185
|
- lib/redox/models/meta.rb
|
186
|
+
- lib/redox/models/observation.rb
|
187
|
+
- lib/redox/models/observer.rb
|
137
188
|
- lib/redox/models/patient.rb
|
138
189
|
- lib/redox/models/patient_identifier.rb
|
190
|
+
- lib/redox/models/phone_number.rb
|
191
|
+
- lib/redox/models/provider.rb
|
192
|
+
- lib/redox/models/reference_range.rb
|
193
|
+
- lib/redox/models/visit.rb
|
139
194
|
- lib/redox/patient_search/query.rb
|
140
195
|
- lib/redox/query.rb
|
196
|
+
- lib/redox/scheduling/booked.rb
|
141
197
|
- lib/redox/source.rb
|
142
198
|
- lib/redox/version.rb
|
143
199
|
- redox-client.gemspec
|
@@ -146,7 +202,7 @@ licenses:
|
|
146
202
|
- MIT
|
147
203
|
metadata:
|
148
204
|
source_code_uri: https://github.com/patient-discovery/redox-client
|
149
|
-
changelog_uri: https://github.com/patient-discovery/redox-client/blob/
|
205
|
+
changelog_uri: https://github.com/patient-discovery/redox-client/blob/main/CHANGELOG.md
|
150
206
|
post_install_message:
|
151
207
|
rdoc_options: []
|
152
208
|
require_paths:
|