allscripts_unity_client 3.2.2 → 3.3.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: 93d6a293357813026811d3ac5218a18f6670891f
4
- data.tar.gz: 31e812dd2336a1365a453b5156e8caeed5f8f508
3
+ metadata.gz: 318d72c20fb76dddb339df2816c74e13ff94e212
4
+ data.tar.gz: cf380ce84440281cb5474214fea46b24b43705f8
5
5
  SHA512:
6
- metadata.gz: 106616676750288be5c91e4ca7a8c45137e8b05d63601a7bc4274bc474afde5e624c4a55f08134a519f0a0e0423cec299955c981f249bad74a3cd0f18dc0b30f
7
- data.tar.gz: 016876031b97295407002e4fb1a61e78dec615855c944cd0f8433eb4c847923b165835cb45dee4509308a968b3820e823ef8525086d849ce2ef58f25c07231eb
6
+ metadata.gz: 296d617eead2d1cc0e638ae8ea4247bf6f4c4d0bb033ebc4c551dff6d84f8040d118f7990bbf26686c2c4b41c367a1efd9aafe2f5f3a822b31a98ec656a1fe59
7
+ data.tar.gz: 630a7653aaf3f9d99ba477bdf275e31581a177ed6995bdd90fa6388f556a20911a4a21ecfb9f1002fef88ae0163461ceb0895d3a611eba7ae314db1db9dae382
@@ -147,7 +147,7 @@ module AllscriptsUnityClient
147
147
  action: 'GetClinicalSummary',
148
148
  userid: userid,
149
149
  patientid: patientid,
150
- parameter3: extra_med_data ? 'Y' : nil
150
+ parameter3: unity_true_or_blank_parameter(extra_med_data)
151
151
  }
152
152
  response = magic(magic_parameters)
153
153
 
@@ -246,7 +246,7 @@ module AllscriptsUnityClient
246
246
  parameter1: encounter_type,
247
247
  parameter2: when_param,
248
248
  parameter3: nostradamus,
249
- parameter4: show_past_flag && show_past_flag != 'N' ? 'Y' : 'N',
249
+ parameter4: unity_boolean_parameter(show_past_flag),
250
250
  parameter5: billing_provider_user_name,
251
251
  # According to the developer guide this parameter is no longer
252
252
  # used.
@@ -393,8 +393,21 @@ module AllscriptsUnityClient
393
393
  raise NotImplementedError, 'GetPatientLocations magic action not implemented'
394
394
  end
395
395
 
396
- def get_patient_pharmacies
397
- raise NotImplementedError, 'GetPatientPharmacies magic action not implemented'
396
+ def get_patient_pharmacies(patient_id, limit_to_favorites = false)
397
+ response = magic(
398
+ action: 'GetPatientPharmacies',
399
+ patientid: patient_id,
400
+ parameter1: unity_boolean_parameter(limit_to_favorites)
401
+ )
402
+
403
+ # When the patient has only ever used one pharmacy, Unity does
404
+ # not return a collection of one. Rather, it returns the sole
405
+ # pharmacy as a Hash.
406
+ if response.is_a?(Array)
407
+ response
408
+ else
409
+ [response]
410
+ end
398
411
  end
399
412
 
400
413
  def get_patient_problems(patientid, show_by_encounter_flag = nil, assessed = nil, encounter_id = nil, medcin_id = nil)
@@ -818,6 +831,23 @@ module AllscriptsUnityClient
818
831
 
819
832
  private
820
833
 
834
+ # Truthy values, with the exception to the string "N", will be
835
+ # converted to the string "Y". Falsy values and the string "N"
836
+ # will be converted to the string "N".
837
+ def unity_boolean_parameter(native_value)
838
+ if native_value && native_value != 'N'
839
+ 'Y'
840
+ else
841
+ 'N'
842
+ end
843
+ end
844
+
845
+ # Truthy values will converted to the string "Y". Falsy values
846
+ # will be converted to nil.
847
+ def unity_true_or_blank_parameter(native_value)
848
+ native_value ? 'Y' : nil
849
+ end
850
+
821
851
  def nokogiri_to_string(builder)
822
852
  builder.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
823
853
  end
@@ -1,3 +1,3 @@
1
1
  module AllscriptsUnityClient
2
- VERSION = '3.2.2'
2
+ VERSION = '3.3.0'
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -184,7 +184,67 @@ describe AllscriptsUnityClient::Client do
184
184
  end
185
185
 
186
186
  describe '#get_patient_pharmacies' do
187
- it { expect { subject.get_patient_pharmacies }.to raise_error(NotImplementedError) }
187
+ let(:patient_pharmacy) do
188
+ {
189
+ :phone => "(608) 555-5555",
190
+ :supports_epcs => "N",
191
+ :city => "MADISON",
192
+ :pharm_id => "1234",
193
+ :address2 => " ",
194
+ :fax => "(608) 555-5556",
195
+ :description => "1234 STATE ST, MADISON, WI 537061234, \nPh: 608-555-5555",
196
+ :type => "R",
197
+ :state => "WI",
198
+ :zip => "537041234 ",
199
+ :name => "WALGREENS-1234 STATE ST",
200
+ :address1 => "1234 STATE ST"
201
+ }
202
+ end
203
+
204
+ let(:patient_id) { '1234' }
205
+
206
+ let(:driver) { double('Driver') }
207
+ let(:client) { AllscriptsUnityClient::Client.new(driver) }
208
+
209
+ it 'returns an Array when Unity returns a Hash' do
210
+ allow(driver).
211
+ to receive(:magic).
212
+ with(action: 'GetPatientPharmacies',
213
+ patientid: patient_id,
214
+ parameter1: 'N') { patient_pharmacy }
215
+
216
+ expect(client.get_patient_pharmacies(patient_id)).to eq([patient_pharmacy])
217
+ end
218
+
219
+ it 'preserves Arrays returned by Unity' do
220
+ allow(driver).
221
+ to receive(:magic).
222
+ with(action: 'GetPatientPharmacies',
223
+ patientid: patient_id,
224
+ parameter1: 'N') { [patient_pharmacy] }
225
+
226
+ expect(client.get_patient_pharmacies(patient_id)).to eq([patient_pharmacy])
227
+ end
228
+
229
+ it 'coerces truthy values in the second parameter to Unity true' do
230
+ expect(driver).
231
+ to receive(:magic).
232
+ with(action: 'GetPatientPharmacies',
233
+ patientid: patient_id,
234
+ parameter1: 'Y')
235
+
236
+ client.get_patient_pharmacies(patient_id, true)
237
+ end
238
+
239
+ it 'preserves Unity false values in the second parameter' do
240
+ expect(driver).
241
+ to receive(:magic).
242
+ with(action: 'GetPatientPharmacies',
243
+ patientid: patient_id,
244
+ parameter1: 'N')
245
+
246
+ client.get_patient_pharmacies(patient_id, 'N')
247
+ end
188
248
  end
189
249
 
190
250
  describe '#get_patient_problems'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allscripts_unity_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - healthfinch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -288,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  version: '0'
289
289
  requirements: []
290
290
  rubyforge_project:
291
- rubygems_version: 2.2.2
291
+ rubygems_version: 2.4.6
292
292
  signing_key:
293
293
  specification_version: 4
294
294
  summary: Allscripts Unity API client