medivo 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/app/controllers/medivo/labs_controller.rb +3 -5
  2. data/app/models/medivo/appointment.rb +21 -4
  3. data/lib/medivo/version.rb +1 -1
  4. data/lib/pdf/medivo/pdf_generator.rb +2 -0
  5. data/lib/pdf/medivo/pdf_group.rb +17 -15
  6. data/spec/dummy/app/views/labs/search.html.haml +1 -1
  7. data/spec/dummy/config/medivo/appointment_resource.yml +1 -0
  8. data/spec/dummy/log/development.log +1103 -0
  9. data/spec/dummy/tmp/cache/assets/C46/F00/sprockets%2F2281d588b540056c5a7306c32a3761b9 +0 -0
  10. data/spec/dummy/tmp/cache/assets/C6C/8D0/sprockets%2F2f423a28516973330a94ad121151f3bf +0 -0
  11. data/spec/dummy/tmp/cache/assets/C81/D00/sprockets%2F64f056bd752d271308a86a6f865b1911 +0 -0
  12. data/spec/dummy/tmp/cache/assets/CB4/BD0/sprockets%2F3378f27c0d4f5e6d708665b22707a31f +0 -0
  13. data/spec/dummy/tmp/cache/assets/CC3/EF0/sprockets%2F453b504c1f8f374578636f699eaa455d +0 -0
  14. data/spec/dummy/tmp/cache/assets/CD8/DA0/sprockets%2F622aa5281d15503829a5f7a0bf56fc29 +0 -0
  15. data/spec/dummy/tmp/cache/assets/CDD/820/sprockets%2Fb28231960c7ac62eff9048e702a29c70 +0 -0
  16. data/spec/dummy/tmp/cache/assets/CEC/EF0/sprockets%2F4b24a74018f693c06088bd52f8cc9f86 +0 -0
  17. data/spec/dummy/tmp/cache/assets/CEE/250/sprockets%2F96688f33f2f8aa261bf6701c1d6d7575 +0 -0
  18. data/spec/dummy/tmp/cache/assets/D07/6B0/sprockets%2F69a2df619ff14da071309dac4196400e +0 -0
  19. data/spec/dummy/tmp/cache/assets/D1B/820/sprockets%2F92a83e15913997b3d9ac7ed437b1e44c +0 -0
  20. data/spec/dummy/tmp/cache/assets/D20/F10/sprockets%2Fb2e907e4faa85fe755f4439e3b229088 +0 -0
  21. data/spec/dummy/tmp/cache/assets/D29/000/sprockets%2F61a10ddf57f1129c02a1049bfed6e007 +0 -0
  22. data/spec/dummy/tmp/cache/assets/D2C/F80/sprockets%2F399f6d5eb273936af7ff8f35a77c5037 +0 -0
  23. data/spec/dummy/tmp/cache/assets/D30/920/sprockets%2Fcc4603fc6441ca421a7d02886a81ab9d +0 -0
  24. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  25. data/spec/dummy/tmp/cache/assets/D36/870/sprockets%2Fce9e887568de873b133ae43d7c977f68 +0 -0
  26. data/spec/dummy/tmp/cache/assets/D41/250/sprockets%2F7b3c4426715dcd1feedc4a95e5444256 +0 -0
  27. data/spec/dummy/tmp/cache/assets/D45/320/sprockets%2Fc50ff379a1bdf1dd4d22249058749cf6 +0 -0
  28. data/spec/dummy/tmp/cache/assets/D4C/7A0/sprockets%2Fbc635c7b186d1ef5178f4ed3722d868b +0 -0
  29. data/spec/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  30. data/spec/dummy/tmp/cache/assets/D55/ED0/sprockets%2F0f673e42e816c6fe5b66a5c96f896f1a +0 -0
  31. data/spec/dummy/tmp/cache/assets/D5D/3E0/sprockets%2F63fea6cc142b5f02da93bf81e70b2116 +0 -0
  32. data/spec/dummy/tmp/cache/assets/D60/030/sprockets%2Ffc9485f617fc5e9b8918755d2e08ecc6 +0 -0
  33. data/spec/dummy/tmp/cache/assets/D64/C50/sprockets%2F22ee6fb2ab1ea9694ac7f0f41a406094 +0 -0
  34. data/spec/dummy/tmp/cache/assets/D65/6D0/sprockets%2F3ce07ca1958d7ab3e80c4b3e0d24088c +0 -0
  35. data/spec/dummy/tmp/cache/assets/D69/130/sprockets%2Fbaa4ec50a34ce938c986612c2a47a64e +0 -0
  36. data/spec/dummy/tmp/cache/assets/D74/9A0/sprockets%2F0ca4e6e833c72156fc7e7d5f007d9ce3 +0 -0
  37. data/spec/dummy/tmp/cache/assets/D76/720/sprockets%2F88d8aa1d2fb41ce79b8ec4150ea74748 +0 -0
  38. data/spec/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  39. data/spec/dummy/tmp/cache/assets/D88/2C0/sprockets%2F452ab3ebb1912cf1c2ba617eec52a718 +0 -0
  40. data/spec/dummy/tmp/cache/assets/D9C/F50/sprockets%2F224e78bb9e1c414a2d518a3aaffd6f77 +0 -0
  41. data/spec/dummy/tmp/cache/assets/D9F/260/sprockets%2Fa3e040f83c30e4bbc1c79ffae57909e6 +0 -0
  42. data/spec/dummy/tmp/cache/assets/DA1/640/sprockets%2F91874cbba5e63cd19d6a7bd3c8362dc4 +0 -0
  43. data/spec/dummy/tmp/cache/assets/DC1/230/sprockets%2F3a36cd467bdce1914a2b7af4ed4114cf +0 -0
  44. data/spec/dummy/tmp/cache/assets/DCE/E80/sprockets%2Fc71ec62157b9cc7aabfc030955cef87b +0 -0
  45. data/spec/dummy/tmp/cache/assets/DD1/FD0/sprockets%2Fa531f33dc9c5852d39d64a9eda44dacf +0 -0
  46. data/spec/dummy/tmp/cache/assets/DD4/2B0/sprockets%2Fef214a63f29afe7f3cbffc65af943108 +0 -0
  47. data/spec/dummy/tmp/cache/assets/DFC/420/sprockets%2F502e2c683d1aaad6ac88966ffc4d2ade +0 -0
  48. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  49. data/spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4 +0 -0
  50. data/spec/dummy/tmp/image_path_fb5f3a59200b_1320622886.pdf +0 -0
  51. data/spec/dummy/tmp/pids/server.pid +1 -0
  52. data/spec/lib/pdf_generator_spec.rb +43 -34
  53. data/spec/lib/pdf_group_spec.rb +18 -10
  54. data/spec/spec_helper.rb +1 -1
  55. data/spec/support/helper.rb +10 -0
  56. metadata +23 -19
@@ -0,0 +1 @@
1
+ 65439
@@ -2,49 +2,58 @@ require 'spec_helper'
2
2
 
3
3
  describe Medivo::PdfGenerator do
4
4
 
5
- it "#variable_fields generates pdf by filling in the variables" do
6
- name = "Duderoni"
7
- path = medivo_fixture_path "negative_results.pdf"
8
- pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name})
9
- text = pdf_to_text(pdf_file)
10
- text.should match name
11
- end
12
-
13
- it "#variable_fields generates pdf by filling in the variables" do
14
-
15
- fields = {
16
- :full_name => 'my full name',
17
- :address => 'my address',
18
- :first_name => 'me!!!!!',
19
- :sched_date => 'todays date',
20
- :app_date => 'my appt date',
21
- :app_time => 'my appt time',
22
- :lab_name => 'LabCorp',
23
- :lab_address => 'the lab address',
24
- :order_number => 'the lab id'
25
- }
5
+ describe "#variable_fields generates pdf by filling in the variables" do
6
+
7
+ it "for negative results cover letter" do
8
+ name = "Duderoni"
9
+ path = medivo_fixture_path "negative_results.pdf"
10
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, {:patient_name=>name})
11
+ text = pdf_to_text(pdf_file)
12
+ text.should match name
13
+ pdf_file.unlink
14
+ end
26
15
 
27
- path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
28
- pdf_file = Medivo::PdfGenerator.variable_fields(path, fields)
29
- text = pdf_to_text(pdf_file)
30
- fields.values.each do |value|
31
- text.should match value
16
+ it "for uhc requisition cover letter" do
17
+
18
+ fields = {
19
+ :full_name => 'my full name',
20
+ :address => 'my address',
21
+ :first_name => 'me!!!!!',
22
+ :sched_date => 'todays date',
23
+ :app_date => 'my appt date',
24
+ :app_time => 'my appt time',
25
+ :lab_name => 'LabCorp',
26
+ :lab_address => 'the lab address',
27
+ :order_number => 'the lab id'
28
+ }
29
+
30
+ path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
31
+ pdf_file = Medivo::PdfGenerator.variable_fields(path, fields)
32
+
33
+ text = pdf_to_text(pdf_file)
34
+ fields.values.each do |value|
35
+ text.should match value
36
+ end
37
+ pdf_file.unlink
32
38
  end
33
39
  end
34
40
 
35
-
36
- it "#variable_fields accepts image param and stamps image onto pdf" do
41
+ it "#variable_fields_with_images accepts image param and stamps image onto pdf" do
37
42
  md = <<-MD
38
- Catherine E. Palmier, M.D.
39
- Chief Medical Officer,
40
- UnitedHealthcare Clinical Services
41
- Southeast Region
43
+ Catherine E. Palmier, M.D.
44
+ Chief Medical Officer,
45
+ UnitedHealthcare Clinical Services
46
+ Southeast Region
42
47
  MD
43
48
 
44
49
  path = medivo_fixture_path "uhc_requisition_cover_letter.pdf"
45
50
  img_path = medivo_fixture_path "Southeast.jpg"
46
- pdf_file = Medivo::PdfGenerator.variable_fields_with_images(path, {:director_name=>md}, [{:path=> img_path, :at=> [0, 120]}])
47
- #open('/tmp/test.pdf', 'wb+') { |f| f.write pdf_file.read }
51
+ pdf_file = Medivo::PdfGenerator.variable_fields_with_images(
52
+ path,
53
+ {:director_name=>md},
54
+ [{:path=> img_path, :at=> [30, 120]}]
55
+ )
56
+ show_me_the_pdf(pdf_file, '/tmp/test.pdf')
48
57
  text = pdf_to_text(pdf_file)
49
58
  text.should match "Catherine E. Palmier, M.D."
50
59
  pdf_file.unlink
@@ -2,14 +2,22 @@ require 'spec_helper'
2
2
 
3
3
  describe Medivo::PdfGroup do
4
4
 
5
+ it "can call read on the pdf after creating it" do
6
+ path = medivo_fixture_path "result_faq.pdf"
7
+ pdf_group = Medivo::PdfGroup.create do
8
+ static_pdf(path)
9
+ end
10
+ expect { pdf_group.read }.should_not raise_error
11
+ end
12
+
5
13
  it "#variable_fields" do
6
14
  name = "Duderoni"
7
15
  o = OpenStruct.new(:name=>name)
8
16
  path = medivo_fixture_path "negative_results.pdf"
9
- pdf = Medivo::PdfGroup.create do
17
+ pdf_group = Medivo::PdfGroup.create do
10
18
  variable_fields(path, {:patient_name=>o.name})
11
19
  end
12
- text = pdf_to_text(pdf)
20
+ text = pdf_to_text(pdf_group.pdf)
13
21
  text.should match name
14
22
  end
15
23
 
@@ -17,11 +25,11 @@ describe Medivo::PdfGroup do
17
25
  requisition_id = 170420
18
26
  stub_order_requisition(requisition_id, "lc_order_with_requisition.xml")
19
27
 
20
- pdf = Medivo::PdfGroup.create do
28
+ pdf_group = Medivo::PdfGroup.create do
21
29
  lab_requisition(requisition_id)
22
30
  end
23
31
 
24
- text = pdf_to_text(pdf)
32
+ text = pdf_to_text(pdf_group.pdf)
25
33
  text.should match "Account #:111111111 Req\/Control #:#{requisition_id}"
26
34
  end
27
35
 
@@ -29,21 +37,21 @@ describe Medivo::PdfGroup do
29
37
  requisition_id = 170420
30
38
  stub_order_result(requisition_id, "lc_order_with_positive_results.xml")
31
39
 
32
- pdf = Medivo::PdfGroup.create do
40
+ pdf_group = Medivo::PdfGroup.create do
33
41
  lab_result(requisition_id)
34
42
  end
35
43
 
36
- text = pdf_to_text(pdf)
44
+ text = pdf_to_text(pdf_group.pdf)
37
45
  text.should match "COLLECTED:2011-09-06 RECEIVED:2011-09-06 REPORTED:2011-09-06"
38
46
  end
39
47
 
40
48
  it "#static_pdf" do
41
49
  path = medivo_fixture_path "result_faq.pdf"
42
- pdf = Medivo::PdfGroup.create do
50
+ pdf_group = Medivo::PdfGroup.create do
43
51
  static_pdf(path)
44
52
  end
45
53
 
46
- text = pdf_to_text(pdf)
54
+ text = pdf_to_text(pdf_group.pdf)
47
55
  text.should match "Q: What does a positive result mean"
48
56
  end
49
57
 
@@ -56,13 +64,13 @@ describe Medivo::PdfGroup do
56
64
 
57
65
  faq_path = medivo_fixture_path "result_faq.pdf"
58
66
 
59
- pdf = Medivo::PdfGroup.create do
67
+ pdf_group = Medivo::PdfGroup.create do
60
68
  variable_fields(cover_letter_path, {:patient_name=>name})
61
69
  lab_requisition(requisition_id)
62
70
  static_pdf(faq_path)
63
71
  end
64
72
  # open('/tmp/test.pdf', 'wb+') { |f| f.write pdf.read }
65
- text = pdf_to_text(pdf)
73
+ text = pdf_to_text(pdf_group.pdf)
66
74
  text.should match name
67
75
  text.should match "Account #:111111111 Req\/Control #:#{requisition_id}"
68
76
  text.should match "Q: What does a positive result mean"
data/spec/spec_helper.rb CHANGED
@@ -47,5 +47,5 @@ Spork.each_run do
47
47
  Dir["#{ENGINE_PATH}/lib/support/**/*.rb"].each { |f| load f }
48
48
  Dir["#{ENGINE_PATH}/lib/pdf/**/*.rb"].each { |f| load f }
49
49
  load "#{ENGINE_PATH}/config/routes.rb"
50
- load "#{ENGINE_PATH}/spec/support/blueprints.rb"
50
+ Dir["#{ENGINE_PATH}/spec/support/**/*.rb"].each { |f| load f }
51
51
  end
@@ -19,6 +19,16 @@ module Medivo::Spec
19
19
  text
20
20
  end
21
21
 
22
+ ##
23
+ # For seeing the pdf yourself. writes to file so you can open it.
24
+ # All the pdf's are created with tempfiles so you have to write to
25
+ # a real file to see it.
26
+ def show_me_the_pdf(pdf_file, file_name)
27
+ # tmp files auto closed by me, so reopen again to read it
28
+ pdf_file.open
29
+ open(file_name, 'wb+') { |f| f.write pdf_file.read }
30
+ end
31
+
22
32
  FIXTURE_PATH = File.expand_path('../../fixtures', __FILE__) unless defined? FIXTURE_PATH
23
33
 
24
34
  def medivo_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.11
4
+ version: 0.1.12
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: &2152623820 !ruby/object:Gem::Requirement
17
+ requirement: &2156714880 !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: *2152623820
25
+ version_requirements: *2156714880
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jquery-rails
28
- requirement: &2152623400 !ruby/object:Gem::Requirement
28
+ requirement: &2156711280 !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: *2152623400
36
+ version_requirements: *2156711280
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-script
39
- requirement: &2152622940 !ruby/object:Gem::Requirement
39
+ requirement: &2156706180 !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: *2152622940
47
+ version_requirements: *2156706180
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: haml-rails
50
- requirement: &2152622520 !ruby/object:Gem::Requirement
50
+ requirement: &2156703620 !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: *2152622520
58
+ version_requirements: *2156703620
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: geocoder
61
- requirement: &2152622020 !ruby/object:Gem::Requirement
61
+ requirement: &2156701340 !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: *2152622020
69
+ version_requirements: *2156701340
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
- requirement: &2152621600 !ruby/object:Gem::Requirement
72
+ requirement: &2156699220 !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: *2152621600
80
+ version_requirements: *2156699220
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: pdfkit
83
- requirement: &2152621180 !ruby/object:Gem::Requirement
83
+ requirement: &2156674140 !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: *2152621180
91
+ version_requirements: *2156674140
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: prawn
94
- requirement: &2152620760 !ruby/object:Gem::Requirement
94
+ requirement: &2156671240 !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: *2152620760
102
+ version_requirements: *2156671240
103
103
  description: Use the medivo platform to find lab locations, make labcorp appointments,
104
104
  place lab orders
105
105
  email:
@@ -258,6 +258,8 @@ files:
258
258
  - spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
259
259
  - spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4
260
260
  - spec/dummy/tmp/cache/assets/E59/D50/sprockets%2Fbe1cc4d9b0efb617e58baa16dd1dee58
261
+ - spec/dummy/tmp/image_path_fb5f3a59200b_1320622886.pdf
262
+ - spec/dummy/tmp/pids/server.pid
261
263
  - spec/fixtures/lc_order_with_normal_results.xml
262
264
  - spec/fixtures/lc_order_with_positive_results.xml
263
265
  - spec/fixtures/lc_order_with_requisition.xml
@@ -292,7 +294,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
292
294
  version: '0'
293
295
  segments:
294
296
  - 0
295
- hash: 2347708548636800452
297
+ hash: 4020770003589116663
296
298
  required_rubygems_version: !ruby/object:Gem::Requirement
297
299
  none: false
298
300
  requirements:
@@ -301,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
303
  version: '0'
302
304
  segments:
303
305
  - 0
304
- hash: 2347708548636800452
306
+ hash: 4020770003589116663
305
307
  requirements: []
306
308
  rubyforge_project:
307
309
  rubygems_version: 1.6.2
@@ -401,6 +403,8 @@ test_files:
401
403
  - spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
402
404
  - spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4
403
405
  - spec/dummy/tmp/cache/assets/E59/D50/sprockets%2Fbe1cc4d9b0efb617e58baa16dd1dee58
406
+ - spec/dummy/tmp/image_path_fb5f3a59200b_1320622886.pdf
407
+ - spec/dummy/tmp/pids/server.pid
404
408
  - spec/fixtures/lc_order_with_normal_results.xml
405
409
  - spec/fixtures/lc_order_with_positive_results.xml
406
410
  - spec/fixtures/lc_order_with_requisition.xml