allscripts_api 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d2ee397a4c9ecf45e7a20fa6a3cd5e7cad43c77
4
- data.tar.gz: 80b8b4c04c0fe2c585c0fa5b7a935a71d36a4826
3
+ metadata.gz: 315aedfaf84044bf6676dba411e2c73f5693aa0e
4
+ data.tar.gz: 4d37e4ebba1d080edb9766e80dbb672dae232fd8
5
5
  SHA512:
6
- metadata.gz: 80dda6414b9382877ea4abce74f14505d04b901253282df42939ff59c1c4898977434ae009ce85a05168cd7a79dc190397ab8044fc2904e6c2cd1e37e0538729
7
- data.tar.gz: fae98f28f8f2d1da1e59fb908f5ccff36d4b7f90b69175ff948431cf983abdd861bc71d882a3fc2971376b71f9e782358283ed05af71c60b78d20eef0c358371
6
+ metadata.gz: 1215aeb29079a1a44e68c07762cb52f2e3132e0d57666574d30a43a49f04dd015c2833157eecfda9e9f964cfc06125b6b82ffd4cf55e7cfcc45c300734db3bae
7
+ data.tar.gz: 2a12b36abd1eca7dddef706a0fdd96726c4500c4ee55af2e166a43aadfc3e3e0f4e650ac576dbbb359a74f759b5520ce1ae2622677c19c2e8fb78709251bc826
data/.pryrc CHANGED
@@ -1,5 +1,8 @@
1
1
  require "allscripts_api"
2
2
  require "yaml"
3
+ require "awesome_print"
4
+ AwesomePrint.pry!
5
+ AwesomePrint.defaults = { raw: true }
3
6
 
4
7
  begin
5
8
  loaded = ENV["app_name"] && ENV["app_password"] && ENV["unity_url"] && ENV["app_username"]
data/.rubocop.yml CHANGED
@@ -17,6 +17,12 @@ Style/AccessorMethodName:
17
17
  # Bumbing the max from 10 to 15 allows magic params to work nicely
18
18
  Metrics/MethodLength:
19
19
  Max: 15
20
+ Exclude:
21
+ - "lib/allscripts_api/order.rb"
20
22
  # Bumbing the max from 5 to 7 allows magic params to work nicely
21
23
  Metrics/ParameterLists:
22
- Max: 7
24
+ Max: 7
25
+
26
+ Metrics/AbcSize:
27
+ Exclude:
28
+ - "lib/allscripts_api/order.rb"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- allscripts_api (0.3.0)
4
+ allscripts_api (0.4.0)
5
5
  faraday (>= 0.12.2)
6
6
 
7
7
  GEM
@@ -10,6 +10,9 @@ GEM
10
10
  addressable (2.5.2)
11
11
  public_suffix (>= 2.0.2, < 4.0)
12
12
  ast (2.3.0)
13
+ awesome_print (1.7.0)
14
+ binding_of_caller (0.7.2)
15
+ debug_inspector (>= 0.0.1)
13
16
  coderay (1.1.2)
14
17
  coveralls (0.8.21)
15
18
  json (>= 1.8, < 3)
@@ -19,6 +22,7 @@ GEM
19
22
  tins (~> 1.6)
20
23
  crack (0.4.3)
21
24
  safe_yaml (~> 1.0.0)
25
+ debug_inspector (0.0.2)
22
26
  diff-lcs (1.3)
23
27
  docile (1.1.5)
24
28
  faraday (0.14.0)
@@ -29,6 +33,7 @@ GEM
29
33
  hashdiff (0.3.7)
30
34
  httparty (0.14.0)
31
35
  multi_xml (>= 0.5.2)
36
+ interception (0.5)
32
37
  json (2.1.0)
33
38
  method_source (0.9.0)
34
39
  mini_portile2 (2.3.0)
@@ -55,6 +60,15 @@ GEM
55
60
  pry (0.11.3)
56
61
  coderay (~> 1.1.0)
57
62
  method_source (~> 0.9.0)
63
+ pry-doc (0.13.4)
64
+ pry (~> 0.11)
65
+ yard (~> 0.9.11)
66
+ pry-rescue (1.4.4)
67
+ interception (>= 0.5)
68
+ pry
69
+ pry-stack_explorer (0.4.9.2)
70
+ binding_of_caller (>= 0.7)
71
+ pry (>= 0.9.11)
58
72
  public_suffix (3.0.2)
59
73
  rainbow (2.2.2)
60
74
  rake
@@ -108,12 +122,16 @@ PLATFORMS
108
122
 
109
123
  DEPENDENCIES
110
124
  allscripts_api!
125
+ awesome_print
111
126
  bundler (~> 1.16)
112
127
  coveralls
113
128
  nokogiri
114
129
  pronto
115
130
  pronto-rubocop
116
131
  pry
132
+ pry-doc
133
+ pry-rescue
134
+ pry-stack_explorer
117
135
  rake (~> 10.0)
118
136
  rspec (~> 3.0)
119
137
  webmock (~> 3.3)
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # AllscriptsApi, an Allscripts Unity Client
2
-
2
+ [![Gem Version](https://badge.fury.io/rb/allscripts_api.svg)](https://badge.fury.io/rb/allscripts_api)
3
3
  [![Coverage Status](https://coveralls.io/repos/github/Avhana/allscripts_api/badge.svg?branch=master)](https://coveralls.io/github/Avhana/allscripts_api?branch=master)
4
4
  [![Build Status](https://travis-ci.org/Avhana/allscripts_api.svg?branch=master)](https://travis-ci.org/Avhana/allscripts_api)
5
5
  [![Inline docs](http://inch-ci.org/github/Avhana/allscripts_api.svg?branch=master&style=shields)](http://inch-ci.org/github/Avhana/allscripts_api)
@@ -23,12 +23,16 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "faraday", ">= 0.12.2"
26
+ spec.add_development_dependency "awesome_print"
26
27
  spec.add_development_dependency "bundler", "~> 1.16"
27
28
  spec.add_development_dependency "coveralls"
28
29
  spec.add_development_dependency "nokogiri"
29
30
  spec.add_development_dependency "pronto"
30
31
  spec.add_development_dependency "pronto-rubocop"
31
32
  spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "pry-doc"
34
+ spec.add_development_dependency "pry-rescue"
35
+ spec.add_development_dependency "pry-stack_explorer"
32
36
  spec.add_development_dependency "rake", "~> 10.0"
33
37
  spec.add_development_dependency "rspec", "~> 3.0"
34
38
  spec.add_development_dependency "yard", "~> 0.9"
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require "nokogiri"
3
3
  require "allscripts_api/configuration"
4
4
  require "allscripts_api/magic_params"
5
5
  require "allscripts_api/named_magic_methods"
6
+ require "allscripts_api/ordering_methods"
7
+ require "allscripts_api/order"
6
8
  require "allscripts_api/client"
7
9
  require "allscripts_api/version"
8
10
 
@@ -36,7 +38,7 @@ module AllscriptsApi
36
38
  class << self
37
39
  attr_accessor :configuration
38
40
  # a method that allows a configuration block to be passed
39
- # to {AllscriptsApi::Configuration#new}
41
+ # to AllscriptsApi::Configuration#new
40
42
  # @see AllscriptsApi::Configuration
41
43
  def configure
42
44
  self.configuration ||= AllscriptsApi::Configuration.new
@@ -6,6 +6,7 @@ module AllscriptsApi
6
6
  # Client serves as an entry point for making calls
7
7
  class Client
8
8
  include AllscriptsApi::NamedMagicMethods
9
+ include AllscriptsApi::OrderingMethods
9
10
  attr_reader :adapter, :unity_url, :app_name, :token
10
11
  attr_writer :sso_token
11
12
 
@@ -86,7 +87,6 @@ module AllscriptsApi
86
87
  req.url(full_path)
87
88
  req.body = body
88
89
  end
89
-
90
90
  read_magic_response(response)
91
91
  end
92
92
 
@@ -104,6 +104,27 @@ module AllscriptsApi
104
104
  results["getpatientinfo"]
105
105
  end
106
106
 
107
+ # gets patient's demographic info, insurance, guarantor, and PCP info
108
+ # Note that this method is litely to return blank data sets
109
+ # for invalid IDs rather than raising an error
110
+ #
111
+ # @param patient_id [String] patient id
112
+ # @param mrn [String|nil] medical record number, if patient id is unknown
113
+ # @parma order_id [String|nil] optionally used to get info for a secific
114
+ # patient order
115
+ # @return [String, AllscriptsApi::MagicError] patient demographics
116
+ def get_patient_full(patient_id, mrn = nil, order_id = nil)
117
+ params =
118
+ MagicParams.format(
119
+ user_id: @allscripts_username,
120
+ patient_id: patient_id,
121
+ parameter1: mrn,
122
+ parameter2: order_id
123
+ )
124
+ results = magic("GetPatientFull", magic_params: params)
125
+ results["getpatientfullinfo"]
126
+ end
127
+
107
128
  # a wrapper around GetPatientProblems
108
129
  #
109
130
  # @param patient_id [String] patient id
@@ -150,6 +171,24 @@ module AllscriptsApi
150
171
  results["getscheduleinfo"]
151
172
  end
152
173
 
174
+ def get_encounter_list(patient_id = "", encounter_type = "",
175
+ when_or_limit = "", nostradamus = 0,
176
+ show_past_flag = "Y",
177
+ billing_provider_user_name = "")
178
+ params =
179
+ MagicParams.format(
180
+ user_id: @allscripts_username,
181
+ patient_id: patient_id,
182
+ parameter1: encounter_type, # from Encounter_Type_DE
183
+ parameter2: when_or_limit,
184
+ parameter3: nostradamus,
185
+ parameter4: show_past_flag,
186
+ parameter5: billing_provider_user_name,
187
+ )
188
+ results = magic("GetEncounterList", magic_params: params)
189
+ results["getencounterlistinfo"]
190
+ end
191
+
153
192
  # a wrapper around GetListOfDictionaries, which returns
154
193
  # list of all dictionaries
155
194
  #
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AllscriptsApi
4
+ # A value object wrapped around a `Nokogiri::XML::Builder` DSL that builds
5
+ # properly formatted XML for `AllscriptsApi::OrderingMEthods.save_order`
6
+ class Order
7
+ # Builder method for returning XML
8
+ #
9
+ # @param site_id [String] the id for the Allscripts install site
10
+ # @param emr_user_id [String] the provider's Allscripts id
11
+ # @param order_date [DateTime] a date for the order (Typically today)
12
+ # @param encounter_id [String|Nil] an encounter id, used when
13
+ # ordering to current encounter
14
+ # @return [String] xml formatted for
15
+ # {AllscriptsApi::OrderingMethods#save_order}
16
+ def self.build_xml(site_id, emr_user_id, order_date, encounter_id = "")
17
+ date = order_date.strftime("%d-%b-%Y")
18
+ builder = Nokogiri::XML::Builder.new
19
+ builder.saveorderxml do
20
+ # a value of 'Y' makes the order visible on the order list
21
+ builder.field("id" => "ordershowonorderlist", "value" => "Y")
22
+ builder.field("id" => "orderlocation", "value" => site_id)
23
+ builder.field("id" => "ordertobedone", "value" => date)
24
+ # default, not important, required
25
+ builder.field("id" => "orderpriority", "value" => "2")
26
+ builder.field("id" => "orderschedulefreetext", "value" => "")
27
+ builder.field("id" => "orderschedulerecurring", "value" => "")
28
+ builder.field("id" => "orderschedulerecurringperiod", "value" => "")
29
+ builder.field("id" => "orderschedulestarting", "value" => date)
30
+ builder.field("id" => "orderscheduleending", "value" => date)
31
+ builder.field("id" => "orderscheduleendingafter", "value" => "")
32
+ builder.field("id" => "orderperformingcomment", "value" => "")
33
+ builder.field("id" => "ordercommunicatedby", "value" => 11) # hard coded
34
+ builder.field("id" => "orderorderedby", "value" => emr_user_id)
35
+ builder.field("id" => "ordermanagedby", "value" => emr_user_id)
36
+ builder.field("id" => "ordersupervisedby", "value" => "")
37
+ builder.field("id" => "orderciteresult", "value" => "")
38
+ builder.field("id" => "orderannotation", "value" => "")
39
+ builder.field("id" => "orderstatus", "value" => "Active")
40
+ builder.field("id" => "orderstatusdate", "value" => date)
41
+ builder.field("id" => "orderdeferralinterval", "value" => 0)
42
+ builder.field("id" => "orderdeferralunit", "value" => "Days")
43
+ builder.field("id" => "orderstatusreason", "value" => "")
44
+ builder.field("id" => "encounter", "value" => encounter_id.to_s)
45
+ builder.orderlinkedproblems
46
+ builder.clinicalquestions
47
+ end
48
+
49
+ builder.to_xml
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AllscriptsApi
4
+ # A collection convenience methods for ordering that map
5
+ # to Allscripts magic actions. Some of these methods
6
+ # wrap multiple actions. These methods are included
7
+ # in {AllscriptsApi::Client} and can be accessed from
8
+ # instances of that class.
9
+ module OrderingMethods
10
+ # a wrapper around SaveOrder, which save and order of the
11
+ # sepcified category, among: AdministeredMedication,
12
+ # Immunization, InstructionOrder, ProcedureOrder,
13
+ # Referral, SuppliesOrder.
14
+ #
15
+ # xml can be constructed with {AllscriptsApi::Order.build_xml}
16
+ #
17
+ # @param patient_id [String]
18
+ # @param xml [String] xml containing saveorderxml fields and values
19
+ # @param order_category [String] one of AdministeredMedication,
20
+ # Immunization, InstructionOrder, ProcedureOrder,
21
+ # Referral, SuppliesOrder.
22
+ # @param dictionary_id [String] id of the dictionary from SearchOrder TODO: look into how to doc this better
23
+ # @param problem_id [String|Nil] problem to associate with the order,
24
+ # may be passed in as part of the xml
25
+ # @param trans_id [String|Nil] the original OrderID,
26
+ # necessary when updating a past order
27
+ # @return [Hash|MagicError] order confirmation or error
28
+ def save_order(patient_id, xml, order_category, dictionary_id,
29
+ problem_id = nil, trans_id = nil)
30
+ params = MagicParams.format(
31
+ user_id: @allscripts_username,
32
+ patient_id: patient_id,
33
+ parameter1: xml,
34
+ parameter2: order_category,
35
+ parameter3: dictionary_id,
36
+ parameter4: problem_id,
37
+ parameter5: trans_id
38
+ )
39
+ magic("SaveOrder", magic_params: params)
40
+ end
41
+ end
42
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module AllscriptsApi
4
4
  # gem version declaration
5
- VERSION = "0.3.0".freeze
5
+ VERSION = "0.4.0".freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allscripts_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chase
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.12.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,48 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-doc
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-rescue
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry-stack_explorer
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
111
167
  - !ruby/object:Gem::Dependency
112
168
  name: rake
113
169
  requirement: !ruby/object:Gem::Requirement
@@ -193,6 +249,8 @@ files:
193
249
  - lib/allscripts_api/configuration.rb
194
250
  - lib/allscripts_api/magic_params.rb
195
251
  - lib/allscripts_api/named_magic_methods.rb
252
+ - lib/allscripts_api/order.rb
253
+ - lib/allscripts_api/ordering_methods.rb
196
254
  - lib/allscripts_api/version.rb
197
255
  homepage: https://github.com/Avhana/allscripts_api
198
256
  licenses: []
@@ -213,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
271
  version: '0'
214
272
  requirements: []
215
273
  rubyforge_project:
216
- rubygems_version: 2.6.13
274
+ rubygems_version: 2.6.14
217
275
  signing_key:
218
276
  specification_version: 4
219
277
  summary: A simple, configurable wrapper around Allscripts APIs