medivo 0.1.19 → 0.1.20

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.
@@ -1,3 +1,3 @@
1
1
  module Medivo
2
- VERSION = "0.1.19"
2
+ VERSION = "0.1.20"
3
3
  end
@@ -28,7 +28,7 @@ module Medivo
28
28
  ##
29
29
  # file_path String path to pdf file with variable fields
30
30
  # variables Hash the hash of variables to fill in
31
- # images Array of image info like:
31
+ # image_data Array of image info like:
32
32
  # [ {:path=>'/absolute/path/to/image1.jpg', :options=>{ :at=>[x_pos, y_pos]} },
33
33
  # {:path=>'/absolute/path/to/image2.jpg', :options=>{ :at=>[20, 800], :width=>20, :height=>40} }
34
34
  # ]
@@ -37,12 +37,12 @@ module Medivo
37
37
  #
38
38
  # NOTE: need to create tmp dir in home directory for temporary image files
39
39
  #
40
- def self.variable_fields_with_images(file_path, variables, images=[])
40
+ def self.variable_fields_with_images(file_path, variables, image_data=[])
41
41
  content_pdf = variable_fields(file_path, variables)
42
42
  image_path = "#{ENV['HOME']}/tmp/image_path_#{SecureRandom.hex(6)}_#{Time.now.to_i}.pdf"
43
43
  img_pdf = Prawn::Document.generate(image_path) do |pdf|
44
- images.each do |img_info|
45
- pdf.image img_info[:path], img_info[:options]
44
+ image_data.each do |data|
45
+ pdf.image data[:path], data[:options]
46
46
  end
47
47
  end
48
48
  pdf = tmp_pdf do |pdf|
@@ -28,6 +28,10 @@ module Medivo
28
28
  @pdfs << PdfGenerator.variable_fields(file_path, variables)
29
29
  end
30
30
 
31
+ def variable_fields_with_images(file_path, variables, image_data)
32
+ @pdfs << PdfGenerator.variable_fields_with_images(file_path, variables, image_data)
33
+ end
34
+
31
35
  def lab_requisition(requisition_id)
32
36
  pdf_bytes = Medivo::Order.pdf_requisition(requisition_id)
33
37
  @pdfs << PdfGenerator.tmp_pdf { |pdf| pdf.write pdf_bytes }
@@ -47,11 +47,11 @@ Southeast Region
47
47
 
48
48
  it "#variable_fields_with_images accepts image param and stamps image onto pdf" do
49
49
  path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
50
- img_path = medivo_fixture_path "Southeast.jpg"
50
+ image_path = medivo_fixture_path "Southeast.jpg"
51
51
  pdf_file = Medivo::PdfGenerator.variable_fields_with_images(
52
52
  path,
53
53
  uhc_cover_letter_fields,
54
- [{:path=> img_path, :options=>{:at=> [40, 100], :width=>180, :height=>28}}]
54
+ [{:path=> image_path, :options=>{:at=> [40, 100], :width=>180, :height=>28}}]
55
55
  )
56
56
 
57
57
  show_me_the_pdf(pdf_file, '/tmp/test.pdf')
@@ -22,6 +22,23 @@ describe Medivo::PdfGroup do
22
22
  pdf_group.close
23
23
  end
24
24
 
25
+ it "#variable_fields_with_images" do
26
+ name = "Duderoni"
27
+ path = medivo_fixture_path "hepc_negative_results.pdf"
28
+ image_path = medivo_fixture_path "Southeast.jpg"
29
+ image_data = [{:path=> image_path, :options=>{:at=> [40, 100], :width=>180, :height=>28}}]
30
+
31
+ pdf_group = Medivo::PdfGroup.create do
32
+ variable_fields_with_images(path, {:patient_name=>name}, image_data)
33
+ end
34
+
35
+ show_me_the_pdf(pdf_group.pdf, '/tmp/test.pdf')
36
+
37
+ text = pdf_to_text(pdf_group.pdf)
38
+ text.should match name
39
+ pdf_group.close
40
+ end
41
+
25
42
 
26
43
  it "#lab_requisition" do
27
44
  requisition_id = 170420
@@ -24,11 +24,15 @@ module Medivo::Spec
24
24
  # All the pdf's are created with tempfiles so you have to write to
25
25
  # a real file to see it.
26
26
  def show_me_the_pdf(pdf_file, file_name)
27
- # tmp files auto closed by me, so reopen again to read it
27
+ # tmp files usually are kept closed, so reopen again to read it
28
28
  pdf_file.open
29
29
  open(file_name, 'wb+') { |f| f.write pdf_file.read }
30
30
  end
31
31
 
32
+ def show_me_the_pdf_stream(bytes, file_name)
33
+ open(file_name, 'wb+') { |f| f.write bytes }
34
+ end
35
+
32
36
  FIXTURE_PATH = File.expand_path('../../fixtures', __FILE__) unless defined? FIXTURE_PATH
33
37
  def medivo_fixture_path(file_name)
34
38
  "#{FIXTURE_PATH}/#{file_name}"
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.19
4
+ version: 0.1.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2152951920 !ruby/object:Gem::Requirement
17
+ requirement: &2173276280 !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: *2152951920
25
+ version_requirements: *2173276280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jquery-rails
28
- requirement: &2152951500 !ruby/object:Gem::Requirement
28
+ requirement: &2173275780 !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: *2152951500
36
+ version_requirements: *2173275780
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-script
39
- requirement: &2152951040 !ruby/object:Gem::Requirement
39
+ requirement: &2173275300 !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: *2152951040
47
+ version_requirements: *2173275300
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: haml-rails
50
- requirement: &2152950620 !ruby/object:Gem::Requirement
50
+ requirement: &2173274880 !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: *2152950620
58
+ version_requirements: *2173274880
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: geocoder
61
- requirement: &2152950200 !ruby/object:Gem::Requirement
61
+ requirement: &2173274460 !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: *2152950200
69
+ version_requirements: *2173274460
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
- requirement: &2152949700 !ruby/object:Gem::Requirement
72
+ requirement: &2173274020 !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: *2152949700
80
+ version_requirements: *2173274020
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: pdfkit
83
- requirement: &2152949280 !ruby/object:Gem::Requirement
83
+ requirement: &2173273600 !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: *2152949280
91
+ version_requirements: *2173273600
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: prawn
94
- requirement: &2152948860 !ruby/object:Gem::Requirement
94
+ requirement: &2173273180 !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: *2152948860
102
+ version_requirements: *2173273180
103
103
  description: Use the medivo platform to find lab locations, make labcorp appointments,
104
104
  place lab orders
105
105
  email:
@@ -298,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
298
  version: '0'
299
299
  segments:
300
300
  - 0
301
- hash: -978377392272491129
301
+ hash: -1955997495768441744
302
302
  required_rubygems_version: !ruby/object:Gem::Requirement
303
303
  none: false
304
304
  requirements:
@@ -307,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
307
  version: '0'
308
308
  segments:
309
309
  - 0
310
- hash: -978377392272491129
310
+ hash: -1955997495768441744
311
311
  requirements: []
312
312
  rubyforge_project:
313
313
  rubygems_version: 1.6.2