updox 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7eeab31e87fabd58b70a27bcf1a2012ba06ac93421d23861cc246d12bcf3614f
4
+ data.tar.gz: c4969565b9a34f4f87afacf4bd1e26165e04e17bc931457dfebc9108acb037b7
5
+ SHA512:
6
+ metadata.gz: a32b3b74cc2f7afd897418274d8a041a02602c0fabf783ea2a6bcf172750cdbaa2af5873a8a7ac48e0e4ec047a5bcc26a50a8db8a759ceb662587cea54a19fd1
7
+ data.tar.gz: 451421900c7777190b72db3c95a8124a3294c0b0c945ac28cb08b263015b7222c5d276252e80c9cbbab637c13273fa909aa91bbb6bee69ffa6297a0f546cca93
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.x] - UNRELEASED
8
+ ### Changed
9
+ - None
10
+
11
+ ## 0.1.0 - 2020-01-20
12
+ ### Added
13
+ - Initial Release
14
+
15
+ [Unreleased]: https://github.com/WeInfuse/redox/compare/v1.0.2...HEAD
16
+ [0.1.1]: https://github.com/WeInfuse/redox/compare/0.1.0...0.1.1
@@ -0,0 +1,73 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ education, socio-economic status, nationality, personal appearance, race,
10
+ religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redox.gemspec
4
+ gemspec
@@ -0,0 +1,117 @@
1
+ [![CircleCI](https://circleci.com/gh/WeInfuse/updox.svg?style=svg)](https://circleci.com/gh/WeInfuse/updox)
2
+
3
+ # Updox
4
+ Ruby API wrapper for [Updox](https://updoxqa.com/api/newio)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'updox'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install updox
21
+
22
+ ## Usage
23
+
24
+ ### Setup
25
+
26
+ Make sure you're [configured](#configuration)!
27
+
28
+ ```ruby
29
+ patient = Updox::Models::Patient.new
30
+ patient.demographics.first_name = 'Joe'
31
+ patient.demographics['LastName'] = 'Joerson'
32
+ patient.add_identifier(type: 'TheType', value: 'x13005')
33
+
34
+ meta = Updox::Models::Meta.new
35
+ meta.set_source(name: 'MySource', id: '123-584')
36
+ meta.add_destination(name: 'TheDest', id: '973-238')
37
+ ```
38
+
39
+ ### Create
40
+
41
+ ```ruby
42
+ response = patient.create(meta: meta)
43
+ ```
44
+
45
+ ### Update
46
+
47
+ ```ruby
48
+ response = patient.update(meta: meta)
49
+ ```
50
+
51
+ ### Search
52
+
53
+ ```ruby
54
+ response = Updox::Models::Patient.query(patient, meta: meta)
55
+ ```
56
+
57
+ ### Response
58
+
59
+ The response object is a base `Updox::Models::Model` class.
60
+
61
+ With the HTTParty response object
62
+ ```ruby
63
+ response.response
64
+ #<HTTParty::Response:0x7fa354c1fbe8>
65
+
66
+ response.response.ok?
67
+ true
68
+ ```
69
+
70
+ And any `Model` objects that were returned
71
+ ```ruby
72
+ response.patient
73
+ {
74
+ "Identifiers"=> [
75
+ {"IDType"=>"MR", "ID"=>"0000000003"},
76
+ {"ID"=>"e3fedf48-c8bf-4728-845f-cb810001b571", "IDType"=>"EHRID"}
77
+ ],
78
+ "Demographics"=> {
79
+ "Race"=>"Black",
80
+ "SSN"=>"303-03-0003",
81
+ "Nickname"=>"Walt"
82
+ ...
83
+ }
84
+ "PCP"=> {
85
+ "NPI"=>nil,
86
+ }
87
+ }
88
+
89
+ response.meta
90
+ {
91
+ "EventDateTime"=>"2019-04-26T20:03:00.304866Z",
92
+ "DataModel"=>"PatientAdmin",
93
+ ...
94
+ "Transmission"=>{"ID"=>797225234},
95
+ "Message"=>{"ID"=>1095117817}
96
+ }
97
+ ```
98
+
99
+ ### Configuration
100
+
101
+ ```ruby
102
+ Updox.configure do |c|
103
+ c.application_id = ENV['UPDOX_APP_ID']
104
+ c.application_password = ENV['UPDOX_APP_PASS']
105
+ c.api_endpoint = 'http://hello.com' # Defaults to Updox endpoint
106
+ end
107
+ ```
108
+
109
+ ## Development
110
+
111
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
112
+
113
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
114
+
115
+ ## Contributing
116
+
117
+ Bug reports and pull requests are welcome on GitHub at https://github.com/WeInfuse/updox.
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,65 @@
1
+ require 'httparty'
2
+ require 'hashie'
3
+ require 'updox/version'
4
+ require 'updox/updox_exception'
5
+ require 'updox/connection'
6
+ require 'updox/models/auth'
7
+ require 'updox/models/practice'
8
+
9
+ module Updox
10
+ class Configuration
11
+ attr_accessor :application_id, :application_password
12
+
13
+ def initialize
14
+ @application_id = nil
15
+ @application_password = nil
16
+ end
17
+
18
+ def api_endpoint=(endpoint)
19
+ Connection.base_uri(endpoint.freeze)
20
+ end
21
+
22
+ def api_endpoint
23
+ return Connection.base_uri
24
+ end
25
+
26
+ def to_h
27
+ return {
28
+ application_id: @application_id,
29
+ application_password: @application_password,
30
+ api_endpoint: api_endpoint
31
+ }
32
+ end
33
+
34
+ def from_h(h)
35
+ self.application_id = h[:application_id]
36
+ self.application_password = h[:application_password]
37
+ self.api_endpoint = h[:api_endpoint]
38
+
39
+ return self
40
+ end
41
+ end
42
+
43
+ class << self
44
+ def configuration
45
+ @configuration ||= Configuration.new
46
+ end
47
+
48
+ def configure
49
+ yield(configuration)
50
+ end
51
+ end
52
+
53
+ # Updox API client
54
+ class UpdoxClient
55
+ class << self
56
+ def connection
57
+ @connection ||= Connection.new
58
+ end
59
+
60
+ def release
61
+ @connection = nil
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,36 @@
1
+ module Updox
2
+ class Connection
3
+ include HTTParty
4
+
5
+ base_uri 'http://updoxqa.com/api/io/'.freeze
6
+
7
+ headers 'Content-Type' => 'application/json'
8
+
9
+ format :json
10
+
11
+ def request(endpoint: Updox::Models::Auth::PING_ENDPOINT, body: {}, headers: {}, auth: Updox::Models::Auth.new, required_auths: [])
12
+ if body.is_a?(Hash)
13
+ body = auth_data(auth, required_auths).merge(body)
14
+ body = body.to_json
15
+ end
16
+
17
+ self.class.post(endpoint, body: body, headers: headers)
18
+ end
19
+
20
+ private
21
+ def auth_data(auth, required_auths)
22
+ result_auth = auth.dup
23
+
24
+ if required_auths.any?
25
+ result_auth = Updox::Models::Auth.new(
26
+ application_id: Updox.configuration.application_id,
27
+ application_password: Updox.configuration.application_password
28
+ ).merge(result_auth)
29
+ end
30
+
31
+ result_auth = result_auth.keep_if {|k, v| required_auths.include?(k) }
32
+
33
+ result_auth.to_h
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ module Updox
2
+ module Models
3
+ class Auth < Hashie::Trash
4
+ AUTH_NONE = []
5
+ AUTH_APP = [:applicationId, :applicationPassword]
6
+ AUTH_ACCT = AUTH_APP + [:accountId]
7
+ AUTH_FULL = AUTH_ACCT + [:userId]
8
+
9
+ PING_ENDPOINT = '/ping'
10
+ PING_APP_ENDPOINT = '/pingWithApplicationAuth'
11
+ PING_ACCT_ENDPOINT = '/pingWithAccountAuth'
12
+ PING_FULL_ENDPOINT = '/pingWithAuth'
13
+
14
+ property :applicationId, from: :application_id
15
+ property :applicationPassword, from: :application_password
16
+ property :accountId, from: :account_id
17
+ property :userId, from: :user_id
18
+
19
+ def to_h
20
+ { auth: super.to_h }
21
+ end
22
+
23
+ def ping
24
+ UpdoxClient.connection.request(endpoint: PING_ENDPOINT, auth: self)
25
+ end
26
+
27
+ def ping_with_application_auth
28
+ UpdoxClient.connection.request(endpoint: PING_APP_ENDPOINT, auth: self, required_auths: AUTH_APP)
29
+ end
30
+
31
+ def ping_with_account_auth
32
+ UpdoxClient.connection.request(endpoint: PING_ACCT_ENDPOINT, auth: self, required_auths: AUTH_ACCT)
33
+ end
34
+
35
+ def ping_with_full_auth
36
+ UpdoxClient.connection.request(endpoint: PING_FULL_ENDPOINT, auth: self, required_auths: AUTH_FULL)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,38 @@
1
+ module Updox
2
+ module Models
3
+ class Practice < Hashie::Trash
4
+ CREATE_ENDPOINT = '/practiceCreate'.freeze
5
+
6
+ include Hashie::Extensions::IndifferentAccess
7
+
8
+ property :name, required: true
9
+ property :active, default: false
10
+ property :accountId, from: :account_id, with: ->(v) { v.to_s }
11
+ property :address1
12
+ property :address2
13
+ property :city
14
+ property :state
15
+ property :postal
16
+ property :phone
17
+ property :fax
18
+ property :websiteAddress, from: :website_address
19
+ property :timeZone, from: :time_zone
20
+ property :directDomain, from: :direct_domain
21
+ property :directAddress, from: :direct_address
22
+ property :protocol
23
+ property :ipAddress, from: :ip_address
24
+ property :port
25
+ property :path
26
+ property :metadata
27
+ property :practiceSpecialtyCode, from: :practice_specialty_code
28
+ property :practiceNpi, from: :practice_npi
29
+ property :defaultConsentMethods
30
+
31
+ alias_method :account_id, :accountId
32
+
33
+ def create
34
+ UpdoxClient.connection.request(endpoint: CREATE_ENDPOINT, body: self.to_h)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ module Updox
2
+ class UpdoxException < Exception
3
+ def self.from_response(response, msg: nil)
4
+ exception_msg = "Failed #{msg}:"
5
+ exception_msg << " HTTP code: #{response.code} MSG: "
6
+
7
+ begin
8
+ error_response = JSON.parse(response.body)
9
+
10
+ #if (error_response.is_a?(Hash) && error_response.include?("Meta") && error_response["Meta"].include?("Errors"))
11
+ #exception_msg << error_response["Meta"]["Errors"]
12
+ #else
13
+ exception_msg << error_response
14
+ #end
15
+ rescue JSON::ParserError
16
+ exception_msg << response.body
17
+ end
18
+
19
+ return UpdoxException.new(exception_msg)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Updox
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'updox/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'updox'
7
+ spec.version = Updox::VERSION
8
+ spec.authors = ['Mike Crockett']
9
+ spec.email = ['mike.crockett@weinfuse.com']
10
+
11
+ spec.summary = 'Ruby wrapper for the Updox API'
12
+ spec.homepage = 'https://github.com/WeInfuse/updox'
13
+
14
+ # Prevent pushing this gem to RubyGems.org.
15
+ if spec.respond_to?(:metadata)
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+ else
18
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
19
+ 'public gem pushes.'
20
+ end
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match?(%r{^(test|spec|features|bin|helpers|)/}) || f.match?(%r{^(\.[[:alnum:]]+)})
24
+ end
25
+
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+ spec.licenses = ['MIT']
30
+
31
+ spec.add_dependency 'httparty', '~> 0.17'
32
+ spec.add_dependency 'hashie', '~> 3.5'
33
+ spec.add_development_dependency 'bundler', '>=1', '<3'
34
+ spec.add_development_dependency 'byebug', '~> 11'
35
+ spec.add_development_dependency 'minitest', '~> 5.0'
36
+ spec.add_development_dependency 'rake', '~> 10.0'
37
+ spec.add_development_dependency 'webmock', '~> 3.1'
38
+ spec.add_development_dependency 'yard', '~> 0.9'
39
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: updox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Crockett
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.17'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '3'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '1'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: byebug
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '11'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '11'
75
+ - !ruby/object:Gem::Dependency
76
+ name: minitest
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '5.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '5.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '10.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '10.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: webmock
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.1'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.1'
117
+ - !ruby/object:Gem::Dependency
118
+ name: yard
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '0.9'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '0.9'
131
+ description:
132
+ email:
133
+ - mike.crockett@weinfuse.com
134
+ executables: []
135
+ extensions: []
136
+ extra_rdoc_files: []
137
+ files:
138
+ - CHANGELOG.md
139
+ - CODE_OF_CONDUCT.md
140
+ - Gemfile
141
+ - README.md
142
+ - Rakefile
143
+ - lib/updox.rb
144
+ - lib/updox/connection.rb
145
+ - lib/updox/models/auth.rb
146
+ - lib/updox/models/practice.rb
147
+ - lib/updox/updox_exception.rb
148
+ - lib/updox/version.rb
149
+ - updox.gemspec
150
+ homepage: https://github.com/WeInfuse/updox
151
+ licenses:
152
+ - MIT
153
+ metadata:
154
+ allowed_push_host: https://rubygems.org
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.7.6
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Ruby wrapper for the Updox API
175
+ test_files: []