medivo 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/medivo.rb CHANGED
@@ -10,5 +10,5 @@ require 'geocoder'
10
10
  Geocoder::Configuration.lookup = :yahoo
11
11
 
12
12
  ENGINE_PATH = File.expand_path('../..', __FILE__) unless defined? ENGINE_PATH
13
- Dir["#{ENGINE_PATH}/lib/pdf/**/*.rb"].each { |f| p f; require f }
13
+ Dir["#{ENGINE_PATH}/lib/pdf/**/*.rb"].each { |f| require f }
14
14
  Dir["#{ENGINE_PATH}/lib/support/**/*.rb"].each { |f| require f }
@@ -1,3 +1,3 @@
1
1
  module Medivo
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  module Medivo
2
2
  class PdfGroup
3
+
3
4
  def initialize
4
5
  @pdfs = []
5
6
  end
@@ -7,8 +8,7 @@ module Medivo
7
8
  def self.create(&block)
8
9
  raise "need to pass a block do create" unless block_given?
9
10
  pdf_group = PdfGroup.new
10
- yield pdf_group
11
- # combine the pdfs
11
+ pdf_group.instance_eval &block
12
12
  pdf_group.pdf
13
13
  end
14
14
 
@@ -30,12 +30,17 @@ module Medivo
30
30
  @pdfs << pdf
31
31
  end
32
32
 
33
+ def static_pdf(path)
34
+ @pdfs << File.new(path)
35
+ end
36
+
33
37
  ##
34
38
  # Combines the PDFs
35
39
  def pdf
36
40
  pdf = Tempfile.new('pdf', :encoding => 'ascii-8bit')
37
41
  args = [@pdfs.collect(&:path), 'cat', 'output', pdf.path].flatten
38
42
  system 'pdftk', *args
43
+ pdf.close
39
44
  pdf
40
45
  end
41
46
  end
@@ -2161,3 +2161,105 @@ Started GET "/medivo/labs/appointment_data?utf8=%E2%9C%93&appointment_date=11%2F
2161
2161
  Processing by Medivo::LabsController#appointment_data as JS
2162
2162
  Parameters: {"utf8"=>"✓", "appointment_date"=>"11/07/2011", "lab_code"=>"22974", "commit"=>"Search for appointments"}
2163
2163
  Completed 200 OK in 0ms (Views: 0.1ms)
2164
+
2165
+
2166
+ Started GET "/labs/lab_search?zip_code=90210" for 127.0.0.1 at 2011-11-04 15:59:56 -0400
2167
+ Processing by LabsController#lab_search as HTML
2168
+ Parameters: {"zip_code"=>"90210"}
2169
+ Rendered labs/search.html.haml within layouts/application (10.8ms)
2170
+ Compiled medivo/lab_appointment/handlers.js (166ms) (pid 50391)
2171
+ Compiled medivo/lab_appointment/application.js (50ms) (pid 50391)
2172
+ Compiled application.js (8ms) (pid 50391)
2173
+ Completed 200 OK in 1356ms (Views: 266.8ms)
2174
+
2175
+
2176
+ Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2177
+ Served asset /application.css - 304 Not Modified (0ms)
2178
+
2179
+
2180
+ Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2181
+ Served asset /jquery.js - 304 Not Modified (0ms)
2182
+
2183
+
2184
+ Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2185
+ Served asset /jquery_ujs.js - 304 Not Modified (0ms)
2186
+
2187
+
2188
+ Started GET "/assets/medivo/handlebars.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2189
+ Served asset /medivo/handlebars.js - 304 Not Modified (0ms)
2190
+
2191
+
2192
+ Started GET "/assets/medivo/helpers.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2193
+ Served asset /medivo/helpers.js - 304 Not Modified (0ms)
2194
+
2195
+
2196
+ Started GET "/assets/medivo/models.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2197
+ Served asset /medivo/models.js - 304 Not Modified (0ms)
2198
+
2199
+
2200
+ Started GET "/assets/medivo/lab_list/models.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2201
+ Served asset /medivo/lab_list/models.js - 304 Not Modified (0ms)
2202
+
2203
+
2204
+ Started GET "/assets/medivo/views.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2205
+ Served asset /medivo/views.js - 304 Not Modified (0ms)
2206
+
2207
+
2208
+ Started GET "/assets/medivo/lab_list/views.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2209
+ Served asset /medivo/lab_list/views.js - 304 Not Modified (0ms)
2210
+
2211
+
2212
+ Started GET "/assets/medivo/lab_list/handlers.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2213
+ Served asset /medivo/lab_list/handlers.js - 304 Not Modified (0ms)
2214
+
2215
+
2216
+ Started GET "/assets/medivo/lab_list/application.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2217
+ Served asset /medivo/lab_list/application.js - 304 Not Modified (0ms)
2218
+
2219
+
2220
+ Started GET "/assets/medivo/lab_list/sample/show_labs.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2221
+ Served asset /medivo/lab_list/sample/show_labs.js - 304 Not Modified (0ms)
2222
+
2223
+
2224
+ Started GET "/assets/medivo/date.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2225
+ Served asset /medivo/date.js - 304 Not Modified (0ms)
2226
+
2227
+
2228
+ Started GET "/assets/medivo/lab_appointment/models.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2229
+ Served asset /medivo/lab_appointment/models.js - 304 Not Modified (0ms)
2230
+
2231
+
2232
+ Started GET "/assets/medivo/lab_appointment/views.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2233
+ Served asset /medivo/lab_appointment/views.js - 304 Not Modified (0ms)
2234
+
2235
+
2236
+ Started GET "/assets/medivo/lab_appointment/handlers.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2237
+ Served asset /medivo/lab_appointment/handlers.js - 200 OK (2ms)
2238
+
2239
+
2240
+ Started GET "/assets/medivo/lab_appointment/application.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2241
+ Served asset /medivo/lab_appointment/application.js - 200 OK (4ms)
2242
+
2243
+
2244
+ Started GET "/assets/medivo/lab_appointment/sample/show_appointments.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2245
+ Served asset /medivo/lab_appointment/sample/show_appointments.js - 304 Not Modified (0ms)
2246
+
2247
+
2248
+ Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2011-11-04 15:59:57 -0400
2249
+ Served asset /application.js - 200 OK (0ms)
2250
+
2251
+
2252
+ Started GET "/assets/medivo/markerA.png" for 127.0.0.1 at 2011-11-04 15:59:58 -0400
2253
+ Served asset /medivo/markerA.png - 304 Not Modified (0ms)
2254
+
2255
+
2256
+ Started GET "/assets/medivo/markerB.png" for 127.0.0.1 at 2011-11-04 15:59:58 -0400
2257
+ Served asset /medivo/markerB.png - 304 Not Modified (0ms)
2258
+
2259
+
2260
+ Started GET "/assets/medivo/markerC.png" for 127.0.0.1 at 2011-11-04 15:59:58 -0400
2261
+ Served asset /medivo/markerC.png - 304 Not Modified (0ms)
2262
+
2263
+
2264
+ Started GET "/assets/medivo/arrow.png" for 127.0.0.1 at 2011-11-04 15:59:58 -0400
2265
+ Served asset /medivo/arrow.png - 304 Not Modified (0ms)
Binary file
@@ -5,38 +5,68 @@ describe Medivo::PdfGroup do
5
5
  it "#variable_fields" do
6
6
  name = "Duderoni"
7
7
  path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf"
8
- pdf = Medivo::PdfGroup.create do |pdf|
9
- pdf.variable_fields(path, {:patient_name=>name})
8
+ pdf = Medivo::PdfGroup.create do
9
+ variable_fields(path, {:patient_name=>name})
10
10
  end
11
- text = pdf_to_text(pdf.read)
11
+ text = pdf_to_text(pdf)
12
12
  text.should =~ /#{name}/
13
13
  end
14
14
 
15
15
  it "#lab_requisition" do
16
- reqiuisition_number = 170420
17
- order = Medivo::Order.new(:requisition_number=> reqiuisition_number)
18
- stub_request(:get, "test:test@test.medivo.com/customers/#{order.requisition_id}.xml?include=requisition").
16
+ requisition_number = 170420
17
+ stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_number}.xml?include=requisition").
19
18
  to_return(:body => File.read("#{ENGINE_PATH}/spec/fixtures/lc_order_with_requisition.xml"))
20
19
 
21
- pdf = Medivo::PdfGroup.create do |pdf|
22
- pdf.lab_requisition(reqiuisition_number)
20
+ pdf = Medivo::PdfGroup.create do
21
+ lab_requisition(requisition_number)
23
22
  end
24
23
 
25
- text = pdf_to_text(pdf.read)
26
- text.should match /Account #:111111111 Req\/Control #:170420/
24
+ text = pdf_to_text(pdf)
25
+ text.should match "Account #:111111111 Req\/Control #:#{requisition_number}"
27
26
  end
28
27
 
29
28
  it "#lab_result" do
30
- reqiuisition_number = 170420
31
- order = Medivo::Order.new(:requisition_number=>reqiuisition_number)
32
- stub_request(:get, "test:test@test.medivo.com/customers/#{order.requisition_id}.xml?include=reconciled_results").
29
+ requisition_number = 170420
30
+ stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_number}.xml?include=reconciled_results").
33
31
  to_return(:body => File.read(("#{ENGINE_PATH}/spec/fixtures/lc_order_with_positive_results.xml")))
34
32
 
35
- pdf = Medivo::PdfGroup.create do |pdf|
36
- pdf.lab_result(reqiuisition_number)
33
+ pdf = Medivo::PdfGroup.create do
34
+ lab_result(requisition_number)
37
35
  end
38
36
 
39
- text = pdf_to_text(pdf.read)
37
+ text = pdf_to_text(pdf)
40
38
  text.should match /COLLECTED:2011-09-06 RECEIVED:2011-09-06 REPORTED:2011-09-06/
41
39
  end
40
+
41
+ it "#static_pdf" do
42
+ path = "#{ENGINE_PATH}/spec/fixtures/result_faq.pdf"
43
+ pdf = Medivo::PdfGroup.create do
44
+ static_pdf(path)
45
+ end
46
+ #open('/tmp/test.pdf', 'wb+') { |f| f.write pdf.read }
47
+ text = pdf_to_text(pdf)
48
+ text.should match /Q: What does a positive result mean/
49
+ end
50
+
51
+ it "handles a combination of pdfs" do
52
+ name = "Duderoni"
53
+ cover_letter_path = "#{ENGINE_PATH}/spec/fixtures/negative_results.pdf"
54
+
55
+ requisition_number = 170420
56
+ stub_request(:get, "test:test@test.medivo.com/customers/#{requisition_number}.xml?include=requisition").
57
+ to_return(:body => File.read("#{ENGINE_PATH}/spec/fixtures/lc_order_with_requisition.xml"))
58
+
59
+ faq_path = "#{ENGINE_PATH}/spec/fixtures/result_faq.pdf"
60
+
61
+ pdf = Medivo::PdfGroup.create do
62
+ variable_fields(cover_letter_path, {:patient_name=>name})
63
+ lab_requisition(requisition_number)
64
+ static_pdf(faq_path)
65
+ end
66
+
67
+ text = pdf_to_text(pdf)
68
+ text.should match /#{name}/
69
+ text.should match /Q: What does a positive result mean/
70
+ text.should match /Account #:111111111 Req\/Control #:#{requisition_number}/
71
+ end
42
72
  end
@@ -4,12 +4,7 @@ class String
4
4
  end
5
5
  end
6
6
 
7
- def pdf_to_text(pdf_stream)
8
- file = Tempfile.new('pdf', :encoding => 'ascii-8bit')
9
- file.write pdf_stream
10
- file.close
7
+ def pdf_to_text(file)
11
8
  pdf = PDF::Toolkit.open(file)
12
- pdf.to_text.read
13
- ensure
14
- file.unlink
9
+ pdf.to_text.read.force_encoding('ascii-8bit')
15
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-04 00:00:00.000000000 -04:00
12
+ date: 2011-11-05 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2173831600 !ruby/object:Gem::Requirement
17
+ requirement: &2158570100 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2173831600
25
+ version_requirements: *2158570100
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jquery-rails
28
- requirement: &2173831180 !ruby/object:Gem::Requirement
28
+ requirement: &2158569660 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2173831180
36
+ version_requirements: *2158569660
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-script
39
- requirement: &2173830700 !ruby/object:Gem::Requirement
39
+ requirement: &2158569200 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2173830700
47
+ version_requirements: *2158569200
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: haml-rails
50
- requirement: &2173830280 !ruby/object:Gem::Requirement
50
+ requirement: &2158568760 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2173830280
58
+ version_requirements: *2158568760
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: geocoder
61
- requirement: &2173829840 !ruby/object:Gem::Requirement
61
+ requirement: &2158568320 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2173829840
69
+ version_requirements: *2158568320
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
- requirement: &2173829420 !ruby/object:Gem::Requirement
72
+ requirement: &2158567880 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *2173829420
80
+ version_requirements: *2158567880
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: pdf-toolkit
83
- requirement: &2173828980 !ruby/object:Gem::Requirement
83
+ requirement: &2158567440 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *2173828980
91
+ version_requirements: *2158567440
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: pdfkit
94
- requirement: &2173828540 !ruby/object:Gem::Requirement
94
+ requirement: &2158567020 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: '0'
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *2173828540
102
+ version_requirements: *2158567020
103
103
  description: Use the medivo platform to find lab locations, make labcorp appointments,
104
104
  place lab orders
105
105
  email:
@@ -262,6 +262,7 @@ files:
262
262
  - spec/fixtures/lc_order_with_positive_results.xml
263
263
  - spec/fixtures/lc_order_with_requisition.xml
264
264
  - spec/fixtures/negative_results.pdf
265
+ - spec/fixtures/result_faq.pdf
265
266
  - spec/fixtures/valid_uhc_order.xml
266
267
  - spec/lib/fdf_generator_spec.rb
267
268
  - spec/lib/pdf_generator_spec.rb
@@ -289,7 +290,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
289
290
  version: '0'
290
291
  segments:
291
292
  - 0
292
- hash: 2469472185808359
293
+ hash: -549547875535863151
293
294
  required_rubygems_version: !ruby/object:Gem::Requirement
294
295
  none: false
295
296
  requirements:
@@ -298,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
299
  version: '0'
299
300
  segments:
300
301
  - 0
301
- hash: 2469472185808359
302
+ hash: -549547875535863151
302
303
  requirements: []
303
304
  rubyforge_project:
304
305
  rubygems_version: 1.6.2
@@ -403,6 +404,7 @@ test_files:
403
404
  - spec/fixtures/lc_order_with_positive_results.xml
404
405
  - spec/fixtures/lc_order_with_requisition.xml
405
406
  - spec/fixtures/negative_results.pdf
407
+ - spec/fixtures/result_faq.pdf
406
408
  - spec/fixtures/valid_uhc_order.xml
407
409
  - spec/lib/fdf_generator_spec.rb
408
410
  - spec/lib/pdf_generator_spec.rb