mirah-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +93 -0
- data/.gitignore +14 -0
- data/.overcommit.yml +48 -0
- data/.overcommit_gems.rb +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +54 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +187 -0
- data/Rakefile +24 -0
- data/bin/autocorrect +28 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/setup_overcommit +12 -0
- data/lib/mirah.rb +44 -0
- data/lib/mirah/base_input_object.rb +65 -0
- data/lib/mirah/base_object.rb +98 -0
- data/lib/mirah/client.rb +420 -0
- data/lib/mirah/collection.rb +98 -0
- data/lib/mirah/data/appointment.rb +65 -0
- data/lib/mirah/data/organization.rb +31 -0
- data/lib/mirah/data/page_info.rb +40 -0
- data/lib/mirah/data/patient.rb +46 -0
- data/lib/mirah/data/practitioner.rb +53 -0
- data/lib/mirah/errors.rb +39 -0
- data/lib/mirah/filters.rb +7 -0
- data/lib/mirah/filters/appointment_filters.rb +16 -0
- data/lib/mirah/filters/organization_filters.rb +16 -0
- data/lib/mirah/filters/paging.rb +33 -0
- data/lib/mirah/filters/patient_filters.rb +16 -0
- data/lib/mirah/filters/practitioner_filters.rb +16 -0
- data/lib/mirah/graphql.rb +33 -0
- data/lib/mirah/graphql/fragments.rb +97 -0
- data/lib/mirah/graphql/mutations.rb +72 -0
- data/lib/mirah/graphql/queries.rb +196 -0
- data/lib/mirah/inputs.rb +7 -0
- data/lib/mirah/inputs/appointment_input.rb +40 -0
- data/lib/mirah/inputs/organization_input.rb +20 -0
- data/lib/mirah/inputs/patient_input.rb +40 -0
- data/lib/mirah/inputs/practitioner_input.rb +44 -0
- data/lib/mirah/push_result.rb +40 -0
- data/lib/mirah/serializers.rb +57 -0
- data/lib/mirah/version.rb +5 -0
- data/mirah-ruby.gemspec +41 -0
- data/schema.json +8936 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b06a0f1fe231e4a3f490563bcaed279296715cf4e4b97647f9fd3810b769d66f
|
4
|
+
data.tar.gz: 0e182f930e9b7478aa8e020dda8eace77c5cf40e7dcd7ca93df1ab5a75f5ad67
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23e8b43f19e52ee63413a5988c1185013e80eeb869ad83ee514cd4baa666847a5cf6b8ab9813b0207d91f329bb8dae44053a247f1998279fb4df840de31667cd
|
7
|
+
data.tar.gz: 90acff70c6cb89897c4b86483bb44b118ae019fcefd57a94a83e866b4972459fc96bd8d9a7b6d362b4590e6bb0532a820c033bf8f421f41c17459085ee663a41
|
@@ -0,0 +1,93 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test24:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.4.6-stretch-node
|
9
|
+
executor: ruby/default
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: Configure Bundler
|
14
|
+
command: |
|
15
|
+
echo 'export BUNDLER_VERSION=1.16.6' >> $BASH_ENV
|
16
|
+
source $BASH_ENV
|
17
|
+
gem install bundler
|
18
|
+
- run:
|
19
|
+
name: Which bundler?
|
20
|
+
command: bundle -v
|
21
|
+
- ruby/bundle-install
|
22
|
+
- run:
|
23
|
+
name: Tests
|
24
|
+
command: bundle exec rake spec
|
25
|
+
test25:
|
26
|
+
docker:
|
27
|
+
- image: circleci/ruby:2.5-stretch-node
|
28
|
+
executor: ruby/default
|
29
|
+
steps:
|
30
|
+
- checkout
|
31
|
+
- run:
|
32
|
+
name: Configure Bundler
|
33
|
+
command: |
|
34
|
+
echo 'export BUNDLER_VERSION=1.16.6' >> $BASH_ENV
|
35
|
+
source $BASH_ENV
|
36
|
+
gem install bundler
|
37
|
+
- run:
|
38
|
+
name: Which bundler?
|
39
|
+
command: bundle -v
|
40
|
+
- ruby/bundle-install
|
41
|
+
- run:
|
42
|
+
name: Tests
|
43
|
+
command: bundle exec rake spec
|
44
|
+
test26:
|
45
|
+
docker:
|
46
|
+
- image: circleci/ruby:2.6-stretch-node
|
47
|
+
executor: ruby/default
|
48
|
+
steps:
|
49
|
+
- checkout
|
50
|
+
- run:
|
51
|
+
name: Configure Bundler
|
52
|
+
command: |
|
53
|
+
echo 'export BUNDLER_VERSION=2.1.4' >> $BASH_ENV
|
54
|
+
source $BASH_ENV
|
55
|
+
gem install bundler
|
56
|
+
- run:
|
57
|
+
name: Which bundler?
|
58
|
+
command: bundle -v
|
59
|
+
- ruby/bundle-install
|
60
|
+
- run:
|
61
|
+
name: Tests
|
62
|
+
command: bundle exec rake spec
|
63
|
+
test27:
|
64
|
+
docker:
|
65
|
+
- image: circleci/ruby:2.7-node
|
66
|
+
executor: ruby/default
|
67
|
+
steps:
|
68
|
+
- checkout
|
69
|
+
- run:
|
70
|
+
name: Configure Bundler
|
71
|
+
command: |
|
72
|
+
echo 'export BUNDLER_VERSION=2.1.4' >> $BASH_ENV
|
73
|
+
source $BASH_ENV
|
74
|
+
gem install bundler
|
75
|
+
- run:
|
76
|
+
name: Which bundler?
|
77
|
+
command: bundle -v
|
78
|
+
- ruby/bundle-install
|
79
|
+
- run:
|
80
|
+
name: Tests
|
81
|
+
command: bundle exec rake spec
|
82
|
+
|
83
|
+
|
84
|
+
workflows:
|
85
|
+
version: 2
|
86
|
+
test:
|
87
|
+
jobs:
|
88
|
+
- test24
|
89
|
+
- test25
|
90
|
+
- test26
|
91
|
+
- test27
|
92
|
+
|
93
|
+
|
data/.gitignore
ADDED
data/.overcommit.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/brigade/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/brigade/overcommit#configuration
|
15
|
+
#
|
16
|
+
# Uncomment the following lines to make the configuration take effect.
|
17
|
+
gemfile: .overcommit_gems.rb
|
18
|
+
|
19
|
+
PreCommit:
|
20
|
+
Brakeman:
|
21
|
+
enabled: true
|
22
|
+
BundleAudit:
|
23
|
+
enabled: true
|
24
|
+
FixMe:
|
25
|
+
enabled: true
|
26
|
+
on_fail: warn
|
27
|
+
# TODO: enable
|
28
|
+
# ForbiddenBranches:
|
29
|
+
# enabled: true
|
30
|
+
# branch_patterns: ['master', 'qa']
|
31
|
+
HardTabs:
|
32
|
+
enabled: true
|
33
|
+
exclude: ['spec/fixtures/**/*', 'Makefile']
|
34
|
+
RuboCop:
|
35
|
+
enabled: true
|
36
|
+
command: ['rubocop']
|
37
|
+
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names', '--config=.rubocop.yml']
|
38
|
+
|
39
|
+
# TODO: enable
|
40
|
+
# PrePush:
|
41
|
+
# ForbiddenBranches:
|
42
|
+
# enabled: true
|
43
|
+
# branch_patterns: ['master', 'qa']
|
44
|
+
|
45
|
+
# PreRebase:
|
46
|
+
# MergedCommits:
|
47
|
+
# enabled: true
|
48
|
+
# branches: ['master', 'qa']
|
data/.overcommit_gems.rb
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
DefaultFormatter: progress
|
6
|
+
DisplayCopNames: true
|
7
|
+
DisplayStyleGuide: true
|
8
|
+
Exclude:
|
9
|
+
- 'bin/*'
|
10
|
+
- '*.md'
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 120
|
14
|
+
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Max: 20
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 15
|
20
|
+
|
21
|
+
Metrics/BlockLength:
|
22
|
+
Exclude:
|
23
|
+
- 'spec/**/*'
|
24
|
+
- 'mirah-ruby.gemspec'
|
25
|
+
|
26
|
+
Naming/MethodParameterName:
|
27
|
+
AllowedNames:
|
28
|
+
- io
|
29
|
+
- id
|
30
|
+
- to
|
31
|
+
- by
|
32
|
+
- 'on'
|
33
|
+
- in
|
34
|
+
- at
|
35
|
+
- ip
|
36
|
+
- db
|
37
|
+
- tz
|
38
|
+
- el
|
39
|
+
- e
|
40
|
+
|
41
|
+
RSpec/ExampleLength:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
RSpec/LetSetup:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
RSpec/NestedGroups:
|
48
|
+
Max: 7
|
49
|
+
|
50
|
+
RSpec/MessageSpies:
|
51
|
+
EnforcedStyle: receive
|
52
|
+
|
53
|
+
RSpec/MultipleExpectations:
|
54
|
+
Enabled: false
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
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
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
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 ben@benjones.io. 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://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Ben Jones
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# Mirah Ruby Integration Library
|
2
|
+
|
3
|
+
This gem provides convenience methods to allow EHRs and other systems of record to access and update a variety of Mirah endpoints. It is intended for use in the following circumstances
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This gem is intended for use for existing Mirah customers only. To get started, ask your account representative for a technical contact, who will provide you with the following for both staging and production:
|
8
|
+
|
9
|
+
- An `API_USER_ID` which is your unique user. This is provided at the system level and does not correspond to an individual.
|
10
|
+
- An `API_KEY` as a secret key.
|
11
|
+
- An `API_HOST` which is the URL of the API.
|
12
|
+
|
13
|
+
There are different endpoints for production and staging. They will be configured below as part of installation.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'mirah-ruby'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle install
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install mirah-ruby
|
30
|
+
|
31
|
+
Configure your environments so that you use the correct credentials for each environment. For example, in rails you can edit `db/secrets.yml`:
|
32
|
+
|
33
|
+
production:
|
34
|
+
mirah_api_host: <%= ENV["MIRAH_API_HOST"] %>
|
35
|
+
mirah_api_user_id: <%= ENV["MIRAH_API_USER_ID"] %>
|
36
|
+
mirah_api_token: <%= ENV["MIRAH_API_KEY"] %>
|
37
|
+
|
38
|
+
Finally, ensure `MIRAH_API_HOST`, `MIRAH_API_USER_ID` and `MIRAH_API_KEY` are present in environment variables to be used.
|
39
|
+
|
40
|
+
## Supported Ruby Versions
|
41
|
+
|
42
|
+
This library supports the following Ruby implementations:
|
43
|
+
|
44
|
+
* Ruby 2.4
|
45
|
+
* Ruby 2.5
|
46
|
+
* Ruby 2.6
|
47
|
+
* Ruby 2.7
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
To begin, let's instantiate our client:
|
52
|
+
|
53
|
+
# Or otherwise provided by your secrets. Do not store these credentials in source code.
|
54
|
+
host = Rails.application.secrets.mirah_api_host
|
55
|
+
user_id = Rails.application.secrets.mirah_api_user_id
|
56
|
+
token = Rails.application.secrets.mirah_api_key
|
57
|
+
client = Mirah::Client.new(host: host, user_id: user_id, access_token: token) # => #<Mirah::Client:0x00007fdf9d698d70....>
|
58
|
+
|
59
|
+
There are three kinds of end points in this library:
|
60
|
+
|
61
|
+
* 'Push' methods for sending new or updated data to Mirah - e.g. 'push_patient'.
|
62
|
+
* 'Find' methods for single items
|
63
|
+
* 'Query' methods for multiple items - e.g. `query_patients`. These can support filters and will paginate.
|
64
|
+
|
65
|
+
Let's start by creating a new patient:
|
66
|
+
|
67
|
+
result = client.push_patient(external_id: 'mrn001', given_name: 'Henry', family_name: 'Jones', birth_date: Date.parse('1983-03-20')) # => #<Mirah::PushResult:... @given_name="Henry", @family_name="Jones", @birth_date=#<Date: 1983-03-20>
|
68
|
+
|
69
|
+
You should get an object with the newly created patient:
|
70
|
+
|
71
|
+
result.status # => "CREATED"
|
72
|
+
result.result # => #<Mirah::Data::Patient ... @given_name="Henry", @family_name="Jones" ... >
|
73
|
+
|
74
|
+
If you send the same message back, you'll notice the status is 'UPDATED'.
|
75
|
+
|
76
|
+
result = client.push_patient(external_id: 'mrn001', given_name: 'Henry', family_name: 'Jones', birth_date: Date.parse('1983-03-20')) # => #<Mirah::PushResult:... @given_name="Henry", @family_name="Jones", @birth_date=#<Date: 1983-03-20>
|
77
|
+
result.status # => "UPDATED"
|
78
|
+
|
79
|
+
You can even do a partial update:
|
80
|
+
|
81
|
+
partial = client.push_patient(external_id: 'mrn001', phone_number: '555-555-5555') # => #<Mirah::PushResult:... @given_name="Henry", @family_name="Jones", @birth_date=#<Date: 1983-03-20>
|
82
|
+
|
83
|
+
Now let's move onto querying.
|
84
|
+
|
85
|
+
patient_collection = client.query_patients # => #<Mirah::Collection:0x00007fc4b8943480 @results=[...] >
|
86
|
+
|
87
|
+
You can read more about each below, but for now, we can examine the first page of the patient results:
|
88
|
+
|
89
|
+
patient_collection.results.length # => 10
|
90
|
+
patient_collection.results.first # => #<Mirah::Data::Patient:0x00007fc4b6aa2850 @id="3046af39-0560-4add-9881-2e004ecdb042", @given_name="Test", @family_name="Patient", @birth_date=#<Date: 1991-01-01)>>
|
91
|
+
|
92
|
+
Let's pluck out the first result's id, and then fetch the data directly:
|
93
|
+
|
94
|
+
patient_id = patient_collection.results.first.id # => "3046af39-0560-4add-9881-2e004ecdb042"
|
95
|
+
patient = client.find_patient(patient_id) # => #<Mirah::Data::Patient ....>
|
96
|
+
|
97
|
+
You may also fetch directly by your own identifier:
|
98
|
+
|
99
|
+
my_patient = client.find_patient_by_external_id('mrn0001') # => #<Mirah::Data::Patient ....>
|
100
|
+
|
101
|
+
If you want to find more than one record at a time, you may do so by specifying a filter as part of a normal patient query:
|
102
|
+
|
103
|
+
matching_patients = client.query_patients(external_ids: ['mrn0001', 'mrn0002']) # => #<Mirah::Collection:0x00007fc4b8943480 @results=[...] >
|
104
|
+
|
105
|
+
To see the full documentation, see documentation for {Mirah::Client}
|
106
|
+
|
107
|
+
|
108
|
+
### Find methods
|
109
|
+
|
110
|
+
- e.g. {Mirah::Client#find_patient}, {Mirah::Client#find_patient_by_external_id}. These are used to get a single record and do not support pagination or filtering. You must know the identifier (either Mirah or your own) of the record in order to access it.
|
111
|
+
|
112
|
+
|
113
|
+
## Use of identifiers
|
114
|
+
|
115
|
+
This API mixes resources where it is likely that users are the system of record (e.g. Patient information), with records where Mirah is the originator (e.g. assessment records). All items in this API contain an `id` field, which corresponds to the Mirah internal identifier.
|
116
|
+
|
117
|
+
Some classes also contain an extra `identifiers` field that describes the rest of the identifiers that Mirah knows about. This includes:
|
118
|
+
|
119
|
+
- An `assigner` which corresponds to which system assigned the identifier. In most circumstances where you are the only system of record, this will be `default`.
|
120
|
+
- A `value` which is the actual record identifier.
|
121
|
+
|
122
|
+
## Error Handling
|
123
|
+
|
124
|
+
All errors raised will be a subclass of {Mirah::Error}. You can rescue from these as follows to maintain safe code:
|
125
|
+
|
126
|
+
begin
|
127
|
+
client.query_patients
|
128
|
+
rescue Mirah::Error => e
|
129
|
+
#
|
130
|
+
end
|
131
|
+
|
132
|
+
The expected kinds of errors will vary on the basis of whether you are using query methods or updating data. Unexpected errors - connectivity, etc, will be raised as a {Mirah::Errors::ClientError}.
|
133
|
+
|
134
|
+
### Query methods
|
135
|
+
|
136
|
+
The most common errors will come from supply invalid data to queries. For example, {Mirah::Filters::AppointmentFilters} allows you to supply a `status` variable which needs to be of the correct type.
|
137
|
+
|
138
|
+
client.query_appointments(status: 'INVALID') # => Mirah::Errors::ServerError: Unknown error from Mirah server: Variable $status of type [AppointmentStatus!] was provided invalid value for 0 (Expected "INVALID" to be one of: PROPOSED, PENDING, BOOKED, ARRIVED, FULFILLED, CANCELED, NOSHOW)
|
139
|
+
|
140
|
+
### Push methods
|
141
|
+
|
142
|
+
Push methods wrap their errors into an error type. You should always inspect the result for success:
|
143
|
+
|
144
|
+
result = client.push_appointment(external_id: 'mynewappointment', status: 'NOTVALIDSTATUS', external_patient_id: 'doesnotexist')
|
145
|
+
if result.status == 'ERROR'
|
146
|
+
result.errors.map { |e| e['message'] } # ["Variable $input of type CreateOrUpdateAppointmentInput! was provided invalid value for status (Expected \"BOOKEDS\" to be one of: PROPOSED, PENDING, BOOKED, ARRIVED, FULFILLED, CANCELED, NOSHOW)"]
|
147
|
+
else
|
148
|
+
# SUCCESS
|
149
|
+
end
|
150
|
+
|
151
|
+
## Development
|
152
|
+
|
153
|
+
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.
|
154
|
+
|
155
|
+
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).
|
156
|
+
|
157
|
+
## Documentation
|
158
|
+
|
159
|
+
To run the documentation server locally:
|
160
|
+
|
161
|
+
bundle exec yard server --reload
|
162
|
+
|
163
|
+
## Testing
|
164
|
+
|
165
|
+
To run the test suite:
|
166
|
+
|
167
|
+
bundle exec rake spec
|
168
|
+
|
169
|
+
We use VCR to supply real API responses during internal testing. To set this up in `mirah_server`, you may run a convenience task to make a specially configured site with exactly the same data:
|
170
|
+
|
171
|
+
bundle exec rake integration:create_gem_institute # in mirah_server
|
172
|
+
|
173
|
+
By default, any requests from the API which cause a request which has not been recorded will cause an error. To enable fetching of real request data, you must supply environment variables:
|
174
|
+
|
175
|
+
VCR_HOST=http://localhost:3000 VCR_USER_ID=ABC VCR_TOKEN=XYZ bundle exec rake spec
|
176
|
+
|
177
|
+
## Contributing
|
178
|
+
|
179
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mirah_tech/mirah-ruby. 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/mirah_tech/mirah-ruby/blob/master/CODE_OF_CONDUCT.md).
|
180
|
+
|
181
|
+
## License
|
182
|
+
|
183
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
184
|
+
|
185
|
+
## Code of Conduct
|
186
|
+
|
187
|
+
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mirah_tech/mirah-ruby/blob/master/CODE_OF_CONDUCT.md).
|